Skip to contentSkip to conversation

Model SMPS10 regulator

PATCH Applied Kishon Vijay Abraham I 3 participants 14 messages Jun 20, 2013 – Jun 24, 2013

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

cover Model SMPS10 regulator

Palmas has SMPS10 regulator which can generate two voltage level 3.75 and 5V. This SMPS10 has two outputs OUT1 and OUT2 and having one input IN1.

SMPS10-OUT2 is always connected to SMPS10-IN1 via following logic:
- Through parasitic diode (no sw control)
- In bypass mode (bit configuration is there to enable/disable Bypass)
- In Boost mode (bit configuration is there to enable/disable Boost mode)

SMPS10-OUT1 is connected to the SMPS10-OUT2 pin through Switch (SW control for enabling/disabling this switch).

There currently doesn't exist a property to indicate if the regulator supports bypass mode. So added a property to indicate if the regulator supports bypass mode. Also modified of_get_regulation_constraints() to check for that property and set appropriate constraints.

The second patch models SMPS10 as two regulators, SMPS10-OUT1 and SMPS10-OUT2.

Tested regulator enable of SMPS10-OUT1.
Dint test bypass mode.

Kishon Vijay Abraham I (2):
regulator: of: Added a property to indicate bypass mode support
regulator: palmas: model SMPS10 as two regulators

 .../devicetree/bindings/regulator/regulator.txt    |    1 +
 drivers/regulator/of_regulator.c                   |    3 ++
 drivers/regulator/palmas-regulator.c               |   39 ++++++++++++++++++--
 include/linux/mfd/palmas.h                         |    9 +++--
 4 files changed, 44 insertions(+), 8 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/2 regulator: of: Added a property to indicate bypass mode support

Added a property to indicate if the regulator supports bypass mode. Also modified of_get_regulation_constraints() to check for that property and set appropriate constraints.

---
 Documentation/devicetree/bindings/regulator/regulator.txt |    1 +
 drivers/regulator/of_regulator.c                          |    3 +++
 2 files changed, 4 insertions(+)
Documentation/devicetree/bindings/regulator/regulator.txt +1 -0
index ecfc6cc..48a3b8e 100644
@@ -9,6 +9,7 @@ Optional properties:
 - regulator-max-microamp: largest current consumers may set
 - regulator-always-on: boolean, regulator should never be disabled
 - regulator-boot-on: bootloader/firmware enabled regulator
+- regulator-allow-bypass: allow the regulator to go into bypass mode
 - <name>-supply: phandle to the parent supply/regulator node
 - regulator-ramp-delay: ramp delay for regulator(in uV/uS)
 
drivers/regulator/of_regulator.c +3 -0
index 66ca769..f3c8f8f 100644
@@ -61,6 +61,9 @@ static void of_get_regulation_constraints(struct device_node *np,
 	else /* status change should be possible if not always on. */
 		constraints->valid_ops_mask |= REGULATOR_CHANGE_STATUS;
 
+	if (of_property_read_bool(np, "regulator-allow-bypass"))
+		constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS;
+
 	ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL);
 	if (ramp_delay)
 		constraints->ramp_delay = be32_to_cpu(*ramp_delay);
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 2/2 regulator: palmas: model SMPS10 as two regulators

In reply to Kishon Vijay Abraham I

SMPS10 has two outputs OUT1 and OUT2 and have one input IN1. SMPS10-OUT2 is connected to SMPS10-IN1 and can be configured either in BOOST mode or BYPASS mode. regulator_enable of SMPS10-OUT2 configures it in BOOST mode. For BYPASS mode regulator_allow_bypass() API can be used. SMPS10-OUT1 is connected to SMPS10-OUT2 and can be enabled using regulator_enable().

---
 drivers/regulator/palmas-regulator.c |   39 ++++++++++++++++++++++++++++++----
 include/linux/mfd/palmas.h           |    9 ++++----
 2 files changed, 40 insertions(+), 8 deletions(-)
