Skip to contentSkip to conversation

Regulator: DA9055 Regulator driver

PATCH Superseded Ashish Jangam 2 participants 2 messages Oct 8, 2012 – Oct 9, 2012

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 2/7 Regulator: DA9055 Regulator driver

This is the Regulator patch for the DA9055 PMIC and has got dependency on the DA9055 MFD core.

This patch support all of the DA9055 regulators. The output voltages are fully programmable through I2C interface only. The platform data with regulation constraints is passed down from the board to the regulator.

This patch is functionaly tested on SMDK6410 board. DA9055 Evaluation board was connected to the SMDK6410 board.

---
- restructuring of GPIO regulator initialization code.

---
 drivers/regulator/Kconfig            |   10 +
 drivers/regulator/Makefile           |    1 +
 drivers/regulator/da9055-regulator.c |  704 ++++++++++++++++++++++++++++++++++
 include/linux/mfd/da9055/pdata.h     |    1 +
 4 files changed, 716 insertions(+), 0 deletions(-)
 create mode 100644 drivers/regulator/da9055-regulator.c
drivers/regulator/Kconfig +10 -0
index 129c827..0bd6db1 100644
@@ -109,6 +109,16 @@ config REGULATOR_DA9052
 	  This driver supports the voltage regulators of DA9052-BC and
 	  DA9053-AA/Bx PMIC.
 
+config REGULATOR_DA9055
+	tristate "Dialog Semiconductor DA9055 regulators"
+	depends on MFD_DA9055
+	help
+	  Say y here to support the BUCKs and LDOs regulators found on
+	  Dialog Semiconductor DA9055 PMIC.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called da9055-regulator.
+
 config REGULATOR_ANATOP
 	tristate "Freescale i.MX on-chip ANATOP LDO regulators"
 	depends on MFD_ANATOP
drivers/regulator/Makefile +1 -0
index 3a0dbc5..950b38b 100644
@@ -18,6 +18,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
 obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
 obj-$(CONFIG_REGULATOR_DA903X)	+= da903x.o
 obj-$(CONFIG_REGULATOR_DA9052)	+= da9052-regulator.o
+obj-$(CONFIG_REGULATOR_DA9055)	+= da9055-regulator.o
 obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
 obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
 obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
drivers/regulator/da9055-regulator.c new file +704 -0

704 lines not on this page · raw message

include/linux/mfd/da9055/pdata.h +1 -0
index 147293b..4527ad3 100644
@@ -28,5 +28,6 @@ struct da9055_pdata {
 	bool reset_enable;		/* Enable RTC in RESET Mode */
 	enum gpio_select *gpio_rsel;	/* Select regulator set thru GPIO 1/2 */
 	enum gpio_select *gpio_ren;	/* Enable regulator thru GPIO 1/2 */
+	int *ena_gpio;	/* GPIOs to enable regulator, 0 if not available */
 };
 #endif /* __DA9055_PDATA_H */
Signature · 1 line
1.7.0.4
#1 lore raw

On Mon, Oct 08, 2012 at 07:00:39PM +0530, Ashish Jangam wrote:

Mostly OK, but there's a few issues including yet more reimplementation of framework features.

Quoted 4 lines
drivers/regulator/da9055-regulator.c new file +4 -0
+static int da9055_list_voltage(struct regulator_dev *rdev,
+				unsigned int selector)
+{
+	struct da9055_regulator *regulator = rdev_get_drvdata(rdev);

drivers/regulator/da9055-regulator.c line 233

Quoted 10 lines
drivers/regulator/da9055-regulator.c new file +10 -0
+	struct da9055_regulator_info *info = regulator->info;
+	int volt_uV;
+
+	volt_uV = (selector * info->step_uV) + info->min_uV;
+
+	if (volt_uV > info->max_uV)
+		return -EINVAL;
+
+	return volt_uV;
+}

This is regulator_list_voltage_linear()

Quoted 12 lines
drivers/regulator/da9055-regulator.c new file +12 -0
+static int da9055_map_voltage(struct regulator_dev *rdev,
+			      int min_uV, int max_uV)
+{
+	struct da9055_regulator *regulator = rdev_get_drvdata(rdev);
+	struct da9055_regulator_info *info = regulator->info;
+	int ret, sel;
+
+	ret = verify_range(info, min_uV, max_uV);
+	if (ret < 0)
+		return ret;
+
+	if (min_uV < info->min_uV)

drivers/regulator/da9055-regulator.c line 256

Quoted 10 lines
drivers/regulator/da9055-regulator.c new file +10 -0
+		min_uV = info->min_uV;
+
+	sel = DIV_ROUND_UP(min_uV - info->min_uV, info->step_uV);
+
+	ret = da9055_list_voltage(rdev, sel);
+	if (ret < 0)
+		return ret;
+
+	return sel;
+}

This is regulator_map_voltage_linear().

drivers/regulator/da9055-regulator.c line 525

Quoted 3 lines
drivers/regulator/da9055-regulator.c new file +2 -0
+             int gpio = pdata->gpio_base + pdata->gpio_ren[id];
 
+		sprintf(name, "DA9055 REG %d STATE", id);

snprintf().

drivers/regulator/da9055-regulator.c line 531

Quoted 5 lines
drivers/regulator/da9055-regulator.c new file +5 -0
+		/* Set the GPIO I/P pin for controlling the regulator state. */
+		ret = devm_gpio_request_one(config->dev, gpio, GPIOF_DIR_IN,
+					    name);
+		if (ret < 0)
+			goto err;

We never actually appear to use this GPIO anywhere... why are we requesting it? Also, why is the ability to read the regulator state via a GPIO associated with controlling it via a GPIO, it's unusual for these things to be tied together.