Skip to content

Commit

Permalink
Merge remote-tracking branches 'regulator/topic/anatop', 'regulator/t…
Browse files Browse the repository at this point in the history
…opic/arizona', 'regulator/topic/bd9571mvw-m' and 'regulator/topic/const' into regulator-next
  • Loading branch information
broonie committed Apr 30, 2017
5 parents bde1e61 + 0e69c2e + af367af + e85c5a1 + 5339c34 commit 59e4c63
Show file tree
Hide file tree
Showing 18 changed files with 448 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Anatop Voltage regulators

Required properties:
- compatible: Must be "fsl,anatop-regulator"
- regulator-name: A string used as a descriptive name for regulator outputs
- anatop-reg-offset: Anatop MFD register offset
- anatop-vol-bit-shift: Bit shift for the register
- anatop-vol-bit-width: Number of bits used in the register
Expand Down
2 changes: 2 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -13631,12 +13631,14 @@ F: drivers/mfd/cs47l24*
F: drivers/power/supply/wm83*.c
F: drivers/rtc/rtc-wm83*.c
F: drivers/regulator/wm8*.c
F: drivers/regulator/arizona*
F: drivers/video/backlight/wm83*_bl.c
F: drivers/watchdog/wm83*_wdt.c
F: include/linux/mfd/arizona/
F: include/linux/mfd/wm831x/
F: include/linux/mfd/wm8350/
F: include/linux/mfd/wm8400*
F: include/linux/regulator/arizona*
F: include/linux/wm97xx.h
F: include/sound/wm????.h
F: sound/soc/codecs/arizona.?
Expand Down
8 changes: 6 additions & 2 deletions arch/arm/mach-s3c64xx/mach-crag6410-module.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ static const struct i2c_board_info wm1277_devs[] = {
};

