[PATCH 4/7] clk: sunxi: Use a single driver for all variants

2022-05-08 Thread Samuel Holland
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 
---

 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(-)

diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
index e5374f6cf0..4752a1167b 100644
--- a/drivers/clk/sunxi/clk_a10.c
+++ b/drivers/clk/sunxi/clk_a10.c
@@ -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,
-};
diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
index 07d518c121..9619c5f935 100644
--- a/drivers/clk/sunxi/clk_a10s.c
+++ b/drivers/clk/sunxi/clk_a10s.c
@@ -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,
-};
diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
index 9c0e5db07c..5e19c11c23 100644
--- a/drivers/clk/sunxi/clk_a23.c
+++ b/drivers/clk/sunxi/clk_a23.c
@@ -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,
-};
diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
index 3d0767e290..0f58ea 100644
--- a/drivers/clk/sunxi/clk_a31.c
+++ b/drivers/clk/sunxi/clk_a31.c
@@ -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_reset

Re: [PATCH 4/7] clk: sunxi: Use a single driver for all variants

2022-06-26 Thread Andre Przywara
On Mon,  9 May 2022 00:29:34 -0500
Samuel Holland  wrote:

Hi,

> 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 

Nice one, I like that cleanup. Again I added support for the F1C100s.

Reviewed-by: Andre Przywara 

Cheers,
Andre

> ---
> 
>  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(-)
> 
> diff --git a/drivers/clk/sunxi/clk_a10.c b/drivers/clk/sunxi/clk_a10.c
> index e5374f6cf0..4752a1167b 100644
> --- a/drivers/clk/sunxi/clk_a10.c
> +++ b/drivers/clk/sunxi/clk_a10.c
> @@ -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,
> -};
> diff --git a/drivers/clk/sunxi/clk_a10s.c b/drivers/clk/sunxi/clk_a10s.c
> index 07d518c121..9619c5f935 100644
> --- a/drivers/clk/sunxi/clk_a10s.c
> +++ b/drivers/clk/sunxi/clk_a10s.c
> @@ -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,
> -};
> diff --git a/drivers/clk/sunxi/clk_a23.c b/drivers/clk/sunxi/clk_a23.c
> index 9c0e5db07c..5e19c11c23 100644
> --- a/drivers/clk/sunxi/clk_a23.c
> +++ b/drivers/clk/sunxi/clk_a23.c
> @@ -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,
> -};
> diff --git a/drivers/clk/sunxi/clk_a31.c b/drivers/clk/sunxi/clk_a31.c
> index 3d0767e290..0f58ea 100644
> --- a/drivers/clk/sunxi/clk_a31.c
> +++ b/drivers/clk/sunxi/clk_a31.c
> @@ -87,25 +87,9