]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
reset: sunxi: Get the reset count from the CCU descriptor
authorSamuel Holland <samuel@sholland.org>
Mon, 9 May 2022 05:29:33 +0000 (00:29 -0500)
committerAndre Przywara <andre.przywara@arm.com>
Mon, 18 Jul 2022 08:37:49 +0000 (09:37 +0100)
This allows all of the clock drivers to use a common bind function.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
[Andre: add F1C100s support]
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
18 files changed:
drivers/clk/sunxi/clk_a10.c
drivers/clk/sunxi/clk_a10s.c
drivers/clk/sunxi/clk_a23.c
drivers/clk/sunxi/clk_a31.c
drivers/clk/sunxi/clk_a31_r.c
drivers/clk/sunxi/clk_a64.c
drivers/clk/sunxi/clk_a80.c
drivers/clk/sunxi/clk_a83t.c
drivers/clk/sunxi/clk_f1c100s.c
drivers/clk/sunxi/clk_h3.c
drivers/clk/sunxi/clk_h6.c
drivers/clk/sunxi/clk_h616.c
drivers/clk/sunxi/clk_h6_r.c
drivers/clk/sunxi/clk_r40.c
drivers/clk/sunxi/clk_sunxi.c
drivers/clk/sunxi/clk_v3s.c
drivers/reset/reset-sunxi.c
include/clk/sunxi.h

index b3cca2aa3a08fcc04c52bda5a897b0bfad5136ab..7bd9a379d7cb6ad6784e02677b2cc404eb371819 100644 (file)
@@ -71,11 +71,6 @@ static const struct ccu_desc a10_ccu_desc = {
        .num_resets = ARRAY_SIZE(a10_resets),
 };
 
-static int a10_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(a10_resets));
-}
-
 static const struct udevice_id a10_ccu_ids[] = {
        { .compatible = "allwinner,sun4i-a10-ccu",
          .data = (ulong)&a10_ccu_desc },
@@ -91,5 +86,5 @@ U_BOOT_DRIVER(clk_sun4i_a10) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = a10_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index 0e75c303d062e1fe657ac3067dff87918db3d0da..4a83d6b21594892f3d50970ff4e20d5e13fc0ffb 100644 (file)
@@ -56,11 +56,6 @@ static const struct ccu_desc a10s_ccu_desc = {
        .num_resets = ARRAY_SIZE(a10s_resets),
 };
 
-static int a10s_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(a10s_resets));
-}
-
 static const struct udevice_id a10s_ccu_ids[] = {
        { .compatible = "allwinner,sun5i-a10s-ccu",
          .data = (ulong)&a10s_ccu_desc },
@@ -76,5 +71,5 @@ U_BOOT_DRIVER(clk_sun5i_a10s) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = a10s_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index a9c77bad2084d311061d75634e4cd902b7017d28..c7f516d7333dce515c391a0010d4b5584bc9851e 100644 (file)
@@ -75,11 +75,6 @@ static const struct ccu_desc a23_ccu_desc = {
        .num_resets = ARRAY_SIZE(a23_resets),
 };
 
-static int a23_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(a23_resets));
-}
-
 static const struct udevice_id a23_clk_ids[] = {
        { .compatible = "allwinner,sun8i-a23-ccu",
          .data = (ulong)&a23_ccu_desc },
@@ -95,5 +90,5 @@ U_BOOT_DRIVER(clk_sun8i_a23) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = a23_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index 69df4e08d0f73dccfa1d982d80c6a351e82554fa..aa113fa714c626bdff5a72461efceb44c8b46f95 100644 (file)
@@ -96,11 +96,6 @@ static const struct ccu_desc a31_ccu_desc = {
        .num_resets = ARRAY_SIZE(a31_resets),
 };
 
-static int a31_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(a31_resets));
-}
-
 static const struct udevice_id a31_clk_ids[] = {
        { .compatible = "allwinner,sun6i-a31-ccu",
          .data = (ulong)&a31_ccu_desc },
@@ -114,5 +109,5 @@ U_BOOT_DRIVER(clk_sun6i_a31) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = a31_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index 7bf1c4578c5c2efc6189215835750f99d29a949f..04c238204dcb7d51b35f22957ba6efdc55cb6064 100644 (file)
@@ -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,
 };
index e24d5c5ca321eea6862c0b20da166c0e0b0d0c55..eac1151e966f8a174e27fffbe384576a6a6a7817 100644 (file)
@@ -84,11 +84,6 @@ static const struct ccu_desc a64_ccu_desc = {
        .num_resets = ARRAY_SIZE(a64_resets),
 };
 