static struct arizona_pdata wm5102_reva_pdata = {
.ldoena = S3C64XX_GPN(7),
.ldo1 = {
.ldoena = S3C64XX_GPN(7),
},
.gpio_base = CODEC_GPIO_BASE,
.irq_flags = IRQF_TRIGGER_HIGH,
.micd_pol_gpio = CODEC_GPIO_BASE + 4,
Expand Down Expand Up @@ -239,7 +241,9 @@ static struct spi_board_info wm5102_reva_spi_devs[] = {
};

static struct arizona_pdata wm5102_pdata = {
.ldoena = S3C64XX_GPN(7),
.ldo1 = {
.ldoena = S3C64XX_GPN(7),
},
.gpio_base = CODEC_GPIO_BASE,
.irq_flags = IRQF_TRIGGER_HIGH,
.micd_pol_gpio = CODEC_GPIO_BASE + 2,
Expand Down
25 changes: 22 additions & 3 deletions drivers/regulator/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,20 @@ config REGULATOR_AB8500
This driver supports the regulators found on the ST-Ericsson mixed
signal AB8500 PMIC

config REGULATOR_ARIZONA
tristate "Wolfson Arizona class devices"
config REGULATOR_ARIZONA_LDO1
tristate "Wolfson Arizona class devices LDO1"
depends on MFD_ARIZONA
depends on SND_SOC
help
Support for the regulators found on Wolfson Arizona class
Support for the LDO1 regulators found on Wolfson Arizona class
devices.

config REGULATOR_ARIZONA_MICSUPP
tristate "Wolfson Arizona class devices MICSUPP"
depends on MFD_ARIZONA
depends on SND_SOC
help
Support for the MICSUPP regulators found on Wolfson Arizona class
devices.

config REGULATOR_AS3711
Expand Down Expand Up @@ -163,6 +171,17 @@ config REGULATOR_BCM590XX
BCM590xx PMUs. This will enable support for the software
controllable LDO/Switching regulators.

config REGULATOR_BD9571MWV
tristate "ROHM BD9571MWV Regulators"
depends on MFD_BD9571MWV
help
This driver provides support for the voltage regulators on the
ROHM BD9571MWV PMIC. This will enable support for the software
controllable regulator and voltage sampling units.

This driver can also be built as a module. If so, the module
will be called bd9571mwv-regulator.

config REGULATOR_CPCAP
tristate "Motorola CPCAP regulator"
depends on MFD_CPCAP
Expand Down
4 changes: 3 additions & 1 deletion drivers/regulator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o
obj-$(CONFIG_REGULATOR_ACT8945A) += act8945a-regulator.o
obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
obj-$(CONFIG_REGULATOR_ARIZONA_LDO1) += arizona-ldo1.o
obj-$(CONFIG_REGULATOR_ARIZONA_MICSUPP) += arizona-micsupp.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_BD9571MWV) += bd9571mwv-regulator.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
Expand Down
19 changes: 15 additions & 4 deletions drivers/regulator/anatop-regulator.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#define LDO_FET_FULL_ON 0x1f

struct anatop_regulator {
const char *name;
u32 control_reg;
struct regmap *anatop;
int vol_bit_shift;
Expand Down Expand Up @@ -193,13 +192,21 @@ static int anatop_regulator_probe(struct platform_device *pdev)
sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL);
if (!sreg)
return -ENOMEM;
sreg->name = of_get_property(np, "regulator-name", NULL);

rdesc = &sreg->rdesc;
rdesc->name = sreg->name;
rdesc->type = REGULATOR_VOLTAGE;
rdesc->owner = THIS_MODULE;

of_property_read_string(np, "regulator-name", &rdesc->name);
if (!rdesc->name) {
dev_err(dev, "failed to get a regulator-name\n");
return -EINVAL;
}

initdata = of_get_regulator_init_data(dev, np, rdesc);
if (!initdata)
return -ENOMEM;

initdata->supply_regulator = "vin";
sreg->initdata = initdata;

Expand Down Expand Up @@ -293,9 +300,13 @@ static int anatop_regulator_probe(struct platform_device *pdev)
* a sane default until imx6-cpufreq was probed and changes the
* voltage to the correct value. In this case we set 1.25V.
*/
if (!sreg->sel && !strcmp(sreg->name, "vddpu"))
if (!sreg->sel && !strcmp(rdesc->name, "vddpu"))
sreg->sel = 22;

/* set the default voltage of the pcie phy to be 1.100v */
if (!sreg->sel && !strcmp(rdesc->name, "vddpcie"))
sreg->sel = 0x10;

if (!sreg->bypass && !sreg->sel) {
dev_err(&pdev->dev, "Failed to read a valid default voltage selector.\n");
return -EINVAL;
Expand Down
140 changes: 81 additions & 59 deletions drivers/regulator/arizona-ldo1.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
#include <linux/gpio.h>
#include <linux/slab.h>

#include <linux/regulator/arizona-ldo1.h>

#include <linux/mfd/arizona/core.h>
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>

struct arizona_ldo1 {
struct regulator_dev *regulator;
struct arizona *arizona;
struct regmap *regmap;

struct regulator_consumer_supply supply;
struct regulator_init_data init_data;
Expand Down Expand Up @@ -65,7 +67,7 @@ static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev,
unsigned sel)
{
struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev);
struct regmap *regmap = ldo->arizona->regmap;
struct regmap *regmap = ldo->regmap;
unsigned int val;
int ret;

Expand All @@ -91,7 +93,7 @@ static int arizona_ldo1_hc_set_voltage_sel(struct regulator_dev *rdev,
static int arizona_ldo1_hc_get_voltage_sel(struct regulator_dev *rdev)
{
struct arizona_ldo1 *ldo = rdev_get_drvdata(rdev);
struct regmap *regmap = ldo->arizona->regmap;
struct regmap *regmap = ldo->regmap;
unsigned int val;
int ret;

Expand Down Expand Up @@ -186,19 +188,19 @@ static const struct regulator_init_data arizona_ldo1_wm5110 = {
.num_consumer_supplies = 1,
};

static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
struct regulator_config *config,
const struct regulator_desc *desc)
const struct regulator_desc *desc,
bool *external_dcvdd)
{
struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_ldo1 *ldo1 = config->driver_data;
struct device_node *np = arizona->dev->of_node;
struct device_node *np = config->dev->of_node;
struct device_node *init_node, *dcvdd_node;
struct regulator_init_data *init_data;

pdata->ldoena = of_get_named_gpio(np, "wlf,ldoena", 0);
if (pdata->ldoena < 0) {
dev_warn(arizona->dev,
dev_warn(config->dev,
"LDOENA GPIO property missing/malformed: %d\n",
pdata->ldoena);
pdata->ldoena = 0;
Expand All @@ -212,87 +214,60 @@ static int arizona_ldo1_of_get_pdata(struct arizona *arizona,
if (init_node) {
config->of_node = init_node;

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

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;
*external_dcvdd = true;

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

of_node_put(dcvdd_node);

return 0;
}

static int arizona_ldo1_probe(struct platform_device *pdev)
static int arizona_ldo1_common_init(struct platform_device *pdev,
struct arizona_ldo1 *ldo1,
const struct regulator_desc *desc,
struct arizona_ldo1_pdata *pdata,
bool *external_dcvdd)
{
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
const struct regulator_desc *desc;
struct device *parent_dev = pdev->dev.parent;
struct regulator_config config = { };
struct arizona_ldo1 *ldo1;
int ret;

arizona->external_dcvdd = false;

ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
if (!ldo1)
return -ENOMEM;

ldo1->arizona = arizona;

/*
* Since the chip usually supplies itself we provide some
* default init_data for it. This will be overridden with
* platform data if provided.
*/
switch (arizona->type) {
case WM5102:
case WM8997:
case WM8998:
case WM1814:
desc = &arizona_ldo1_hc;
ldo1->init_data = arizona_ldo1_dvfs;
break;
case WM5110:
case WM8280:
desc = &arizona_ldo1;
ldo1->init_data = arizona_ldo1_wm5110;
break;
default:
desc = &arizona_ldo1;
ldo1->init_data = arizona_ldo1_default;
break;
}
*external_dcvdd = false;

ldo1->init_data.consumer_supplies = &ldo1->supply;
ldo1->supply.supply = "DCVDD";
ldo1->supply.dev_name = dev_name(arizona->dev);
ldo1->init_data.consumer_supplies = &ldo1->supply;
ldo1->supply.dev_name = dev_name(parent_dev);

config.dev = arizona->dev;
config.dev = parent_dev;
config.driver_data = ldo1;
config.regmap = arizona->regmap;
config.regmap = ldo1->regmap;

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

config.ena_gpio = arizona->pdata.ldoena;
config.ena_gpio = pdata->ldoena;

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

Expand All @@ -301,15 +276,15 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
* consumers then DCVDD is supplied externally.
*/
if (config.init_data->num_consumer_supplies == 0)
arizona->external_dcvdd = true;
*external_dcvdd = true;

ldo1->regulator = devm_regulator_register(&pdev->dev, desc, &config);

of_node_put(config.of_node);

if (IS_ERR(ldo1->regulator)) {
ret = PTR_ERR(ldo1->regulator);
dev_err(arizona->dev, "Failed to register LDO1 supply: %d\n",
dev_err(&pdev->dev, "Failed to register LDO1 supply: %d\n",
ret);
return ret;
}
Expand All @@ -319,6 +294,53 @@ static int arizona_ldo1_probe(struct platform_device *pdev)
return 0;
}

static int arizona_ldo1_probe(struct platform_device *pdev)
{
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
struct arizona_ldo1 *ldo1;
const struct regulator_desc *desc;
bool external_dcvdd;
int ret;

ldo1 = devm_kzalloc(&pdev->dev, sizeof(*ldo1), GFP_KERNEL);
if (!ldo1)
return -ENOMEM;

ldo1->regmap = arizona->regmap;

/*
* Since the chip usually supplies itself we provide some
* default init_data for it. This will be overridden with
* platform data if provided.
*/
switch (arizona->type) {
case WM5102:
case WM8997:
case WM8998:
case WM1814:
desc = &arizona_ldo1_hc;
ldo1->init_data = arizona_ldo1_dvfs;
break;
case WM5110:
case WM8280:
desc = &arizona_ldo1;
ldo1->init_data = arizona_ldo1_wm5110;
break;
default:
desc = &arizona_ldo1;
ldo1->init_data = arizona_ldo1_default;
break;
}

ret = arizona_ldo1_common_init(pdev, ldo1, desc,
&arizona->pdata.ldo1,
&external_dcvdd);
if (ret == 0)
arizona->external_dcvdd = external_dcvdd;

return ret;
}

static struct platform_driver arizona_ldo1_driver = {
.probe = arizona_ldo1_probe,
.driver = {
Expand Down
Loading

0 comments on commit 59e4c63

Please sign in to comment.