linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] regulator: max77620: add support to configure MPOK
@ 2016-11-17 17:54 Venkat Reddy Talla
  2016-11-17 17:54 ` [PATCH v2 2/2] dt-bindings: max77620: add documentation for MPOK property Venkat Reddy Talla
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Venkat Reddy Talla @ 2016-11-17 17:54 UTC (permalink / raw)
  To: lee.jones, lgirdwood, broonie, robh+dt, mark.rutland, devicetree,
	linux-kernel
  Cc: ldewangan, svelpula, vreddytalla

Adding support to configure regulator POK mapping bit
to control nRST_IO and GPIO1 POK function.
In  tegra based platform which uses MAX20024 pmic, when
some of regulators are configured FPS_NONE(flexible power sequencer)
causes PMIC GPIO1 to go low which lead to various other rails turning off,
to avoid this MPOK bit of those regulators need to be set to 0
so that PMIC GPIO1 will not go low.

Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>

---
changes in v2:
- updated commit message for the patch
- address review comments
---
 drivers/regulator/max77620-regulator.c | 46 ++++++++++++++++++++++++++++++++++
 include/linux/mfd/max77620.h           |  2 ++
 2 files changed, 48 insertions(+)

diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c
index a1b49a6..850b14c 100644
--- a/drivers/regulator/max77620-regulator.c
+++ b/drivers/regulator/max77620-regulator.c
@@ -81,6 +81,7 @@ struct max77620_regulator_pdata {
 	int suspend_fps_pd_slot;
 	int suspend_fps_pu_slot;
 	int current_mode;
+	int power_ok;
 	int ramp_rate_setting;
 };
 
@@ -351,11 +352,48 @@ static int max77620_set_slew_rate(struct max77620_regulator *pmic, int id,
 	return 0;
 }
 
+static int max77620_config_power_ok(struct max77620_regulator *pmic, int id)
+{
+	struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
+	struct max77620_regulator_info *rinfo = pmic->rinfo[id];
+	struct max77620_chip *chip = dev_get_drvdata(pmic->dev->parent);
+	u8 val, mask;
+	int ret;
+
+	switch (chip->chip_id) {
+	case MAX20024:
+		if (rpdata->power_ok >= 0) {
+			if (rinfo->type == MAX77620_REGULATOR_TYPE_SD)
+				mask = MAX20024_SD_CFG1_MPOK_MASK;
+			else
+				mask = MAX20024_LDO_CFG2_MPOK_MASK;
+
+			val = rpdata->power_ok ? mask : 0;
+
+			ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr,
+						 mask, val);
+			if (ret < 0) {
+				dev_err(pmic->dev, "Reg 0x%02x update failed %d\n",
+					rinfo->cfg_addr, ret);
+				return ret;
+			}
+		}
+		break;
+
+	default:
+		break;
+	}
+
+	return 0;
+}
+
 static int max77620_init_pmic(struct max77620_regulator *pmic, int id)
 {
 	struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
 	int ret;
 
+	max77620_config_power_ok(pmic, id);
+
 	/* Update power mode */
 	ret = max77620_regulator_get_power_mode(pmic, id);
 	if (ret < 0)
@@ -595,6 +633,12 @@ static int max77620_of_parse_cb(struct device_node *np,
 			np, "maxim,suspend-fps-power-down-slot", &pval);
 	rpdata->suspend_fps_pd_slot = (!ret) ? pval : -1;
 
+	ret = of_property_read_u32(np, "maxim,power-ok-control", &pval);
+	if (!ret)
+		rpdata->power_ok = pval;
+	else
+		rpdata->power_ok = -1;
+
 	ret = of_property_read_u32(np, "maxim,ramp-rate-setting", &pval);
 	rpdata->ramp_rate_setting = (!ret) ? pval : 0;
 
@@ -807,6 +851,8 @@ static int max77620_regulator_resume(struct device *dev)
 	for (id = 0; id < MAX77620_NUM_REGS; id++) {
 		reg_pdata = &pmic->reg_pdata[id];
 
+		max77620_config_power_ok(pmic, id);
+
 		max77620_regulator_set_fps_slots(pmic, id, false);
 		if (reg_pdata->active_fps_src < 0)
 			continue;
diff --git a/include/linux/mfd/max77620.h b/include/linux/mfd/max77620.h
index 3ca0af07..ad2a9a8 100644
--- a/include/linux/mfd/max77620.h
+++ b/include/linux/mfd/max77620.h
@@ -180,6 +180,7 @@
 #define MAX77620_SD_CFG1_FPWM_SD_MASK		BIT(2)
 #define MAX77620_SD_CFG1_FPWM_SD_SKIP		0
 #define MAX77620_SD_CFG1_FPWM_SD_FPWM		BIT(2)
+#define MAX20024_SD_CFG1_MPOK_MASK		BIT(1)
 #define MAX77620_SD_CFG1_FSRADE_SD_MASK		BIT(0)
 #define MAX77620_SD_CFG1_FSRADE_SD_DISABLE	0
 #define MAX77620_SD_CFG1_FSRADE_SD_ENABLE	BIT(0)
@@ -187,6 +188,7 @@
 /* LDO_CNFG2 */
 #define MAX77620_LDO_POWER_MODE_MASK		0xC0
 #define MAX77620_LDO_POWER_MODE_SHIFT		6
+#define MAX20024_LDO_CFG2_MPOK_MASK		BIT(2)
 #define MAX77620_LDO_CFG2_ADE_MASK		BIT(1)
 #define MAX77620_LDO_CFG2_ADE_DISABLE		0
 #define MAX77620_LDO_CFG2_ADE_ENABLE		BIT(1)
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] dt-bindings: max77620: add documentation for MPOK property
  2016-11-17 17:54 [PATCH v2 1/2] regulator: max77620: add support to configure MPOK Venkat Reddy Talla
@ 2016-11-17 17:54 ` Venkat Reddy Talla
  2016-11-18 14:54   ` Rob Herring
  2016-11-21 13:10   ` Lee Jones
  2016-11-21 13:09 ` [PATCH v2 1/2] regulator: max77620: add support to configure MPOK Lee Jones
  2016-11-23 16:31 ` Applied "regulator: max77620: add support to configure MPOK" to the regulator tree Mark Brown
  2 siblings, 2 replies; 8+ messages in thread
