config SYS_MALLOC_F_LEN
default 0x8000 if RCAR_GEN3
+config DM_RESET
+ default y if RCAR_GEN3
+
endif
#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>
.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 =
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;
+}
.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,
{ }
};
-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,
};
.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,
{ }
};
-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,
};
.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
{ }
};
-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,
};
.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
{ }
};
-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,
};
.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
{ }
};
-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,
};
.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,
{ }
};
-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,
};
.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,
{ }
};
-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,
};
.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
{ }
};
-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,
};
.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
{ }
};
-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,
};
.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
{ }
};
-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,
};
.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
{ }
};
-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,
};
.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
{ }
};
-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,
};
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;