clk: renesas: Add and enable CPG reset driver

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>
This commit is contained in:
Marek Vasut 2023-01-26 21:02:03 +01:00 committed by Marek Vasut
parent d1c886f563
commit 326e05c5e2
15 changed files with 156 additions and 112 deletions

View 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

View file

@ -13,12 +13,15 @@
#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;
}

View 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,
};

View 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,
};

View 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,
};

View 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,
};

View 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,
};

View 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,
};

View 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,
};

View 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,
};

View 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,
};

View 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,
};

View 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,
};

View 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,
};

View 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;