提交 ec1882a9 编写于 作者: L 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
  ...
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",
......
/*
* Regulators driver for Marvell 88PM800
*
* Copyright (C) 2012 Marvell International Ltd.
* Joseph(Yossi) Hanin <yhanin@marvell.com>
* Yi Zhang <yizhang@marvell.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/mfd/88pm80x.h>
#include <linux/delay.h>
#include <linux/io.h>
#include <linux/of.h>
#include <linux/regulator/of_regulator.h>
/* LDO1 with DVC[0..3] */
#define PM800_LDO1_VOUT (0x08) /* VOUT1 */
#define PM800_LDO1_VOUT_2 (0x09)
#define PM800_LDO1_VOUT_3 (0x0A)
#define PM800_LDO2_VOUT (0x0B)
#define PM800_LDO3_VOUT (0x0C)
#define PM800_LDO4_VOUT (0x0D)
#define PM800_LDO5_VOUT (0x0E)
#define PM800_LDO6_VOUT (0x0F)
#define PM800_LDO7_VOUT (0x10)
#define PM800_LDO8_VOUT (0x11)
#define PM800_LDO9_VOUT (0x12)
#define PM800_LDO10_VOUT (0x13)
#define PM800_LDO11_VOUT (0x14)
#define PM800_LDO12_VOUT (0x15)
#define PM800_LDO13_VOUT (0x16)
#define PM800_LDO14_VOUT (0x17)
#define PM800_LDO15_VOUT (0x18)
#define PM800_LDO16_VOUT (0x19)
#define PM800_LDO17_VOUT (0x1A)
#define PM800_LDO18_VOUT (0x1B)
#define PM800_LDO19_VOUT (0x1C)
/* BUCK1 with DVC[0..3] */
#define PM800_BUCK1 (0x3C)
#define PM800_BUCK1_1 (0x3D)
#define PM800_BUCK1_2 (0x3E)
#define PM800_BUCK1_3 (0x3F)
#define PM800_BUCK2 (0x40)
#define PM800_BUCK3 (0x41)
#define PM800_BUCK3 (0x41)
#define PM800_BUCK4 (0x42)
#define PM800_BUCK4_1 (0x43)
#define PM800_BUCK4_2 (0x44)
#define PM800_BUCK4_3 (0x45)
#define PM800_BUCK5 (0x46)
#define PM800_BUCK_ENA (0x50)
#define PM800_LDO_ENA1_1 (0x51)
#define PM800_LDO_ENA1_2 (0x52)
#define PM800_LDO_ENA1_3 (0x53)
#define PM800_LDO_ENA2_1 (0x56)
#define PM800_LDO_ENA2_2 (0x57)
#define PM800_LDO_ENA2_3 (0x58)
#define PM800_BUCK1_MISC1 (0x78)
#define PM800_BUCK3_MISC1 (0x7E)
#define PM800_BUCK4_MISC1 (0x81)
#define PM800_BUCK5_MISC1 (0x84)
struct pm800_regulator_info {
struct regulator_desc desc;
int max_ua;
};
struct pm800_regulators {
struct regulator_dev *regulators[PM800_ID_RG_MAX];
struct pm80x_chip *chip;
struct regmap *map;
};
/*
* vreg - the buck regs string.
* ereg - the string for the enable register.
* ebit - the bit number in the enable register.
* amax - the current
* Buck has 2 kinds of voltage steps. It is easy to find voltage by ranges,
* not the constant voltage table.
* n_volt - Number of available selectors
*/
#define PM800_BUCK(vreg, ereg, ebit, amax, volt_ranges, n_volt) \
{ \
.desc = { \
.name = #vreg, \
.ops = &pm800_volt_range_ops, \
.type = REGULATOR_VOLTAGE, \
.id = PM800_ID_##vreg, \
.owner = THIS_MODULE, \
.n_voltages = n_volt, \
.linear_ranges = volt_ranges, \
.n_linear_ranges = ARRAY_SIZE(volt_ranges), \
.vsel_reg = PM800_##vreg, \
.vsel_mask = 0x7f, \
.enable_reg = PM800_##ereg, \
.enable_mask = 1 << (ebit), \
}, \
.max_ua = (amax), \
}
/*
* vreg - the LDO regs string
* ereg - the string for the enable register.
* ebit - the bit number in the enable register.
* amax - the current
* volt_table - the LDO voltage table
* For all the LDOes, there are too many ranges. Using volt_table will be
* simpler and faster.
*/
#define PM800_LDO(vreg, ereg, ebit, amax, ldo_volt_table) \
{ \
.desc = { \
.name = #vreg, \
.ops = &pm800_volt_table_ops, \
.type = REGULATOR_VOLTAGE, \
.id = PM800_ID_##vreg, \
.owner = THIS_MODULE, \
.n_voltages = ARRAY_SIZE(ldo_volt_table), \
.vsel_reg = PM800_##vreg##_VOUT, \
.vsel_mask = 0x1f, \
.enable_reg = PM800_##ereg, \
.enable_mask = 1 << (ebit), \
.volt_table = ldo_volt_table, \
}, \
.max_ua = (amax), \
}
/* Ranges are sorted in ascending order. */
static const struct regulator_linear_range buck1_volt_range[] = {
{ .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f,
.uV_step = 12500 },
{ .min_uV = 1600000, .max_uV = 1800000, .min_sel = 0x50,
.max_sel = 0x54, .uV_step = 50000 },
};
/* BUCK 2~5 have same ranges. */
static const struct regulator_linear_range buck2_5_volt_range[] = {
{ .min_uV = 600000, .max_uV = 1587500, .min_sel = 0, .max_sel = 0x4f,
.uV_step = 12500 },
{ .min_uV = 1600000, .max_uV = 3300000, .min_sel = 0x50,
.max_sel = 0x72, .uV_step = 50000 },
};
static const unsigned int ldo1_volt_table[] = {
600000, 650000, 700000, 750000, 800000, 850000, 900000, 950000,
1000000, 1050000, 1100000, 1150000, 1200000, 1300000, 1400000, 1500000,
};
static const unsigned int ldo2_volt_table[] = {
1700000, 1800000, 1900000, 2000000, 2100000, 2500000, 2700000, 2800000,
};
/* LDO 3~17 have same voltage table. */
static const unsigned int ldo3_17_volt_table[] = {
1200000, 1250000, 1700000, 1800000, 1850000, 1900000, 2500000, 2600000,
2700000, 2750000, 2800000, 2850000, 2900000, 3000000, 3100000, 3300000,
};
/* LDO 18~19 have same voltage table. */
static const unsigned int ldo18_19_volt_table[] = {
1700000, 1800000, 1900000, 2500000, 2800000, 2900000, 3100000, 3300000,
};
static int pm800_get_current_limit(struct regulator_dev *rdev)
{
struct pm800_regulator_info *info = rdev_get_drvdata(rdev);
return info->max_ua;
}
static struct regulator_ops pm800_volt_range_ops = {
.list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_current_limit = pm800_get_current_limit,
};
static struct regulator_ops pm800_volt_table_ops = {
.list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_iterate,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.get_current_limit = pm800_get_current_limit,
};
/* The array is indexed by id(PM800_ID_XXX) */
static struct pm800_regulator_info pm800_regulator_info[] = {
PM800_BUCK(BUCK1, BUCK_ENA, 0, 3000000, buck1_volt_range, 0x55),
PM800_BUCK(BUCK2, BUCK_ENA, 1, 1200000, buck2_5_volt_range, 0x73),
PM800_BUCK(BUCK3, BUCK_ENA, 2, 1200000, buck2_5_volt_range, 0x73),
PM800_BUCK(BUCK4, BUCK_ENA, 3, 1200000, buck2_5_volt_range, 0x73),
PM800_BUCK(BUCK5, BUCK_ENA, 4, 1200000, buck2_5_volt_range, 0x73),
PM800_LDO(LDO1, LDO_ENA1_1, 0, 200000, ldo1_volt_table),
PM800_LDO(LDO2, LDO_ENA1_1, 1, 10000, ldo2_volt_table),
PM800_LDO(LDO3, LDO_ENA1_1, 2, 300000, ldo3_17_volt_table),
PM800_LDO(LDO4, LDO_ENA1_1, 3, 300000, ldo3_17_volt_table),
PM800_LDO(LDO5, LDO_ENA1_1, 4, 300000, ldo3_17_volt_table),
PM800_LDO(LDO6, LDO_ENA1_1, 5, 300000, ldo3_17_volt_table),
PM800_LDO(LDO7, LDO_ENA1_1, 6, 300000, ldo3_17_volt_table),
PM800_LDO(LDO8, LDO_ENA1_1, 7, 300000, ldo3_17_volt_table),
PM800_LDO(LDO9, LDO_ENA1_2, 0, 300000, ldo3_17_volt_table),
PM800_LDO(LDO10, LDO_ENA1_2, 1, 300000, ldo3_17_volt_table),
PM800_LDO(LDO11, LDO_ENA1_2, 2, 300000, ldo3_17_volt_table),
PM800_LDO(LDO12, LDO_ENA1_2, 3, 300000, ldo3_17_volt_table),
PM800_LDO(LDO13, LDO_ENA1_2, 4, 300000, ldo3_17_volt_table),
PM800_LDO(LDO14, LDO_ENA1_2, 5, 300000, ldo3_17_volt_table),
PM800_LDO(LDO15, LDO_ENA1_2, 6, 300000, ldo3_17_volt_table),
PM800_LDO(LDO16, LDO_ENA1_2, 7, 300000, ldo3_17_volt_table),
PM800_LDO(LDO17, LDO_ENA1_3, 0, 300000, ldo3_17_volt_table),
PM800_LDO(LDO18, LDO_ENA1_3, 1, 200000, ldo18_19_volt_table),
PM800_LDO(LDO19, LDO_ENA1_3, 2, 200000, ldo18_19_volt_table),
};
#define PM800_REGULATOR_OF_MATCH(_name, _id) \
[PM800_ID_##_id] = { \
.name = #_name, \
.driver_data = &pm800_regulator_info[PM800_ID_##_id], \
}
static struct of_regulator_match pm800_regulator_matches[] = {
PM800_REGULATOR_OF_MATCH(buck1, BUCK1),
PM800_REGULATOR_OF_MATCH(buck2, BUCK2),
PM800_REGULATOR_OF_MATCH(buck3, BUCK3),
PM800_REGULATOR_OF_MATCH(buck4, BUCK4),
PM800_REGULATOR_OF_MATCH(buck5, BUCK5),
PM800_REGULATOR_OF_MATCH(ldo1, LDO1),
PM800_REGULATOR_OF_MATCH(ldo2, LDO2),
PM800_REGULATOR_OF_MATCH(ldo3, LDO3),
PM800_REGULATOR_OF_MATCH(ldo4, LDO4),
PM800_REGULATOR_OF_MATCH(ldo5, LDO5),
PM800_REGULATOR_OF_MATCH(ldo6, LDO6),
PM800_REGULATOR_OF_MATCH(ldo7, LDO7),
PM800_REGULATOR_OF_MATCH(ldo8, LDO8),
PM800_REGULATOR_OF_MATCH(ldo9, LDO9),
PM800_REGULATOR_OF_MATCH(ldo10, LDO10),
PM800_REGULATOR_OF_MATCH(ldo11, LDO11),
PM800_REGULATOR_OF_MATCH(ldo12, LDO12),
PM800_REGULATOR_OF_MATCH(ldo13, LDO13),
PM800_REGULATOR_OF_MATCH(ldo14, LDO14),
PM800_REGULATOR_OF_MATCH(ldo15, LDO15),
PM800_REGULATOR_OF_MATCH(ldo16, LDO16),
PM800_REGULATOR_OF_MATCH(ldo17, LDO17),
PM800_REGULATOR_OF_MATCH(ldo18, LDO18),
PM800_REGULATOR_OF_MATCH(ldo19, LDO19),
};
static int pm800_regulator_dt_init(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
int ret;
ret = of_regulator_match(&pdev->dev, np,
pm800_regulator_matches,
ARRAY_SIZE(pm800_regulator_matches));
if (ret < 0)
return ret;
return 0;
}
static int pm800_regulator_probe(struct platform_device *pdev)
{
struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct pm80x_platform_data *pdata = dev_get_platdata(pdev->dev.parent);
struct pm800_regulators *pm800_data;
struct pm800_regulator_info *info;
struct regulator_config config = { };
struct regulator_init_data *init_data;
int i, ret;
if (!pdata || pdata->num_regulators == 0) {
if (IS_ENABLED(CONFIG_OF)) {
ret = pm800_regulator_dt_init(pdev);
if (ret)
return ret;
} else {
return -ENODEV;
}
} else if (pdata->num_regulators) {
unsigned int count = 0;
/* Check whether num_regulator is valid. */
for (i = 0; i < ARRAY_SIZE(pdata->regulators); i++) {
if (pdata->regulators[i])
count++;
}
if (count != pdata->num_regulators)
return -EINVAL;
} else {
return -EINVAL;
}
pm800_data = devm_kzalloc(&pdev->dev, sizeof(*pm800_data),
GFP_KERNEL);
if (!pm800_data) {
dev_err(&pdev->dev, "Failed to allocate pm800_regualtors");
return -ENOMEM;
}
pm800_data->map = chip->subchip->regmap_power;
pm800_data->chip = chip;
platform_set_drvdata(pdev, pm800_data);
for (i = 0; i < PM800_ID_RG_MAX; i++) {
if (!pdata || pdata->num_regulators == 0)
init_data = pm800_regulator_matches[i].init_data;
else
init_data = pdata->regulators[i];
if (!init_data)
continue;
info = pm800_regulator_matches[i].driver_data;
config.dev = &pdev->dev;
config.init_data = init_data;
config.driver_data = info;
config.regmap = pm800_data->map;
config.of_node = pm800_regulator_matches[i].of_node;
pm800_data->regulators[i] =
regulator_register(&info->desc, &config);
if (IS_ERR(pm800_data->regulators[i])) {
ret = PTR_ERR(pm800_data->regulators[i]);
dev_err(&pdev->dev, "Failed to register %s\n",
info->desc.name);
while (--i >= 0)
regulator_unregister(pm800_data->regulators[i]);
return ret;
}
}
return 0;
}
static int pm800_regulator_remove(struct platform_device *pdev)
{
struct pm800_regulators *pm800_data = platform_get_drvdata(pdev);
int i;
for (i = 0; i < PM800_ID_RG_MAX; i++)
regulator_unregister(pm800_data->regulators[i]);
return 0;
}
static struct platform_driver pm800_regulator_driver = {
.driver = {
.name = "88pm80x-regulator",
.owner = THIS_MODULE,
},
.probe = pm800_regulator_probe,
.remove = pm800_regulator_remove,
};
module_platform_driver(pm800_regulator_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Joseph(Yossi) Hanin <yhanin@marvell.com>");
MODULE_DESCRIPTION("Regulator Driver for Marvell 88PM800 PMIC");
MODULE_ALIAS("platform:88pm800-regulator");
......@@ -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;
......
......@@ -64,15 +64,21 @@ config REGULATOR_USERSPACE_CONSUMER
If unsure, say no.
config REGULATOR_GPIO
tristate "GPIO regulator support"
depends on GPIOLIB
config REGULATOR_88PM800
tristate "Marvell 88PM800 Power regulators"
depends on MFD_88PM800
help
This driver provides support for regulators that can be
controlled via gpios.
It is capable of supporting current and voltage regulators
and the platform has to provide a mapping of GPIO-states
to target volts/amps.
This driver supports Marvell 88PM800 voltage regulator chips.
It delivers digitally programmable output,
the voltage is programmed via I2C interface.
It's suitable to support PXA988 chips to control VCC_MAIN and
various voltages.
config REGULATOR_88PM8607
tristate "Marvell 88PM8607 Power regulators"
depends on MFD_88PM860X=y
help
This driver supports 88PM8607 voltage regulator chips.
config REGULATOR_AD5398
tristate "Analog Devices AD5398/AD5821 regulators"
......@@ -81,6 +87,14 @@ config REGULATOR_AD5398
This driver supports AD5398 and AD5821 current regulator chips.
If building into module, its name is ad5398.ko.
config REGULATOR_ANATOP
tristate "Freescale i.MX on-chip ANATOP LDO regulators"
depends on MFD_SYSCON
help
Say y here to support Freescale i.MX on-chip ANATOP LDOs
regulators. It is recommended that this option be
enabled on i.MX6 platform.
config REGULATOR_AAT2870
tristate "AnalogicTech AAT2870 Regulators"
depends on MFD_AAT2870_CORE
......@@ -88,6 +102,22 @@ config REGULATOR_AAT2870
If you have a AnalogicTech AAT2870 say Y to enable the
regulator driver.
config REGULATOR_AB3100
tristate "ST-Ericsson AB3100 Regulator functions"
depends on AB3100_CORE
default y if AB3100_CORE
help
These regulators correspond to functionality in the
AB3100 analog baseband dealing with power regulators
for the system.
config REGULATOR_AB8500
bool "ST-Ericsson AB8500 Power Regulators"
depends on AB8500_CORE
help
This driver supports the regulators found on the ST-Ericsson mixed
signal AB8500 PMIC
config REGULATOR_ARIZONA
tristate "Wolfson Arizona class devices"
depends on MFD_ARIZONA
......@@ -96,6 +126,13 @@ config REGULATOR_ARIZONA
Support for the regulators found on Wolfson Arizona class
devices.
config REGULATOR_AS3711
tristate "AS3711 PMIC"
depends on MFD_AS3711
help
This driver provides support for the voltage regulators on the
AS3711 PMIC
config REGULATOR_DA903X
tristate "Dialog Semiconductor DA9030/DA9034 regulators"
depends on PMIC_DA903X
......@@ -120,6 +157,37 @@ config REGULATOR_DA9055
This driver can also be built as a module. If so, the module
will be called da9055-regulator.
config REGULATOR_DA9063
tristate "Dialog Semiconductor DA9063 regulators"
depends on MFD_DA9063
help
Say y here to support the BUCKs and LDOs regulators found on
DA9063 PMICs.
This driver can also be built as a module. If so, the module
will be called da9063-regulator.
config REGULATOR_DA9210
tristate "Dialog Semiconductor DA9210 regulator"
depends on I2C
select REGMAP_I2C
help
Say y here to support for the Dialog Semiconductor DA9210.
The DA9210 is a multi-phase synchronous step down
converter 12A DC-DC Buck controlled through an I2C
interface.
config REGULATOR_DBX500_PRCMU
bool
config REGULATOR_DB8500_PRCMU
bool "ST-Ericsson DB8500 Voltage Domain Regulators"
depends on MFD_DB8500_PRCMU
select REGULATOR_DBX500_PRCMU
help
This driver supports the voltage domain regulators controlled by the
DB8500 PRCMU
config REGULATOR_FAN53555
tristate "Fairchild FAN53555 Regulator"
depends on I2C
......@@ -131,44 +199,57 @@ config REGULATOR_FAN53555
input voltage supply of 2.5V to 5.5V. The output voltage is
programmed through an I2C interface.
config REGULATOR_ANATOP
tristate "Freescale i.MX on-chip ANATOP LDO regulators"
depends on MFD_SYSCON
config REGULATOR_GPIO
tristate "GPIO regulator support"
depends on GPIOLIB
help
Say y here to support Freescale i.MX on-chip ANATOP LDOs
regulators. It is recommended that this option be
enabled on i.MX6 platform.
This driver provides support for regulators that can be
controlled via gpios.
It is capable of supporting current and voltage regulators
and the platform has to provide a mapping of GPIO-states
to target volts/amps.
config REGULATOR_MC13XXX_CORE
tristate
config REGULATOR_ISL6271A
tristate "Intersil ISL6271A Power regulator"
depends on I2C
help
This driver supports ISL6271A voltage regulator chip.
config REGULATOR_MC13783
tristate "Freescale MC13783 regulator driver"
depends on MFD_MC13783
select REGULATOR_MC13XXX_CORE
config REGULATOR_LP3971
tristate "National Semiconductors LP3971 PMIC regulator driver"
depends on I2C
help
Say y here to support the regulators found on the Freescale MC13783
PMIC.
Say Y here to support the voltage regulators and convertors
on National Semiconductors LP3971 PMIC
config REGULATOR_MC13892
tristate "Freescale MC13892 regulator driver"
depends on MFD_MC13XXX
select REGULATOR_MC13XXX_CORE
config REGULATOR_LP3972
tristate "National Semiconductors LP3972 PMIC regulator driver"
depends on I2C
help
Say y here to support the regulators found on the Freescale MC13892
PMIC.
Say Y here to support the voltage regulators and convertors
on National Semiconductors LP3972 PMIC
config REGULATOR_ISL6271A
tristate "Intersil ISL6271A Power regulator"
config REGULATOR_LP872X
tristate "TI/National Semiconductor LP8720/LP8725 voltage regulators"
depends on I2C
select REGMAP_I2C
help
This driver supports ISL6271A voltage regulator chip.
This driver supports LP8720/LP8725 PMIC
config REGULATOR_88PM8607
bool "Marvell 88PM8607 Power regulators"
depends on MFD_88PM860X=y
config REGULATOR_LP8755
tristate "TI LP8755 High Performance PMU driver"
depends on I2C
select REGMAP_I2C
help
This driver supports 88PM8607 voltage regulator chips.
This driver supports LP8755 High Performance PMU driver. This
chip contains six step-down DC/DC converters which can support
9 mode multiphase configuration.
config REGULATOR_LP8788
tristate "TI LP8788 Power Regulators"
depends on MFD_LP8788
help
This driver supports LP8788 voltage regulator chip.
config REGULATOR_MAX1586
tristate "Maxim 1586/1587 voltage regulator"
......@@ -259,48 +340,43 @@ config REGULATOR_MAX77693
and one current regulator 'CHARGER'. This is suitable for
Exynos-4x12 chips.
config REGULATOR_PCAP
tristate "Motorola PCAP2 regulator driver"
depends on EZX_PCAP
help
This driver provides support for the voltage regulators of the
PCAP2 PMIC.
config REGULATOR_MC13XXX_CORE
tristate
config REGULATOR_LP3971
tristate "National Semiconductors LP3971 PMIC regulator driver"
depends on I2C
config REGULATOR_MC13783
tristate "Freescale MC13783 regulator driver"
depends on MFD_MC13783
select REGULATOR_MC13XXX_CORE
help
Say Y here to support the voltage regulators and convertors
on National Semiconductors LP3971 PMIC
Say y here to support the regulators found on the Freescale MC13783
PMIC.
config REGULATOR_LP3972
tristate "National Semiconductors LP3972 PMIC regulator driver"
depends on I2C
config REGULATOR_MC13892
tristate "Freescale MC13892 regulator driver"
depends on MFD_MC13XXX
select REGULATOR_MC13XXX_CORE
help
Say Y here to support the voltage regulators and convertors
on National Semiconductors LP3972 PMIC
Say y here to support the regulators found on the Freescale MC13892
PMIC.
config REGULATOR_LP872X
bool "TI/National Semiconductor LP8720/LP8725 voltage regulators"
depends on I2C=y
select REGMAP_I2C
config REGULATOR_PALMAS
tristate "TI Palmas PMIC Regulators"
depends on MFD_PALMAS
help
This driver supports LP8720/LP8725 PMIC
If you wish to control the regulators on the Palmas series of
chips say Y here. This will enable support for all the software
controllable SMPS/LDO regulators.
config REGULATOR_LP8755
tristate "TI LP8755 High Performance PMU driver"
depends on I2C
select REGMAP_I2C
help
This driver supports LP8755 High Performance PMU driver. This
chip contains six step-down DC/DC converters which can support
9 mode multiphase configuration.
The regulators available on Palmas series chips vary depending
on the muxing. This is handled automatically in the driver by
reading the mux info from OTP.
config REGULATOR_LP8788
bool "TI LP8788 Power Regulators"
depends on MFD_LP8788
config REGULATOR_PCAP
tristate "Motorola PCAP2 regulator driver"
depends on EZX_PCAP
help
This driver supports LP8788 voltage regulator chip.
This driver provides support for the voltage regulators of the
PCAP2 PMIC.
config REGULATOR_PCF50633
tristate "NXP PCF50633 regulator driver"
......@@ -309,6 +385,14 @@ config REGULATOR_PCF50633
Say Y here to support the voltage regulators and convertors
on PCF50633
config REGULATOR_PFUZE100
tristate "Support regulators on Freescale PFUZE100 PMIC"
depends on I2C
select REGMAP_I2C
help
Say y here to support the regulators found on the Freescale PFUZE100
PMIC.
config REGULATOR_RC5T583
tristate "RICOH RC5T583 Power regulators"
depends on MFD_RC5T583
......@@ -335,44 +419,15 @@ config REGULATOR_S5M8767
via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and
supports DVS mode with 8bits of output voltage control.
config REGULATOR_AB3100
tristate "ST-Ericsson AB3100 Regulator functions"
depends on AB3100_CORE
default y if AB3100_CORE
help
These regulators correspond to functionality in the
AB3100 analog baseband dealing with power regulators
for the system.
config REGULATOR_AB8500
bool "ST-Ericsson AB8500 Power Regulators"
depends on AB8500_CORE
help
This driver supports the regulators found on the ST-Ericsson mixed
signal AB8500 PMIC
config REGULATOR_DBX500_PRCMU
bool
config REGULATOR_DB8500_PRCMU
bool "ST-Ericsson DB8500 Voltage Domain Regulators"
depends on MFD_DB8500_PRCMU
select REGULATOR_DBX500_PRCMU
help
This driver supports the voltage domain regulators controlled by the
DB8500 PRCMU
config REGULATOR_PALMAS
tristate "TI Palmas PMIC Regulators"
depends on MFD_PALMAS
config REGULATOR_TI_ABB
tristate "TI Adaptive Body Bias on-chip LDO"
depends on ARCH_OMAP
help
If you wish to control the regulators on the Palmas series of
chips say Y here. This will enable support for all the software
controllable SMPS/LDO regulators.
The regulators available on Palmas series chips vary depending
on the muxing. This is handled automatically in the driver by
reading the mux info from OTP.
Select this option to support Texas Instruments' on-chip Adaptive Body
Bias (ABB) LDO regulators. It is recommended that this option be
enabled on required TI SoC. Certain Operating Performance Points
on TI SoCs may be unstable without enabling this as it provides
device specific optimized bias to allow/optimize functionality.
config REGULATOR_TPS51632
tristate "TI TPS51632 Power Regulator"
......@@ -475,22 +530,12 @@ config REGULATOR_TPS80031
output to control regulators.
config REGULATOR_TWL4030
bool "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC"
tristate "TI TWL4030/TWL5030/TWL6030/TPS659x0 PMIC"
depends on TWL4030_CORE
help
This driver supports the voltage regulators provided by
this family of companion chips.
config REGULATOR_TI_ABB
bool "TI Adaptive Body Bias on-chip LDO"
depends on ARCH_OMAP
help
Select this option to support Texas Instruments' on-chip Adaptive Body
Bias (ABB) LDO regulators. It is recommended that this option be
enabled on required TI SoC. Certain Operating Performance Points
on TI SoCs may be unstable without enabling this as it provides
device specific optimized bias to allow/optimize functionality.
config REGULATOR_VEXPRESS
tristate "Versatile Express regulators"
depends on VEXPRESS_CONFIG
......@@ -526,12 +571,5 @@ config REGULATOR_WM8994
This driver provides support for the voltage regulators on the
WM8994 CODEC.
config REGULATOR_AS3711
tristate "AS3711 PMIC"
depends on MFD_AS3711
help
This driver provides support for the voltage regulators on the
AS3711 PMIC
endif
......@@ -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, \
}
......
......@@ -323,13 +323,14 @@ static ssize_t regulator_uA_show(struct device *dev,
}
static DEVICE_ATTR(microamps, 0444, regulator_uA_show, NULL);
static ssize_t regulator_name_show(struct device *dev,
struct device_attribute *attr, char *buf)
static ssize_t name_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct regulator_dev *rdev = dev_get_drvdata(dev);
return sprintf(buf, "%s\n", rdev_get_name(rdev));
}
static DEVICE_ATTR_RO(name);
static ssize_t regulator_print_opmode(char *buf, int mode)
{
......@@ -489,15 +490,16 @@ static ssize_t regulator_total_uA_show(struct device *dev,
}
static DEVICE_ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL);
static ssize_t regulator_num_users_show(struct device *dev,
struct device_attribute *attr, char *buf)
static ssize_t num_users_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct regulator_dev *rdev = dev_get_drvdata(dev);
return sprintf(buf, "%d\n", rdev->use_count);
}
static DEVICE_ATTR_RO(num_users);
static ssize_t regulator_type_show(struct device *dev,
struct device_attribute *attr, char *buf)
static ssize_t type_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct regulator_dev *rdev = dev_get_drvdata(dev);
......@@ -509,6 +511,7 @@ static ssize_t regulator_type_show(struct device *dev,
}
return sprintf(buf, "unknown\n");
}
static DEVICE_ATTR_RO(type);
static ssize_t regulator_suspend_mem_uV_show(struct device *dev,
struct device_attribute *attr, char *buf)
......@@ -632,12 +635,13 @@ static DEVICE_ATTR(bypass, 0444,
* These are the only attributes are present for all regulators.
* Other attributes are a function of regulator functionality.
*/
static struct device_attribute regulator_dev_attrs[] = {
__ATTR(name, 0444, regulator_name_show, NULL),
__ATTR(num_users, 0444, regulator_num_users_show, NULL),
__ATTR(type, 0444, regulator_type_show, NULL),
__ATTR_NULL,
static struct attribute *regulator_dev_attrs[] = {
&dev_attr_name.attr,
&dev_attr_num_users.attr,
&dev_attr_type.attr,
NULL,
};
ATTRIBUTE_GROUPS(regulator_dev);
static void regulator_dev_release(struct device *dev)
{
......@@ -648,7 +652,7 @@ static void regulator_dev_release(struct device *dev)
static struct class regulator_class = {
.name = "regulator",
.dev_release = regulator_dev_release,
.dev_attrs = regulator_dev_attrs,
.dev_groups = regulator_dev_groups,
};
/* Calculate the new optimum regulator operating mode based on the new total
......@@ -984,7 +988,8 @@ static int set_machine_constraints(struct regulator_dev *rdev,
}
}
if (rdev->constraints->ramp_delay && ops->set_ramp_delay) {
if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable)
&& ops->set_ramp_delay) {
ret = ops->set_ramp_delay(rdev, rdev->constraints->ramp_delay);
if (ret < 0) {
rdev_err(rdev, "failed to set ramp_delay\n");
......@@ -1238,7 +1243,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
/* Internal regulator request function */
static struct regulator *_regulator_get(struct device *dev, const char *id,
int exclusive)
bool exclusive)
{
struct regulator_dev *rdev;
struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);
......@@ -1344,7 +1349,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
*/
struct regulator *regulator_get(struct device *dev, const char *id)
{
return _regulator_get(dev, id, 0);
return _regulator_get(dev, id, false);
}
EXPORT_SYMBOL_GPL(regulator_get);
......@@ -1405,10 +1410,69 @@ EXPORT_SYMBOL_GPL(devm_regulator_get);
*/
struct regulator *regulator_get_exclusive(struct device *dev, const char *id)
{
return _regulator_get(dev, id, 1);
return _regulator_get(dev, id, true);
}
EXPORT_SYMBOL_GPL(regulator_get_exclusive);
/**
* regulator_get_optional - obtain optional access to a regulator.
* @dev: device for regulator "consumer"
* @id: Supply name or regulator ID.
*
* Returns a struct regulator corresponding to the regulator producer,
* or IS_ERR() condition containing errno. Other consumers will be
* unable to obtain this reference is held and the use count for the
* regulator will be initialised to reflect the current state of the
* regulator.
*
* This is intended for use by consumers for devices which can have
* some supplies unconnected in normal use, such as some MMC devices.
* It can allow the regulator core to provide stub supplies for other
* supplies requested using normal regulator_get() calls without
* disrupting the operation of drivers that can handle absent
* supplies.
*
* Use of supply names configured via regulator_set_device_supply() is
* strongly encouraged. It is recommended that the supply name used
* should match the name used for the supply and/or the relevant
* device pins in the datasheet.
*/
struct regulator *regulator_get_optional(struct device *dev, const char *id)
{
return _regulator_get(dev, id, 0);
}
EXPORT_SYMBOL_GPL(regulator_get_optional);
/**
* devm_regulator_get_optional - Resource managed regulator_get_optional()
* @dev: device for regulator "consumer"
* @id: Supply name or regulator ID.
*
* Managed regulator_get_optional(). Regulators returned from this
* function are automatically regulator_put() on driver detach. See
* regulator_get_optional() for more information.
*/
struct regulator *devm_regulator_get_optional(struct device *dev,
const char *id)
{
struct regulator **ptr, *regulator;
ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
regulator = regulator_get_optional(dev, id);
if (!IS_ERR(regulator)) {
*ptr = regulator;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return regulator;
}
EXPORT_SYMBOL_GPL(devm_regulator_get_optional);
/* Locks held by regulator_put() */
static void _regulator_put(struct regulator *regulator)
{
......@@ -1434,6 +1498,36 @@ static void _regulator_put(struct regulator *regulator)
module_put(rdev->owner);
}
/**
* devm_regulator_get_exclusive - Resource managed regulator_get_exclusive()
* @dev: device for regulator "consumer"
* @id: Supply name or regulator ID.
*
* Managed regulator_get_exclusive(). Regulators returned from this function
* are automatically regulator_put() on driver detach. See regulator_get() for
* more information.
*/
struct regulator *devm_regulator_get_exclusive(struct device *dev,
const char *id)
{
struct regulator **ptr, *regulator;
ptr = devres_alloc(devm_regulator_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
return ERR_PTR(-ENOMEM);
regulator = _regulator_get(dev, id, 1);
if (!IS_ERR(regulator)) {
*ptr = regulator;
devres_add(dev, ptr);
} else {
devres_free(ptr);
}
return regulator;
}
EXPORT_SYMBOL_GPL(devm_regulator_get_exclusive);
/**
* regulator_put - "free" the regulator source
* @regulator: regulator source
......@@ -1890,8 +1984,9 @@ int regulator_disable_deferred(struct regulator *regulator, int ms)
rdev->deferred_disables++;
mutex_unlock(&rdev->mutex);
ret = schedule_delayed_work(&rdev->disable_work,
msecs_to_jiffies(ms));
ret = queue_delayed_work(system_power_efficient_wq,
&rdev->disable_work,
msecs_to_jiffies(ms));
if (ret < 0)
return ret;
else
......@@ -1899,77 +1994,6 @@ int regulator_disable_deferred(struct regulator *regulator, int ms)
}
EXPORT_SYMBOL_GPL(regulator_disable_deferred);
/**
* regulator_is_enabled_regmap - standard is_enabled() for regmap users
*
* @rdev: regulator to operate on
*
* Regulators that use regmap for their register I/O can set the
* enable_reg and enable_mask fields in their descriptor and then use
* this as their is_enabled operation, saving some code.
*/
int regulator_is_enabled_regmap(struct regulator_dev *rdev)
{
unsigned int val;
int ret;
ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);
if (ret != 0)
return ret;
if (rdev->desc->enable_is_inverted)
return (val & rdev->desc->enable_mask) == 0;
else
return (val & rdev->desc->enable_mask) != 0;
}
EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
/**
* regulator_enable_regmap - standard enable() for regmap users
*
* @rdev: regulator to operate on
*
* Regulators that use regmap for their register I/O can set the
* enable_reg and enable_mask fields in their descriptor and then use
* this as their enable() operation, saving some code.
*/
int regulator_enable_regmap(struct regulator_dev *rdev)
{
unsigned int val;
if (rdev->desc->enable_is_inverted)
val = 0;
else
val = rdev->desc->enable_mask;
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
rdev->desc->enable_mask, val);
}
EXPORT_SYMBOL_GPL(regulator_enable_regmap);
/**
* regulator_disable_regmap - standard disable() for regmap users
*
* @rdev: regulator to operate on
*
* Regulators that use regmap for their register I/O can set the
* enable_reg and enable_mask fields in their descriptor and then use
* this as their disable() operation, saving some code.
*/
int regulator_disable_regmap(struct regulator_dev *rdev)
{
unsigned int val;
if (rdev->desc->enable_is_inverted)
val = rdev->desc->enable_mask;
else
val = 0;
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
rdev->desc->enable_mask, val);
}
EXPORT_SYMBOL_GPL(regulator_disable_regmap);
static int _regulator_is_enabled(struct regulator_dev *rdev)
{
/* A GPIO control always takes precedence */
......@@ -2054,55 +2078,6 @@ int regulator_count_voltages(struct regulator *regulator)
}
EXPORT_SYMBOL_GPL(regulator_count_voltages);
/**
* regulator_list_voltage_linear - List voltages with simple calculation
*
* @rdev: Regulator device
* @selector: Selector to convert into a voltage
*
* Regulators with a simple linear mapping between voltages and
* selectors can set min_uV and uV_step in the regulator descriptor
* and then use this function as their list_voltage() operation,
*/
int regulator_list_voltage_linear(struct regulator_dev *rdev,
unsigned int selector)
{
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
if (selector < rdev->desc->linear_min_sel)
return 0;
selector -= rdev->desc->linear_min_sel;
return rdev->desc->min_uV + (rdev->desc->uV_step * selector);
}
EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
/**
* regulator_list_voltage_table - List voltages with table based mapping
*
* @rdev: Regulator device
* @selector: Selector to convert into a voltage
*
* Regulators with table based mapping between voltages and
* selectors can set volt_table in the regulator descriptor
* and then use this function as their list_voltage() operation.
*/
int regulator_list_voltage_table(struct regulator_dev *rdev,
unsigned int selector)
{
if (!rdev->desc->volt_table) {
BUG_ON(!rdev->desc->volt_table);
return -EINVAL;
}
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
return rdev->desc->volt_table[selector];
}
EXPORT_SYMBOL_GPL(regulator_list_voltage_table);
/**
* regulator_list_voltage - enumerate supported voltages
* @regulator: regulator source
......@@ -2197,177 +2172,6 @@ int regulator_is_supported_voltage(struct regulator *regulator,
}
EXPORT_SYMBOL_GPL(regulator_is_supported_voltage);
/**
* regulator_get_voltage_sel_regmap - standard get_voltage_sel for regmap users
*
* @rdev: regulator to operate on
*
* Regulators that use regmap for their register I/O can set the
* vsel_reg and vsel_mask fields in their descriptor and then use this
* as their get_voltage_vsel operation, saving some code.
*/
int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev)
{
unsigned int val;
int ret;
ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val);
if (ret != 0)
return ret;
val &= rdev->desc->vsel_mask;
val >>= ffs(rdev->desc->vsel_mask) - 1;
return val;
}
EXPORT_SYMBOL_GPL(regulator_get_voltage_sel_regmap);
/**
* regulator_set_voltage_sel_regmap - standard set_voltage_sel for regmap users
*
* @rdev: regulator to operate on
* @sel: Selector to set
*
* Regulators that use regmap for their register I/O can set the
* vsel_reg and vsel_mask fields in their descriptor and then use this
* as their set_voltage_vsel operation, saving some code.
*/
int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel)
{
int ret;
sel <<= ffs(rdev->desc->vsel_mask) - 1;
ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg,
rdev->desc->vsel_mask, sel);
if (ret)
return ret;
if (rdev->desc->apply_bit)
ret = regmap_update_bits(rdev->regmap, rdev->desc->apply_reg,
rdev->desc->apply_bit,
rdev->desc->apply_bit);
return ret;
}
EXPORT_SYMBOL_GPL(regulator_set_voltage_sel_regmap);
/**
* regulator_map_voltage_iterate - map_voltage() based on list_voltage()
*
* @rdev: Regulator to operate on
* @min_uV: Lower bound for voltage
* @max_uV: Upper bound for voltage
*
* Drivers implementing set_voltage_sel() and list_voltage() can use
* this as their map_voltage() operation. It will find a suitable
* voltage by calling list_voltage() until it gets something in bounds
* for the requested voltages.
*/
int regulator_map_voltage_iterate(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
int best_val = INT_MAX;
int selector = 0;
int i, ret;
/* Find the smallest voltage that falls within the specified
* range.
*/
for (i = 0; i < rdev->desc->n_voltages; i++) {
ret = rdev->desc->ops->list_voltage(rdev, i);
if (ret < 0)
continue;
if (ret < best_val && ret >= min_uV && ret <= max_uV) {
best_val = ret;
selector = i;
}
}
if (best_val != INT_MAX)
return selector;
else
return -EINVAL;
}
EXPORT_SYMBOL_GPL(regulator_map_voltage_iterate);
/**
* regulator_map_voltage_ascend - map_voltage() for ascendant voltage list
*
* @rdev: Regulator to operate on
* @min_uV: Lower bound for voltage
* @max_uV: Upper bound for voltage
*
* Drivers that have ascendant voltage list can use this as their
* map_voltage() operation.
*/
int regulator_map_voltage_ascend(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
int i, ret;
for (i = 0; i < rdev->desc->n_voltages; i++) {
ret = rdev->desc->ops->list_voltage(rdev, i);
if (ret < 0)
continue;
if (ret > max_uV)
break;
if (ret >= min_uV && ret <= max_uV)
return i;
}
return -EINVAL;
}
EXPORT_SYMBOL_GPL(regulator_map_voltage_ascend);
/**
* regulator_map_voltage_linear - map_voltage() for simple linear mappings
*
* @rdev: Regulator to operate on
* @min_uV: Lower bound for voltage
* @max_uV: Upper bound for voltage
*
* Drivers providing min_uV and uV_step in their regulator_desc can
* use this as their map_voltage() operation.
*/
int regulator_map_voltage_linear(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
int ret, voltage;
/* Allow uV_step to be 0 for fixed voltage */
if (rdev->desc->n_voltages == 1 && rdev->desc->uV_step == 0) {
if (min_uV <= rdev->desc->min_uV && rdev->desc->min_uV <= max_uV)
return 0;
else
return -EINVAL;
}
if (!rdev->desc->uV_step) {
BUG_ON(!rdev->desc->uV_step);
return -EINVAL;
}
if (min_uV < rdev->desc->min_uV)
min_uV = rdev->desc->min_uV;
ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step);
if (ret < 0)
return ret;
ret += rdev->desc->linear_min_sel;
/* Map back into a voltage to verify we're still in bounds */
voltage = rdev->desc->ops->list_voltage(rdev, ret);
if (voltage < min_uV || voltage > max_uV)
return -EINVAL;
return ret;
}
EXPORT_SYMBOL_GPL(regulator_map_voltage_linear);
static int _regulator_do_set_voltage(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
......@@ -2438,8 +2242,8 @@ static int _regulator_do_set_voltage(struct regulator_dev *rdev,
}
/* Call set_voltage_time_sel if successfully obtained old_selector */
if (ret == 0 && _regulator_is_enabled(rdev) && old_selector >= 0 &&
old_selector != selector && rdev->desc->ops->set_voltage_time_sel) {
if (ret == 0 && !rdev->constraints->ramp_disable && old_selector >= 0
&& old_selector != selector) {
delay = rdev->desc->ops->set_voltage_time_sel(rdev,
old_selector, selector);
......@@ -2970,47 +2774,6 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
}
EXPORT_SYMBOL_GPL(regulator_set_optimum_mode);
/**
* regulator_set_bypass_regmap - Default set_bypass() using regmap
*
* @rdev: device to operate on.
* @enable: state to set.
*/
int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable)
{
unsigned int val;
if (enable)
val = rdev->desc->bypass_mask;
else
val = 0;
return regmap_update_bits(rdev->regmap, rdev->desc->bypass_reg,
rdev->desc->bypass_mask, val);
}
EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap);
/**
* regulator_get_bypass_regmap - Default get_bypass() using regmap
*
* @rdev: device to operate on.
* @enable: current state.
*/
int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable)
{
unsigned int val;
int ret;
ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val);
if (ret != 0)
return ret;
*enable = val & rdev->desc->bypass_mask;
return 0;
}
EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap);
/**
* regulator_allow_bypass - allow the regulator to go into bypass mode
*
......@@ -3740,8 +3503,11 @@ void regulator_unregister(struct regulator_dev *rdev)
if (rdev == NULL)
return;
if (rdev->supply)
if (rdev->supply) {
while (rdev->use_count--)
regulator_disable(rdev->supply);
regulator_put(rdev->supply);
}
mutex_lock(&regulator_list_mutex);
debugfs_remove_recursive(rdev->debugfs);
flush_work(&rdev->disable_work.work);
......
......@@ -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)
......
此差异已折叠。
/*
* 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 = { };
......
/*
* helpers.c -- Voltage/Current Regulator framework helper functions.
*
* Copyright 2007, 2008 Wolfson Microelectronics PLC.
* Copyright 2008 SlimLogic Ltd.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/
#include <linux/kernel.h>
#include <linux/err.h>
#include <linux/delay.h>
#include <linux/regmap.h>
#include <linux/regulator/consumer.h>
#include <linux/regulator/driver.h>
#include <linux/module.h>
/**
* regulator_is_enabled_regmap - standard is_enabled() for regmap users
*
* @rdev: regulator to operate on
*
* Regulators that use regmap for their register I/O can set the
* enable_reg and enable_mask fields in their descriptor and then use
* this as their is_enabled operation, saving some code.
*/
int regulator_is_enabled_regmap(struct regulator_dev *rdev)
{
unsigned int val;
int ret;
ret = regmap_read(rdev->regmap, rdev->desc->enable_reg, &val);
if (ret != 0)
return ret;
if (rdev->desc->enable_is_inverted)
return (val & rdev->desc->enable_mask) == 0;
else
return (val & rdev->desc->enable_mask) != 0;
}
EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
/**
* regulator_enable_regmap - standard enable() for regmap users
*
* @rdev: regulator to operate on
*
* Regulators that use regmap for their register I/O can set the
* enable_reg and enable_mask fields in their descriptor and then use
* this as their enable() operation, saving some code.
*/
int regulator_enable_regmap(struct regulator_dev *rdev)
{
unsigned int val;
if (rdev->desc->enable_is_inverted)
val = 0;
else
val = rdev->desc->enable_mask;
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
rdev->desc->enable_mask, val);
}
EXPORT_SYMBOL_GPL(regulator_enable_regmap);
/**
* regulator_disable_regmap - standard disable() for regmap users
*
* @rdev: regulator to operate on
*
* Regulators that use regmap for their register I/O can set the
* enable_reg and enable_mask fields in their descriptor and then use
* this as their disable() operation, saving some code.
*/
int regulator_disable_regmap(struct regulator_dev *rdev)
{
unsigned int val;
if (rdev->desc->enable_is_inverted)
val = rdev->desc->enable_mask;
else
val = 0;
return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
rdev->desc->enable_mask, val);
}
EXPORT_SYMBOL_GPL(regulator_disable_regmap);
/**
* regulator_get_voltage_sel_regmap - standard get_voltage_sel for regmap users
*
* @rdev: regulator to operate on
*
* Regulators that use regmap for their register I/O can set the
* vsel_reg and vsel_mask fields in their descriptor and then use this
* as their get_voltage_vsel operation, saving some code.
*/
int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev)
{
unsigned int val;
int ret;
ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val);
if (ret != 0)
return ret;
val &= rdev->desc->vsel_mask;
val >>= ffs(rdev->desc->vsel_mask) - 1;
return val;
}
EXPORT_SYMBOL_GPL(regulator_get_voltage_sel_regmap);
/**
* regulator_set_voltage_sel_regmap - standard set_voltage_sel for regmap users
*
* @rdev: regulator to operate on
* @sel: Selector to set
*
* Regulators that use regmap for their register I/O can set the
* vsel_reg and vsel_mask fields in their descriptor and then use this
* as their set_voltage_vsel operation, saving some code.
*/
int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel)
{
int ret;
sel <<= ffs(rdev->desc->vsel_mask) - 1;
ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg,
rdev->desc->vsel_mask, sel);
if (ret)
return ret;
if (rdev->desc->apply_bit)
ret = regmap_update_bits(rdev->regmap, rdev->desc->apply_reg,
rdev->desc->apply_bit,
rdev->desc->apply_bit);
return ret;
}
EXPORT_SYMBOL_GPL(regulator_set_voltage_sel_regmap);
/**
* regulator_map_voltage_iterate - map_voltage() based on list_voltage()
*
* @rdev: Regulator to operate on
* @min_uV: Lower bound for voltage
* @max_uV: Upper bound for voltage
*
* Drivers implementing set_voltage_sel() and list_voltage() can use
* this as their map_voltage() operation. It will find a suitable
* voltage by calling list_voltage() until it gets something in bounds
* for the requested voltages.
*/
int regulator_map_voltage_iterate(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
int best_val = INT_MAX;
int selector = 0;
int i, ret;
/* Find the smallest voltage that falls within the specified
* range.
*/
for (i = 0; i < rdev->desc->n_voltages; i++) {
ret = rdev->desc->ops->list_voltage(rdev, i);
if (ret < 0)
continue;
if (ret < best_val && ret >= min_uV && ret <= max_uV) {
best_val = ret;
selector = i;
}
}
if (best_val != INT_MAX)
return selector;
else
return -EINVAL;
}
EXPORT_SYMBOL_GPL(regulator_map_voltage_iterate);
/**
* regulator_map_voltage_ascend - map_voltage() for ascendant voltage list
*
* @rdev: Regulator to operate on
* @min_uV: Lower bound for voltage
* @max_uV: Upper bound for voltage
*
* Drivers that have ascendant voltage list can use this as their
* map_voltage() operation.
*/
int regulator_map_voltage_ascend(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
int i, ret;
for (i = 0; i < rdev->desc->n_voltages; i++) {
ret = rdev->desc->ops->list_voltage(rdev, i);
if (ret < 0)
continue;
if (ret > max_uV)
break;
if (ret >= min_uV && ret <= max_uV)
return i;
}
return -EINVAL;
}
EXPORT_SYMBOL_GPL(regulator_map_voltage_ascend);
/**
* regulator_map_voltage_linear - map_voltage() for simple linear mappings
*
* @rdev: Regulator to operate on
* @min_uV: Lower bound for voltage
* @max_uV: Upper bound for voltage
*
* Drivers providing min_uV and uV_step in their regulator_desc can
* use this as their map_voltage() operation.
*/
int regulator_map_voltage_linear(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
int ret, voltage;
/* Allow uV_step to be 0 for fixed voltage */
if (rdev->desc->n_voltages == 1 && rdev->desc->uV_step == 0) {
if (min_uV <= rdev->desc->min_uV && rdev->desc->min_uV <= max_uV)
return 0;
else
return -EINVAL;
}
if (!rdev->desc->uV_step) {
BUG_ON(!rdev->desc->uV_step);
return -EINVAL;
}
if (min_uV < rdev->desc->min_uV)
min_uV = rdev->desc->min_uV;
ret = DIV_ROUND_UP(min_uV - rdev->desc->min_uV, rdev->desc->uV_step);
if (ret < 0)
return ret;
ret += rdev->desc->linear_min_sel;
/* Map back into a voltage to verify we're still in bounds */
voltage = rdev->desc->ops->list_voltage(rdev, ret);
if (voltage < min_uV || voltage > max_uV)
return -EINVAL;
return ret;
}
EXPORT_SYMBOL_GPL(regulator_map_voltage_linear);
/**
* regulator_map_voltage_linear - map_voltage() for multiple linear ranges
*
* @rdev: Regulator to operate on
* @min_uV: Lower bound for voltage
* @max_uV: Upper bound for voltage
*
* Drivers providing linear_ranges in their descriptor can use this as
* their map_voltage() callback.
*/
int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
int min_uV, int max_uV)
{
const struct regulator_linear_range *range;
int ret = -EINVAL;
int voltage, i;
if (!rdev->desc->n_linear_ranges) {
BUG_ON(!rdev->desc->n_linear_ranges);
return -EINVAL;
}
for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
range = &rdev->desc->linear_ranges[i];
if (!(min_uV <= range->max_uV && max_uV >= range->min_uV))
continue;
if (min_uV <= range->min_uV)
min_uV = range->min_uV;
/* range->uV_step == 0 means fixed voltage range */
if (range->uV_step == 0) {
ret = 0;
} else {
ret = DIV_ROUND_UP(min_uV - range->min_uV,
range->uV_step);
if (ret < 0)
return ret;
}
ret += range->min_sel;
break;
}
if (i == rdev->desc->n_linear_ranges)
return -EINVAL;
/* Map back into a voltage to verify we're still in bounds */
voltage = rdev->desc->ops->list_voltage(rdev, ret);
if (voltage < min_uV || voltage > max_uV)
return -EINVAL;
return ret;
}
EXPORT_SYMBOL_GPL(regulator_map_voltage_linear_range);
/**
* regulator_list_voltage_linear - List voltages with simple calculation
*
* @rdev: Regulator device
* @selector: Selector to convert into a voltage
*
* Regulators with a simple linear mapping between voltages and
* selectors can set min_uV and uV_step in the regulator descriptor
* and then use this function as their list_voltage() operation,
*/
int regulator_list_voltage_linear(struct regulator_dev *rdev,
unsigned int selector)
{
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
if (selector < rdev->desc->linear_min_sel)
return 0;
selector -= rdev->desc->linear_min_sel;
return rdev->desc->min_uV + (rdev->desc->uV_step * selector);
}
EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
/**
* regulator_list_voltage_linear_range - List voltages for linear ranges
*
* @rdev: Regulator device
* @selector: Selector to convert into a voltage
*
* Regulators with a series of simple linear mappings between voltages
* and selectors can set linear_ranges in the regulator descriptor and
* then use this function as their list_voltage() operation,
*/
int regulator_list_voltage_linear_range(struct regulator_dev *rdev,
unsigned int selector)
{
const struct regulator_linear_range *range;
int i;
if (!rdev->desc->n_linear_ranges) {
BUG_ON(!rdev->desc->n_linear_ranges);
return -EINVAL;
}
for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
range = &rdev->desc->linear_ranges[i];
if (!(selector >= range->min_sel &&
selector <= range->max_sel))
continue;
selector -= range->min_sel;
return range->min_uV + (range->uV_step * selector);
}
return -EINVAL;
}
EXPORT_SYMBOL_GPL(regulator_list_voltage_linear_range);
/**
* regulator_list_voltage_table - List voltages with table based mapping
*
* @rdev: Regulator device
* @selector: Selector to convert into a voltage
*
* Regulators with table based mapping between voltages and
* selectors can set volt_table in the regulator descriptor
* and then use this function as their list_voltage() operation.
*/
int regulator_list_voltage_table(struct regulator_dev *rdev,
unsigned int selector)
{
if (!rdev->desc->volt_table) {
BUG_ON(!rdev->desc->volt_table);
return -EINVAL;
}
if (selector >= rdev->desc->n_voltages)
return -EINVAL;
return rdev->desc->volt_table[selector];
}
EXPORT_SYMBOL_GPL(regulator_list_voltage_table);
/**
* regulator_set_bypass_regmap - Default set_bypass() using regmap
*
* @rdev: device to operate on.
* @enable: state to set.
*/
int regulator_set_bypass_regmap(struct regulator_dev *rdev, bool enable)
{
unsigned int val;
if (enable)
val = rdev->desc->bypass_mask;
else
val = 0;
return regmap_update_bits(rdev->regmap, rdev->desc->bypass_reg,
rdev->desc->bypass_mask, val);
}
EXPORT_SYMBOL_GPL(regulator_set_bypass_regmap);
/**
* regulator_get_bypass_regmap - Default get_bypass() using regmap
*
* @rdev: device to operate on.
* @enable: current state.
*/
int regulator_get_bypass_regmap(struct regulator_dev *rdev, bool *enable)
{
unsigned int val;
int ret;
ret = regmap_read(rdev->regmap, rdev->desc->bypass_reg, &val);
if (ret != 0)
return ret;
*enable = val & rdev->desc->bypass_mask;
return 0;
}
EXPORT_SYMBOL_GPL(regulator_get_bypass_regmap);
......@@ -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;
......
/*
* Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/err.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/regulator/of_regulator.h>
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/pfuze100.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/regmap.h>
#define PFUZE_NUMREGS 128
#define PFUZE100_VOL_OFFSET 0
#define PFUZE100_STANDBY_OFFSET 1
#define PFUZE100_MODE_OFFSET 3
#define PFUZE100_CONF_OFFSET 4
#define PFUZE100_DEVICEID 0x0
#define PFUZE100_REVID 0x3
#define PFUZE100_FABID 0x3
#define PFUZE100_SW1ABVOL 0x20
#define PFUZE100_SW1CVOL 0x2e
#define PFUZE100_SW2VOL 0x35
#define PFUZE100_SW3AVOL 0x3c
#define PFUZE100_SW3BVOL 0x43
#define PFUZE100_SW4VOL 0x4a
#define PFUZE100_SWBSTCON1 0x66
#define PFUZE100_VREFDDRCON 0x6a
#define PFUZE100_VSNVSVOL 0x6b
#define PFUZE100_VGEN1VOL 0x6c
#define PFUZE100_VGEN2VOL 0x6d
#define PFUZE100_VGEN3VOL 0x6e
#define PFUZE100_VGEN4VOL 0x6f
#define PFUZE100_VGEN5VOL 0x70
#define PFUZE100_VGEN6VOL 0x71
struct pfuze_regulator {
struct regulator_desc desc;
unsigned char stby_reg;
unsigned char stby_mask;
};
struct pfuze_chip {
struct regmap *regmap;
struct device *dev;
struct pfuze_regulator regulator_descs[PFUZE100_MAX_REGULATOR];
struct regulator_dev *regulators[PFUZE100_MAX_REGULATOR];
};
static const int pfuze100_swbst[] = {
5000000, 5050000, 5100000, 5150000,
};
static const int pfuze100_vsnvs[] = {
1000000, 1100000, 1200000, 1300000, 1500000, 1800000, 3000000,
};
static const struct i2c_device_id pfuze_device_id[] = {
{.name = "pfuze100"},
{},
};
MODULE_DEVICE_TABLE(i2c, pfuze_device_id);
static const struct of_device_id pfuze_dt_ids[] = {
{ .compatible = "fsl,pfuze100" },
{},
};
MODULE_DEVICE_TABLE(of, pfuze_dt_ids);
static int pfuze100_set_ramp_delay(struct regulator_dev *rdev, int ramp_delay)
{
struct pfuze_chip *pfuze100 = rdev_get_drvdata(rdev);
int id = rdev->desc->id;
unsigned int ramp_bits;
int ret;
if (id < PFUZE100_SWBST) {
ramp_delay = 12500 / ramp_delay;
ramp_bits = (ramp_delay >> 1) - (ramp_delay >> 3);
ret = regmap_update_bits(pfuze100->regmap,
rdev->desc->vsel_reg + 4,
0xc0, ramp_bits << 6);
if (ret < 0)
dev_err(pfuze100->dev, "ramp failed, err %d\n", ret);
} else
ret = -EACCES;
return ret;
}
static struct regulator_ops pfuze100_ldo_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
};
static struct regulator_ops pfuze100_fixed_regulator_ops = {
.list_voltage = regulator_list_voltage_linear,
};
static struct regulator_ops pfuze100_sw_regulator_ops = {
.list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_time_sel = regulator_set_voltage_time_sel,
.set_ramp_delay = pfuze100_set_ramp_delay,
};
static struct regulator_ops pfuze100_swb_regulator_ops = {
.list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_ascend,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
};
#define PFUZE100_FIXED_REG(_name, base, voltage) \
[PFUZE100_ ## _name] = { \
.desc = { \
.name = #_name, \
.n_voltages = 1, \
.ops = &pfuze100_fixed_regulator_ops, \
.type = REGULATOR_VOLTAGE, \
.id = PFUZE100_ ## _name, \
.owner = THIS_MODULE, \
.min_uV = (voltage), \
.enable_reg = (base), \
.enable_mask = 0x10, \
}, \
}
#define PFUZE100_SW_REG(_name, base, min, max, step) \
[PFUZE100_ ## _name] = { \
.desc = { \
.name = #_name,\
.n_voltages = ((max) - (min)) / (step) + 1, \
.ops = &pfuze100_sw_regulator_ops, \
.type = REGULATOR_VOLTAGE, \
.id = PFUZE100_ ## _name, \
.owner = THIS_MODULE, \
.min_uV = (min), \
.uV_step = (step), \
.vsel_reg = (base) + PFUZE100_VOL_OFFSET, \
.vsel_mask = 0x3f, \
}, \
.stby_reg = (base) + PFUZE100_STANDBY_OFFSET, \
.stby_mask = 0x3f, \
}
#define PFUZE100_SWB_REG(_name, base, mask, voltages) \
[PFUZE100_ ## _name] = { \
.desc = { \
.name = #_name, \
.n_voltages = ARRAY_SIZE(voltages), \
.ops = &pfuze100_swb_regulator_ops, \
.type = REGULATOR_VOLTAGE, \
.id = PFUZE100_ ## _name, \
.owner = THIS_MODULE, \
.volt_table = voltages, \
.vsel_reg = (base), \
.vsel_mask = (mask), \
}, \
}
#define PFUZE100_VGEN_REG(_name, base, min, max, step) \
[PFUZE100_ ## _name] = { \
.desc = { \
.name = #_name, \
.n_voltages = ((max) - (min)) / (step) + 1, \
.ops = &pfuze100_ldo_regulator_ops, \
.type = REGULATOR_VOLTAGE, \
.id = PFUZE100_ ## _name, \
.owner = THIS_MODULE, \
.min_uV = (min), \
.uV_step = (step), \
.vsel_reg = (base), \
.vsel_mask = 0xf, \
.enable_reg = (base), \
.enable_mask = 0x10, \
}, \
.stby_reg = (base), \
.stby_mask = 0x20, \
}
static struct pfuze_regulator pfuze100_regulators[] = {
PFUZE100_SW_REG(SW1AB, PFUZE100_SW1ABVOL, 300000, 1875000, 25000),
PFUZE100_SW_REG(SW1C, PFUZE100_SW1CVOL, 300000, 1875000, 25000),
PFUZE100_SW_REG(SW2, PFUZE100_SW2VOL, 400000, 1975000, 25000),
PFUZE100_SW_REG(SW3A, PFUZE100_SW3AVOL, 400000, 1975000, 25000),
PFUZE100_SW_REG(SW3B, PFUZE100_SW3BVOL, 400000, 1975000, 25000),
PFUZE100_SW_REG(SW4, PFUZE100_SW4VOL, 400000, 1975000, 25000),
PFUZE100_SWB_REG(SWBST, PFUZE100_SWBSTCON1, 0x3 , pfuze100_swbst),
PFUZE100_SWB_REG(VSNVS, PFUZE100_VSNVSVOL, 0x7, pfuze100_vsnvs),
PFUZE100_FIXED_REG(VREFDDR, PFUZE100_VREFDDRCON, 750000),
PFUZE100_VGEN_REG(VGEN1, PFUZE100_VGEN1VOL, 800000, 1550000, 50000),
PFUZE100_VGEN_REG(VGEN2, PFUZE100_VGEN2VOL, 800000, 1550000, 50000),
PFUZE100_VGEN_REG(VGEN3, PFUZE100_VGEN3VOL, 1800000, 3300000, 100000),
PFUZE100_VGEN_REG(VGEN4, PFUZE100_VGEN4VOL, 1800000, 3300000, 100000),
PFUZE100_VGEN_REG(VGEN5, PFUZE100_VGEN5VOL, 1800000, 3300000, 100000),
PFUZE100_VGEN_REG(VGEN6, PFUZE100_VGEN6VOL, 1800000, 3300000, 100000),
};
#ifdef CONFIG_OF
static struct of_regulator_match pfuze100_matches[] = {
{ .name = "sw1ab", },
{ .name = "sw1c", },
{ .name = "sw2", },
{ .name = "sw3a", },
{ .name = "sw3b", },
{ .name = "sw4", },
{ .name = "swbst", },
{ .name = "vsnvs", },
{ .name = "vrefddr", },
{ .name = "vgen1", },
{ .name = "vgen2", },
{ .name = "vgen3", },
{ .name = "vgen4", },
{ .name = "vgen5", },
{ .name = "vgen6", },
};
static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
{
struct device *dev = chip->dev;
struct device_node *np, *parent;
int ret;
np = of_node_get(dev->parent->of_node);
if (!np)
return 0;
parent = of_find_node_by_name(np, "regulators");
if (!parent) {
dev_err(dev, "regulators node not found\n");
return -EINVAL;
}
ret = of_regulator_match(dev, parent, pfuze100_matches,
ARRAY_SIZE(pfuze100_matches));
of_node_put(parent);
if (ret < 0) {
dev_err(dev, "Error parsing regulator init data: %d\n",
ret);
return ret;
}
return 0;
}
static inline struct regulator_init_data *match_init_data(int index)
{
return pfuze100_matches[index].init_data;
}
static inline struct device_node *match_of_node(int index)
{
return pfuze100_matches[index].of_node;
}
#else
static int pfuze_parse_regulators_dt(struct pfuze_chip *chip)
{
return 0;
}
static inline struct regulator_init_data *match_init_data(int index)
{
return NULL;
}
static inline struct device_node *match_of_node(int index)
{
return NULL;
}
#endif
static int pfuze_identify(struct pfuze_chip *pfuze_chip)
{
unsigned int value;
int ret;
ret = regmap_read(pfuze_chip->regmap, PFUZE100_DEVICEID, &value);
if (ret)
return ret;
if (value & 0x0f) {
dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value);
return -ENODEV;
}
ret = regmap_read(pfuze_chip->regmap, PFUZE100_REVID, &value);
if (ret)
return ret;
dev_info(pfuze_chip->dev,
"Full lay: %x, Metal lay: %x\n",
(value & 0xf0) >> 4, value & 0x0f);
ret = regmap_read(pfuze_chip->regmap, PFUZE100_FABID, &value);
if (ret)
return ret;
dev_info(pfuze_chip->dev, "FAB: %x, FIN: %x\n",
(value & 0xc) >> 2, value & 0x3);
return 0;
}
static const struct regmap_config pfuze_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = PFUZE_NUMREGS - 1,
.cache_type = REGCACHE_RBTREE,
};
static int pfuze100_regulator_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct pfuze_chip *pfuze_chip;
struct pfuze_regulator_platform_data *pdata =
dev_get_platdata(&client->dev);
struct regulator_config config = { };
int i, ret;
pfuze_chip = devm_kzalloc(&client->dev, sizeof(*pfuze_chip),
GFP_KERNEL);
if (!pfuze_chip)
return -ENOMEM;
i2c_set_clientdata(client, pfuze_chip);
memcpy(pfuze_chip->regulator_descs, pfuze100_regulators,
sizeof(pfuze_chip->regulator_descs));
pfuze_chip->dev = &client->dev;
pfuze_chip->regmap = devm_regmap_init_i2c(client, &pfuze_regmap_config);
if (IS_ERR(pfuze_chip->regmap)) {
ret = PTR_ERR(pfuze_chip->regmap);
dev_err(&client->dev,
"regmap allocation failed with err %d\n", ret);
return ret;
}
ret = pfuze_identify(pfuze_chip);
if (ret) {
dev_err(&client->dev, "unrecognized pfuze chip ID!\n");
return ret;
}
ret = pfuze_parse_regulators_dt(pfuze_chip);
if (ret)
return ret;
for (i = 0; i < PFUZE100_MAX_REGULATOR; i++) {
struct regulator_init_data *init_data;
struct regulator_desc *desc;
int val;
desc = &pfuze_chip->regulator_descs[i].desc;
if (pdata)
init_data = pdata->init_data[i];
else
init_data = match_init_data(i);
/* SW2~SW4 high bit check and modify the voltage value table */
if (i > PFUZE100_SW1C && i < PFUZE100_SWBST) {
regmap_read(pfuze_chip->regmap, desc->vsel_reg, &val);
if (val & 0x40) {
desc->min_uV = 800000;
desc->uV_step = 50000;
desc->n_voltages = 51;
}
}
config.dev = &client->dev;
config.init_data = init_data;
config.driver_data = pfuze_chip;
config.of_node = match_of_node(i);
pfuze_chip->regulators[i] = regulator_register(desc, &config);
if (IS_ERR(pfuze_chip->regulators[i])) {
dev_err(&client->dev, "register regulator%s failed\n",
pfuze100_regulators[i].desc.name);
ret = PTR_ERR(pfuze_chip->regulators[i]);
while (--i >= 0)
regulator_unregister(pfuze_chip->regulators[i]);
return ret;
}
}
return 0;
}
static int pfuze100_regulator_remove(struct i2c_client *client)
{
int i;
struct pfuze_chip *pfuze_chip = i2c_get_clientdata(client);
for (i = 0; i < PFUZE100_MAX_REGULATOR; i++)
regulator_unregister(pfuze_chip->regulators[i]);
return 0;
}
static struct i2c_driver pfuze_driver = {
.id_table = pfuze_device_id,
.driver = {
.name = "pfuze100-regulator",
.owner = THIS_MODULE,
.of_match_table = pfuze_dt_ids,
},
.probe = pfuze100_regulator_probe,
.remove = pfuze100_regulator_remove,
};
module_i2c_driver(pfuze_driver);
MODULE_AUTHOR("Robin Gong <b38343@freescale.com>");
MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100 PMIC");
MODULE_LICENSE("GPL v2");
MODULE_ALIAS("i2c:pfuze100-regulator");
此差异已折叠。
......@@ -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;
......
......@@ -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 = { };
......
此差异已折叠。
......@@ -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;
};
......
此差异已折叠。
此差异已折叠。
......@@ -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 */
};
/**
......
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册