Skip to contentSkip to conversation

Add STM32MP157 regulator driver

PATCH RESEND Superseded Patrice Chotard 2 participants 6 messages Apr 26, 2018 – Apr 30, 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

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 +++++
 include/dt-bindings/mfd/st,stpmu1.h |  60 ++++++++
 4 files changed, 371 insertions(+)
 create mode 100644 include/dt-bindings/mfd/st,stpmu1.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH RESEND 1/3 power: pmic: stpmu1: Add regulator bindings

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
#2 lore raw

PATCH RESEND 2/3 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
#3 lore raw

PATCH RESEND 3/3 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
#4 lore raw

cover Add STM32MP157 regulator driver

In reply to Patrice Chotard

it misses one patch, sorry
i ressend it right now

Patrice

Quoted 20 lines · Patrice Chotard

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

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 +++++
  include/dt-bindings/mfd/st,stpmu1.h |  60 ++++++++
  4 files changed, 371 insertions(+)

create mode 100644 include/dt-bindings/mfd/st,stpmu1.h

#5 lore raw

cover Add STM32MP157 regulator driver

Hi,

Quoted 2 lines · Patrice CHOTARD

it misses one patch, sorry
i ressend it right now

"[RESEND][PATCH v1 0/4] .... " are right?

Best Regards,
Jaehoon Chung

Quoted 23 lines

Patrice

Quoted 19 lines · Patrice Chotard

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

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 +++++
  include/dt-bindings/mfd/st,stpmu1.h |  60 ++++++++
  4 files changed, 371 insertions(+)

create mode 100644 include/dt-bindings/mfd/st,stpmu1.h