]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
clk: renesas: Add and enable CPG reset driver
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Thu, 26 Jan 2023 20:02:03 +0000 (21:02 +0100)
committerMarek Vasut <marek.vasut+renesas@gmail.com>
Thu, 2 Feb 2023 00:49:20 +0000 (01:49 +0100)
Add trivial reset driver extension to the CPG clock driver. The change
turns current CPG UCLASS_CLK driver instance into an UCLASS_NOP proxy
driver, which in turn binds both generic rcar3_clk UCLASS_CLK clock
driver as well as generic rcar_rst UCLASS_RESET reset driver to the
CPG DT node. This way, any other drivers which use the 'reset' DT
property can now obtain valid reset handle backed by a reset driver.

The clock tables have been updated to represent the CPG driver and only
implement the generic CPG proxy driver bind call, which binds the clock
and reset drivers.

The DM_RESET is now enabled for all R-Car Gen3 platforms.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
15 files changed:
arch/arm/mach-rmobile/Kconfig.64
drivers/clk/renesas/clk-rcar-gen3.c
drivers/clk/renesas/r8a774a1-cpg-mssr.c
drivers/clk/renesas/r8a774b1-cpg-mssr.c
drivers/clk/renesas/r8a774c0-cpg-mssr.c
drivers/clk/renesas/r8a774e1-cpg-mssr.c
drivers/clk/renesas/r8a7795-cpg-mssr.c
drivers/clk/renesas/r8a7796-cpg-mssr.c
drivers/clk/renesas/r8a77965-cpg-mssr.c
drivers/clk/renesas/r8a77970-cpg-mssr.c
drivers/clk/renesas/r8a77980-cpg-mssr.c
drivers/clk/renesas/r8a77990-cpg-mssr.c
drivers/clk/renesas/r8a77995-cpg-mssr.c
drivers/clk/renesas/r8a779a0-cpg-mssr.c
drivers/clk/renesas/rcar-gen3-cpg.h

index bf12b21ecf45300f62c45be3df4dcda583685c40..8e617e582442c26ec646acf01bf2e2dc7c056552 100644 (file)
@@ -201,4 +201,7 @@ config MULTI_DTB_FIT_USER_DEF_ADDR
 config SYS_MALLOC_F_LEN
        default 0x8000 if RCAR_GEN3
 
+config DM_RESET
+       default y if RCAR_GEN3
+
 endif
index 94715bb00ce4f9f216f917a2c1af18923248d257..3611bdb06fc581ef4aa39e5300c29604a1de392d 100644 (file)
 #include <common.h>
 #include <clk-uclass.h>
 #include <dm.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
 #include <errno.h>
 #include <log.h>
 #include <wait_bit.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
 #include <linux/bitops.h>
+#include <reset-uclass.h>
 
 #include <dt-bindings/clock/renesas-cpg-mssr.h>
 
@@ -389,7 +392,7 @@ const struct clk_ops gen3_clk_ops = {
        .of_xlate       = gen3_clk_of_xlate,
 };
 
-int gen3_clk_probe(struct udevice *dev)
+static int gen3_clk_probe(struct udevice *dev)
 {
        struct gen3_clk_priv *priv = dev_get_priv(dev);
        struct cpg_mssr_info *info =
@@ -447,9 +450,84 @@ int gen3_clk_probe(struct udevice *dev)
        return 0;
 }
 
-int gen3_clk_remove(struct udevice *dev)
+static int gen3_clk_remove(struct udevice *dev)
 {
        struct gen3_clk_priv *priv = dev_get_priv(dev);
 
        return renesas_clk_remove(priv->base, priv->info);
 }