From: Venkat Reddy Talla @ 2016-11-17 17:54 UTC (permalink / raw)
  To: lee.jones, lgirdwood, broonie, robh+dt, mark.rutland, devicetree,
	linux-kernel
  Cc: ldewangan, svelpula, vreddytalla

Adding documentation for maxim,power-ok-control dts property

Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>

---
Changes from V1:
 None
---
 Documentation/devicetree/bindings/mfd/max77620.txt | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/mfd/max77620.txt b/Documentation/devicetree/bindings/mfd/max77620.txt
index 2ad44f7..9c16d51 100644
--- a/Documentation/devicetree/bindings/mfd/max77620.txt
+++ b/Documentation/devicetree/bindings/mfd/max77620.txt
@@ -106,6 +106,18 @@ Here supported time periods by device in microseconds are as follows:
 MAX77620 supports 40, 80, 160, 320, 640, 1280, 2560 and 5120 microseconds.
 MAX20024 supports 20, 40, 80, 160, 320, 640, 1280 and 2540 microseconds.
 
+-maxim,power-ok-control: configure map power ok bit
+			1: Enables POK(Power OK) to control nRST_IO and GPIO1
+			POK function.
+			0: Disables POK control.
+			if property missing, do not configure MPOK bit.
+			If POK mapping is enabled for GPIO1/nRST_IO then,
+			GPIO1/nRST_IO pins are HIGH only if all rails
+			that have POK control enabled are HIGH.
+			If any of the rails goes down(which are enabled for POK
+			control) then, GPIO1/nRST_IO goes LOW.
+			this property is valid for max20024 only.
+
 For DT binding details of different sub modules like GPIO, pincontrol,
 regulator, power, please refer respective device-tree binding document
 under their respective sub-system directories.
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] dt-bindings: max77620: add documentation for MPOK property
  2016-11-17 17:54 ` [PATCH v2 2/2] dt-bindings: max77620: add documentation for MPOK property Venkat Reddy Talla
@ 2016-11-18 14:54   ` Rob Herring
  2016-11-21 13:10   ` Lee Jones
  1 sibling, 0 replies; 8+ messages in thread
From: Rob Herring @ 2016-11-18 14:54 UTC (permalink / raw)
  To: Venkat Reddy Talla
  Cc: lee.jones, lgirdwood, broonie, mark.rutland, devicetree,
	linux-kernel, ldewangan, svelpula

On Thu, Nov 17, 2016 at 11:24:36PM +0530, Venkat Reddy Talla wrote:
> Adding documentation for maxim,power-ok-control dts property
> 
> Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
> 
> ---
> Changes from V1:
>  None
> ---
>  Documentation/devicetree/bindings/mfd/max77620.txt | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] regulator: max77620: add support to configure MPOK
  2016-11-17 17:54 [PATCH v2 1/2] regulator: max77620: add support to configure MPOK Venkat Reddy Talla
  2016-11-17 17:54 ` [PATCH v2 2/2] dt-bindings: max77620: add documentation for MPOK property Venkat Reddy Talla
