Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343157
b: refs/heads/master
c: f329b17
h: refs/heads/master
i:
  343155: 749375d
v: v3
  • Loading branch information
Laxman Dewangan authored and Mark Brown committed Oct 17, 2012
1 parent 55f1748 commit f75496a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 22 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3a81ef8c27cea5c749a45765da4e06a7af75be2b
refs/heads/master: f329b1755b475f64f0472cda1ae9602e092f6f05
77 changes: 57 additions & 20 deletions trunk/drivers/regulator/tps65090-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <linux/module.h>
#include <linux/init.h>
#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/err.h>
#include <linux/platform_device.h>
Expand All @@ -31,10 +32,13 @@ struct tps65090_regulator {
struct regulator_dev *rdev;
};

static struct regulator_ops tps65090_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
static struct regulator_ops tps65090_ext_control_ops = {
};

static struct regulator_ops tps65090_reg_contol_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
};

static struct regulator_ops tps65090_ldo_ops = {
Expand All @@ -53,16 +57,16 @@ static struct regulator_ops tps65090_ldo_ops = {
}

static struct regulator_desc tps65090_regulator_desc[] = {
tps65090_REG_DESC(DCDC1, "vsys1", 0x0C, tps65090_ops),
tps65090_REG_DESC(DCDC2, "vsys2", 0x0D, tps65090_ops),
tps65090_REG_DESC(DCDC3, "vsys3", 0x0E, tps65090_ops),
tps65090_REG_DESC(FET1, "infet1", 0x0F, tps65090_ops),
tps65090_REG_DESC(FET2, "infet2", 0x10, tps65090_ops),
tps65090_REG_DESC(FET3, "infet3", 0x11, tps65090_ops),
tps65090_REG_DESC(FET4, "infet4", 0x12, tps65090_ops),
tps65090_REG_DESC(FET5, "infet5", 0x13, tps65090_ops),
tps65090_REG_DESC(FET6, "infet6", 0x14, tps65090_ops),
tps65090_REG_DESC(FET7, "infet7", 0x15, tps65090_ops),
tps65090_REG_DESC(DCDC1, "vsys1", 0x0C, tps65090_reg_contol_ops),
tps65090_REG_DESC(DCDC2, "vsys2", 0x0D, tps65090_reg_contol_ops),
tps65090_REG_DESC(DCDC3, "vsys3", 0x0E, tps65090_reg_contol_ops),
tps65090_REG_DESC(FET1, "infet1", 0x0F, tps65090_reg_contol_ops),
tps65090_REG_DESC(FET2, "infet2", 0x10, tps65090_reg_contol_ops),
tps65090_REG_DESC(FET3, "infet3", 0x11, tps65090_reg_contol_ops),
tps65090_REG_DESC(FET4, "infet4", 0x12, tps65090_reg_contol_ops),
tps65090_REG_DESC(FET5, "infet5", 0x13, tps65090_reg_contol_ops),
tps65090_REG_DESC(FET6, "infet6", 0x14, tps65090_reg_contol_ops),
tps65090_REG_DESC(FET7, "infet7", 0x15, tps65090_reg_contol_ops),
tps65090_REG_DESC(LDO1, "vsys_l1", 0, tps65090_ldo_ops),
tps65090_REG_DESC(LDO2, "vsys_l2", 0, tps65090_ldo_ops),
};
Expand Down Expand Up @@ -118,6 +122,22 @@ static int __devinit tps65090_regulator_disable_ext_control(
return tps65090_config_ext_control(ri, false);
}

static void __devinit tps65090_configure_regulator_config(
struct tps65090_regulator_plat_data *tps_pdata,
struct regulator_config *config)
{
if (gpio_is_valid(tps_pdata->gpio)) {
int gpio_flag = GPIOF_OUT_INIT_LOW;

if (tps_pdata->reg_init_data->constraints.always_on ||
tps_pdata->reg_init_data->constraints.boot_on)
gpio_flag = GPIOF_OUT_INIT_HIGH;

config->ena_gpio = tps_pdata->gpio;
config->ena_gpio_flags = gpio_flag;
}
}

static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
{
struct tps65090 *tps65090_mfd = dev_get_drvdata(pdev->dev.parent);
Expand Down Expand Up @@ -154,18 +174,24 @@ static int __devinit tps65090_regulator_probe(struct platform_device *pdev)

/*
* TPS5090 DCDC support the control from external digital input.
* It may be possible that during boot, the external control is
* enabled. Disabling external control for DCDC.
* Configure it as per platform data.
*/
if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data) {
ret = tps65090_regulator_disable_ext_control(
if (tps_pdata->enable_ext_control) {
tps65090_configure_regulator_config(
tps_pdata, &config);
ri->desc->ops = &tps65090_ext_control_ops;
} else {
ret = tps65090_regulator_disable_ext_control(
ri, tps_pdata);
if (ret < 0) {
dev_err(&pdev->dev,
if (ret < 0) {
dev_err(&pdev->dev,
"failed disable ext control\n");
goto scrub;
goto scrub;
}
}
}

config.dev = &pdev->dev;
config.driver_data = ri;
config.regmap = tps65090_mfd->rmap;
Expand All @@ -182,6 +208,17 @@ static int __devinit tps65090_regulator_probe(struct platform_device *pdev)
goto scrub;
}
ri->rdev = rdev;

/* Enable external control if it is require */
if (tps_pdata && is_dcdc(num) && tps_pdata->reg_init_data &&
tps_pdata->enable_ext_control) {
ret = tps65090_config_ext_control(ri, true);
if (ret < 0) {
/* Increment num to get unregister rdev */
num++;
goto scrub;
}
}
}

platform_set_drvdata(pdev, pmic);
Expand Down
7 changes: 6 additions & 1 deletion trunk/include/linux/mfd/tps65090.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,15 @@ struct tps65090_subdev_info {
* struct tps65090_regulator_plat_data
*
* @reg_init_data: The regulator init data.
* @enable_ext_control: Enable extrenal control or not. Only available for
* DCDC1, DCDC2 and DCDC3.
* @gpio: Gpio number if external control is enabled and controlled through
* gpio.
*/

struct tps65090_regulator_plat_data {
struct regulator_init_data *reg_init_data;
bool enable_ext_control;
int gpio;
};

struct tps65090_platform_data {
Expand Down

0 comments on commit f75496a

Please sign in to comment.