Skip to contentSkip to conversation

regulator: tps65132: add regulator driver for TI TPS65132

PATCH Superseded Venkat Reddy Talla 2 participants 2 messages Mar 6, 2017 – Mar 7, 2017 Voltage and current regulator framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 regulator: tps65132: add regulator driver for TI TPS65132

Adding regulator driver for the device TI TPS65132 which is single inductor - dual output power supply device. TPS65132 device is designed to support general positive/negative driven applications like TFT display panels.

TPS65132 regulator driver supports to enable/disable and set voltage on its output.

---
 drivers/regulator/Kconfig              |   8 +
 drivers/regulator/Makefile             |   1 +
 drivers/regulator/tps65132-regulator.c | 327 +++++++++++++++++++++++++++++++++
 3 files changed, 336 insertions(+)
 create mode 100644 drivers/regulator/tps65132-regulator.c
drivers/regulator/Kconfig +0 -0
index be06eb2..85d295d 100644
@@ -843,6 +843,14 @@ config REGULATOR_TPS80031

converters, 11 general purpose LDOs, VBUS generator and digital output to control regulators.

+config REGULATOR_TPS65132
+ tristate "TI TPS65132 Dual Output Power regulators"
+ depends on I2C && GPIOLIB
+ select REGMAP_I2C
+ help
+ This driver supports TPS65132 single inductor - dual output
+ power supply specifcally designed for display panels.
+
config REGULATOR_TWL4030

	tristate "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC"
	depends on TWL4030_CORE
drivers/regulator/Makefile +1 -0
index ef7725e..8bc7faa 100644
@@ -105,6 +105,7 @@ obj-$(CONFIG_REGULATOR_TPS6586X) += tps6586x-regulator.o
 obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
 obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o
 obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o
+obj-$(CONFIG_REGULATOR_TPS65132) += tps65132-regulator.o
 obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o twl6030-regulator.o
 obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress-regulator.o
 obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
drivers/regulator/tps65132-regulator.c new file +327 -0

327 lines not on this page · raw message

--
2.1.4

maintainer
#1 lore raw

drivers/regulator/tps65132-regulator.c line 84

Quoted 2 lines · Venkat Reddy Talla
drivers/regulator/tps65132-regulator.c new file +2 -0
+	dis_mask = (id == TPS65132_REGULATOR_ID_VPOS) ?
+			TPS65132_REG_APPS_DISP : TPS65132_REG_APPS_DISN;

Please don't abuse the ternery operator, write normal if statements so that people can read the code easily.

drivers/regulator/tps65132-regulator.c line 110

Quoted 13 lines
drivers/regulator/tps65132-regulator.c new file +13 -0
+static int tps65132_disable(struct regulator_dev *rdev)
+{
+	struct tps65132_regulator *tps = rdev_get_drvdata(rdev);
+	int id = rdev_get_id(rdev);
+	int act_dis_gpio = tps->reg_pdata[id].active_discharge_gpio;
+	unsigned int act_dis_time_us = tps->reg_pdata[id].active_discharge_time;
+
+	if (gpio_is_valid(act_dis_gpio)) {
+		gpio_set_value_cansleep(act_dis_gpio, 1);
+		usleep_range(act_dis_time_us,
+			act_dis_time_us + TPS65132_ACT_DIS_TIME_SLACK);
+		gpio_set_value_cansleep(act_dis_gpio, 0);
+	}

Don't we need to undo the active discharge register write?

Quoted 4 lines
drivers/regulator/tps65132-regulator.c new file +4 -0
+static int tps65132_get_regulator_dt_data(struct device *dev,
+		struct tps65132_regulator *tps65132_regs)
+{
+	struct tps65132_reg_pdata *rpdata;

drivers/regulator/tps65132-regulator.c line 163

Quoted 10 lines
drivers/regulator/tps65132-regulator.c new file +10 -0
+	struct device_node *rnode;
+	int id;
+	int ret;
+
+	ret = of_regulator_match(dev, dev->of_node, tps65132_regulator_matches,
+			ARRAY_SIZE(tps65132_regulator_matches));
+	if (ret < 0) {
+		dev_err(dev, "node parsing for regulator failed: %d\n", ret);
+		return ret;
+	}

Don't open code this, use of_parse_cb() to parse your extra properties.

drivers/regulator/tps65132-regulator.c line 316

Quoted 5 lines
drivers/regulator/tps65132-regulator.c new file +5 -0
+static int __init tps65132_init(void)
+{
+	return i2c_add_driver(&tps65132_i2c_driver);
+}
+subsys_initcall(tps65132_init);

You should use module_i2c_driver() for new drivers.