Skip to contentSkip to conversation

regulator: max8973: cleanups and add DT parsing for platform data

PATCH Applied Laxman Dewangan 2 participants 13 messages Apr 20, 2015 – May 6, 2015

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

cover regulator: max8973: cleanups and add DT parsing for platform data

Remove redundant variables for dvs gpio validity, handle unset/default dvs gpio and add DT parsing for platform data.

Laxman Dewangan (3):
regulator: max8973: get rid of extra variable for gpio validity
regulator: max8973: make default/unset dvs gpio as invalid gpio
regulator: max8973: add DT parsing of platform specific parameter

 .../bindings/regulator/max8973-regulator.txt       | 14 ++++
 drivers/regulator/max8973-regulator.c              | 93 ++++++++++++++++------
 2 files changed, 81 insertions(+), 26 deletions(-)
Signature · 6 lines
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 1/3 regulator: max8973: get rid of extra variable for gpio validity

To find that dvs-gpio is valid or not, gpio API gpio_is_valid() can be directly used instead of intermediate variable.

Removing the extra variable and using the gpio_is_valid().

---
This is same as earlier patch. Making this as part of this series.

 drivers/regulator/max8973-regulator.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/regulator/max8973-regulator.c +2 -6
index c3d55c2..1890808 100644
@@ -100,7 +100,6 @@ struct max8973_chip {
 	int curr_vout_val[MAX8973_MAX_VOUT_REG];
 	int curr_vout_reg;
 	int curr_gpio_val;
-	bool valid_dvs_gpio;
 	struct regulator_ops ops;
 };
 