@ 2016-11-21 13:09 ` Lee Jones
  2016-11-21 13:11   ` Lee Jones
  2016-11-23 16:31 ` Applied "regulator: max77620: add support to configure MPOK" to the regulator tree Mark Brown
  2 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2016-11-21 13:09 UTC (permalink / raw)
  To: Venkat Reddy Talla
  Cc: lgirdwood, broonie, robh+dt, mark.rutland, devicetree,
	linux-kernel, ldewangan, svelpula

On Thu, 17 Nov 2016, Venkat Reddy Talla wrote:

> Adding support to configure regulator POK mapping bit
> to control nRST_IO and GPIO1 POK function.
> In  tegra based platform which uses MAX20024 pmic, when
> some of regulators are configured FPS_NONE(flexible power sequencer)
> causes PMIC GPIO1 to go low which lead to various other rails turning off,
> to avoid this MPOK bit of those regulators need to be set to 0
> so that PMIC GPIO1 will not go low.
> 
> Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
> 
> ---
> changes in v2:
> - updated commit message for the patch
> - address review comments
> ---
>  drivers/regulator/max77620-regulator.c | 46 ++++++++++++++++++++++++++++++++++
>  include/linux/mfd/max77620.h           |  2 ++

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

>  2 files changed, 48 insertions(+)
> 
> diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c
> index a1b49a6..850b14c 100644
> --- a/drivers/regulator/max77620-regulator.c
> +++ b/drivers/regulator/max77620-regulator.c
> @@ -81,6 +81,7 @@ struct max77620_regulator_pdata {
>  	int suspend_fps_pd_slot;
>  	int suspend_fps_pu_slot;
>  	int current_mode;
> +	int power_ok;
>  	int ramp_rate_setting;
>  };
>  
> @@ -351,11 +352,48 @@ static int max77620_set_slew_rate(struct max77620_regulator *pmic, int id,
>  	return 0;
>  }
>  
> +static int max77620_config_power_ok(struct max77620_regulator *pmic, int id)
> +{
> +	struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
> +	struct max77620_regulator_info *rinfo = pmic->rinfo[id];
> +	struct max77620_chip *chip = dev_get_drvdata(pmic->dev->parent);
> +	u8 val, mask;
> +	int ret;
> +
> +	switch (chip->chip_id) {
> +	case MAX20024:
> +		if (rpdata->power_ok >= 0) {
> +			if (rinfo->type == MAX77620_REGULATOR_TYPE_SD)
> +				mask = MAX20024_SD_CFG1_MPOK_MASK;
> +			else
> +				mask = MAX20024_LDO_CFG2_MPOK_MASK;
> +
> +			val = rpdata->power_ok ? mask : 0;
> +
> +			ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr,
> +						 mask, val);
> +			if (ret < 0) {
> +				dev_err(pmic->dev, "Reg 0x%02x update failed %d\n",
> +					rinfo->cfg_addr, ret);
> +				return ret;
> +			}
> +		}
> +		break;
> +
> +	default:
> +		break;
> +	}
> +
> +	return 0;
> +}
> +
>  static int max77620_init_pmic(struct max77620_regulator *pmic, int id)
>  {
>  	struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
>  	int ret;
>  
> +	max77620_config_power_ok(pmic, id);
> +
>  	/* Update power mode */
>  	ret = max77620_regulator_get_power_mode(pmic, id);
>  	if (ret < 0)
> @@ -595,6 +633,12 @@ static int max77620_of_parse_cb(struct device_node *np,
>  			np, "maxim,suspend-fps-power-down-slot", &pval);
>  	rpdata->suspend_fps_pd_slot = (!ret) ? pval : -1;
>  
> +	ret = of_property_read_u32(np, "maxim,power-ok-control", &pval);
> +	if (!ret)
> +		rpdata->power_ok = pval;
> +	else
> +		rpdata->power_ok = -1;
> +
>  	ret = of_property_read_u32(np, "maxim,ramp-rate-setting", &pval);
>  	rpdata->ramp_rate_setting = (!ret) ? pval : 0;
>  
> @@ -807,6 +851,8 @@ static int max77620_regulator_resume(struct device *dev)
>  	for (id = 0; id < MAX77620_NUM_REGS; id++) {
>  		reg_pdata = &pmic->reg_pdata[id];
>  
> +		max77620_config_power_ok(pmic, id);
> +
>  		max77620_regulator_set_fps_slots(pmic, id, false);
>  		if (reg_pdata->active_fps_src < 0)
>  			continue;
> diff --git a/include/linux/mfd/max77620.h b/include/linux/mfd/max77620.h
> index 3ca0af07..ad2a9a8 100644
> --- a/include/linux/mfd/max77620.h
> +++ b/include/linux/mfd/max77620.h
> @@ -180,6 +180,7 @@
>  #define MAX77620_SD_CFG1_FPWM_SD_MASK		BIT(2)
>  #define MAX77620_SD_CFG1_FPWM_SD_SKIP		0
>  #define MAX77620_SD_CFG1_FPWM_SD_FPWM		BIT(2)
> +#define MAX20024_SD_CFG1_MPOK_MASK		BIT(1)
>  #define MAX77620_SD_CFG1_FSRADE_SD_MASK		BIT(0)
>  #define MAX77620_SD_CFG1_FSRADE_SD_DISABLE	0
>  #define MAX77620_SD_CFG1_FSRADE_SD_ENABLE	BIT(0)
> @@ -187,6 +188,7 @@
>  /* LDO_CNFG2 */
>  #define MAX77620_LDO_POWER_MODE_MASK		0xC0
>  #define MAX77620_LDO_POWER_MODE_SHIFT		6
> +#define MAX20024_LDO_CFG2_MPOK_MASK		BIT(2)
>  #define MAX77620_LDO_CFG2_ADE_MASK		BIT(1)
>  #define MAX77620_LDO_CFG2_ADE_DISABLE		0
>  #define MAX77620_LDO_CFG2_ADE_ENABLE		BIT(1)

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] dt-bindings: max77620: add documentation for MPOK property
  2016-11-17 17:54 ` [PATCH v2 2/2] dt-bindings: max77620: add documentation for MPOK property Venkat Reddy Talla
  2016-11-18 14:54   ` Rob Herring
@ 2016-11-21 13:10   ` Lee Jones
  1 sibling, 0 replies; 8+ messages in thread
