Commit ec1882a9 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'regulator-v3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator

Pull regulator updates from Mark Brown:
 "Not much exciting going on with the regulator API this time around,
  lots of driver fixes and enhancements - the main thing is the addition
  of a new API to help make the stubbing code do the right thing for
  missing regulator mappings.

  Highlights:

   - A new regulator_get_optional() API call for regulators that can be
     absent in normal operation.  This currently does nothing but will
     be used to improve the stubbing code for unspecified regulators,
     helping avoid some of the issues we've seen with adding new
     regulator support.
   - Helpers for devices with multiple linear ranges of voltages in the
     same regulator.
   - Moved the helpers into a separate file since core.c is getting
     rather large.
   - New drivers for Dialog DA9210 and DA9063, Freescale pfuze100 and
     Marvell 88pm800"

* tag 'regulator-v3.12' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (70 commits)
  regulator: da9063: Statize da9063_ldo_lim_event
  regulator: lp872x: Make REGULATOR_LP872X depend on I2C rather than I2C=y
  regulator: tps65217: Convert to use linear ranges
  regulator: da9063: Use IS_ERR to check return value of regulator_register()
  regulator: da9063: Optimize da9063_set_current_limit implementation
  regulator: build: Allow most regulators to be built as modules
  regulator: Add devm_regulator_get_exclusive()
  regulator: da9063: Add Dialog DA9063 voltage regulators support.
  regulator: ti-abb: simplify platform_get_resource_byname/devm_ioremap_resource
  hwmon: (sht15) Use devm_regulator_get_optional()
  regulator: core: Use bool for exclusivitity flag
  regulator: 88pm800: forever loop in pm800_regulator_probe()
  cpufreq: cpufreq-cpu0: Use devm_regulator_get_optional()
  regulator: da9210: Remove redundant MODULE_ALIAS
  regulator: 88pm800: Fix checking whether num_regulator is valid
  regulator: s2mps11: Fix setting ramp_delay
  regulator: s2mps11: Fix wrong arguments for regmap_update_bits() call
  regulator: palmas: Update the DT binding doc for smps10 out1 and out2
  regulator: palmas: model SMPS10 as two regulators
  regulator: core: Move list_voltage_{linear,linear_range,table} to helpers.c
  ...