@@ -174,7 +173,7 @@ static int max8973_dcdc_set_voltage_sel(struct regulator_dev *rdev,
 	 * If gpios are available to select the VOUT register then least
 	 * recently used register for new configuration.
 	 */
-	if (max->valid_dvs_gpio)
+	if (gpio_is_valid(max->dvs_gpio))
 		found = find_voltage_set_register(max, vsel,
 					&vout_reg, &gpio_val);
 
@@ -191,7 +190,7 @@ static int max8973_dcdc_set_voltage_sel(struct regulator_dev *rdev,
 	}
 
 	/* Select proper VOUT register vio gpios */
-	if (max->valid_dvs_gpio) {
+	if (gpio_is_valid(max->dvs_gpio)) {
 		gpio_set_value_cansleep(max->dvs_gpio, gpio_val & 0x1);
 		max->curr_gpio_val = gpio_val;
 	}
@@ -434,7 +433,6 @@ static int max8973_probe(struct i2c_client *client,
 				max->dvs_gpio, ret);
 			return ret;
 		}
-		max->valid_dvs_gpio = true;
 
 		/*
 		 * Initialize the lru index with vout_reg id
@@ -444,8 +442,6 @@ static int max8973_probe(struct i2c_client *client,
 			max->lru_index[i] = i;
 		max->lru_index[0] = max->curr_vout_reg;
 		max->lru_index[max->curr_vout_reg] = 0;
-	} else {
-		max->valid_dvs_gpio = false;
 	}
 
 	if (pdata) {
Signature · 1 line
1.8.1.5
maintainer
#2 lore raw

Re: [PATCH 1/3] regulator: max8973: get rid of extra variable for gpio validity

Quoted 4 lines · Laxman Dewangan

To find that dvs-gpio is valid or not, gpio API gpio_is_valid() can be directly used instead of intermediate variable.

Removing the extra variable and using the gpio_is_valid().

This still looks like it's got the same issue with not doing the right thing with platform data that uses zero as a default which is the point in having a flag like this.

maintainer Applied
#3 lore raw

Re: [PATCH 1/3] regulator: max8973: get rid of extra variable for gpio validity

In reply to Laxman Dewangan
Quoted 2 lines · Laxman Dewangan

To find that dvs-gpio is valid or not, gpio API gpio_is_valid() can be directly used instead of intermediate variable.

Applied, thanks.

#4 lore raw

Re: [PATCH 1/3] regulator: max8973: get rid of extra variable for gpio validity

Quoted 7 lines · Mark Brown

* PGP Signed by an unknown key

Quoted 2 lines · Laxman Dewangan

To find that dvs-gpio is valid or not, gpio API gpio_is_valid() can be directly used instead of intermediate variable.

Applied, thanks.

This patch is not available on linux-next. Is it pending for any clean-up?

maintainer
#5 lore raw

Re: [PATCH 1/3] regulator: max8973: get rid of extra variable for gpio validity

Quoted 1 line · Laxman Dewangan

This patch is not available on linux-next. Is it pending for any clean-up?

Ah, sorry - forgot to follow up on this. The patch doesn't apply against curent code, please check and resend.

#6 lore raw

PATCH 2/3 regulator: max8973: make default/unset dvs gpio as invalid gpio

In reply to Laxman Dewangan

If platform data has dvs-gpio value 0 as default/unset then make this as invalid gpio so that function gpio_is_valid() can return false on this case.

---
As discussed on the patch
[PATCH] regulator: max8973: get rid of extra variable for gpio validity Adding handling of unset/default gpio on platform data which is set as 0.

 drivers/regulator/max8973-regulator.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/regulator/max8973-regulator.c +1 -1
index 1890808..85fa2de 100644
@@ -408,7 +408,7 @@ static int max8973_probe(struct i2c_client *client,
 	}
 
 	if (pdata) {
-		max->dvs_gpio = pdata->dvs_gpio;
+		max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL;
 		max->enable_external_control = pdata->enable_ext_control;
 		max->curr_gpio_val = pdata->dvs_def_state;
 		max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state;
Signature · 6 lines
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#7 lore raw

Re: [PATCH 2/3] regulator: max8973: make default/unset dvs gpio as invalid gpio

Quoted 3 lines · Laxman Dewangan

If platform data has dvs-gpio value 0 as default/unset then make this as invalid gpio so that function gpio_is_valid() can return false on this case.

OK, so this handles the problem with the first patch - it should have been the first patch to help with review.

#8 lore raw

Re: [PATCH 2/3] regulator: max8973: make default/unset dvs gpio as invalid gpio

Quoted 9 lines · Mark Brown

* PGP Signed by an unknown key

Quoted 3 lines · Laxman Dewangan

If platform data has dvs-gpio value 0 as default/unset then make this as invalid gpio so that function gpio_is_valid() can return false on this case.

OK, so this handles the problem with the first patch - it should have been the first patch to help with review.

Yaah, I realized after reading your comment on patch 1 that I should have on different sequence.

Thanks for accepting the patches.

maintainer Applied
#9 lore raw

Re: [PATCH 2/3] regulator: max8973: make default/unset dvs gpio as invalid gpio

In reply to Laxman Dewangan
Quoted 3 lines · Laxman Dewangan

If platform data has dvs-gpio value 0 as default/unset then make this as invalid gpio so that function gpio_is_valid() can return false on this case.

Applied, thanks.

#10 lore raw

PATCH 3/3 regulator: max8973: add DT parsing of platform specific parameter

In reply to Laxman Dewangan

There are some platform specific parameter required to configure the device like enable external control, DVS gpio etc.

Add DT parsing of such properties to make platform specific data.

Update DT binding doc accordingly.

---
 .../bindings/regulator/max8973-regulator.txt       | 14 ++++
 drivers/regulator/max8973-regulator.c              | 85 +++++++++++++++++-----
 2 files changed, 79 insertions(+), 20 deletions(-)
Documentation/devicetree/bindings/regulator/max8973-regulator.txt +14 -0
index 4f15d8a..f63de7d 100644
@@ -8,6 +8,20 @@ Required properties:
 Any standard regulator properties can be used to configure the single max8973
 DCDC.
 
+Optional properties:
+
+-maxim,externally-enable: boolean, externally control the regulator output
+		enable/disable.
+-maxim,dvs-gpio: GPIO which is connected to DVS pin of device.
+-maxim,dvs-default-state: Default state of GPIO during initialisation.
+		1 for HIGH and 0 for LOW.
+-maxim,enable-remote-sense: boolean, enable reote sense.
+-maxim,enable-falling-slew-rate: boolean, enable falling slew rate.
+-maxim,enable-active-discharge: boolean: enable active discharge.
+-maxim,enable-frequency-shift: boolean, enable 9% frequency shift.
+-maxim,enable-bias-control: boolean, enable bias control. By enabling this
+		startup delay can be reduce to 20us from 220us.
+
 Example:
 
 	max8973@1b {
drivers/regulator/max8973-regulator.c +65 -20

132 lines not on this page · raw message

Signature · 1 line
1.8.1.5
maintainer
#11 lore raw

Re: [PATCH 3/3] regulator: max8973: add DT parsing of platform specific parameter

Documentation/devicetree/bindings/regulator/max8973-regulator.txt Required properties: · line 14

Quoted 4 lines · Laxman Dewangan
Documentation/devicetree/bindings/regulator/max8973-regulator.txt +4 -0
+Optional properties:
+
+-maxim,externally-enable: boolean, externally control the regulator output
+		enable/disable.

I'd have expected this to be enabled if a GPIO is provided to do the control rather than having a specific property for it.

Documentation/devicetree/bindings/regulator/max8973-regulator.txt Required properties: · line 23

Quoted 5 lines
+-maxim,enable-falling-slew-rate: boolean, enable falling slew rate.
+-maxim,enable-active-discharge: boolean: enable active discharge.
+-maxim,enable-frequency-shift: boolean, enable 9% frequency shift.
+-maxim,enable-bias-control: boolean, enable bias control. By enabling this
Documentation/devicetree/bindings/regulator/max8973-regulator.txt +1 -0
+		startup delay can be reduce to 20us from 220us.

It looks like we should be implementing the set_ramp_delay() operation here?

#12 lore raw

Re: [PATCH 3/3] regulator: max8973: add DT parsing of platform specific parameter

Quoted 10 lines · Mark Brown

* PGP Signed by an unknown key

Documentation/devicetree/bindings/regulator/max8973-regulator.txt Required properties: · line 14

Quoted 4 lines · Laxman Dewangan
Documentation/devicetree/bindings/regulator/max8973-regulator.txt +4 -0
+Optional properties:
+
+-maxim,externally-enable: boolean, externally control the regulator output
+		enable/disable.

I'd have expected this to be enabled if a GPIO is provided to do the control rather than having a specific property for it.

Curently there is no support for providing a GPIO for external control pins. I have follow on patch to support this as my platform control the EN pin of the device through GPIO.

There is also case that the EN pin is controlled by the control signal from host power management controller directly and this control signal is not exported as GPIO. So we need this option to support on both cases.

There is another device from Maxim, MAX77621, which is compatible on register with this device but it has converted the EN pin as SHTDN pin. I have follow on patches to support this device through this driver instead of duplicating the driver.

MAX8973: Vout is enabled when EN pin OR EN bit on register is 1.
MAX77621: Vout is enabled when EN pin AND EN bit on register is 1. If EN pin (renamed as SHTDN pin) goes low, it reset the entire register configuration.

In our platform, we are using MAX77621 and SHTDN pin of MAX77621 is controlled through GPIO.
On this case, we will use the GPIO as always HIGH and control Vout enable/disable through the register EN bit write otherwise, we will need to restore all configuration on each regulator enable.

So on MAX77621 use, we will provide the GPIO for SHTDN pin to make it enable always and it will not be controlled externally, it will be controlled through register access.

Quoted 9 lines

Documentation/devicetree/bindings/regulator/max8973-regulator.txt Required properties: · line 23

Quoted 6 lines
+-maxim,enable-falling-slew-rate: boolean, enable falling slew rate.
+-maxim,enable-active-discharge: boolean: enable active discharge.
+-maxim,enable-frequency-shift: boolean, enable 9% frequency shift.
+-maxim,enable-bias-control: boolean, enable bias control. By enabling this
Documentation/devicetree/bindings/regulator/max8973-regulator.txt +1 -0
+		startup delay can be reduce to 20us from 220us.

It looks like we should be implementing the set_ramp_delay() operation here?

It is actually enable_time which changes with this bias enable/disable.
So we need to provide desc->enable_time based on this flag. Currently it is missing on driver.

I have few more patches, not sent because did not want to bulk the review and started with small changes which can be discussed easily.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html