From: Lee Jones @ 2016-11-21 13:10 UTC (permalink / raw)
  To: Venkat Reddy Talla
  Cc: lgirdwood, broonie, robh+dt, mark.rutland, devicetree,
	linux-kernel, ldewangan, svelpula

On Thu, 17 Nov 2016, Venkat Reddy Talla wrote:

> Adding documentation for maxim,power-ok-control dts property
> 
> Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
> 
> ---
> Changes from V1:
>  None
> ---
>  Documentation/devicetree/bindings/mfd/max77620.txt | 12 ++++++++++++
>  1 file changed, 12 insertions(+)

For my own reference:
  Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
  
> diff --git a/Documentation/devicetree/bindings/mfd/max77620.txt b/Documentation/devicetree/bindings/mfd/max77620.txt
> index 2ad44f7..9c16d51 100644
> --- a/Documentation/devicetree/bindings/mfd/max77620.txt
> +++ b/Documentation/devicetree/bindings/mfd/max77620.txt
> @@ -106,6 +106,18 @@ Here supported time periods by device in microseconds are as follows:
>  MAX77620 supports 40, 80, 160, 320, 640, 1280, 2560 and 5120 microseconds.
>  MAX20024 supports 20, 40, 80, 160, 320, 640, 1280 and 2540 microseconds.
>  
> +-maxim,power-ok-control: configure map power ok bit
> +			1: Enables POK(Power OK) to control nRST_IO and GPIO1
> +			POK function.
> +			0: Disables POK control.
> +			if property missing, do not configure MPOK bit.
> +			If POK mapping is enabled for GPIO1/nRST_IO then,
> +			GPIO1/nRST_IO pins are HIGH only if all rails
> +			that have POK control enabled are HIGH.
> +			If any of the rails goes down(which are enabled for POK
> +			control) then, GPIO1/nRST_IO goes LOW.
> +			this property is valid for max20024 only.
> +
>  For DT binding details of different sub modules like GPIO, pincontrol,
>  regulator, power, please refer respective device-tree binding document
>  under their respective sub-system directories.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] regulator: max77620: add support to configure MPOK
  2016-11-21 13:09 ` [PATCH v2 1/2] regulator: max77620: add support to configure MPOK Lee Jones
@ 2016-11-21 13:11   ` Lee Jones
  2016-11-23 16:40     ` Mark Brown
  0 siblings, 1 reply; 8+ messages in thread
From: Lee Jones @ 2016-11-21 13:11 UTC (permalink / raw)
  To: Venkat Reddy Talla
  Cc: lgirdwood, broonie, robh+dt, mark.rutland, devicetree,
	linux-kernel, ldewangan, svelpula

On Mon, 21 Nov 2016, Lee Jones wrote:

> On Thu, 17 Nov 2016, Venkat Reddy Talla wrote:
> 
> > Adding support to configure regulator POK mapping bit
> > to control nRST_IO and GPIO1 POK function.
> > In  tegra based platform which uses MAX20024 pmic, when
> > some of regulators are configured FPS_NONE(flexible power sequencer)
> > causes PMIC GPIO1 to go low which lead to various other rails turning off,
> > to avoid this MPOK bit of those regulators need to be set to 0
> > so that PMIC GPIO1 will not go low.
> > 
> > Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
> > 
> > ---
> > changes in v2:
> > - updated commit message for the patch
> > - address review comments
> > ---
> >  drivers/regulator/max77620-regulator.c | 46 ++++++++++++++++++++++++++++++++++
> >  include/linux/mfd/max77620.h           |  2 ++
> 
> For my own reference:
>   Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>

Mark if you want to take this patch, feel free.

> >  2 files changed, 48 insertions(+)
> > 
> > diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c
> > index a1b49a6..850b14c 100644
> > --- a/drivers/regulator/max77620-regulator.c
> > +++ b/drivers/regulator/max77620-regulator.c
> > @@ -81,6 +81,7 @@ struct max77620_regulator_pdata {
> >  	int suspend_fps_pd_slot;
> >  	int suspend_fps_pu_slot;
> >  	int current_mode;
> > +	int power_ok;
> >  	int ramp_rate_setting;
> >  };
> >  
> > @@ -351,11 +352,48 @@ static int max77620_set_slew_rate(struct max77620_regulator *pmic, int id,
> >  	return 0;
> >  }
> >  
> > +static int max77620_config_power_ok(struct max77620_regulator *pmic, int id)
> > +{
> > +	struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
> > +	struct max77620_regulator_info *rinfo = pmic->rinfo[id];
> > +	struct max77620_chip *chip = dev_get_drvdata(pmic->dev->parent);
> > +	u8 val, mask;
> > +	int ret;
> > +
> > +	switch (chip->chip_id) {
> > +	case MAX20024:
> > +		if (rpdata->power_ok >= 0) {
> > +			if (rinfo->type == MAX77620_REGULATOR_TYPE_SD)
> > +				mask = MAX20024_SD_CFG1_MPOK_MASK;
> > +			else
> > +				mask = MAX20024_LDO_CFG2_MPOK_MASK;
> > +
> > +			val = rpdata->power_ok ? mask : 0;
> > +
> > +			ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr,
> > +						 mask, val);
> > +			if (ret < 0) {
> > +				dev_err(pmic->dev, "Reg 0x%02x update failed %d\n",
> > +					rinfo->cfg_addr, ret);
> > +				return ret;
> > +			}
> > +		}
> > +		break;
> > +
> > +	default:
> > +		break;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  static int max77620_init_pmic(struct max77620_regulator *pmic, int id)
> >  {
> >  	struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
> >  	int ret;
> >  
> > +	max77620_config_power_ok(pmic, id);
> > +
> >  	/* Update power mode */
> >  	ret = max77620_regulator_get_power_mode(pmic, id);
> >  	if (ret < 0)
> > @@ -595,6 +633,12 @@ static int max77620_of_parse_cb(struct device_node *np,
> >  			np, "maxim,suspend-fps-power-down-slot", &pval);
> >  	rpdata->suspend_fps_pd_slot = (!ret) ? pval : -1;
> >  
> > +	ret = of_property_read_u32(np, "maxim,power-ok-control", &pval);
> > +	if (!ret)
> > +		rpdata->power_ok = pval;
> > +	else
> > +		rpdata->power_ok = -1;
> > +
> >  	ret = of_property_read_u32(np, "maxim,ramp-rate-setting", &pval);
> >  	rpdata->ramp_rate_setting = (!ret) ? pval : 0;
> >  
> > @@ -807,6 +851,8 @@ static int max77620_regulator_resume(struct device *dev)
> >  	for (id = 0; id < MAX77620_NUM_REGS; id++) {
> >  		reg_pdata = &pmic->reg_pdata[id];
> >  
> > +		max77620_config_power_ok(pmic, id);
> > +
> >  		max77620_regulator_set_fps_slots(pmic, id, false);
> >  		if (reg_pdata->active_fps_src < 0)
> >  			continue;
> > diff --git a/include/linux/mfd/max77620.h b/include/linux/mfd/max77620.h
> > index 3ca0af07..ad2a9a8 100644
> > --- a/include/linux/mfd/max77620.h
> > +++ b/include/linux/mfd/max77620.h
> > @@ -180,6 +180,7 @@
> >  #define MAX77620_SD_CFG1_FPWM_SD_MASK		BIT(2)
> >  #define MAX77620_SD_CFG1_FPWM_SD_SKIP		0
> >  #define MAX77620_SD_CFG1_FPWM_SD_FPWM		BIT(2)
> > +#define MAX20024_SD_CFG1_MPOK_MASK		BIT(1)
> >  #define MAX77620_SD_CFG1_FSRADE_SD_MASK		BIT(0)
> >  #define MAX77620_SD_CFG1_FSRADE_SD_DISABLE	0
> >  #define MAX77620_SD_CFG1_FSRADE_SD_ENABLE	BIT(0)
> > @@ -187,6 +188,7 @@
> >  /* LDO_CNFG2 */
> >  #define MAX77620_LDO_POWER_MODE_MASK		0xC0
> >  #define MAX77620_LDO_POWER_MODE_SHIFT		6
> > +#define MAX20024_LDO_CFG2_MPOK_MASK		BIT(2)
> >  #define MAX77620_LDO_CFG2_ADE_MASK		BIT(1)
> >  #define MAX77620_LDO_CFG2_ADE_DISABLE		0
> >  #define MAX77620_LDO_CFG2_ADE_ENABLE		BIT(1)
> 

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Applied "regulator: max77620: add support to configure MPOK" to the regulator tree
  2016-11-17 17:54 [PATCH v2 1/2] regulator: max77620: add support to configure MPOK Venkat Reddy Talla
  2016-11-17 17:54 ` [PATCH v2 2/2] dt-bindings: max77620: add documentation for MPOK property Venkat Reddy Talla
  2016-11-21 13:09 ` [PATCH v2 1/2] regulator: max77620: add support to configure MPOK Lee Jones
@ 2016-11-23 16:31 ` Mark Brown
  2 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2016-11-23 16:31 UTC (permalink / raw)
  To: Venkat Reddy Talla
  Cc: Lee Jones, Mark Brown, lee.jones, lgirdwood, broonie, robh+dt,
	mark.rutland, devicetree, linux-kernel, ldewangan, svelpula,
	vreddytalla

