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>
---
v4: - Add a dependency on I2C, to avoid a CROSS_COMPILE build error
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 6fb3768e3d71c..01805c3eec57d 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1182,6 +1182,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..026cd92e20ad3 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,
+ .max_register = 0xaa,
+};
+
+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.45.2
On Wed, 25 Jun 2025, 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> > --- > v4: - Add a dependency on I2C, to avoid a CROSS_COMPILE build error > > 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 6fb3768e3d71c..01805c3eec57d 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -1182,6 +1182,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..026cd92e20ad3 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, > + .max_register = 0xaa, > +}; Suggest making this more widely useful by adding the 'max_register' attribute to 'struct simple_mfd' and conditionally overriding regmap_config_8r_8v's value during probe. > +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.45.2 > -- Lee Jones [李琼斯]
On 6/27/25 7:51 AM, Lee Jones wrote: >> @@ -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, >> + .max_register = 0xaa, >> +}; > Suggest making this more widely useful by adding the 'max_register' > attribute to 'struct simple_mfd' and conditionally overriding > regmap_config_8r_8v's value during probe. So you're suggesting I make a general improvement to "simple-mfd-i2c.c", because everybody else just uses the generic fallback regmap config? (I'm asking because at first I didn't understand your statement, and the "more widely useful" comment). I would be happy to do this, and it's not that hard. Can I do it as a follow-on patch though? It's adding scope (again), beyond what I anticipated and honestly I'm ready to be done with this... Anyway, if you say "no" I'll send another version of this series today. -Alex > >> +static const struct mfd_cell spacemit_p1_cells[] = { >> + { .name = "spacemit-p1-regulator", }, >> + { .name = "spacemit-p1-rtc", }, >> +}; >> +
On Fri, 27 Jun 2025, Alex Elder wrote: > On 6/27/25 7:51 AM, Lee Jones wrote: > > > @@ -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, > > > + .max_register = 0xaa, > > > +}; > > Suggest making this more widely useful by adding the 'max_register' > > attribute to 'struct simple_mfd' and conditionally overriding > > regmap_config_8r_8v's value during probe. > > So you're suggesting I make a general improvement to > "simple-mfd-i2c.c", because everybody else just uses > the generic fallback regmap config? Yes, exactly that. > (I'm asking because at first I didn't understand your > statement, and the "more widely useful" comment). > > I would be happy to do this, and it's not that hard. > Can I do it as a follow-on patch though? It's adding > scope (again), beyond what I anticipated and honestly > I'm ready to be done with this... Good job you're not working on a complex addition then. =;-) > Anyway, if you say "no" I'll send another version of > this series today. A follow-up would be good, thanks. -- Lee Jones [李琼斯]
© 2016 - 2025 Red Hat, Inc.