diff mbox

[3/3] regulator: palmas: add support for LDO8 tracking mode

Message ID 1366191793-13934-3-git-send-email-ldewangan@nvidia.com
State Not Applicable, archived
Headers show

Commit Message

Laxman Dewangan April 17, 2013, 9:43 a.m. UTC
LDO8 of Palma device like tps65913 support the tracking mode
on which LDO8 track the SMPS45 voltage when SMPS45 is ON
and use the LDO8.VOLTAGE_SEL register when SMPS45 is OFF.

On track mode, the steps of voltage change for LDO8 is 25mV
where in non-tracking mode it is 50mV. Set the steps accordingly.
Number of voltage count is still same for both the cases.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
---
 drivers/regulator/palmas-regulator.c |   53 ++++++++++++++++++++++++++++++++++
 include/linux/mfd/palmas.h           |    3 ++
 2 files changed, 56 insertions(+), 0 deletions(-)

Comments

Graeme Gregory April 17, 2013, 1:54 p.m. UTC | #1
Looks good to me, I don't actually know the use case for this feature!

Acked-by: Graeme Gregory <gg@slimlogic.co.uk>

On 17/04/13 10:43, Laxman Dewangan wrote:
> LDO8 of Palma device like tps65913 support the tracking mode
> on which LDO8 track the SMPS45 voltage when SMPS45 is ON
> and use the LDO8.VOLTAGE_SEL register when SMPS45 is OFF.
>
> On track mode, the steps of voltage change for LDO8 is 25mV
> where in non-tracking mode it is 50mV. Set the steps accordingly.
> Number of voltage count is still same for both the cases.
>
> Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
> ---
>  drivers/regulator/palmas-regulator.c |   53 ++++++++++++++++++++++++++++++++++
>  include/linux/mfd/palmas.h           |    3 ++
>  2 files changed, 56 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
> index 28080a7..d6efaf1 100644
> --- a/drivers/regulator/palmas-regulator.c
> +++ b/drivers/regulator/palmas-regulator.c
> @@ -572,6 +572,46 @@ static int palmas_extreg_init(struct palmas *palmas, int id,
>  	return 0;
>  }
>  
> +static void palmas_enable_ldo8_track(struct palmas *palmas)
> +{
> +	unsigned int reg;
> +	unsigned int addr;
> +	int ret;
> +
> +	addr = palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr;
> +
> +	ret = palmas_ldo_read(palmas, addr, &reg);
> +	if (ret) {
> +		dev_err(palmas->dev, "Error in reading ldo8 control reg\n");
> +		return;
> +	}
> +
> +	reg |= PALMAS_LDO8_CTRL_LDO_TRACKING_EN;
> +	ret = palmas_ldo_write(palmas, addr, reg);
> +	if (ret < 0) {
> +		dev_err(palmas->dev, "Error in enabling tracking mode\n");
> +		return;
> +	}
> +	/*
> +	 * When SMPS45 is set to off and LDO8 tracking is enabled, the LDO8
> +	 * output is defined by the LDO8_VOLTAGE.VSEL register divided by two,
> +	 * and can be set from 0.45 to 1.65 V.
> +	 */
> +	addr = palmas_regs_info[PALMAS_REG_LDO8].vsel_addr;
> +	ret = palmas_ldo_read(palmas, addr, &reg);
> +	if (ret) {
> +		dev_err(palmas->dev, "Error in reading ldo8 voltage reg\n");
> +		return;
> +	}
> +
> +	reg = (reg << 1) & PALMAS_LDO8_VOLTAGE_VSEL_MASK;
> +	ret = palmas_ldo_write(palmas, addr, reg);
> +	if (ret < 0)
> +		dev_err(palmas->dev, "Error in setting ldo8 voltage reg\n");
> +
> +	return;
> +}
> +
>  static struct of_regulator_match palmas_matches[] = {
>  	{ .name = "smps12", },
>  	{ .name = "smps123", },
> @@ -657,6 +697,11 @@ static void palmas_dt_to_pdata(struct device *dev,
>  		if (ret)
>  			pdata->reg_init[idx]->vsel =
>  				PALMAS_SMPS12_VOLTAGE_RANGE;
> +
> +		if (idx == PALMAS_REG_LDO8)
> +			pdata->enable_ldo8_tracking = of_property_read_bool(
> +						palmas_matches[idx].of_node,
> +						"ti,enable-ldo8-tracking");
>  	}
>  
>  	pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator");
> @@ -836,6 +881,13 @@ static int palmas_regulators_probe(struct platform_device *pdev)
>  						palmas_regs_info[id].ctrl_addr);
>  			pmic->desc[id].enable_mask =
>  					PALMAS_LDO1_CTRL_MODE_ACTIVE;
> +
> +			/* Check if LDO8 is in tracking mode or not */
> +			if (pdata && (id == PALMAS_REG_LDO8) &&
> +					pdata->enable_ldo8_tracking) {
> +				palmas_enable_ldo8_track(palmas);
> +				pmic->desc[id].uV_step = 25000;
> +			}
>  		} else {
>  			pmic->desc[id].n_voltages = 1;
>  			pmic->desc[id].ops = &palmas_ops_extreg;
> @@ -884,6 +936,7 @@ static int palmas_regulators_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> +
>  	return 0;
>  
>  err_unregister_regulator:
> diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
> index fb04d07..12d8a62 100644
> --- a/include/linux/mfd/palmas.h
> +++ b/include/linux/mfd/palmas.h
> @@ -187,6 +187,9 @@ struct palmas_pmic_platform_data {
>  
>  	/* use LDO6 for vibrator control */
>  	int ldo6_vibrator;
> +
> +	/* Enable tracking mode of LDO8 */
> +	bool enable_ldo8_tracking;
>  };
>  
>  struct palmas_usb_platform_data {

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown April 17, 2013, 2:06 p.m. UTC | #2
On Wed, Apr 17, 2013 at 03:13:13PM +0530, Laxman Dewangan wrote:
> LDO8 of Palma device like tps65913 support the tracking mode
> on which LDO8 track the SMPS45 voltage when SMPS45 is ON
> and use the LDO8.VOLTAGE_SEL register when SMPS45 is OFF.

Applied, thanks.
Laxman Dewangan April 17, 2013, 4:14 p.m. UTC | #3
On Wednesday 17 April 2013 07:24 PM, Graeme Gregory wrote:
> Looks good to me, I don't actually know the use case for this feature!
>
> Acked-by: Graeme Gregory <gg@slimlogic.co.uk>
>

This is require for Tegra.
The always ON section of Tegra (say vdd_ao) need to be same as the core 
voltage(vdd_core) when system is active/idle. Hence the vdd_ao should be 
track to vdd_core and for this we need to configure the rail in tracking 
mode.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 28080a7..d6efaf1 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -572,6 +572,46 @@  static int palmas_extreg_init(struct palmas *palmas, int id,
 	return 0;
 }
 
+static void palmas_enable_ldo8_track(struct palmas *palmas)
+{
+	unsigned int reg;
+	unsigned int addr;
+	int ret;
+
+	addr = palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr;
+
+	ret = palmas_ldo_read(palmas, addr, &reg);
+	if (ret) {
+		dev_err(palmas->dev, "Error in reading ldo8 control reg\n");
+		return;
+	}
+
+	reg |= PALMAS_LDO8_CTRL_LDO_TRACKING_EN;
+	ret = palmas_ldo_write(palmas, addr, reg);
+	if (ret < 0) {
+		dev_err(palmas->dev, "Error in enabling tracking mode\n");
+		return;
+	}
+	/*
+	 * When SMPS45 is set to off and LDO8 tracking is enabled, the LDO8
+	 * output is defined by the LDO8_VOLTAGE.VSEL register divided by two,
+	 * and can be set from 0.45 to 1.65 V.
+	 */
+	addr = palmas_regs_info[PALMAS_REG_LDO8].vsel_addr;
+	ret = palmas_ldo_read(palmas, addr, &reg);
+	if (ret) {
+		dev_err(palmas->dev, "Error in reading ldo8 voltage reg\n");
+		return;
+	}
+
+	reg = (reg << 1) & PALMAS_LDO8_VOLTAGE_VSEL_MASK;
+	ret = palmas_ldo_write(palmas, addr, reg);
+	if (ret < 0)
+		dev_err(palmas->dev, "Error in setting ldo8 voltage reg\n");
+
+	return;
+}
+
 static struct of_regulator_match palmas_matches[] = {
 	{ .name = "smps12", },
 	{ .name = "smps123", },
@@ -657,6 +697,11 @@  static void palmas_dt_to_pdata(struct device *dev,
 		if (ret)
 			pdata->reg_init[idx]->vsel =
 				PALMAS_SMPS12_VOLTAGE_RANGE;
+
+		if (idx == PALMAS_REG_LDO8)
+			pdata->enable_ldo8_tracking = of_property_read_bool(
+						palmas_matches[idx].of_node,
+						"ti,enable-ldo8-tracking");
 	}
 
 	pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator");
@@ -836,6 +881,13 @@  static int palmas_regulators_probe(struct platform_device *pdev)
 						palmas_regs_info[id].ctrl_addr);
 			pmic->desc[id].enable_mask =
 					PALMAS_LDO1_CTRL_MODE_ACTIVE;
+
+			/* Check if LDO8 is in tracking mode or not */
+			if (pdata && (id == PALMAS_REG_LDO8) &&
+					pdata->enable_ldo8_tracking) {
+				palmas_enable_ldo8_track(palmas);
+				pmic->desc[id].uV_step = 25000;
+			}
 		} else {
 			pmic->desc[id].n_voltages = 1;
 			pmic->desc[id].ops = &palmas_ops_extreg;
@@ -884,6 +936,7 @@  static int palmas_regulators_probe(struct platform_device *pdev)
 		}
 	}
 
+
 	return 0;
 
 err_unregister_regulator:
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index fb04d07..12d8a62 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -187,6 +187,9 @@  struct palmas_pmic_platform_data {
 
 	/* use LDO6 for vibrator control */
 	int ldo6_vibrator;
+
+	/* Enable tracking mode of LDO8 */
+	bool enable_ldo8_tracking;
 };
 
 struct palmas_usb_platform_data {