drivers/regulator/palmas-regulator.c +35 -4
index 3ae44ac..7004bab 100644
@@ -97,7 +97,12 @@ static const struct regs_info palmas_regs_info[] = {
 		.ctrl_addr	= PALMAS_SMPS9_CTRL,
 	},
 	{
-		.name		= "SMPS10",
+		.name		= "SMPS10_OUT1",
+		.sname		= "smps10-out2",
+		.ctrl_addr	= PALMAS_SMPS10_CTRL,
+	},
+	{
+		.name		= "SMPS10_OUT2",
 		.sname		= "smps10-in",
 		.ctrl_addr	= PALMAS_SMPS10_CTRL,
 	},
@@ -487,6 +492,8 @@ static struct regulator_ops palmas_ops_smps10 = {
 	.set_voltage_sel	= regulator_set_voltage_sel_regmap,
 	.list_voltage		= regulator_list_voltage_linear,
 	.map_voltage		= regulator_map_voltage_linear,
+	.set_bypass		= regulator_set_bypass_regmap,
+	.get_bypass		= regulator_get_bypass_regmap,
 };
 
 static int palmas_is_enabled_ldo(struct regulator_dev *dev)
@@ -538,7 +545,8 @@ static int palmas_smps_init(struct palmas *palmas, int id,
 		return ret;
 
 	switch (id) {
-	case PALMAS_REG_SMPS10:
+	case PALMAS_REG_SMPS10_OUT1:
+	case PALMAS_REG_SMPS10_OUT2:
 		reg &= ~PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK;
 		if (reg_init->mode_sleep)
 			reg |= reg_init->mode_sleep <<
@@ -681,7 +689,8 @@ static struct of_regulator_match palmas_matches[] = {
 	{ .name = "smps7", },
 	{ .name = "smps8", },
 	{ .name = "smps9", },
-	{ .name = "smps10", },
+	{ .name = "smps10_out1", },
+	{ .name = "smps10_out2", },
 	{ .name = "ldo1", },
 	{ .name = "ldo2", },
 	{ .name = "ldo3", },
@@ -869,7 +878,25 @@ static int palmas_regulators_probe(struct platform_device *pdev)
 		pmic->desc[id].id = id;
 
 		switch (id) {
-		case PALMAS_REG_SMPS10:
+		case PALMAS_REG_SMPS10_OUT1:
+			pmic->desc[id].n_voltages = PALMAS_SMPS10_NUM_VOLTAGES;
+			pmic->desc[id].ops = &palmas_ops_smps10;
+			pmic->desc[id].vsel_reg =
+					PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
+							PALMAS_SMPS10_CTRL);
+			pmic->desc[id].vsel_mask = SMPS10_VSEL;
+			pmic->desc[id].enable_reg =
+					PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
+							PALMAS_SMPS10_CTRL);
+			pmic->desc[id].enable_mask = SMPS10_SWITCH_EN;
+			pmic->desc[id].bypass_reg =
+					PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
+							PALMAS_SMPS10_CTRL);
+			pmic->desc[id].bypass_mask = SMPS10_BYPASS_EN;
+			pmic->desc[id].min_uV = 3750000;
+			pmic->desc[id].uV_step = 1250000;
+			break;
+		case PALMAS_REG_SMPS10_OUT2:
 			pmic->desc[id].n_voltages = PALMAS_SMPS10_NUM_VOLTAGES;
 			pmic->desc[id].ops = &palmas_ops_smps10;
 			pmic->desc[id].vsel_reg =
@@ -880,6 +907,10 @@ static int palmas_regulators_probe(struct platform_device *pdev)
 					PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
 							PALMAS_SMPS10_CTRL);
 			pmic->desc[id].enable_mask = SMPS10_BOOST_EN;
+			pmic->desc[id].bypass_reg =
+					PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
+							PALMAS_SMPS10_CTRL);
+			pmic->desc[id].bypass_mask = SMPS10_BYPASS_EN;
 			pmic->desc[id].min_uV = 3750000;
 			pmic->desc[id].uV_step = 1250000;
 			break;
