Skip to content

Commit

Permalink
Merge remote-tracking branches 'regulator/topic/arizona', 'regulator/…
Browse files Browse the repository at this point in the history
…topic/axp20' and 'regulator/topic/bcm590xx' into regulator-next
  • Loading branch information
Mark Brown committed Jun 2, 2014
4 parents 42398db + 7b22b9a + b887035 + bfbc344 commit 8ff15e0
Show file tree
Hide file tree
Showing 14 changed files with 593 additions and 72 deletions.
4 changes: 3 additions & 1 deletion Documentation/devicetree/bindings/mfd/bcm590xx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ Optional child nodes:
The valid regulator node names for BCM59056 are:
rfldo, camldo1, camldo2, simldo1, simldo2, sdldo, sdxldo,
mmcldo1, mmcldo2, audldo, micldo, usbldo, vibldo,
csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr
csr, iosr1, iosr2, msr, sdsr1, sdsr2, vsr,
gpldo1, gpldo2, gpldo3, gpldo4, gpldo5, gpldo6,
vbus

Example:
pmu: bcm59056@8 {
Expand Down
41 changes: 24 additions & 17 deletions drivers/mfd/arizona-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,19 +508,31 @@ int arizona_of_get_type(struct device *dev)
}
EXPORT_SYMBOL_GPL(arizona_of_get_type);

int arizona_of_get_named_gpio(struct arizona *arizona, const char *prop,
bool mandatory)
{
int gpio;

gpio = of_get_named_gpio(arizona->dev->of_node, prop, 0);
if (gpio < 0) {
if (mandatory)
dev_err(arizona->dev,
"Mandatory DT gpio %s missing/malformed: %d\n",
prop, gpio);

gpio = 0;
}

return gpio;
}
EXPORT_SYMBOL_GPL(arizona_of_get_named_gpio);

static int arizona_of_get_core_pdata(struct arizona *arizona)
{
struct arizona_pdata *pdata = &arizona->pdata;
int ret, i;

arizona->pdata.reset = of_get_named_gpio(arizona->dev->of_node,
"wlf,reset", 0);
if (arizona->pdata.reset < 0)
arizona->pdata.reset = 0;

arizona->pdata.ldoena = of_get_named_gpio(arizona->dev->of_node,
"wlf,ldoena", 0);
if (arizona->pdata.ldoena < 0)
arizona->pdata.ldoena = 0;
pdata->reset = arizona_of_get_named_gpio(arizona, "wlf,reset", true);

ret = of_property_read_u32_array(arizona->dev->of_node,
"wlf,gpio-defaults",
Expand Down Expand Up @@ -652,6 +664,9 @@ int arizona_dev_init(struct arizona *arizona)
return -EINVAL;
}

/* Mark DCVDD as external, LDO1 driver will clear if internal */
arizona->external_dcvdd = true;

ret = mfd_add_devices(arizona->dev, -1, early_devs,
ARRAY_SIZE(early_devs), NULL, 0, NULL);
if (ret != 0) {
Expand Down Expand Up @@ -851,14 +866,6 @@ int arizona_dev_init(struct arizona *arizona)
arizona->pdata.gpio_defaults[i]);
}

/*
* LDO1 can only be used to supply DCVDD so if it has no
* consumers then DCVDD is supplied externally.
*/
if (arizona->pdata.ldo1 &&
arizona->pdata.ldo1->num_consumer_supplies == 0)
arizona->external_dcvdd = true;

pm_runtime_set_autosuspend_delay(arizona->dev, 100);
pm_runtime_use_autosuspend(arizona->dev);
pm_runtime_enable(arizona->dev);
Expand Down
60 changes: 46 additions & 14 deletions drivers/mfd/bcm590xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,71 @@ static const struct mfd_cell bcm590xx_devs[] = {
},
};