+
+U_BOOT_DRIVER(clk_gen3) = {
+       .name           = "clk_gen3",
+       .id             = UCLASS_CLK,
+       .priv_auto      = sizeof(struct gen3_clk_priv),
+       .ops            = &gen3_clk_ops,
+       .probe          = gen3_clk_probe,
+       .remove         = gen3_clk_remove,
+};
+
+static int gen3_reset_assert(struct reset_ctl *reset_ctl)
+{
+       struct udevice *cdev = (struct udevice *)dev_get_driver_data(reset_ctl->dev);
+       struct gen3_clk_priv *priv = dev_get_priv(cdev);
+       unsigned int reg = reset_ctl->id / 32;
+       unsigned int bit = reset_ctl->id % 32;
+       u32 bitmask = BIT(bit);
+
+       writel(bitmask, priv->base + priv->info->reset_regs[reg]);
+
+       return 0;
+}
+
+static int gen3_reset_deassert(struct reset_ctl *reset_ctl)
+{
+       struct udevice *cdev = (struct udevice *)dev_get_driver_data(reset_ctl->dev);
+       struct gen3_clk_priv *priv = dev_get_priv(cdev);
+       unsigned int reg = reset_ctl->id / 32;
+       unsigned int bit = reset_ctl->id % 32;
+       u32 bitmask = BIT(bit);
+
+       writel(bitmask, priv->base + priv->info->reset_clear_regs[reg]);
+
+       return 0;
+}
+
+static const struct reset_ops rst_gen3_ops = {
+       .rst_assert = gen3_reset_assert,
+       .rst_deassert = gen3_reset_deassert,
+};
+
+U_BOOT_DRIVER(rst_gen3) = {
+       .name = "rst_gen3",
+       .id = UCLASS_RESET,
+       .ops = &rst_gen3_ops,
+};
+
+int gen3_cpg_bind(struct udevice *parent)
+{
+       struct cpg_mssr_info *info =
+               (struct cpg_mssr_info *)dev_get_driver_data(parent);
+       struct udevice *cdev, *rdev;
+       struct driver *drv;
+       int ret;
+
+       drv = lists_driver_lookup_name("clk_gen3");
+       if (!drv)
+               return -ENOENT;
+
+       ret = device_bind_with_driver_data(parent, drv, "clk_gen3", (ulong)info,
+                                          dev_ofnode(parent), &cdev);
+       if (ret)
+               return ret;
+
+       drv = lists_driver_lookup_name("rst_gen3");
+       if (!drv)
+               return -ENOENT;
+
+       ret = device_bind_with_driver_data(parent, drv, "rst_gen3", (ulong)cdev,
+                                          dev_ofnode(parent), &rdev);
+       if (ret)
+               device_unbind(cdev);
+
+       return ret;
+}
index 445c58b88a0c831d273e2a242d145103dd73dc2f..1f76d6b2c2e61fa993fe19452d0dd60b72f3550f 100644 (file)
@@ -331,7 +331,7 @@ static const struct cpg_mssr_info r8a774a1_cpg_mssr_info = {
        .get_pll_config         = r8a774a1_get_pll_config,
 };
 
