Add driver for Sophgo CV1800 series SoC RTC MFD. The RTC module comprises
a 32kHz oscillator, Power-on-Reset (PoR) sub-module, HW state machine to
control chip power-on, power-off and reset. Furthermore, the 8051 subsystem
is located within RTCSYS including associated SRAM block.
This patch only populates RTC sub-device.
Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
---
Changelog:
v12:
- new patch
MAINTAINERS | 1 +
drivers/mfd/Kconfig | 14 ++++++++
drivers/mfd/Makefile | 1 +
drivers/mfd/cv1800-rtcsys.c | 66 +++++++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+)
create mode 100644 drivers/mfd/cv1800-rtcsys.c
diff --git a/MAINTAINERS b/MAINTAINERS
index 92fc0eca7061..446156998380 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -22185,6 +22185,7 @@ M: Chen Wang <unicorn_wang@outlook.com>
M: Inochi Amaoto <inochiama@outlook.com>
T: git https://github.com/sophgo/linux.git
S: Maintained
+F: drivers/mfd/cv1800-rtcsys.c
N: sophgo
K: sophgo
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 6b0682af6e32..842cc4d95c4b 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -285,6 +285,20 @@ config MFD_CS42L43_SDW
Select this to support the Cirrus Logic CS42L43 PC CODEC with
headphone and class D speaker drivers over SoundWire.
+config MFD_CV1800_RTCSYS
+ tristate "Sophgo CV1800 RTC MFD"
+ depends on ARCH_SOPHGO || COMPILE_TEST
+ select MFD_CORE
+ help
+ If you say yes here you get support the RTC MFD driver for Sophgo
+ CV1800 series SoC. The RTC module comprises a 32kHz oscillator,
+ Power-on-Reset (PoR) sub-module, HW state machine to control chip
+ power-on, power-off and reset. Furthermore, the 8051 subsystem is
+ located within RTCSYS including associated SRAM block.
+
+ This driver can also be built as a module. If so, the module will be
+ called cv1800-rtcsys.
+
config MFD_MADERA
tristate "Cirrus Logic Madera codecs"
select MFD_CORE
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 9220eaf7cf12..3cf03ffeedbb 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_MFD_CROS_EC_DEV) += cros_ec_dev.o
obj-$(CONFIG_MFD_CS42L43) += cs42l43.o
obj-$(CONFIG_MFD_CS42L43_I2C) += cs42l43-i2c.o
obj-$(CONFIG_MFD_CS42L43_SDW) += cs42l43-sdw.o
+obj-$(CONFIG_MFD_CV1800_RTCSYS) += cv1800-rtcsys.o
obj-$(CONFIG_MFD_ENE_KB3930) += ene-kb3930.o
obj-$(CONFIG_MFD_EXYNOS_LPASS) += exynos-lpass.o
obj-$(CONFIG_MFD_GATEWORKS_GSC) += gateworks-gsc.o
diff --git a/drivers/mfd/cv1800-rtcsys.c b/drivers/mfd/cv1800-rtcsys.c
new file mode 100644
index 000000000000..72d11284f1de
--- /dev/null
+++ b/drivers/mfd/cv1800-rtcsys.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Driver for Sophgo CV1800 series SoC RTC MFD
+ *
+ * The RTC module comprises a 32kHz oscillator, Power-on-Reset (PoR) sub-module,
+ * HW state machine to control chip power-on, power-off and reset. Furthermore,
+ * the 8051 subsystem is located within RTCSYS including associated SRAM block.
+ *
+ * Copyright (C) 2025 Alexander Sverdlin <alexander.sverdlin@gmail.com>
+ *
+ */
+
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/property.h>
+
+static struct resource cv1800_rtcsys_irq_resources[] = {
+ DEFINE_RES_IRQ_NAMED(0, "alarm"),
+};
+
+static const struct mfd_cell cv1800_rtcsys_subdev[] = {
+ {
+ .name = "cv1800-rtc",
+ .num_resources = 1,
+ .resources = &cv1800_rtcsys_irq_resources[0],
+ },
+};
+
+static const struct mfd_cell cv1800_rtcsys_rtc_subdev =
+ MFD_CELL_NAME("cv1800-rtc");
+
+static int cv1800_rtcsys_probe(struct platform_device *pdev)
+{
+ int irq;
+
+ irq = platform_get_irq_byname(pdev, "alarm");
+ if (irq < 0)
+ return irq;
+ cv1800_rtcsys_irq_resources[0].start = irq;
+ cv1800_rtcsys_irq_resources[0].end = irq;
+
+ return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
+ cv1800_rtcsys_subdev,
+ ARRAY_SIZE(cv1800_rtcsys_subdev),
+ NULL, 0, NULL);
+}
+
+static const struct of_device_id cv1800_rtcsys_of_match[] = {
+ { .compatible = "sophgo,cv1800b-rtc" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, cv1800_rtcsys_of_match);
+
+static struct platform_driver cv1800_rtcsys_mfd = {
+ .probe = cv1800_rtcsys_probe,
+ .driver = {
+ .name = "cv1800_rtcsys",
+ .of_match_table = cv1800_rtcsys_of_match,
+ },
+};
+module_platform_driver(cv1800_rtcsys_mfd);
+
+MODULE_AUTHOR("Alexander Sverdlin <alexander.sverdlin@gmail.com>");
+MODULE_DESCRIPTION("Sophgo CV1800 series SoC RTC MFD driver");
+MODULE_LICENSE("GPL");
--
2.48.1
Hi Alexander,
kernel test robot noticed the following build warnings:
[auto build test WARNING on lee-mfd/for-mfd-next]
[also build test WARNING on abelloni/rtc-next linus/master lee-mfd/for-mfd-fixes v6.14-rc5 next-20250305]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Alexander-Sverdlin/dt-bindings-mfd-sophgo-add-RTC-support-for-Sophgo-CV1800-series-SoC/20250303-035433
base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
patch link: https://lore.kernel.org/r/20250302195205.3183174-3-alexander.sverdlin%40gmail.com
patch subject: [PATCH v12 2/3] mfd: sophgo: cv1800: rtcsys: New driver (handling RTC only)
config: sh-allyesconfig (https://download.01.org/0day-ci/archive/20250306/202503061309.yjpOnrMo-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250306/202503061309.yjpOnrMo-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503061309.yjpOnrMo-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/mfd/cv1800-rtcsys.c:30:30: warning: 'cv1800_rtcsys_rtc_subdev' defined but not used [-Wunused-const-variable=]
30 | static const struct mfd_cell cv1800_rtcsys_rtc_subdev =
| ^~~~~~~~~~~~~~~~~~~~~~~~
vim +/cv1800_rtcsys_rtc_subdev +30 drivers/mfd/cv1800-rtcsys.c
29
> 30 static const struct mfd_cell cv1800_rtcsys_rtc_subdev =
31 MFD_CELL_NAME("cv1800-rtc");
32
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
On Sun, 02 Mar 2025, Alexander Sverdlin wrote:
> Add driver for Sophgo CV1800 series SoC RTC MFD. The RTC module comprises
> a 32kHz oscillator, Power-on-Reset (PoR) sub-module, HW state machine to
> control chip power-on, power-off and reset. Furthermore, the 8051 subsystem
> is located within RTCSYS including associated SRAM block.
>
> This patch only populates RTC sub-device.
>
> Signed-off-by: Alexander Sverdlin <alexander.sverdlin@gmail.com>
> ---
> Changelog:
> v12:
> - new patch
>
> MAINTAINERS | 1 +
> drivers/mfd/Kconfig | 14 ++++++++
> drivers/mfd/Makefile | 1 +
> drivers/mfd/cv1800-rtcsys.c | 66 +++++++++++++++++++++++++++++++++++++
> 4 files changed, 82 insertions(+)
> create mode 100644 drivers/mfd/cv1800-rtcsys.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 92fc0eca7061..446156998380 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -22185,6 +22185,7 @@ M: Chen Wang <unicorn_wang@outlook.com>
> M: Inochi Amaoto <inochiama@outlook.com>
> T: git https://github.com/sophgo/linux.git
> S: Maintained
> +F: drivers/mfd/cv1800-rtcsys.c
> N: sophgo
> K: sophgo
>
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 6b0682af6e32..842cc4d95c4b 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -285,6 +285,20 @@ config MFD_CS42L43_SDW
> Select this to support the Cirrus Logic CS42L43 PC CODEC with
> headphone and class D speaker drivers over SoundWire.
>
> +config MFD_CV1800_RTCSYS
> + tristate "Sophgo CV1800 RTC MFD"
> + depends on ARCH_SOPHGO || COMPILE_TEST
> + select MFD_CORE
> + help
> + If you say yes here you get support the RTC MFD driver for Sophgo
> + CV1800 series SoC. The RTC module comprises a 32kHz oscillator,
> + Power-on-Reset (PoR) sub-module, HW state machine to control chip
> + power-on, power-off and reset. Furthermore, the 8051 subsystem is
> + located within RTCSYS including associated SRAM block.
> +
> + This driver can also be built as a module. If so, the module will be
> + called cv1800-rtcsys.
> +
> config MFD_MADERA
> tristate "Cirrus Logic Madera codecs"
> select MFD_CORE
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 9220eaf7cf12..3cf03ffeedbb 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -18,6 +18,7 @@ obj-$(CONFIG_MFD_CROS_EC_DEV) += cros_ec_dev.o
> obj-$(CONFIG_MFD_CS42L43) += cs42l43.o
> obj-$(CONFIG_MFD_CS42L43_I2C) += cs42l43-i2c.o
> obj-$(CONFIG_MFD_CS42L43_SDW) += cs42l43-sdw.o
> +obj-$(CONFIG_MFD_CV1800_RTCSYS) += cv1800-rtcsys.o
> obj-$(CONFIG_MFD_ENE_KB3930) += ene-kb3930.o
> obj-$(CONFIG_MFD_EXYNOS_LPASS) += exynos-lpass.o
> obj-$(CONFIG_MFD_GATEWORKS_GSC) += gateworks-gsc.o
> diff --git a/drivers/mfd/cv1800-rtcsys.c b/drivers/mfd/cv1800-rtcsys.c
> new file mode 100644
> index 000000000000..72d11284f1de
> --- /dev/null
> +++ b/drivers/mfd/cv1800-rtcsys.c
> @@ -0,0 +1,66 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Driver for Sophgo CV1800 series SoC RTC MFD
> + *
> + * The RTC module comprises a 32kHz oscillator, Power-on-Reset (PoR) sub-module,
> + * HW state machine to control chip power-on, power-off and reset. Furthermore,
> + * the 8051 subsystem is located within RTCSYS including associated SRAM block.
> + *
> + * Copyright (C) 2025 Alexander Sverdlin <alexander.sverdlin@gmail.com>
> + *
> + */
> +
> +#include <linux/mfd/core.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/property.h>
> +
> +static struct resource cv1800_rtcsys_irq_resources[] = {
> + DEFINE_RES_IRQ_NAMED(0, "alarm"),
> +};
> +
> +static const struct mfd_cell cv1800_rtcsys_subdev[] = {
> + {
> + .name = "cv1800-rtc",
> + .num_resources = 1,
> + .resources = &cv1800_rtcsys_irq_resources[0],
> + },
> +};
> +
> +static const struct mfd_cell cv1800_rtcsys_rtc_subdev =
> + MFD_CELL_NAME("cv1800-rtc");
How is this different from the one above?
Adding a single device does not constitute an MFD.
> +static int cv1800_rtcsys_probe(struct platform_device *pdev)
> +{
> + int irq;
> +
> + irq = platform_get_irq_byname(pdev, "alarm");
> + if (irq < 0)
> + return irq;
> + cv1800_rtcsys_irq_resources[0].start = irq;
> + cv1800_rtcsys_irq_resources[0].end = irq;
> +
> + return devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_AUTO,
> + cv1800_rtcsys_subdev,
> + ARRAY_SIZE(cv1800_rtcsys_subdev),
> + NULL, 0, NULL);
> +}
> +
> +static const struct of_device_id cv1800_rtcsys_of_match[] = {
> + { .compatible = "sophgo,cv1800b-rtc" },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, cv1800_rtcsys_of_match);
> +
> +static struct platform_driver cv1800_rtcsys_mfd = {
> + .probe = cv1800_rtcsys_probe,
> + .driver = {
> + .name = "cv1800_rtcsys",
> + .of_match_table = cv1800_rtcsys_of_match,
> + },
> +};
> +module_platform_driver(cv1800_rtcsys_mfd);
> +
> +MODULE_AUTHOR("Alexander Sverdlin <alexander.sverdlin@gmail.com>");
> +MODULE_DESCRIPTION("Sophgo CV1800 series SoC RTC MFD driver");
> +MODULE_LICENSE("GPL");
> --
> 2.48.1
>
--
Lee Jones [李琼斯]
Hi Alexander,
kernel test robot noticed the following build warnings:
[auto build test WARNING on lee-mfd/for-mfd-next]
[also build test WARNING on abelloni/rtc-next linus/master lee-mfd/for-mfd-fixes v6.14-rc5 next-20250305]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Alexander-Sverdlin/dt-bindings-mfd-sophgo-add-RTC-support-for-Sophgo-CV1800-series-SoC/20250303-035433
base: https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git for-mfd-next
patch link: https://lore.kernel.org/r/20250302195205.3183174-3-alexander.sverdlin%40gmail.com
patch subject: [PATCH v12 2/3] mfd: sophgo: cv1800: rtcsys: New driver (handling RTC only)
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20250306/202503060435.1c1akI1Q-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250306/202503060435.1c1akI1Q-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503060435.1c1akI1Q-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> drivers/mfd/cv1800-rtcsys.c:30:30: warning: unused variable 'cv1800_rtcsys_rtc_subdev' [-Wunused-const-variable]
30 | static const struct mfd_cell cv1800_rtcsys_rtc_subdev =
| ^~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
vim +/cv1800_rtcsys_rtc_subdev +30 drivers/mfd/cv1800-rtcsys.c
29
> 30 static const struct mfd_cell cv1800_rtcsys_rtc_subdev =
31 MFD_CELL_NAME("cv1800-rtc");
32
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
© 2016 - 2025 Red Hat, Inc.