Skip to contentSkip to conversation

Add STM32MP157 regulator driver

PATCH RESEND New Patrice Chotard 2 participants 9 messages Apr 26, 2018 – May 8, 2018

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Add STM32MP157 regulator driver

This series :
_ adds stpmu1 regulator driver
_ enables regulator relative flags in stm32mp15_basic_defconfig _ updates pmic driver to bind regulator child nodes
_ adds regulator nodes entry in DT

Christophe Kerello (1):
power: regulator: stpmu1: Introduce stpmu1 driver

Patrice Chotard (3):
power: pmic: stpmu1: Add regulator bindings
ARM: dts: stm32mp157c-ed1: Add regulator node
configs: stm32mp15_basic: Set regulator relative flags

 arch/arm/dts/stm32mp157c-ed1.dts    | 272 +++++++++++++++
 configs/stm32mp15_basic_defconfig   |   5 +
 drivers/power/pmic/stpmu1.c         |  34 ++
 drivers/power/regulator/Kconfig     |   9 +
 drivers/power/regulator/Makefile    |   1 +
 drivers/power/regulator/stpmu1.c    | 670 ++++++++++++++++++++++++++++++++++++
 include/dt-bindings/mfd/st,stpmu1.h |  60 ++++
 7 files changed, 1051 insertions(+)
 create mode 100644 drivers/power/regulator/stpmu1.c
 create mode 100644 include/dt-bindings/mfd/st,stpmu1.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH RESEND 1/4 power: regulator: stpmu1: Introduce stpmu1 driver

From: Christophe Kerello <[email protected]>

Enable support for the regulator functions of the STPMU1X PMIC. The driver implements get/set api for the various BUCKS and LDOs supported by the PMIC device. This driver is controlled by a device tree node which includes voltage limits.

---

 drivers/power/regulator/Kconfig  |   9 +
 drivers/power/regulator/Makefile |   1 +
 drivers/power/regulator/stpmu1.c | 670 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 680 insertions(+)
 create mode 100644 drivers/power/regulator/stpmu1.c
drivers/power/regulator/Kconfig +9 -0
index 5b4ac10462b4..822cff6608b8 100644
@@ -204,3 +204,12 @@ config DM_REGULATOR_TPS65910
 	The TPS65910 PMIC provides 4 SMPSs and 8 LDOs. This driver supports all
 	regulator types of the TPS65910 (BUCK, BOOST and LDO). It implements
 	the get/set api for value and enable.
+
+config DM_REGULATOR_STPMU1
+	bool "Enable driver for STPMU1 regulators"
+	depends on DM_REGULATOR && PMIC_STPMU1
+	---help---
+	Enable support for the regulator functions of the STPMU1 PMIC. The
+	driver implements get/set api for the various BUCKS and LDOs supported
+	by the PMIC device. This driver is controlled by a device tree node
+	which includes voltage limits.
drivers/power/regulator/Makefile +1 -0
index f7873ad27af1..d73a6e3577a9 100644
@@ -23,3 +23,4 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR_PBIAS) += pbias_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
 obj-$(CONFIG_DM_REGULATOR_TPS65910) += tps65910_regulator.o
+obj-$(CONFIG_$(SPL_)DM_REGULATOR_STPMU1) += stpmu1.o
drivers/power/regulator/stpmu1.c new file +670 -0

670 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH RESEND 1/4 power: regulator: stpmu1: Introduce stpmu1 driver

Quoted 10 lines · Patrice Chotard

From: Christophe Kerello <[email protected]>

Enable support for the regulator functions of the STPMU1X PMIC. The driver implements get/set api for the various BUCKS and LDOs supported by the PMIC device. This driver is controlled by a device tree node which includes voltage limits.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180508/85ffbaff/attachment.sig>
#3 lore raw

PATCH RESEND 2/4 power: pmic: stpmu1: Add regulator bindings

In reply to Patrice Chotard

Add regulator bindings to get access to regulator managed by drivers/power/regulator/stpmu1.c regulator driver.

---

 drivers/power/pmic/stpmu1.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/power/pmic/stpmu1.c +34 -0
index 4615365ea809..4a230ec163ae 100644
@@ -13,6 +13,17 @@
 
 #define STMPU1_NUM_OF_REGS 0x100
 