parents 5d3fed70 a5848622
Marvell 88PM800 regulator
Required properties:
- compatible: "marvell,88pm800"
- reg: I2C slave address
- regulators: A node that houses a sub-node for each regulator within the
device. Each sub-node is identified using the node's name (or the deprecated
regulator-compatible property if present), with valid values listed below.
The content of each sub-node is defined by the standard binding for
regulators; see regulator.txt.
The valid names for regulators are:
buck1, buck2, buck3, buck4, buck5, ldo1, ldo2, ldo3, ldo4, ldo5, ldo6, ldo7,
ldo8, ldo9, ldo10, ldo11, ldo12, ldo13, ldo14, ldo15, ldo16, ldo17, ldo18, ldo19
Example:
pmic: 88pm800@31 {
compatible = "marvell,88pm800";
reg = <0x31>;
regulators {
buck1 {
regulator-min-microvolt = <600000>;
regulator-max-microvolt = <3950000>;
regulator-boot-on;
regulator-always-on;
};
ldo1 {
regulator-min-microvolt = <600000>;
regulator-max-microvolt = <15000000>;
regulator-boot-on;
regulator-always-on;
};
...
};
};
Maxim MAX8660 voltage regulator
Required properties:
- compatible: must be one of "maxim,max8660", "maxim,max8661"
- reg: I2C slave address, usually 0x34
- any required generic properties defined in regulator.txt
Example:
i2c_master {
max8660@34 {
compatible = "maxim,max8660";
reg = <0x34>;
regulators {
regulator@0 {
regulator-compatible= "V3(DCDC)";
regulator-min-microvolt = <725000>;
regulator-max-microvolt = <1800000>;
};
regulator@1 {
regulator-compatible= "V4(DCDC)";
regulator-min-microvolt = <725000>;
regulator-max-microvolt = <1800000>;
};
regulator@2 {
regulator-compatible= "V5(LDO)";
regulator-min-microvolt = <1700000>;
regulator-max-microvolt = <2000000>;
};
regulator@3 {
regulator-compatible= "V6(LDO)";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
};
regulator@4 {
regulator-compatible= "V7(LDO)";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
};
};
};
};
......@@ -25,8 +25,8 @@ Optional nodes:
Additional custom properties are listed below.
For ti,palmas-pmic - smps12, smps123, smps3 depending on OTP,
smps45, smps457, smps7 depending on variant, smps6, smps[8-10],
ldo[1-9], ldoln, ldousb.
smps45, smps457, smps7 depending on variant, smps6, smps[8-9],
smps10_out2, smps10_out1, do[1-9], ldoln, ldousb.
Optional sub-node properties:
ti,warm-reset - maintain voltage during warm reset(boolean)
......
PFUZE100 family of regulators
Required properties:
- compatible: "fsl,pfuze100"
- reg: I2C slave address
Required child node:
- regulators: This is the list of child nodes that specify the regulator
initialization data for defined regulators. Please refer to below doc
Documentation/devicetree/bindings/regulator/regulator.txt.
The valid names for regulators are:
sw1ab,sw1c,sw2,sw3a,sw3b,sw4,swbst,vsnvs,vrefddr,vgen1~vgen6
Each regulator is defined using the standard binding for regulators.
Example:
pmic: pfuze100@08 {
compatible = "fsl,pfuze100";
reg = <0x08>;
regulators {
sw1a_reg: sw1ab {
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1875000>;
regulator-boot-on;
regulator-always-on;
regulator-ramp-delay = <6250>;
};
sw1c_reg: sw1c {
regulator-min-microvolt = <300000>;
regulator-max-microvolt = <1875000>;
regulator-boot-on;
regulator-always-on;
};
sw2_reg: sw2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
regulator-always-on;
};
sw3a_reg: sw3a {
regulator-min-microvolt = <400000>;
regulator-max-microvolt = <1975000>;
regulator-boot-on;
regulator-always-on;
};
sw3b_reg: sw3b {
regulator-min-microvolt = <400000>;
regulator-max-microvolt = <1975000>;
regulator-boot-on;
regulator-always-on;
};
sw4_reg: sw4 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <3300000>;
};
swbst_reg: swbst {
regulator-min-microvolt = <5000000>;
regulator-max-microvolt = <5150000>;
};
snvs_reg: vsnvs {
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <3000000>;
regulator-boot-on;
regulator-always-on;
};
vref_reg: vrefddr {
regulator-boot-on;
regulator-always-on;
};
vgen1_reg: vgen1 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
};
vgen2_reg: vgen2 {
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1550000>;
};
vgen3_reg: vgen3 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
};
vgen4_reg: vgen4 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen5_reg: vgen5 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
vgen6_reg: vgen6 {
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
};
};
};
......@@ -12,6 +12,8 @@ Optional properties:
- regulator-allow-bypass: allow the regulator to go into bypass mode
- <name>-supply: phandle to the parent supply/regulator node
- regulator-ramp-delay: ramp delay for regulator(in uV/uS)
For hardwares which support disabling ramp rate, it should be explicitly
intialised to zero (regulator-ramp-delay = <0>) for disabling ramp delay.
Deprecated properties:
- regulator-compatible: If a regulator chip contains multiple
......
......@@ -197,7 +197,7 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
cpu_dev = &pdev->dev;
cpu_dev->of_node = np;
cpu_reg = devm_regulator_get(cpu_dev, "cpu0");
cpu_reg = devm_regulator_get_optional(cpu_dev, "cpu0");
if (IS_ERR(cpu_reg)) {
/*
* If cpu0 regulator supply node is present, but regulator is
......
......@@ -957,7 +957,7 @@ static int sht15_probe(struct platform_device *pdev)
* If a regulator is available,
* query what the supply voltage actually is!
*/
data->reg = devm_regulator_get(data->dev, "vcc");
data->reg = devm_regulator_get_optional(data->dev, "vcc");
if (!IS_ERR(data->reg)) {
int voltage;
......
......@@ -1313,7 +1313,7 @@ int mmc_regulator_get_supply(struct mmc_host *mmc)
supply = devm_regulator_get(dev, "vmmc");
mmc->supply.vmmc = supply;
mmc->supply.vqmmc = devm_regulator_get(dev, "vqmmc");
mmc->supply.vqmmc = devm_regulator_get_optional(dev, "vqmmc");
if (IS_ERR(supply))
return PTR_ERR(supply);
......
......@@ -2231,7 +2231,7 @@ int dw_mci_probe(struct dw_mci *host)
}
}
host->vmmc = devm_regulator_get(host->dev, "vmmc");
host->vmmc = devm_regulator_get_optional(host->dev, "vmmc");
if (IS_ERR(host->vmmc)) {
ret = PTR_ERR(host->vmmc);
if (ret == -EPROBE_DEFER)
......
......@@ -83,7 +83,7 @@ struct pxamci_host {
static inline void pxamci_init_ocr(struct pxamci_host *host)
{
#ifdef CONFIG_REGULATOR
host->vcc = regulator_get(mmc_dev(host->mmc), "vmmc");
host->vcc = regulator_get_optional(mmc_dev(host->mmc), "vmmc");
if (IS_ERR(host->vcc))
host->vcc = NULL;
......
......@@ -2966,7 +2966,7 @@ int sdhci_add_host(struct sdhci_host *host)
mmc->caps |= MMC_CAP_NEEDS_POLL;
/* If vqmmc regulator and no 1.8V signalling, then there's no UHS */
host->vqmmc = regulator_get(mmc_dev(mmc), "vqmmc");
host->vqmmc = regulator_get_optional(mmc_dev(mmc), "vqmmc");
if (IS_ERR_OR_NULL(host->vqmmc)) {
if (PTR_ERR(host->vqmmc) < 0) {
pr_info("%s: no vqmmc regulator found\n",
......@@ -3042,7 +3042,7 @@ int sdhci_add_host(struct sdhci_host *host)
ocr_avail = 0;
host->vmmc = regulator_get(mmc_dev(mmc), "vmmc");
host->vmmc = regulator_get_optional(mmc_dev(mmc), "vmmc");
if (IS_ERR_OR_NULL(host->vmmc)) {
if (PTR_ERR(host->vmmc) < 0) {
pr_info("%s: no vmmc regulator found\n",
......
This diff is collapsed.
......@@ -346,7 +346,7 @@ static int pm8607_regulator_probe(struct platform_device *pdev)
{
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct pm8607_regulator_info *info = NULL;
struct regulator_init_data *pdata = pdev->dev.platform_data;
struct regulator_init_data *pdata = dev_get_platdata(&pdev->dev);
struct regulator_config config = { };
struct resource *res;
int i;
......
This diff is collapsed.
......@@ -3,12 +3,13 @@
#
obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o
obj-$(CONFIG_REGULATOR) += core.o dummy.o fixed-helper.o helpers.o
obj-$(CONFIG_OF) += of_regulator.o
obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
obj-$(CONFIG_REGULATOR_88PM800) += 88pm800.o
obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
......@@ -20,6 +21,8 @@ obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
obj-$(CONFIG_REGULATOR_DA9055) += da9055-regulator.o
obj-$(CONFIG_REGULATOR_DA9063) += da9063-regulator.o
obj-$(CONFIG_REGULATOR_DA9210) += da9210-regulator.o
obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o
......@@ -46,12 +49,14 @@ obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o
obj-$(CONFIG_REGULATOR_TPS65023) += tps65023-regulator.o
......@@ -64,7 +69,6 @@ obj-$(CONFIG_REGULATOR_TPS65910) += tps65910-regulator.o
obj-$(CONFIG_REGULATOR_TPS65912) += tps65912-regulator.o
obj-$(CONFIG_REGULATOR_TPS80031) += tps80031-regulator.o
obj-$(CONFIG_REGULATOR_TWL4030) += twl-regulator.o
obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
obj-$(CONFIG_REGULATOR_VEXPRESS) += vexpress.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-dcdc.o
obj-$(CONFIG_REGULATOR_WM831X) += wm831x-isink.o
......
......@@ -174,7 +174,7 @@ static int aat2870_regulator_probe(struct platform_device *pdev)
config.dev = &pdev->dev;
config.driver_data = ri;
config.init_data = pdev->dev.platform_data;
config.init_data = dev_get_platdata(&pdev->dev);
rdev = regulator_register(&ri->desc, &config);
if (IS_ERR(rdev)) {
......
......@@ -660,7 +660,7 @@ ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
static int ab3100_regulators_probe(struct platform_device *pdev)
{
struct ab3100_platform_data *plfdata = pdev->dev.platform_data;
struct ab3100_platform_data *plfdata = dev_get_platdata(&pdev->dev);
struct device_node *np = pdev->dev.of_node;
int err = 0;
u8 data;
......
......@@ -214,7 +214,7 @@ MODULE_DEVICE_TABLE(i2c, ad5398_id);
static int ad5398_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct regulator_init_data *init_data = client->dev.platform_data;
struct regulator_init_data *init_data = dev_get_platdata(&client->dev);
struct regulator_config config = { };
struct ad5398_chip_info *chip;
const struct ad5398_current_data_format *df =
......
......@@ -30,102 +30,6 @@ struct as3711_regulator {
struct regulator_dev *rdev;
};
static int as3711_list_voltage_sd(struct regulator_dev *rdev,
unsigned int selector)
{
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
if (!selector)
return 0;
if (selector < 0x41)
return 600000 + selector * 12500;
if (selector < 0x71)
return 1400000 + (selector - 0x40) * 25000;
return 2600000 + (selector - 0x70) * 50000;
}
static int as3711_list_voltage_aldo(struct regulator_dev *rdev,
unsigned int selector)
{
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
if (selector < 0x10)
return 1200000 + selector * 50000;
return 1800000 + (selector - 0x10) * 100000;
}
static int as3711_list_voltage_dldo(struct regulator_dev *rdev,
unsigned int selector)
{
if (selector >= rdev->desc->n_voltages ||
(selector > 0x10 && selector < 0x20))
return -EINVAL;
if (selector < 0x11)
return 900000 + selector * 50000;
return 1750000 + (selector - 0x20) * 50000;
}
static int as3711_bound_check(struct regulator_dev *rdev,
int *min_uV, int *max_uV)
{
struct as3711_regulator *reg = rdev_get_drvdata(rdev);
struct as3711_regulator_info *info = reg->reg_info;
dev_dbg(&rdev->dev, "%s(), %d, %d, %d\n", __func__,
*min_uV, rdev->desc->min_uV, info->max_uV);
if (*max_uV < *min_uV ||
*min_uV > info->max_uV || rdev->desc->min_uV > *max_uV)
return -EINVAL;
if (rdev->desc->n_voltages == 1)
return 0;
if (*max_uV > info->max_uV)
*max_uV = info->max_uV;
if (*min_uV < rdev->desc->min_uV)
*min_uV = rdev->desc->min_uV;
return *min_uV;
}
static int as3711_sel_check(int min, int max, int bottom, int step)
{
int sel, voltage;
/* Round up min, when dividing: keeps us within the range */
sel = DIV_ROUND_UP(min - bottom, step);
voltage = sel * step + bottom;
pr_debug("%s(): select %d..%d in %d+N*%d: %d\n", __func__,
min, max, bottom, step, sel);
if (voltage > max)
return -EINVAL;
return sel;
}
static int as3711_map_voltage_sd(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
int ret;
ret = as3711_bound_check(rdev, &min_uV, &max_uV);
if (ret <= 0)
return ret;
if (min_uV <= 1400000)
return as3711_sel_check(min_uV, max_uV, 600000, 12500);
if (min_uV <= 2600000)
return as3711_sel_check(min_uV, max_uV, 1400000, 25000) + 0x40;
return as3711_sel_check(min_uV, max_uV, 2600000, 50000) + 0x70;
}
/*
* The regulator API supports 4 modes of operataion: FAST, NORMAL, IDLE and
* STANDBY. We map them in the following way to AS3711 SD1-4 DCDC modes:
......@@ -180,44 +84,14 @@ static unsigned int as3711_get_mode_sd(struct regulator_dev *rdev)
return -EINVAL;
}
static int as3711_map_voltage_aldo(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
int ret;
ret = as3711_bound_check(rdev, &min_uV, &max_uV);
if (ret <= 0)
return ret;
if (min_uV <= 1800000)
return as3711_sel_check(min_uV, max_uV, 1200000, 50000);
return as3711_sel_check(min_uV, max_uV, 1800000, 100000) + 0x10;
}
static int as3711_map_voltage_dldo(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
int ret;
ret = as3711_bound_check(rdev, &min_uV, &max_uV);
if (ret <= 0)
return ret;
if (min_uV <= 1700000)
return as3711_sel_check(min_uV, max_uV, 900000, 50000);
return as3711_sel_check(min_uV, max_uV, 1750000, 50000) + 0x20;
}
static struct regulator_ops as3711_sd_ops = {
.is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.list_voltage = as3711_list_voltage_sd,
.map_voltage = as3711_map_voltage_sd,
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
.get_mode = as3711_get_mode_sd,
.set_mode = as3711_set_mode_sd,
};
......@@ -228,8 +102,8 @@ static struct regulator_ops as3711_aldo_ops = {
.disable = regulator_disable_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.list_voltage = as3711_list_voltage_aldo,
.map_voltage = as3711_map_voltage_aldo,
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
};
static struct regulator_ops as3711_dldo_ops = {
......@@ -238,8 +112,31 @@ static struct regulator_ops as3711_dldo_ops = {
.disable = regulator_disable_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.list_voltage = as3711_list_voltage_dldo,
.map_voltage = as3711_map_voltage_dldo,
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
};
static const struct regulator_linear_range as3711_sd_ranges[] = {
{ .min_uV = 612500, .max_uV = 1400000,
.min_sel = 0x1, .max_sel = 0x40, .uV_step = 12500 },
{ .min_uV = 1425000, .max_uV = 2600000,
.min_sel = 0x41, .max_sel = 0x70, .uV_step = 25000 },
{ .min_uV = 2650000, .max_uV = 3350000,
.min_sel = 0x71, .max_sel = 0x7f, .uV_step = 50000 },
};
static const struct regulator_linear_range as3711_aldo_ranges[] = {
{ .min_uV = 1200000, .max_uV = 1950000,
.min_sel = 0, .max_sel = 0xf, .uV_step = 50000 },
{ .min_uV = 1800000, .max_uV = 3300000,
.min_sel = 0x10, .max_sel = 0x1f, .uV_step = 100000 },
};
static const struct regulator_linear_range as3711_dldo_ranges[] = {
{ .min_uV = 900000, .max_uV = 1700000,
.min_sel = 0, .max_sel = 0x10, .uV_step = 50000 },
{ .min_uV = 1750000, .max_uV = 3300000,
.min_sel = 0x20, .max_sel = 0x3f, .uV_step = 50000 },
};
#define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \
......@@ -256,6 +153,8 @@ static struct regulator_ops as3711_dldo_ops = {
.enable_reg = AS3711_ ## _en_reg, \
.enable_mask = BIT(_en_bit), \
.min_uV = _min_uV, \
.linear_ranges = as3711_ ## _sfx ## _ranges, \
.n_linear_ranges = ARRAY_SIZE(as3711_ ## _sfx ## _ranges), \
}, \
.max_uV = _max_uV, \
}
......
This diff is collapsed.
......@@ -252,39 +252,12 @@ static int da9034_set_dvc_voltage_sel(struct regulator_dev *rdev,
return ret;
}
static int da9034_map_ldo12_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
int sel;
if (check_range(info, min_uV, max_uV)) {
pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
return -EINVAL;
}
sel = DIV_ROUND_UP(min_uV - info->desc.min_uV, info->desc.uV_step);
sel = (sel >= 20) ? sel - 12 : ((sel > 7) ? 8 : sel);
return sel;
}
static int da9034_list_ldo12_voltage(struct regulator_dev *rdev,
unsigned selector)
{
struct da903x_regulator_info *info = rdev_get_drvdata(rdev);
int volt;
if (selector >= 8)
volt = 2700000 + rdev->desc->uV_step * (selector - 8);
else
volt = rdev->desc->min_uV + rdev->desc->uV_step * selector;
if (volt > info->max_uV)
return -EINVAL;
return volt;
}
static const struct regulator_linear_range da9034_ldo12_ranges[] = {
{ .min_uV = 1700000, .max_uV = 2050000, .min_sel = 0, .max_sel = 7,
.uV_step = 50000 },
{ .min_uV = 2700000, .max_uV = 3050000, .min_sel = 8, .max_sel = 15,
.uV_step = 50000 },
};
static struct regulator_ops da903x_regulator_ldo_ops = {
.set_voltage_sel = da903x_set_voltage_sel,
......@@ -332,8 +305,8 @@ static struct regulator_ops da9034_regulator_dvc_ops = {
static struct regulator_ops da9034_regulator_ldo12_ops = {
.set_voltage_sel = da903x_set_voltage_sel,
.get_voltage_sel = da903x_get_voltage_sel,
.list_voltage = da9034_list_ldo12_voltage,
.map_voltage = da9034_map_ldo12_voltage,
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
.enable = da903x_enable,
.disable = da903x_disable,
.is_enabled = da903x_is_enabled,
......@@ -476,6 +449,8 @@ static int da903x_regulator_probe(struct platform_device *pdev)
if (ri->desc.id == DA9034_ID_LDO12) {
ri->desc.ops = &da9034_regulator_ldo12_ops;
ri->desc.n_voltages = 16;
ri->desc.linear_ranges = da9034_ldo12_ranges;
ri->desc.n_linear_ranges = ARRAY_SIZE(da9034_ldo12_ranges);
}
if (ri->desc.id == DA9030_ID_LDO14)
......@@ -485,7 +460,7 @@ static int da903x_regulator_probe(struct platform_device *pdev)
ri->desc.ops = &da9030_regulator_ldo1_15_ops;
config.dev = &pdev->dev;
config.init_data = pdev->dev.platform_data;
config.init_data = dev_get_platdata(&pdev->dev);
config.driver_data = ri;
rdev = regulator_register(&ri->desc, &config);
......
......@@ -349,7 +349,7 @@ static int da9052_regulator_probe(struct platform_device *pdev)
return -ENOMEM;
da9052 = dev_get_drvdata(pdev->dev.parent);
pdata = da9052->dev->platform_data;
pdata = dev_get_platdata(da9052->dev);
regulator->da9052 = da9052;
regulator->info = find_regulator_info(regulator->da9052->chip_id,
......
......@@ -535,7 +535,7 @@ static int da9055_regulator_probe(struct platform_device *pdev)
struct regulator_config config = { };
struct da9055_regulator *regulator;
struct da9055 *da9055 = dev_get_drvdata(pdev->dev.parent);
struct da9055_pdata *pdata = da9055->dev->platform_data;
struct da9055_pdata *pdata = dev_get_platdata(da9055->dev);
int ret, irq;
if (pdata == NULL || pdata->regulators[pdev->id] == NULL)
......
This diff is collapsed.
/*
* da9210-regulator.c - Regulator device driver for DA9210
* Copyright (C) 2013 Dialog Semiconductor Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regmap.h>
#include "da9210-regulator.h"
struct da9210 {
struct regulator_dev *rdev;
struct regmap *regmap;
};
static const struct regmap_config da9210_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
};
static int da9210_set_current_limit(struct regulator_dev *rdev, int min_uA,
int max_uA);
static int da9210_get_current_limit(struct regulator_dev *rdev);
static struct regulator_ops da9210_buck_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.list_voltage = regulator_list_voltage_linear,
.set_current_limit = da9210_set_current_limit,
.get_current_limit = da9210_get_current_limit,
};
/* Default limits measured in millivolts and milliamps */
#define DA9210_MIN_MV 300
#define DA9210_MAX_MV 1570
#define DA9210_STEP_MV 10
/* Current limits for buck (uA) indices corresponds with register values */
static const int da9210_buck_limits[] = {
1600000, 1800000, 2000000, 2200000, 2400000, 2600000, 2800000, 3000000,
3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000, 4600000
};
static const struct regulator_desc da9210_reg = {
.name = "DA9210",
.id = 0,
.ops = &da9210_buck_ops,
.type = REGULATOR_VOLTAGE,
.n_voltages = ((DA9210_MAX_MV - DA9210_MIN_MV) / DA9210_STEP_MV) + 1,
.min_uV = (DA9210_MIN_MV * 1000),
.uV_step = (DA9210_STEP_MV * 1000),
.vsel_reg = DA9210_REG_VBUCK_A,
.vsel_mask = DA9210_VBUCK_MASK,
.enable_reg = DA9210_REG_BUCK_CONT,
.enable_mask = DA9210_BUCK_EN,
.owner = THIS_MODULE,
};
static int da9210_set_current_limit(struct regulator_dev *rdev, int min_uA,
int max_uA)
{
struct da9210 *chip = rdev_get_drvdata(rdev);
unsigned int sel;
int i;
/* search for closest to maximum */
for (i = ARRAY_SIZE(da9210_buck_limits)-1; i >= 0; i--) {
if (min_uA <= da9210_buck_limits[i] &&
max_uA >= da9210_buck_limits[i]) {
sel = i;
sel = sel << DA9210_BUCK_ILIM_SHIFT;
return regmap_update_bits(chip->regmap,
DA9210_REG_BUCK_ILIM,
DA9210_BUCK_ILIM_MASK, sel);
}
}
return -EINVAL;
}
static int da9210_get_current_limit(struct regulator_dev *rdev)
{
struct da9210 *chip = rdev_get_drvdata(rdev);
unsigned int data;
unsigned int sel;
int ret;
ret = regmap_read(chip->regmap, DA9210_REG_BUCK_ILIM, &data);
if (ret < 0)
return ret;
/* select one of 16 values: 0000 (1600mA) to 1111 (4600mA) */
sel = (data & DA9210_BUCK_ILIM_MASK) >> DA9210_BUCK_ILIM_SHIFT;
return da9210_buck_limits[sel];
}
/*
* I2C driver interface functions
*/
static int da9210_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct da9210 *chip;
struct da9210_pdata *pdata = i2c->dev.platform_data;
struct regulator_dev *rdev = NULL;
struct regulator_config config = { };
int error;
chip = devm_kzalloc(&i2c->dev, sizeof(struct da9210), GFP_KERNEL);
if (NULL == chip) {
dev_err(&i2c->dev,
"Cannot kzalloc memory for regulator structure\n");
return -ENOMEM;
}
chip->regmap = devm_regmap_init_i2c(i2c, &da9210_regmap_config);
if (IS_ERR(chip->regmap)) {
error = PTR_ERR(chip->regmap);
dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
error);
return error;
}
config.dev = &i2c->dev;
if (pdata)
config.init_data = &pdata->da9210_constraints;
config.driver_data = chip;
config.regmap = chip->regmap;
rdev = regulator_register(&da9210_reg, &config);
if (IS_ERR(rdev)) {
dev_err(&i2c->dev, "Failed to register DA9210 regulator\n");
return PTR_ERR(rdev);
}
chip->rdev = rdev;
i2c_set_clientdata(i2c, chip);
return 0;
}
static int da9210_i2c_remove(struct i2c_client *i2c)
{
struct da9210 *chip = i2c_get_clientdata(i2c);
regulator_unregister(chip->rdev);
return 0;
}
static const struct i2c_device_id da9210_i2c_id[] = {
{"da9210", 0},
{},
};
MODULE_DEVICE_TABLE(i2c, da9210_i2c_id);
static struct i2c_driver da9210_regulator_driver = {
.driver = {
.name = "da9210",
.owner = THIS_MODULE,
},
.probe = da9210_i2c_probe,
.remove = da9210_i2c_remove,
.id_table = da9210_i2c_id,
};
module_i2c_driver(da9210_regulator_driver);
MODULE_AUTHOR("S Twiss <stwiss.opensource@diasemi.com>");
MODULE_DESCRIPTION("Regulator device driver for Dialog DA9210");
MODULE_LICENSE("GPL v2");
/*
* da9210-regulator.h - Regulator definitions for DA9210
* Copyright (C) 2013 Dialog Semiconductor Ltd.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __DA9210_REGISTERS_H__
#define __DA9210_REGISTERS_H__
struct da9210_pdata {
struct regulator_init_data da9210_constraints;
};
/* Page selection */
#define DA9210_REG_PAGE_CON 0x00
/* System Control and Event Registers */
#define DA9210_REG_STATUS_A 0x50
#define DA9210_REG_STATUS_B 0x51
#define DA9210_REG_EVENT_A 0x52
#define DA9210_REG_EVENT_B 0x53
#define DA9210_REG_MASK_A 0x54
#define DA9210_REG_MASK_B 0x55
#define DA9210_REG_CONTROL_A 0x56
/* GPIO Control Registers */
#define DA9210_REG_GPIO_0_1 0x58
#define DA9210_REG_GPIO_2_3 0x59
#define DA9210_REG_GPIO_4_5 0x5A
#define DA9210_REG_GPIO_6 0x5B
/* Regulator Registers */
#define DA9210_REG_BUCK_CONT 0x5D
#define DA9210_REG_BUCK_ILIM 0xD0
#define DA9210_REG_BUCK_CONF1 0xD1
#define DA9210_REG_BUCK_CONF2 0xD2
#define DA9210_REG_VBACK_AUTO 0xD4
#define DA9210_REG_VBACK_BASE 0xD5
#define DA9210_REG_VBACK_MAX_DVC_IF 0xD6
#define DA9210_REG_VBACK_DVC 0xD7
#define DA9210_REG_VBUCK_A 0xD8
#define DA9210_REG_VBUCK_B 0xD9
/* I2C Interface Settings */
#define DA9210_REG_INTERFACE 0x105
/* OTP */
#define DA9210_REG_OPT_COUNT 0x140
#define DA9210_REG_OPT_ADDR 0x141
#define DA9210_REG_OPT_DATA 0x142
/* Customer Trim and Configuration */
#define DA9210_REG_CONFIG_A 0x143
#define DA9210_REG_CONFIG_B 0x144
#define DA9210_REG_CONFIG_C 0x145
#define DA9210_REG_CONFIG_D 0x146
#define DA9210_REG_CONFIG_E 0x147
/*
* Registers bits
*/
/* DA9210_REG_PAGE_CON (addr=0x00) */
#define DA9210_PEG_PAGE_SHIFT 0
#define DA9210_REG_PAGE_MASK 0x0F
/* On I2C registers 0x00 - 0xFF */
#define DA9210_REG_PAGE0 0
/* On I2C registers 0x100 - 0x1FF */
#define DA9210_REG_PAGE2 2
#define DA9210_PAGE_WRITE_MODE 0x00
#define DA9210_REPEAT_WRITE_MODE 0x40
#define DA9210_PAGE_REVERT 0x80
/* DA9210_REG_STATUS_A (addr=0x50) */
#define DA9210_GPI0 0x01
#define DA9210_GPI1 0x02
#define DA9210_GPI2 0x04
#define DA9210_GPI3 0x08
#define DA9210_GPI4 0x10
#define DA9210_GPI5 0x20
#define DA9210_GPI6 0x40
/* DA9210_REG_EVENT_A (addr=0x52) */
#define DA9210_E_GPI0 0x01
#define DA9210_E_GPI1 0x02
#define DA9210_E_GPI2 0x04
#define DA9210_E_GPI3 0x08
#define DA9210_E_GPI4 0x10
#define DA9210_E_GPI5 0x20
#define DA9210_E_GPI6 0x40
/* DA9210_REG_EVENT_B (addr=0x53) */
#define DA9210_E_OVCURR 0x01
#define DA9210_E_NPWRGOOD 0x02
#define DA9210_E_TEMP_WARN 0x04
#define DA9210_E_TEMP_CRIT 0x08
#define DA9210_E_VMAX 0x10
/* DA9210_REG_MASK_A (addr=0x54) */
#define DA9210_M_GPI0 0x01
#define DA9210_M_GPI1 0x02
#define DA9210_M_GPI2 0x04
#define DA9210_M_GPI3 0x08
#define DA9210_M_GPI4 0x10
#define DA9210_M_GPI5 0x20
#define DA9210_M_GPI6 0x40
/* DA9210_REG_MASK_B (addr=0x55) */
#define DA9210_M_OVCURR 0x01
#define DA9210_M_NPWRGOOD 0x02
#define DA9210_M_TEMP_WARN 0x04
#define DA9210_M_TEMP_CRIT 0x08
#define DA9210_M_VMAX 0x10
/* DA9210_REG_CONTROL_A (addr=0x56) */
#define DA9210_DEBOUNCING_SHIFT 0
#define DA9210_DEBOUNCING_MASK 0x07
#define DA9210_SLEW_RATE_SHIFT 3
#define DA9210_SLEW_RATE_MASK 0x18
#define DA9210_V_LOCK 0x20
/* DA9210_REG_GPIO_0_1 (addr=0x58) */
#define DA9210_GPIO0_PIN_SHIFT 0
#define DA9210_GPIO0_PIN_MASK 0x03
#define DA9210_GPIO0_PIN_GPI 0x00
#define DA9210_GPIO0_PIN_GPO_OD 0x02
#define DA9210_GPIO0_PIN_GPO 0x03
#define DA9210_GPIO0_TYPE 0x04
#define DA9210_GPIO0_TYPE_GPI 0x00
#define DA9210_GPIO0_TYPE_GPO 0x04
#define DA9210_GPIO0_MODE 0x08
#define DA9210_GPIO1_PIN_SHIFT 4
#define DA9210_GPIO1_PIN_MASK 0x30
#define DA9210_GPIO1_PIN_GPI 0x00
#define DA9210_GPIO1_PIN_VERROR 0x10
#define DA9210_GPIO1_PIN_GPO_OD 0x20
#define DA9210_GPIO1_PIN_GPO 0x30
#define DA9210_GPIO1_TYPE_SHIFT 0x40
#define DA9210_GPIO1_TYPE_GPI 0x00
#define DA9210_GPIO1_TYPE_GPO 0x40
#define DA9210_GPIO1_MODE 0x80
/* DA9210_REG_GPIO_2_3 (addr=0x59) */
#define DA9210_GPIO2_PIN_SHIFT 0
#define DA9210_GPIO2_PIN_MASK 0x03
#define DA9210_GPIO2_PIN_GPI 0x00
#define DA9210_GPIO5_PIN_BUCK_CLK 0x10
#define DA9210_GPIO2_PIN_GPO_OD 0x02
#define DA9210_GPIO2_PIN_GPO 0x03
#define DA9210_GPIO2_TYPE 0x04
#define DA9210_GPIO2_TYPE_GPI 0x00
#define DA9210_GPIO2_TYPE_GPO 0x04
#define DA9210_GPIO2_MODE 0x08
#define DA9210_GPIO3_PIN_SHIFT 4
#define DA9210_GPIO3_PIN_MASK 0x30
#define DA9210_GPIO3_PIN_GPI 0x00
#define DA9210_GPIO3_PIN_IERROR 0x10
#define DA9210_GPIO3_PIN_GPO_OD 0x20
#define DA9210_GPIO3_PIN_GPO 0x30
#define DA9210_GPIO3_TYPE_SHIFT 0x40
#define DA9210_GPIO3_TYPE_GPI 0x00
#define DA9210_GPIO3_TYPE_GPO 0x40
#define DA9210_GPIO3_MODE 0x80
/* DA9210_REG_GPIO_4_5 (addr=0x5A) */
#define DA9210_GPIO4_PIN_SHIFT 0
#define DA9210_GPIO4_PIN_MASK 0x03
#define DA9210_GPIO4_PIN_GPI 0x00
#define DA9210_GPIO4_PIN_GPO_OD 0x02
#define DA9210_GPIO4_PIN_GPO 0x03
#define DA9210_GPIO4_TYPE 0x04
#define DA9210_GPIO4_TYPE_GPI 0x00
#define DA9210_GPIO4_TYPE_GPO 0x04
#define DA9210_GPIO4_MODE 0x08
#define DA9210_GPIO5_PIN_SHIFT 4
#define DA9210_GPIO5_PIN_MASK 0x30
#define DA9210_GPIO5_PIN_GPI 0x00
#define DA9210_GPIO5_PIN_INTERFACE 0x01
#define DA9210_GPIO5_PIN_GPO_OD 0x20
#define DA9210_GPIO5_PIN_GPO 0x30
#define DA9210_GPIO5_TYPE_SHIFT 0x40
#define DA9210_GPIO5_TYPE_GPI 0x00
#define DA9210_GPIO5_TYPE_GPO 0x40
#define DA9210_GPIO5_MODE 0x80
/* DA9210_REG_GPIO_6 (addr=0x5B) */
#define DA9210_GPIO6_PIN_SHIFT 0
#define DA9210_GPIO6_PIN_MASK 0x03
#define DA9210_GPIO6_PIN_GPI 0x00
#define DA9210_GPIO6_PIN_INTERFACE 0x01
#define DA9210_GPIO6_PIN_GPO_OD 0x02
#define DA9210_GPIO6_PIN_GPO 0x03
#define DA9210_GPIO6_TYPE 0x04
#define DA9210_GPIO6_TYPE_GPI 0x00
#define DA9210_GPIO6_TYPE_GPO 0x04
#define DA9210_GPIO6_MODE 0x08
/* DA9210_REG_BUCK_CONT (addr=0x5D) */
#define DA9210_BUCK_EN 0x01
#define DA9210_BUCK_GPI_SHIFT 1
#define DA9210_BUCK_GPI_MASK 0x06
#define DA9210_BUCK_GPI_OFF 0x00
#define DA9210_BUCK_GPI_GPIO0 0x02
#define DA9210_BUCK_GPI_GPIO3 0x04
#define DA9210_BUCK_GPI_GPIO4 0x06
#define DA9210_BUCK_PD_DIS 0x08
#define DA9210_VBUCK_SEL 0x10
#define DA9210_VBUCK_SEL_A 0x00
#define DA9210_VBUCK_SEL_B 0x10
#define DA9210_VBUCK_GPI_SHIFT 5
#define DA9210_VBUCK_GPI_MASK 0x60
#define DA9210_VBUCK_GPI_OFF 0x00
#define DA9210_VBUCK_GPI_GPIO0 0x20
#define DA9210_VBUCK_GPI_GPIO3 0x40
#define DA9210_VBUCK_GPI_GPIO4 0x60
#define DA9210_DVC_CTRL_EN 0x80
/* DA9210_REG_BUCK_ILIM (addr=0xD0) */
#define DA9210_BUCK_ILIM_SHIFT 0
#define DA9210_BUCK_ILIM_MASK 0x0F
#define DA9210_BUCK_IALARM 0x10
/* DA9210_REG_BUCK_CONF1 (addr=0xD1) */
#define DA9210_BUCK_MODE_SHIFT 0
#define DA9210_BUCK_MODE_MASK 0x03
#define DA9210_BUCK_MODE_MANUAL 0x00
#define DA9210_BUCK_MODE_SLEEP 0x01
#define DA9210_BUCK_MODE_SYNC 0x02
#define DA9210_BUCK_MODE_AUTO 0x03
#define DA9210_STARTUP_CTRL_SHIFT 2
#define DA9210_STARTUP_CTRL_MASK 0x1C
#define DA9210_PWR_DOWN_CTRL_SHIFT 5
#define DA9210_PWR_DOWN_CTRL_MASK 0xE0
/* DA9210_REG_BUCK_CONF2 (addr=0xD2) */
#define DA9210_PHASE_SEL_SHIFT 0
#define DA9210_PHASE_SEL_MASK 0x03
#define DA9210_FREQ_SEL 0x40
/* DA9210_REG_BUCK_AUTO (addr=0xD4) */
#define DA9210_VBUCK_AUTO_SHIFT 0
#define DA9210_VBUCK_AUTO_MASK 0x7F
/* DA9210_REG_BUCK_BASE (addr=0xD5) */
#define DA9210_VBUCK_BASE_SHIFT 0
#define DA9210_VBUCK_BASE_MASK 0x7F
/* DA9210_REG_VBUCK_MAX_DVC_IF (addr=0xD6) */
#define DA9210_VBUCK_MAX_SHIFT 0
#define DA9210_VBUCK_MAX_MASK 0x7F
#define DA9210_DVC_STEP_SIZE 0x80
#define DA9210_DVC_STEP_SIZE_10MV 0x00
#define DA9210_DVC_STEP_SIZE_20MV 0x80
/* DA9210_REG_VBUCK_DVC (addr=0xD7) */
#define DA9210_VBUCK_DVC_SHIFT 0
#define DA9210_VBUCK_DVC_MASK 0x7F
/* DA9210_REG_VBUCK_A/B (addr=0xD8/0xD9) */
#define DA9210_VBUCK_SHIFT 0
#define DA9210_VBUCK_MASK 0x7F
#define DA9210_VBUCK_BIAS 0
#define DA9210_BUCK_SL 0x80
/* DA9210_REG_INTERFACE (addr=0x105) */
#define DA9210_IF_BASE_ADDR_SHIFT 4
#define DA9210_IF_BASE_ADDR_MASK 0xF0
/* DA9210_REG_CONFIG_E (addr=0x147) */
#define DA9210_STAND_ALONE 0x01
#endif /* __DA9210_REGISTERS_H__ */
......@@ -237,7 +237,7 @@ static int fan53555_regulator_probe(struct i2c_client *client,
unsigned int val;
int ret;
pdata = client->dev.platform_data;
pdata = dev_get_platdata(&client->dev);
if (!pdata || !pdata->regulator) {
dev_err(&client->dev, "Platform data not found!\n");
return -ENODEV;
......
......@@ -146,7 +146,7 @@ static int reg_fixed_voltage_probe(struct platform_device *pdev)
if (IS_ERR(config))
return PTR_ERR(config);
} else {
config = pdev->dev.platform_data;
config = dev_get_platdata(&pdev->dev);
}
if (!config)
......
......@@ -219,7 +219,7 @@ static struct regulator_ops gpio_regulator_current_ops = {
static int gpio_regulator_probe(struct platform_device *pdev)
{
struct gpio_regulator_config *config = pdev->dev.platform_data;
struct gpio_regulator_config *config = dev_get_platdata(&pdev->dev);
struct device_node *np = pdev->dev.of_node;
struct gpio_regulator_data *drvdata;
struct regulator_config cfg = { };
......
This diff is collapsed.
......@@ -110,7 +110,7 @@ static int isl6271a_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct regulator_config config = { };
struct regulator_init_data *init_data = i2c->dev.platform_data;
struct regulator_init_data *init_data = dev_get_platdata(&i2c->dev);
struct isl_pmic *pmic;
int err, i;
......
......@@ -425,7 +425,7 @@ static int lp3971_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct lp3971 *lp3971;
struct lp3971_platform_data *pdata = i2c->dev.platform_data;
struct lp3971_platform_data *pdata = dev_get_platdata(&i2c->dev);
int ret;
u16 val;
......
......@@ -519,7 +519,7 @@ static int lp3972_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct lp3972 *lp3972;
struct lp3972_platform_data *pdata = i2c->dev.platform_data;
struct lp3972_platform_data *pdata = dev_get_platdata(&i2c->dev);
int ret;
u16 val;
......
......@@ -373,7 +373,7 @@ static int lp8725_buck_set_current_limit(struct regulator_dev *rdev,
return -EINVAL;
}
for (i = ARRAY_SIZE(lp8725_buck_uA) - 1 ; i >= 0; i--) {
for (i = ARRAY_SIZE(lp8725_buck_uA) - 1; i >= 0; i--) {
if (lp8725_buck_uA[i] >= min_uA &&
lp8725_buck_uA[i] <= max_uA)
return lp872x_update_bits(lp, addr,
......@@ -787,7 +787,7 @@ static int lp872x_regulator_register(struct lp872x *lp)
struct regulator_dev *rdev;
int i, ret;
for (i = 0 ; i < lp->num_regulators ; i++) {
for (i = 0; i < lp->num_regulators; i++) {
desc = (lp->chipid == LP8720) ? &lp8720_regulator_desc[i] :
&lp8725_regulator_desc[i];
......@@ -820,7 +820,7 @@ static void lp872x_regulator_unregister(struct lp872x *lp)
struct regulator_dev *rdev;
int i;
for (i = 0 ; i < lp->num_regulators ; i++) {
for (i = 0; i < lp->num_regulators; i++) {
rdev = *(lp->regulators + i);
regulator_unregister(rdev);
}
......@@ -907,7 +907,8 @@ static struct lp872x_platform_data
goto out;
for (i = 0; i < num_matches; i++) {
pdata->regulator_data[i].id = (int)match[i].driver_data;
pdata->regulator_data[i].id =
(enum lp872x_regulator_id)match[i].driver_data;
pdata->regulator_data[i].init_data = match[i].init_data;
/* Operation mode configuration for buck/buck1/buck2 */
......@@ -961,7 +962,7 @@ static int lp872x_probe(struct i2c_client *cl, const struct i2c_device_id *id)
}
lp->dev = &cl->dev;
lp->pdata = cl->dev.platform_data;
lp->pdata = dev_get_platdata(&cl->dev);
lp->chipid = id->driver_data;
lp->num_regulators = num_regulators;
i2c_set_clientdata(cl, lp);
......
......@@ -228,6 +228,7 @@ static int lp8755_buck_set_ramp(struct regulator_dev *rdev, int ramp)
}
static struct regulator_ops lp8755_buck_ops = {
.map_voltage = regulator_map_voltage_linear,
.list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
......@@ -449,7 +450,7 @@ static int lp8755_probe(struct i2c_client *client,
{
int ret, icnt;
struct lp8755_chip *pchip;
struct lp8755_platform_data *pdata = client->dev.platform_data;
struct lp8755_platform_data *pdata = dev_get_platdata(&client->dev);
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
dev_err(&client->dev, "i2c functionality check fail.\n");
......
......@@ -163,7 +163,7 @@ static int max1586_pmic_probe(struct i2c_client *client,
const struct i2c_device_id *i2c_id)
{
struct regulator_dev **rdev;
struct max1586_platform_data *pdata = client->dev.platform_data;
struct max1586_platform_data *pdata = dev_get_platdata(&client->dev);
struct regulator_config config = { };
struct max1586_data *max1586;
int i, id, ret = -ENOMEM;
......
......@@ -152,7 +152,7 @@ static struct regmap_config max8649_regmap_config = {
static int max8649_regulator_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct max8649_platform_data *pdata = client->dev.platform_data;
struct max8649_platform_data *pdata = dev_get_platdata(&client->dev);
struct max8649_regulator_info *info = NULL;
struct regulator_config config = { };
unsigned int val;
......
......@@ -44,6 +44,9 @@
#include <linux/regulator/driver.h>
#include <linux/slab.h>
#include <linux/regulator/max8660.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/regulator/of_regulator.h>
#define MAX8660_DCDC_MIN_UV 725000
#define MAX8660_DCDC_MAX_UV 1800000
......@@ -305,21 +308,105 @@ static const struct regulator_desc max8660_reg[] = {
},
};
enum {
MAX8660 = 0,
MAX8661 = 1,
};
#ifdef CONFIG_OF
static const struct of_device_id max8660_dt_ids[] = {
{ .compatible = "maxim,max8660", .data = (void *) MAX8660 },
{ .compatible = "maxim,max8661", .data = (void *) MAX8661 },
{ }
};
MODULE_DEVICE_TABLE(of, max8660_dt_ids);
static int max8660_pdata_from_dt(struct device *dev,
struct device_node **of_node,
struct max8660_platform_data *pdata)
{
int matched, i;
struct device_node *np;
struct max8660_subdev_data *sub;
struct of_regulator_match rmatch[ARRAY_SIZE(max8660_reg)];
np = of_find_node_by_name(dev->of_node, "regulators");
if (!np) {
dev_err(dev, "missing 'regulators' subnode in DT\n");
return -EINVAL;
}
for (i = 0; i < ARRAY_SIZE(rmatch); i++)
rmatch[i].name = max8660_reg[i].name;
matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(rmatch));
if (matched <= 0)
return matched;
pdata->subdevs = devm_kzalloc(dev, sizeof(struct max8660_subdev_data) *
matched, GFP_KERNEL);
if (!pdata->subdevs)
return -ENOMEM;
pdata->num_subdevs = matched;
sub = pdata->subdevs;
for (i = 0; i < matched; i++) {
sub->id = i;
sub->name = rmatch[i].name;
sub->platform_data = rmatch[i].init_data;
of_node[i] = rmatch[i].of_node;
sub++;
}
return 0;
}
#else
static inline int max8660_pdata_from_dt(struct device *dev,
struct device_node **of_node,
struct max8660_platform_data *pdata)
{
return 0;
}
#endif
static int max8660_probe(struct i2c_client *client,
const struct i2c_device_id *i2c_id)
{
struct regulator_dev **rdev;
struct max8660_platform_data *pdata = client->dev.platform_data;
struct device *dev = &client->dev;
struct max8660_platform_data *pdata = dev_get_platdata(dev);
struct regulator_config config = { };
struct max8660 *max8660;
int boot_on, i, id, ret = -EINVAL;
struct device_node *of_node[MAX8660_V_END];
unsigned long type;
if (dev->of_node && !pdata) {
const struct of_device_id *id;
struct max8660_platform_data pdata_of;
id = of_match_device(of_match_ptr(max8660_dt_ids), dev);
if (!id)
return -ENODEV;
ret = max8660_pdata_from_dt(dev, of_node, &pdata_of);
if (ret < 0)
return ret;
pdata = &pdata_of;
type = (unsigned long) id->data;
} else {
type = i2c_id->driver_data;
memset(of_node, 0, sizeof(of_node));
}
if (pdata->num_subdevs > MAX8660_V_END) {
dev_err(&client->dev, "Too many regulators found!\n");
dev_err(dev, "Too many regulators found!\n");
return -EINVAL;
}
max8660 = devm_kzalloc(&client->dev, sizeof(struct max8660) +
max8660 = devm_kzalloc(dev, sizeof(struct max8660) +
sizeof(struct regulator_dev *) * MAX8660_V_END,
GFP_KERNEL);
if (!max8660)
......@@ -376,8 +463,8 @@ static int max8660_probe(struct i2c_client *client,
break;
case MAX8660_V7:
if (!strcmp(i2c_id->name, "max8661")) {
dev_err(&client->dev, "Regulator not on this chip!\n");
if (type == MAX8661) {
dev_err(dev, "Regulator not on this chip!\n");
goto err_out;
}
......@@ -386,7 +473,7 @@ static int max8660_probe(struct i2c_client *client,
break;
default:
dev_err(&client->dev, "invalid regulator %s\n",
dev_err(dev, "invalid regulator %s\n",
pdata->subdevs[i].name);
goto err_out;
}
......@@ -397,14 +484,15 @@ static int max8660_probe(struct i2c_client *client,
id = pdata->subdevs[i].id;
config.dev = &client->dev;
config.dev = dev;
config.init_data = pdata->subdevs[i].platform_data;
config.of_node = of_node[i];
config.driver_data = max8660;
rdev[i] = regulator_register(&max8660_reg[id], &config);
if (IS_ERR(rdev[i])) {
ret = PTR_ERR(rdev[i]);
dev_err(&client->dev, "failed to register %s\n",
dev_err(dev, "failed to register %s\n",
max8660_reg[id].name);
goto err_unregister;
}
......@@ -431,8 +519,8 @@ static int max8660_remove(struct i2c_client *client)
}
static const struct i2c_device_id max8660_id[] = {
{ "max8660", 0 },
{ "max8661", 0 },
{ .name = "max8660", .driver_data = MAX8660 },
{ .name = "max8661", .driver_data = MAX8661 },
{ }
};
MODULE_DEVICE_TABLE(i2c, max8660_id);
......
......@@ -277,7 +277,7 @@ static int max8925_regulator_dt_init(struct platform_device *pdev,
static int max8925_regulator_probe(struct platform_device *pdev)
{
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct regulator_init_data *pdata = pdev->dev.platform_data;
struct regulator_init_data *pdata = dev_get_platdata(&pdev->dev);
struct regulator_config config = { };
struct max8925_regulator_info *ri;
struct resource *res;
......
......@@ -196,7 +196,7 @@ static int max8952_pmic_probe(struct i2c_client *client,
const struct i2c_device_id *i2c_id)
{
struct i2c_adapter *adapter = to_i2c_adapter(client->dev.parent);
struct max8952_platform_data *pdata = client->dev.platform_data;
struct max8952_platform_data *pdata = dev_get_platdata(&client->dev);
struct regulator_config config = { };
struct max8952_data *max8952;
......
......@@ -371,7 +371,7 @@ static int max8973_probe(struct i2c_client *client,
struct max8973_chip *max;
int ret;
pdata = client->dev.platform_data;
pdata = dev_get_platdata(&client->dev);
if (!pdata && !client->dev.of_node) {
dev_err(&client->dev, "No Platform data");
......
......@@ -21,6 +21,7 @@ static void of_get_regulation_constraints(struct device_node *np,
{
const __be32 *min_uV, *max_uV, *uV_offset;
const __be32 *min_uA, *max_uA, *ramp_delay;
struct property *prop;
struct regulation_constraints *constraints = &(*init_data)->constraints;
constraints->name = of_get_property(np, "regulator-name", NULL);
......@@ -64,9 +65,14 @@ static void of_get_regulation_constraints(struct device_node *np,
if (of_property_read_bool(np, "regulator-allow-bypass"))
constraints->valid_ops_mask |= REGULATOR_CHANGE_BYPASS;
ramp_delay = of_get_property(np, "regulator-ramp-delay", NULL);
if (ramp_delay)
constraints->ramp_delay = be32_to_cpu(*ramp_delay);
prop = of_find_property(np, "regulator-ramp-delay", NULL);
if (prop && prop->value) {
ramp_delay = prop->value;
if (*ramp_delay)
constraints->ramp_delay = be32_to_cpu(*ramp_delay);
else
constraints->ramp_disable = true;
}
}
/**
......
......@@ -97,10 +97,15 @@ static const struct regs_info palmas_regs_info[] = {
.ctrl_addr = PALMAS_SMPS9_CTRL,
},
{
.name = "SMPS10",
.name = "SMPS10_OUT2",
.sname = "smps10-in",
.ctrl_addr = PALMAS_SMPS10_CTRL,
},
{
.name = "SMPS10_OUT1",
.sname = "smps10-out2",
.ctrl_addr = PALMAS_SMPS10_CTRL,
},
{
.name = "LDO1",
.sname = "ldo1-in",
......@@ -487,6 +492,8 @@ static struct regulator_ops palmas_ops_smps10 = {
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.list_voltage = regulator_list_voltage_linear,
.map_voltage = regulator_map_voltage_linear,
.set_bypass = regulator_set_bypass_regmap,
.get_bypass = regulator_get_bypass_regmap,
};
static int palmas_is_enabled_ldo(struct regulator_dev *dev)
......@@ -538,7 +545,8 @@ static int palmas_smps_init(struct palmas *palmas, int id,
return ret;
switch (id) {
case PALMAS_REG_SMPS10:
case PALMAS_REG_SMPS10_OUT1:
case PALMAS_REG_SMPS10_OUT2:
reg &= ~PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK;
if (reg_init->mode_sleep)
reg |= reg_init->mode_sleep <<
......@@ -681,7 +689,8 @@ static struct of_regulator_match palmas_matches[] = {
{ .name = "smps7", },
{ .name = "smps8", },
{ .name = "smps9", },
{ .name = "smps10", },
{ .name = "smps10_out2", },
{ .name = "smps10_out1", },
{ .name = "ldo1", },
{ .name = "ldo2", },
{ .name = "ldo3", },
......@@ -765,7 +774,7 @@ static void palmas_dt_to_pdata(struct device *dev,
static int palmas_regulators_probe(struct platform_device *pdev)
{
struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data;
struct palmas_pmic_platform_data *pdata = dev_get_platdata(&pdev->dev);
struct device_node *node = pdev->dev.of_node;
struct regulator_dev *rdev;
struct regulator_config config = { };
......@@ -838,7 +847,8 @@ static int palmas_regulators_probe(struct platform_device *pdev)
continue;
ramp_delay_support = true;
break;
case PALMAS_REG_SMPS10:
case PALMAS_REG_SMPS10_OUT1:
case PALMAS_REG_SMPS10_OUT2:
if (!PALMAS_PMIC_HAS(palmas, SMPS10_BOOST))
continue;
}
......@@ -872,7 +882,8 @@ static int palmas_regulators_probe(struct platform_device *pdev)
pmic->desc[id].id = id;
switch (id) {
case PALMAS_REG_SMPS10:
case PALMAS_REG_SMPS10_OUT1:
case PALMAS_REG_SMPS10_OUT2:
pmic->desc[id].n_voltages = PALMAS_SMPS10_NUM_VOLTAGES;
pmic->desc[id].ops = &palmas_ops_smps10;
pmic->desc[id].vsel_reg =
......@@ -882,7 +893,14 @@ static int palmas_regulators_probe(struct platform_device *pdev)
pmic->desc[id].enable_reg =
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
PALMAS_SMPS10_CTRL);
pmic->desc[id].enable_mask = SMPS10_BOOST_EN;
if (id == PALMAS_REG_SMPS10_OUT1)
pmic->desc[id].enable_mask = SMPS10_SWITCH_EN;
else
pmic->desc[id].enable_mask = SMPS10_BOOST_EN;
pmic->desc[id].bypass_reg =
PALMAS_BASE_TO_REG(PALMAS_SMPS_BASE,
PALMAS_SMPS10_CTRL);
pmic->desc[id].bypass_mask = SMPS10_BYPASS_EN;
pmic->desc[id].min_uV = 3750000;
pmic->desc[id].uV_step = 1250000;
break;
......
......@@ -243,7 +243,7 @@ static int pcap_regulator_probe(struct platform_device *pdev)
struct regulator_config config = { };
config.dev = &pdev->dev;
config.init_data = pdev->dev.platform_data;
config.init_data = dev_get_platdata(&pdev->dev);
config.driver_data = pcap;
rdev = regulator_register(&pcap_regulators[pdev->id], &config);
......
......@@ -86,7 +86,7 @@ static int pcf50633_regulator_probe(struct platform_device *pdev)
pcf = dev_to_pcf50633(pdev->dev.parent);
config.dev = &pdev->dev;
config.init_data = pdev->dev.platform_data;
config.init_data = dev_get_platdata(&pdev->dev);
config.driver_data = pcf;
config.regmap = pcf->regmap;
......
This diff is collapsed.
This diff is collapsed.
......@@ -717,11 +717,6 @@ static int ti_abb_probe(struct platform_device *pdev)
/* Map ABB resources */
pname = "base-address";
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
if (!res) {
dev_err(dev, "Missing '%s' IO resource\n", pname);
ret = -ENODEV;
goto err;
}
abb->base = devm_ioremap_resource(dev, res);
if (IS_ERR(abb->base)) {
ret = PTR_ERR(abb->base);
......@@ -770,11 +765,6 @@ static int ti_abb_probe(struct platform_device *pdev)
pname = "ldo-address";
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, pname);
if (!res) {
dev_dbg(dev, "Missing '%s' IO resource\n", pname);
ret = -ENODEV;
goto skip_opt;
}
abb->ldo_base = devm_ioremap_resource(dev, res);
if (IS_ERR(abb->ldo_base)) {
ret = PTR_ERR(abb->ldo_base);
......
......@@ -275,7 +275,7 @@ static int tps51632_probe(struct i2c_client *client,
}
}
pdata = client->dev.platform_data;
pdata = dev_get_platdata(&client->dev);
if (!pdata && client->dev.of_node)
pdata = of_get_tps51632_platform_data(&client->dev);
if (!pdata) {
......
......@@ -350,7 +350,7 @@ static int tps62360_probe(struct i2c_client *client,
int i;
int chip_id;
pdata = client->dev.platform_data;
pdata = dev_get_platdata(&client->dev);
if (client->dev.of_node) {
const struct of_device_id *match;
......
......@@ -218,7 +218,7 @@ static int tps_65023_probe(struct i2c_client *client,
* init_data points to array of regulator_init structures
* coming from the board-evm file.
*/
init_data = client->dev.platform_data;
init_data = dev_get_platdata(&client->dev);
if (!init_data)
return -EIO;
......
This diff is collapsed.
......@@ -601,7 +601,7 @@ static int pmic_probe(struct spi_device *spi)
struct regulator_config config = { };
int ret = 0, i;
init_data = dev->platform_data;
init_data = dev_get_platdata(dev);
if (!init_data) {
dev_err(dev, "could not find regulator platform data\n");
return -EINVAL;
......
......@@ -118,6 +118,15 @@ struct tps65912_reg {
int eco_reg;
};
static const struct regulator_linear_range tps65912_ldo_ranges[] = {
{ .min_uV = 800000, .max_uV = 1600000, .min_sel = 0, .max_sel = 32,
.uV_step = 25000 },
{ .min_uV = 1650000, .max_uV = 3000000, .min_sel = 33, .max_sel = 60,
.uV_step = 50000 },
{ .min_uV = 3100000, .max_uV = 3300000, .min_sel = 61, .max_sel = 63,
.uV_step = 100000 },
};
static int tps65912_get_range(struct tps65912_reg *pmic, int id)
{
struct tps65912 *mfd = pmic->mfd;
......@@ -184,20 +193,6 @@ static unsigned long tps65912_vsel_to_uv_range3(u8 vsel)
return uv;
}
static unsigned long tps65912_vsel_to_uv_ldo(u8 vsel)
{
unsigned long uv = 0;
if (vsel <= 32)
uv = ((vsel * 25000) + 800000);
else if (vsel > 32 && vsel <= 60)
uv = (((vsel - 32) * 50000) + 1600000);
else if (vsel > 60)
uv = (((vsel - 60) * 100000) + 3000000);
return uv;
}
static int tps65912_get_ctrl_register(int id)
{
if (id >= TPS65912_REG_DCDC1 && id <= TPS65912_REG_LDO4)
......@@ -376,9 +371,6 @@ static int tps65912_list_voltage(struct regulator_dev *dev, unsigned selector)
struct tps65912_reg *pmic = rdev_get_drvdata(dev);
int range, voltage = 0, id = rdev_get_id(dev);
if (id >= TPS65912_REG_LDO1 && id <= TPS65912_REG_LDO10)
return tps65912_vsel_to_uv_ldo(selector);
if (id > TPS65912_REG_DCDC4)
return -EINVAL;
......@@ -456,7 +448,8 @@ static struct regulator_ops tps65912_ops_ldo = {
.disable = tps65912_reg_disable,
.get_voltage_sel = tps65912_get_voltage_sel,
.set_voltage_sel = tps65912_set_voltage_sel,
.list_voltage = tps65912_list_voltage,
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
};
static int tps65912_probe(struct platform_device *pdev)
......@@ -495,8 +488,14 @@ static int tps65912_probe(struct platform_device *pdev)
pmic->desc[i].name = info->name;
pmic->desc[i].id = i;
pmic->desc[i].n_voltages = 64;
pmic->desc[i].ops = (i > TPS65912_REG_DCDC4 ?
&tps65912_ops_ldo : &tps65912_ops_dcdc);
if (i > TPS65912_REG_DCDC4) {
pmic->desc[i].ops = &tps65912_ops_ldo;
pmic->desc[i].linear_ranges = tps65912_ldo_ranges;
pmic->desc[i].n_linear_ranges =
ARRAY_SIZE(tps65912_ldo_ranges);
} else {
pmic->desc[i].ops = &tps65912_ops_dcdc;
}
pmic->desc[i].type = REGULATOR_VOLTAGE;
pmic->desc[i].owner = THIS_MODULE;
range = tps65912_get_range(pmic, i);
......
......@@ -1108,7 +1108,7 @@ static int twlreg_probe(struct platform_device *pdev)
drvdata = NULL;
} else {
id = pdev->id;
initdata = pdev->dev.platform_data;
initdata = dev_get_platdata(&pdev->dev);
for (i = 0, template = NULL; i < ARRAY_SIZE(twl_of_match); i++) {
template = twl_of_match[i].data;
if (template && template->desc.id == id)
......
......@@ -111,7 +111,7 @@ static int regulator_userspace_consumer_probe(struct platform_device *pdev)
struct userspace_consumer_data *drvdata;
int ret;
pdata = pdev->dev.platform_data;
pdata = dev_get_platdata(&pdev->dev);
if (!pdata)
return -EINVAL;
......
......@@ -287,7 +287,7 @@ static const struct attribute_group regulator_virtual_attr_group = {
static int regulator_virtual_probe(struct platform_device *pdev)
{
char *reg_id = pdev->dev.platform_data;
char *reg_id = dev_get_platdata(&pdev->dev);
struct virtual_consumer_data *drvdata;
int ret;
......
......@@ -451,7 +451,7 @@ static void wm831x_buckv_dvs_init(struct wm831x_dcdc *dcdc,
static int wm831x_buckv_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
struct regulator_config config = { };
int id;
struct wm831x_dcdc *dcdc;
......@@ -624,7 +624,7 @@ static struct regulator_ops wm831x_buckp_ops = {
static int wm831x_buckp_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
struct regulator_config config = { };
int id;
struct wm831x_dcdc *dcdc;
......@@ -770,7 +770,7 @@ static struct regulator_ops wm831x_boostp_ops = {
static int wm831x_boostp_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
struct regulator_config config = { };
int id = pdev->id % ARRAY_SIZE(pdata->dcdc);
struct wm831x_dcdc *dcdc;
......@@ -880,7 +880,7 @@ static struct regulator_ops wm831x_epe_ops = {
static int wm831x_epe_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
struct regulator_config config = { };
int id = pdev->id % ARRAY_SIZE(pdata->epe);
struct wm831x_dcdc *dcdc;
......
......@@ -151,7 +151,7 @@ static irqreturn_t wm831x_isink_irq(int irq, void *data)
static int wm831x_isink_probe(struct platform_device *pdev)
{
struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent);
struct wm831x_pdata *pdata = wm831x->dev->platform_data;
struct wm831x_pdata *pdata = dev_get_platdata(wm831x->dev);
struct wm831x_isink *isink;
int id = pdev->id % ARRAY_SIZE(pdata->isink);
struct regulator_config config = { };
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -125,7 +125,7 @@ static const struct regulator_init_data wm8994_ldo_default[] = {
static int wm8994_ldo_probe(struct platform_device *pdev)
{
struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent);
struct wm8994_pdata *pdata = wm8994->dev->platform_data;
struct wm8994_pdata *pdata = dev_get_platdata(wm8994->dev);
int id = pdev->id % ARRAY_SIZE(pdata->ldo);
struct regulator_config config = { };
struct wm8994_ldo *ldo;
......
......@@ -160,7 +160,8 @@ enum palmas_regulators {
PALMAS_REG_SMPS7,
PALMAS_REG_SMPS8,
PALMAS_REG_SMPS9,
PALMAS_REG_SMPS10,
PALMAS_REG_SMPS10_OUT2,
PALMAS_REG_SMPS10_OUT1,
/* LDO regulators */
PALMAS_REG_LDO1,
PALMAS_REG_LDO2,
......@@ -355,9 +356,9 @@ struct palmas_pmic {
int smps123;
int smps457;
int range[PALMAS_REG_SMPS10];
unsigned int ramp_delay[PALMAS_REG_SMPS10];
unsigned int current_reg_mode[PALMAS_REG_SMPS10];
int range[PALMAS_REG_SMPS10_OUT1];
unsigned int ramp_delay[PALMAS_REG_SMPS10_OUT1];
unsigned int current_reg_mode[PALMAS_REG_SMPS10_OUT1];
};
struct palmas_resource {
......
......@@ -191,6 +191,17 @@ enum s2mps11_regulators {
#define S2MPS11_BUCK_N_VOLTAGES (S2MPS11_BUCK_VSEL_MASK + 1)
#define S2MPS11_RAMP_DELAY 25000 /* uV/us */
#define S2MPS11_BUCK2_RAMP_SHIFT 6
#define S2MPS11_BUCK34_RAMP_SHIFT 4
#define S2MPS11_BUCK5_RAMP_SHIFT 6
#define S2MPS11_BUCK16_RAMP_SHIFT 4
#define S2MPS11_BUCK7810_RAMP_SHIFT 2
#define S2MPS11_BUCK9_RAMP_SHIFT 0
#define S2MPS11_BUCK2_RAMP_EN_SHIFT 3
#define S2MPS11_BUCK3_RAMP_EN_SHIFT 2
#define S2MPS11_BUCK4_RAMP_EN_SHIFT 1
#define S2MPS11_BUCK6_RAMP_EN_SHIFT 0
#define S2MPS11_PMIC_EN_SHIFT 6
#define S2MPS11_REGULATOR_MAX (S2MPS11_REG_MAX - 3)
......
......@@ -243,24 +243,6 @@ struct tps65217_board {
struct tps65217_bl_pdata *bl_pdata;
};
/**
* struct tps_info - packages regulator constraints
* @name: Voltage regulator name
* @min_uV: minimum micro volts
* @max_uV: minimum micro volts
* @vsel_to_uv: Function pointer to get voltage from selector
* @uv_to_vsel: Function pointer to get selector from voltage
*
* This data is used to check the regualtor voltage limits while setting.
*/
struct tps_info {
const char *name;
int min_uV;
int max_uV;
int (*vsel_to_uv)(unsigned int vsel);
int (*uv_to_vsel)(int uV, unsigned int *vsel);
};
/**
* struct tps65217 - tps65217 sub-driver chip access routines
*
......@@ -273,7 +255,6 @@ struct tps65217 {
unsigned int id;
struct regulator_desc desc[TPS65217_NUM_REGULATOR];
struct regulator_dev *rdev[TPS65217_NUM_REGULATOR];
struct tps_info *info[TPS65217_NUM_REGULATOR];
struct regmap *regmap;
};
......
This diff is collapsed.
This diff is collapsed.
......@@ -11,6 +11,7 @@
*/
#ifndef __FAN53555_H__
#define __FAN53555_H__
/* VSEL ID */
enum {
......
......@@ -134,6 +134,7 @@ struct regulation_constraints {
unsigned always_on:1; /* regulator never off when system is on */
unsigned boot_on:1; /* bootloader/firmware enabled regulator */
unsigned apply_uV:1; /* apply uV constraint if min == max */
unsigned ramp_disable:1; /* disable ramp delay */
};
/**
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment