From 49b2b0a2b6782609a9977095d9c80391de463044 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 9 May 2022 00:29:31 -0500 Subject: clk: sunxi: Store the array sizes in the CCU descriptor The reset array size is currently used for bounds checking in the reset driver. The same bounds check should really be done in the clock driver. Currently, the array size is provided to the reset driver separately from the CCU descriptor, which is a bit strange. Let's do this the usual way, with the array sizes next to the arrays themselves. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara [Andre: add F1C100s support] Signed-off-by: Andre Przywara --- include/clk/sunxi.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index c4a9dee5ebf..f1717a5e954 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -70,6 +70,8 @@ struct ccu_reset { struct ccu_desc { const struct ccu_clk_gate *gates; const struct ccu_reset *resets; + u8 num_gates; + u8 num_resets; }; /** -- cgit v1.3.1 From d39088ad9c97fa612c480475b18759a3931c41fd Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 9 May 2022 00:29:33 -0500 Subject: reset: sunxi: Get the reset count from the CCU descriptor This allows all of the clock drivers to use a common bind function. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara [Andre: add F1C100s support] Signed-off-by: Andre Przywara --- drivers/clk/sunxi/clk_a10.c | 7 +------ drivers/clk/sunxi/clk_a10s.c | 7 +------ drivers/clk/sunxi/clk_a23.c | 7 +------ drivers/clk/sunxi/clk_a31.c | 7 +------ drivers/clk/sunxi/clk_a31_r.c | 7 +------ drivers/clk/sunxi/clk_a64.c | 7 +------ drivers/clk/sunxi/clk_a80.c | 12 +----------- drivers/clk/sunxi/clk_a83t.c | 7 +------ drivers/clk/sunxi/clk_f1c100s.c | 7 +------ drivers/clk/sunxi/clk_h3.c | 7 +------ drivers/clk/sunxi/clk_h6.c | 7 +------ drivers/clk/sunxi/clk_h616.c | 7 +------ drivers/clk/sunxi/clk_h6_r.c | 7 +------ drivers/clk/sunxi/clk_r40.c | 7 +------ drivers/clk/sunxi/clk_sunxi.c | 5 +++++ drivers/clk/sunxi/clk_v3s.c | 7 +------ drivers/reset/reset-sunxi.c | 6 ++---- include/clk/sunxi.h | 9 +++++++-- 18 files changed, 29 insertions(+), 101 deletions(-) (limited to 'include') diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c index b3cca2aa3a0..7bd9a379d7c 100644 --- a/drivers/clk/sunxi/clk_a10.c +++ b/drivers/clk/sunxi/clk_a10.c @@ -71,11 +71,6 @@ static const struct ccu_desc a10_ccu_desc = { .num_resets = ARRAY_SIZE(a10_resets), }; -static int a10_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a10_resets)); -} - static const struct udevice_id a10_ccu_ids[] = { { .compatible = "allwinner,sun4i-a10-ccu", .data = (ulong)&a10_ccu_desc }, @@ -91,5 +86,5 @@ U_BOOT_DRIVER(clk_sun4i_a10) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a10_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c index 0e75c303d06..4a83d6b2159 100644 --- a/drivers/clk/sunxi/clk_a10s.c +++ b/drivers/clk/sunxi/clk_a10s.c @@ -56,11 +56,6 @@ static const struct ccu_desc a10s_ccu_desc = { .num_resets = ARRAY_SIZE(a10s_resets), }; -static int a10s_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a10s_resets)); -} - static const struct udevice_id a10s_ccu_ids[] = { { .compatible = "allwinner,sun5i-a10s-ccu", .data = (ulong)&a10s_ccu_desc }, @@ -76,5 +71,5 @@ U_BOOT_DRIVER(clk_sun5i_a10s) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a10s_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c index a9c77bad208..c7f516d7333 100644 --- a/drivers/clk/sunxi/clk_a23.c +++ b/drivers/clk/sunxi/clk_a23.c @@ -75,11 +75,6 @@ static const struct ccu_desc a23_ccu_desc = { .num_resets = ARRAY_SIZE(a23_resets), }; -static int a23_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a23_resets)); -} - static const struct udevice_id a23_clk_ids[] = { { .compatible = "allwinner,sun8i-a23-ccu", .data = (ulong)&a23_ccu_desc }, @@ -95,5 +90,5 @@ U_BOOT_DRIVER(clk_sun8i_a23) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a23_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c index 69df4e08d0f..aa113fa714c 100644 --- a/drivers/clk/sunxi/clk_a31.c +++ b/drivers/clk/sunxi/clk_a31.c @@ -96,11 +96,6 @@ static const struct ccu_desc a31_ccu_desc = { .num_resets = ARRAY_SIZE(a31_resets), }; -static int a31_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a31_resets)); -} - static const struct udevice_id a31_clk_ids[] = { { .compatible = "allwinner,sun6i-a31-ccu", .data = (ulong)&a31_ccu_desc }, @@ -114,5 +109,5 @@ U_BOOT_DRIVER(clk_sun6i_a31) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a31_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a31_r.c b/drivers/clk/sunxi/clk_a31_r.c index 7bf1c4578c5..04c238204dc 100644 --- a/drivers/clk/sunxi/clk_a31_r.c +++ b/drivers/clk/sunxi/clk_a31_r.c @@ -35,11 +35,6 @@ static const struct ccu_desc a31_r_ccu_desc = { .num_resets = ARRAY_SIZE(a31_r_resets), }; -static int a31_r_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a31_r_resets)); -} - static const struct udevice_id a31_r_clk_ids[] = { { .compatible = "allwinner,sun8i-a83t-r-ccu", .data = (ulong)&a31_r_ccu_desc }, @@ -57,5 +52,5 @@ U_BOOT_DRIVER(clk_sun6i_a31_r) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a31_r_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c index e24d5c5ca32..eac1151e966 100644 --- a/drivers/clk/sunxi/clk_a64.c +++ b/drivers/clk/sunxi/clk_a64.c @@ -84,11 +84,6 @@ static const struct ccu_desc a64_ccu_desc = { .num_resets = ARRAY_SIZE(a64_resets), }; -static int a64_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a64_resets)); -} - static const struct udevice_id a64_ccu_ids[] = { { .compatible = "allwinner,sun50i-a64-ccu", .data = (ulong)&a64_ccu_desc }, @@ -102,5 +97,5 @@ U_BOOT_DRIVER(clk_sun50i_a64) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a64_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a80.c b/drivers/clk/sunxi/clk_a80.c index adedcba1665..426205d7482 100644 --- a/drivers/clk/sunxi/clk_a80.c +++ b/drivers/clk/sunxi/clk_a80.c @@ -88,16 +88,6 @@ static const struct ccu_desc a80_mmc_clk_desc = { .num_resets = ARRAY_SIZE(a80_mmc_resets), }; -static int a80_clk_bind(struct udevice *dev) -{ - ulong count = ARRAY_SIZE(a80_resets); - - if (device_is_compatible(dev, "allwinner,sun9i-a80-mmc-config-clk")) - count = ARRAY_SIZE(a80_mmc_resets); - - return sunxi_reset_bind(dev, count); -} - static const struct udevice_id a80_ccu_ids[] = { { .compatible = "allwinner,sun9i-a80-ccu", .data = (ulong)&a80_ccu_desc }, @@ -113,5 +103,5 @@ U_BOOT_DRIVER(clk_sun9i_a80) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a80_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c index 4a0659af3e2..464e95c07da 100644 --- a/drivers/clk/sunxi/clk_a83t.c +++ b/drivers/clk/sunxi/clk_a83t.c @@ -79,11 +79,6 @@ static const struct ccu_desc a83t_ccu_desc = { .num_resets = ARRAY_SIZE(a83t_resets), }; -static int a83t_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(a83t_resets)); -} - static const struct udevice_id a83t_clk_ids[] = { { .compatible = "allwinner,sun8i-a83t-ccu", .data = (ulong)&a83t_ccu_desc }, @@ -97,5 +92,5 @@ U_BOOT_DRIVER(clk_sun8i_a83t) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = a83t_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_f1c100s.c b/drivers/clk/sunxi/clk_f1c100s.c index cb0159ecbc7..acba8f2ebec 100644 --- a/drivers/clk/sunxi/clk_f1c100s.c +++ b/drivers/clk/sunxi/clk_f1c100s.c @@ -54,11 +54,6 @@ static const struct ccu_desc f1c100s_ccu_desc = { .num_resets = ARRAY_SIZE(f1c100s_resets), }; -static int f1c100s_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(f1c100s_resets)); -} - static const struct udevice_id f1c100s_clk_ids[] = { { .compatible = "allwinner,suniv-f1c100s-ccu", .data = (ulong)&f1c100s_ccu_desc }, @@ -72,5 +67,5 @@ U_BOOT_DRIVER(clk_suniv_f1c100s) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = f1c100s_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c index d69cb04b824..474cf98f644 100644 --- a/drivers/clk/sunxi/clk_h3.c +++ b/drivers/clk/sunxi/clk_h3.c @@ -97,11 +97,6 @@ static const struct ccu_desc h3_ccu_desc = { .num_resets = ARRAY_SIZE(h3_resets), }; -static int h3_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(h3_resets)); -} - static const struct udevice_id h3_ccu_ids[] = { { .compatible = "allwinner,sun8i-h3-ccu", .data = (ulong)&h3_ccu_desc }, @@ -117,5 +112,5 @@ U_BOOT_DRIVER(clk_sun8i_h3) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = h3_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c index f8d2379b494..4e717afa26e 100644 --- a/drivers/clk/sunxi/clk_h6.c +++ b/drivers/clk/sunxi/clk_h6.c @@ -98,11 +98,6 @@ static const struct ccu_desc h6_ccu_desc = { .num_resets = ARRAY_SIZE(h6_resets), }; -static int h6_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(h6_resets)); -} - static const struct udevice_id h6_ccu_ids[] = { { .compatible = "allwinner,sun50i-h6-ccu", .data = (ulong)&h6_ccu_desc }, @@ -116,5 +111,5 @@ U_BOOT_DRIVER(clk_sun50i_h6) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = h6_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_h616.c b/drivers/clk/sunxi/clk_h616.c index 34cfcffb49d..1ecccd7620c 100644 --- a/drivers/clk/sunxi/clk_h616.c +++ b/drivers/clk/sunxi/clk_h616.c @@ -116,11 +116,6 @@ static const struct ccu_desc h616_ccu_desc = { .num_resets = ARRAY_SIZE(h616_resets), }; -static int h616_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(h616_resets)); -} - static const struct udevice_id h616_ccu_ids[] = { { .compatible = "allwinner,sun50i-h616-ccu", .data = (ulong)&h616_ccu_desc }, @@ -134,5 +129,5 @@ U_BOOT_DRIVER(clk_sun50i_h616) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = h616_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c index 18913751fb7..bb67d58fa47 100644 --- a/drivers/clk/sunxi/clk_h6_r.c +++ b/drivers/clk/sunxi/clk_h6_r.c @@ -41,11 +41,6 @@ static const struct ccu_desc h6_r_ccu_desc = { .num_resets = ARRAY_SIZE(h6_r_resets), }; -static int h6_r_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(h6_r_resets)); -} - static const struct udevice_id h6_r_clk_ids[] = { { .compatible = "allwinner,sun50i-h6-r-ccu", .data = (ulong)&h6_r_ccu_desc }, @@ -61,5 +56,5 @@ U_BOOT_DRIVER(clk_sun50i_h6_r) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = h6_r_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c index 81e4a0219a9..daab6ad33b4 100644 --- a/drivers/clk/sunxi/clk_r40.c +++ b/drivers/clk/sunxi/clk_r40.c @@ -106,11 +106,6 @@ static const struct ccu_desc r40_ccu_desc = { .num_resets = ARRAY_SIZE(r40_resets), }; -static int r40_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(r40_resets)); -} - static const struct udevice_id r40_clk_ids[] = { { .compatible = "allwinner,sun8i-r40-ccu", .data = (ulong)&r40_ccu_desc }, @@ -124,5 +119,5 @@ U_BOOT_DRIVER(clk_sun8i_r40) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = r40_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c index 62e77386be7..23d81f68c5c 100644 --- a/drivers/clk/sunxi/clk_sunxi.c +++ b/drivers/clk/sunxi/clk_sunxi.c @@ -67,6 +67,11 @@ struct clk_ops sunxi_clk_ops = { .disable = sunxi_clk_disable, }; +int sunxi_clk_bind(struct udevice *dev) +{ + return sunxi_reset_bind(dev); +} + int sunxi_clk_probe(struct udevice *dev) { struct ccu_priv *priv = dev_get_priv(dev); diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c index f45e9400419..5b5afa68715 100644 --- a/drivers/clk/sunxi/clk_v3s.c +++ b/drivers/clk/sunxi/clk_v3s.c @@ -56,11 +56,6 @@ static const struct ccu_desc v3s_ccu_desc = { .num_resets = ARRAY_SIZE(v3s_resets), }; -static int v3s_clk_bind(struct udevice *dev) -{ - return sunxi_reset_bind(dev, ARRAY_SIZE(v3s_resets)); -} - static const struct udevice_id v3s_clk_ids[] = { { .compatible = "allwinner,sun8i-v3s-ccu", .data = (ulong)&v3s_ccu_desc }, @@ -76,5 +71,5 @@ U_BOOT_DRIVER(clk_sun8i_v3s) = { .priv_auto = sizeof(struct ccu_priv), .ops = &sunxi_clk_ops, .probe = sunxi_clk_probe, - .bind = v3s_clk_bind, + .bind = sunxi_clk_bind, }; diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c index e2a9c2a142b..621912ad237 100644 --- a/drivers/reset/reset-sunxi.c +++ b/drivers/reset/reset-sunxi.c @@ -19,7 +19,6 @@ struct sunxi_reset_priv { void *base; - ulong count; const struct ccu_desc *desc; }; @@ -35,7 +34,7 @@ static int sunxi_reset_request(struct reset_ctl *reset_ctl) debug("%s: (RST#%ld)\n", __func__, reset_ctl->id); - if (reset_ctl->id >= priv->count) + if (reset_ctl->id >= priv->desc->num_resets) return -EINVAL; return 0; @@ -91,7 +90,7 @@ static int sunxi_reset_probe(struct udevice *dev) return 0; } -int sunxi_reset_bind(struct udevice *dev, ulong count) +int sunxi_reset_bind(struct udevice *dev) { struct udevice *rst_dev; struct sunxi_reset_priv *priv; @@ -104,7 +103,6 @@ int sunxi_reset_bind(struct udevice *dev, ulong count) return ret; } priv = malloc(sizeof(struct sunxi_reset_priv)); - priv->count = count; priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev); dev_set_priv(rst_dev, priv); diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index f1717a5e954..a70119304a7 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -85,6 +85,12 @@ struct ccu_priv { const struct ccu_desc *desc; }; +/** + * sunxi_clk_bind - common sunxi clock bind + * @dev: clock device + */ +int sunxi_clk_bind(struct udevice *dev); + /** * sunxi_clk_probe - common sunxi clock probe * @dev: clock device @@ -97,9 +103,8 @@ extern struct clk_ops sunxi_clk_ops; * sunxi_reset_bind() - reset binding * * @dev: reset device - * @count: reset count * Return: 0 success, or error value */ -int sunxi_reset_bind(struct udevice *dev, ulong count); +int sunxi_reset_bind(struct udevice *dev); #endif /* _CLK_SUNXI_H */ -- cgit v1.3.1 From 46fa23f9eecd0fc32215a194e7a7f5f5abe67cdc Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 9 May 2022 00:29:34 -0500 Subject: clk: sunxi: Use a single driver for all variants Now that all of the variants use the same bind/probe functions and ops, there is no need to have a separate driver for each variant. Since most SoCs contain two variants (the main CCU and PRCM CCU), this saves a bit of firmware size and RAM. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara [Andre: add F1C100s support] Signed-off-by: Andre Przywara --- drivers/clk/sunxi/clk_a10.c | 20 +------ drivers/clk/sunxi/clk_a10s.c | 20 +------ drivers/clk/sunxi/clk_a23.c | 20 +------ drivers/clk/sunxi/clk_a31.c | 18 +----- drivers/clk/sunxi/clk_a31_r.c | 22 +------ drivers/clk/sunxi/clk_a64.c | 18 +----- drivers/clk/sunxi/clk_a80.c | 22 +------ drivers/clk/sunxi/clk_a83t.c | 18 +----- drivers/clk/sunxi/clk_f1c100s.c | 18 +----- drivers/clk/sunxi/clk_h3.c | 20 +------ drivers/clk/sunxi/clk_h6.c | 18 +----- drivers/clk/sunxi/clk_h616.c | 18 +----- drivers/clk/sunxi/clk_h6_r.c | 20 +------ drivers/clk/sunxi/clk_r40.c | 18 +----- drivers/clk/sunxi/clk_sunxi.c | 123 +++++++++++++++++++++++++++++++++++++++- drivers/clk/sunxi/clk_v3s.c | 20 +------ include/clk/sunxi.h | 12 ---- 17 files changed, 137 insertions(+), 288 deletions(-) (limited to 'include') diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c index 7bd9a379d7c..abd4e8b7389 100644 --- a/drivers/clk/sunxi/clk_a10.c +++ b/drivers/clk/sunxi/clk_a10.c @@ -64,27 +64,9 @@ static struct ccu_reset a10_resets[] = { [RST_USB_PHY2] = RESET(0x0cc, BIT(2)), }; -static const struct ccu_desc a10_ccu_desc = { +const struct ccu_desc a10_ccu_desc = { .gates = a10_gates, .resets = a10_resets, .num_gates = ARRAY_SIZE(a10_gates), .num_resets = ARRAY_SIZE(a10_resets), }; - -static const struct udevice_id a10_ccu_ids[] = { - { .compatible = "allwinner,sun4i-a10-ccu", - .data = (ulong)&a10_ccu_desc }, - { .compatible = "allwinner,sun7i-a20-ccu", - .data = (ulong)&a10_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun4i_a10) = { - .name = "sun4i_a10_ccu", - .id = UCLASS_CLK, - .of_match = a10_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c index 4a83d6b2159..e486cedd48d 100644 --- a/drivers/clk/sunxi/clk_a10s.c +++ b/drivers/clk/sunxi/clk_a10s.c @@ -49,27 +49,9 @@ static struct ccu_reset a10s_resets[] = { [RST_USB_PHY1] = RESET(0x0cc, BIT(1)), }; -static const struct ccu_desc a10s_ccu_desc = { +const struct ccu_desc a10s_ccu_desc = { .gates = a10s_gates, .resets = a10s_resets, .num_gates = ARRAY_SIZE(a10s_gates), .num_resets = ARRAY_SIZE(a10s_resets), }; - -static const struct udevice_id a10s_ccu_ids[] = { - { .compatible = "allwinner,sun5i-a10s-ccu", - .data = (ulong)&a10s_ccu_desc }, - { .compatible = "allwinner,sun5i-a13-ccu", - .data = (ulong)&a10s_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun5i_a10s) = { - .name = "sun5i_a10s_ccu", - .id = UCLASS_CLK, - .of_match = a10s_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c index c7f516d7333..d94fecadd59 100644 --- a/drivers/clk/sunxi/clk_a23.c +++ b/drivers/clk/sunxi/clk_a23.c @@ -68,27 +68,9 @@ static struct ccu_reset a23_resets[] = { [RST_BUS_UART4] = RESET(0x2d8, BIT(20)), }; -static const struct ccu_desc a23_ccu_desc = { +const struct ccu_desc a23_ccu_desc = { .gates = a23_gates, .resets = a23_resets, .num_gates = ARRAY_SIZE(a23_gates), .num_resets = ARRAY_SIZE(a23_resets), }; - -static const struct udevice_id a23_clk_ids[] = { - { .compatible = "allwinner,sun8i-a23-ccu", - .data = (ulong)&a23_ccu_desc }, - { .compatible = "allwinner,sun8i-a33-ccu", - .data = (ulong)&a23_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_a23) = { - .name = "sun8i_a23_ccu", - .id = UCLASS_CLK, - .of_match = a23_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c index aa113fa714c..360658912dd 100644 --- a/drivers/clk/sunxi/clk_a31.c +++ b/drivers/clk/sunxi/clk_a31.c @@ -89,25 +89,9 @@ static struct ccu_reset a31_resets[] = { [RST_APB2_UART5] = RESET(0x2d8, BIT(21)), }; -static const struct ccu_desc a31_ccu_desc = { +const struct ccu_desc a31_ccu_desc = { .gates = a31_gates, .resets = a31_resets, .num_gates = ARRAY_SIZE(a31_gates), .num_resets = ARRAY_SIZE(a31_resets), }; - -static const struct udevice_id a31_clk_ids[] = { - { .compatible = "allwinner,sun6i-a31-ccu", - .data = (ulong)&a31_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun6i_a31) = { - .name = "sun6i_a31_ccu", - .id = UCLASS_CLK, - .of_match = a31_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a31_r.c b/drivers/clk/sunxi/clk_a31_r.c index 04c238204dc..fa6887fa756 100644 --- a/drivers/clk/sunxi/clk_a31_r.c +++ b/drivers/clk/sunxi/clk_a31_r.c @@ -28,29 +28,9 @@ static struct ccu_reset a31_r_resets[] = { [RST_APB0_I2C] = RESET(0x0b0, BIT(6)), }; -static const struct ccu_desc a31_r_ccu_desc = { +const struct ccu_desc a31_r_ccu_desc = { .gates = a31_r_gates, .resets = a31_r_resets, .num_gates = ARRAY_SIZE(a31_r_gates), .num_resets = ARRAY_SIZE(a31_r_resets), }; - -static const struct udevice_id a31_r_clk_ids[] = { - { .compatible = "allwinner,sun8i-a83t-r-ccu", - .data = (ulong)&a31_r_ccu_desc }, - { .compatible = "allwinner,sun8i-h3-r-ccu", - .data = (ulong)&a31_r_ccu_desc }, - { .compatible = "allwinner,sun50i-a64-r-ccu", - .data = (ulong)&a31_r_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun6i_a31_r) = { - .name = "sun6i_a31_r_ccu", - .id = UCLASS_CLK, - .of_match = a31_r_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a64.c b/drivers/clk/sunxi/clk_a64.c index eac1151e966..8c81b1ac453 100644 --- a/drivers/clk/sunxi/clk_a64.c +++ b/drivers/clk/sunxi/clk_a64.c @@ -77,25 +77,9 @@ static const struct ccu_reset a64_resets[] = { [RST_BUS_UART4] = RESET(0x2d8, BIT(20)), }; -static const struct ccu_desc a64_ccu_desc = { +const struct ccu_desc a64_ccu_desc = { .gates = a64_gates, .resets = a64_resets, .num_gates = ARRAY_SIZE(a64_gates), .num_resets = ARRAY_SIZE(a64_resets), }; - -static const struct udevice_id a64_ccu_ids[] = { - { .compatible = "allwinner,sun50i-a64-ccu", - .data = (ulong)&a64_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun50i_a64) = { - .name = "sun50i_a64_ccu", - .id = UCLASS_CLK, - .of_match = a64_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a80.c b/drivers/clk/sunxi/clk_a80.c index 426205d7482..3c9eb143167 100644 --- a/drivers/clk/sunxi/clk_a80.c +++ b/drivers/clk/sunxi/clk_a80.c @@ -74,34 +74,16 @@ static const struct ccu_reset a80_mmc_resets[] = { [3] = GATE(0xc, BIT(18)), }; -static const struct ccu_desc a80_ccu_desc = { +const struct ccu_desc a80_ccu_desc = { .gates = a80_gates, .resets = a80_resets, .num_gates = ARRAY_SIZE(a80_gates), .num_resets = ARRAY_SIZE(a80_resets), }; -static const struct ccu_desc a80_mmc_clk_desc = { +const struct ccu_desc a80_mmc_clk_desc = { .gates = a80_mmc_gates, .resets = a80_mmc_resets, .num_gates = ARRAY_SIZE(a80_mmc_gates), .num_resets = ARRAY_SIZE(a80_mmc_resets), }; - -static const struct udevice_id a80_ccu_ids[] = { - { .compatible = "allwinner,sun9i-a80-ccu", - .data = (ulong)&a80_ccu_desc }, - { .compatible = "allwinner,sun9i-a80-mmc-config-clk", - .data = (ulong)&a80_mmc_clk_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun9i_a80) = { - .name = "sun9i_a80_ccu", - .id = UCLASS_CLK, - .of_match = a80_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_a83t.c b/drivers/clk/sunxi/clk_a83t.c index 464e95c07da..3562da61d14 100644 --- a/drivers/clk/sunxi/clk_a83t.c +++ b/drivers/clk/sunxi/clk_a83t.c @@ -72,25 +72,9 @@ static struct ccu_reset a83t_resets[] = { [RST_BUS_UART4] = RESET(0x2d8, BIT(20)), }; -static const struct ccu_desc a83t_ccu_desc = { +const struct ccu_desc a83t_ccu_desc = { .gates = a83t_gates, .resets = a83t_resets, .num_gates = ARRAY_SIZE(a83t_gates), .num_resets = ARRAY_SIZE(a83t_resets), }; - -static const struct udevice_id a83t_clk_ids[] = { - { .compatible = "allwinner,sun8i-a83t-ccu", - .data = (ulong)&a83t_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_a83t) = { - .name = "sun8i_a83t_ccu", - .id = UCLASS_CLK, - .of_match = a83t_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_f1c100s.c b/drivers/clk/sunxi/clk_f1c100s.c index acba8f2ebec..7b4c3ce5176 100644 --- a/drivers/clk/sunxi/clk_f1c100s.c +++ b/drivers/clk/sunxi/clk_f1c100s.c @@ -47,25 +47,9 @@ static struct ccu_reset f1c100s_resets[] = { [RST_BUS_UART2] = RESET(0x2d0, BIT(22)), }; -static const struct ccu_desc f1c100s_ccu_desc = { +const struct ccu_desc f1c100s_ccu_desc = { .gates = f1c100s_gates, .resets = f1c100s_resets, .num_gates = ARRAY_SIZE(f1c100s_gates), .num_resets = ARRAY_SIZE(f1c100s_resets), }; - -static const struct udevice_id f1c100s_clk_ids[] = { - { .compatible = "allwinner,suniv-f1c100s-ccu", - .data = (ulong)&f1c100s_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_suniv_f1c100s) = { - .name = "suniv_f1c100s_ccu", - .id = UCLASS_CLK, - .of_match = f1c100s_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_h3.c b/drivers/clk/sunxi/clk_h3.c index 474cf98f644..17ab3b5c278 100644 --- a/drivers/clk/sunxi/clk_h3.c +++ b/drivers/clk/sunxi/clk_h3.c @@ -90,27 +90,9 @@ static struct ccu_reset h3_resets[] = { [RST_BUS_UART3] = RESET(0x2d8, BIT(19)), }; -static const struct ccu_desc h3_ccu_desc = { +const struct ccu_desc h3_ccu_desc = { .gates = h3_gates, .resets = h3_resets, .num_gates = ARRAY_SIZE(h3_gates), .num_resets = ARRAY_SIZE(h3_resets), }; - -static const struct udevice_id h3_ccu_ids[] = { - { .compatible = "allwinner,sun8i-h3-ccu", - .data = (ulong)&h3_ccu_desc }, - { .compatible = "allwinner,sun50i-h5-ccu", - .data = (ulong)&h3_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_h3) = { - .name = "sun8i_h3_ccu", - .id = UCLASS_CLK, - .of_match = h3_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_h6.c b/drivers/clk/sunxi/clk_h6.c index 4e717afa26e..041bc5e80ed 100644 --- a/drivers/clk/sunxi/clk_h6.c +++ b/drivers/clk/sunxi/clk_h6.c @@ -91,25 +91,9 @@ static struct ccu_reset h6_resets[] = { [RST_BUS_OTG] = RESET(0xa8c, BIT(24)), }; -static const struct ccu_desc h6_ccu_desc = { +const struct ccu_desc h6_ccu_desc = { .gates = h6_gates, .resets = h6_resets, .num_gates = ARRAY_SIZE(h6_gates), .num_resets = ARRAY_SIZE(h6_resets), }; - -static const struct udevice_id h6_ccu_ids[] = { - { .compatible = "allwinner,sun50i-h6-ccu", - .data = (ulong)&h6_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun50i_h6) = { - .name = "sun50i_h6_ccu", - .id = UCLASS_CLK, - .of_match = h6_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_h616.c b/drivers/clk/sunxi/clk_h616.c index 1ecccd7620c..964636d7281 100644 --- a/drivers/clk/sunxi/clk_h616.c +++ b/drivers/clk/sunxi/clk_h616.c @@ -109,25 +109,9 @@ static struct ccu_reset h616_resets[] = { [RST_BUS_OTG] = RESET(0xa8c, BIT(24)), }; -static const struct ccu_desc h616_ccu_desc = { +const struct ccu_desc h616_ccu_desc = { .gates = h616_gates, .resets = h616_resets, .num_gates = ARRAY_SIZE(h616_gates), .num_resets = ARRAY_SIZE(h616_resets), }; - -static const struct udevice_id h616_ccu_ids[] = { - { .compatible = "allwinner,sun50i-h616-ccu", - .data = (ulong)&h616_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun50i_h616) = { - .name = "sun50i_h616_ccu", - .id = UCLASS_CLK, - .of_match = h616_ccu_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_h6_r.c b/drivers/clk/sunxi/clk_h6_r.c index bb67d58fa47..ddcb3dae30a 100644 --- a/drivers/clk/sunxi/clk_h6_r.c +++ b/drivers/clk/sunxi/clk_h6_r.c @@ -34,27 +34,9 @@ static struct ccu_reset h6_r_resets[] = { [RST_R_APB1_W1] = RESET(0x1ec, BIT(16)), }; -static const struct ccu_desc h6_r_ccu_desc = { +const struct ccu_desc h6_r_ccu_desc = { .gates = h6_r_gates, .resets = h6_r_resets, .num_gates = ARRAY_SIZE(h6_r_gates), .num_resets = ARRAY_SIZE(h6_r_resets), }; - -static const struct udevice_id h6_r_clk_ids[] = { - { .compatible = "allwinner,sun50i-h6-r-ccu", - .data = (ulong)&h6_r_ccu_desc }, - { .compatible = "allwinner,sun50i-h616-r-ccu", - .data = (ulong)&h6_r_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun50i_h6_r) = { - .name = "sun50i_h6_r_ccu", - .id = UCLASS_CLK, - .of_match = h6_r_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_r40.c b/drivers/clk/sunxi/clk_r40.c index daab6ad33b4..ef743d65b7f 100644 --- a/drivers/clk/sunxi/clk_r40.c +++ b/drivers/clk/sunxi/clk_r40.c @@ -99,25 +99,9 @@ static struct ccu_reset r40_resets[] = { [RST_BUS_UART7] = RESET(0x2d8, BIT(23)), }; -static const struct ccu_desc r40_ccu_desc = { +const struct ccu_desc r40_ccu_desc = { .gates = r40_gates, .resets = r40_resets, .num_gates = ARRAY_SIZE(r40_gates), .num_resets = ARRAY_SIZE(r40_resets), }; - -static const struct udevice_id r40_clk_ids[] = { - { .compatible = "allwinner,sun8i-r40-ccu", - .data = (ulong)&r40_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_r40) = { - .name = "sun8i_r40_ccu", - .id = UCLASS_CLK, - .of_match = r40_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c index 23d81f68c5c..8503c797637 100644 --- a/drivers/clk/sunxi/clk_sunxi.c +++ b/drivers/clk/sunxi/clk_sunxi.c @@ -67,12 +67,12 @@ struct clk_ops sunxi_clk_ops = { .disable = sunxi_clk_disable, }; -int sunxi_clk_bind(struct udevice *dev) +static int sunxi_clk_bind(struct udevice *dev) { return sunxi_reset_bind(dev); } -int sunxi_clk_probe(struct udevice *dev) +static int sunxi_clk_probe(struct udevice *dev) { struct ccu_priv *priv = dev_get_priv(dev); struct clk_bulk clk_bulk; @@ -97,3 +97,122 @@ int sunxi_clk_probe(struct udevice *dev) return 0; } + +extern const struct ccu_desc a10_ccu_desc; +extern const struct ccu_desc a10s_ccu_desc; +extern const struct ccu_desc a23_ccu_desc; +extern const struct ccu_desc a31_ccu_desc; +extern const struct ccu_desc a31_r_ccu_desc; +extern const struct ccu_desc a64_ccu_desc; +extern const struct ccu_desc a80_ccu_desc; +extern const struct ccu_desc a80_mmc_clk_desc; +extern const struct ccu_desc a83t_ccu_desc; +extern const struct ccu_desc f1c100s_ccu_desc; +extern const struct ccu_desc h3_ccu_desc; +extern const struct ccu_desc h6_ccu_desc; +extern const struct ccu_desc h616_ccu_desc; +extern const struct ccu_desc h6_r_ccu_desc; +extern const struct ccu_desc r40_ccu_desc; +extern const struct ccu_desc v3s_ccu_desc; + +static const struct udevice_id sunxi_clk_ids[] = { +#ifdef CONFIG_CLK_SUN4I_A10 + { .compatible = "allwinner,sun4i-a10-ccu", + .data = (ulong)&a10_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN5I_A10S + { .compatible = "allwinner,sun5i-a10s-ccu", + .data = (ulong)&a10s_ccu_desc }, + { .compatible = "allwinner,sun5i-a13-ccu", + .data = (ulong)&a10s_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN6I_A31 + { .compatible = "allwinner,sun6i-a31-ccu", + .data = (ulong)&a31_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN4I_A10 + { .compatible = "allwinner,sun7i-a20-ccu", + .data = (ulong)&a10_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_A23 + { .compatible = "allwinner,sun8i-a23-ccu", + .data = (ulong)&a23_ccu_desc }, + { .compatible = "allwinner,sun8i-a33-ccu", + .data = (ulong)&a23_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_A83T + { .compatible = "allwinner,sun8i-a83t-ccu", + .data = (ulong)&a83t_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN6I_A31_R + { .compatible = "allwinner,sun8i-a83t-r-ccu", + .data = (ulong)&a31_r_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_H3 + { .compatible = "allwinner,sun8i-h3-ccu", + .data = (ulong)&h3_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN6I_A31_R + { .compatible = "allwinner,sun8i-h3-r-ccu", + .data = (ulong)&a31_r_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_R40 + { .compatible = "allwinner,sun8i-r40-ccu", + .data = (ulong)&r40_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_V3S + { .compatible = "allwinner,sun8i-v3-ccu", + .data = (ulong)&v3s_ccu_desc }, + { .compatible = "allwinner,sun8i-v3s-ccu", + .data = (ulong)&v3s_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN9I_A80 + { .compatible = "allwinner,sun9i-a80-ccu", + .data = (ulong)&a80_ccu_desc }, + { .compatible = "allwinner,sun9i-a80-mmc-config-clk", + .data = (ulong)&a80_mmc_clk_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_A64 + { .compatible = "allwinner,sun50i-a64-ccu", + .data = (ulong)&a64_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN6I_A31_R + { .compatible = "allwinner,sun50i-a64-r-ccu", + .data = (ulong)&a31_r_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN8I_H3 + { .compatible = "allwinner,sun50i-h5-ccu", + .data = (ulong)&h3_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_H6 + { .compatible = "allwinner,sun50i-h6-ccu", + .data = (ulong)&h6_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_H6_R + { .compatible = "allwinner,sun50i-h6-r-ccu", + .data = (ulong)&h6_r_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_H616 + { .compatible = "allwinner,sun50i-h616-ccu", + .data = (ulong)&h616_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUN50I_H6_R + { .compatible = "allwinner,sun50i-h616-r-ccu", + .data = (ulong)&h6_r_ccu_desc }, +#endif +#ifdef CONFIG_CLK_SUNIV_F1C100S + { .compatible = "allwinner,suniv-f1c100s-ccu", + .data = (ulong)&f1c100s_ccu_desc }, +#endif + { } +}; + +U_BOOT_DRIVER(sunxi_clk) = { + .name = "sunxi_clk", + .id = UCLASS_CLK, + .of_match = sunxi_clk_ids, + .bind = sunxi_clk_bind, + .probe = sunxi_clk_probe, + .priv_auto = sizeof(struct ccu_priv), + .ops = &sunxi_clk_ops, +}; diff --git a/drivers/clk/sunxi/clk_v3s.c b/drivers/clk/sunxi/clk_v3s.c index 5b5afa68715..f2fd11eac2c 100644 --- a/drivers/clk/sunxi/clk_v3s.c +++ b/drivers/clk/sunxi/clk_v3s.c @@ -49,27 +49,9 @@ static struct ccu_reset v3s_resets[] = { [RST_BUS_UART2] = RESET(0x2d8, BIT(18)), }; -static const struct ccu_desc v3s_ccu_desc = { +const struct ccu_desc v3s_ccu_desc = { .gates = v3s_gates, .resets = v3s_resets, .num_gates = ARRAY_SIZE(v3s_gates), .num_resets = ARRAY_SIZE(v3s_resets), }; - -static const struct udevice_id v3s_clk_ids[] = { - { .compatible = "allwinner,sun8i-v3s-ccu", - .data = (ulong)&v3s_ccu_desc }, - { .compatible = "allwinner,sun8i-v3-ccu", - .data = (ulong)&v3s_ccu_desc }, - { } -}; - -U_BOOT_DRIVER(clk_sun8i_v3s) = { - .name = "sun8i_v3s_ccu", - .id = UCLASS_CLK, - .of_match = v3s_clk_ids, - .priv_auto = sizeof(struct ccu_priv), - .ops = &sunxi_clk_ops, - .probe = sunxi_clk_probe, - .bind = sunxi_clk_bind, -}; diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index a70119304a7..65da03ee60c 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -85,18 +85,6 @@ struct ccu_priv { const struct ccu_desc *desc; }; -/** - * sunxi_clk_bind - common sunxi clock bind - * @dev: clock device - */ -int sunxi_clk_bind(struct udevice *dev); - -/** - * sunxi_clk_probe - common sunxi clock probe - * @dev: clock device - */ -int sunxi_clk_probe(struct udevice *dev); - extern struct clk_ops sunxi_clk_ops; /** -- cgit v1.3.1 From 5af97b6ff74e3ce7312b3ef533c55f73430fb7d5 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 9 May 2022 00:29:35 -0500 Subject: clk: sunxi: Convert driver private data to platform data All of the driver private data should really be platform data since it is determined statically (selected by the compatible string or extracted from the devicetree). Move everything to platform data, so it can be provided when binding the driver. This is useful for SPL, or for instantiating the driver as part of an MFD. Signed-off-by: Samuel Holland Reviewed-by: Andre Przywara Signed-off-by: Andre Przywara --- drivers/clk/sunxi/clk_sunxi.c | 41 ++++++++++++++++++++++++----------------- include/clk/sunxi.h | 4 ++-- 2 files changed, 26 insertions(+), 19 deletions(-) (limited to 'include') diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c index 8503c797637..5b208c9b34b 100644 --- a/drivers/clk/sunxi/clk_sunxi.c +++ b/drivers/clk/sunxi/clk_sunxi.c @@ -15,19 +15,19 @@ #include #include -static const struct ccu_clk_gate *priv_to_gate(struct ccu_priv *priv, +static const struct ccu_clk_gate *plat_to_gate(struct ccu_plat *plat, unsigned long id) { - if (id >= priv->desc->num_gates) + if (id >= plat->desc->num_gates) return NULL; - return &priv->desc->gates[id]; + return &plat->desc->gates[id]; } static int sunxi_set_gate(struct clk *clk, bool on) { - struct ccu_priv *priv = dev_get_priv(clk->dev); - const struct ccu_clk_gate *gate = priv_to_gate(priv, clk->id); + struct ccu_plat *plat = dev_get_plat(clk->dev); + const struct ccu_clk_gate *gate = plat_to_gate(plat, clk->id); u32 reg; if (gate && (gate->flags & CCU_CLK_F_DUMMY_GATE)) @@ -41,13 +41,13 @@ static int sunxi_set_gate(struct clk *clk, bool on) debug("%s: (CLK#%ld) off#0x%x, BIT(%d)\n", __func__, clk->id, gate->off, ilog2(gate->bit)); - reg = readl(priv->base + gate->off); + reg = readl(plat->base + gate->off); if (on) reg |= gate->bit; else reg &= ~gate->bit; - writel(reg, priv->base + gate->off); + writel(reg, plat->base + gate->off); return 0; } @@ -74,19 +74,10 @@ static int sunxi_clk_bind(struct udevice *dev) static int sunxi_clk_probe(struct udevice *dev) { - struct ccu_priv *priv = dev_get_priv(dev); struct clk_bulk clk_bulk; struct reset_ctl_bulk rst_bulk; int ret; - priv->base = dev_read_addr_ptr(dev); - if (!priv->base) - return -ENOMEM; - - priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev); - if (!priv->desc) - return -EINVAL; - ret = clk_get_bulk(dev, &clk_bulk); if (!ret) clk_enable_bulk(&clk_bulk); @@ -98,6 +89,21 @@ static int sunxi_clk_probe(struct udevice *dev) return 0; } +static int sunxi_clk_of_to_plat(struct udevice *dev) +{ + struct ccu_plat *plat = dev_get_plat(dev); + + plat->base = dev_read_addr_ptr(dev); + if (!plat->base) + return -ENOMEM; + + plat->desc = (const struct ccu_desc *)dev_get_driver_data(dev); + if (!plat->desc) + return -EINVAL; + + return 0; +} + extern const struct ccu_desc a10_ccu_desc; extern const struct ccu_desc a10s_ccu_desc; extern const struct ccu_desc a23_ccu_desc; @@ -213,6 +219,7 @@ U_BOOT_DRIVER(sunxi_clk) = { .of_match = sunxi_clk_ids, .bind = sunxi_clk_bind, .probe = sunxi_clk_probe, - .priv_auto = sizeof(struct ccu_priv), + .of_to_plat = sunxi_clk_of_to_plat, + .plat_auto = sizeof(struct ccu_plat), .ops = &sunxi_clk_ops, }; diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index 65da03ee60c..640b5cfc331 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -75,12 +75,12 @@ struct ccu_desc { }; /** - * struct ccu_priv - sunxi clock control unit + * struct ccu_plat - sunxi clock control unit platform data * * @base: base address * @desc: ccu descriptor */ -struct ccu_priv { +struct ccu_plat { void *base; const struct ccu_desc *desc; }; -- cgit v1.3.1 From 66391263f8484aae41cae80753f31c0edc6138af Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Mon, 9 May 2022 00:29:37 -0500 Subject: reset: sunxi: Reuse the platform data from the clock driver The clock and reset drivers use the exact same platform data. Simplify them by sharing the object. This is safe because the parent device (the clock device) always gets its driver model callbacks run first. Signed-off-by: Samuel Holland Acked-by: Andre Przywara Signed-off-by: Andre Przywara --- drivers/clk/sunxi/clk_sunxi.c | 7 ++++++- drivers/reset/reset-sunxi.c | 43 +++---------------------------------------- include/clk/sunxi.h | 8 -------- 3 files changed, 9 insertions(+), 49 deletions(-) (limited to 'include') diff --git a/drivers/clk/sunxi/clk_sunxi.c b/drivers/clk/sunxi/clk_sunxi.c index 5b208c9b34b..ec02a2d0370 100644 --- a/drivers/clk/sunxi/clk_sunxi.c +++ b/drivers/clk/sunxi/clk_sunxi.c @@ -12,9 +12,12 @@ #include #include #include +#include #include #include +extern U_BOOT_DRIVER(sunxi_reset); + static const struct ccu_clk_gate *plat_to_gate(struct ccu_plat *plat, unsigned long id) { @@ -69,7 +72,9 @@ struct clk_ops sunxi_clk_ops = { static int sunxi_clk_bind(struct udevice *dev) { - return sunxi_reset_bind(dev); + /* Reuse the platform data for the reset driver. */ + return device_bind(dev, DM_DRIVER_REF(sunxi_reset), "reset", + dev_get_plat(dev), dev_ofnode(dev), NULL); } static int sunxi_clk_probe(struct udevice *dev) diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c index f5c66dde43a..e484d1fff44 100644 --- a/drivers/reset/reset-sunxi.c +++ b/drivers/reset/reset-sunxi.c @@ -12,17 +12,10 @@ #include #include #include -#include -#include #include #include -struct sunxi_reset_plat { - void *base; - const struct ccu_desc *desc; -}; - -static const struct ccu_reset *plat_to_reset(struct sunxi_reset_plat *plat, +static const struct ccu_reset *plat_to_reset(struct ccu_plat *plat, unsigned long id) { return &plat->desc->resets[id]; @@ -30,7 +23,7 @@ static const struct ccu_reset *plat_to_reset(struct sunxi_reset_plat *plat, static int sunxi_reset_request(struct reset_ctl *reset_ctl) { - struct sunxi_reset_plat *plat = dev_get_plat(reset_ctl->dev); + struct ccu_plat *plat = dev_get_plat(reset_ctl->dev); debug("%s: (RST#%ld)\n", __func__, reset_ctl->id); @@ -42,7 +35,7 @@ static int sunxi_reset_request(struct reset_ctl *reset_ctl) static int sunxi_set_reset(struct reset_ctl *reset_ctl, bool on) { - struct sunxi_reset_plat *plat = dev_get_plat(reset_ctl->dev); + struct ccu_plat *plat = dev_get_plat(reset_ctl->dev); const struct ccu_reset *reset = plat_to_reset(plat, reset_ctl->id); u32 reg; @@ -81,38 +74,8 @@ struct reset_ops sunxi_reset_ops = { .rst_deassert = sunxi_reset_deassert, }; -static int sunxi_reset_of_to_plat(struct udevice *dev) -{ - struct sunxi_reset_plat *plat = dev_get_plat(dev); - - plat->base = dev_read_addr_ptr(dev); - - return 0; -} - -int sunxi_reset_bind(struct udevice *dev) -{ - struct udevice *rst_dev; - struct sunxi_reset_plat *plat; - int ret; - - ret = device_bind_driver_to_node(dev, "sunxi_reset", "reset", - dev_ofnode(dev), &rst_dev); - if (ret) { - debug("failed to bind sunxi_reset driver (ret=%d)\n", ret); - return ret; - } - plat = malloc(sizeof(struct sunxi_reset_plat)); - plat->desc = (const struct ccu_desc *)dev_get_driver_data(dev); - dev_set_plat(rst_dev, plat); - - return 0; -} - U_BOOT_DRIVER(sunxi_reset) = { .name = "sunxi_reset", .id = UCLASS_RESET, .ops = &sunxi_reset_ops, - .of_to_plat = sunxi_reset_of_to_plat, - .plat_auto = sizeof(struct sunxi_reset_plat), }; diff --git a/include/clk/sunxi.h b/include/clk/sunxi.h index 640b5cfc331..c298195c51e 100644 --- a/include/clk/sunxi.h +++ b/include/clk/sunxi.h @@ -87,12 +87,4 @@ struct ccu_plat { extern struct clk_ops sunxi_clk_ops; -/** - * sunxi_reset_bind() - reset binding - * - * @dev: reset device - * Return: 0 success, or error value - */ -int sunxi_reset_bind(struct udevice *dev); - #endif /* _CLK_SUNXI_H */ -- cgit v1.3.1 From 93118438243ba428b7f3949a3ba14a9ae54b7381 Mon Sep 17 00:00:00 2001 From: Andre Przywara Date: Mon, 4 Jul 2022 15:10:03 +0100 Subject: sunxi: configs: streamline include/configs/sun*.h wrappers For mostly historic reasons we had configuration headers for each Allwinner CPU "family". These days they are mostly just including one common header, with the rest being somewhat empty. There were attempts to remove them, and to just use the one common header to begin with, but this has implications to the build system, which me might not be ready for, yet. To document this behaviour, and to avoid something sneaking in over time, make those files all the same (minus the CPU family name and the copyrights), and add a comment explaining that. This makes it easier to just remove those files later on, when needed and possible. Signed-off-by: Andre Przywara Reviewed-by: Tom Rini --- include/configs/sun4i.h | 10 ++-------- include/configs/sun50i.h | 19 ++----------------- include/configs/sun5i.h | 10 ++-------- include/configs/sun6i.h | 7 ++----- include/configs/sun7i.h | 6 ++---- include/configs/sun8i.h | 13 ++----------- include/configs/sun9i.h | 11 ++--------- include/configs/suniv.h | 7 ++----- 8 files changed, 16 insertions(+), 67 deletions(-) (limited to 'include') diff --git a/include/configs/sun4i.h b/include/configs/sun4i.h index 0e1baa91bb1..70d451f2243 100644 --- a/include/configs/sun4i.h +++ b/include/configs/sun4i.h @@ -2,18 +2,12 @@ /* * (C) Copyright 2012-2013 Henrik Nordstrom * - * Configuration settings for the Allwinner A10 (sun4i) CPU + * Placeholder wrapper to allow addressing Allwinner A10 (sun4i) CPU + * based devices separately. Please do not add anything in here. */ #ifndef __CONFIG_H #define __CONFIG_H -/* - * A10 specific configuration - */ - -/* - * Include common sunxi configuration where most the settings are - */ #include #endif /* __CONFIG_H */ diff --git a/include/configs/sun50i.h b/include/configs/sun50i.h index bc2e3a3d008..dfcb321d425 100644 --- a/include/configs/sun50i.h +++ b/include/configs/sun50i.h @@ -1,26 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Configuration settings for the Allwinner A64 (sun50i) CPU + * Placeholder wrapper to allow addressing Allwinner A64 (and later) sun50i + * CPU based devices separately. Please do not add anything in here. */ - #ifndef __CONFIG_H #define __CONFIG_H -/* - * A64 specific configuration - */ - -#ifndef CONFIG_SUN50I_GEN_H6 -#define GICD_BASE 0x1c81000 -#define GICC_BASE 0x1c82000 -#else -#define GICD_BASE 0x3021000 -#define GICC_BASE 0x3022000 -#endif - -/* - * Include common sunxi configuration where most the settings are - */ #include #endif /* __CONFIG_H */ diff --git a/include/configs/sun5i.h b/include/configs/sun5i.h index ada18de7537..30173078548 100644 --- a/include/configs/sun5i.h +++ b/include/configs/sun5i.h @@ -2,18 +2,12 @@ /* * (C) Copyright 2012-2013 Henrik Nordstrom * - * Configuration settings for the Allwinner A13 (sun5i) CPU + * Placeholder wrapper to allow addressing Allwinner A13 (sun5i) CPU + * based devices separately. Please do not add anything in here. */ #ifndef __CONFIG_H #define __CONFIG_H -/* - * High Level Configuration Options - */ - -/* - * Include common sunxi configuration where most the settings are - */ #include #endif /* __CONFIG_H */ diff --git a/include/configs/sun6i.h b/include/configs/sun6i.h index 0b1fedda108..cbe04ac3c23 100644 --- a/include/configs/sun6i.h +++ b/include/configs/sun6i.h @@ -4,15 +4,12 @@ * (C) Copyright 2013 Luke Kenneth Casson Leighton * (C) Copyright 2013 Maxime Ripard * - * Configuration settings for the Allwinner A31 (sun6i) CPU + * Placeholder wrapper to allow addressing Allwinner A31 (sun6i) CPU + * based devices separately. Please do not add anything in here. */ - #ifndef __CONFIG_H #define __CONFIG_H -/* - * Include common sunxi configuration where most the settings are - */ #include #endif /* __CONFIG_H */ diff --git a/include/configs/sun7i.h b/include/configs/sun7i.h index bc2779fa26f..ad24ab98b52 100644 --- a/include/configs/sun7i.h +++ b/include/configs/sun7i.h @@ -3,14 +3,12 @@ * (C) Copyright 2012-2013 Henrik Nordstrom * (C) Copyright 2013 Luke Kenneth Casson Leighton * - * Configuration settings for the Allwinner A20 (sun7i) CPU + * Placeholder wrapper to allow addressing Allwinner A20 (sun7i) CPU + * based devices separately. Please do not add anything in here. */ #ifndef __CONFIG_H #define __CONFIG_H -/* - * Include common sunxi configuration where most the settings are - */ #include #endif /* __CONFIG_H */ diff --git a/include/configs/sun8i.h b/include/configs/sun8i.h index 106139d0904..b6cd8d39a8f 100644 --- a/include/configs/sun8i.h +++ b/include/configs/sun8i.h @@ -2,21 +2,12 @@ /* * (C) Copyright 2014 Chen-Yu Tsai * - * Configuration settings for the Allwinner A23 (sun8i) CPU + * Placeholder wrapper to allow addressing Allwinner A23 (and later) sun8i + * CPU based devices separately. Please do not add anything in here. */ - #ifndef __CONFIG_H #define __CONFIG_H -/* - * A23 specific configuration - */ - -#include - -/* - * Include common sunxi configuration where most the settings are - */ #include #endif /* __CONFIG_H */ diff --git a/include/configs/sun9i.h b/include/configs/sun9i.h index 6ee08cf0d95..6bf5fc3f66a 100644 --- a/include/configs/sun9i.h +++ b/include/configs/sun9i.h @@ -2,19 +2,12 @@ /* * (C) Copyright 2015 Hans de Goede * - * Configuration settings for the Allwinner A80 (sun9i) CPU + * Placeholder wrapper to allow addressing Allwinner A80 (sun9i) CPU + * based devices separately. Please do not add anything in here. */ - #ifndef __CONFIG_H #define __CONFIG_H -/* - * A80 specific configuration - */ - -/* - * Include common sunxi configuration where most the settings are - */ #include #endif /* __CONFIG_H */ diff --git a/include/configs/suniv.h b/include/configs/suniv.h index 6118cd5e1a6..9cc1a77f6c8 100644 --- a/include/configs/suniv.h +++ b/include/configs/suniv.h @@ -1,14 +1,11 @@ /* SPDX-License-Identifier: GPL-2.0+ */ /* - * Configuration settings for new Allwinner F-series (suniv) CPU + * Placeholder wrapper to allow addressing Allwinner F-series (suniv) CPU + * based devices separately. Please do not add anything in here. */ - #ifndef __CONFIG_H #define __CONFIG_H -/* - * Include common sunxi configuration where most the settings are - */ #include #endif /* __CONFIG_H */ -- cgit v1.3.1