+#ifndef CONFIG_SPL_BUILD
+static const struct pmic_child_info stpmu1_children_info[] = {
+	{ .prefix = "ldo", .driver = "stpmu1_ldo" },
+	{ .prefix = "buck", .driver = "stpmu1_buck" },
+	{ .prefix = "vref_ddr", .driver = "stpmu1_vref_ddr" },
+	{ .prefix = "pwr_sw", .driver = "stpmu1_pwr_sw" },
+	{ .prefix = "boost", .driver = "stpmu1_boost" },
+	{ },
+};
+#endif /* CONFIG_SPL_BUILD */
+
 static int stpmu1_reg_count(struct udevice *dev)
 {
 	return STMPU1_NUM_OF_REGS;
@@ -43,6 +54,28 @@ static int stpmu1_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
 	return ret;
 }
 
+static int stpmu1_bind(struct udevice *dev)
+{
+#ifndef CONFIG_SPL_BUILD
+	ofnode regulators_node;
+	int children;
+
+	regulators_node = dev_read_subnode(dev, "regulators");
+	if (!ofnode_valid(regulators_node)) {
+		dev_dbg(dev, "regulators subnode not found!");
+		return -ENXIO;
+	}
+	dev_dbg(dev, "found regulators subnode\n");
+
+	children = pmic_bind_children(dev, regulators_node,
+				      stpmu1_children_info);
+	if (!children)
+		dev_dbg(dev, "no child found\n");
+#endif /* CONFIG_SPL_BUILD */
+
+	return 0;
+}
+
 static struct dm_pmic_ops stpmu1_ops = {
 	.reg_count = stpmu1_reg_count,
 	.read = stpmu1_read,
@@ -58,5 +91,6 @@ U_BOOT_DRIVER(pmic_stpmu1) = {
 	.name = "stpmu1_pmic",
 	.id = UCLASS_PMIC,
 	.of_match = stpmu1_ids,
+	.bind = stpmu1_bind,
 	.ops = &stpmu1_ops,
 };
Signature · 1 line
1.9.1
#4 lore raw

PATCH RESEND 2/4 power: pmic: stpmu1: Add regulator bindings

Quoted 6 lines · Patrice Chotard

Add regulator bindings to get access to regulator managed by drivers/power/regulator/stpmu1.c regulator driver.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180508/29df0563/attachment.sig>
#5 lore raw

PATCH RESEND 3/4 ARM: dts: stm32mp157c-ed1: Add regulator node

In reply to Patrice Chotard

Add regulator nodes needed by stpmu1 regulator driver Add vmmc-supply and vqmmc-supply regulator property for sdmmc1 and sdmmc2.

---

 arch/arm/dts/stm32mp157c-ed1.dts    | 272 ++++++++++++++++++++++++++++++++++++
 include/dt-bindings/mfd/st,stpmu1.h |  60 ++++++++
 2 files changed, 332 insertions(+)
 create mode 100644 include/dt-bindings/mfd/st,stpmu1.h
arch/arm/dts/stm32mp157c-ed1.dts +272 -0
index 4b20fabb717a..76e384775252 100644
@@ -10,6 +10,7 @@
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/pinctrl/stm32-pinfunc.h>
+#include <dt-bindings/mfd/st,stpmu1.h>
 
 / {
 	model = "STMicroelectronics STM32MP157C pmic eval daughter";
@@ -23,6 +24,19 @@
 	memory {
 		reg = <0xC0000000 0x40000000>;
 	};
+
+	sd_switch: regulator-sd_switch {
+		compatible = "regulator-gpio";
+		regulator-name = "sd_switch";
+		regulator-min-microvolt = <1800000>;
+		regulator-max-microvolt = <2900000>;
+		regulator-type = "voltage";
+		regulator-always-on;
+
+		gpios = <&gpiof 14 GPIO_ACTIVE_HIGH>;
+		gpios-states = <0>;
+		states = <1800000 0x1 2900000 0x0>;
+	};
 };
 
 &gpioa {
@@ -141,6 +155,262 @@
 		interrupt-controller;
 		#interrupt-cells = <2>;
 		status = "okay";
+
+		st,main_control_register = <0x04>;
+		st,vin_control_register = <0xc0>;
+		st,usb_control_register = <0x30>;
+
+		regulators {
+			compatible = "st,stpmu1-regulators";
+
+			ldo1-supply = <&v3v3>;
+			ldo2-supply = <&v3v3>;
+			ldo3-supply = <&vdd_ddr>;
+			ldo5-supply = <&v3v3>;
+			ldo6-supply = <&v3v3>;
+			pwr_sw1-supply = <&bst_out>;
+			pwr_sw2-supply = <&bst_out>;
+
+			vddcore: buck1 {
+				regulator-name = "vddcore";
+				regulator-min-microvolt = <800000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-always-on;
+				regulator-initial-mode = <2>;
+				regulator-over-current-protection;
+
+				regulator-state-standby {
+					regulator-on-in-suspend;
+					regulator-suspend-microvolt = <1200000>;
+					regulator-mode = <8>;
+				};
+				regulator-state-mem {
+					regulator-off-in-suspend;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			vdd_ddr: buck2 {
+				regulator-name = "vdd_ddr";
+				regulator-min-microvolt = <1350000>;
+				regulator-max-microvolt = <1350000>;
+				regulator-always-on;
+				regulator-initial-mode = <2>;
+				regulator-over-current-protection;
+
+				regulator-state-standby {
+					regulator-suspend-microvolt = <1350000>;
+					regulator-on-in-suspend;
+					regulator-mode = <8>;
+				};
+				regulator-state-mem {
+					regulator-suspend-microvolt = <1350000>;
+					regulator-on-in-suspend;
+					regulator-mode = <8>;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			vdd: buck3 {
+				regulator-name = "vdd";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-always-on;
+				st,mask_reset;
+				regulator-initial-mode = <8>;
+				regulator-over-current-protection;
+
+				regulator-state-standby {
+					regulator-suspend-microvolt = <3300000>;
+					regulator-on-in-suspend;
+					regulator-mode = <8>;
+				};
+				regulator-state-mem {
+					regulator-suspend-microvolt = <3300000>;
+					regulator-on-in-suspend;
+					regulator-mode = <8>;
+				};
+				regulator-state-disk {
+					regulator-suspend-microvolt = <3300000>;
+					regulator-on-in-suspend;
+					regulator-mode = <8>;
+				};
+			};
+
+			v3v3: buck4 {
+				regulator-name = "v3v3";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				regulator-boot-on;
+				regulator-over-current-protection;
+				regulator-initial-mode = <8>;
+
+				regulator-state-standby {
+					regulator-suspend-microvolt = <3300000>;
+					regulator-unchanged-in-suspend;
+					regulator-mode = <8>;
+				};
+				regulator-state-mem {
+					regulator-off-in-suspend;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			vdda: ldo1 {
+				regulator-name = "vdda";
+				regulator-min-microvolt = <2900000>;
+				regulator-max-microvolt = <2900000>;
+				interrupts = <IT_CURLIM_LDO1 0>;
+				interrupt-parent = <&pmic>;
+
+				regulator-state-standby {
+					regulator-suspend-microvolt = <2900000>;
+					regulator-unchanged-in-suspend;
+				};
+				regulator-state-mem {
+					regulator-off-in-suspend;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			v2v8: ldo2 {
+				regulator-name = "v2v8";
+				regulator-min-microvolt = <2800000>;
+				regulator-max-microvolt = <2800000>;
+				interrupts = <IT_CURLIM_LDO2 0>;
+				interrupt-parent = <&pmic>;
+
+				regulator-state-standby {
+					regulator-suspend-microvolt = <2800000>;
+					regulator-unchanged-in-suspend;
+				};
+				regulator-state-mem {
+					regulator-off-in-suspend;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			vtt_ddr: ldo3 {
+				regulator-name = "vtt_ddr";
+				regulator-min-microvolt = <0000000>;
+				regulator-max-microvolt = <1000000>;
+				regulator-always-on;
+				regulator-over-current-protection;
+
+				regulator-state-standby {
+					regulator-off-in-suspend;
+				};
+				regulator-state-mem {
+					regulator-off-in-suspend;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			vdd_usb: ldo4 {
+				regulator-name = "vdd_usb";
+				regulator-min-microvolt = <3300000>;
+				regulator-max-microvolt = <3300000>;
+				interrupts = <IT_CURLIM_LDO4 0>;
+				interrupt-parent = <&pmic>;
+
+				regulator-state-standby {
+					regulator-unchanged-in-suspend;
+				};
+				regulator-state-mem {
+					regulator-off-in-suspend;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			vdd_sd: ldo5 {
+				regulator-name = "vdd_sd";
+				regulator-min-microvolt = <2900000>;
+				regulator-max-microvolt = <2900000>;
+				interrupts = <IT_CURLIM_LDO5 0>;
+				interrupt-parent = <&pmic>;
+				regulator-boot-on;
+
+				regulator-state-standby {
+					regulator-suspend-microvolt = <2900000>;
+					regulator-unchanged-in-suspend;
+				};
+				regulator-state-mem {
+					regulator-off-in-suspend;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			v1v8: ldo6 {
+				regulator-name = "v1v8";
+				regulator-min-microvolt = <1800000>;
+				regulator-max-microvolt = <1800000>;
+				interrupts = <IT_CURLIM_LDO6 0>;
+				interrupt-parent = <&pmic>;
+
+				regulator-state-standby {
+					regulator-suspend-microvolt = <1800000>;
+					regulator-unchanged-in-suspend;
+				};
+				regulator-state-mem {
+					regulator-off-in-suspend;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			vref_ddr: vref_ddr {
+				regulator-name = "vref_ddr";
+				regulator-always-on;
+				regulator-over-current-protection;
+
+				regulator-state-standby {
+					regulator-on-in-suspend;
+				};
+				regulator-state-mem {
+					regulator-on-in-suspend;
+				};
+				regulator-state-disk {
+					regulator-off-in-suspend;
+				};
+			};
+
+			 bst_out: boost {
+				regulator-name = "bst_out";
+				interrupts = <IT_OCP_BOOST 0>;
+				interrupt-parent = <&pmic>;
+			 };
+
+			vbus_otg: pwr_sw1 {
+				regulator-name = "vbus_otg";
+				interrupts = <IT_OCP_OTG 0>;
+				interrupt-parent = <&pmic>;
+				regulator-active-discharge;
+			 };
+
+			 vbus_sw: pwr_sw2 {
+				regulator-name = "vbus_sw";
+				interrupts = <IT_OCP_SWOUT 0>;
+				interrupt-parent = <&pmic>;
+				regulator-active-discharge;
+			 };
+		};
 	};
 };
 
@@ -152,6 +422,8 @@
 	st,negedge;
 	st,pin-ckin;
 	bus-width = <4>;
+	vmmc-supply = <&vdd_sd>;
+	vqmmc-supply = <&sd_switch>;
 	sd-uhs-sdr12;
 	sd-uhs-sdr25;
 	sd-uhs-sdr50;
include/dt-bindings/mfd/st,stpmu1.h new file +60 -0

60 lines not on this page · raw message

Signature · 1 line
1.9.1
#6 lore raw

PATCH RESEND 3/4 ARM: dts: stm32mp157c-ed1: Add regulator node

Quoted 6 lines · Patrice Chotard

Add regulator nodes needed by stpmu1 regulator driver Add vmmc-supply and vqmmc-supply regulator property for sdmmc1 and sdmmc2.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180508/6f5819a3/attachment.sig>
#7 lore raw

PATCH RESEND 4/4 configs: stm32mp15_basic: Set regulator relative flags

In reply to Patrice Chotard

Enable DM_REGULATOR_STPMU1 flag to activate regulator driver for STM32MP15 SoC and CMD_REGULATOR flag to be able to set/get regulator state int U-boot command line.

Disable PMIC_CHILDREN as this flag is not needed in SPL for STM32MP1.

---

 configs/stm32mp15_basic_defconfig | 5 +++++
 1 file changed, 5 insertions(+)
configs/stm32mp15_basic_defconfig +5 -0
index 4ab1d4c8b12c..b5a75563fc38 100644
@@ -22,6 +22,7 @@ CONFIG_CMD_GPIO=y
 CONFIG_CMD_I2C=y
 CONFIG_CMD_MMC=y
 CONFIG_CMD_PMIC=y
+CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_ISO_PARTITION is not set
@@ -31,6 +32,10 @@ CONFIG_DM_MMC=y
 CONFIG_STM32_SDMMC2=y
 # CONFIG_SPL_PINCTRL_FULL is not set
 CONFIG_DM_PMIC=y
+# CONFIG_SPL_PMIC_CHILDREN is not set
 CONFIG_PMIC_STPMU1=y
+CONFIG_DM_REGULATOR=y
+CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_REGULATOR_STPMU1=y
 CONFIG_STM32_SERIAL=y
 # CONFIG_EFI_LOADER is not set
Signature · 1 line
1.9.1
#8 lore raw

PATCH RESEND 4/4 configs: stm32mp15_basic: Set regulator relative flags

Quoted 8 lines · Patrice Chotard

Enable DM_REGULATOR_STPMU1 flag to activate regulator driver for STM32MP15 SoC and CMD_REGULATOR flag to be able to set/get regulator state int U-boot command line.

Disable PMIC_CHILDREN as this flag is not needed in SPL for STM32MP1.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180508/208e43af/attachment.sig>