Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Support for trees of clocks served by one clock manager



Jared McNeill <jmcneill%invisible.ca@localhost> writes:

> Please update your patch to pass phandle to cc decode callback,
> otherwise it's on my TODO list but I can't make any commitments.

Here is the patch. I built a release successfully with it and also
tested it on my nanosoc (the only place where it has any real impact
currently) and on sunxi "just in case".

Regards,
 Aymeric

diff --git a/sys/arch/arm/broadcom/bcm2835_aux.c b/sys/arch/arm/broadcom/bcm2835_aux.c
index cd85374aa1ff..7c218cb089a8 100644
--- a/sys/arch/arm/broadcom/bcm2835_aux.c
+++ b/sys/arch/arm/broadcom/bcm2835_aux.c
@@ -52,7 +52,7 @@ __KERNEL_RCSID(0, "$NetBSD: bcm2835_aux.c,v 1.1 2017/12/10 21:38:26 skrll Exp $"
 static int	bcmaux_match(device_t, cfdata_t, void *);
 static void	bcmaux_attach(device_t, device_t, void *);
 
-static struct clk *bcmaux_decode(device_t, const void *, size_t);
+static struct clk *bcmaux_decode(device_t, int, const void *, size_t);
 
 static const struct fdtbus_clock_controller_func bcmaux_fdt_funcs = {
 	.decode = bcmaux_decode
@@ -154,10 +154,11 @@ bcmaux_attach(device_t parent, device_t self, void *aux)
 }
 
 static struct clk *
-bcmaux_decode(device_t dev, const void *data, size_t len)
+bcmaux_decode(device_t dev, int cc_phandle, const void *data, size_t len)
 {
 	struct bcmaux_softc * const sc = device_private(dev);
 	u_int clkid;
+	(void) cc_phandle;
 
 	if (len != 4)
 		return NULL;
diff --git a/sys/arch/arm/broadcom/bcm2835_cprman.c b/sys/arch/arm/broadcom/bcm2835_cprman.c
index fa24547b1988..40bdf4dc77fc 100644
--- a/sys/arch/arm/broadcom/bcm2835_cprman.c
+++ b/sys/arch/arm/broadcom/bcm2835_cprman.c
@@ -74,12 +74,13 @@ struct cprman_softc {
 
 
 static struct clk *
-cprman_decode(device_t dev, const void *data, size_t len)
+cprman_decode(device_t dev, int cc_phandle, const void *data, size_t len)
 {
 	struct cprman_softc * const sc = device_private(dev);
 	struct cprman_clk *clk;
 	const u_int *spec = data;
 	u_int id;
+	(void) cc_phandle;
 
 	if (len != 4)
 		return NULL;
diff --git a/sys/arch/arm/nvidia/tegra124_car.c b/sys/arch/arm/nvidia/tegra124_car.c
index 7f4b0d09b8e7..c19cf8be9a7e 100644
--- a/sys/arch/arm/nvidia/tegra124_car.c
+++ b/sys/arch/arm/nvidia/tegra124_car.c
@@ -53,7 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: tegra124_car.c,v 1.14 2017/07/21 01:01:22 jmcneill E
 static int	tegra124_car_match(device_t, cfdata_t, void *);
 static void	tegra124_car_attach(device_t, device_t, void *);
 
-static struct clk *tegra124_car_clock_decode(device_t, const void *, size_t);
+static struct clk *tegra124_car_clock_decode(device_t, int, const void *,
+					     size_t);
 
 static const struct fdtbus_clock_controller_func tegra124_car_fdtclock_funcs = {
 	.decode = tegra124_car_clock_decode
@@ -959,10 +960,12 @@ tegra124_car_clock_find_by_id(u_int clock_id)
 }
 
 static struct clk *
-tegra124_car_clock_decode(device_t dev, const void *data, size_t len)
+tegra124_car_clock_decode(device_t dev, int cc_phandle, const void *data,
+			  size_t len)
 {
 	struct tegra124_car_softc * const sc = device_private(dev);
 	struct tegra_clk *tclk;
+	(void) cc_phandle;
 
 	if (len != sc->sc_clock_cells * 4) {
 		return NULL;
diff --git a/sys/arch/arm/nvidia/tegra210_car.c b/sys/arch/arm/nvidia/tegra210_car.c
index b3f09b7daaa7..8bf68dd1b723 100644
--- a/sys/arch/arm/nvidia/tegra210_car.c
+++ b/sys/arch/arm/nvidia/tegra210_car.c
@@ -53,7 +53,8 @@ __KERNEL_RCSID(0, "$NetBSD: tegra210_car.c,v 1.18 2018/07/16 23:11:47 christos E
 static int	tegra210_car_match(device_t, cfdata_t, void *);
 static void	tegra210_car_attach(device_t, device_t, void *);
 
-static struct clk *tegra210_car_clock_decode(device_t, const void *, size_t);
+static struct clk *tegra210_car_clock_decode(device_t, int, const void *,
+					     size_t);
 
 static const struct fdtbus_clock_controller_func tegra210_car_fdtclock_funcs = {
 	.decode = tegra210_car_clock_decode
@@ -1069,10 +1070,12 @@ tegra210_car_clock_find_by_id(u_int clock_id)
 }
 
 static struct clk *
-tegra210_car_clock_decode(device_t dev, const void *data, size_t len)
+tegra210_car_clock_decode(device_t dev, int cc_phandle, const void *data,
+			  size_t len)
 {
 	struct tegra210_car_softc * const sc = device_private(dev);
 	struct tegra_clk *tclk;
+	(void) cc_phandle;
 
 	if (len != sc->sc_clock_cells * 4) {
 		return NULL;
diff --git a/sys/arch/arm/rockchip/rk_cru.c b/sys/arch/arm/rockchip/rk_cru.c
index a8ea8d77bf94..822ea8a3b2b7 100644
--- a/sys/arch/arm/rockchip/rk_cru.c
+++ b/sys/arch/arm/rockchip/rk_cru.c
@@ -91,10 +91,11 @@ static const struct fdtbus_reset_controller_func rk_cru_fdtreset_funcs = {
 };
 
 static struct clk *
-rk_cru_clock_decode(device_t dev, const void *data, size_t len)
+rk_cru_clock_decode(device_t dev, int cc_phandle, const void *data, size_t len)
 {
 	struct rk_cru_softc * const sc = device_private(dev);
 	struct rk_cru_clk *clk;
+	(void) cc_phandle;
 
 	if (len != 4)
 		return NULL;
diff --git a/sys/arch/arm/rockchip/rk_usb.c b/sys/arch/arm/rockchip/rk_usb.c
index 7e91f16a5fbc..8870b67b0d0f 100644
--- a/sys/arch/arm/rockchip/rk_usb.c
+++ b/sys/arch/arm/rockchip/rk_usb.c
@@ -183,9 +183,10 @@ static const struct clk_funcs rk_usb_clk_funcs = {
 };
 
 static struct clk *
-rk_usb_fdt_decode(device_t dev, const void *data, size_t len)
+rk_usb_fdt_decode(device_t dev, int cc_phandle, const void *data, size_t len)
 {
 	struct rk_usb_softc * const sc = device_private(dev);
+	(void) cc_phandle;
 
 	if (len != 0)
 		return NULL;
diff --git a/sys/arch/arm/samsung/exynos5410_clock.c b/sys/arch/arm/samsung/exynos5410_clock.c
index bc85b59d847a..a1b4822a46b6 100644
--- a/sys/arch/arm/samsung/exynos5410_clock.c
+++ b/sys/arch/arm/samsung/exynos5410_clock.c
@@ -45,7 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: exynos5410_clock.c,v 1.3 2018/07/02 20:24:55 jmcneil
 
 #include <dev/fdt/fdtvar.h>
 
-static struct clk *exynos5410_clock_decode(device_t, const void *, size_t);
+static struct clk *exynos5410_clock_decode(device_t, int, const void *, size_t);
 
 static const struct fdtbus_clock_controller_func exynos5410_car_fdtclock_funcs = {
 	.decode = exynos5410_clock_decode
@@ -549,9 +549,11 @@ exynos5410_clock_print(struct exynos5410_clock_softc *sc,
 }
 
 static struct clk *
-exynos5410_clock_decode(device_t dev, const void *data, size_t len)
+exynos5410_clock_decode(device_t dev, int cc_phandle, const void *data,
+			size_t len)
 {
 	struct exynos_clk *eclk;
+	(void) cc_phandle;
 
 	/* #clock-cells should be 1 */
 	if (len != 4) {
diff --git a/sys/arch/arm/samsung/exynos5422_clock.c b/sys/arch/arm/samsung/exynos5422_clock.c
index 926617c54bcc..48f28593c197 100644
--- a/sys/arch/arm/samsung/exynos5422_clock.c
+++ b/sys/arch/arm/samsung/exynos5422_clock.c
@@ -47,7 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: exynos5422_clock.c,v 1.12 2018/07/05 13:11:58 jmcnei
 
 #include <dev/fdt/fdtvar.h>
 
-static struct clk *exynos5422_clock_decode(device_t, const void *, size_t);
+static struct clk *exynos5422_clock_decode(device_t, int, const void *, size_t);
 
 static const struct fdtbus_clock_controller_func exynos5422_car_fdtclock_funcs = {
 	.decode = exynos5422_clock_decode
@@ -726,9 +726,11 @@ exynos5422_clock_print(struct exynos5422_clock_softc *sc,
 }
 
 static struct clk *
-exynos5422_clock_decode(device_t dev, const void *data, size_t len)
+exynos5422_clock_decode(device_t dev, int cc_phandle, const void *data,
+			size_t len)
 {
 	struct exynos_clk *eclk;
+	(void) cc_phandle;
 
 	/* #clock-cells should be 1 */
 	if (len != 4) {
diff --git a/sys/arch/arm/sunxi/sunxi_ccu.c b/sys/arch/arm/sunxi/sunxi_ccu.c
index 672627f5222a..d72178da6ac3 100644
--- a/sys/arch/arm/sunxi/sunxi_ccu.c
+++ b/sys/arch/arm/sunxi/sunxi_ccu.c
@@ -102,10 +102,12 @@ static const struct fdtbus_reset_controller_func sunxi_ccu_fdtreset_funcs = {
 };
 
 static struct clk *
-sunxi_ccu_clock_decode(device_t dev, const void *data, size_t len)
+sunxi_ccu_clock_decode(device_t dev, int cc_phandle, const void *data,
+		       size_t len)
 {
 	struct sunxi_ccu_softc * const sc = device_private(dev);
 	struct sunxi_ccu_clk *clk;
+	(void) cc_phandle;
 
 	if (len != 4)
 		return NULL;
diff --git a/sys/arch/arm/sunxi/sunxi_gates.c b/sys/arch/arm/sunxi/sunxi_gates.c
index f276a209419b..1889819ac998 100644
--- a/sys/arch/arm/sunxi/sunxi_gates.c
+++ b/sys/arch/arm/sunxi/sunxi_gates.c
@@ -70,10 +70,12 @@ struct sunxi_gates_softc {
 	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
 
 static struct clk *
-sunxi_gates_clock_decode(device_t dev, const void *data, size_t len)
+sunxi_gates_clock_decode(device_t dev, int cc_phandle, const void *data,
+			 size_t len)
 {
 	struct sunxi_gates_softc * const sc = device_private(dev);
 	struct sunxi_gate *gate;
+	(void) cc_phandle;
 
 	if (len != 4)
 		return NULL;
diff --git a/sys/arch/arm/sunxi/sunxi_gmacclk.c b/sys/arch/arm/sunxi/sunxi_gmacclk.c
index 04820a7ccd81..59f1fe8d2dc5 100644
--- a/sys/arch/arm/sunxi/sunxi_gmacclk.c
+++ b/sys/arch/arm/sunxi/sunxi_gmacclk.c
@@ -50,7 +50,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_gmacclk.c,v 1.1 2017/10/07 13:28:59 jmcneill E
 static int	sunxi_gmacclk_match(device_t, cfdata_t, void *);
 static void	sunxi_gmacclk_attach(device_t, device_t, void *);
 
-static struct clk *sunxi_gmacclk_decode(device_t, const void *, size_t);
+static struct clk *sunxi_gmacclk_decode(device_t, int, const void *, size_t);
 
 static const struct fdtbus_clock_controller_func sunxi_gmacclk_fdt_funcs = {
 	.decode = sunxi_gmacclk_decode
@@ -139,9 +139,11 @@ sunxi_gmacclk_attach(device_t parent, device_t self, void *aux)
 }
 
 static struct clk *
-sunxi_gmacclk_decode(device_t dev, const void *data, size_t len)
+sunxi_gmacclk_decode(device_t dev, int cc_phandle, const void *data,
+		     size_t len)
 {
 	struct sunxi_gmacclk_softc * const sc = device_private(dev);
+	(void) cc_phandle;
 
 	if (len != 0)
 		return NULL;
diff --git a/sys/dev/fdt/fdt_clock.c b/sys/dev/fdt/fdt_clock.c
index f82e2c86b63a..d5b605b2d97e 100644
--- a/sys/dev/fdt/fdt_clock.c
+++ b/sys/dev/fdt/fdt_clock.c
@@ -103,7 +103,7 @@ fdtbus_clock_get_index_prop(int phandle, u_int index, const char *prop)
 			cc = fdtbus_get_clock_controller(cc_phandle);
 			if (cc == NULL)
 				break;
-			clk = cc->cc_funcs->decode(cc->cc_dev,
+			clk = cc->cc_funcs->decode(cc->cc_dev, cc_phandle,
 			    clock_cells > 0 ? &p[1] : NULL, clock_cells * 4);
 			break;
 		}
@@ -195,6 +195,7 @@ fdtbus_clock_byname(const char *clkname)
 					break;
 				const u_int index_raw = htobe32(index);
 				return cc->cc_funcs->decode(cc->cc_dev,
+				    cc->cc_phandle,
 				    clock_cells > 0 ? &index_raw : NULL,
 				    clock_cells > 0 ? 4 : 0);
 			}
diff --git a/sys/dev/fdt/fdtvar.h b/sys/dev/fdt/fdtvar.h
index 82a2647a5b91..bb981eb0dc67 100644
--- a/sys/dev/fdt/fdtvar.h
+++ b/sys/dev/fdt/fdtvar.h
@@ -111,7 +111,7 @@ struct fdtbus_regulator_controller_func {
 };
 
 struct fdtbus_clock_controller_func {
-	struct clk *	(*decode)(device_t, const void *, size_t);
+	struct clk *	(*decode)(device_t, int, const void *, size_t);
 };
 
 struct fdtbus_reset_controller;
diff --git a/sys/dev/fdt/fixedclock.c b/sys/dev/fdt/fixedclock.c
index cd13273343e9..04105f06abf8 100644
--- a/sys/dev/fdt/fixedclock.c
+++ b/sys/dev/fdt/fixedclock.c
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: fixedclock.c,v 1.4 2018/06/16 00:13:06 jmcneill Exp
 static int	fixedclock_match(device_t, cfdata_t, void *);
 static void	fixedclock_attach(device_t, device_t, void *);
 
-static struct clk *fixedclock_decode(device_t, const void *, size_t);
+static struct clk *fixedclock_decode(device_t, int, const void *, size_t);
 
 static const struct fdtbus_clock_controller_func fixedclock_fdt_funcs = {
 	.decode = fixedclock_decode
@@ -116,9 +116,10 @@ fixedclock_attach(device_t parent, device_t self, void *aux)
 }
 
 static struct clk *
-fixedclock_decode(device_t dev, const void *data, size_t len)
+fixedclock_decode(device_t dev, int cc_phandle, const void *data, size_t len)
 {
 	struct fixedclock_softc * const sc = device_private(dev);
+	(void) cc_phandle;
 
 	/* #clock-cells for a fixed clock is always 0 */
 	if (len != 0)
diff --git a/sys/dev/fdt/fixedfactorclock.c b/sys/dev/fdt/fixedfactorclock.c
index c27bed7b59c6..890f3be58feb 100644
--- a/sys/dev/fdt/fixedfactorclock.c
+++ b/sys/dev/fdt/fixedfactorclock.c
@@ -42,7 +42,7 @@ __KERNEL_RCSID(0, "$NetBSD: fixedfactorclock.c,v 1.2 2018/04/28 15:21:05 jmcneil
 static int	fixedfactorclock_match(device_t, cfdata_t, void *);
 static void	fixedfactorclock_attach(device_t, device_t, void *);
 
-static struct clk *fixedfactorclock_decode(device_t, const void *, size_t);
+static struct clk *fixedfactorclock_decode(device_t, int, const void *, size_t);
 
 static const struct fdtbus_clock_controller_func fixedfactorclock_fdt_funcs = {
 	.decode = fixedfactorclock_decode
@@ -124,9 +124,11 @@ fixedfactorclock_attach(device_t parent, device_t self, void *aux)
 }
 
 static struct clk *
-fixedfactorclock_decode(device_t dev, const void *data, size_t len)
+fixedfactorclock_decode(device_t dev, int cc_phandle, const void *data,
+			size_t len)
 {
 	struct fixedfactorclock_softc * const sc = device_private(dev);
+	(void) cc_phandle;
 
 	/* #clock-cells for a fixed factor clock is always 0 */
 	if (len != 0)


Home | Main Index | Thread Index | Old Index