Skip to contentSkip to conversation

TPS65217: Add tps65217 regulator driver

PATCH Superseded AnilKumar Ch 2 participants 3 messages Jan 2, 2012 – Jan 3, 2012

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/2 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 |  459 ++++++++++++++++++++++++++++++++
 3 files changed, 469 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/tps65217-regulator.c
drivers/regulator/Kconfig +9 -0
index 9713b1b..9fcc919 100644
@@ -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 (I2C && 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
index 93a6318..aeae546 100644
@@ -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 +459 -0

459 lines not on this page · raw message

Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 1 line · AnilKumar Ch

This patch adds tps65217 PMIC as a regulator

Use subject lines appropriate for the subsystem you're submitting against.

drivers/regulator/Kconfig config REGULATOR_TPS6507X · line 264

Quoted 3 lines
drivers/regulator/Kconfig +3 -0
+config REGULATOR_TPS65217
+	tristate "TI TPS65217 Power regulators"
+	depends on (I2C && MFD_TPS65217)

Should only depend on the MFD, there's no direct I2C usage.

drivers/regulator/tps65217-regulator.c line 59

Quoted 10 lines
drivers/regulator/tps65217-regulator.c new file +10 -0
+static unsigned int tps65217_vsel_to_uv_range0(unsigned int vsel)
+{
+	unsigned int uV = 0;
+
+	if (vsel <= 24)
+		uV = ((vsel * 25000) + 900000);
+	else if (vsel > 24 && vsel <= 52)
+		uV = (((vsel - 24) * 50000) + 1500000);
+	else if (vsel > 52 && vsel <= 56)
+		uV = (((vsel - 52) * 100000) + 2900000);

No need for the > checks as this is already taken care of by being in the else clause.

drivers/regulator/tps65217-regulator.c line 103

Quoted 12 lines
drivers/regulator/tps65217-regulator.c new file +12 -0
+static unsigned int tps65217_vsel_to_uv_range2(unsigned int vsel)
+{
+	unsigned int uV = 0;
+
+	if (vsel <= 8)
+		uV = ((vsel * 50000) + 1500000);
+	else if (vsel > 9 && vsel <= 13)
+		uV = (((vsel - 8) * 100000) + 1900000);
+	else if (vsel > 13)
+		uV = (((vsel - 13) * 50000) + 2400000);
+
+	return uV;

In all of these functions there ought to be a check to make sure vsel isn't out of range and return an error if it is.

drivers/regulator/tps65217-regulator.c line 132

Quoted 3 lines
drivers/regulator/tps65217-regulator.c new file +3 -0
+static int tps65217_pmic_set_bits(struct tps65217 *tps, unsigned int reg,
+		unsigned int mask, unsigned int val, unsigned int level)
+{

To repeat what I said when reviewing the previous version of the patch things like this shouldn't be open coded in individual function drivers, they should be in the MFD driver. There is *nothing* PMIC specific about register access.

I've stopped reading at this point.

#2 lore raw

Hi Mark,

Quoted 11 lines · Mark Brown
Quoted 1 line · AnilKumar Ch

This patch adds tps65217 PMIC as a regulator

Use subject lines appropriate for the subsystem you're submitting against.

drivers/regulator/Kconfig config REGULATOR_TPS6507X · line 264

Quoted 3 lines
drivers/regulator/Kconfig +3 -0
+config REGULATOR_TPS65217
+	tristate "TI TPS65217 Power regulators"
+	depends on (I2C && MFD_TPS65217)

Should only depend on the MFD, there's no direct I2C usage.

Agree, removed I2C

Quoted 14 lines

drivers/regulator/tps65217-regulator.c line 59

Quoted 11 lines
drivers/regulator/tps65217-regulator.c new file +10 -0
+static unsigned int tps65217_vsel_to_uv_range0(unsigned int vsel)
+{
+	unsigned int uV = 0;
+
+	if (vsel <= 24)
+		uV = ((vsel * 25000) + 900000);
+	else if (vsel > 24 && vsel <= 52)
+		uV = (((vsel - 24) * 50000) + 1500000);
+	else if (vsel > 52 && vsel <= 56)
+		uV = (((vsel - 52) * 100000) + 2900000);

No need for the > checks as this is already taken care of by being in the else clause.

Changed

Quoted 16 lines

drivers/regulator/tps65217-regulator.c line 103

Quoted 13 lines
drivers/regulator/tps65217-regulator.c new file +12 -0
+static unsigned int tps65217_vsel_to_uv_range2(unsigned int vsel)
+{
+	unsigned int uV = 0;
+
+	if (vsel <= 8)
+		uV = ((vsel * 50000) + 1500000);
+	else if (vsel > 9 && vsel <= 13)
+		uV = (((vsel - 8) * 100000) + 1900000);
+	else if (vsel > 13)
+		uV = (((vsel - 13) * 50000) + 2400000);
+
+	return uV;

In all of these functions there ought to be a check to make sure vsel isn't out of range and return an error if it is.

Added error checks as well.

Quoted 10 lines

drivers/regulator/tps65217-regulator.c line 132

Quoted 4 lines
drivers/regulator/tps65217-regulator.c new file +3 -0
+static int tps65217_pmic_set_bits(struct tps65217 *tps, unsigned int reg,
+		unsigned int mask, unsigned int val, unsigned int level)
+{

To repeat what I said when reviewing the previous version of the patch things like this shouldn't be open coded in individual function drivers, they should be in the MFD driver. There is *nothing* PMIC specific about register access.

Quoted 2 lines

I've stopped reading at this point.

Mark sorry about this, password protected writes/update bits are required only for regulator so I put it in regulator driver. I got your point, will be moved to MFD driver.

Thanks for your patience here.

Regards,
AnilKumar