-static const struct udevice_id r8a774a1_clk_ids[] = {
+static const struct udevice_id r8a774a1_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a774a1-cpg-mssr",
                .data           = (ulong)&r8a774a1_cpg_mssr_info,
@@ -339,12 +339,9 @@ static const struct udevice_id r8a774a1_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a774a1) = {
-       .name           = "clk_r8a774a1",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a774a1_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a774a1) = {
+       .name           = "cpg_r8a774a1",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a774a1_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index a09f11d433463238a8b5fdde857b8a8d52489b15..b5927c7892c491043d1a504a62d155202c74b848 100644 (file)
@@ -329,7 +329,7 @@ static const struct cpg_mssr_info r8a774b1_cpg_mssr_info = {
        .get_pll_config         = r8a774b1_get_pll_config,
 };
 
-static const struct udevice_id r8a774b1_clk_ids[] = {
+static const struct udevice_id r8a774b1_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a774b1-cpg-mssr",
                .data           = (ulong)&r8a774b1_cpg_mssr_info,
@@ -337,12 +337,9 @@ static const struct udevice_id r8a774b1_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a774b1) = {
-       .name           = "clk_r8a774b1",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a774b1_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a774b1) = {
+       .name           = "cpg_r8a774b1",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a774b1_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index f2dce5d8853f89651a553cdf5906230b389c9870..802a9c0b1191d7bece5dad6769b2f9e2dae2bc9c 100644 (file)
@@ -300,7 +300,7 @@ const struct cpg_mssr_info r8a774c0_cpg_mssr_info = {
        .get_pll_config         = r8a774c0_get_pll_config,
 };
 
-static const struct udevice_id r8a774c0_clk_ids[] = {
+static const struct udevice_id r8a774c0_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a774c0-cpg-mssr",
                .data           = (ulong)&r8a774c0_cpg_mssr_info
@@ -308,12 +308,9 @@ static const struct udevice_id r8a774c0_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a774c0) = {
-       .name           = "clk_r8a774c0",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a774c0_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a774c0) = {
+       .name           = "cpg_r8a774c0",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a774c0_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index ab44dbdeeb58c98ad5aeddc657f8fbdbcec76a70..617fa769dcfa38487fd60bf5f7d9c97782913bdb 100644 (file)
@@ -343,7 +343,7 @@ static const struct cpg_mssr_info r8a774e1_cpg_mssr_info = {
        .get_pll_config         = r8a774e1_get_pll_config,
 };
 
-static const struct udevice_id r8a774e1_clk_ids[] = {
+static const struct udevice_id r8a774e1_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a774e1-cpg-mssr",
                .data           = (ulong)&r8a774e1_cpg_mssr_info
@@ -351,12 +351,9 @@ static const struct udevice_id r8a774e1_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a774e1) = {
-       .name           = "clk_r8a774e1",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a774e1_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a774e1) = {
+       .name           = "cpg_r8a774e1",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a774e1_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index 31cd24ec127a3494bb2f1b843c28918055b4668f..005f6a9ecd7e72f715e2d4fa01068fec92e33991 100644 (file)
@@ -380,7 +380,7 @@ static const struct cpg_mssr_info r8a7795_cpg_mssr_info = {
        .get_pll_config         = r8a7795_get_pll_config,
 };
 
-static const struct udevice_id r8a7795_clk_ids[] = {
+static const struct udevice_id r8a7795_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a7795-cpg-mssr",
                .data           = (ulong)&r8a7795_cpg_mssr_info
@@ -388,12 +388,9 @@ static const struct udevice_id r8a7795_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a7795) = {
-       .name           = "clk_r8a7795",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a7795_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a7795) = {
+       .name           = "cpg_r8a7795",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a7795_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index a3fee15851065af31d3e886c4b84ee425f9efc93..27cf62e02133732b5055324fd972a8dfe26c5822 100644 (file)
@@ -370,7 +370,7 @@ static const struct cpg_mssr_info r8a77961_cpg_mssr_info = {
        .get_pll_config         = r8a7796_get_pll_config,
 };
 
-static const struct udevice_id r8a7796_clk_ids[] = {
+static const struct udevice_id r8a7796_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a7796-cpg-mssr",
                .data           = (ulong)&r8a7796_cpg_mssr_info,
@@ -382,12 +382,9 @@ static const struct udevice_id r8a7796_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a7796) = {
-       .name           = "clk_r8a7796",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a7796_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a7796) = {
+       .name           = "cpg_r8a7796",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a7796_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index cd3bda9a39eb94903bd2a49ba03849c600d7a123..58e557a95f5a02aca3e7329dbf9402aec08e276e 100644 (file)
@@ -358,7 +358,7 @@ static const struct cpg_mssr_info r8a77965_cpg_mssr_info = {
        .get_pll_config         = r8a77965_get_pll_config,
 };
 
-static const struct udevice_id r8a77965_clk_ids[] = {
+static const struct udevice_id r8a77965_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a77965-cpg-mssr",
                .data           = (ulong)&r8a77965_cpg_mssr_info,
@@ -366,12 +366,9 @@ static const struct udevice_id r8a77965_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a77965) = {
-       .name           = "clk_r8a77965",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a77965_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a77965) = {
+       .name           = "cpg_r8a77965",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a77965_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index a85bed61929577c7d96b3c150b6514c2a5c92302..4d72ec1fae8554f8d06bd873eef32bb7b8103405 100644 (file)
@@ -219,7 +219,7 @@ static const struct cpg_mssr_info r8a77970_cpg_mssr_info = {
        .get_pll_config         = r8a77970_get_pll_config,
 };
 
-static const struct udevice_id r8a77970_clk_ids[] = {
+static const struct udevice_id r8a77970_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a77970-cpg-mssr",
                .data           = (ulong)&r8a77970_cpg_mssr_info
@@ -227,12 +227,9 @@ static const struct udevice_id r8a77970_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a77970) = {
-       .name           = "clk_r8a77970",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a77970_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a77970) = {
+       .name           = "cpg_r8a77970",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a77970_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index 1f29e77da9da339ed8cae47c1ef7c4219ac1ffdf..f29727ddb90ba1cc7dd14c796bd37bafcec942f9 100644 (file)
@@ -239,7 +239,7 @@ static const struct cpg_mssr_info r8a77980_cpg_mssr_info = {
        .get_pll_config         = r8a77980_get_pll_config,
 };
 
-static const struct udevice_id r8a77980_clk_ids[] = {
+static const struct udevice_id r8a77980_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a77980-cpg-mssr",
                .data           = (ulong)&r8a77980_cpg_mssr_info
@@ -247,12 +247,9 @@ static const struct udevice_id r8a77980_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a77980) = {
-       .name           = "clk_r8a77980",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a77980_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a77980) = {
+       .name           = "cpg_r8a77980",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a77980_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index 4d9b78ebab8d780953a28e43404195b658f75130..1864af30c8c2ae08a2b57d339ed7e0717b363a9e 100644 (file)
@@ -314,7 +314,7 @@ static const struct cpg_mssr_info r8a77990_cpg_mssr_info = {
        .get_pll_config         = r8a77990_get_pll_config,
 };
 
-static const struct udevice_id r8a77990_clk_ids[] = {
+static const struct udevice_id r8a77990_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a77990-cpg-mssr",
                .data           = (ulong)&r8a77990_cpg_mssr_info
@@ -322,12 +322,9 @@ static const struct udevice_id r8a77990_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a77990) = {
-       .name           = "clk_r8a77990",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a77990_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a77990) = {
+       .name           = "cpg_r8a77990",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a77990_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index ee4061f9d82df23fd9211bf142f098f37711b40e..03ae863c8bc6ca2434e315abbc83d4ce40c20aee 100644 (file)
@@ -250,7 +250,7 @@ static const struct cpg_mssr_info r8a77995_cpg_mssr_info = {
        .get_pll_config         = r8a77995_get_pll_config,
 };
 
-static const struct udevice_id r8a77995_clk_ids[] = {
+static const struct udevice_id r8a77995_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a77995-cpg-mssr",
                .data           = (ulong)&r8a77995_cpg_mssr_info
@@ -258,12 +258,9 @@ static const struct udevice_id r8a77995_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a77995) = {
-       .name           = "clk_r8a77995",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a77995_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a77995) = {
+       .name           = "cpg_r8a77995",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a77995_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index 0c28477377e67350be6da5cc81499d5c07ae46d6..a9c941b6dbfc0fd1c9a3f0095d768abfb2cc2f51 100644 (file)
@@ -301,7 +301,7 @@ static const struct cpg_mssr_info r8a779a0_cpg_mssr_info = {
        .reg_layout             = CLK_REG_LAYOUT_RCAR_V3U,
 };
 
-static const struct udevice_id r8a779a0_clk_ids[] = {
+static const struct udevice_id r8a779a0_cpg_ids[] = {
        {
                .compatible     = "renesas,r8a779a0-cpg-mssr",
                .data           = (ulong)&r8a779a0_cpg_mssr_info
@@ -309,12 +309,9 @@ static const struct udevice_id r8a779a0_clk_ids[] = {
        { }
 };
 
-U_BOOT_DRIVER(clk_r8a779a0) = {
-       .name           = "clk_r8a779a0",
-       .id             = UCLASS_CLK,
-       .of_match       = r8a779a0_clk_ids,
-       .priv_auto      = sizeof(struct gen3_clk_priv),
-       .ops            = &gen3_clk_ops,
-       .probe          = gen3_clk_probe,
-       .remove         = gen3_clk_remove,
+U_BOOT_DRIVER(cpg_r8a779a0) = {
+       .name           = "cpg_r8a779a0",
+       .id             = UCLASS_NOP,
+       .of_match       = r8a779a0_cpg_ids,
+       .bind           = gen3_cpg_bind,
 };
index 85bfc7233b77a87a3122a86e96e33c04054fa1af..a7074e2bcde74a91e9130eeb92f45bc4430bb62e 100644 (file)
@@ -126,8 +126,7 @@ struct gen3_clk_priv {
        const struct rcar_gen3_cpg_pll_config *cpg_pll_config;
 };
 
-int gen3_clk_probe(struct udevice *dev);
-int gen3_clk_remove(struct udevice *dev);
+int gen3_cpg_bind(struct udevice *parent);
 
 extern const struct clk_ops gen3_clk_ops;