clk: sunxi: Out-of-bounds access fix and driver cleanup
Subsystems (4)
Samuel Holland
maintainercover clk: sunxi: Out-of-bounds access fix and driver cleanup
This series fixes an issue with out-of-bounds access to the gate array (patches 1-2), uses the rearranged array size information to remove a bunch of duplicate code (patches 3-4), and then simplifies how the reset driver is bound (patches 5-7).
The original motivation for these changes was adding a driver for the legacy A31/A23/A33 PRCM binding (which I will send separately), and trying to use OF_PLATDATA in SPL (which did not work out). But I think at least some of the cleanup is worth applying on its own.
Patch 4 is generally the same change I made between v1 and v2 of the pinctrl series, using some #ifdefs to share a U_BOOT_DRIVER. It's not quite as clean as the pinctrl case, because here the SoC-specific parts are in different files, so all of the CCU descriptors have to be global.
Samuel Holland (7):
clk: sunxi: Store the array sizes in the CCU descriptor
clk: sunxi: Prevent out-of-bounds gate array access
reset: sunxi: Get the reset count from the CCU descriptor
clk: sunxi: Use a single driver for all variants
clk: sunxi: Convert driver private data to platform data
reset: sunxi: Convert driver private data to platform data
reset: sunxi: Reuse the platform data from the clock driver
drivers/clk/sunxi/clk_a10.c | 27 +----- drivers/clk/sunxi/clk_a10s.c | 27 +----- drivers/clk/sunxi/clk_a23.c | 27 +----- drivers/clk/sunxi/clk_a31.c | 25 +---- drivers/clk/sunxi/clk_a31_r.c | 29 +----- drivers/clk/sunxi/clk_a64.c | 25 +---- drivers/clk/sunxi/clk_a80.c | 36 ++------ drivers/clk/sunxi/clk_a83t.c | 25 +---- drivers/clk/sunxi/clk_h3.c | 27 +----- drivers/clk/sunxi/clk_h6.c | 25 +---- drivers/clk/sunxi/clk_h616.c | 25 +---- drivers/clk/sunxi/clk_h6_r.c | 27 +----- drivers/clk/sunxi/clk_r40.c | 25 +---- drivers/clk/sunxi/clk_sunxi.c | 168 ++++++++++++++++++++++++++++++---- drivers/clk/sunxi/clk_v3s.c | 27 +----- drivers/reset/reset-sunxi.c | 55 ++--------- include/clk/sunxi.h | 21 +---- 17 files changed, 208 insertions(+), 413 deletions(-)
Signature · 1 line
2.35.1
Samuel Holland
maintainerPATCH 1/7 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.
---
drivers/clk/sunxi/clk_a10.c | 2 ++ drivers/clk/sunxi/clk_a10s.c | 2 ++ drivers/clk/sunxi/clk_a23.c | 2 ++ drivers/clk/sunxi/clk_a31.c | 2 ++ drivers/clk/sunxi/clk_a31_r.c | 2 ++ drivers/clk/sunxi/clk_a64.c | 2 ++ drivers/clk/sunxi/clk_a80.c | 4 ++++ drivers/clk/sunxi/clk_a83t.c | 2 ++ drivers/clk/sunxi/clk_h3.c | 2 ++ drivers/clk/sunxi/clk_h6.c | 2 ++ drivers/clk/sunxi/clk_h616.c | 2 ++ drivers/clk/sunxi/clk_h6_r.c | 2 ++ drivers/clk/sunxi/clk_r40.c | 2 ++ drivers/clk/sunxi/clk_v3s.c | 2 ++ include/clk/sunxi.h | 2 ++ 15 files changed, 32 insertions(+)
drivers/clk/sunxi/clk_a10.c +2 -0
@@ -65,6 +65,8 @@ static struct ccu_reset a10_resets[] = {static 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 int a10_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_a10s.c +2 -0
@@ -50,6 +50,8 @@ static struct ccu_reset a10s_resets[] = {static 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 int a10s_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_a23.c +2 -0
@@ -69,6 +69,8 @@ static struct ccu_reset a23_resets[] = {static 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 int a23_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_a31.c +2 -0
@@ -90,6 +90,8 @@ static struct ccu_reset a31_resets[] = {static 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 int a31_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_a31_r.c +2 -0
@@ -31,6 +31,8 @@ static struct ccu_reset a31_r_resets[] = {static 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 int a31_r_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_a64.c +2 -0
@@ -76,6 +76,8 @@ static const struct ccu_reset a64_resets[] = {static 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 int a64_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_a80.c +4 -0
@@ -75,11 +75,15 @@ static const struct ccu_reset a80_mmc_resets[] = {static 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 = { .gates = a80_mmc_gates, .resets = a80_mmc_resets, + .num_gates =ARRAY_SIZE (a80_mmc_gates), + .num_resets =ARRAY_SIZE (a80_mmc_resets), };static int a80_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_a83t.c +2 -0
@@ -73,6 +73,8 @@ static struct ccu_reset a83t_resets[] = {static 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 int a83t_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_h3.c +2 -0
@@ -89,6 +89,8 @@ static struct ccu_reset h3_resets[] = {static 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 int h3_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_h6.c +2 -0
@@ -90,6 +90,8 @@ static struct ccu_reset h6_resets[] = {static 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 int h6_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_h616.c +2 -0
@@ -108,6 +108,8 @@ static struct ccu_reset h616_resets[] = {static 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 int h616_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_h6_r.c +2 -0
@@ -35,6 +35,8 @@ static struct ccu_reset h6_r_resets[] = {static 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 int h6_r_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_r40.c +2 -0
@@ -100,6 +100,8 @@ static struct ccu_reset r40_resets[] = {static 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 int r40_clk_bind (struct udevice *dev)
drivers/clk/sunxi/clk_v3s.c +2 -0
@@ -50,6 +50,8 @@ static struct ccu_reset v3s_resets[] = {static 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 int v3s_clk_bind (struct udevice *dev)
include/clk/sunxi.h +2 -0
@@ -65,6 +65,8 @@ struct ccu_reset {struct ccu_desc {const struct ccu_clk_gate *gates;const struct ccu_reset *resets; +u8 num_gates; +u8 num_resets; };/**
Signature · 1 line
2.35.1
Re: [PATCH 1/7] clk: sunxi: Store the array sizes in the CCU descriptor
Quoted 6 lines · On Mon, 9 May 2022 00:29:31 -0500 Samuel Holland <[email protected]> wrote:
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.
Checked for typos, all fine. Added the F1C100s on the way.
Quoted 2 lines
Signed-off-by Samuel Holland <[email protected]>
Thanks,
Andre
Quoted 221 lines
---
drivers/clk/sunxi/clk_a10.c | 2 ++ drivers/clk/sunxi/clk_a10s.c | 2 ++ drivers/clk/sunxi/clk_a23.c | 2 ++ drivers/clk/sunxi/clk_a31.c | 2 ++ drivers/clk/sunxi/clk_a31_r.c | 2 ++ drivers/clk/sunxi/clk_a64.c | 2 ++ drivers/clk/sunxi/clk_a80.c | 4 ++++ drivers/clk/sunxi/clk_a83t.c | 2 ++ drivers/clk/sunxi/clk_h3.c | 2 ++ drivers/clk/sunxi/clk_h6.c | 2 ++ drivers/clk/sunxi/clk_h616.c | 2 ++ drivers/clk/sunxi/clk_h6_r.c | 2 ++ drivers/clk/sunxi/clk_r40.c | 2 ++ drivers/clk/sunxi/clk_v3s.c | 2 ++ include/clk/sunxi.h | 2 ++ 15 files changed, 32 insertions(+)drivers/clk/sunxi/clk_a10.c +2
-0@@ -65,6 +65,8 @@ static struct ccu_reset a10_resets[] = {static 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 int a10_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_a10s.c +2
-0@@ -50,6 +50,8 @@ static struct ccu_reset a10s_resets[] = {static 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 int a10s_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_a23.c +2
-0@@ -69,6 +69,8 @@ static struct ccu_reset a23_resets[] = {static 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 int a23_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_a31.c +2
-0@@ -90,6 +90,8 @@ static struct ccu_reset a31_resets[] = {static 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 int a31_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_a31_r.c +2
-0@@ -31,6 +31,8 @@ static struct ccu_reset a31_r_resets[] = {static 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 int a31_r_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_a64.c +2
-0@@ -76,6 +76,8 @@ static const struct ccu_reset a64_resets[] = {static 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 int a64_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_a80.c +4
-0@@ -75,11 +75,15 @@ static const struct ccu_reset a80_mmc_resets[] = {static 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 = { .gates = a80_mmc_gates, .resets = a80_mmc_resets, + .num_gates =ARRAY_SIZE (a80_mmc_gates), + .num_resets =ARRAY_SIZE (a80_mmc_resets), };static int a80_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_a83t.c +2
-0@@ -73,6 +73,8 @@ static struct ccu_reset a83t_resets[] = {static 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 int a83t_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_h3.c +2
-0@@ -89,6 +89,8 @@ static struct ccu_reset h3_resets[] = {static 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 int h3_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_h6.c +2
-0@@ -90,6 +90,8 @@ static struct ccu_reset h6_resets[] = {static 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 int h6_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_h616.c +2
-0@@ -108,6 +108,8 @@ static struct ccu_reset h616_resets[] = {static 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 int h616_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_h6_r.c +2
-0@@ -35,6 +35,8 @@ static struct ccu_reset h6_r_resets[] = {static 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 int h6_r_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_r40.c +2
-0@@ -100,6 +100,8 @@ static struct ccu_reset r40_resets[] = {static 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 int r40_clk_bind (struct udevice *dev)drivers/clk/sunxi/clk_v3s.c +2
-0@@ -50,6 +50,8 @@ static struct ccu_reset v3s_resets[] = {static 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 int v3s_clk_bind (struct udevice *dev)include/clk/sunxi.h +2
-0@@ -65,6 +65,8 @@ struct ccu_reset {struct ccu_desc {const struct ccu_clk_gate *gates;const struct ccu_reset *resets; +u8 num_gates; +u8 num_resets; };/**
Samuel Holland
maintainerPATCH 2/7 clk: sunxi: Prevent out-of-bounds gate array access
In reply to Samuel HollandBecause the gate arrays are not given explicit sizes, the arrays are only as large as the highest-numbered gate described in the driver. However, only a subset of the CCU clocks are needed by U-Boot. So there are valid clock specifiers with indexes greater than the size of the arrays. Referencing any of these clocks causes out-of-bounds access. Fix this by checking the identifier against the size of the array.
---
drivers/clk/sunxi/clk_sunxi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clk/sunxi/clk_sunxi.c +4 -1
@@ -18,6 +18,9 @@static const struct ccu_clk_gate *priv_to_gate (struct ccu_priv *priv,unsigned long id) { +if (id >= priv->desc->num_gates) +return NULL ; +return &priv->desc->gates[id]; }
@@ -27,7 +30,7 @@ static int sunxi_set_gate(struct clk *clk, bool on)const struct ccu_clk_gate *gate =priv_to_gate (priv, clk->id);u32 reg; -if (!(gate->flags &CCU_CLK_F_IS_VALID )) { +if (!gate || !(gate->flags &CCU_CLK_F_IS_VALID )) {printf ("%s: (CLK#%ld) unhandled\n" , __func__, clk->id);return 0 ; }
Signature · 1 line
2.35.1
Re: [PATCH 2/7] clk: sunxi: Prevent out-of-bounds gate array access
Quoted 9 lines · On Mon, 9 May 2022 00:29:32 -0500 Samuel Holland <[email protected]> wrote:
Because the gate arrays are not given explicit sizes, the arrays are only as large as the highest-numbered gate described in the driver. However, only a subset of the CCU clocks are needed by U-Boot. So there are valid clock specifiers with indexes greater than the size of the arrays. Referencing any of these clocks causes out-of-bounds access. Fix this by checking the identifier against the size of the array.
Fixes 0d47bc705651 ("clk: Add Allwinner A64 CLK driver")Signed-off-by Samuel Holland <[email protected]>
That's a good addition! Amended the patch to cover CCU_CLK_F_DUMMY_GATE.
Cheers,
Andre
Quoted 28 lines
---
drivers/clk/sunxi/clk_sunxi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/clk/sunxi/clk_sunxi.c +4
-1@@ -18,6 +18,9 @@static const struct ccu_clk_gate *priv_to_gate (struct ccu_priv *priv,unsigned long id) { +if (id >= priv->desc->num_gates) +return NULL ; +return &priv->desc->gates[id]; }@@ -27,7 +30,7 @@ static int sunxi_set_gate(struct clk *clk, bool on)const struct ccu_clk_gate *gate =priv_to_gate (priv, clk->id);u32 reg; -if (!(gate->flags &CCU_CLK_F_IS_VALID )) { +if (!gate || !(gate->flags &CCU_CLK_F_IS_VALID )) {printf ("%s: (CLK#%ld) unhandled\n" , __func__, clk->id);return 0 ; }
Samuel Holland
maintainerPATCH 3/7 reset: sunxi: Get the reset count from the CCU descriptor
In reply to Samuel HollandThis allows all of the clock drivers to use a common bind function.
---
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_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 +++++++-- 17 files changed, 28 insertions(+), 95 deletions(-)
drivers/clk/sunxi/clk_a10.c +1 -6
@@ -69,11 +69,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 },
@@ -89,5 +84,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, };
drivers/clk/sunxi/clk_a10s.c +1 -6
@@ -54,11 +54,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 },
@@ -74,5 +69,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, };
drivers/clk/sunxi/clk_a23.c +1 -6
@@ -73,11 +73,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 },
@@ -93,5 +88,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, };
drivers/clk/sunxi/clk_a31.c +1 -6
@@ -94,11 +94,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 },
@@ -112,5 +107,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, };
drivers/clk/sunxi/clk_a31_r.c +1 -6
@@ -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, };
drivers/clk/sunxi/clk_a64.c +1 -6
@@ -80,11 +80,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 },
@@ -98,5 +93,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, };
drivers/clk/sunxi/clk_a80.c +1 -11
@@ -86,16 +86,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 },
@@ -111,5 +101,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, };
drivers/clk/sunxi/clk_a83t.c +1 -6
@@ -77,11 +77,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 },
@@ -95,5 +90,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, };
drivers/clk/sunxi/clk_h3.c +1 -6
@@ -93,11 +93,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 },
@@ -113,5 +108,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, };
drivers/clk/sunxi/clk_h6.c +1 -6
@@ -94,11 +94,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 },
@@ -112,5 +107,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, };
drivers/clk/sunxi/clk_h616.c +1 -6
@@ -112,11 +112,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 },
@@ -130,5 +125,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, };
drivers/clk/sunxi/clk_h6_r.c +1 -6
@@ -39,11 +39,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 },
@@ -59,5 +54,5 @@ U_BOOT_DRIVER(clk_sun6i_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, };
drivers/clk/sunxi/clk_r40.c +1 -6
@@ -104,11 +104,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 },
@@ -122,5 +117,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, };
drivers/clk/sunxi/clk_sunxi.c +5 -0
@@ -64,6 +64,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);
drivers/clk/sunxi/clk_v3s.c +1 -6
@@ -54,11 +54,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 },
@@ -74,5 +69,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, };
drivers/reset/reset-sunxi.c +2 -4
@@ -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 ;
@@ -99,7 +98,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;
@@ -112,7 +111,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);
include/clk/sunxi.h +7 -2
@@ -80,6 +80,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
@@ -92,9 +98,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 */
Signature · 1 line
2.35.1
Re: [PATCH 3/7] reset: sunxi: Get the reset count from the CCU descriptor
Quoted 1 line · On Mon, 9 May 2022 00:29:33 -0500 Samuel Holland <[email protected]> wrote:
This allows all of the clock drivers to use a common bind function.
Looks good, and a nice cleanup. Added the F1C100s on the way.
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>
Thanks,
Andre
Quoted 430 lines
---
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_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 +++++++-- 17 files changed, 28 insertions(+), 95 deletions(-)drivers/clk/sunxi/clk_a10.c +1
-6@@ -69,11 +69,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 },@@ -89,5 +84,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, };drivers/clk/sunxi/clk_a10s.c +1
-6@@ -54,11 +54,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 },@@ -74,5 +69,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, };drivers/clk/sunxi/clk_a23.c +1
-6@@ -73,11 +73,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 },@@ -93,5 +88,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, };drivers/clk/sunxi/clk_a31.c +1
-6@@ -94,11 +94,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 },@@ -112,5 +107,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, };drivers/clk/sunxi/clk_a31_r.c +1
-6@@ -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, };drivers/clk/sunxi/clk_a64.c +1
-6@@ -80,11 +80,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 },@@ -98,5 +93,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, };drivers/clk/sunxi/clk_a80.c +1
-11@@ -86,16 +86,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 },@@ -111,5 +101,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, };drivers/clk/sunxi/clk_a83t.c +1
-6@@ -77,11 +77,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 },@@ -95,5 +90,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, };drivers/clk/sunxi/clk_h3.c +1
-6@@ -93,11 +93,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 },@@ -113,5 +108,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, };drivers/clk/sunxi/clk_h6.c +1
-6@@ -94,11 +94,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 },@@ -112,5 +107,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, };drivers/clk/sunxi/clk_h616.c +1
-6@@ -112,11 +112,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 },@@ -130,5 +125,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, };drivers/clk/sunxi/clk_h6_r.c +1
-6@@ -39,11 +39,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 },@@ -59,5 +54,5 @@ U_BOOT_DRIVER(clk_sun6i_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, };drivers/clk/sunxi/clk_r40.c +1
-6@@ -104,11 +104,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 },@@ -122,5 +117,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, };drivers/clk/sunxi/clk_sunxi.c +5
-0@@ -64,6 +64,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);drivers/clk/sunxi/clk_v3s.c +1
-6@@ -54,11 +54,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 },@@ -74,5 +69,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, };drivers/reset/reset-sunxi.c +2
-4@@ -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 ;@@ -99,7 +98,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;@@ -112,7 +111,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);include/clk/sunxi.h +7
-2@@ -80,6 +80,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 @@ -92,9 +98,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 */
Samuel Holland
maintainerPATCH 4/7 clk: sunxi: Use a single driver for all variants
In reply to Samuel HollandNow 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.
---
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_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 | 118 +++++++++++++++++++++++++++++++++- drivers/clk/sunxi/clk_v3s.c | 20 +----- include/clk/sunxi.h | 12 ---- 16 files changed, 131 insertions(+), 271 deletions(-)
drivers/clk/sunxi/clk_a10.c +1 -19
@@ -62,27 +62,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, -};
drivers/clk/sunxi/clk_a10s.c +1 -19
@@ -47,27 +47,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, -};
drivers/clk/sunxi/clk_a23.c +1 -19
@@ -66,27 +66,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, -};
drivers/clk/sunxi/clk_a31.c +1 -17
@@ -87,25 +87,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, -};
drivers/clk/sunxi/clk_a31_r.c +1 -21
@@ -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, -};
drivers/clk/sunxi/clk_a64.c +1 -17
@@ -73,25 +73,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, -};
drivers/clk/sunxi/clk_a80.c +2 -20
@@ -72,34 +72,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, -};
drivers/clk/sunxi/clk_a83t.c +1 -17
@@ -70,25 +70,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, -};
drivers/clk/sunxi/clk_h3.c +1 -19
@@ -86,27 +86,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, -};
drivers/clk/sunxi/clk_h6.c +1 -17
@@ -87,25 +87,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, -};
drivers/clk/sunxi/clk_h616.c +1 -17
@@ -105,25 +105,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, -};
drivers/clk/sunxi/clk_h6_r.c +1 -19
@@ -32,27 +32,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_sun6i_h6_r) = { - .name ="sun6i_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, -};
drivers/clk/sunxi/clk_r40.c +1 -17
@@ -97,25 +97,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, -};
drivers/clk/sunxi/clk_sunxi.c +116 -2
131 lines not on this page · raw message
drivers/clk/sunxi/clk_v3s.c +1 -19
@@ -47,27 +47,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, -};
include/clk/sunxi.h +0 -12
@@ -80,18 +80,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;/**
Signature · 1 line
2.35.1
Re: [PATCH 4/7] clk: sunxi: Use a single driver for all variants
On Mon, 9 May 2022 00:29:34 -0500
Samuel Holland <[email protected]> wrote:
Hi,
Quoted 6 lines
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 <[email protected]>
Nice one, I like that cleanup. Again I added support for the F1C100s.
Cheers,
Andre
Quoted 640 lines
---
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_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 | 118 +++++++++++++++++++++++++++++++++- drivers/clk/sunxi/clk_v3s.c | 20 +----- include/clk/sunxi.h | 12 ---- 16 files changed, 131 insertions(+), 271 deletions(-)drivers/clk/sunxi/clk_a10.c +1
-19@@ -62,27 +62,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, -};drivers/clk/sunxi/clk_a10s.c +1
-19@@ -47,27 +47,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, -};drivers/clk/sunxi/clk_a23.c +1
-19@@ -66,27 +66,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, -};drivers/clk/sunxi/clk_a31.c +1
-17@@ -87,25 +87,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, -};drivers/clk/sunxi/clk_a31_r.c +1
-21@@ -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, -};drivers/clk/sunxi/clk_a64.c +1
-17@@ -73,25 +73,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, -};drivers/clk/sunxi/clk_a80.c +2
-20@@ -72,34 +72,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, -};drivers/clk/sunxi/clk_a83t.c +1
-17@@ -70,25 +70,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, -};drivers/clk/sunxi/clk_h3.c +1
-19@@ -86,27 +86,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, -};drivers/clk/sunxi/clk_h6.c +1
-17@@ -87,25 +87,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, -};drivers/clk/sunxi/clk_h616.c +1
-17@@ -105,25 +105,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, -};drivers/clk/sunxi/clk_h6_r.c +1
-19@@ -32,27 +32,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_sun6i_h6_r) = { - .name ="sun6i_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, -};drivers/clk/sunxi/clk_r40.c +1
-17@@ -97,25 +97,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, -};drivers/clk/sunxi/clk_sunxi.c +116
-2@@ -64,12 +64,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;@@ -94,3 +94,117 @@ 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 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 + { } +}; + +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, +};drivers/clk/sunxi/clk_v3s.c +1
-19@@ -47,27 +47,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, -};include/clk/sunxi.h +0
-12@@ -80,18 +80,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;/**
Samuel Holland
maintainerPATCH 5/7 clk: sunxi: Convert driver private data to platform data
In reply to Samuel HollandAll 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.
---
drivers/clk/sunxi/clk_sunxi.c | 41 ++++++++++++++++++++--------------- include/clk/sunxi.h | 4 ++-- 2 files changed, 26 insertions(+), 19 deletions(-)
drivers/clk/sunxi/clk_sunxi.c +24 -17
@@ -15,19 +15,19 @@#include <linux/bitops.h> #include <linux/log2.h> -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_IS_VALID )) {
@@ -38,13 +38,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 ; }
@@ -71,19 +71,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);
@@ -95,6 +86,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;
@@ -205,6 +211,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, };
include/clk/sunxi.h +2 -2
@@ -70,12 +70,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; };
Signature · 1 line
2.35.1
Re: [PATCH 5/7] clk: sunxi: Convert driver private data to platform data
Quoted 5 lines · On Mon, 9 May 2022 00:29:35 -0500 Samuel Holland <[email protected]> wrote:
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.
Indeed, nothing in struct ccu_priv is private to the instance (of where there is really only one anyway).
Confirmed to be mostly s/priv/plat/, the rest looks fine as well.
Cheers,
Andre
Quoted 123 lines
Signed-off-by Samuel Holland <[email protected]>---
drivers/clk/sunxi/clk_sunxi.c | 41 ++++++++++++++++++++--------------- include/clk/sunxi.h | 4 ++-- 2 files changed, 26 insertions(+), 19 deletions(-)drivers/clk/sunxi/clk_sunxi.c +24
-17@@ -15,19 +15,19 @@#include <linux/bitops.h> #include <linux/log2.h> -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_IS_VALID )) {@@ -38,13 +38,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 ; }@@ -71,19 +71,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);@@ -95,6 +86,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;@@ -205,6 +211,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, };include/clk/sunxi.h +2
-2@@ -70,12 +70,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; };
Samuel Holland
maintainerPATCH 6/7 reset: sunxi: Convert driver private data to platform data
In reply to Samuel HollandThe reason here is the same as the reason for changing the clock driver:
platform data can be provided when binding the driver.
---
drivers/reset/reset-sunxi.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/reset/reset-sunxi.c +18 -18
@@ -17,24 +17,24 @@#include <linux/bitops.h> #include <linux/log2.h> -struct sunxi_reset_priv { +struct sunxi_reset_plat {void *base;const struct ccu_desc *desc; }; -static const struct ccu_reset *priv_to_reset (struct sunxi_reset_priv *priv, +static const struct ccu_reset *plat_to_reset (struct sunxi_reset_plat *plat,unsigned long id) { -return &priv->desc->resets[id]; +return &plat->desc->resets[id]; }static int sunxi_reset_request (struct reset_ctl *reset_ctl) { -struct sunxi_reset_priv *priv =dev_get_priv (reset_ctl->dev); +struct sunxi_reset_plat *plat =dev_get_plat (reset_ctl->dev);debug ("%s: (RST#%ld)\n" , __func__, reset_ctl->id); -if (reset_ctl->id >= priv->desc->num_resets) +if (reset_ctl->id >= plat->desc->num_resets)return -EINVAL ;return 0 ;
@@ -49,8 +49,8 @@ static int sunxi_reset_free(struct reset_ctl *reset_ctl)static int sunxi_set_reset (struct reset_ctl *reset_ctl,bool on) { -struct sunxi_reset_priv *priv =dev_get_priv (reset_ctl->dev); -const struct ccu_reset *reset =priv_to_reset (priv, reset_ctl->id); +struct sunxi_reset_plat *plat =dev_get_plat (reset_ctl->dev); +const struct ccu_reset *reset =plat_to_reset (plat, reset_ctl->id);u32 reg;if (!(reset->flags &CCU_RST_F_IS_VALID )) {
@@ -61,13 +61,13 @@ static int sunxi_set_reset(struct reset_ctl *reset_ctl, bool on)debug ("%s: (RST#%ld) off#0x%x, BIT(%d)\n" , __func__, reset_ctl->id, reset->off,ilog2 (reset->bit)); - reg =readl (priv->base + reset->off); + reg =readl (plat->base + reset->off);if (on) reg |= reset->bit;else reg &= ~reset->bit; -writel (reg, priv->base + reset->off); +writel (reg, plat->base + reset->off);return 0 ; }
@@ -89,11 +89,11 @@ struct reset_ops sunxi_reset_ops = { .rst_deassert = sunxi_reset_deassert, }; -static int sunxi_reset_probe (struct udevice *dev) +static int sunxi_reset_of_to_plat (struct udevice *dev) { -struct sunxi_reset_priv *priv =dev_get_priv (dev); +struct sunxi_reset_plat *plat =dev_get_plat (dev); - priv->base =dev_read_addr_ptr (dev); + plat->base =dev_read_addr_ptr (dev);return 0 ; }
@@ -101,7 +101,7 @@ static int sunxi_reset_probe(struct udevice *dev)int sunxi_reset_bind (struct udevice *dev) {struct udevice *rst_dev; -struct sunxi_reset_priv *priv; +struct sunxi_reset_plat *plat;int ret; ret = device_bind_driver_to_node(dev, "sunxi_reset", "reset",
@@ -110,9 +110,9 @@ int sunxi_reset_bind(struct udevice *dev)debug ("failed to bind sunxi_reset driver (ret=%d)\n" , ret);return ret; } - priv =malloc (sizeof (struct sunxi_reset_priv )); - priv->desc = (const struct ccu_desc *)dev_get_driver_data (dev); -dev_set_priv (rst_dev, priv); + 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 ; }
@@ -121,6 +121,6 @@ U_BOOT_DRIVER(sunxi_reset) = { .name = "sunxi_reset", .id = UCLASS_RESET, .ops = &sunxi_reset_ops, - .probe = sunxi_reset_probe, - .priv_auto = sizeof(struct sunxi_reset_priv), + .of_to_plat = sunxi_reset_of_to_plat, + .plat_auto = sizeof(struct sunxi_reset_plat), };
Signature · 1 line
2.35.1
Re: [PATCH 6/7] reset: sunxi: Convert driver private data to platform data
Quoted 2 lines · On Mon, 9 May 2022 00:29:36 -0500 Samuel Holland <[email protected]> wrote:
The reason here is the same as the reason for changing the clock driver:
platform data can be provided when binding the driver.
Yes, that's right. Confirmed to be almost completely s/priv/plat/.
Quoted 1 line
Signed-off-by Samuel Holland <[email protected]>
Cheers,
Andre
Quoted 112 lines
---
drivers/reset/reset-sunxi.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-)drivers/reset/reset-sunxi.c +18
-18@@ -17,24 +17,24 @@#include <linux/bitops.h> #include <linux/log2.h> -struct sunxi_reset_priv { +struct sunxi_reset_plat {void *base;const struct ccu_desc *desc; }; -static const struct ccu_reset *priv_to_reset (struct sunxi_reset_priv *priv, +static const struct ccu_reset *plat_to_reset (struct sunxi_reset_plat *plat,unsigned long id) { -return &priv->desc->resets[id]; +return &plat->desc->resets[id]; }static int sunxi_reset_request (struct reset_ctl *reset_ctl) { -struct sunxi_reset_priv *priv =dev_get_priv (reset_ctl->dev); +struct sunxi_reset_plat *plat =dev_get_plat (reset_ctl->dev);debug ("%s: (RST#%ld)\n" , __func__, reset_ctl->id); -if (reset_ctl->id >= priv->desc->num_resets) +if (reset_ctl->id >= plat->desc->num_resets)return -EINVAL ;return 0 ;@@ -49,8 +49,8 @@ static int sunxi_reset_free(struct reset_ctl *reset_ctl)static int sunxi_set_reset (struct reset_ctl *reset_ctl,bool on) { -struct sunxi_reset_priv *priv =dev_get_priv (reset_ctl->dev); -const struct ccu_reset *reset =priv_to_reset (priv, reset_ctl->id); +struct sunxi_reset_plat *plat =dev_get_plat (reset_ctl->dev); +const struct ccu_reset *reset =plat_to_reset (plat, reset_ctl->id);u32 reg;if (!(reset->flags &CCU_RST_F_IS_VALID )) {@@ -61,13 +61,13 @@ static int sunxi_set_reset(struct reset_ctl *reset_ctl, bool on)debug ("%s: (RST#%ld) off#0x%x, BIT(%d)\n" , __func__, reset_ctl->id, reset->off,ilog2 (reset->bit)); - reg =readl (priv->base + reset->off); + reg =readl (plat->base + reset->off);if (on) reg |= reset->bit;else reg &= ~reset->bit; -writel (reg, priv->base + reset->off); +writel (reg, plat->base + reset->off);return 0 ; }@@ -89,11 +89,11 @@ struct reset_ops sunxi_reset_ops = { .rst_deassert = sunxi_reset_deassert, }; -static int sunxi_reset_probe (struct udevice *dev) +static int sunxi_reset_of_to_plat (struct udevice *dev) { -struct sunxi_reset_priv *priv =dev_get_priv (dev); +struct sunxi_reset_plat *plat =dev_get_plat (dev); - priv->base =dev_read_addr_ptr (dev); + plat->base =dev_read_addr_ptr (dev);return 0 ; }@@ -101,7 +101,7 @@ static int sunxi_reset_probe(struct udevice *dev)int sunxi_reset_bind (struct udevice *dev) {struct udevice *rst_dev; -struct sunxi_reset_priv *priv; +struct sunxi_reset_plat *plat;int ret; ret = device_bind_driver_to_node(dev, "sunxi_reset", "reset",@@ -110,9 +110,9 @@ int sunxi_reset_bind(struct udevice *dev)debug ("failed to bind sunxi_reset driver (ret=%d)\n" , ret);return ret; } - priv =malloc (sizeof (struct sunxi_reset_priv )); - priv->desc = (const struct ccu_desc *)dev_get_driver_data (dev); -dev_set_priv (rst_dev, priv); + 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 ; }@@ -121,6 +121,6 @@ U_BOOT_DRIVER(sunxi_reset) = { .name = "sunxi_reset", .id = UCLASS_RESET, .ops = &sunxi_reset_ops, - .probe = sunxi_reset_probe, - .priv_auto = sizeof(struct sunxi_reset_priv), + .of_to_plat = sunxi_reset_of_to_plat, + .plat_auto = sizeof(struct sunxi_reset_plat), };
Samuel Holland
maintainerPATCH 7/7 reset: sunxi: Reuse the platform data from the clock driver
In reply to Samuel HollandThe 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.
---
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(-)
drivers/clk/sunxi/clk_sunxi.c +6 -1
@@ -12,9 +12,12 @@#include <reset.h> #include <asm/io.h> #include <clk/sunxi.h> +#include <dm/device-internal.h> #include <linux/bitops.h> #include <linux/log2.h> +extern U_BOOT_DRIVER (sunxi_reset); +static const struct ccu_clk_gate *plat_to_gate (struct ccu_plat *plat,unsigned long id) {
@@ -66,7 +69,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)
drivers/reset/reset-sunxi.c +3 -40
72 lines not on this page · raw message
include/clk/sunxi.h +0 -8
@@ -82,12 +82,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 */
Signature · 1 line
2.35.1
Re: [PATCH 7/7] reset: sunxi: Reuse the platform data from the clock driver
On Mon, 9 May 2022 00:29:37 -0500
Samuel Holland <[email protected]> wrote:
Hi,
Quoted 5 lines
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 <[email protected]>
I am not too familiar with U-Boot's DM internals (device_bind()), but the idea is certainly good, and it seems to work, so I am happy with that.
Cheers,
Andre
Quoted 132 lines
---
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(-)drivers/clk/sunxi/clk_sunxi.c +6
-1@@ -12,9 +12,12 @@#include <reset.h> #include <asm/io.h> #include <clk/sunxi.h> +#include <dm/device-internal.h> #include <linux/bitops.h> #include <linux/log2.h> +extern U_BOOT_DRIVER (sunxi_reset); +static const struct ccu_clk_gate *plat_to_gate (struct ccu_plat *plat,unsigned long id) {@@ -66,7 +69,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)drivers/reset/reset-sunxi.c +3
-40@@ -12,17 +12,10 @@#include <reset-uclass.h> #include <asm/io.h> #include <clk/sunxi.h> -#include <dm/device-internal.h> -#include <dm/lists.h> #include <linux/bitops.h> #include <linux/log2.h> -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);@@ -49,7 +42,7 @@ static int sunxi_reset_free(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;@@ -89,38 +82,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 ), };include/clk/sunxi.h +0
-8@@ -82,12 +82,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 */
On Mon, 9 May 2022 00:29:30 -0500
Samuel Holland <[email protected]> wrote:
Hi Samuel,
Quoted 10 lines
This series fixes an issue with out-of-bounds access to the gate array (patches 1-2), uses the rearranged array size information to remove a bunch of duplicate code (patches 3-4), and then simplifies how the reset driver is bound (patches 5-7).
The original motivation for these changes was adding a driver for the legacy A31/A23/A33 PRCM binding (which I will send separately), and trying to use
OF_PLATDATAin SPL (which did not work out). But I think at least some of the cleanup is worth applying on its own.
Quoted 4 lines
Patch 4 is generally the same change I made between v1 and v2 of the pinctrl series, using some #ifdefs to share a
U_BOOT_DRIVER. It's not quite as clean as the pinctrl case, because here the SoC-specific parts are in different files, so all of the CCU descriptors have to be global.
so I skimmed over the series and quite like it: the negative diffstat speaks for itself ;-)
I need to go over each individual patch with more scrutiny (unless someone beats me to it), but assuming no issues, I am planning on taking this for the next merge window.
You mention out-of-bounds accesses: did you actually encounter one with the old or new DTs, that would need fixing now?
Cheers,
Andre
Quoted 28 lines
Samuel Holland (7):
clk: sunxi: Store the array sizes in the CCU descriptor
clk: sunxi: Prevent out-of-bounds gate array access
reset: sunxi: Get the reset count from the CCU descriptor
clk: sunxi: Use a single driver for all variants
clk: sunxi: Convert driver private data to platform data
reset: sunxi: Convert driver private data to platform data
reset: sunxi: Reuse the platform data from the clock driverdrivers/clk/sunxi/clk_a10.c | 27 +----- drivers/clk/sunxi/clk_a10s.c | 27 +----- drivers/clk/sunxi/clk_a23.c | 27 +----- drivers/clk/sunxi/clk_a31.c | 25 +---- drivers/clk/sunxi/clk_a31_r.c | 29 +----- drivers/clk/sunxi/clk_a64.c | 25 +---- drivers/clk/sunxi/clk_a80.c | 36 ++------ drivers/clk/sunxi/clk_a83t.c | 25 +---- drivers/clk/sunxi/clk_h3.c | 27 +----- drivers/clk/sunxi/clk_h6.c | 25 +---- drivers/clk/sunxi/clk_h616.c | 25 +---- drivers/clk/sunxi/clk_h6_r.c | 27 +----- drivers/clk/sunxi/clk_r40.c | 25 +---- drivers/clk/sunxi/clk_sunxi.c | 168 ++++++++++++++++++++++++++++++---- drivers/clk/sunxi/clk_v3s.c | 27 +----- drivers/reset/reset-sunxi.c | 55 ++--------- include/clk/sunxi.h | 21 +---- 17 files changed, 208 insertions(+), 413 deletions(-)
Quoted 35 lines · Samuel Holland
This series fixes an issue with out-of-bounds access to the gate array (patches 1-2), uses the rearranged array size information to remove a bunch of duplicate code (patches 3-4), and then simplifies how the reset driver is bound (patches 5-7).
The original motivation for these changes was adding a driver for the legacy A31/A23/A33 PRCM binding (which I will send separately), and trying to use
OF_PLATDATAin SPL (which did not work out). But I think at least some of the cleanup is worth applying on its own.Patch 4 is generally the same change I made between v1 and v2 of the pinctrl series, using some #ifdefs to share a
U_BOOT_DRIVER. It's not quite as clean as the pinctrl case, because here the SoC-specific parts are in different files, so all of the CCU descriptors have to be global.Samuel Holland (7):
clk: sunxi: Store the array sizes in the CCU descriptor
clk: sunxi: Prevent out-of-bounds gate array access
reset: sunxi: Get the reset count from the CCU descriptor
clk: sunxi: Use a single driver for all variants
clk: sunxi: Convert driver private data to platform data
reset: sunxi: Convert driver private data to platform data
reset: sunxi: Reuse the platform data from the clock driverdrivers/clk/sunxi/clk_a10.c | 27 +----- drivers/clk/sunxi/clk_a10s.c | 27 +----- drivers/clk/sunxi/clk_a23.c | 27 +----- drivers/clk/sunxi/clk_a31.c | 25 +---- drivers/clk/sunxi/clk_a31_r.c | 29 +----- drivers/clk/sunxi/clk_a64.c | 25 +---- drivers/clk/sunxi/clk_a80.c | 36 ++------ drivers/clk/sunxi/clk_a83t.c | 25 +---- drivers/clk/sunxi/clk_h3.c | 27 +----- drivers/clk/sunxi/clk_h6.c | 25 +----
Quoted 9 lines
drivers/clk/sunxi/clk_h616.c | 25 +---- drivers/clk/sunxi/clk_h6_r.c | 27 +----- drivers/clk/sunxi/clk_r40.c | 25 +---- drivers/clk/sunxi/clk_sunxi.c | 168 ++++++++++++++++++++++++++++++---- drivers/clk/sunxi/clk_v3s.c | 27 +----- drivers/reset/reset-sunxi.c | 55 ++--------- include/clk/sunxi.h | 21 +---- 17 files changed, 208 insertions(+), 413 deletions(-)
For this series:
On Mon, 9 May 2022 00:29:30 -0500
Samuel Holland <[email protected]> wrote:
Hi Samuel,
Quoted 10 lines
This series fixes an issue with out-of-bounds access to the gate array (patches 1-2), uses the rearranged array size information to remove a bunch of duplicate code (patches 3-4), and then simplifies how the reset driver is bound (patches 5-7).
The original motivation for these changes was adding a driver for the legacy A31/A23/A33 PRCM binding (which I will send separately), and trying to use
OF_PLATDATAin SPL (which did not work out). But I think at least some of the cleanup is worth applying on its own.
Quoted 4 lines
Patch 4 is generally the same change I made between v1 and v2 of the pinctrl series, using some #ifdefs to share a
U_BOOT_DRIVER. It's not quite as clean as the pinctrl case, because here the SoC-specific parts are in different files, so all of the CCU descriptors have to be global.
Many thanks for your work on this!
So I am done with reviewing this series, and as mentioned quite like it and am fine with it. I added F1C100s support, which got added in U-Boot meanwhile, and pushed that to sunxi/next:
https://source.denx.de/u-boot/custodians/u-boot-sunxi/-/commits/next/
Can you please have a look and confirm that this is fine? I will then send the PR in about two weeks time, if nothing breaks.
Cheers,
Andre
Quoted 28 lines
Samuel Holland (7):
clk: sunxi: Store the array sizes in the CCU descriptor
clk: sunxi: Prevent out-of-bounds gate array access
reset: sunxi: Get the reset count from the CCU descriptor
clk: sunxi: Use a single driver for all variants
clk: sunxi: Convert driver private data to platform data
reset: sunxi: Convert driver private data to platform data
reset: sunxi: Reuse the platform data from the clock driverdrivers/clk/sunxi/clk_a10.c | 27 +----- drivers/clk/sunxi/clk_a10s.c | 27 +----- drivers/clk/sunxi/clk_a23.c | 27 +----- drivers/clk/sunxi/clk_a31.c | 25 +---- drivers/clk/sunxi/clk_a31_r.c | 29 +----- drivers/clk/sunxi/clk_a64.c | 25 +---- drivers/clk/sunxi/clk_a80.c | 36 ++------ drivers/clk/sunxi/clk_a83t.c | 25 +---- drivers/clk/sunxi/clk_h3.c | 27 +----- drivers/clk/sunxi/clk_h6.c | 25 +---- drivers/clk/sunxi/clk_h616.c | 25 +---- drivers/clk/sunxi/clk_h6_r.c | 27 +----- drivers/clk/sunxi/clk_r40.c | 25 +---- drivers/clk/sunxi/clk_sunxi.c | 168 ++++++++++++++++++++++++++++++---- drivers/clk/sunxi/clk_v3s.c | 27 +----- drivers/reset/reset-sunxi.c | 55 ++--------- include/clk/sunxi.h | 21 +---- 17 files changed, 208 insertions(+), 413 deletions(-)
Samuel Holland
maintainerHi Andre,
Quoted 20 lines · Andre Przywara
On Mon, 9 May 2022 00:29:30 -0500
Samuel Holland <[email protected]> wrote:Hi Samuel,
Quoted 10 lines
This series fixes an issue with out-of-bounds access to the gate array (patches 1-2), uses the rearranged array size information to remove a bunch of duplicate code (patches 3-4), and then simplifies how the reset driver is bound (patches 5-7).
The original motivation for these changes was adding a driver for the legacy A31/A23/A33 PRCM binding (which I will send separately), and trying to use
OF_PLATDATAin SPL (which did not work out). But I think at least some of the cleanup is worth applying on its own.Quoted 4 lines
Patch 4 is generally the same change I made between v1 and v2 of the pinctrl series, using some #ifdefs to share a
U_BOOT_DRIVER. It's not quite as clean as the pinctrl case, because here the SoC-specific parts are in different files, so all of the CCU descriptors have to be global.
Quoted 8 lines
Many thanks for your work on this!
So I am done with reviewing this series, and as mentioned quite like it and am fine with it. I added F1C100s support, which got added in U-Boot meanwhile, and pushed that to sunxi/next:
https://source.denx.de/u-boot/custodians/u-boot-sunxi/-/commits/next/Can you please have a look and confirm that this is fine? I will then send the PR in about two weeks time, if nothing breaks.
Looks good to me, and thanks for taking care of F1C100s. My only trivial comment is that you left out Sean's ack.
Regards,
Samuel