static const struct regmap_config bcm590xx_regmap_config = {
static const struct regmap_config bcm590xx_regmap_config_pri = {
.reg_bits = 8,
.val_bits = 8,
.max_register = BCM590XX_MAX_REGISTER,
.max_register = BCM590XX_MAX_REGISTER_PRI,
.cache_type = REGCACHE_RBTREE,
};

static int bcm590xx_i2c_probe(struct i2c_client *i2c,
static const struct regmap_config bcm590xx_regmap_config_sec = {
.reg_bits = 8,
.val_bits = 8,
.max_register = BCM590XX_MAX_REGISTER_SEC,
.cache_type = REGCACHE_RBTREE,
};

static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri,
const struct i2c_device_id *id)
{
struct bcm590xx *bcm590xx;
int ret;

bcm590xx = devm_kzalloc(&i2c->dev, sizeof(*bcm590xx), GFP_KERNEL);
bcm590xx = devm_kzalloc(&i2c_pri->dev, sizeof(*bcm590xx), GFP_KERNEL);
if (!bcm590xx)
return -ENOMEM;

i2c_set_clientdata(i2c, bcm590xx);
bcm590xx->dev = &i2c->dev;
bcm590xx->i2c_client = i2c;
i2c_set_clientdata(i2c_pri, bcm590xx);
bcm590xx->dev = &i2c_pri->dev;
bcm590xx->i2c_pri = i2c_pri;

bcm590xx->regmap = devm_regmap_init_i2c(i2c, &bcm590xx_regmap_config);
if (IS_ERR(bcm590xx->regmap)) {
ret = PTR_ERR(bcm590xx->regmap);
dev_err(&i2c->dev, "regmap initialization failed: %d\n", ret);
bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri,
&bcm590xx_regmap_config_pri);
if (IS_ERR(bcm590xx->regmap_pri)) {
ret = PTR_ERR(bcm590xx->regmap_pri);
dev_err(&i2c_pri->dev, "primary regmap init failed: %d\n", ret);
return ret;
}

ret = mfd_add_devices(&i2c->dev, -1, bcm590xx_devs,
/* Secondary I2C slave address is the base address with A(2) asserted */
bcm590xx->i2c_sec = i2c_new_dummy(i2c_pri->adapter,
i2c_pri->addr | BIT(2));
if (IS_ERR_OR_NULL(bcm590xx->i2c_sec)) {
dev_err(&i2c_pri->dev, "failed to add secondary I2C device\n");
return -ENODEV;
}
i2c_set_clientdata(bcm590xx->i2c_sec, bcm590xx);

bcm590xx->regmap_sec = devm_regmap_init_i2c(bcm590xx->i2c_sec,
&bcm590xx_regmap_config_sec);
if (IS_ERR(bcm590xx->regmap_sec)) {
ret = PTR_ERR(bcm590xx->regmap_sec);
dev_err(&bcm590xx->i2c_sec->dev,
"secondary regmap init failed: %d\n", ret);
goto err;
}

ret = mfd_add_devices(&i2c_pri->dev, -1, bcm590xx_devs,
ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL);
if (ret < 0)
dev_err(&i2c->dev, "failed to add sub-devices: %d\n", ret);
if (ret < 0) {
dev_err(&i2c_pri->dev, "failed to add sub-devices: %d\n", ret);
goto err;
}

return 0;

err:
i2c_unregister_device(bcm590xx->i2c_sec);
return ret;
}

Expand Down
41 changes: 25 additions & 16 deletions drivers/mfd/tps65090.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,6 @@
#define NUM_INT_REG 2
#define TOTAL_NUM_REG 0x18

/* interrupt status registers */
#define TPS65090_INT_STS 0x0
#define TPS65090_INT_STS2 0x1

/* interrupt mask registers */
#define TPS65090_INT_MSK 0x2
#define TPS65090_INT_MSK2 0x3

#define TPS65090_INT1_MASK_VAC_STATUS_CHANGE 1
#define TPS65090_INT1_MASK_VSYS_STATUS_CHANGE 2
#define TPS65090_INT1_MASK_BAT_STATUS_CHANGE 3
Expand All @@ -64,11 +56,16 @@ static struct resource charger_resources[] = {
}
};

static const struct mfd_cell tps65090s[] = {
{
enum tps65090_cells {
PMIC = 0,
CHARGER = 1,
};

static struct mfd_cell tps65090s[] = {
[PMIC] = {
.name = "tps65090-pmic",
},
{
[CHARGER] = {
.name = "tps65090-charger",
.num_resources = ARRAY_SIZE(charger_resources),
.resources = &charger_resources[0],
Expand Down Expand Up @@ -139,17 +136,26 @@ static struct regmap_irq_chip tps65090_irq_chip = {
.irqs = tps65090_irqs,
.num_irqs = ARRAY_SIZE(tps65090_irqs),
.num_regs = NUM_INT_REG,
.status_base = TPS65090_INT_STS,
.mask_base = TPS65090_INT_MSK,
.status_base = TPS65090_REG_INTR_STS,
.mask_base = TPS65090_REG_INTR_MASK,
.mask_invert = true,
};

static bool is_volatile_reg(struct device *dev, unsigned int reg)
{
if ((reg == TPS65090_INT_STS) || (reg == TPS65090_INT_STS2))
return true;
else
/* Nearly all registers have status bits mixed in, except a few */
switch (reg) {
case TPS65090_REG_INTR_MASK:
case TPS65090_REG_INTR_MASK2:
case TPS65090_REG_CG_CTRL0:
case TPS65090_REG_CG_CTRL1:
case TPS65090_REG_CG_CTRL2:
case TPS65090_REG_CG_CTRL3:
case TPS65090_REG_CG_CTRL4:
case TPS65090_REG_CG_CTRL5:
return false;
}
return true;
}

static const struct regmap_config tps65090_regmap_config = {
Expand Down Expand Up @@ -211,6 +217,9 @@ static int tps65090_i2c_probe(struct i2c_client *client,
"IRQ init failed with err: %d\n", ret);
return ret;
}
} else {
/* Don't tell children they have an IRQ that'll never fire */
tps65090s[CHARGER].num_resources = 0;
}

ret = mfd_add_devices(tps65090->dev, -1, tps65090s,
Expand Down
11 changes: 0 additions & 11 deletions drivers/power/tps65090-charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@

#include <linux/mfd/tps65090.h>

#define TPS65090_REG_INTR_STS 0x00
#define TPS65090_REG_INTR_MASK 0x02
#define TPS65090_REG_CG_CTRL0 0x04
#define TPS65090_REG_CG_CTRL1 0x05
#define TPS65090_REG_CG_CTRL2 0x06
#define TPS65090_REG_CG_CTRL3 0x07
#define TPS65090_REG_CG_CTRL4 0x08
#define TPS65090_REG_CG_CTRL5 0x09
#define TPS65090_REG_CG_STATUS1 0x0a
#define TPS65090_REG_CG_STATUS2 0x0b

#define TPS65090_CHARGER_ENABLE BIT(0)
#define TPS65090_VACG BIT(1)
#define TPS65090_NOITERM BIT(5)
Expand Down
7 changes: 7 additions & 0 deletions drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ config REGULATOR_AS3722
AS3722 PMIC. This will enable support for all the software
controllable DCDC/LDO regulators.

config REGULATOR_AXP20X
tristate "X-POWERS AXP20X PMIC Regulators"
depends on MFD_AXP20X
help
This driver provides support for the voltage regulators on the
AXP20X PMIC.

config REGULATOR_BCM590XX
tristate "Broadcom BCM590xx PMU Regulators"
depends on MFD_BCM590XX
Expand Down
1 change: 1 addition & 0 deletions drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
Expand Down
58 changes: 58 additions & 0 deletions drivers/regulator/arizona-ldo1.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
#include <linux/init.h>
#include <linux/bitops.h>
#include <linux/err.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/gpio.h>
#include <linux/slab.h>

Expand Down Expand Up @@ -178,6 +180,42 @@ static const struct regulator_init_data arizona_ldo1_default = {
.num_consumer_supplies = 1,
};

static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
struct regulator_config *config)
{
struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_ldo1 *ldo1 = config->driver_data;
struct device_node *init_node, *dcvdd_node;
struct regulator_init_data *init_data;

pdata->ldoena = arizona_of_get_named_gpio(arizona, "wlf,ldoena", true);

init_node = of_get_child_by_name(arizona->dev->of_node, "ldo1");
dcvdd_node = of_parse_phandle(arizona->dev->of_node, "DCVDD-supply", 0);

if (init_node) {
config->of_node = init_node;

init_data = of_get_regulator_init_data(arizona->dev, init_node);

if (init_data) {
init_data->consumer_supplies = &ldo1->supply;
init_data->num_consumer_supplies = 1;

if (dcvdd_node && dcvdd_node != init_node)
arizona->external_dcvdd = true;

pdata->ldo1 = init_data;
}
} else if (dcvdd_node) {
arizona->external_dcvdd = true;
}

of_node_put(dcvdd_node);

return 0;
}

static int arizona_ldo1_probe(struct platform_device *pdev)
{
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
Expand All @@ -186,6 +224,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
struct arizona_ldo1 *ldo1;
int ret;

arizona->external_dcvdd = false;

ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
if (!ldo1)
return -ENOMEM;
Expand Down Expand Up @@ -216,13 +256,29 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
config.dev = arizona->dev;
config.driver_data = ldo1;
config.regmap = arizona->regmap;

if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) {
ret = arizona_ldo1_of_get_pdata(arizona, &config);
if (ret < 0)
return ret;
}
}

config.ena_gpio = arizona->pdata.ldoena;

if (arizona->pdata.ldo1)
config.init_data = arizona->pdata.ldo1;
else
config.init_data = &ldo1->init_data;

/*
* LDO1 can only be used to supply DCVDD so if it has no
* consumers then DCVDD is supplied externally.
*/
if (config.init_data->num_consumer_supplies == 0)
arizona->external_dcvdd = true;

ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);
if (IS_ERR(ldo1->regulator)) {
ret = PTR_ERR(ldo1->regulator);
Expand All @@ -231,6 +287,8 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
return ret;
}

of_node_put(config.of_node);

platform_set_drvdata(pdev, ldo1);

return 0;
Expand Down
Loading

0 comments on commit 8ff15e0

Please sign in to comment.