The patch

   regulator: max77620: add support to configure MPOK

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 383d0fca7035a12f1201277d33e8fc87c9d60c9a Mon Sep 17 00:00:00 2001
From: Venkat Reddy Talla <vreddytalla@nvidia.com>
Date: Thu, 17 Nov 2016 23:24:35 +0530
Subject: [PATCH] regulator: max77620: add support to configure MPOK

Adding support to configure regulator POK mapping bit
to control nRST_IO and GPIO1 POK function.
In  tegra based platform which uses MAX20024 pmic, when
some of regulators are configured FPS_NONE(flexible power sequencer)
causes PMIC GPIO1 to go low which lead to various other rails turning off,
to avoid this MPOK bit of those regulators need to be set to 0
so that PMIC GPIO1 will not go low.

Signed-off-by: Venkat Reddy Talla <vreddytalla@nvidia.com>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/regulator/max77620-regulator.c | 46 ++++++++++++++++++++++++++++++++++
 include/linux/mfd/max77620.h           |  2 ++
 2 files changed, 48 insertions(+)

diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c
index c39a56b41901..d088a7c79e60 100644
--- a/drivers/regulator/max77620-regulator.c
+++ b/drivers/regulator/max77620-regulator.c
@@ -80,6 +80,7 @@ struct max77620_regulator_pdata {
 	int suspend_fps_pd_slot;
 	int suspend_fps_pu_slot;
 	int current_mode;
+	int power_ok;
 	int ramp_rate_setting;
 };
 
