reset: starfive: Add StarFive JH7110 reset driver
authorHal Feng <hal.feng@starfivetech.com>
Sat, 12 Nov 2022 15:39:59 +0000 (23:39 +0800)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 24 Jul 2023 23:24:32 +0000 (08:24 +0900)
Add auxiliary driver to support StarFive JH7110 system
and always-on resets.

Tested-by: Tommaso Merciai <tomm.merciai@gmail.com>
Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
drivers/reset/starfive/Kconfig
drivers/reset/starfive/Makefile
drivers/reset/starfive/reset-starfive-jh7110.c [new file with mode: 0644]

index 1927a5a..1fa706a 100644 (file)
@@ -10,3 +10,11 @@ config RESET_STARFIVE_JH7100
        default ARCH_STARFIVE
        help
          This enables the reset controller driver for the StarFive JH7100 SoC.
+
+config RESET_STARFIVE_JH7110
+       bool "StarFive JH7110 Reset Driver"
+       depends on AUXILIARY_BUS && CLK_STARFIVE_JH7110_SYS
+       select RESET_STARFIVE_JH71X0
+       default ARCH_STARFIVE
+       help
+         This enables the reset controller driver for the StarFive JH7110 SoC.
index f6aa124..7a44b66 100644 (file)
@@ -2,3 +2,4 @@
 obj-$(CONFIG_RESET_STARFIVE_JH71X0)            += reset-starfive-jh71x0.o
 
 obj-$(CONFIG_RESET_STARFIVE_JH7100)            += reset-starfive-jh7100.o
+obj-$(CONFIG_RESET_STARFIVE_JH7110)            += reset-starfive-jh7110.o
diff --git a/drivers/reset/starfive/reset-starfive-jh7110.c b/drivers/reset/starfive/reset-starfive-jh7110.c
new file mode 100644 (file)
index 0000000..4ccb3f7
--- /dev/null
@@ -0,0 +1,70 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Reset driver for the StarFive JH7110 SoC
+ *
+ * Copyright (C) 2022 StarFive Technology Co., Ltd.
+ */
+
+#include <linux/auxiliary_bus.h>
+
+#include "reset-starfive-jh71x0.h"
+
+#include <dt-bindings/reset/starfive,jh7110-crg.h>
+
+struct jh7110_reset_info {
+       unsigned int nr_resets;
+       unsigned int assert_offset;
+       unsigned int status_offset;
+};
+
+static const struct jh7110_reset_info jh7110_sys_info = {
+       .nr_resets = JH7110_SYSRST_END,
+       .assert_offset = 0x2F8,
+       .status_offset = 0x308,
+};
+
+static const struct jh7110_reset_info jh7110_aon_info = {
+       .nr_resets = JH7110_AONRST_END,
+       .assert_offset = 0x38,
+       .status_offset = 0x3C,
+};
+
+static int jh7110_reset_probe(struct auxiliary_device *adev,
+                             const struct auxiliary_device_id *id)
+{
+       struct jh7110_reset_info *info = (struct jh7110_reset_info *)(id->driver_data);
+       void __iomem **base = (void __iomem **)dev_get_drvdata(adev->dev.parent);
+
+       if (!info || !base)
+               return -ENODEV;
+
+       return reset_starfive_jh71x0_register(&adev->dev, adev->dev.parent->of_node,
+                                             *base + info->assert_offset,
+                                             *base + info->status_offset,
+                                             NULL,
+                                             info->nr_resets,
+                                             NULL);
+}
+
+static const struct auxiliary_device_id jh7110_reset_ids[] = {
+       {
+               .name = "clk_starfive_jh71x0.reset-sys",
+               .driver_data = (kernel_ulong_t)&jh7110_sys_info,
+       },
+       {
+               .name = "clk_starfive_jh71x0.reset-aon",
+               .driver_data = (kernel_ulong_t)&jh7110_aon_info,
+       },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(auxiliary, jh7110_reset_ids);
+
+static struct auxiliary_driver jh7110_reset_driver = {
+       .probe          = jh7110_reset_probe,
+       .id_table       = jh7110_reset_ids,
+};
+module_auxiliary_driver(jh7110_reset_driver);
+
+MODULE_AUTHOR("Hal Feng <hal.feng@starfivetech.com>");
+MODULE_DESCRIPTION("StarFive JH7110 reset driver");
+MODULE_LICENSE("GPL");