[PATCH v9 0/8] spacemit: introduce P1 PMIC support

Alex Elder
2025-07-24T20:25:16Z

The SpacemiT P1 is an I2C-controlled PMIC that implements 6 buck
converters and 12 LDOs. It contains a load switch, ADC channels,
GPIOs, a real-time clock, and a watchdog timer.

This series introduces a multifunction driver for the P1 PMIC as well
as drivers for its regulators and RTC.

Version 8 provided the ability in "simple-mfd-i2c.c" to specify the
max_register value for the regmap configuration as an alternative
to providing a "full" regmap structure. Lee Jones asked that the
max_register value take precedence if the regmap_config was also
provided.

This version changes a few things from v8:
- Alexandre Belloni's ack is added to patch 5.
- The max_register value in simple_mfd_data is always used if
it is non-zero, as requested by Lee Jones.
- The global regmap_config_8r_8v structure is back to being
const again.
- A new function simple_regmap_config() has been added in patch 2
to encapsulate the logic that determines what regmap_config
structure will be used.
- It uses regmap_config_8r_8v if simple_mfd_data is not supplied
for some reason.
- It uses regmap_config_8r_8v if the simple_mfd_data defines
neither regmap_config nor max_register.
- Otherwise, it dynamically allocates a regmap_config structure.
If simple_mfd_data refers to a regmap_config structure, it is
copied into the allocated struct; otherwise regmap_config_8r_8v
is copied.
- Finally, if the simple_mfd_data structure provides a non-zero
max_register value, it is used in the regmap_config.
- A small duplicated comment in "simple-mfd-i2c.h" is removed.

-Alex

This series is available here:
https://github.com/riscstar/linux/tree/outgoing/pmic-v9

Between version 8 and version 9:
- The max_config value is always used if it is provided with the
simple_mfd_data structure.
- The regmap_config structure used is allocated dynamically if
necessary; otherwise regmap_config_8r_8v is used.
- A small duplicated comment is removed

Here is version 8 of this series:
https://lore.kernel.org/lkml/20250710175107.1280221-1-elder@riscstar.com/

Between version 7 and version 8:
- Change the global regmap_config to not be const in patch 2.

Here is version 7 of this series:
https://lore.kernel.org/lkml/20250702213658.545163-1-elder@riscstar.com/

Between version 6 and version 7:
- Revise patch 2 to preserve the option to provide a full regmap config

Here is version 6 of this series:
https://lore.kernel.org/lkml/20250627142309.1444135-1-elder@riscstar.com/

Between version 5 and version 6:
- Added Rob Herring's reviewed-by to patch 1
- Add the simple MFD functionality suggested by Lee Jones
- Update patch 3 (previously 2) accordingly

Here is version 5 of this series:
https://lore.kernel.org/lkml/20250625164119.1068842-1-elder@riscstar.com/

Between version 4 and version 5:
- Only check the seconds register for change when looping on read
- Return without re-enabling the RTC if writing registers fails
- If the RTC is disabled when reading, return an error

Here is version 4 of this series:
https://lore.kernel.org/lkml/20250625164119.1068842-1-elder@riscstar.com/

More complete history is available at that link.

Alex Elder (8):
dt-bindings: mfd: add support the SpacemiT P1 PMIC
mfd: simple-mfd-i2c: specify max_register
mfd: simple-mfd-i2c: add SpacemiT P1 support
regulator: spacemit: support SpacemiT P1 regulators
rtc: spacemit: support the SpacemiT P1 RTC
riscv: dts: spacemit: enable the i2c8 adapter
riscv: dts: spacemit: define fixed regulators
riscv: dts: spacemit: define regulator constraints

.../devicetree/bindings/mfd/spacemit,p1.yaml | 86 +++++++++
.../boot/dts/spacemit/k1-bananapi-f3.dts | 138 +++++++++++++++
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 7 +
arch/riscv/boot/dts/spacemit/k1.dtsi | 11 ++
drivers/mfd/Kconfig | 11 ++
drivers/mfd/simple-mfd-i2c.c | 50 +++++-
drivers/mfd/simple-mfd-i2c.h | 5 +-
drivers/regulator/Kconfig | 12 ++
drivers/regulator/Makefile | 1 +
drivers/regulator/spacemit-p1.c | 157 ++++++++++++++++
drivers/rtc/Kconfig | 10 ++
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-spacemit-p1.c | 167 ++++++++++++++++++
13 files changed, 647 insertions(+), 9 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/spacemit,p1.yaml
create mode 100644 drivers/regulator/spacemit-p1.c
create mode 100644 drivers/rtc/rtc-spacemit-p1.c

base-commit: 9ee814bd78e315e4551223ca7548dd3f6bdcf1ae
--
2.43.0