@@ -350,11 +351,48 @@ static int max77620_set_slew_rate(struct max77620_regulator *pmic, int id,
 	return 0;
 }
 
+static int max77620_config_power_ok(struct max77620_regulator *pmic, int id)
+{
+	struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
+	struct max77620_regulator_info *rinfo = pmic->rinfo[id];
+	struct max77620_chip *chip = dev_get_drvdata(pmic->dev->parent);
+	u8 val, mask;
+	int ret;
+
+	switch (chip->chip_id) {
+	case MAX20024:
+		if (rpdata->power_ok >= 0) {
+			if (rinfo->type == MAX77620_REGULATOR_TYPE_SD)
+				mask = MAX20024_SD_CFG1_MPOK_MASK;
+			else
+				mask = MAX20024_LDO_CFG2_MPOK_MASK;
+
+			val = rpdata->power_ok ? mask : 0;
+
+			ret = regmap_update_bits(pmic->rmap, rinfo->cfg_addr,
+						 mask, val);
+			if (ret < 0) {
+				dev_err(pmic->dev, "Reg 0x%02x update failed %d\n",
+					rinfo->cfg_addr, ret);
+				return ret;
+			}
+		}
+		break;
+
+	default:
+		break;
+	}
+
+	return 0;
+}
+
 static int max77620_init_pmic(struct max77620_regulator *pmic, int id)
 {
 	struct max77620_regulator_pdata *rpdata = &pmic->reg_pdata[id];
 	int ret;
 
+	max77620_config_power_ok(pmic, id);
+
 	/* Update power mode */
 	ret = max77620_regulator_get_power_mode(pmic, id);
 	if (ret < 0)
@@ -594,6 +632,12 @@ static int max77620_of_parse_cb(struct device_node *np,
 			np, "maxim,suspend-fps-power-down-slot", &pval);
 	rpdata->suspend_fps_pd_slot = (!ret) ? pval : -1;
 
+	ret = of_property_read_u32(np, "maxim,power-ok-control", &pval);
+	if (!ret)
+		rpdata->power_ok = pval;
+	else
+		rpdata->power_ok = -1;
+
 	ret = of_property_read_u32(np, "maxim,ramp-rate-setting", &pval);
 	rpdata->ramp_rate_setting = (!ret) ? pval : 0;
 
@@ -806,6 +850,8 @@ static int max77620_regulator_resume(struct device *dev)
 	for (id = 0; id < MAX77620_NUM_REGS; id++) {
 		reg_pdata = &pmic->reg_pdata[id];
 
+		max77620_config_power_ok(pmic, id);
+
 		max77620_regulator_set_fps_slots(pmic, id, false);
 		if (reg_pdata->active_fps_src < 0)
 			continue;
diff --git a/include/linux/mfd/max77620.h b/include/linux/mfd/max77620.h
index 3ca0af07fc78..ad2a9a852aea 100644
--- a/include/linux/mfd/max77620.h
+++ b/include/linux/mfd/max77620.h
@@ -180,6 +180,7 @@
 #define MAX77620_SD_CFG1_FPWM_SD_MASK		BIT(2)
 #define MAX77620_SD_CFG1_FPWM_SD_SKIP		0
 #define MAX77620_SD_CFG1_FPWM_SD_FPWM		BIT(2)
+#define MAX20024_SD_CFG1_MPOK_MASK		BIT(1)
 #define MAX77620_SD_CFG1_FSRADE_SD_MASK		BIT(0)
 #define MAX77620_SD_CFG1_FSRADE_SD_DISABLE	0
 #define MAX77620_SD_CFG1_FSRADE_SD_ENABLE	BIT(0)
@@ -187,6 +188,7 @@
 /* LDO_CNFG2 */
 #define MAX77620_LDO_POWER_MODE_MASK		0xC0
 #define MAX77620_LDO_POWER_MODE_SHIFT		6
+#define MAX20024_LDO_CFG2_MPOK_MASK		BIT(2)
 #define MAX77620_LDO_CFG2_ADE_MASK		BIT(1)
 #define MAX77620_LDO_CFG2_ADE_DISABLE		0
 #define MAX77620_LDO_CFG2_ADE_ENABLE		BIT(1)
-- 
2.10.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] regulator: max77620: add support to configure MPOK
  2016-11-21 13:11   ` Lee Jones
@ 2016-11-23 16:40     ` Mark Brown
  0 siblings, 0 replies; 8+ messages in thread
From: Mark Brown @ 2016-11-23 16:40 UTC (permalink / raw)
  To: Lee Jones
  Cc: Venkat Reddy Talla, lgirdwood, robh+dt, mark.rutland, devicetree,
	linux-kernel, ldewangan, svelpula

[-- Attachment #1: Type: text/plain, Size: 1291 bytes --]

On Mon, Nov 21, 2016 at 01:11:21PM +0000, Lee Jones wrote:

> Mark if you want to take this patch, feel free.

The following changes since commit 1001354ca34179f3db924eb66672442a173147dc:

  Linux 4.9-rc1 (2016-10-15 12:17:50 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git tags/regulator-max77620-mpok

for you to fetch changes up to 983779235a4d08f94e8cda073200423e0ff01d2e:

  regulator: max77620: add documentation for MPOK property (2016-11-23 16:27:42 +0000)

----------------------------------------------------------------
regulator: max77620: Implement support for MPOK bit

Allow systems to configure the MPOK bit, controlling power OK signalling
from the device.

----------------------------------------------------------------
Venkat Reddy Talla (3):
      regulator: max77620: remove unused variable
      regulator: max77620: add support to configure MPOK
      regulator: max77620: add documentation for MPOK property

 Documentation/devicetree/bindings/mfd/max77620.txt | 12 ++++++
 drivers/regulator/max77620-regulator.c             | 47 +++++++++++++++++++++-
 include/linux/mfd/max77620.h                       |  2 +
 3 files changed, 60 insertions(+), 1 deletion(-)

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-23 16:41 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-17 17:54 [PATCH v2 1/2] regulator: max77620: add support to configure MPOK Venkat Reddy Talla
2016-11-17 17:54 ` [PATCH v2 2/2] dt-bindings: max77620: add documentation for MPOK property Venkat Reddy Talla
2016-11-18 14:54   ` Rob Herring
2016-11-21 13:10   ` Lee Jones
2016-11-21 13:09 ` [PATCH v2 1/2] regulator: max77620: add support to configure MPOK Lee Jones
2016-11-21 13:11   ` Lee Jones
2016-11-23 16:40     ` Mark Brown
2016-11-23 16:31 ` Applied "regulator: max77620: add support to configure MPOK" to the regulator tree Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).