Enable support for the RTC and regulators found in the SpacemiT P1
PMIC. Support is implemented by the simple I2C MFD driver.
The P1 PMIC is normally implemented with the SpacemiT K1 SoC. This
PMIC provides 6 buck converters and 12 LDO regulators. It also
implements a switch, watchdog timer, real-time clock, and more.
Initially its RTC and regulators are supported.
Signed-off-by: Alex Elder <elder@riscstar.com>
---
drivers/mfd/Kconfig | 11 +++++++++++
drivers/mfd/simple-mfd-i2c.c | 18 ++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 425c5fba6cb1e..4d6a5a3a27220 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1238,6 +1238,17 @@ config MFD_QCOM_RPM
Say M here if you want to include support for the Qualcomm RPM as a
module. This will build a module called "qcom_rpm".
+config MFD_SPACEMIT_P1
+ tristate "SpacemiT P1 PMIC"
+ depends on I2C
+ select MFD_SIMPLE_MFD_I2C
+ help
+ This option supports the I2C-based SpacemiT P1 PMIC, which
+ contains regulators, a power switch, GPIOs, an RTC, and more.
+ This option is selected when any of the supported sub-devices
+ is configured. The basic functionality is implemented by the
+ simple MFD I2C driver.
+
config MFD_SPMI_PMIC
tristate "Qualcomm SPMI PMICs"
depends on ARCH_QCOM || COMPILE_TEST
diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c
index 22159913bea03..47ffaac035cae 100644
--- a/drivers/mfd/simple-mfd-i2c.c
+++ b/drivers/mfd/simple-mfd-i2c.c
@@ -93,12 +93,30 @@ static const struct simple_mfd_data maxim_mon_max77705 = {
.mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells),
};
+
+static const struct regmap_config spacemit_p1_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+};
+
+static const struct mfd_cell spacemit_p1_cells[] = {
+ { .name = "spacemit-p1-regulator", },
+ { .name = "spacemit-p1-rtc", },
+};
+
+static const struct simple_mfd_data spacemit_p1 = {
+ .regmap_config = &spacemit_p1_regmap_config,
+ .mfd_cell = spacemit_p1_cells,
+ .mfd_cell_size = ARRAY_SIZE(spacemit_p1_cells),
+};
+
static const struct of_device_id simple_mfd_i2c_of_match[] = {
{ .compatible = "kontron,sl28cpld" },
{ .compatible = "silergy,sy7636a", .data = &silergy_sy7636a},
{ .compatible = "maxim,max5970", .data = &maxim_max5970},
{ .compatible = "maxim,max5978", .data = &maxim_max5970},
{ .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705},
+ { .compatible = "spacemit,p1", .data = &spacemit_p1, },
{}
};
MODULE_DEVICE_TABLE(of, simple_mfd_i2c_of_match);
--
2.48.1
Hi, Alex, I did not find any accesses to the P1 shutdown or reboot registers here. Does this mean that the current series does not support reboot or shutdown? If so, do you have any plans to support this functionality? If I have misunderstood, please correct me. Best regards, Troy On Tue, Aug 12, 2025 at 09:45:03PM -0500, Alex Elder wrote: > Enable support for the RTC and regulators found in the SpacemiT P1 > PMIC. Support is implemented by the simple I2C MFD driver. > > The P1 PMIC is normally implemented with the SpacemiT K1 SoC. This > PMIC provides 6 buck converters and 12 LDO regulators. It also > implements a switch, watchdog timer, real-time clock, and more. > Initially its RTC and regulators are supported. > > Signed-off-by: Alex Elder <elder@riscstar.com> > --- > drivers/mfd/Kconfig | 11 +++++++++++ > drivers/mfd/simple-mfd-i2c.c | 18 ++++++++++++++++++ > 2 files changed, 29 insertions(+) > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > index 425c5fba6cb1e..4d6a5a3a27220 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -1238,6 +1238,17 @@ config MFD_QCOM_RPM > Say M here if you want to include support for the Qualcomm RPM as a > module. This will build a module called "qcom_rpm". > > +config MFD_SPACEMIT_P1 > + tristate "SpacemiT P1 PMIC" > + depends on I2C > + select MFD_SIMPLE_MFD_I2C > + help > + This option supports the I2C-based SpacemiT P1 PMIC, which > + contains regulators, a power switch, GPIOs, an RTC, and more. > + This option is selected when any of the supported sub-devices > + is configured. The basic functionality is implemented by the > + simple MFD I2C driver. > + > config MFD_SPMI_PMIC > tristate "Qualcomm SPMI PMICs" > depends on ARCH_QCOM || COMPILE_TEST > diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c > index 22159913bea03..47ffaac035cae 100644 > --- a/drivers/mfd/simple-mfd-i2c.c > +++ b/drivers/mfd/simple-mfd-i2c.c > @@ -93,12 +93,30 @@ static const struct simple_mfd_data maxim_mon_max77705 = { > .mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells), > }; > > + > +static const struct regmap_config spacemit_p1_regmap_config = { > + .reg_bits = 8, > + .val_bits = 8, > +}; > + > +static const struct mfd_cell spacemit_p1_cells[] = { > + { .name = "spacemit-p1-regulator", }, > + { .name = "spacemit-p1-rtc", }, > +}; > + > +static const struct simple_mfd_data spacemit_p1 = { > + .regmap_config = &spacemit_p1_regmap_config, > + .mfd_cell = spacemit_p1_cells, > + .mfd_cell_size = ARRAY_SIZE(spacemit_p1_cells), > +}; > + > static const struct of_device_id simple_mfd_i2c_of_match[] = { > { .compatible = "kontron,sl28cpld" }, > { .compatible = "silergy,sy7636a", .data = &silergy_sy7636a}, > { .compatible = "maxim,max5970", .data = &maxim_max5970}, > { .compatible = "maxim,max5978", .data = &maxim_max5970}, > { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, > + { .compatible = "spacemit,p1", .data = &spacemit_p1, }, > {} > }; > MODULE_DEVICE_TABLE(of, simple_mfd_i2c_of_match); > -- > 2.48.1 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv
On 8/14/25 9:28 PM, Troy Mitchell wrote: > Hi, Alex, > > I did not find any accesses to the P1 shutdown or reboot registers here. > Does this mean that the current series does not support reboot or shutdown? Yes, that is correct. > If so, do you have any plans to support this functionality? At this time I personally don't have any plans to add this, but it could be added later (by anyone). I actually attempted to do this initially, but gave up. The PMIC is accessed via I2C, and I needed to implement a non-blocking version of the I2C register write operation. I tried that, but then found that the shutdown or reboot still did not work reliably. As it was, this was more than I originally planned to do, so I just implemented the simple RTC operations instead. -Alex > If I have misunderstood, please correct me. > > Best regards, > Troy > > > On Tue, Aug 12, 2025 at 09:45:03PM -0500, Alex Elder wrote: >> Enable support for the RTC and regulators found in the SpacemiT P1 >> PMIC. Support is implemented by the simple I2C MFD driver. >> >> The P1 PMIC is normally implemented with the SpacemiT K1 SoC. This >> PMIC provides 6 buck converters and 12 LDO regulators. It also >> implements a switch, watchdog timer, real-time clock, and more. >> Initially its RTC and regulators are supported. >> >> Signed-off-by: Alex Elder <elder@riscstar.com> >> --- >> drivers/mfd/Kconfig | 11 +++++++++++ >> drivers/mfd/simple-mfd-i2c.c | 18 ++++++++++++++++++ >> 2 files changed, 29 insertions(+) >> >> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig >> index 425c5fba6cb1e..4d6a5a3a27220 100644 >> --- a/drivers/mfd/Kconfig >> +++ b/drivers/mfd/Kconfig >> @@ -1238,6 +1238,17 @@ config MFD_QCOM_RPM >> Say M here if you want to include support for the Qualcomm RPM as a >> module. This will build a module called "qcom_rpm". >> >> +config MFD_SPACEMIT_P1 >> + tristate "SpacemiT P1 PMIC" >> + depends on I2C >> + select MFD_SIMPLE_MFD_I2C >> + help >> + This option supports the I2C-based SpacemiT P1 PMIC, which >> + contains regulators, a power switch, GPIOs, an RTC, and more. >> + This option is selected when any of the supported sub-devices >> + is configured. The basic functionality is implemented by the >> + simple MFD I2C driver. >> + >> config MFD_SPMI_PMIC >> tristate "Qualcomm SPMI PMICs" >> depends on ARCH_QCOM || COMPILE_TEST >> diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c >> index 22159913bea03..47ffaac035cae 100644 >> --- a/drivers/mfd/simple-mfd-i2c.c >> +++ b/drivers/mfd/simple-mfd-i2c.c >> @@ -93,12 +93,30 @@ static const struct simple_mfd_data maxim_mon_max77705 = { >> .mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells), >> }; >> >> + >> +static const struct regmap_config spacemit_p1_regmap_config = { >> + .reg_bits = 8, >> + .val_bits = 8, >> +}; >> + >> +static const struct mfd_cell spacemit_p1_cells[] = { >> + { .name = "spacemit-p1-regulator", }, >> + { .name = "spacemit-p1-rtc", }, >> +}; >> + >> +static const struct simple_mfd_data spacemit_p1 = { >> + .regmap_config = &spacemit_p1_regmap_config, >> + .mfd_cell = spacemit_p1_cells, >> + .mfd_cell_size = ARRAY_SIZE(spacemit_p1_cells), >> +}; >> + >> static const struct of_device_id simple_mfd_i2c_of_match[] = { >> { .compatible = "kontron,sl28cpld" }, >> { .compatible = "silergy,sy7636a", .data = &silergy_sy7636a}, >> { .compatible = "maxim,max5970", .data = &maxim_max5970}, >> { .compatible = "maxim,max5978", .data = &maxim_max5970}, >> { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, >> + { .compatible = "spacemit,p1", .data = &spacemit_p1, }, >> {} >> }; >> MODULE_DEVICE_TABLE(of, simple_mfd_i2c_of_match); >> -- >> 2.48.1 >> >> >> _______________________________________________ >> linux-riscv mailing list >> linux-riscv@lists.infradead.org >> http://lists.infradead.org/mailman/listinfo/linux-riscv
On Mon, Aug 25, 2025 at 11:08:45AM -0500, Alex Elder wrote: > On 8/14/25 9:28 PM, Troy Mitchell wrote: > > Hi, Alex, > > > > I did not find any accesses to the P1 shutdown or reboot registers here. > > Does this mean that the current series does not support reboot or shutdown? > > Yes, that is correct. > > > If so, do you have any plans to support this functionality? > > At this time I personally don't have any plans to add this, but > it could be added later (by anyone). > > I actually attempted to do this initially, but gave up. The PMIC > is accessed via I2C, and I needed to implement a non-blocking > version of the I2C register write operation. I tried that, but I have implemented a non-blocking version of the I2C driver [1] Link: https://lore.kernel.org/all/20250827-k1-i2c-atomic-v1-0-e59bea02d680@linux.spacemit.com/ [1] - Troy > then found that the shutdown or reboot still did not work reliably. > As it was, this was more than I originally planned to do, so I just > implemented the simple RTC operations instead. > > -Alex > > > If I have misunderstood, please correct me. > > > > Best regards, > > Troy > > > > > > On Tue, Aug 12, 2025 at 09:45:03PM -0500, Alex Elder wrote: > > > Enable support for the RTC and regulators found in the SpacemiT P1 > > > PMIC. Support is implemented by the simple I2C MFD driver. > > > > > > The P1 PMIC is normally implemented with the SpacemiT K1 SoC. This > > > PMIC provides 6 buck converters and 12 LDO regulators. It also > > > implements a switch, watchdog timer, real-time clock, and more. > > > Initially its RTC and regulators are supported. > > > > > > Signed-off-by: Alex Elder <elder@riscstar.com> > > > --- > > > drivers/mfd/Kconfig | 11 +++++++++++ > > > drivers/mfd/simple-mfd-i2c.c | 18 ++++++++++++++++++ > > > 2 files changed, 29 insertions(+) > > > > > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > > > index 425c5fba6cb1e..4d6a5a3a27220 100644 > > > --- a/drivers/mfd/Kconfig > > > +++ b/drivers/mfd/Kconfig > > > @@ -1238,6 +1238,17 @@ config MFD_QCOM_RPM > > > Say M here if you want to include support for the Qualcomm RPM as a > > > module. This will build a module called "qcom_rpm". > > > +config MFD_SPACEMIT_P1 > > > + tristate "SpacemiT P1 PMIC" > > > + depends on I2C > > > + select MFD_SIMPLE_MFD_I2C > > > + help > > > + This option supports the I2C-based SpacemiT P1 PMIC, which > > > + contains regulators, a power switch, GPIOs, an RTC, and more. > > > + This option is selected when any of the supported sub-devices > > > + is configured. The basic functionality is implemented by the > > > + simple MFD I2C driver. > > > + > > > config MFD_SPMI_PMIC > > > tristate "Qualcomm SPMI PMICs" > > > depends on ARCH_QCOM || COMPILE_TEST > > > diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c > > > index 22159913bea03..47ffaac035cae 100644 > > > --- a/drivers/mfd/simple-mfd-i2c.c > > > +++ b/drivers/mfd/simple-mfd-i2c.c > > > @@ -93,12 +93,30 @@ static const struct simple_mfd_data maxim_mon_max77705 = { > > > .mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells), > > > }; > > > + > > > +static const struct regmap_config spacemit_p1_regmap_config = { > > > + .reg_bits = 8, > > > + .val_bits = 8, > > > +}; > > > + > > > +static const struct mfd_cell spacemit_p1_cells[] = { > > > + { .name = "spacemit-p1-regulator", }, > > > + { .name = "spacemit-p1-rtc", }, > > > +}; > > > + > > > +static const struct simple_mfd_data spacemit_p1 = { > > > + .regmap_config = &spacemit_p1_regmap_config, > > > + .mfd_cell = spacemit_p1_cells, > > > + .mfd_cell_size = ARRAY_SIZE(spacemit_p1_cells), > > > +}; > > > + > > > static const struct of_device_id simple_mfd_i2c_of_match[] = { > > > { .compatible = "kontron,sl28cpld" }, > > > { .compatible = "silergy,sy7636a", .data = &silergy_sy7636a}, > > > { .compatible = "maxim,max5970", .data = &maxim_max5970}, > > > { .compatible = "maxim,max5978", .data = &maxim_max5970}, > > > { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, > > > + { .compatible = "spacemit,p1", .data = &spacemit_p1, }, > > > {} > > > }; > > > MODULE_DEVICE_TABLE(of, simple_mfd_i2c_of_match); > > > -- > > > 2.48.1 > > > > > > > > > _______________________________________________ > > > linux-riscv mailing list > > > linux-riscv@lists.infradead.org > > > http://lists.infradead.org/mailman/listinfo/linux-riscv > >
On Mon, Aug 25, 2025 at 11:08:45AM -0500, Alex Elder wrote: > On 8/14/25 9:28 PM, Troy Mitchell wrote: > > Hi, Alex, > > > > I did not find any accesses to the P1 shutdown or reboot registers here. > > Does this mean that the current series does not support reboot or shutdown? > > Yes, that is correct. > > > If so, do you have any plans to support this functionality? > > At this time I personally don't have any plans to add this, but > it could be added later (by anyone). > > I actually attempted to do this initially, but gave up. The PMIC > is accessed via I2C, and I needed to implement a non-blocking > version of the I2C register write operation. I tried that, You tried that? so that means you have implemented a non-blocking version of the I2C? If so, can you give me a source tree to test it? > but > then found that the shutdown or reboot still did not work reliably. ditto. - Troy > As it was, this was more than I originally planned to do, so I just > implemented the simple RTC operations instead. > > -Alex > > > If I have misunderstood, please correct me. > > > > Best regards, > > Troy > > > > > > On Tue, Aug 12, 2025 at 09:45:03PM -0500, Alex Elder wrote: > > > Enable support for the RTC and regulators found in the SpacemiT P1 > > > PMIC. Support is implemented by the simple I2C MFD driver. > > > > > > The P1 PMIC is normally implemented with the SpacemiT K1 SoC. This > > > PMIC provides 6 buck converters and 12 LDO regulators. It also > > > implements a switch, watchdog timer, real-time clock, and more. > > > Initially its RTC and regulators are supported. > > > > > > Signed-off-by: Alex Elder <elder@riscstar.com> > > > --- > > > drivers/mfd/Kconfig | 11 +++++++++++ > > > drivers/mfd/simple-mfd-i2c.c | 18 ++++++++++++++++++ > > > 2 files changed, 29 insertions(+) > > > > > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > > > index 425c5fba6cb1e..4d6a5a3a27220 100644 > > > --- a/drivers/mfd/Kconfig > > > +++ b/drivers/mfd/Kconfig > > > @@ -1238,6 +1238,17 @@ config MFD_QCOM_RPM > > > Say M here if you want to include support for the Qualcomm RPM as a > > > module. This will build a module called "qcom_rpm". > > > +config MFD_SPACEMIT_P1 > > > + tristate "SpacemiT P1 PMIC" > > > + depends on I2C > > > + select MFD_SIMPLE_MFD_I2C > > > + help > > > + This option supports the I2C-based SpacemiT P1 PMIC, which > > > + contains regulators, a power switch, GPIOs, an RTC, and more. > > > + This option is selected when any of the supported sub-devices > > > + is configured. The basic functionality is implemented by the > > > + simple MFD I2C driver. > > > + > > > config MFD_SPMI_PMIC > > > tristate "Qualcomm SPMI PMICs" > > > depends on ARCH_QCOM || COMPILE_TEST > > > diff --git a/drivers/mfd/simple-mfd-i2c.c b/drivers/mfd/simple-mfd-i2c.c > > > index 22159913bea03..47ffaac035cae 100644 > > > --- a/drivers/mfd/simple-mfd-i2c.c > > > +++ b/drivers/mfd/simple-mfd-i2c.c > > > @@ -93,12 +93,30 @@ static const struct simple_mfd_data maxim_mon_max77705 = { > > > .mfd_cell_size = ARRAY_SIZE(max77705_sensor_cells), > > > }; > > > + > > > +static const struct regmap_config spacemit_p1_regmap_config = { > > > + .reg_bits = 8, > > > + .val_bits = 8, > > > +}; > > > + > > > +static const struct mfd_cell spacemit_p1_cells[] = { > > > + { .name = "spacemit-p1-regulator", }, > > > + { .name = "spacemit-p1-rtc", }, > > > +}; > > > + > > > +static const struct simple_mfd_data spacemit_p1 = { > > > + .regmap_config = &spacemit_p1_regmap_config, > > > + .mfd_cell = spacemit_p1_cells, > > > + .mfd_cell_size = ARRAY_SIZE(spacemit_p1_cells), > > > +}; > > > + > > > static const struct of_device_id simple_mfd_i2c_of_match[] = { > > > { .compatible = "kontron,sl28cpld" }, > > > { .compatible = "silergy,sy7636a", .data = &silergy_sy7636a}, > > > { .compatible = "maxim,max5970", .data = &maxim_max5970}, > > > { .compatible = "maxim,max5978", .data = &maxim_max5970}, > > > { .compatible = "maxim,max77705-battery", .data = &maxim_mon_max77705}, > > > + { .compatible = "spacemit,p1", .data = &spacemit_p1, }, > > > {} > > > }; > > > MODULE_DEVICE_TABLE(of, simple_mfd_i2c_of_match); > > > -- > > > 2.48.1 > > > > > > > > > _______________________________________________ > > > linux-riscv mailing list > > > linux-riscv@lists.infradead.org > > > http://lists.infradead.org/mailman/listinfo/linux-riscv > >
© 2016 - 2025 Red Hat, Inc.