include/linux/mfd/palmas.h +5 -4
index 8f21daf..1bbcda9 100644
@@ -138,7 +138,8 @@ enum palmas_regulators {
 	PALMAS_REG_SMPS7,
 	PALMAS_REG_SMPS8,
 	PALMAS_REG_SMPS9,
-	PALMAS_REG_SMPS10,
+	PALMAS_REG_SMPS10_OUT1,
+	PALMAS_REG_SMPS10_OUT2,
 	/* LDO regulators */
 	PALMAS_REG_LDO1,
 	PALMAS_REG_LDO2,
@@ -336,9 +337,9 @@ struct palmas_pmic {
 	int smps123;
 	int smps457;
 
-	int range[PALMAS_REG_SMPS10];
-	unsigned int ramp_delay[PALMAS_REG_SMPS10];
-	unsigned int current_reg_mode[PALMAS_REG_SMPS10];
+	int range[PALMAS_REG_SMPS10_OUT2];
+	unsigned int ramp_delay[PALMAS_REG_SMPS10_OUT2];
+	unsigned int current_reg_mode[PALMAS_REG_SMPS10_OUT2];
 };
 
 struct palmas_resource {
Signature · 1 line
1.7.10.4
#4 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

Quoted 21 lines · Kishon Vijay Abraham I

SMPS10 has two outputs OUT1 and OUT2 and have one input IN1. SMPS10-OUT2 is connected to SMPS10-IN1 and can be configured either in BOOST mode or BYPASS mode. regulator_enable of SMPS10-OUT2 configures it in BOOST mode. For BYPASS mode regulator_allow_bypass() API can be used. SMPS10-OUT1 is connected to SMPS10-OUT2 and can be enabled using regulator_enable().

---
  drivers/regulator/palmas-regulator.c |   39 ++++++++++++++++++++++++++++++----
  include/linux/mfd/palmas.h           |    9 ++++----
  2 files changed, 40 insertions(+), 8 deletions(-)
drivers/regulator/palmas-regulator.c +0 -0
index 3ae44ac..7004bab 100644
@@ -97,7 +97,12 @@ static const struct regs_info palmas_regs_info[] = {
  		.ctrl_addr	= PALMAS_SMPS9_CTRL,
  	},

drivers/regulator/palmas-regulator.c static const struct regs_info palmas_regs_info[] = { · line 107

Quoted 10 lines
drivers/regulator/palmas-regulator.c +6 -1
  	{
-		.name		= "SMPS10",
+		.name		= "SMPS10_OUT1",
+		.sname		= "smps10-out2",
+		.ctrl_addr	= PALMAS_SMPS10_CTRL,
+	},
+	{
+		.name		= "SMPS10_OUT2",
  		.sname		= "smps10-in",
 

This sequence can create regulator to be never register.
In probe, we register regulator from 0 to max_id.
Here smps10-out1 comes first and see the supply as smps10-out2 which is not registered yet and so will fail with PROBE_DEFER When again it tries, the same issue.

I think we need to reverse the sequence, SMPS10-OUT2 and then SMPS10-OUT1.

maintainer Applied
#2 lore raw

Re: [PATCH 1/2] regulator: of: Added a property to indicate bypass mode support

In reply to Kishon Vijay Abraham I
Quoted 3 lines · Kishon Vijay Abraham I

Added a property to indicate if the regulator supports bypass mode. Also modified of_get_regulation_constraints() to check for that property and set appropriate constraints.

Applied, thanks.

_______________________________________________
devicetree-discuss mailing list devicetree-discuss-uLR06cmDAlY/[email protected]
https://lists.ozlabs.org/listinfo/devicetree-discuss

#5 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

In reply to Laxman Dewangan

Hi,

Quoted 31 lines · Laxman Dewangan
Quoted 30 lines · Kishon Vijay Abraham I

SMPS10 has two outputs OUT1 and OUT2 and have one input IN1. SMPS10-OUT2 is connected to SMPS10-IN1 and can be configured either in BOOST mode or BYPASS mode. regulator_enable of SMPS10-OUT2 configures it in BOOST mode. For BYPASS mode regulator_allow_bypass() API can be used. SMPS10-OUT1 is connected to SMPS10-OUT2 and can be enabled using regulator_enable().

---
  drivers/regulator/palmas-regulator.c |   39 ++++++++++++++++++++++++++++++----
  include/linux/mfd/palmas.h           |    9 ++++----
  2 files changed, 40 insertions(+), 8 deletions(-)
drivers/regulator/palmas-regulator.c +6 -1
index 3ae44ac..7004bab 100644
@@ -97,7 +97,12 @@ static const struct regs_info palmas_regs_info[] = {
          .ctrl_addr    = PALMAS_SMPS9_CTRL,
      },
      {
-        .name        = "SMPS10",
+        .name        = "SMPS10_OUT1",
+        .sname        = "smps10-out2",
+        .ctrl_addr    = PALMAS_SMPS10_CTRL,
+    },
+    {
+        .name        = "SMPS10_OUT2",
Quoted 8 lines

drivers/regulator/palmas-regulator.c static const struct regs_info palmas_regs_info[] = { · line 107

Quoted 2 lines
drivers/regulator/palmas-regulator.c +0 -0
          .sname        = "smps10-in",
 

This sequence can create regulator to be never register.
In probe, we register regulator from 0 to max_id.
Here smps10-out1 comes first and see the supply as smps10-out2 which is not registered yet and so will fail with PROBE_DEFER
When again it tries, the same issue.

hmm.. But I was able to get (regulator_get) *SMPS10_OUT1* without any issue during my testing. From looking at the code, I couldn't see *sname* being used anywhere.

Thanks
Kishon

#6 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

Quoted 41 lines · Kishon Vijay Abraham I

Hi,

Quoted 30 lines · Laxman Dewangan
Quoted 29 lines · Kishon Vijay Abraham I

SMPS10 has two outputs OUT1 and OUT2 and have one input IN1. SMPS10-OUT2 is connected to SMPS10-IN1 and can be configured either in BOOST mode or BYPASS mode. regulator_enable of SMPS10-OUT2 configures it in BOOST mode. For BYPASS mode regulator_allow_bypass() API can be used. SMPS10-OUT1 is connected to SMPS10-OUT2 and can be enabled using regulator_enable().

---
   drivers/regulator/palmas-regulator.c |   39 ++++++++++++++++++++++++++++++----
   include/linux/mfd/palmas.h           |    9 ++++----
   2 files changed, 40 insertions(+), 8 deletions(-)
drivers/regulator/palmas-regulator.c +5 -1
index 3ae44ac..7004bab 100644
@@ -97,7 +97,12 @@ static const struct regs_info palmas_regs_info[] = {
           .ctrl_addr    = PALMAS_SMPS9_CTRL,
       },
       {
-        .name        = "SMPS10",
+        .name        = "SMPS10_OUT1",
+        .sname        = "smps10-out2",
+        .ctrl_addr    = PALMAS_SMPS10_CTRL,
+    },
+    {
Quoted 8 lines

drivers/regulator/palmas-regulator.c static const struct regs_info palmas_regs_info[] = {

Quoted 3 lines
drivers/regulator/palmas-regulator.c +1 -0
+        .name        = "SMPS10_OUT2",
           .sname        = "smps10-in",
 

This sequence can create regulator to be never register.
In probe, we register regulator from 0 to max_id.
Here smps10-out1 comes first and see the supply as smps10-out2 which is not registered yet and so will fail with PROBE_DEFER
When again it tries, the same issue.

Quoted 3 lines

hmm.. But I was able to get (regulator_get) *SMPS10_OUT1* without any issue during my testing. From looking at the code, I couldn't see *sname* being used anywhere.

We used the sname as
pmic->desc[id].supply_name = palmas_regs_info[id].sname;

However, how you have populated your dt?
Have you added like
smps10-out2-supply = <&SMPS10_OUT2>

for the palmas regualtor -dt.

#7 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

Hi,

Quoted 47 lines · Laxman Dewangan
Quoted 42 lines · Kishon Vijay Abraham I

Hi,

Quoted 31 lines · Laxman Dewangan
Quoted 30 lines · Kishon Vijay Abraham I

SMPS10 has two outputs OUT1 and OUT2 and have one input IN1. SMPS10-OUT2 is connected to SMPS10-IN1 and can be configured either in BOOST mode or BYPASS mode. regulator_enable of SMPS10-OUT2 configures it in BOOST mode. For BYPASS mode regulator_allow_bypass() API can be used. SMPS10-OUT1 is connected to SMPS10-OUT2 and can be enabled using regulator_enable().

---
   drivers/regulator/palmas-regulator.c |   39
++++++++++++++++++++++++++++++----
   include/linux/mfd/palmas.h           |    9 ++++----
   2 files changed, 40 insertions(+), 8 deletions(-)
drivers/regulator/palmas-regulator.c +5 -1
index 3ae44ac..7004bab 100644
@@ -97,7 +97,12 @@ static const struct regs_info palmas_regs_info[] = {
           .ctrl_addr    = PALMAS_SMPS9_CTRL,
       },
       {
-        .name        = "SMPS10",
+        .name        = "SMPS10_OUT1",
+        .sname        = "smps10-out2",
+        .ctrl_addr    = PALMAS_SMPS10_CTRL,
+    },
+    {
Quoted 8 lines

drivers/regulator/palmas-regulator.c static const struct regs_info palmas_regs_info[] = {

Quoted 3 lines
drivers/regulator/palmas-regulator.c +1 -0
+        .name        = "SMPS10_OUT2",
           .sname        = "smps10-in",
 

This sequence can create regulator to be never register.
In probe, we register regulator from 0 to max_id.
Here smps10-out1 comes first and see the supply as smps10-out2 which is not registered yet and so will fail with PROBE_DEFER
When again it tries, the same issue.

Quoted 3 lines

hmm.. But I was able to get (regulator_get) *SMPS10_OUT1* without any issue during my testing. From looking at the code, I couldn't see *sname* being used anywhere.

Quoted 8 lines

We used the sname as
pmic->desc[id].supply_name = palmas_regs_info[id].sname;

However, how you have populated your dt?
Have you added like
smps10-out2-supply = <&SMPS10_OUT2>

for the palmas regualtor -dt.

I added the regulator data like

+ smps10_out1_reg: smps10_out1 {

+                               regulator-name = "smps10_out1";
+                               regulator-min-microvolt = <5000000>;
+                               regulator-max-microvolt = <5000000>;
+                               regulator-always-on;
+                               regulator-boot-on;
+                               regulator-allow-bypass;
+                               ti,warm_sleep = <0>;
+                               ti,roof_floor = <0>;
+                               ti,mode_sleep = <0>;
+                               ti,warm_reset = <0>;
+                               ti,tstep = <0>;
+                               ti,vsel = <0>;

+ };

and from my controller I reference it using
+ vbus-supply = <&smps10_out1_reg>;

and in the controller driver I use
+ vbus_reg = devm_regulator_get(dev, "vbus");

Thanks
Kishon

#8 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

Quoted 74 lines · Kishon Vijay Abraham I

Hi,

Quoted 46 lines · Laxman Dewangan
Quoted 42 lines · Kishon Vijay Abraham I

Hi,

Quoted 31 lines · Laxman Dewangan
Quoted 30 lines · Kishon Vijay Abraham I

SMPS10 has two outputs OUT1 and OUT2 and have one input IN1. SMPS10-OUT2 is connected to SMPS10-IN1 and can be configured either in BOOST mode or BYPASS mode. regulator_enable of SMPS10-OUT2 configures it in BOOST mode. For BYPASS mode regulator_allow_bypass() API can be used. SMPS10-OUT1 is connected to SMPS10-OUT2 and can be enabled using regulator_enable().

---
    drivers/regulator/palmas-regulator.c |   39
++++++++++++++++++++++++++++++----
    include/linux/mfd/palmas.h           |    9 ++++----
    2 files changed, 40 insertions(+), 8 deletions(-)
drivers/regulator/palmas-regulator.c +5 -1
index 3ae44ac..7004bab 100644
@@ -97,7 +97,12 @@ static const struct regs_info palmas_regs_info[] = {
            .ctrl_addr    = PALMAS_SMPS9_CTRL,
        },
        {
-        .name        = "SMPS10",
+        .name        = "SMPS10_OUT1",
+        .sname        = "smps10-out2",
+        .ctrl_addr    = PALMAS_SMPS10_CTRL,
+    },
+    {
Quoted 8 lines

drivers/regulator/palmas-regulator.c static const struct regs_info palmas_regs_info[] = {

Quoted 3 lines
drivers/regulator/palmas-regulator.c +1 -0
+        .name        = "SMPS10_OUT2",
            .sname        = "smps10-in",
 

This sequence can create regulator to be never register.
In probe, we register regulator from 0 to max_id.
Here smps10-out1 comes first and see the supply as smps10-out2 which is not registered yet and so will fail with PROBE_DEFER
When again it tries, the same issue.

Quoted 3 lines

hmm.. But I was able to get (regulator_get) *SMPS10_OUT1* without any issue during my testing. From looking at the code, I couldn't see *sname* being used anywhere.

Quoted 8 lines

We used the sname as
pmic->desc[id].supply_name = palmas_regs_info[id].sname;

However, how you have populated your dt?
Have you added like
smps10-out2-supply = <&SMPS10_OUT2>

for the palmas regualtor -dt.

I added the regulator data like

(quoted diff) +14 -0
+                       smps10_out1_reg: smps10_out1 {
+                               regulator-name = "smps10_out1";
+                               regulator-min-microvolt = <5000000>;
+                               regulator-max-microvolt = <5000000>;
+                               regulator-always-on;
+                               regulator-boot-on;
+                               regulator-allow-bypass;
+                               ti,warm_sleep = <0>;
+                               ti,roof_floor = <0>;
+                               ti,mode_sleep = <0>;
+                               ti,warm_reset = <0>;
+                               ti,tstep = <0>;
+                               ti,vsel = <0>;
+                       };
Quoted 5 lines

and from my controller I reference it using
+ vbus-supply = <&smps10_out1_reg>;

and in the controller driver I use
+ vbus_reg = devm_regulator_get(dev, "vbus");

Have you added the regulator supply entries?
Are you testing on mainline linux-next?

I have DT entry as:

                palmas: tps65913@58 {
                        compatible = "ti,palmas";
                        reg = <0x58>;
                        interrupts = <0 86 0x4>;

                :::::::::::::::;
                        palmas_pmic {
                            compatible = "ti,palmas-pmic";
                            smps1-in-supply = <&tps65090_dcdc3_reg>;
                            smps3-in-supply = <&tps65090_dcdc3_reg>;
                            smps4-in-supply = <&tps65090_dcdc2_reg>;

:::::::::;

			smps10-out2-supply = <&SMPS10_OUT2>

:::::::::::::;
}

And it fails.

#9 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

Hi,

Quoted 75 lines · Laxman Dewangan
Quoted 74 lines · Kishon Vijay Abraham I

Hi,

Quoted 46 lines · Laxman Dewangan
Quoted 42 lines · Kishon Vijay Abraham I

Hi,

Quoted 31 lines · Laxman Dewangan
Quoted 30 lines · Kishon Vijay Abraham I

SMPS10 has two outputs OUT1 and OUT2 and have one input IN1. SMPS10-OUT2 is connected to SMPS10-IN1 and can be configured either in BOOST mode or BYPASS mode. regulator_enable of SMPS10-OUT2 configures it in BOOST mode. For BYPASS mode regulator_allow_bypass() API can be used. SMPS10-OUT1 is connected to SMPS10-OUT2 and can be enabled using regulator_enable().

---
    drivers/regulator/palmas-regulator.c |   39
++++++++++++++++++++++++++++++----
    include/linux/mfd/palmas.h           |    9 ++++----
    2 files changed, 40 insertions(+), 8 deletions(-)
drivers/regulator/palmas-regulator.c +5 -1
index 3ae44ac..7004bab 100644
@@ -97,7 +97,12 @@ static const struct regs_info palmas_regs_info[] = {
            .ctrl_addr    = PALMAS_SMPS9_CTRL,
        },
        {
-        .name        = "SMPS10",
+        .name        = "SMPS10_OUT1",
+        .sname        = "smps10-out2",
+        .ctrl_addr    = PALMAS_SMPS10_CTRL,
+    },
+    {
Quoted 8 lines

drivers/regulator/palmas-regulator.c static const struct regs_info palmas_regs_info[] = {

Quoted 3 lines
drivers/regulator/palmas-regulator.c +1 -0
+        .name        = "SMPS10_OUT2",
            .sname        = "smps10-in",
 

This sequence can create regulator to be never register.
In probe, we register regulator from 0 to max_id.
Here smps10-out1 comes first and see the supply as smps10-out2 which is not registered yet and so will fail with PROBE_DEFER
When again it tries, the same issue.

Quoted 3 lines

hmm.. But I was able to get (regulator_get) *SMPS10_OUT1* without any issue during my testing. From looking at the code, I couldn't see *sname* being used anywhere.

Quoted 8 lines

We used the sname as
pmic->desc[id].supply_name = palmas_regs_info[id].sname;

However, how you have populated your dt?
Have you added like
smps10-out2-supply = <&SMPS10_OUT2>

for the palmas regualtor -dt.

I added the regulator data like

(quoted diff) +14 -0
+                       smps10_out1_reg: smps10_out1 {
+                               regulator-name = "smps10_out1";
+                               regulator-min-microvolt = <5000000>;
+                               regulator-max-microvolt = <5000000>;
+                               regulator-always-on;
+                               regulator-boot-on;
+                               regulator-allow-bypass;
+                               ti,warm_sleep = <0>;
+                               ti,roof_floor = <0>;
+                               ti,mode_sleep = <0>;
+                               ti,warm_reset = <0>;
+                               ti,tstep = <0>;
+                               ti,vsel = <0>;
+                       };
Quoted 8 lines
Quoted 5 lines

and from my controller I reference it using
+ vbus-supply = <&smps10_out1_reg>;

and in the controller driver I use
+ vbus_reg = devm_regulator_get(dev, "vbus");

Have you added the regulator supply entries?
Are you testing on mainline linux-next?

Not in linux-next :-( Tested only with mainline.
Does inverting the order helps?

Thanks
Kishon

#10 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

Quoted 9 lines · Kishon Vijay Abraham I

Hi,

Quoted 3 lines · Laxman Dewangan

Have you added the regulator supply entries?
Are you testing on mainline linux-next?

Not in linux-next :-( Tested only with mainline.
Does inverting the order helps?

I think because you do not have entry of supply in your dt node, it gets ignored by regulator_dev_lookup() and continue.

I made the entry like (added entry form smps10-out2-supply and smps10-in-supply in dt node) and then it failed. /***

+ smps10-out2-supply = <&palmas_smps10_out2_reg>;

+                           smps10-in-supply = <&tps65090_dcdc3_reg>;
                            ldo3-in-supply = <&palmas_smps3_reg>;
@@ -903,6 +905,20 @@
                                        regulator-always-on;
                                };

+ palmas_smps10_out1_reg: smps10_out1 {

+                                       regulator-name = "smps10_out1";
+                                       regulator-min-microvolt = <5000000>;
+                                       regulator-max-microvolt = <5000000>;
+                                       regulator-always-on;
+                               };
+
+                               palmas_smps10_out2_reg: smps10_out2 {
+                                       regulator-name = "smps10_out2";
+                                       regulator-min-microvolt = <5000000>;
+                                       regulator-max-microvolt = <5000000>;
+                                       regulator-always-on;

+ };
+
**/

After reversing the sequence, it worked fine.

#11 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

Quoted 42 lines · Laxman Dewangan
Quoted 9 lines · Kishon Vijay Abraham I

Hi,

Quoted 3 lines · Laxman Dewangan

Have you added the regulator supply entries?
Are you testing on mainline linux-next?

Not in linux-next :-( Tested only with mainline.
Does inverting the order helps?

I think because you do not have entry of supply in your dt node, it gets ignored by regulator_dev_lookup() and continue.

I made the entry like (added entry form smps10-out2-supply and smps10-in-supply in dt node) and then it failed.
/***

(quoted diff) +16 -0
+                           smps10-out2-supply = <&palmas_smps10_out2_reg>;
+                           smps10-in-supply = <&tps65090_dcdc3_reg>;
                             ldo3-in-supply = <&palmas_smps3_reg>;
@@ -903,6 +905,20 @@
                                         regulator-always-on;
                                 };
 
+                               palmas_smps10_out1_reg: smps10_out1 {
+                                       regulator-name = "smps10_out1";
+                                       regulator-min-microvolt = <5000000>;
+                                       regulator-max-microvolt = <5000000>;
+                                       regulator-always-on;
+                               };
+
+                               palmas_smps10_out2_reg: smps10_out2 {
+                                       regulator-name = "smps10_out2";
+                                       regulator-min-microvolt = <5000000>;
+                                       regulator-max-microvolt = <5000000>;
+                                       regulator-always-on;
+                               };
+
 **/
 
 
Quoted 1 line

After reversing the sequence, it worked fine.

You mean, changing the order in dt node helped?

Thanks
Kishon

#12 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

Quoted 41 lines · Kishon Vijay Abraham I
Quoted 40 lines · Laxman Dewangan
Quoted 8 lines · Kishon Vijay Abraham I

Hi,

Quoted 2 lines · Laxman Dewangan

Have you added the regulator supply entries?
Are you testing on mainline linux-next?

Not in linux-next :-( Tested only with mainline.
Does inverting the order helps?

I think because you do not have entry of supply in your dt node, it gets ignored by regulator_dev_lookup() and continue.

I made the entry like (added entry form smps10-out2-supply and smps10-in-supply in dt node) and then it failed.
/***

(quoted diff) +16 -0
+                           smps10-out2-supply = <&palmas_smps10_out2_reg>;
+                           smps10-in-supply = <&tps65090_dcdc3_reg>;
                              ldo3-in-supply = <&palmas_smps3_reg>;
@@ -903,6 +905,20 @@
                                          regulator-always-on;
                                  };
 
+                               palmas_smps10_out1_reg: smps10_out1 {
+                                       regulator-name = "smps10_out1";
+                                       regulator-min-microvolt = <5000000>;
+                                       regulator-max-microvolt = <5000000>;
+                                       regulator-always-on;
+                               };
+
+                               palmas_smps10_out2_reg: smps10_out2 {
+                                       regulator-name = "smps10_out2";
+                                       regulator-min-microvolt = <5000000>;
+                                       regulator-max-microvolt = <5000000>;
+                                       regulator-always-on;
+                               };
+
 **/
 
 
Quoted 2 lines
Quoted 1 line

After reversing the sequence, it worked fine.

You mean, changing the order in dt node helped?

The sequence on DT does not matter. We register the regulators in the sequence it is having enums value for regulator-id in loop. So we need to revert there.

Yaah, it looks odd that SMPS10-OUT2come before SMPS10-OUT1 in enums definition.

#13 lore raw

Re: [PATCH 2/2] regulator: palmas: model SMPS10 as two regulators

Hi,

Quoted 42 lines · Laxman Dewangan
Quoted 41 lines · Kishon Vijay Abraham I
Quoted 40 lines · Laxman Dewangan
Quoted 8 lines · Kishon Vijay Abraham I

Hi,

Quoted 2 lines · Laxman Dewangan

Have you added the regulator supply entries?
Are you testing on mainline linux-next?

Not in linux-next :-( Tested only with mainline.
Does inverting the order helps?

I think because you do not have entry of supply in your dt node, it gets ignored by regulator_dev_lookup() and continue.

I made the entry like (added entry form smps10-out2-supply and smps10-in-supply in dt node) and then it failed.
/***

(quoted diff) +16 -0
+                           smps10-out2-supply = <&palmas_smps10_out2_reg>;
+                           smps10-in-supply = <&tps65090_dcdc3_reg>;
                              ldo3-in-supply = <&palmas_smps3_reg>;
@@ -903,6 +905,20 @@
                                          regulator-always-on;
                                  };
 
+                               palmas_smps10_out1_reg: smps10_out1 {
+                                       regulator-name = "smps10_out1";
+                                       regulator-min-microvolt = <5000000>;
+                                       regulator-max-microvolt = <5000000>;
+                                       regulator-always-on;
+                               };
+
+                               palmas_smps10_out2_reg: smps10_out2 {
+                                       regulator-name = "smps10_out2";
+                                       regulator-min-microvolt = <5000000>;
+                                       regulator-max-microvolt = <5000000>;
+                                       regulator-always-on;
+                               };
+
 **/
 
 
Quoted 7 lines
Quoted 2 lines
Quoted 1 line

After reversing the sequence, it worked fine.

You mean, changing the order in dt node helped?

The sequence on DT does not matter. We register the regulators in the sequence it is having enums value for regulator-id in loop. So we need to revert there.

Yaah, it looks odd that SMPS10-OUT2come before SMPS10-OUT1 in enums definition.

Will fix that and send a patch.

Thanks
Kishon