spacemit: introduce P1 PMIC and regulator support
Subsystems (5)
v2 cover spacemit: introduce P1 PMIC and regulator support
The SpacemiT P1 is an I2C-controlled PMIC that implements six buck converters and twelve 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 a driver for its regulators.
This series is available here:
https://github.com/riscstar/linux/tree/outgoing/pmic-v2
-Alex
Between version 1 and version 2:
- Added Reviewed-by tag from Mark Brown to patch 3
- Implemented suggestions from Vivian Wang:
- Fixed a typo in the subject line in patch 1
- Now use module_i2c_driver() for the PMIC driver in patch 2
- Added MODULE_ALIAS() for both drivers (patches 2 and 3)
- Defined and used DRV_NAME in both drivers
- Added additional Kconfig module help text for both drivers
Here is version 1 of this series:
https://lore.kernel.org/lkml/[email protected]/
Alex Elder (6):
dt-bindings: mfd: add support the SpacemiT P1 PMIC
mfd: spacemit: add support for SpacemiT PMICs
regulator: spacemit: support SpacemiT P1 regulators
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 | 13 ++ drivers/mfd/Makefile | 1 + drivers/mfd/spacemit-pmic.c | 83 +++++++++ drivers/regulator/Kconfig | 11 ++ drivers/regulator/Makefile | 1 + drivers/regulator/spacemit-p1.c | 157 ++++++++++++++++++ 10 files changed, 508 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/spacemit,p1.yaml create mode 100644 drivers/mfd/spacemit-pmic.c create mode 100644 drivers/regulator/spacemit-p1.c
base-commit: 2c923c845768a0f0e34b8161d70bc96525385782
Signature · 1 line
2.45.2
PATCH v2 1/6 dt-bindings: mfd: add support the SpacemiT P1 PMIC
Enable the SpacemiT P1, which is an I2C-controlled PMIC. Initially only the regulators will be supported.
---
v2: - Spell SpacemiT correctly in the subject line
.../devicetree/bindings/mfd/spacemit,p1.yaml | 86 +++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/spacemit,p1.yaml
Documentation/devicetree/bindings/mfd/spacemit,p1.yaml new file +86 -0
@@ -0,0 +1,86 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/spacemit,p1.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: SpacemiT P1 Power Management Integrated Circuit + +maintainers: + - Troy Mitchell <[email protected]> + +description: + P1 is an I2C-controlled PMIC produced by SpacemiT. It implements six + constant-on-time buck converters and twelve low-dropout regulators. + It also contains a load switch, watchdog timer, real-time clock, eight + 12-bit ADC channels, and six GPIOs. Additional details are available + in the "Power Stone/P1" section at the following link. + https://developer.spacemit.com/documentation + +properties: + compatible: + const: spacemit,p1 + + reg: + maxItems: 1 + + interrupts: + maxItems: 1 + + vin-supply: + description: Input supply phandle. + + regulators: + type: object + + patternProperties: + "^(buck[1-6]|aldo[1-4]|dldo[1-7])$": + type: object + $ref: /schemas/regulator/regulator.yaml# + unevaluatedProperties: false + + unevaluatedProperties: false + +required: + - compatible + - reg + - interrupts + +unevaluatedProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@41 { + compatible = "spacemit,p1"; + reg = <0x41>; + interrupts = <64>; + + regulators { + buck1 { + regulator-name = "buck1"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + aldo1 { + regulator-name = "aldo1"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-boot-on; + }; + + dldo1 { + regulator-name = "dldo1"; + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-boot-on; + }; + }; + }; + };
Signature · 1 line
2.45.2
PATCH v2 2/6 mfd: spacemit: add support for SpacemiT PMICs
In reply to Alex ElderAdd support for SpacemiT PMICs. Initially only the P1 PMIC is supported but the driver is structured to allow support for others to be added.
The P1 PMIC is controlled by I2C, and is normally implemented with the SpacemiT K1 SoC. This PMIC provides six buck converters and 12 LDO regulators. It also implements a switch, watchdog timer, real-time clock, and more, but initially we will only support its regulators.
---
v2: - Use module_i2c_driver()
- Expanded Kconfig module help text
- Add MODULE_ALIAS(), and define and use DRV_NAME
drivers/mfd/Kconfig | 13 ++++++ drivers/mfd/Makefile | 1 + drivers/mfd/spacemit-pmic.c | 83 +++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 drivers/mfd/spacemit-pmic.c
drivers/mfd/Kconfig +13 -0
@@ -1182,6 +1182,19 @@ 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_PMIC + tristate "SpacemiT PMIC" + depends on ARCH_SPACEMIT || COMPILE_TEST + depends on I2C && OF + select MFD_CORE + select REGMAP_I2C + default ARCH_SPACEMIT + help + This option enables support for SpacemiT I2C based PMICs. At + this time only the P1 PMIC (used with the K1 SoC) is supported. + To compile this driver as a module, choose M here. The module + will be called "spacemit-pmic". + config MFD_SPMI_PMIC tristate "Qualcomm SPMI PMICs" depends on ARCH_QCOM || COMPILE_TEST
drivers/mfd/Makefile +1 -0
@@ -266,6 +266,7 @@ obj-$(CONFIG_MFD_SUN4I_GPADC) += sun4i-gpadc.o obj-$(CONFIG_MFD_STM32_LPTIMER) += stm32-lptimer.o obj-$(CONFIG_MFD_STM32_TIMERS) += stm32-timers.o obj-$(CONFIG_MFD_MXS_LRADC) += mxs-lradc.o +obj-$(CONFIG_MFD_SPACEMIT_PMIC) += spacemit-pmic.o obj-$(CONFIG_MFD_SC27XX_PMIC) += sprd-sc27xx-spi.o obj-$(CONFIG_RAVE_SP_CORE) += rave-sp.o obj-$(CONFIG_MFD_ROHM_BD71828) += rohm-bd71828.o
drivers/mfd/spacemit-pmic.c new file +83 -0
83 lines not on this page · raw message
Signature · 1 line
2.45.2
Lee Jones
maintainerRe: [PATCH v2 2/6] mfd: spacemit: add support for SpacemiT PMICs
Quoted 14 lines · Alex Elder
Add support for SpacemiT PMICs. Initially only the P1 PMIC is supported but the driver is structured to allow support for others to be added.
The P1 PMIC is controlled by I2C, and is normally implemented with the SpacemiT K1 SoC. This PMIC provides six buck converters and 12 LDO regulators. It also implements a switch, watchdog timer, real-time clock, and more, but initially we will only support its regulators.
Signed-off-by Alex Elder <[email protected]>---
v2: - Usemodule_i2c_driver()
- ExpandedKconfigmodule help text
- AddMODULE_ALIAS(), and define and useDRV_NAME
Quoted 5 lines
drivers/mfd/Kconfig | 13 ++++++ drivers/mfd/Makefile | 1 + drivers/mfd/spacemit-pmic.c | 83 +++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 drivers/mfd/spacemit-pmic.c
All comments fro v1 are still relevant.
Signature · 1 line
Lee Jones [李琼斯]
PATCH v2 3/6 regulator: spacemit: support SpacemiT P1 regulators
In reply to Alex ElderAdd support for the regulators found in the SpacemiT P1 PMIC. This PMIC provides six buck converters and 12 LDO regulators.
The PMIC is implemented as a multi-function device. These regulators are probed based on this driver being named in a MFD cell in the P1 PMIC driver.
---
v2: - Added Mark's Reviewed-by tag
- Expanded Kconfig module help text
- Add MODULE_ALIAS(), and define and use DRV_NAME
drivers/regulator/Kconfig | 11 +++ drivers/regulator/Makefile | 1 + drivers/regulator/spacemit-p1.c | 157 ++++++++++++++++++++++++++++++++ 3 files changed, 169 insertions(+) create mode 100644 drivers/regulator/spacemit-p1.c
drivers/regulator/Kconfig +11 -0
@@ -1395,6 +1395,17 @@ config REGULATOR_SLG51000 The SLG51000 is seven compact and customizable low dropout regulators. +config REGULATOR_SPACEMIT_P1 + tristate "SpacemiT P1 regulators" + depends on ARCH_SPACEMIT || COMPILE_TEST + default ARCH_SPACEMIT + help + Enable support for regulators implemented by the SpacemiT P1 + power controller. The P1 implements 6 high-efficiency buck + converters and 12 programmable LDO regulators. To compile this + driver as a module, choose M here. The module will be called + "spacemit-pmic". + config REGULATOR_STM32_BOOSTER tristate "STMicroelectronics STM32 BOOSTER" depends on ARCH_STM32 || COMPILE_TEST
drivers/regulator/Makefile +1 -0
@@ -162,6 +162,7 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o obj-$(CONFIG_REGULATOR_SLG51000) += slg51000-regulator.o +obj-$(CONFIG_REGULATOR_SPACEMIT_P1) += spacemit-p1.o obj-$(CONFIG_REGULATOR_STM32_BOOSTER) += stm32-booster.o obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
drivers/regulator/spacemit-p1.c new file +157 -0
157 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH v2 4/6 riscv: dts: spacemit: enable the i2c8 adapter
In reply to Alex ElderDefine properties for the I2C adapter that provides access to the SpacemiT P1 PMIC. Enable this adapter on the Banana Pi BPI-F3.
--- arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts | 15 +++++++++++++++ arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi | 7 +++++++ arch/riscv/boot/dts/spacemit/k1.dtsi | 11 +++++++++++ 3 files changed, 33 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +15 -0
@@ -40,6 +40,21 @@ &emmc { status = "okay"; }; +&i2c8 { + pinctrl-0 = <&i2c8_cfg>; + pinctrl-names = "default"; + #address-cells = <1>; + #size-cells = <0>; + status = "okay"; + + pmic@41 { + compatible = "spacemit,p1"; + reg = <0x41>; + interrupts = <64>; + status = "okay"; + }; +}; + &uart0 { pinctrl-names = "default"; pinctrl-0 = <&uart0_2_cfg>;
arch/riscv/boot/dts/spacemit/k1-pinctrl.dtsi +7 -0
@@ -11,6 +11,13 @@ #define K1_GPIO(x) (x / 32) (x % 32) &pinctrl { + i2c8_cfg: i2c8-cfg { + i2c8-0-pins { + pinmux = <K1_PADCONF(93, 0)>, /* PWR_SCL */ + <K1_PADCONF(94, 0)>; /* PWR_SDA */ + }; + }; + uart0_2_cfg: uart0-2-cfg { uart0-2-pins { pinmux = <K1_PADCONF(68, 2)>,
arch/riscv/boot/dts/spacemit/k1.dtsi +11 -0
@@ -483,6 +483,17 @@ gpio: gpio@d4019000 { <&pinctrl 3 0 96 32>; }; + i2c8: i2c@d401d800 { + compatible = "spacemit,k1-i2c"; + reg = <0x0 0xd401d800 0x0 0x38>; + interrupts = <19>; + clocks = <&syscon_apbc CLK_TWSI8>, + <&syscon_apbc CLK_TWSI8_BUS>; + clock-names = "func", "bus"; + clock-frequency = <400000>; + status = "disabled"; + }; + pinctrl: pinctrl@d401e000 { compatible = "spacemit,k1-pinctrl"; reg = <0x0 0xd401e000 0x0 0x400>;
Signature · 1 line
2.45.2
PATCH v2 5/6 riscv: dts: spacemit: define fixed regulators
In reply to Alex ElderDefine the DC power input and the 4v power as fixed supplies in the Banana Pi BPI-F3.
--- .../boot/dts/spacemit/k1-bananapi-f3.dts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +19 -0
@@ -28,6 +28,25 @@ led1 { default-state = "on"; }; }; + + reg_dc_in: dc-in-12v { + compatible = "regulator-fixed"; + regulator-name = "dc_in_12v"; + regulator-min-microvolt = <12000000>; + regulator-max-microvolt = <12000000>; + regulator-boot-on; + regulator-always-on; + }; + + reg_vcc_4v: vcc-4v { + compatible = "regulator-fixed"; + regulator-name = "vcc_4v"; + regulator-min-microvolt = <4000000>; + regulator-max-microvolt = <4000000>; + regulator-boot-on; + regulator-always-on; + vin-supply = <®_dc_in>; + }; }; &emmc {
Signature · 1 line
2.45.2
PATCH v2 6/6 riscv: dts: spacemit: define regulator constraints
In reply to Alex ElderDefine basic constraints for the regulators in the SpacemiT P1 PMIC, as implemented in the Banana Pi BPI-F3.
--- .../boot/dts/spacemit/k1-bananapi-f3.dts | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+)
arch/riscv/boot/dts/spacemit/k1-bananapi-f3.dts +104 -0
@@ -70,7 +70,111 @@ pmic@41 { compatible = "spacemit,p1"; reg = <0x41>; interrupts = <64>; + vin-supply = <®_vcc_4v>; status = "okay"; + + regulators { + buck1 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck2 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck3 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <1800000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck4 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3300000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck5 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + buck6 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3450000>; + regulator-ramp-delay = <5000>; + regulator-always-on; + }; + + aldo1 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-boot-on; + }; + + aldo2 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + aldo3 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + aldo4 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo1 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-boot-on; + }; + + dldo2 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo3 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo4 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-always-on; + }; + + dldo5 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + + dldo6 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + regulator-always-on; + }; + + dldo7 { + regulator-min-microvolt = <500000>; + regulator-max-microvolt = <3400000>; + }; + }; }; };
Signature · 1 line
2.45.2