-static int a64_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(a64_resets));
-}
-
 static const struct udevice_id a64_ccu_ids[] = {
        { .compatible = "allwinner,sun50i-a64-ccu",
          .data = (ulong)&a64_ccu_desc },
@@ -102,5 +97,5 @@ U_BOOT_DRIVER(clk_sun50i_a64) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = a64_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index adedcba1665097e09b57b19fdbdcb1bdb3358a2d..426205d74822107cd5f8962a7d9abd842e2eeac0 100644 (file)
@@ -88,16 +88,6 @@ static const struct ccu_desc a80_mmc_clk_desc = {
        .num_resets = ARRAY_SIZE(a80_mmc_resets),
 };
 
-static int a80_clk_bind(struct udevice *dev)
-{
-       ulong count = ARRAY_SIZE(a80_resets);
-
-       if (device_is_compatible(dev, "allwinner,sun9i-a80-mmc-config-clk"))
-               count = ARRAY_SIZE(a80_mmc_resets);
-
-       return sunxi_reset_bind(dev, count);
-}
-
 static const struct udevice_id a80_ccu_ids[] = {
        { .compatible = "allwinner,sun9i-a80-ccu",
          .data = (ulong)&a80_ccu_desc },
@@ -113,5 +103,5 @@ U_BOOT_DRIVER(clk_sun9i_a80) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = a80_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index 4a0659af3e265fca650fb89828471da6a640f9b1..464e95c07da13addc605f0716bf90db7bd5affba 100644 (file)
@@ -79,11 +79,6 @@ static const struct ccu_desc a83t_ccu_desc = {
        .num_resets = ARRAY_SIZE(a83t_resets),
 };
 
-static int a83t_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(a83t_resets));
-}
-
 static const struct udevice_id a83t_clk_ids[] = {
        { .compatible = "allwinner,sun8i-a83t-ccu",
          .data = (ulong)&a83t_ccu_desc },
@@ -97,5 +92,5 @@ U_BOOT_DRIVER(clk_sun8i_a83t) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = a83t_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index cb0159ecbc7c97d89dae7d7d274b3050c6cb4f68..acba8f2ebec7bb6c9d823aed4ed86a88893b7ccb 100644 (file)
@@ -54,11 +54,6 @@ static const struct ccu_desc f1c100s_ccu_desc = {
        .num_resets = ARRAY_SIZE(f1c100s_resets),
 };
 
-static int f1c100s_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(f1c100s_resets));
-}
-
 static const struct udevice_id f1c100s_clk_ids[] = {
        { .compatible = "allwinner,suniv-f1c100s-ccu",
          .data = (ulong)&f1c100s_ccu_desc },
@@ -72,5 +67,5 @@ U_BOOT_DRIVER(clk_suniv_f1c100s) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = f1c100s_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index d69cb04b8242d85dec4d991deab7096c230cf24e..474cf98f6445a10725ee84b5fa79ba7a164c67db 100644 (file)
@@ -97,11 +97,6 @@ static const struct ccu_desc h3_ccu_desc = {
        .num_resets = ARRAY_SIZE(h3_resets),
 };
 
-static int h3_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(h3_resets));
-}
-
 static const struct udevice_id h3_ccu_ids[] = {
        { .compatible = "allwinner,sun8i-h3-ccu",
          .data = (ulong)&h3_ccu_desc },
@@ -117,5 +112,5 @@ U_BOOT_DRIVER(clk_sun8i_h3) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = h3_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index f8d2379b494a5491abb5868435537b0d2005ef47..4e717afa26e0f08d0c18cf8bfed8c19f7da269d9 100644 (file)
@@ -98,11 +98,6 @@ static const struct ccu_desc h6_ccu_desc = {
        .num_resets = ARRAY_SIZE(h6_resets),
 };
 
-static int h6_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(h6_resets));
-}
-
 static const struct udevice_id h6_ccu_ids[] = {
        { .compatible = "allwinner,sun50i-h6-ccu",
          .data = (ulong)&h6_ccu_desc },
@@ -116,5 +111,5 @@ U_BOOT_DRIVER(clk_sun50i_h6) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = h6_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index 34cfcffb49d2490676dfb1ffd0215ce8dcac1d7b..1ecccd7620c6c697dd0482243a7d69e0cfa8c30a 100644 (file)
@@ -116,11 +116,6 @@ static const struct ccu_desc h616_ccu_desc = {
        .num_resets = ARRAY_SIZE(h616_resets),
 };
 
-static int h616_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(h616_resets));
-}
-
 static const struct udevice_id h616_ccu_ids[] = {
        { .compatible = "allwinner,sun50i-h616-ccu",
          .data = (ulong)&h616_ccu_desc },
@@ -134,5 +129,5 @@ U_BOOT_DRIVER(clk_sun50i_h616) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = h616_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index 18913751fb7b1c32f8ec67adcf3e01d4cfd3040f..bb67d58fa4708e6a4ee118f8020b1b88269b263f 100644 (file)
@@ -41,11 +41,6 @@ static const struct ccu_desc h6_r_ccu_desc = {
        .num_resets = ARRAY_SIZE(h6_r_resets),
 };
 
-static int h6_r_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(h6_r_resets));
-}
-
 static const struct udevice_id h6_r_clk_ids[] = {
        { .compatible = "allwinner,sun50i-h6-r-ccu",
          .data = (ulong)&h6_r_ccu_desc },
@@ -61,5 +56,5 @@ U_BOOT_DRIVER(clk_sun50i_h6_r) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = h6_r_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index 81e4a0219a9e4405f0d10c18ee23f69bdbc9da3f..daab6ad33b45e32621361092d37e0c874e68e1f1 100644 (file)
@@ -106,11 +106,6 @@ static const struct ccu_desc r40_ccu_desc = {
        .num_resets = ARRAY_SIZE(r40_resets),
 };
 
-static int r40_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(r40_resets));
-}
-
 static const struct udevice_id r40_clk_ids[] = {
        { .compatible = "allwinner,sun8i-r40-ccu",
          .data = (ulong)&r40_ccu_desc },
@@ -124,5 +119,5 @@ U_BOOT_DRIVER(clk_sun8i_r40) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = r40_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index 62e77386be7acc828fc8485f09fec679392c79d3..23d81f68c5c0c5eaa929a2219ceac6987fb88b69 100644 (file)
@@ -67,6 +67,11 @@ struct clk_ops sunxi_clk_ops = {
        .disable = sunxi_clk_disable,
 };
 
+int sunxi_clk_bind(struct udevice *dev)
+{
+       return sunxi_reset_bind(dev);
+}
+
 int sunxi_clk_probe(struct udevice *dev)
 {
        struct ccu_priv *priv = dev_get_priv(dev);
index f45e9400419f5f4996e96414e3b4ed638d098221..5b5afa687153f1227aa28fad3ab0e0eec0b61f89 100644 (file)
@@ -56,11 +56,6 @@ static const struct ccu_desc v3s_ccu_desc = {
        .num_resets = ARRAY_SIZE(v3s_resets),
 };
 
-static int v3s_clk_bind(struct udevice *dev)
-{
-       return sunxi_reset_bind(dev, ARRAY_SIZE(v3s_resets));
-}
-
 static const struct udevice_id v3s_clk_ids[] = {
        { .compatible = "allwinner,sun8i-v3s-ccu",
          .data = (ulong)&v3s_ccu_desc },
@@ -76,5 +71,5 @@ U_BOOT_DRIVER(clk_sun8i_v3s) = {
        .priv_auto      = sizeof(struct ccu_priv),
        .ops            = &sunxi_clk_ops,
        .probe          = sunxi_clk_probe,
-       .bind           = v3s_clk_bind,
+       .bind           = sunxi_clk_bind,
 };
index e2a9c2a142b1ea7f912b8400660dd9f2bb2e6851..621912ad2375630fc15a48c7be8fa29412bf6795 100644 (file)
@@ -19,7 +19,6 @@
 
 struct sunxi_reset_priv {
        void *base;
-       ulong count;
        const struct ccu_desc *desc;
 };
 
@@ -35,7 +34,7 @@ static int sunxi_reset_request(struct reset_ctl *reset_ctl)
 
        debug("%s: (RST#%ld)\n", __func__, reset_ctl->id);
 
-       if (reset_ctl->id >= priv->count)
+       if (reset_ctl->id >= priv->desc->num_resets)
                return -EINVAL;
 
        return 0;
@@ -91,7 +90,7 @@ static int sunxi_reset_probe(struct udevice *dev)
        return 0;
 }
 
-int sunxi_reset_bind(struct udevice *dev, ulong count)
+int sunxi_reset_bind(struct udevice *dev)
 {
        struct udevice *rst_dev;
        struct sunxi_reset_priv *priv;
@@ -104,7 +103,6 @@ int sunxi_reset_bind(struct udevice *dev, ulong count)
                return ret;
        }
        priv = malloc(sizeof(struct sunxi_reset_priv));
-       priv->count = count;
        priv->desc = (const struct ccu_desc *)dev_get_driver_data(dev);
        dev_set_priv(rst_dev, priv);
 
index f1717a5e95434ed86cd9c4a482d2a2dc00e3d658..a70119304a707d1b6964d4b21516ca0f86cb4f28 100644 (file)
@@ -85,6 +85,12 @@ struct ccu_priv {
        const struct ccu_desc *desc;
 };
 
+/**
+ * sunxi_clk_bind - common sunxi clock bind
+ * @dev:       clock device
+ */
+int sunxi_clk_bind(struct udevice *dev);
+
 /**
  * sunxi_clk_probe - common sunxi clock probe
  * @dev:       clock device
@@ -97,9 +103,8 @@ extern struct clk_ops sunxi_clk_ops;
  * sunxi_reset_bind() - reset binding
  *
  * @dev:       reset device
- * @count:     reset count
  * Return: 0 success, or error value
  */
-int sunxi_reset_bind(struct udevice *dev, ulong count);
+int sunxi_reset_bind(struct udevice *dev);
 
 #endif /* _CLK_SUNXI_H */