* [RFT][PATCH 1/2] regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0
@ 2013-04-17 13:42 Axel Lin
2013-04-17 13:43 ` [RFT][PATCH 2/2] regulator: tps80031: Convert tps80031_dcdc_ops to [get|set]_voltage_sel_regmap Axel Lin
2013-04-23 10:48 ` [RFT][PATCH 1/2] regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0 Mark Brown
0 siblings, 2 replies; 4+ messages in thread
From: Axel Lin @ 2013-04-17 13:42 UTC (permalink / raw)
To: Mark Brown; +Cc: Laxman Dewangan, Liam Girdwood, linux-kernel
Currently we have a special code in tps80031_ldo_set_voltage_sel() to handle
LDO2 track mode for TPS80031 or TPS80032-ES1.0. The purpose is to address below
issues:
Issue description:
- LDO2 traking mode is enabled
- LDO2 tracks SMPS2 voltage.
- LDO2 automatically switch-off when LDO2_CFG_VOLTAGE is changed to some discrete values (non exhaustive list):
00011001, 00011010, 00011011, 00011100, .
- LDO2 switch-on again when LDO2_CFG_VOLTAGE is changed to other values (non exhaustive list):
00011000, 00010111, .
LDOs have reserved codes. For these codes, LDO is switch-off.
In tracking, LDO2 ref comes from SMPS2.
However LDO2 enable is still gated by LDO2 VSEL decoding.
As a result, in tracking mode LDO2 will be disabled for following code (SMPS VSEL format):
000000 & 100000 (MSB not decoded)
011001 & 111001 (MSB not decoded)
011010 & 111010 (MSB not decoded)
011100 & 111100 (MSB not decoded)
011101 & 111101 (MSB not decoded)
011110 & 111110 (MSB not decoded)
However, current code has below bugs:
1. It uses regulator_list_voltage_linear, so list_voltage() still shows above
invalid selectors have supported voltage.
2. Current code may return -EINVAL in tps80031_ldo_set_voltage_sel() for
supported voltage. This is because when we use regulator_list_voltage_linear
as list_voltage callback, regulator core will default use
regulator_map_voltage_linear(). regulator_map_voltage_linear() has an
assumption that the voltages are linear which is not true for this case.
For example,
when request voltage range is: min_uV=950000 uV && max_uV=1200000 uV
regulator_map_voltage_linear() returns the selector is 29 (0x1D),
set_voltage_sel() returns -EINVAL.
(The selector is in invalid range, 0x19 ~ 0x1f).
In above case, map_voltage() should find the lowest valid voltage within
specific range (selector = 0x20) and set_voltage_sel() should successfully
set the voltage to 987500 uV.
This patch fixes these issues by:
1. Add checking valid setting for LDO2 track mode of TPS80031 or TPS80032-ES1.0
in list_voltage. So it returns -EINVAL for invalid selectors.
2. Implement tps80031_ldo_map_voltage, use regulator_map_voltage_iterate()
to find the lowest voltage within specific range for TPS80031 or
TPS80032-ES1.0. This is required when the voltage map is no longer linear.
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
Hi Laxman,
I don't have this hardware, can you test this patch serial?
Thank you,
Axel
drivers/regulator/tps80031-regulator.c | 38 ++++++++++++++++++++++++++++----
1 file changed, 34 insertions(+), 4 deletions(-)
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c
index 9019d0e..6430789 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -238,12 +238,11 @@ static int tps80031_dcdc_get_voltage_sel(struct regulator_dev *rdev)
return vsel & SMPS_VSEL_MASK;
}
-static int tps80031_ldo_set_voltage_sel(struct regulator_dev *rdev,
- unsigned sel)
+static int tps80031_ldo_list_voltage(struct regulator_dev *rdev,
+ unsigned int sel)
{
struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
struct device *parent = to_tps80031_dev(rdev);
- int ret;
/* Check for valid setting for TPS80031 or TPS80032-ES1.0 */
if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
@@ -260,6 +259,36 @@ static int tps80031_ldo_set_voltage_sel(struct regulator_dev *rdev,
}
}
+ return regulator_list_voltage_linear(rdev, sel);
+}
+
+static int tps80031_ldo_map_voltage(struct regulator_dev *rdev,
+ int min_uV, int max_uV)
+{
+ struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
+ struct device *parent = to_tps80031_dev(rdev);
+
+ /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */
+ if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
+ (ri->device_flags & TRACK_MODE_ENABLE)) {
+ if (((tps80031_get_chip_info(parent) == TPS80031) ||
+ ((tps80031_get_chip_info(parent) == TPS80032) &&
+ (tps80031_get_pmu_version(parent) == 0x0)))) {
+ return regulator_map_voltage_iterate(rdev, min_uV,
+ max_uV);
+ }
+ }
+
+ return regulator_map_voltage_linear(rdev, min_uV, max_uV);
+}
+
+static int tps80031_ldo_set_voltage_sel(struct regulator_dev *rdev,
+ unsigned sel)
+{
+ struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
+ struct device *parent = to_tps80031_dev(rdev);
+ int ret;
+
ret = tps80031_write(parent, ri->rinfo->volt_id,
ri->rinfo->volt_reg, sel);
if (ret < 0)
@@ -390,7 +419,8 @@ static struct regulator_ops tps80031_dcdc_ops = {
};
static struct regulator_ops tps80031_ldo_ops = {
- .list_voltage = regulator_list_voltage_linear,
+ .list_voltage = tps80031_ldo_list_voltage,
+ .map_voltage = tps80031_ldo_map_voltage,
.set_voltage_sel = tps80031_ldo_set_voltage_sel,
.get_voltage_sel = tps80031_ldo_get_voltage_sel,
.enable = tps80031_reg_enable,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [RFT][PATCH 2/2] regulator: tps80031: Convert tps80031_dcdc_ops to [get|set]_voltage_sel_regmap
2013-04-17 13:42 [RFT][PATCH 1/2] regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0 Axel Lin
@ 2013-04-17 13:43 ` Axel Lin
2013-04-23 10:48 ` Mark Brown
2013-04-23 10:48 ` [RFT][PATCH 1/2] regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0 Mark Brown
1 sibling, 1 reply; 4+ messages in thread
From: Axel Lin @ 2013-04-17 13:43 UTC (permalink / raw)
To: Mark Brown; +Cc: Laxman Dewangan, Liam Girdwood, linux-kernel
Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
drivers/regulator/tps80031-regulator.c | 39 +++++---------------------------
1 file changed, 6 insertions(+), 33 deletions(-)
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c
index 6430789..6511d0b 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -282,37 +282,6 @@ static int tps80031_ldo_map_voltage(struct regulator_dev *rdev,
return regulator_map_voltage_linear(rdev, min_uV, max_uV);
}
-static int tps80031_ldo_set_voltage_sel(struct regulator_dev *rdev,
- unsigned sel)
-{
- struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
- struct device *parent = to_tps80031_dev(rdev);
- int ret;
-
- ret = tps80031_write(parent, ri->rinfo->volt_id,
- ri->rinfo->volt_reg, sel);
- if (ret < 0)
- dev_err(ri->dev, "Error in writing reg 0x%02x, e = %d\n",
- ri->rinfo->volt_reg, ret);
- return ret;
-}
-
-static int tps80031_ldo_get_voltage_sel(struct regulator_dev *rdev)
-{
- struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
- struct device *parent = to_tps80031_dev(rdev);
- uint8_t vsel;
- int ret;
-
- ret = tps80031_read(parent, ri->rinfo->volt_id,
- ri->rinfo->volt_reg, &vsel);
- if (ret < 0) {
- dev_err(ri->dev, "Error in writing the Voltage register\n");
- return ret;
- }
- return vsel & rdev->desc->vsel_mask;
-}
-
static int tps80031_vbus_is_enabled(struct regulator_dev *rdev)
{
struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
@@ -421,8 +390,8 @@ static struct regulator_ops tps80031_dcdc_ops = {
static struct regulator_ops tps80031_ldo_ops = {
.list_voltage = tps80031_ldo_list_voltage,
.map_voltage = tps80031_ldo_map_voltage,
- .set_voltage_sel = tps80031_ldo_set_voltage_sel,
- .get_voltage_sel = tps80031_ldo_get_voltage_sel,
+ .set_voltage_sel = regulator_set_voltage_sel_regmap,
+ .get_voltage_sel = regulator_get_voltage_sel_regmap,
.enable = tps80031_reg_enable,
.disable = tps80031_reg_disable,
.is_enabled = tps80031_reg_is_enabled,
@@ -489,6 +458,7 @@ static struct regulator_ops tps80031_ext_reg_ops = {
.uV_step = 100000, \
.linear_min_sel = 1, \
.n_voltages = 25, \
+ .vsel_reg = TPS80031_##_id##_CFG_VOLTAGE, \
.vsel_mask = LDO_VSEL_MASK, \
.enable_time = 500, \
}, \
@@ -710,6 +680,7 @@ static int tps80031_regulator_probe(struct platform_device *pdev)
struct tps80031_regulator *pmic;
struct regulator_dev *rdev;
struct regulator_config config = { };
+ struct tps80031 *tps80031_mfd = dev_get_drvdata(pdev->dev.parent);
int ret;
int num;
@@ -737,6 +708,8 @@ static int tps80031_regulator_probe(struct platform_device *pdev)
config.dev = &pdev->dev;
config.init_data = NULL;
config.driver_data = ri;
+ config.regmap = tps80031_mfd->regmap[ri->rinfo->volt_id];
+
if (tps_pdata) {
config.init_data = tps_pdata->reg_init_data;
ri->config_flags = tps_pdata->config_flags;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFT][PATCH 1/2] regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0
2013-04-17 13:42 [RFT][PATCH 1/2] regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0 Axel Lin
2013-04-17 13:43 ` [RFT][PATCH 2/2] regulator: tps80031: Convert tps80031_dcdc_ops to [get|set]_voltage_sel_regmap Axel Lin
@ 2013-04-23 10:48 ` Mark Brown
1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-04-23 10:48 UTC (permalink / raw)
To: Axel Lin; +Cc: Laxman Dewangan, Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 247 bytes --]
On Wed, Apr 17, 2013 at 09:42:23PM +0800, Axel Lin wrote:
> Currently we have a special code in tps80031_ldo_set_voltage_sel() to handle
> LDO2 track mode for TPS80031 or TPS80032-ES1.0. The purpose is to address below
> issues:
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFT][PATCH 2/2] regulator: tps80031: Convert tps80031_dcdc_ops to [get|set]_voltage_sel_regmap
2013-04-17 13:43 ` [RFT][PATCH 2/2] regulator: tps80031: Convert tps80031_dcdc_ops to [get|set]_voltage_sel_regmap Axel Lin
@ 2013-04-23 10:48 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-04-23 10:48 UTC (permalink / raw)
To: Axel Lin; +Cc: Laxman Dewangan, Liam Girdwood, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 124 bytes --]
On Wed, Apr 17, 2013 at 09:43:39PM +0800, Axel Lin wrote:
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Applied, thanks.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-23 10:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-17 13:42 [RFT][PATCH 1/2] regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0 Axel Lin
2013-04-17 13:43 ` [RFT][PATCH 2/2] regulator: tps80031: Convert tps80031_dcdc_ops to [get|set]_voltage_sel_regmap Axel Lin
2013-04-23 10:48 ` Mark Brown
2013-04-23 10:48 ` [RFT][PATCH 1/2] regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0 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).