regulator: tps65217: Add tps65217 regulator driver
Subsystems (2)
PATCH v3 2/2 regulator: tps65217: Add tps65217 regulator driver
This patch adds tps65217 PMIC as a regulator
The regulator module consists of 3 DCDCs and 4 LDOs. The output voltages are configurable and are meant to supply power to the main processor and other components
--- drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/tps65217-regulator.c | 435 ++++++++++++++++++++++++++++++++ 3 files changed, 445 insertions(+), 0 deletions(-) create mode 100644 drivers/regulator/tps65217-regulator.c
drivers/regulator/Kconfig +9 -0
@@ -259,6 +259,15 @@ config REGULATOR_TPS6507X three step-down converters and two general-purpose LDO voltage regulators. It supports TI's software based Class-2 SmartReflex implementation. +config REGULATOR_TPS65217 + tristate "TI TPS65217 Power regulators" + depends on MFD_TPS65217 + help + This driver supports TPS65217 voltage regulator chips. TPS65217 + provides three step-down converters and four general-purpose LDO + voltage regulators. It supports software based voltage control + for different voltage domains + config REGULATOR_TPS65912 tristate "TI TPS65912 Power regulator" depends on (MFD_TPS65912_I2C || MFD_TPS65912_SPI)
drivers/regulator/Makefile +1 -0
@@ -38,6 +38,7 @@ obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o obj-$(CONFIG_REGULATOR_TPS6507X) += tps6507x-regulator.o +obj-$(CONFIG_REGULATOR_TPS65217) += tps65217-regulator.o obj-$(CONFIG_REGULATOR_TPS6524X) += tps6524x-regulator.o obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
drivers/regulator/tps65217-regulator.c new file +435 -0
435 lines not on this page · raw message
Signature · 1 line
1.7.0.4
On Wed, Jan 04, 2012 at 03:22:27PM +0530, AnilKumar Ch wrote:
This looks pretty good. A couple of small issues.
Quoted 15 lines
drivers/regulator/tps65217-regulator.c new file +15
-0+static int tps65217_vsel_to_uv_range1 (unsigned int vsel) +{ +int uV =0 ; + +if (vsel >15 ) +return -EINVAL ; + +if (vsel <=2 ) + uV = vsel *100000 +1000000 ; +else if (vsel <=6 ) + uV = (vsel -2 ) *50000 +1200000 ; +else if (vsel <=9 ) + uV = (vsel -6 ) *100000 +1400000 ; +else if (vsel ==10 ) + uV =2500000 ;
drivers/regulator/tps65217-regulator.c line 92
Quoted 10 lines
drivers/regulator/tps65217-regulator.c new file +10
-0+else if (vsel ==11 ) + uV =2750000 ; +else if (vsel ==12 ) + uV =2800000 ; +else if (vsel ==13 ) + uV =3000000 ; +else if (vsel ==14 ) + uV =3100000 ; +else + uV =3300000 ;
This looks like it should actually be a table - there's far too many irregular steps here. The other regulators looked to be benefiting from the use of calculations.
Quoted 10 lines
drivers/regulator/tps65217-regulator.c new file +10
-0+static int tps65217_pmic_dcdc_get_voltage (struct regulator_dev *dev) +{ +int ret; +struct tps65217 *tps =rdev_get_drvdata (dev); +unsigned int data, dcdc =rdev_get_id (dev); + +if (dcdc <TPS65217_DCDC_1 || dcdc >TPS65217_DCDC_3 ) +return -EINVAL ; + + ret =tps65217_reg_read (tps, tps->info[dcdc]->set_vout_reg, &data);
drivers/regulator/tps65217-regulator.c line 245
Quoted 10 lines
drivers/regulator/tps65217-regulator.c new file +10
-0+if (ret) +return ret; + + data &= tps->info[dcdc]->set_vout_mask; + + ret = tps->info[dcdc]->tps_range (data); +if (ret <0 ) +dev_err (&dev->dev,"Failed to get voltage\n" ); + +return ret;
It seems odd to implement this as a vanilla get_voltage()
drivers/regulator/tps65217-regulator.c line 250
Quoted 3 lines
drivers/regulator/tps65217-regulator.c new file +3
-0+static int tps65217_pmic_dcdc_set_voltage (struct regulator_dev *dev, +unsigned selector) +{
but this as set_voltage_sel(). For non table based regulators plain set_voltage() usually makes a bit more sense as we don't have to iterate through the selectors looking for a match.
Hi Mark,
Quoted 25 lines · Mark Brown
On Wed, Jan 04, 2012 at 03:22:27PM +0530, AnilKumar Ch wrote:
This looks pretty good. A couple of small issues.
Quoted 21 lines
drivers/regulator/tps65217-regulator.c new file +21
-0+static int tps65217_vsel_to_uv_range1 (unsigned int vsel) +{ +int uV =0 ; + +if (vsel >15 ) +return -EINVAL ; + +if (vsel <=2 ) + uV = vsel *100000 +1000000 ; +else if (vsel <=6 ) + uV = (vsel -2 ) *50000 +1200000 ; +else if (vsel <=9 ) + uV = (vsel -6 ) *100000 +1400000 ; +else if (vsel ==10 ) + uV =2500000 ; +else if (vsel ==11 ) + uV =2750000 ; +else if (vsel ==12 ) + uV =2800000 ; +else if (vsel ==13 ) + uV =3000000 ;
Quoted 8 lines
drivers/regulator/tps65217-regulator.c line 92
Quoted 4 lines
drivers/regulator/tps65217-regulator.c new file +4
-0+else if (vsel ==14 ) + uV =3100000 ; +else + uV =3300000 ;This looks like it should actually be a table - there's far too many irregular steps here. The other regulators looked to be benefiting from the use of calculations.
Changed to a table for this regulator only.
Quoted 15 lines
Quoted 15 lines
drivers/regulator/tps65217-regulator.c new file +14
-0+static int tps65217_pmic_dcdc_get_voltage (struct regulator_dev *dev) +{ +int ret; +struct tps65217 *tps =rdev_get_drvdata (dev); +unsigned int data, dcdc =rdev_get_id (dev); + +if (dcdc <TPS65217_DCDC_1 || dcdc >TPS65217_DCDC_3 ) +return -EINVAL ; + + ret =tps65217_reg_read (tps, tps->info[dcdc]->set_vout_reg, &data); +if (ret) +return ret; + + data &= tps->info[dcdc]->set_vout_mask;
Quoted 8 lines
drivers/regulator/tps65217-regulator.c line 245
Quoted 6 lines
drivers/regulator/tps65217-regulator.c new file +6
-0+ + ret = tps->info[dcdc]->tps_range (data); +if (ret <0 ) +dev_err (&dev->dev,"Failed to get voltage\n" ); + +return ret;It seems odd to implement this as a vanilla
get_voltage()
Agree, changed to get_voltage_sel()
Quoted 9 lines
drivers/regulator/tps65217-regulator.c line 250
Quoted 4 lines
drivers/regulator/tps65217-regulator.c new file +3
-0+static int tps65217_pmic_dcdc_set_voltage (struct regulator_dev *dev, +unsigned selector) +{but this as
set_voltage_sel(). For non table based regulators plainset_voltage()usually makes a bit more sense as we don't have to iterate through the selectors looking for a match.
I changed the implementation according to your point but the code size actually increased by 68 lines after fixing these comments. I will send across the replacement, please see if you like this one better.
Regards,
AnilKumar