Commit 61be53f9 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull regulator updates from Mark Brown:
 "In terms of big picture changes this has been an extremely quiet
  release however there's a lot of changes and a fairly big diffstat
  thanks to a bunch of small fixes, mainly coming from Axel Lin. Thanks
  to his work this release removes code overall even though we've added
  a new (albiet fairly small) driver.

  Notable things:

   - A fix for a long standing issue with locking on error interrupts
     from Steve Twiss.

   - A new driver for ST Microelectonics STM32 PWR"

* tag 'regulator-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (134 commits)
  regulator: core: simplify return value on suported_voltage
  regulator: da9xxx: Switch to SPDX identifier
  regulator: stm32-pwr: Remove unneeded .min_uV and .list_volage
  regulator: stm32-pwr: Remove unneeded *desc from struct stm32_pwr_reg
  regulator: ab3100: Set fixed_uV instead of min_uV for fixed regulators
  regulator: ab3100: Constify regulator_ops and ab3100_regulator_desc
  regulator: pv880x0: Switch to SPDX identifier
  regulator: hi6xxx: Switch to SPDX identifier
  regulator: vexpress: Switch to SPDX identifier
  regulator: vexpress: Get rid of struct vexpress_regulator
  regulator: sky81452: Switch to SPDX identifier
  regulator: sky81452: Constify sky81452_reg_ops
  regulator: sy8106a: Get rid of struct sy8106a
  regulator: core: do not report EPROBE_DEFER as error but as debug
  regulator: mt63xx: Switch to SPDX identifier
  regulator: fan53555: Switch to SPDX identifier
  regulator: fan53555: Clean up unneeded fields from struct fan53555_device_info
  regulator: ltc3589: Switch to SPDX identifier
  regulator: ltc3589: Get rid of struct ltc3589_regulator
  regulator: ltc3589: Convert to use simplified DT parsing
  ...
parents 962d5ecc e2a23aff
...@@ -4,16 +4,30 @@ Required properties: ...@@ -4,16 +4,30 @@ Required properties:
- compatible : Must be "regulator-gpio". - compatible : Must be "regulator-gpio".
- regulator-name : Defined in regulator.txt as optional, but required - regulator-name : Defined in regulator.txt as optional, but required
here. here.
- states : Selection of available voltages and GPIO configs. - gpios : Array of one or more GPIO pins used to select the
if there are no states, then use a fixed regulator regulator voltage/current listed in "states".
- states : Selection of available voltages/currents provided by
this regulator and matching GPIO configurations to
achieve them. If there are no states in the "states"
array, use a fixed regulator instead.
Optional properties: Optional properties:
- enable-gpio : GPIO to use to enable/disable the regulator. - enable-gpios : GPIO used to enable/disable the regulator.
- gpios : GPIO group used to control voltage. Warning, the GPIO phandle flags are ignored and the
- gpios-states : gpios pin's initial states array. 0: LOW, 1: HIGH. GPIO polarity is controlled solely by the presence
defualt is LOW if nothing is specified. of "enable-active-high" DT property. This is due to
compatibility with old DTs.
- enable-active-high : Polarity of "enable-gpio" GPIO is active HIGH.
Default is active LOW.
- gpios-states : On operating systems, that don't support reading back
gpio values in output mode (most notably linux), this
array provides the state of GPIO pins set when
requesting them from the gpio controller. Systems,
that are capable of preserving state when requesting
the lines, are free to ignore this property.
0: LOW, 1: HIGH. Default is LOW if nothing else
is specified.
- startup-delay-us : Startup time in microseconds. - startup-delay-us : Startup time in microseconds.
- enable-active-high : Polarity of GPIO is active high (default is low).
- regulator-type : Specifies what is being regulated, must be either - regulator-type : Specifies what is being regulated, must be either
"voltage" or "current", defaults to voltage. "voltage" or "current", defaults to voltage.
...@@ -30,7 +44,7 @@ Example: ...@@ -30,7 +44,7 @@ Example:
regulator-max-microvolt = <2600000>; regulator-max-microvolt = <2600000>;
regulator-boot-on; regulator-boot-on;
enable-gpio = <&gpio0 23 0x4>; enable-gpios = <&gpio0 23 0x4>;
gpios = <&gpio0 24 0x4 gpios = <&gpio0 24 0x4
&gpio0 25 0x4>; &gpio0 25 0x4>;
states = <1800000 0x3 states = <1800000 0x3
......
STM32MP1 PWR Regulators
-----------------------
Available Regulators in STM32MP1 PWR block are:
- reg11 for regulator 1V1
- reg18 for regulator 1V8
- usb33 for the swtich USB3V3
Required properties:
- compatible: Must be "st,stm32mp1,pwr-reg"
- list of child nodes that specify the regulator reg11, reg18 or usb33
initialization data for defined regulators. The definition for each of
these nodes is defined using the standard binding for regulators found at
Documentation/devicetree/bindings/regulator/regulator.txt.
- vdd-supply: phandle to the parent supply/regulator node for vdd input
- vdd_3v3_usbfs-supply: phandle to the parent supply/regulator node for usb33
Example:
pwr_regulators: pwr@50001000 {
compatible = "st,stm32mp1,pwr-reg";
reg = <0x50001000 0x10>;
vdd-supply = <&vdd>;
vdd_3v3_usbfs-supply = <&vdd_usb>;
reg11: reg11 {
regulator-name = "reg11";
regulator-min-microvolt = <1100000>;
regulator-max-microvolt = <1100000>;
};
reg18: reg18 {
regulator-name = "reg18";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
};
usb33: usb33 {
regulator-name = "usb33";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
};
};
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
/* Current settings - values are 2*2^(reg_val/4) microamps. These are /* Current settings - values are 2*2^(reg_val/4) microamps. These are
* exported since they are used by multiple drivers. * exported since they are used by multiple drivers.
*/ */
int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = { const unsigned int wm831x_isinkv_values[WM831X_ISINK_MAX_ISEL + 1] = {
2, 2,
2, 2,
3, 3,
......
...@@ -35,12 +35,6 @@ static bool wm8400_volatile(struct device *dev, unsigned int reg) ...@@ -35,12 +35,6 @@ static bool wm8400_volatile(struct device *dev, unsigned int reg)
} }
} }
int wm8400_block_read(struct wm8400 *wm8400, u8 reg, int count, u16 *data)
{
return regmap_bulk_read(wm8400->regmap, reg, data, count);
}
EXPORT_SYMBOL_GPL(wm8400_block_read);
static int wm8400_register_codec(struct wm8400 *wm8400) static int wm8400_register_codec(struct wm8400 *wm8400)
{ {
const struct mfd_cell cell = { const struct mfd_cell cell = {
......
...@@ -77,11 +77,6 @@ struct pm800_regulator_info { ...@@ -77,11 +77,6 @@ struct pm800_regulator_info {
int max_ua; int max_ua;
}; };
struct pm800_regulators {
struct pm80x_chip *chip;
struct regmap *map;
};
/* /*
* vreg - the buck regs string. * vreg - the buck regs string.
* ereg - the string for the enable register. * ereg - the string for the enable register.
...@@ -235,7 +230,6 @@ static int pm800_regulator_probe(struct platform_device *pdev) ...@@ -235,7 +230,6 @@ static int pm800_regulator_probe(struct platform_device *pdev)
{ {
struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent); struct pm80x_chip *chip = dev_get_drvdata(pdev->dev.parent);
struct pm80x_platform_data *pdata = dev_get_platdata(pdev->dev.parent); struct pm80x_platform_data *pdata = dev_get_platdata(pdev->dev.parent);
struct pm800_regulators *pm800_data;
struct regulator_config config = { }; struct regulator_config config = { };
struct regulator_init_data *init_data; struct regulator_init_data *init_data;
int i, ret; int i, ret;
...@@ -252,18 +246,8 @@ static int pm800_regulator_probe(struct platform_device *pdev) ...@@ -252,18 +246,8 @@ static int pm800_regulator_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
pm800_data = devm_kzalloc(&pdev->dev, sizeof(*pm800_data),
GFP_KERNEL);
if (!pm800_data)
return -ENOMEM;
pm800_data->map = chip->subchip->regmap_power;
pm800_data->chip = chip;
platform_set_drvdata(pdev, pm800_data);
config.dev = chip->dev; config.dev = chip->dev;
config.regmap = pm800_data->map; config.regmap = chip->subchip->regmap_power;
for (i = 0; i < PM800_ID_RG_MAX; i++) { for (i = 0; i < PM800_ID_RG_MAX; i++) {
struct regulator_dev *regulator; struct regulator_dev *regulator;
......
...@@ -235,6 +235,8 @@ static const struct regulator_ops pm8606_preg_ops = { ...@@ -235,6 +235,8 @@ static const struct regulator_ops pm8606_preg_ops = {
{ \ { \
.desc = { \ .desc = { \
.name = "PREG", \ .name = "PREG", \
.of_match = of_match_ptr("PREG"), \
.regulators_node = of_match_ptr("regulators"), \
.ops = &pm8606_preg_ops, \ .ops = &pm8606_preg_ops, \
.type = REGULATOR_CURRENT, \ .type = REGULATOR_CURRENT, \
.id = PM8606_ID_PREG, \ .id = PM8606_ID_PREG, \
...@@ -249,6 +251,8 @@ static const struct regulator_ops pm8606_preg_ops = { ...@@ -249,6 +251,8 @@ static const struct regulator_ops pm8606_preg_ops = {
{ \ { \
.desc = { \ .desc = { \
.name = #vreg, \ .name = #vreg, \
.of_match = of_match_ptr(#vreg), \
.regulators_node = of_match_ptr("regulators"), \
.ops = &pm8607_regulator_ops, \ .ops = &pm8607_regulator_ops, \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = PM8607_ID_##vreg, \ .id = PM8607_ID_##vreg, \
...@@ -270,6 +274,8 @@ static const struct regulator_ops pm8606_preg_ops = { ...@@ -270,6 +274,8 @@ static const struct regulator_ops pm8606_preg_ops = {
{ \ { \
.desc = { \ .desc = { \
.name = "LDO" #_id, \ .name = "LDO" #_id, \
.of_match = of_match_ptr("LDO" #_id), \
.regulators_node = of_match_ptr("regulators"), \
.ops = &pm8607_regulator_ops, \ .ops = &pm8607_regulator_ops, \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = PM8607_ID_LDO##_id, \ .id = PM8607_ID_LDO##_id, \
...@@ -309,36 +315,6 @@ static struct pm8607_regulator_info pm8606_regulator_info[] = { ...@@ -309,36 +315,6 @@ static struct pm8607_regulator_info pm8606_regulator_info[] = {
PM8606_PREG(PREREGULATORB, 5), PM8606_PREG(PREREGULATORB, 5),
}; };
#ifdef CONFIG_OF
static int pm8607_regulator_dt_init(struct platform_device *pdev,
struct pm8607_regulator_info *info,
struct regulator_config *config)
{
struct device_node *nproot, *np;
nproot = pdev->dev.parent->of_node;
if (!nproot)
return -ENODEV;
nproot = of_get_child_by_name(nproot, "regulators");
if (!nproot) {
dev_err(&pdev->dev, "failed to find regulators node\n");
return -ENODEV;
}
for_each_child_of_node(nproot, np) {
if (of_node_name_eq(np, info->desc.name)) {
config->init_data =
of_get_regulator_init_data(&pdev->dev, np,
&info->desc);
config->of_node = np;
break;
}
}
of_node_put(nproot);
return 0;
}
#else
#define pm8607_regulator_dt_init(x, y, z) (-1)
#endif
static int pm8607_regulator_probe(struct platform_device *pdev) static int pm8607_regulator_probe(struct platform_device *pdev)
{ {
struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent);
...@@ -373,10 +349,9 @@ static int pm8607_regulator_probe(struct platform_device *pdev) ...@@ -373,10 +349,9 @@ static int pm8607_regulator_probe(struct platform_device *pdev)
if ((i == PM8607_ID_BUCK3) && chip->buck3_double) if ((i == PM8607_ID_BUCK3) && chip->buck3_double)
info->slope_double = 1; info->slope_double = 1;
config.dev = &pdev->dev; config.dev = chip->dev;
config.driver_data = info; config.driver_data = info;
if (pm8607_regulator_dt_init(pdev, info, &config))
if (pdata) if (pdata)
config.init_data = pdata; config.init_data = pdata;
......
...@@ -223,6 +223,7 @@ config REGULATOR_CPCAP ...@@ -223,6 +223,7 @@ config REGULATOR_CPCAP
config REGULATOR_DA903X config REGULATOR_DA903X
tristate "Dialog Semiconductor DA9030/DA9034 regulators" tristate "Dialog Semiconductor DA9030/DA9034 regulators"
depends on PMIC_DA903X depends on PMIC_DA903X
depends on !CC_IS_CLANG # https://bugs.llvm.org/show_bug.cgi?id=38789
help help
Say y here to support the BUCKs and LDOs regulators found on Say y here to support the BUCKs and LDOs regulators found on
Dialog Semiconductor DA9030/DA9034 PMIC. Dialog Semiconductor DA9030/DA9034 PMIC.
...@@ -839,6 +840,13 @@ config REGULATOR_STM32_VREFBUF ...@@ -839,6 +840,13 @@ config REGULATOR_STM32_VREFBUF
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called stm32-vrefbuf. will be called stm32-vrefbuf.
config REGULATOR_STM32_PWR
bool "STMicroelectronics STM32 PWR"
depends on ARCH_STM32 || COMPILE_TEST
help
This driver supports internal regulators (1V1, 1V8, 3V3) in the
STMicroelectronics STM32 chips.
config REGULATOR_STPMIC1 config REGULATOR_STPMIC1
tristate "STMicroelectronics STPMIC1 PMIC Regulators" tristate "STMicroelectronics STPMIC1 PMIC Regulators"
depends on MFD_STPMIC1 depends on MFD_STPMIC1
...@@ -1010,7 +1018,8 @@ config REGULATOR_TWL4030 ...@@ -1010,7 +1018,8 @@ config REGULATOR_TWL4030
config REGULATOR_UNIPHIER config REGULATOR_UNIPHIER
tristate "UniPhier regulator driver" tristate "UniPhier regulator driver"
depends on ARCH_UNIPHIER || COMPILE_TEST depends on ARCH_UNIPHIER || COMPILE_TEST
depends on OF && MFD_SYSCON depends on OF
select REGMAP_MMIO
default ARCH_UNIPHIER default ARCH_UNIPHIER
help help
Support for regulators implemented on Socionext UniPhier SoCs. Support for regulators implemented on Socionext UniPhier SoCs.
......
...@@ -105,6 +105,7 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o ...@@ -105,6 +105,7 @@ obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o
obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
obj-$(CONFIG_REGULATOR_STM32_PWR) += stm32-pwr.o
obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o obj-$(CONFIG_REGULATOR_STPMIC1) += stpmic1_regulator.o
obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
......
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
* @regreg: regulator register number in the AB3100 * @regreg: regulator register number in the AB3100
*/ */
struct ab3100_regulator { struct ab3100_regulator {
struct regulator_dev *rdev;
struct device *dev; struct device *dev;
struct ab3100_platform_data *plfdata; struct ab3100_platform_data *plfdata;
u8 regreg; u8 regreg;
...@@ -354,14 +353,13 @@ static int ab3100_get_voltage_regulator_external(struct regulator_dev *reg) ...@@ -354,14 +353,13 @@ static int ab3100_get_voltage_regulator_external(struct regulator_dev *reg)
return 0; return 0;
} }
static struct regulator_ops regulator_ops_fixed = { static const struct regulator_ops regulator_ops_fixed = {
.list_voltage = regulator_list_voltage_linear,
.enable = ab3100_enable_regulator, .enable = ab3100_enable_regulator,
.disable = ab3100_disable_regulator, .disable = ab3100_disable_regulator,
.is_enabled = ab3100_is_enabled_regulator, .is_enabled = ab3100_is_enabled_regulator,
}; };
static struct regulator_ops regulator_ops_variable = { static const struct regulator_ops regulator_ops_variable = {
.enable = ab3100_enable_regulator, .enable = ab3100_enable_regulator,
.disable = ab3100_disable_regulator, .disable = ab3100_disable_regulator,
.is_enabled = ab3100_is_enabled_regulator, .is_enabled = ab3100_is_enabled_regulator,
...@@ -370,7 +368,7 @@ static struct regulator_ops regulator_ops_variable = { ...@@ -370,7 +368,7 @@ static struct regulator_ops regulator_ops_variable = {
.list_voltage = regulator_list_voltage_table, .list_voltage = regulator_list_voltage_table,
}; };
static struct regulator_ops regulator_ops_variable_sleepable = { static const struct regulator_ops regulator_ops_variable_sleepable = {
.enable = ab3100_enable_regulator, .enable = ab3100_enable_regulator,
.disable = ab3100_disable_regulator, .disable = ab3100_disable_regulator,
.is_enabled = ab3100_is_enabled_regulator, .is_enabled = ab3100_is_enabled_regulator,
...@@ -386,14 +384,14 @@ static struct regulator_ops regulator_ops_variable_sleepable = { ...@@ -386,14 +384,14 @@ static struct regulator_ops regulator_ops_variable_sleepable = {
* is an on/off switch plain an simple. The external * is an on/off switch plain an simple. The external
* voltage is defined in the board set-up if any. * voltage is defined in the board set-up if any.
*/ */
static struct regulator_ops regulator_ops_external = { static const struct regulator_ops regulator_ops_external = {
.enable = ab3100_enable_regulator, .enable = ab3100_enable_regulator,
.disable = ab3100_disable_regulator, .disable = ab3100_disable_regulator,
.is_enabled = ab3100_is_enabled_regulator, .is_enabled = ab3100_is_enabled_regulator,
.get_voltage = ab3100_get_voltage_regulator_external, .get_voltage = ab3100_get_voltage_regulator_external,
}; };
static struct regulator_desc static const struct regulator_desc
ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
{ {
.name = "LDO_A", .name = "LDO_A",
...@@ -402,7 +400,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { ...@@ -402,7 +400,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
.n_voltages = 1, .n_voltages = 1,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.min_uV = LDO_A_VOLTAGE, .fixed_uV = LDO_A_VOLTAGE,
.enable_time = 200, .enable_time = 200,
}, },
{ {
...@@ -412,7 +410,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { ...@@ -412,7 +410,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
.n_voltages = 1, .n_voltages = 1,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.min_uV = LDO_C_VOLTAGE, .fixed_uV = LDO_C_VOLTAGE,
.enable_time = 200, .enable_time = 200,
}, },
{ {
...@@ -422,7 +420,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = { ...@@ -422,7 +420,7 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
.n_voltages = 1, .n_voltages = 1,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE, .owner = THIS_MODULE,
.min_uV = LDO_D_VOLTAGE, .fixed_uV = LDO_D_VOLTAGE,
.enable_time = 200, .enable_time = 200,
}, },
{ {
...@@ -500,7 +498,7 @@ static int ab3100_regulator_register(struct platform_device *pdev, ...@@ -500,7 +498,7 @@ static int ab3100_regulator_register(struct platform_device *pdev,
struct device_node *np, struct device_node *np,
unsigned long id) unsigned long id)
{ {
struct regulator_desc *desc; const struct regulator_desc *desc;
struct ab3100_regulator *reg; struct ab3100_regulator *reg;
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct regulator_config config = { }; struct regulator_config config = { };
...@@ -545,8 +543,6 @@ static int ab3100_regulator_register(struct platform_device *pdev, ...@@ -545,8 +543,6 @@ static int ab3100_regulator_register(struct platform_device *pdev,
return err; return err;
} }
/* Then set a pointer back to the registered regulator */
reg->rdev = rdev;
return 0; return 0;
} }
...@@ -609,18 +605,6 @@ static const u8 ab3100_reg_initvals[] = { ...@@ -609,18 +605,6 @@ static const u8 ab3100_reg_initvals[] = {
LDO_D_SETTING, LDO_D_SETTING,
}; };
static int ab3100_regulators_remove(struct platform_device *pdev)
{
int i;
for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
struct ab3100_regulator *reg = &ab3100_regulators[i];
reg->rdev = NULL;
}
return 0;
}
static int static int
ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np) ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
{ {
...@@ -647,11 +631,9 @@ ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np) ...@@ -647,11 +631,9 @@ ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
pdev, NULL, ab3100_regulator_matches[i].init_data, pdev, NULL, ab3100_regulator_matches[i].init_data,
ab3100_regulator_matches[i].of_node, ab3100_regulator_matches[i].of_node,
(unsigned long)ab3100_regulator_matches[i].driver_data); (unsigned long)ab3100_regulator_matches[i].driver_data);
if (err) { if (err)
ab3100_regulators_remove(pdev);
return err; return err;
} }
}
return 0; return 0;
} }
...@@ -705,15 +687,13 @@ static int ab3100_regulators_probe(struct platform_device *pdev) ...@@ -705,15 +687,13 @@ static int ab3100_regulators_probe(struct platform_device *pdev)
/* Register the regulators */ /* Register the regulators */
for (i = 0; i < AB3100_NUM_REGULATORS; i++) { for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
struct regulator_desc *desc = &ab3100_regulator_desc[i]; const struct regulator_desc *desc = &ab3100_regulator_desc[i];
err = ab3100_regulator_register(pdev, plfdata, NULL, NULL, err = ab3100_regulator_register(pdev, plfdata, NULL, NULL,
desc->id); desc->id);
if (err) { if (err)
ab3100_regulators_remove(pdev);
return err; return err;
} }
}
return 0; return 0;
} }
...@@ -723,7 +703,6 @@ static struct platform_driver ab3100_regulators_driver = { ...@@ -723,7 +703,6 @@ static struct platform_driver ab3100_regulators_driver = {
.name = "ab3100-regulators", .name = "ab3100-regulators",
}, },
.probe = ab3100_regulators_probe, .probe = ab3100_regulators_probe,
.remove = ab3100_regulators_remove,
}; };
static __init int ab3100_regulators_init(void) static __init int ab3100_regulators_init(void)
......
...@@ -479,7 +479,6 @@ static struct ab8500_regulator_platform_data ab8500_regulator_plat_data = { ...@@ -479,7 +479,6 @@ static struct ab8500_regulator_platform_data ab8500_regulator_plat_data = {
* struct ab8500_ext_regulator_info - ab8500 regulator information * struct ab8500_ext_regulator_info - ab8500 regulator information
* @dev: device pointer * @dev: device pointer
* @desc: regulator description * @desc: regulator description
* @rdev: regulator device
* @cfg: regulator configuration (extension of regulator FW configuration) * @cfg: regulator configuration (extension of regulator FW configuration)
* @update_bank: bank to control on/off * @update_bank: bank to control on/off
* @update_reg: register to control on/off * @update_reg: register to control on/off
...@@ -495,7 +494,6 @@ static struct ab8500_regulator_platform_data ab8500_regulator_plat_data = { ...@@ -495,7 +494,6 @@ static struct ab8500_regulator_platform_data ab8500_regulator_plat_data = {
struct ab8500_ext_regulator_info { struct ab8500_ext_regulator_info {
struct device *dev; struct device *dev;
struct regulator_desc desc; struct regulator_desc desc;
struct regulator_dev *rdev;
struct ab8500_ext_regulator_cfg *cfg; struct ab8500_ext_regulator_cfg *cfg;
u8 update_bank; u8 update_bank;
u8 update_reg; u8 update_reg;
...@@ -530,7 +528,7 @@ static int ab8500_ext_regulator_enable(struct regulator_dev *rdev) ...@@ -530,7 +528,7 @@ static int ab8500_ext_regulator_enable(struct regulator_dev *rdev)
info->update_bank, info->update_reg, info->update_bank, info->update_reg,
info->update_mask, regval); info->update_mask, regval);
if (ret < 0) { if (ret < 0) {
dev_err(rdev_get_dev(info->rdev), dev_err(rdev_get_dev(rdev),
"couldn't set enable bits for regulator\n"); "couldn't set enable bits for regulator\n");
return ret; return ret;
} }
...@@ -566,7 +564,7 @@ static int ab8500_ext_regulator_disable(struct regulator_dev *rdev) ...@@ -566,7 +564,7 @@ static int ab8500_ext_regulator_disable(struct regulator_dev *rdev)
info->update_bank, info->update_reg, info->update_bank, info->update_reg,
info->update_mask, regval); info->update_mask, regval);
if (ret < 0) { if (ret < 0) {
dev_err(rdev_get_dev(info->rdev), dev_err(rdev_get_dev(rdev),
"couldn't set disable bits for regulator\n"); "couldn't set disable bits for regulator\n");
return ret; return ret;
} }
...@@ -720,7 +718,7 @@ static int ab8500_ext_list_voltage(struct regulator_dev *rdev, ...@@ -720,7 +718,7 @@ static int ab8500_ext_list_voltage(struct regulator_dev *rdev,
return -EINVAL; return -EINVAL;
} }
static struct regulator_ops ab8500_ext_regulator_ops = { static const struct regulator_ops ab8500_ext_regulator_ops = {
.enable = ab8500_ext_regulator_enable, .enable = ab8500_ext_regulator_enable,
.disable = ab8500_ext_regulator_disable, .disable = ab8500_ext_regulator_disable,
.is_enabled = ab8500_ext_regulator_is_enabled, .is_enabled = ab8500_ext_regulator_is_enabled,
...@@ -735,6 +733,7 @@ static struct ab8500_ext_regulator_info ...@@ -735,6 +733,7 @@ static struct ab8500_ext_regulator_info
[AB8500_EXT_SUPPLY1] = { [AB8500_EXT_SUPPLY1] = {
.desc = { .desc = {
.name = "VEXTSUPPLY1", .name = "VEXTSUPPLY1",
.of_match = of_match_ptr("ab8500_ext1"),
.ops = &ab8500_ext_regulator_ops, .ops = &ab8500_ext_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.id = AB8500_EXT_SUPPLY1, .id = AB8500_EXT_SUPPLY1,
...@@ -752,6 +751,7 @@ static struct ab8500_ext_regulator_info ...@@ -752,6 +751,7 @@ static struct ab8500_ext_regulator_info
[AB8500_EXT_SUPPLY2] = { [AB8500_EXT_SUPPLY2] = {
.desc = { .desc = {
.name = "VEXTSUPPLY2", .name = "VEXTSUPPLY2",
.of_match = of_match_ptr("ab8500_ext2"),
.ops = &ab8500_ext_regulator_ops, .ops = &ab8500_ext_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.id = AB8500_EXT_SUPPLY2, .id = AB8500_EXT_SUPPLY2,
...@@ -769,6 +769,7 @@ static struct ab8500_ext_regulator_info ...@@ -769,6 +769,7 @@ static struct ab8500_ext_regulator_info
[AB8500_EXT_SUPPLY3] = { [AB8500_EXT_SUPPLY3] = {
.desc = { .desc = {
.name = "VEXTSUPPLY3", .name = "VEXTSUPPLY3",
.of_match = of_match_ptr("ab8500_ext3"),
.ops = &ab8500_ext_regulator_ops, .ops = &ab8500_ext_regulator_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
.id = AB8500_EXT_SUPPLY3, .id = AB8500_EXT_SUPPLY3,
...@@ -785,30 +786,13 @@ static struct ab8500_ext_regulator_info ...@@ -785,30 +786,13 @@ static struct ab8500_ext_regulator_info
}, },
}; };
static struct of_regulator_match ab8500_ext_regulator_match[] = {
{ .name = "ab8500_ext1", .driver_data = (void *) AB8500_EXT_SUPPLY1, },
{ .name = "ab8500_ext2", .driver_data = (void *) AB8500_EXT_SUPPLY2, },
{ .name = "ab8500_ext3", .driver_data = (void *) AB8500_EXT_SUPPLY3, },
};
static int ab8500_ext_regulator_probe(struct platform_device *pdev) static int ab8500_ext_regulator_probe(struct platform_device *pdev)
{ {
struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
struct ab8500_regulator_platform_data *pdata = &ab8500_regulator_plat_data; struct ab8500_regulator_platform_data *pdata = &ab8500_regulator_plat_data;
struct device_node *np = pdev->dev.of_node;
struct regulator_config config = { }; struct regulator_config config = { };
int i, err; struct regulator_dev *rdev;
int i;
if (np) {
err = of_regulator_match(&pdev->dev, np,
ab8500_ext_regulator_match,
ARRAY_SIZE(ab8500_ext_regulator_match));
if (err < 0) {
dev_err(&pdev->dev,
"Error parsing regulator init data: %d\n", err);
return err;
}
}
if (!ab8500) { if (!ab8500) {
dev_err(&pdev->dev, "null mfd parent\n"); dev_err(&pdev->dev, "null mfd parent\n");
...@@ -844,23 +828,18 @@ static int ab8500_ext_regulator_probe(struct platform_device *pdev) ...@@ -844,23 +828,18 @@ static int ab8500_ext_regulator_probe(struct platform_device *pdev)
config.dev = &pdev->dev; config.dev = &pdev->dev;
config.driver_data = info; config.driver_data = info;
config.of_node = ab8500_ext_regulator_match[i].of_node; config.init_data = &pdata->ext_regulator[i];
config.init_data = (np) ?
ab8500_ext_regulator_match[i].init_data :
&pdata->ext_regulator[i];
/* register regulator with framework */ /* register regulator with framework */
info->rdev = devm_regulator_register(&pdev->dev, &info->desc, rdev = devm_regulator_register(&pdev->dev, &info->desc,
&config); &config);
if (IS_ERR(info->rdev)) { if (IS_ERR(rdev)) {
err = PTR_ERR(info->rdev);
dev_err(&pdev->dev, "failed to register regulator %s\n", dev_err(&pdev->dev, "failed to register regulator %s\n",
info->desc.name); info->desc.name);
return err; return PTR_ERR(rdev);
} }
dev_dbg(rdev_get_dev(info->rdev), dev_dbg(&pdev->dev, "%s-probed\n", info->desc.name);
"%s-probed\n", info->desc.name);
} }
return 0; return 0;
......
...@@ -44,7 +44,6 @@ struct ab8500_shared_mode { ...@@ -44,7 +44,6 @@ struct ab8500_shared_mode {
* struct ab8500_regulator_info - ab8500 regulator information * struct ab8500_regulator_info - ab8500 regulator information
* @dev: device pointer * @dev: device pointer
* @desc: regulator description * @desc: regulator description
* @regulator_dev: regulator device
* @shared_mode: used when mode is shared between two regulators * @shared_mode: used when mode is shared between two regulators
* @load_lp_uA: maximum load in idle (low power) mode * @load_lp_uA: maximum load in idle (low power) mode
* @update_bank: bank to control on/off * @update_bank: bank to control on/off
...@@ -65,7 +64,6 @@ struct ab8500_shared_mode { ...@@ -65,7 +64,6 @@ struct ab8500_shared_mode {
struct ab8500_regulator_info { struct ab8500_regulator_info {
struct device *dev; struct device *dev;
struct regulator_desc desc; struct regulator_desc desc;
struct regulator_dev *regulator;
struct ab8500_shared_mode *shared_mode; struct ab8500_shared_mode *shared_mode;
int load_lp_uA; int load_lp_uA;
u8 update_bank; u8 update_bank;
...@@ -510,7 +508,7 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev, ...@@ -510,7 +508,7 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
return ret; return ret;
} }
static struct regulator_ops ab8500_regulator_volt_mode_ops = { static const struct regulator_ops ab8500_regulator_volt_mode_ops = {
.enable = ab8500_regulator_enable, .enable = ab8500_regulator_enable,
.disable = ab8500_regulator_disable, .disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled, .is_enabled = ab8500_regulator_is_enabled,
...@@ -522,7 +520,7 @@ static struct regulator_ops ab8500_regulator_volt_mode_ops = { ...@@ -522,7 +520,7 @@ static struct regulator_ops ab8500_regulator_volt_mode_ops = {
.list_voltage = regulator_list_voltage_table, .list_voltage = regulator_list_voltage_table,
}; };
static struct regulator_ops ab8500_regulator_volt_ops = { static const struct regulator_ops ab8500_regulator_volt_ops = {
.enable = ab8500_regulator_enable, .enable = ab8500_regulator_enable,
.disable = ab8500_regulator_disable, .disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled, .is_enabled = ab8500_regulator_is_enabled,
...@@ -531,7 +529,7 @@ static struct regulator_ops ab8500_regulator_volt_ops = { ...@@ -531,7 +529,7 @@ static struct regulator_ops ab8500_regulator_volt_ops = {
.list_voltage = regulator_list_voltage_table, .list_voltage = regulator_list_voltage_table,
}; };
static struct regulator_ops ab8500_regulator_mode_ops = { static const struct regulator_ops ab8500_regulator_mode_ops = {
.enable = ab8500_regulator_enable, .enable = ab8500_regulator_enable,
.disable = ab8500_regulator_disable, .disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled, .is_enabled = ab8500_regulator_is_enabled,
...@@ -541,14 +539,14 @@ static struct regulator_ops ab8500_regulator_mode_ops = { ...@@ -541,14 +539,14 @@ static struct regulator_ops ab8500_regulator_mode_ops = {
.list_voltage = regulator_list_voltage_table, .list_voltage = regulator_list_voltage_table,
}; };
static struct regulator_ops ab8500_regulator_ops = { static const struct regulator_ops ab8500_regulator_ops = {
.enable = ab8500_regulator_enable, .enable = ab8500_regulator_enable,
.disable = ab8500_regulator_disable, .disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled, .is_enabled = ab8500_regulator_is_enabled,
.list_voltage = regulator_list_voltage_table, .list_voltage = regulator_list_voltage_table,
}; };
static struct regulator_ops ab8500_regulator_anamic_mode_ops = { static const struct regulator_ops ab8500_regulator_anamic_mode_ops = {
.enable = ab8500_regulator_enable, .enable = ab8500_regulator_enable,
.disable = ab8500_regulator_disable, .disable = ab8500_regulator_disable,
.is_enabled = ab8500_regulator_is_enabled, .is_enabled = ab8500_regulator_is_enabled,
...@@ -1600,6 +1598,7 @@ static int ab8500_regulator_register(struct platform_device *pdev, ...@@ -1600,6 +1598,7 @@ static int ab8500_regulator_register(struct platform_device *pdev,
struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
struct ab8500_regulator_info *info = NULL; struct ab8500_regulator_info *info = NULL;
struct regulator_config config = { }; struct regulator_config config = { };
struct regulator_dev *rdev;
/* assign per-regulator data */ /* assign per-regulator data */
info = &abx500_regulator.info[id]; info = &abx500_regulator.info[id];
...@@ -1621,12 +1620,11 @@ static int ab8500_regulator_register(struct platform_device *pdev, ...@@ -1621,12 +1620,11 @@ static int ab8500_regulator_register(struct platform_device *pdev,
} }
/* register regulator with framework */ /* register regulator with framework */
info->regulator = devm_regulator_register(&pdev->dev, &info->desc, rdev = devm_regulator_register(&pdev->dev, &info->desc, &config);
&config); if (IS_ERR(rdev)) {
if (IS_ERR(info->regulator)) {
dev_err(&pdev->dev, "failed to register regulator %s\n", dev_err(&pdev->dev, "failed to register regulator %s\n",
info->desc.name); info->desc.name);
return PTR_ERR(info->regulator); return PTR_ERR(rdev);
} }
return 0; return 0;
......
...@@ -226,7 +226,7 @@ static const struct regulator_linear_range act8600_sudcdc_voltage_ranges[] = { ...@@ -226,7 +226,7 @@ static const struct regulator_linear_range act8600_sudcdc_voltage_ranges[] = {
REGULATOR_LINEAR_RANGE(41400000, 248, 255, 0), REGULATOR_LINEAR_RANGE(41400000, 248, 255, 0),
}; };
static struct regulator_ops act8865_ops = { static const struct regulator_ops act8865_ops = {
.list_voltage = regulator_list_voltage_linear_range, .list_voltage = regulator_list_voltage_linear_range,
.map_voltage = regulator_map_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range,
.get_voltage_sel = regulator_get_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap,
...@@ -236,7 +236,7 @@ static struct regulator_ops act8865_ops = { ...@@ -236,7 +236,7 @@ static struct regulator_ops act8865_ops = {
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
}; };
static struct regulator_ops act8865_ldo_ops = { static const struct regulator_ops act8865_ldo_ops = {
.enable = regulator_enable_regmap, .enable = regulator_enable_regmap,
.disable = regulator_disable_regmap, .disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
...@@ -245,6 +245,8 @@ static struct regulator_ops act8865_ldo_ops = { ...@@ -245,6 +245,8 @@ static struct regulator_ops act8865_ldo_ops = {
#define ACT88xx_REG(_name, _family, _id, _vsel_reg, _supply) \ #define ACT88xx_REG(_name, _family, _id, _vsel_reg, _supply) \
[_family##_ID_##_id] = { \ [_family##_ID_##_id] = { \
.name = _name, \ .name = _name, \
.of_match = of_match_ptr(_name), \
.regulators_node = of_match_ptr("regulators"), \
.supply_name = _supply, \ .supply_name = _supply, \
.id = _family##_ID_##_id, \ .id = _family##_ID_##_id, \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
...@@ -265,6 +267,8 @@ static const struct regulator_desc act8600_regulators[] = { ...@@ -265,6 +267,8 @@ static const struct regulator_desc act8600_regulators[] = {
ACT88xx_REG("DCDC3", ACT8600, DCDC3, VSET, "vp3"), ACT88xx_REG("DCDC3", ACT8600, DCDC3, VSET, "vp3"),
{ {
.name = "SUDCDC_REG4", .name = "SUDCDC_REG4",
.of_match = of_match_ptr("SUDCDC_REG4"),
.regulators_node = of_match_ptr("regulators"),
.id = ACT8600_ID_SUDCDC4, .id = ACT8600_ID_SUDCDC4,
.ops = &act8865_ops, .ops = &act8865_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
...@@ -283,6 +287,8 @@ static const struct regulator_desc act8600_regulators[] = { ...@@ -283,6 +287,8 @@ static const struct regulator_desc act8600_regulators[] = {
ACT88xx_REG("LDO8", ACT8600, LDO8, VSET, "inl"), ACT88xx_REG("LDO8", ACT8600, LDO8, VSET, "inl"),
{ {
.name = "LDO_REG9", .name = "LDO_REG9",
.of_match = of_match_ptr("LDO_REG9"),
.regulators_node = of_match_ptr("regulators"),
.id = ACT8600_ID_LDO9, .id = ACT8600_ID_LDO9,
.ops = &act8865_ldo_ops, .ops = &act8865_ldo_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
...@@ -294,6 +300,8 @@ static const struct regulator_desc act8600_regulators[] = { ...@@ -294,6 +300,8 @@ static const struct regulator_desc act8600_regulators[] = {
}, },
{ {
.name = "LDO_REG10", .name = "LDO_REG10",
.of_match = of_match_ptr("LDO_REG10"),
.regulators_node = of_match_ptr("regulators"),
.id = ACT8600_ID_LDO10, .id = ACT8600_ID_LDO10,
.ops = &act8865_ldo_ops, .ops = &act8865_ldo_ops,
.type = REGULATOR_VOLTAGE, .type = REGULATOR_VOLTAGE,
...@@ -348,110 +356,6 @@ static const struct of_device_id act8865_dt_ids[] = { ...@@ -348,110 +356,6 @@ static const struct of_device_id act8865_dt_ids[] = {
{ } { }
}; };
MODULE_DEVICE_TABLE(of, act8865_dt_ids); MODULE_DEVICE_TABLE(of, act8865_dt_ids);
static struct of_regulator_match act8846_matches[] = {
[ACT8846_ID_REG1] = { .name = "REG1" },
[ACT8846_ID_REG2] = { .name = "REG2" },
[ACT8846_ID_REG3] = { .name = "REG3" },
[ACT8846_ID_REG4] = { .name = "REG4" },
[ACT8846_ID_REG5] = { .name = "REG5" },
[ACT8846_ID_REG6] = { .name = "REG6" },
[ACT8846_ID_REG7] = { .name = "REG7" },
[ACT8846_ID_REG8] = { .name = "REG8" },
[ACT8846_ID_REG9] = { .name = "REG9" },
[ACT8846_ID_REG10] = { .name = "REG10" },
[ACT8846_ID_REG11] = { .name = "REG11" },
[ACT8846_ID_REG12] = { .name = "REG12" },
};
static struct of_regulator_match act8865_matches[] = {
[ACT8865_ID_DCDC1] = { .name = "DCDC_REG1"},
[ACT8865_ID_DCDC2] = { .name = "DCDC_REG2"},
[ACT8865_ID_DCDC3] = { .name = "DCDC_REG3"},
[ACT8865_ID_LDO1] = { .name = "LDO_REG1"},
[ACT8865_ID_LDO2] = { .name = "LDO_REG2"},
[ACT8865_ID_LDO3] = { .name = "LDO_REG3"},
[ACT8865_ID_LDO4] = { .name = "LDO_REG4"},
};
static struct of_regulator_match act8600_matches[] = {
[ACT8600_ID_DCDC1] = { .name = "DCDC_REG1"},
[ACT8600_ID_DCDC2] = { .name = "DCDC_REG2"},
[ACT8600_ID_DCDC3] = { .name = "DCDC_REG3"},
[ACT8600_ID_SUDCDC4] = { .name = "SUDCDC_REG4"},
[ACT8600_ID_LDO5] = { .name = "LDO_REG5"},
[ACT8600_ID_LDO6] = { .name = "LDO_REG6"},
[ACT8600_ID_LDO7] = { .name = "LDO_REG7"},
[ACT8600_ID_LDO8] = { .name = "LDO_REG8"},
[ACT8600_ID_LDO9] = { .name = "LDO_REG9"},
[ACT8600_ID_LDO10] = { .name = "LDO_REG10"},
};
static int act8865_pdata_from_dt(struct device *dev,
struct act8865_platform_data *pdata,
unsigned long type)
{
int matched, i, num_matches;
struct device_node *np;
struct act8865_regulator_data *regulator;
struct of_regulator_match *matches;
switch (type) {
case ACT8600:
matches = act8600_matches;
num_matches = ARRAY_SIZE(act8600_matches);
break;
case ACT8846:
matches = act8846_matches;
num_matches = ARRAY_SIZE(act8846_matches);
break;
case ACT8865:
matches = act8865_matches;
num_matches = ARRAY_SIZE(act8865_matches);
break;
default:
dev_err(dev, "invalid device id %lu\n", type);
return -EINVAL;
}
np = of_get_child_by_name(dev->of_node, "regulators");
if (!np) {
dev_err(dev, "missing 'regulators' subnode in DT\n");
return -EINVAL;
}
matched = of_regulator_match(dev, np, matches, num_matches);
of_node_put(np);
if (matched <= 0)
return matched;
pdata->regulators = devm_kcalloc(dev,
num_matches,
sizeof(struct act8865_regulator_data),
GFP_KERNEL);
if (!pdata->regulators)
return -ENOMEM;
pdata->num_regulators = num_matches;
regulator = pdata->regulators;
for (i = 0; i < num_matches; i++) {
regulator->id = i;
regulator->name = matches[i].name;
regulator->init_data = matches[i].init_data;
regulator->of_node = matches[i].of_node;
regulator++;
}
return 0;
}
#else
static inline int act8865_pdata_from_dt(struct device *dev,
struct act8865_platform_data *pdata,
unsigned long type)
{
return 0;
}
#endif #endif
static struct act8865_regulator_data *act8865_get_regulator_data( static struct act8865_regulator_data *act8865_get_regulator_data(
...@@ -459,9 +363,6 @@ static struct act8865_regulator_data *act8865_get_regulator_data( ...@@ -459,9 +363,6 @@ static struct act8865_regulator_data *act8865_get_regulator_data(
{ {
int i; int i;
if (!pdata)
return NULL;
for (i = 0; i < pdata->num_regulators; i++) { for (i = 0; i < pdata->num_regulators; i++) {
if (pdata->regulators[i].id == id) if (pdata->regulators[i].id == id)
return &pdata->regulators[i]; return &pdata->regulators[i];
...@@ -484,7 +385,7 @@ static int act8865_pmic_probe(struct i2c_client *client, ...@@ -484,7 +385,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
const struct i2c_device_id *i2c_id) const struct i2c_device_id *i2c_id)
{ {
const struct regulator_desc *regulators; const struct regulator_desc *regulators;
struct act8865_platform_data pdata_of, *pdata; struct act8865_platform_data *pdata = NULL;
struct device *dev = &client->dev; struct device *dev = &client->dev;
int i, ret, num_regulators; int i, ret, num_regulators;
struct act8865 *act8865; struct act8865 *act8865;
...@@ -493,9 +394,7 @@ static int act8865_pmic_probe(struct i2c_client *client, ...@@ -493,9 +394,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
int off_reg, off_mask; int off_reg, off_mask;
int voltage_select = 0; int voltage_select = 0;
pdata = dev_get_platdata(dev); if (dev->of_node) {
if (dev->of_node && !pdata) {
const struct of_device_id *id; const struct of_device_id *id;
id = of_match_device(of_match_ptr(act8865_dt_ids), dev); id = of_match_device(of_match_ptr(act8865_dt_ids), dev);
...@@ -509,6 +408,7 @@ static int act8865_pmic_probe(struct i2c_client *client, ...@@ -509,6 +408,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
NULL); NULL);
} else { } else {
type = i2c_id->driver_data; type = i2c_id->driver_data;
pdata = dev_get_platdata(dev);
} }
switch (type) { switch (type) {
...@@ -543,14 +443,6 @@ static int act8865_pmic_probe(struct i2c_client *client, ...@@ -543,14 +443,6 @@ static int act8865_pmic_probe(struct i2c_client *client,
return -EINVAL; return -EINVAL;
} }
if (dev->of_node && !pdata) {
ret = act8865_pdata_from_dt(dev, &pdata_of, type);
if (ret < 0)
return ret;
pdata = &pdata_of;
}
act8865 = devm_kzalloc(dev, sizeof(struct act8865), GFP_KERNEL); act8865 = devm_kzalloc(dev, sizeof(struct act8865), GFP_KERNEL);
if (!act8865) if (!act8865)
return -ENOMEM; return -ENOMEM;
...@@ -577,18 +469,21 @@ static int act8865_pmic_probe(struct i2c_client *client, ...@@ -577,18 +469,21 @@ static int act8865_pmic_probe(struct i2c_client *client,
for (i = 0; i < num_regulators; i++) { for (i = 0; i < num_regulators; i++) {
const struct regulator_desc *desc = &regulators[i]; const struct regulator_desc *desc = &regulators[i];
struct regulator_config config = { }; struct regulator_config config = { };
struct act8865_regulator_data *rdata;
struct regulator_dev *rdev; struct regulator_dev *rdev;
config.dev = dev; config.dev = dev;
config.driver_data = act8865; config.driver_data = act8865;
config.regmap = act8865->regmap; config.regmap = act8865->regmap;
if (pdata) {
struct act8865_regulator_data *rdata;
rdata = act8865_get_regulator_data(desc->id, pdata); rdata = act8865_get_regulator_data(desc->id, pdata);
if (rdata) { if (rdata) {
config.init_data = rdata->init_data; config.init_data = rdata->init_data;
config.of_node = rdata->of_node; config.of_node = rdata->of_node;
} }
}
rdev = devm_regulator_register(dev, desc, &config); rdev = devm_regulator_register(dev, desc, &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
......
...@@ -23,18 +23,10 @@ ...@@ -23,18 +23,10 @@
#define LDO_FET_FULL_ON 0x1f #define LDO_FET_FULL_ON 0x1f
struct anatop_regulator { struct anatop_regulator {
u32 control_reg;
struct regmap *anatop;
int vol_bit_shift;
int vol_bit_width;
u32 delay_reg; u32 delay_reg;
int delay_bit_shift; int delay_bit_shift;
int delay_bit_width; int delay_bit_width;
int min_bit_val;
int min_voltage;
int max_voltage;
struct regulator_desc rdesc; struct regulator_desc rdesc;
struct regulator_init_data *initdata;
bool bypass; bool bypass;
int sel; int sel;
}; };
...@@ -55,7 +47,7 @@ static int anatop_regmap_set_voltage_time_sel(struct regulator_dev *reg, ...@@ -55,7 +47,7 @@ static int anatop_regmap_set_voltage_time_sel(struct regulator_dev *reg,
* to calculate how many steps LDO need to * to calculate how many steps LDO need to
* ramp up, and how much delay needed. (us) * ramp up, and how much delay needed. (us)
*/ */
regmap_read(anatop_reg->anatop, anatop_reg->delay_reg, &val); regmap_read(reg->regmap, anatop_reg->delay_reg, &val);
val = (val >> anatop_reg->delay_bit_shift) & val = (val >> anatop_reg->delay_bit_shift) &
((1 << anatop_reg->delay_bit_width) - 1); ((1 << anatop_reg->delay_bit_width) - 1);
ret = (new_sel - old_sel) * (LDO_RAMP_UP_UNIT_IN_CYCLES << ret = (new_sel - old_sel) * (LDO_RAMP_UP_UNIT_IN_CYCLES <<
...@@ -170,6 +162,13 @@ static int anatop_regulator_probe(struct platform_device *pdev) ...@@ -170,6 +162,13 @@ static int anatop_regulator_probe(struct platform_device *pdev)
struct anatop_regulator *sreg; struct anatop_regulator *sreg;
struct regulator_init_data *initdata; struct regulator_init_data *initdata;
struct regulator_config config = { }; struct regulator_config config = { };
struct regmap *regmap;
u32 control_reg;
u32 vol_bit_shift;
u32 vol_bit_width;
u32 min_bit_val;
u32 min_voltage;
u32 max_voltage;
int ret = 0; int ret = 0;
u32 val; u32 val;
...@@ -192,48 +191,41 @@ static int anatop_regulator_probe(struct platform_device *pdev) ...@@ -192,48 +191,41 @@ static int anatop_regulator_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
initdata->supply_regulator = "vin"; initdata->supply_regulator = "vin";
sreg->initdata = initdata;
anatop_np = of_get_parent(np); anatop_np = of_get_parent(np);
if (!anatop_np) if (!anatop_np)
return -ENODEV; return -ENODEV;
sreg->anatop = syscon_node_to_regmap(anatop_np); regmap = syscon_node_to_regmap(anatop_np);
of_node_put(anatop_np); of_node_put(anatop_np);
if (IS_ERR(sreg->anatop)) if (IS_ERR(regmap))
return PTR_ERR(sreg->anatop); return PTR_ERR(regmap);
ret = of_property_read_u32(np, "anatop-reg-offset", ret = of_property_read_u32(np, "anatop-reg-offset", &control_reg);
&sreg->control_reg);
if (ret) { if (ret) {
dev_err(dev, "no anatop-reg-offset property set\n"); dev_err(dev, "no anatop-reg-offset property set\n");
return ret; return ret;
} }
ret = of_property_read_u32(np, "anatop-vol-bit-width", ret = of_property_read_u32(np, "anatop-vol-bit-width", &vol_bit_width);
&sreg->vol_bit_width);
if (ret) { if (ret) {
dev_err(dev, "no anatop-vol-bit-width property set\n"); dev_err(dev, "no anatop-vol-bit-width property set\n");
return ret; return ret;
} }
ret = of_property_read_u32(np, "anatop-vol-bit-shift", ret = of_property_read_u32(np, "anatop-vol-bit-shift", &vol_bit_shift);
&sreg->vol_bit_shift);
if (ret) { if (ret) {
dev_err(dev, "no anatop-vol-bit-shift property set\n"); dev_err(dev, "no anatop-vol-bit-shift property set\n");
return ret; return ret;
} }
ret = of_property_read_u32(np, "anatop-min-bit-val", ret = of_property_read_u32(np, "anatop-min-bit-val", &min_bit_val);
&sreg->min_bit_val);
if (ret) { if (ret) {
dev_err(dev, "no anatop-min-bit-val property set\n"); dev_err(dev, "no anatop-min-bit-val property set\n");
return ret; return ret;
} }
ret = of_property_read_u32(np, "anatop-min-voltage", ret = of_property_read_u32(np, "anatop-min-voltage", &min_voltage);
&sreg->min_voltage);
if (ret) { if (ret) {
dev_err(dev, "no anatop-min-voltage property set\n"); dev_err(dev, "no anatop-min-voltage property set\n");
return ret; return ret;
} }
ret = of_property_read_u32(np, "anatop-max-voltage", ret = of_property_read_u32(np, "anatop-max-voltage", &max_voltage);
&sreg->max_voltage);
if (ret) { if (ret) {
dev_err(dev, "no anatop-max-voltage property set\n"); dev_err(dev, "no anatop-max-voltage property set\n");
return ret; return ret;
...@@ -247,24 +239,23 @@ static int anatop_regulator_probe(struct platform_device *pdev) ...@@ -247,24 +239,23 @@ static int anatop_regulator_probe(struct platform_device *pdev)
of_property_read_u32(np, "anatop-delay-bit-shift", of_property_read_u32(np, "anatop-delay-bit-shift",
&sreg->delay_bit_shift); &sreg->delay_bit_shift);
rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage) / 25000 + 1 rdesc->n_voltages = (max_voltage - min_voltage) / 25000 + 1
+ sreg->min_bit_val; + min_bit_val;
rdesc->min_uV = sreg->min_voltage; rdesc->min_uV = min_voltage;
rdesc->uV_step = 25000; rdesc->uV_step = 25000;
rdesc->linear_min_sel = sreg->min_bit_val; rdesc->linear_min_sel = min_bit_val;
rdesc->vsel_reg = sreg->control_reg; rdesc->vsel_reg = control_reg;
rdesc->vsel_mask = ((1 << sreg->vol_bit_width) - 1) << rdesc->vsel_mask = ((1 << vol_bit_width) - 1) << vol_bit_shift;
sreg->vol_bit_shift;
rdesc->min_dropout_uV = 125000; rdesc->min_dropout_uV = 125000;
config.dev = &pdev->dev; config.dev = &pdev->dev;
config.init_data = initdata; config.init_data = initdata;
config.driver_data = sreg; config.driver_data = sreg;
config.of_node = pdev->dev.of_node; config.of_node = pdev->dev.of_node;
config.regmap = sreg->anatop; config.regmap = regmap;
/* Only core regulators have the ramp up delay configuration. */ /* Only core regulators have the ramp up delay configuration. */
if (sreg->control_reg && sreg->delay_bit_width) { if (control_reg && sreg->delay_bit_width) {
rdesc->ops = &anatop_core_rops; rdesc->ops = &anatop_core_rops;
ret = regmap_read(config.regmap, rdesc->vsel_reg, &val); ret = regmap_read(config.regmap, rdesc->vsel_reg, &val);
...@@ -273,7 +264,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) ...@@ -273,7 +264,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
return ret; return ret;
} }
sreg->sel = (val & rdesc->vsel_mask) >> sreg->vol_bit_shift; sreg->sel = (val & rdesc->vsel_mask) >> vol_bit_shift;
if (sreg->sel == LDO_FET_FULL_ON) { if (sreg->sel == LDO_FET_FULL_ON) {
sreg->sel = 0; sreg->sel = 0;
sreg->bypass = true; sreg->bypass = true;
...@@ -306,7 +297,7 @@ static int anatop_regulator_probe(struct platform_device *pdev) ...@@ -306,7 +297,7 @@ static int anatop_regulator_probe(struct platform_device *pdev)
anatop_rops.disable = regulator_disable_regmap; anatop_rops.disable = regulator_disable_regmap;
anatop_rops.is_enabled = regulator_is_enabled_regmap; anatop_rops.is_enabled = regulator_is_enabled_regmap;
rdesc->enable_reg = sreg->control_reg; rdesc->enable_reg = control_reg;
rdesc->enable_mask = BIT(enable_bit); rdesc->enable_mask = BIT(enable_bit);
} }
} }
......
/* // SPDX-License-Identifier: GPL-2.0+
* arizona-ldo1.c -- LDO1 supply for Arizona devices //
* // arizona-ldo1.c -- LDO1 supply for Arizona devices
* Copyright 2012 Wolfson Microelectronics PLC. //
* // Copyright 2012 Wolfson Microelectronics PLC.
* Author: Mark Brown <broonie@opensource.wolfsonmicro.com> //
* // Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
* 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/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
......
/* // SPDX-License-Identifier: GPL-2.0+
* arizona-micsupp.c -- Microphone supply for Arizona devices //
* // arizona-micsupp.c -- Microphone supply for Arizona devices
* Copyright 2012 Wolfson Microelectronics PLC. //
* // Copyright 2012 Wolfson Microelectronics PLC.
* Author: Mark Brown <broonie@opensource.wolfsonmicro.com> //
* // Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
* 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/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
......
...@@ -17,14 +17,6 @@ ...@@ -17,14 +17,6 @@
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/slab.h> #include <linux/slab.h>
struct as3711_regulator_info {
struct regulator_desc desc;
};
struct as3711_regulator {
struct as3711_regulator_info *reg_info;
};
/* /*
* The regulator API supports 4 modes of operataion: FAST, NORMAL, IDLE and * 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: * STANDBY. We map them in the following way to AS3711 SD1-4 DCDC modes:
...@@ -129,7 +121,6 @@ static const struct regulator_linear_range as3711_dldo_ranges[] = { ...@@ -129,7 +121,6 @@ static const struct regulator_linear_range as3711_dldo_ranges[] = {
#define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _sfx) \ #define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _sfx) \
[AS3711_REGULATOR_ ## _id] = { \ [AS3711_REGULATOR_ ## _id] = { \
.desc = { \
.name = "as3711-regulator-" # _id, \ .name = "as3711-regulator-" # _id, \
.id = AS3711_REGULATOR_ ## _id, \ .id = AS3711_REGULATOR_ ## _id, \
.n_voltages = (_vmask + 1), \ .n_voltages = (_vmask + 1), \
...@@ -142,10 +133,9 @@ static const struct regulator_linear_range as3711_dldo_ranges[] = { ...@@ -142,10 +133,9 @@ static const struct regulator_linear_range as3711_dldo_ranges[] = {
.enable_mask = BIT(_en_bit), \ .enable_mask = BIT(_en_bit), \
.linear_ranges = as3711_ ## _sfx ## _ranges, \ .linear_ranges = as3711_ ## _sfx ## _ranges, \
.n_linear_ranges = ARRAY_SIZE(as3711_ ## _sfx ## _ranges), \ .n_linear_ranges = ARRAY_SIZE(as3711_ ## _sfx ## _ranges), \
}, \
} }
static struct as3711_regulator_info as3711_reg_info[] = { static const struct regulator_desc as3711_reg_desc[] = {
AS3711_REG(SD_1, SD_CONTROL, 0, 0x7f, sd), AS3711_REG(SD_1, SD_CONTROL, 0, 0x7f, sd),
AS3711_REG(SD_2, SD_CONTROL, 1, 0x7f, sd), AS3711_REG(SD_2, SD_CONTROL, 1, 0x7f, sd),
AS3711_REG(SD_3, SD_CONTROL, 2, 0x7f, sd), AS3711_REG(SD_3, SD_CONTROL, 2, 0x7f, sd),
...@@ -161,7 +151,7 @@ static struct as3711_regulator_info as3711_reg_info[] = { ...@@ -161,7 +151,7 @@ static struct as3711_regulator_info as3711_reg_info[] = {
/* StepUp output voltage depends on supplying regulator */ /* StepUp output voltage depends on supplying regulator */
}; };
#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info) #define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_desc)
static struct of_regulator_match static struct of_regulator_match
as3711_regulator_matches[AS3711_REGULATOR_NUM] = { as3711_regulator_matches[AS3711_REGULATOR_NUM] = {
...@@ -215,11 +205,8 @@ static int as3711_regulator_probe(struct platform_device *pdev) ...@@ -215,11 +205,8 @@ static int as3711_regulator_probe(struct platform_device *pdev)
struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev); struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev);
struct as3711 *as3711 = dev_get_drvdata(pdev->dev.parent); struct as3711 *as3711 = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = {.dev = &pdev->dev,}; struct regulator_config config = {.dev = &pdev->dev,};
struct as3711_regulator *reg = NULL;
struct as3711_regulator *regs;
struct device_node *of_node[AS3711_REGULATOR_NUM] = {}; struct device_node *of_node[AS3711_REGULATOR_NUM] = {};
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct as3711_regulator_info *ri;
int ret; int ret;
int id; int id;
...@@ -236,30 +223,20 @@ static int as3711_regulator_probe(struct platform_device *pdev) ...@@ -236,30 +223,20 @@ static int as3711_regulator_probe(struct platform_device *pdev)
} }
} }
regs = devm_kcalloc(&pdev->dev, for (id = 0; id < AS3711_REGULATOR_NUM; id++) {
AS3711_REGULATOR_NUM,
sizeof(struct as3711_regulator),
GFP_KERNEL);
if (!regs)
return -ENOMEM;
for (id = 0, ri = as3711_reg_info; id < AS3711_REGULATOR_NUM; ++id, ri++) {
reg = &regs[id];
reg->reg_info = ri;
config.init_data = pdata->init_data[id]; config.init_data = pdata->init_data[id];
config.driver_data = reg;
config.regmap = as3711->regmap; config.regmap = as3711->regmap;
config.of_node = of_node[id]; config.of_node = of_node[id];
rdev = devm_regulator_register(&pdev->dev, &ri->desc, &config); rdev = devm_regulator_register(&pdev->dev, &as3711_reg_desc[id],
&config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "Failed to register regulator %s\n", dev_err(&pdev->dev, "Failed to register regulator %s\n",
ri->desc.name); as3711_reg_desc[id].name);
return PTR_ERR(rdev); return PTR_ERR(rdev);
} }
} }
platform_set_drvdata(pdev, regs);
return 0; return 0;
} }
......
This diff is collapsed.
...@@ -367,16 +367,14 @@ static const int axp209_dcdc2_ldo3_slew_rates[] = { ...@@ -367,16 +367,14 @@ static const int axp209_dcdc2_ldo3_slew_rates[] = {
static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
{ {
struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
const struct regulator_desc *desc; int id = rdev_get_id(rdev);
u8 reg, mask, enable, cfg = 0xff; u8 reg, mask, enable, cfg = 0xff;
const int *slew_rates; const int *slew_rates;
int rate_count = 0; int rate_count = 0;
desc = rdev->desc;
switch (axp20x->variant) { switch (axp20x->variant) {
case AXP209_ID: case AXP209_ID:
if (desc->id == AXP20X_DCDC2) { if (id == AXP20X_DCDC2) {
slew_rates = axp209_dcdc2_ldo3_slew_rates; slew_rates = axp209_dcdc2_ldo3_slew_rates;
rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
reg = AXP20X_DCDC2_LDO3_V_RAMP; reg = AXP20X_DCDC2_LDO3_V_RAMP;
...@@ -388,7 +386,7 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) ...@@ -388,7 +386,7 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
break; break;
} }
if (desc->id == AXP20X_LDO3) { if (id == AXP20X_LDO3) {
slew_rates = axp209_dcdc2_ldo3_slew_rates; slew_rates = axp209_dcdc2_ldo3_slew_rates;
rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates); rate_count = ARRAY_SIZE(axp209_dcdc2_ldo3_slew_rates);
reg = AXP20X_DCDC2_LDO3_V_RAMP; reg = AXP20X_DCDC2_LDO3_V_RAMP;
...@@ -435,16 +433,11 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp) ...@@ -435,16 +433,11 @@ static int axp20x_set_ramp_delay(struct regulator_dev *rdev, int ramp)
static int axp20x_regulator_enable_regmap(struct regulator_dev *rdev) static int axp20x_regulator_enable_regmap(struct regulator_dev *rdev)
{ {
struct axp20x_dev *axp20x = rdev_get_drvdata(rdev); struct axp20x_dev *axp20x = rdev_get_drvdata(rdev);
const struct regulator_desc *desc; int id = rdev_get_id(rdev);
if (!rdev)
return -EINVAL;
desc = rdev->desc;
switch (axp20x->variant) { switch (axp20x->variant) {
case AXP209_ID: case AXP209_ID:
if ((desc->id == AXP20X_LDO3) && if ((id == AXP20X_LDO3) &&
rdev->constraints && rdev->constraints->soft_start) { rdev->constraints && rdev->constraints->soft_start) {
int v_out; int v_out;
int ret; int ret;
...@@ -1028,7 +1021,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) ...@@ -1028,7 +1021,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
* (See include/linux/mfd/axp20x.h) * (See include/linux/mfd/axp20x.h)
*/ */
reg = AXP803_DCDC_FREQ_CTRL; reg = AXP803_DCDC_FREQ_CTRL;
/* Fall through to the check below.*/ /* Fall through - to the check below.*/
case AXP806_ID: case AXP806_ID:
/* /*
* AXP806 also have DCDC work frequency setting register at a * AXP806 also have DCDC work frequency setting register at a
...@@ -1119,12 +1112,12 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work ...@@ -1119,12 +1112,12 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
break; break;
case AXP806_ID: case AXP806_ID:
reg = AXP806_DCDC_MODE_CTRL2;
/* /*
* AXP806 DCDC regulator IDs have the same range as AXP22X. * AXP806 DCDC regulator IDs have the same range as AXP22X.
* Fall through to the check below.
* (See include/linux/mfd/axp20x.h) * (See include/linux/mfd/axp20x.h)
*/ */
reg = AXP806_DCDC_MODE_CTRL2;
/* Fall through - to the check below. */
case AXP221_ID: case AXP221_ID:
case AXP223_ID: case AXP223_ID:
case AXP809_ID: case AXP809_ID:
......
...@@ -103,10 +103,6 @@ ...@@ -103,10 +103,6 @@
((n > BCM590XX_REG_VSR) && (n < BCM590XX_REG_VBUS)) ((n > BCM590XX_REG_VSR) && (n < BCM590XX_REG_VBUS))
#define BCM590XX_REG_IS_VBUS(n) (n == BCM590XX_REG_VBUS) #define BCM590XX_REG_IS_VBUS(n) (n == BCM590XX_REG_VBUS)
struct bcm590xx_board {
struct regulator_init_data *bcm590xx_pmu_init_data[BCM590XX_NUM_REGS];
};
/* LDO group A: supported voltages in microvolts */ /* LDO group A: supported voltages in microvolts */
static const unsigned int ldo_a_table[] = { static const unsigned int ldo_a_table[] = {
1200000, 1800000, 2500000, 2700000, 2800000, 1200000, 1800000, 2500000, 2700000, 2800000,
...@@ -280,105 +276,15 @@ static const struct regulator_ops bcm590xx_ops_vbus = { ...@@ -280,105 +276,15 @@ static const struct regulator_ops bcm590xx_ops_vbus = {
.disable = regulator_disable_regmap, .disable = regulator_disable_regmap,
}; };
#define BCM590XX_MATCH(_name, _id) \
{ \
.name = #_name, \
.driver_data = (void *)&bcm590xx_regs[BCM590XX_REG_##_id], \
}
static struct of_regulator_match bcm590xx_matches[] = {
BCM590XX_MATCH(rfldo, RFLDO),
BCM590XX_MATCH(camldo1, CAMLDO1),
BCM590XX_MATCH(camldo2, CAMLDO2),
BCM590XX_MATCH(simldo1, SIMLDO1),
BCM590XX_MATCH(simldo2, SIMLDO2),
BCM590XX_MATCH(sdldo, SDLDO),
BCM590XX_MATCH(sdxldo, SDXLDO),
BCM590XX_MATCH(mmcldo1, MMCLDO1),
BCM590XX_MATCH(mmcldo2, MMCLDO2),
BCM590XX_MATCH(audldo, AUDLDO),
BCM590XX_MATCH(micldo, MICLDO),
BCM590XX_MATCH(usbldo, USBLDO),
BCM590XX_MATCH(vibldo, VIBLDO),
BCM590XX_MATCH(csr, CSR),
BCM590XX_MATCH(iosr1, IOSR1),
BCM590XX_MATCH(iosr2, IOSR2),
BCM590XX_MATCH(msr, MSR),
BCM590XX_MATCH(sdsr1, SDSR1),
BCM590XX_MATCH(sdsr2, SDSR2),
BCM590XX_MATCH(vsr, VSR),
BCM590XX_MATCH(gpldo1, GPLDO1),
BCM590XX_MATCH(gpldo2, GPLDO2),
BCM590XX_MATCH(gpldo3, GPLDO3),
BCM590XX_MATCH(gpldo4, GPLDO4),
BCM590XX_MATCH(gpldo5, GPLDO5),
BCM590XX_MATCH(gpldo6, GPLDO6),
BCM590XX_MATCH(vbus, VBUS),
};
static struct bcm590xx_board *bcm590xx_parse_dt_reg_data(
struct platform_device *pdev,
struct of_regulator_match **bcm590xx_reg_matches)
{
struct bcm590xx_board *data;
struct device_node *np = pdev->dev.parent->of_node;
struct device_node *regulators;
struct of_regulator_match *matches = bcm590xx_matches;
int count = ARRAY_SIZE(bcm590xx_matches);
int idx = 0;
int ret;
if (!np) {
dev_err(&pdev->dev, "of node not found\n");
return NULL;
}
data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
if (!data)
return NULL;
np = of_node_get(np);
regulators = of_get_child_by_name(np, "regulators");
if (!regulators) {
dev_warn(&pdev->dev, "regulator node not found\n");
return NULL;
}
ret = of_regulator_match(&pdev->dev, regulators, matches, count);
of_node_put(regulators);
if (ret < 0) {
dev_err(&pdev->dev, "Error parsing regulator init data: %d\n",
ret);
return NULL;
}
*bcm590xx_reg_matches = matches;
for (idx = 0; idx < count; idx++) {
if (!matches[idx].init_data || !matches[idx].of_node)
continue;
data->bcm590xx_pmu_init_data[idx] = matches[idx].init_data;
}
return data;
}
static int bcm590xx_probe(struct platform_device *pdev) static int bcm590xx_probe(struct platform_device *pdev)
{ {
struct bcm590xx *bcm590xx = dev_get_drvdata(pdev->dev.parent); struct bcm590xx *bcm590xx = dev_get_drvdata(pdev->dev.parent);
struct bcm590xx_board *pmu_data = NULL;
struct bcm590xx_reg *pmu; struct bcm590xx_reg *pmu;
struct regulator_config config = { }; struct regulator_config config = { };
struct bcm590xx_info *info; struct bcm590xx_info *info;
struct regulator_init_data *reg_data;
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct of_regulator_match *bcm590xx_reg_matches = NULL;
int i; int i;
pmu_data = bcm590xx_parse_dt_reg_data(pdev,
&bcm590xx_reg_matches);
pmu = devm_kzalloc(&pdev->dev, sizeof(*pmu), GFP_KERNEL); pmu = devm_kzalloc(&pdev->dev, sizeof(*pmu), GFP_KERNEL);
if (!pmu) if (!pmu)
return -ENOMEM; return -ENOMEM;
...@@ -397,13 +303,10 @@ static int bcm590xx_probe(struct platform_device *pdev) ...@@ -397,13 +303,10 @@ static int bcm590xx_probe(struct platform_device *pdev)
info = bcm590xx_regs; info = bcm590xx_regs;
for (i = 0; i < BCM590XX_NUM_REGS; i++, info++) { for (i = 0; i < BCM590XX_NUM_REGS; i++, info++) {
if (pmu_data)
reg_data = pmu_data->bcm590xx_pmu_init_data[i];
else
reg_data = NULL;
/* Register the regulators */ /* Register the regulators */
pmu->desc[i].name = info->name; pmu->desc[i].name = info->name;
pmu->desc[i].of_match = of_match_ptr(info->name);
pmu->desc[i].regulators_node = of_match_ptr("regulators");
pmu->desc[i].supply_name = info->vin_name; pmu->desc[i].supply_name = info->vin_name;
pmu->desc[i].id = i; pmu->desc[i].id = i;
pmu->desc[i].volt_table = info->volt_table; pmu->desc[i].volt_table = info->volt_table;
...@@ -433,16 +336,12 @@ static int bcm590xx_probe(struct platform_device *pdev) ...@@ -433,16 +336,12 @@ static int bcm590xx_probe(struct platform_device *pdev)
pmu->desc[i].owner = THIS_MODULE; pmu->desc[i].owner = THIS_MODULE;
config.dev = bcm590xx->dev; config.dev = bcm590xx->dev;
config.init_data = reg_data;
config.driver_data = pmu; config.driver_data = pmu;
if (BCM590XX_REG_IS_GPLDO(i) || BCM590XX_REG_IS_VBUS(i)) if (BCM590XX_REG_IS_GPLDO(i) || BCM590XX_REG_IS_VBUS(i))
config.regmap = bcm590xx->regmap_sec; config.regmap = bcm590xx->regmap_sec;
else else
config.regmap = bcm590xx->regmap_pri; config.regmap = bcm590xx->regmap_pri;
if (bcm590xx_reg_matches)
config.of_node = bcm590xx_reg_matches[i].of_node;
rdev = devm_regulator_register(&pdev->dev, &pmu->desc[i], rdev = devm_regulator_register(&pdev->dev, &pmu->desc[i],
&config); &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
......
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev, static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev,
int ramp_delay) int ramp_delay)
{ {
int id = rdev->desc->id; int id = rdev_get_id(rdev);
unsigned int ramp_value = BUCK_RAMPRATE_10P00MV; unsigned int ramp_value;
dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1, dev_dbg(&rdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1,
ramp_delay); ramp_delay);
......
...@@ -1339,9 +1339,7 @@ static int set_machine_constraints(struct regulator_dev *rdev, ...@@ -1339,9 +1339,7 @@ static int set_machine_constraints(struct regulator_dev *rdev,
* We'll only apply the initial system load if an * We'll only apply the initial system load if an
* initial mode wasn't specified. * initial mode wasn't specified.
*/ */
regulator_lock(rdev);
drms_uA_update(rdev); drms_uA_update(rdev);
regulator_unlock(rdev);
} }
if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable) if ((rdev->constraints->ramp_delay || rdev->constraints->ramp_disable)
...@@ -2256,6 +2254,7 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev) ...@@ -2256,6 +2254,7 @@ static void regulator_ena_gpio_free(struct regulator_dev *rdev)
if (pin->gpiod == rdev->ena_pin->gpiod) { if (pin->gpiod == rdev->ena_pin->gpiod) {
if (pin->request_count <= 1) { if (pin->request_count <= 1) {
pin->request_count = 0; pin->request_count = 0;
gpiod_put(pin->gpiod);
list_del(&pin->list); list_del(&pin->list);
kfree(pin); kfree(pin);
rdev->ena_pin = NULL; rdev->ena_pin = NULL;
...@@ -3004,7 +3003,7 @@ EXPORT_SYMBOL_GPL(regulator_get_linear_step); ...@@ -3004,7 +3003,7 @@ EXPORT_SYMBOL_GPL(regulator_get_linear_step);
* @min_uV: Minimum required voltage in uV. * @min_uV: Minimum required voltage in uV.
* @max_uV: Maximum required voltage in uV. * @max_uV: Maximum required voltage in uV.
* *
* Returns a boolean or a negative error code. * Returns a boolean.
*/ */
int regulator_is_supported_voltage(struct regulator *regulator, int regulator_is_supported_voltage(struct regulator *regulator,
int min_uV, int max_uV) int min_uV, int max_uV)
...@@ -3028,7 +3027,7 @@ int regulator_is_supported_voltage(struct regulator *regulator, ...@@ -3028,7 +3027,7 @@ int regulator_is_supported_voltage(struct regulator *regulator,
ret = regulator_count_voltages(regulator); ret = regulator_count_voltages(regulator);
if (ret < 0) if (ret < 0)
return ret; return 0;
voltages = ret; voltages = ret;
for (i = 0; i < voltages; i++) { for (i = 0; i < voltages; i++) {
...@@ -3322,15 +3321,12 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator, ...@@ -3322,15 +3321,12 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator,
/* for not coupled regulators this will just set the voltage */ /* for not coupled regulators this will just set the voltage */
ret = regulator_balance_voltage(rdev, state); ret = regulator_balance_voltage(rdev, state);
if (ret < 0) if (ret < 0) {
goto out2;
out:
return 0;
out2:
voltage->min_uV = old_min_uV; voltage->min_uV = old_min_uV;
voltage->max_uV = old_max_uV; voltage->max_uV = old_max_uV;
}
out:
return ret; return ret;
} }
...@@ -4347,8 +4343,6 @@ int regulator_bulk_get(struct device *dev, int num_consumers, ...@@ -4347,8 +4343,6 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
consumers[i].supply); consumers[i].supply);
if (IS_ERR(consumers[i].consumer)) { if (IS_ERR(consumers[i].consumer)) {
ret = PTR_ERR(consumers[i].consumer); ret = PTR_ERR(consumers[i].consumer);
dev_err(dev, "Failed to get supply '%s': %d\n",
consumers[i].supply, ret);
consumers[i].consumer = NULL; consumers[i].consumer = NULL;
goto err; goto err;
} }
...@@ -4357,6 +4351,13 @@ int regulator_bulk_get(struct device *dev, int num_consumers, ...@@ -4357,6 +4351,13 @@ int regulator_bulk_get(struct device *dev, int num_consumers,
return 0; return 0;
err: err:
if (ret != -EPROBE_DEFER)
dev_err(dev, "Failed to get supply '%s': %d\n",
consumers[i].supply, ret);
else
dev_dbg(dev, "Failed to get supply '%s', deferring\n",
consumers[i].supply);
while (--i >= 0) while (--i >= 0)
regulator_put(consumers[i].consumer); regulator_put(consumers[i].consumer);
...@@ -5064,10 +5065,11 @@ void regulator_unregister(struct regulator_dev *rdev) ...@@ -5064,10 +5065,11 @@ void regulator_unregister(struct regulator_dev *rdev)
regulator_put(rdev->supply); regulator_put(rdev->supply);
} }
flush_work(&rdev->disable_work.work);
mutex_lock(&regulator_list_mutex); mutex_lock(&regulator_list_mutex);
debugfs_remove_recursive(rdev->debugfs); debugfs_remove_recursive(rdev->debugfs);
flush_work(&rdev->disable_work.work);
WARN_ON(rdev->open_count); WARN_ON(rdev->open_count);
regulator_remove_coupling(rdev); regulator_remove_coupling(rdev);
unset_regulator_supplies(rdev); unset_regulator_supplies(rdev);
......
...@@ -505,17 +505,12 @@ MODULE_DEVICE_TABLE(of, cpcap_regulator_id_table); ...@@ -505,17 +505,12 @@ MODULE_DEVICE_TABLE(of, cpcap_regulator_id_table);
static int cpcap_regulator_probe(struct platform_device *pdev) static int cpcap_regulator_probe(struct platform_device *pdev)
{ {
struct cpcap_ddata *ddata; struct cpcap_ddata *ddata;
const struct of_device_id *match; const struct cpcap_regulator *match_data;
struct regulator_config config; struct regulator_config config;
struct regulator_init_data init_data;
int i; int i;
match = of_match_device(of_match_ptr(cpcap_regulator_id_table), match_data = of_device_get_match_data(&pdev->dev);
&pdev->dev); if (!match_data) {
if (!match)
return -EINVAL;
if (!match->data) {
dev_err(&pdev->dev, "no configuration data found\n"); dev_err(&pdev->dev, "no configuration data found\n");
return -ENODEV; return -ENODEV;
...@@ -530,14 +525,12 @@ static int cpcap_regulator_probe(struct platform_device *pdev) ...@@ -530,14 +525,12 @@ static int cpcap_regulator_probe(struct platform_device *pdev)
return -ENODEV; return -ENODEV;
ddata->dev = &pdev->dev; ddata->dev = &pdev->dev;
ddata->soc = match->data; ddata->soc = match_data;
platform_set_drvdata(pdev, ddata); platform_set_drvdata(pdev, ddata);
memset(&config, 0, sizeof(config)); memset(&config, 0, sizeof(config));
memset(&init_data, 0, sizeof(init_data));
config.dev = &pdev->dev; config.dev = &pdev->dev;
config.regmap = ddata->reg; config.regmap = ddata->reg;
config.init_data = &init_data;
for (i = 0; i < CPCAP_NR_REGULATORS; i++) { for (i = 0; i < CPCAP_NR_REGULATORS; i++) {
const struct cpcap_regulator *regulator = &ddata->soc[i]; const struct cpcap_regulator *regulator = &ddata->soc[i];
......
/* // SPDX-License-Identifier: GPL-2.0
* Regulators driver for Dialog Semiconductor DA903x //
* // Regulators driver for Dialog Semiconductor DA903x
* Copyright (C) 2006-2008 Marvell International Ltd. //
* Copyright (C) 2008 Compulab Ltd. // Copyright (C) 2006-2008 Marvell International Ltd.
* // Copyright (C) 2008 Compulab Ltd.
* 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/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
......
/* // SPDX-License-Identifier: GPL-2.0+
* da9052-regulator.c: Regulator driver for DA9052 //
* // da9052-regulator.c: Regulator driver for DA9052
* Copyright(c) 2011 Dialog Semiconductor Ltd. //
* // Copyright(c) 2011 Dialog Semiconductor Ltd.
* Author: David Dajun Chen <dchen@diasemi.com> //
* // Author: David Dajun Chen <dchen@diasemi.com>
* 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/module.h> #include <linux/module.h>
#include <linux/moduleparam.h> #include <linux/moduleparam.h>
...@@ -19,10 +13,8 @@ ...@@ -19,10 +13,8 @@
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
#ifdef CONFIG_OF
#include <linux/of.h> #include <linux/of.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#endif
#include <linux/mfd/da9052/da9052.h> #include <linux/mfd/da9052/da9052.h>
#include <linux/mfd/da9052/reg.h> #include <linux/mfd/da9052/reg.h>
...@@ -294,6 +286,8 @@ static const struct regulator_ops da9052_ldo_ops = { ...@@ -294,6 +286,8 @@ static const struct regulator_ops da9052_ldo_ops = {
{\ {\
.reg_desc = {\ .reg_desc = {\
.name = #_name,\ .name = #_name,\
.of_match = of_match_ptr(#_name),\
.regulators_node = of_match_ptr("regulators"),\
.ops = &da9052_ldo_ops,\ .ops = &da9052_ldo_ops,\
.type = REGULATOR_VOLTAGE,\ .type = REGULATOR_VOLTAGE,\
.id = DA9052_ID_##_id,\ .id = DA9052_ID_##_id,\
...@@ -314,6 +308,8 @@ static const struct regulator_ops da9052_ldo_ops = { ...@@ -314,6 +308,8 @@ static const struct regulator_ops da9052_ldo_ops = {
{\ {\
.reg_desc = {\ .reg_desc = {\
.name = #_name,\ .name = #_name,\
.of_match = of_match_ptr(#_name),\
.regulators_node = of_match_ptr("regulators"),\
.ops = &da9052_dcdc_ops,\ .ops = &da9052_dcdc_ops,\
.type = REGULATOR_VOLTAGE,\ .type = REGULATOR_VOLTAGE,\
.id = DA9052_ID_##_id,\ .id = DA9052_ID_##_id,\
...@@ -417,36 +413,11 @@ static int da9052_regulator_probe(struct platform_device *pdev) ...@@ -417,36 +413,11 @@ static int da9052_regulator_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
config.dev = &pdev->dev; config.dev = da9052->dev;
config.driver_data = regulator; config.driver_data = regulator;
config.regmap = da9052->regmap; config.regmap = da9052->regmap;
if (pdata) { if (pdata)
config.init_data = pdata->regulators[cell->id]; config.init_data = pdata->regulators[cell->id];
} else {
#ifdef CONFIG_OF
struct device_node *nproot = da9052->dev->of_node;
struct device_node *np;
if (!nproot)
return -ENODEV;
nproot = of_get_child_by_name(nproot, "regulators");
if (!nproot)
return -ENODEV;
for_each_child_of_node(nproot, np) {
if (of_node_name_eq(np,
regulator->info->reg_desc.name)) {
config.init_data = of_get_regulator_init_data(
&pdev->dev, np,
&regulator->info->reg_desc);
config.of_node = np;
break;
}
}
of_node_put(nproot);
#endif
}
regulator->rdev = devm_regulator_register(&pdev->dev, regulator->rdev = devm_regulator_register(&pdev->dev,
&regulator->info->reg_desc, &regulator->info->reg_desc,
......
/* // SPDX-License-Identifier: GPL-2.0+
* Regulator driver for DA9055 PMIC //
* // Regulator driver for DA9055 PMIC
* Copyright(c) 2012 Dialog Semiconductor Ltd. //
* // Copyright(c) 2012 Dialog Semiconductor Ltd.
* Author: David Dajun Chen <dchen@diasemi.com> //
* // Author: David Dajun Chen <dchen@diasemi.com>
* 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/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -338,6 +332,8 @@ static const struct regulator_ops da9055_ldo_ops = { ...@@ -338,6 +332,8 @@ static const struct regulator_ops da9055_ldo_ops = {
{\ {\
.reg_desc = {\ .reg_desc = {\
.name = #_id,\ .name = #_id,\
.of_match = of_match_ptr(#_id),\
.regulators_node = of_match_ptr("regulators"),\
.ops = &da9055_ldo_ops,\ .ops = &da9055_ldo_ops,\
.type = REGULATOR_VOLTAGE,\ .type = REGULATOR_VOLTAGE,\
.id = DA9055_ID_##_id,\ .id = DA9055_ID_##_id,\
...@@ -366,6 +362,8 @@ static const struct regulator_ops da9055_ldo_ops = { ...@@ -366,6 +362,8 @@ static const struct regulator_ops da9055_ldo_ops = {
{\ {\
.reg_desc = {\ .reg_desc = {\
.name = #_id,\ .name = #_id,\
.of_match = of_match_ptr(#_id),\
.regulators_node = of_match_ptr("regulators"),\
.ops = &da9055_buck_ops,\ .ops = &da9055_buck_ops,\
.type = REGULATOR_VOLTAGE,\ .type = REGULATOR_VOLTAGE,\
.id = DA9055_ID_##_id,\ .id = DA9055_ID_##_id,\
...@@ -487,8 +485,10 @@ static irqreturn_t da9055_ldo5_6_oc_irq(int irq, void *data) ...@@ -487,8 +485,10 @@ static irqreturn_t da9055_ldo5_6_oc_irq(int irq, void *data)
{ {
struct da9055_regulator *regulator = data; struct da9055_regulator *regulator = data;
regulator_lock(regulator->rdev);
regulator_notifier_call_chain(regulator->rdev, regulator_notifier_call_chain(regulator->rdev,
REGULATOR_EVENT_OVER_CURRENT, NULL); REGULATOR_EVENT_OVER_CURRENT, NULL);
regulator_unlock(regulator->rdev);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -507,59 +507,6 @@ static inline struct da9055_regulator_info *find_regulator_info(int id) ...@@ -507,59 +507,6 @@ static inline struct da9055_regulator_info *find_regulator_info(int id)
return NULL; return NULL;
} }
#ifdef CONFIG_OF
static struct of_regulator_match da9055_reg_matches[] = {
{ .name = "BUCK1", },
{ .name = "BUCK2", },
{ .name = "LDO1", },
{ .name = "LDO2", },
{ .name = "LDO3", },
{ .name = "LDO4", },
{ .name = "LDO5", },
{ .name = "LDO6", },
};
static int da9055_regulator_dt_init(struct platform_device *pdev,
struct da9055_regulator *regulator,
struct regulator_config *config,
int regid)
{
struct device_node *nproot, *np;
int ret;
nproot = of_node_get(pdev->dev.parent->of_node);
if (!nproot)
return -ENODEV;
np = of_get_child_by_name(nproot, "regulators");
if (!np)
return -ENODEV;
ret = of_regulator_match(&pdev->dev, np, &da9055_reg_matches[regid], 1);
of_node_put(nproot);
if (ret < 0) {
dev_err(&pdev->dev, "Error matching regulator: %d\n", ret);
return ret;
}
config->init_data = da9055_reg_matches[regid].init_data;
config->of_node = da9055_reg_matches[regid].of_node;
if (!config->of_node)
return -ENODEV;
return 0;
}
#else
static inline int da9055_regulator_dt_init(struct platform_device *pdev,
struct da9055_regulator *regulator,
struct regulator_config *config,
int regid)
{
return -ENODEV;
}
#endif /* CONFIG_OF */
static int da9055_regulator_probe(struct platform_device *pdev) static int da9055_regulator_probe(struct platform_device *pdev)
{ {
struct regulator_config config = { }; struct regulator_config config = { };
...@@ -580,18 +527,12 @@ static int da9055_regulator_probe(struct platform_device *pdev) ...@@ -580,18 +527,12 @@ static int da9055_regulator_probe(struct platform_device *pdev)
} }
regulator->da9055 = da9055; regulator->da9055 = da9055;
config.dev = &pdev->dev; config.dev = da9055->dev;
config.driver_data = regulator; config.driver_data = regulator;
config.regmap = da9055->regmap; config.regmap = da9055->regmap;
if (pdata) { if (pdata)
config.init_data = pdata->regulators[pdev->id]; config.init_data = pdata->regulators[pdev->id];
} else {
ret = da9055_regulator_dt_init(pdev, regulator, &config,
pdev->id);
if (ret < 0)
return ret;
}
ret = da9055_gpio_init(regulator, &config, pdata, pdev->id); ret = da9055_gpio_init(regulator, &config, pdata, pdev->id);
if (ret < 0) if (ret < 0)
......
This diff is collapsed.
// SPDX-License-Identifier: GPL-2.0+
//
// Regulator driver for DA9063 PMIC series
//
// Copyright 2012 Dialog Semiconductors Ltd.
// Copyright 2013 Philipp Zabel, Pengutronix
//
// Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com>
/*
* Regulator driver for DA9063 PMIC series
*
* Copyright 2012 Dialog Semiconductors Ltd.
* Copyright 2013 Philipp Zabel, Pengutronix
*
* Author: Krystian Garbaciak <krystian.garbaciak@diasemi.com>
*
* 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/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -38,17 +32,12 @@ ...@@ -38,17 +32,12 @@
struct da9063_regulator_info { struct da9063_regulator_info {
struct regulator_desc desc; struct regulator_desc desc;
/* Current limiting */
unsigned n_current_limits;
const int *current_limits;
/* DA9063 main register fields */ /* DA9063 main register fields */
struct reg_field mode; /* buck mode of operation */ struct reg_field mode; /* buck mode of operation */
struct reg_field suspend; struct reg_field suspend;
struct reg_field sleep; struct reg_field sleep;
struct reg_field suspend_sleep; struct reg_field suspend_sleep;
unsigned int suspend_vsel_reg; unsigned int suspend_vsel_reg;
struct reg_field ilimit;
/* DA9063 event detection bit */ /* DA9063 event detection bit */
struct reg_field oc_event; struct reg_field oc_event;
...@@ -73,15 +62,18 @@ struct da9063_regulator_info { ...@@ -73,15 +62,18 @@ struct da9063_regulator_info {
.suspend_vsel_reg = DA9063_REG_V##regl_name##_B .suspend_vsel_reg = DA9063_REG_V##regl_name##_B
/* Macros for voltage DC/DC converters (BUCKs) */ /* Macros for voltage DC/DC converters (BUCKs) */
#define DA9063_BUCK(chip, regl_name, min_mV, step_mV, max_mV, limits_array) \ #define DA9063_BUCK(chip, regl_name, min_mV, step_mV, max_mV, limits_array, \
creg, cmask) \
.desc.id = chip##_ID_##regl_name, \ .desc.id = chip##_ID_##regl_name, \
.desc.name = __stringify(chip##_##regl_name), \ .desc.name = __stringify(chip##_##regl_name), \
.desc.ops = &da9063_buck_ops, \ .desc.ops = &da9063_buck_ops, \
.desc.min_uV = (min_mV) * 1000, \ .desc.min_uV = (min_mV) * 1000, \
.desc.uV_step = (step_mV) * 1000, \ .desc.uV_step = (step_mV) * 1000, \
.desc.n_voltages = ((max_mV) - (min_mV))/(step_mV) + 1, \ .desc.n_voltages = ((max_mV) - (min_mV))/(step_mV) + 1, \
.current_limits = limits_array, \ .desc.csel_reg = (creg), \
.n_current_limits = ARRAY_SIZE(limits_array) .desc.csel_mask = (cmask), \
.desc.curr_table = limits_array, \
.desc.n_current_limits = ARRAY_SIZE(limits_array)
#define DA9063_BUCK_COMMON_FIELDS(regl_name) \ #define DA9063_BUCK_COMMON_FIELDS(regl_name) \
.desc.enable_reg = DA9063_REG_##regl_name##_CONT, \ .desc.enable_reg = DA9063_REG_##regl_name##_CONT, \
...@@ -112,7 +104,6 @@ struct da9063_regulator { ...@@ -112,7 +104,6 @@ struct da9063_regulator {
struct regmap_field *suspend; struct regmap_field *suspend;
struct regmap_field *sleep; struct regmap_field *sleep;
struct regmap_field *suspend_sleep; struct regmap_field *suspend_sleep;
struct regmap_field *ilimit;
}; };
/* Encapsulates all information for the regulators driver */ /* Encapsulates all information for the regulators driver */
...@@ -134,65 +125,32 @@ enum { ...@@ -134,65 +125,32 @@ enum {
/* Current limits array (in uA) for BCORE1, BCORE2, BPRO. /* Current limits array (in uA) for BCORE1, BCORE2, BPRO.
Entry indexes corresponds to register values. */ Entry indexes corresponds to register values. */
static const int da9063_buck_a_limits[] = { static const unsigned int da9063_buck_a_limits[] = {
500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000,
1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000
}; };
/* Current limits array (in uA) for BMEM, BIO, BPERI. /* Current limits array (in uA) for BMEM, BIO, BPERI.
Entry indexes corresponds to register values. */ Entry indexes corresponds to register values. */
static const int da9063_buck_b_limits[] = { static const unsigned int da9063_buck_b_limits[] = {
1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000,
2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000
}; };
/* Current limits array (in uA) for merged BCORE1 and BCORE2. /* Current limits array (in uA) for merged BCORE1 and BCORE2.
Entry indexes corresponds to register values. */ Entry indexes corresponds to register values. */
static const int da9063_bcores_merged_limits[] = { static const unsigned int da9063_bcores_merged_limits[] = {
1000000, 1200000, 1400000, 1600000, 1800000, 2000000, 2200000, 2400000, 1000000, 1200000, 1400000, 1600000, 1800000, 2000000, 2200000, 2400000,
2600000, 2800000, 3000000, 3200000, 3400000, 3600000, 3800000, 4000000 2600000, 2800000, 3000000, 3200000, 3400000, 3600000, 3800000, 4000000
}; };
/* Current limits array (in uA) for merged BMEM and BIO. /* Current limits array (in uA) for merged BMEM and BIO.
Entry indexes corresponds to register values. */ Entry indexes corresponds to register values. */
static const int da9063_bmem_bio_merged_limits[] = { static const unsigned int da9063_bmem_bio_merged_limits[] = {
3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000, 3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000,
4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000 4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000
}; };
static int da9063_set_current_limit(struct regulator_dev *rdev,
int min_uA, int max_uA)
{
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
const struct da9063_regulator_info *rinfo = regl->info;
int n, tval;
for (n = rinfo->n_current_limits - 1; n >= 0; n--) {
tval = rinfo->current_limits[n];
if (tval >= min_uA && tval <= max_uA)
return regmap_field_write(regl->ilimit, n);
}
return -EINVAL;
}
static int da9063_get_current_limit(struct regulator_dev *rdev)
{
struct da9063_regulator *regl = rdev_get_drvdata(rdev);
const struct da9063_regulator_info *rinfo = regl->info;
unsigned int sel;
int ret;
ret = regmap_field_read(regl->ilimit, &sel);
if (ret < 0)
return ret;
if (sel >= rinfo->n_current_limits)
sel = rinfo->n_current_limits - 1;
return rinfo->current_limits[sel];
}
static int da9063_buck_set_mode(struct regulator_dev *rdev, unsigned mode) static int da9063_buck_set_mode(struct regulator_dev *rdev, unsigned mode)
{ {
struct da9063_regulator *regl = rdev_get_drvdata(rdev); struct da9063_regulator *regl = rdev_get_drvdata(rdev);
...@@ -434,8 +392,8 @@ static const struct regulator_ops da9063_buck_ops = { ...@@ -434,8 +392,8 @@ static const struct regulator_ops da9063_buck_ops = {
.get_voltage_sel = regulator_get_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap,
.list_voltage = regulator_list_voltage_linear, .list_voltage = regulator_list_voltage_linear,
.set_current_limit = da9063_set_current_limit, .set_current_limit = regulator_set_current_limit_regmap,
.get_current_limit = da9063_get_current_limit, .get_current_limit = regulator_get_current_limit_regmap,
.set_mode = da9063_buck_set_mode, .set_mode = da9063_buck_set_mode,
.get_mode = da9063_buck_get_mode, .get_mode = da9063_buck_get_mode,
.get_status = da9063_buck_get_status, .get_status = da9063_buck_get_status,
...@@ -465,69 +423,61 @@ static const struct regulator_ops da9063_ldo_ops = { ...@@ -465,69 +423,61 @@ static const struct regulator_ops da9063_ldo_ops = {
static const struct da9063_regulator_info da9063_regulator_info[] = { static const struct da9063_regulator_info da9063_regulator_info[] = {
{ {
DA9063_BUCK(DA9063, BCORE1, 300, 10, 1570, DA9063_BUCK(DA9063, BCORE1, 300, 10, 1570,
da9063_buck_a_limits), da9063_buck_a_limits,
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BCORE1), DA9063_BUCK_COMMON_FIELDS(BCORE1),
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL), .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL),
.ilimit = BFIELD(DA9063_REG_BUCK_ILIM_C,
DA9063_BCORE1_ILIM_MASK),
}, },
{ {
DA9063_BUCK(DA9063, BCORE2, 300, 10, 1570, DA9063_BUCK(DA9063, BCORE2, 300, 10, 1570,
da9063_buck_a_limits), da9063_buck_a_limits,
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE2_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BCORE2), DA9063_BUCK_COMMON_FIELDS(BCORE2),
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE2_SEL), .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE2_SEL),
.ilimit = BFIELD(DA9063_REG_BUCK_ILIM_C,
DA9063_BCORE2_ILIM_MASK),
}, },
{ {
DA9063_BUCK(DA9063, BPRO, 530, 10, 1800, DA9063_BUCK(DA9063, BPRO, 530, 10, 1800,
da9063_buck_a_limits), da9063_buck_a_limits,
DA9063_REG_BUCK_ILIM_B, DA9063_BPRO_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BPRO), DA9063_BUCK_COMMON_FIELDS(BPRO),
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPRO_SEL), .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPRO_SEL),
.ilimit = BFIELD(DA9063_REG_BUCK_ILIM_B,
DA9063_BPRO_ILIM_MASK),
}, },
{ {
DA9063_BUCK(DA9063, BMEM, 800, 20, 3340, DA9063_BUCK(DA9063, BMEM, 800, 20, 3340,
da9063_buck_b_limits), da9063_buck_b_limits,
DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BMEM), DA9063_BUCK_COMMON_FIELDS(BMEM),
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL), .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL),
.ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A,
DA9063_BMEM_ILIM_MASK),
}, },
{ {
DA9063_BUCK(DA9063, BIO, 800, 20, 3340, DA9063_BUCK(DA9063, BIO, 800, 20, 3340,
da9063_buck_b_limits), da9063_buck_b_limits,
DA9063_REG_BUCK_ILIM_A, DA9063_BIO_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BIO), DA9063_BUCK_COMMON_FIELDS(BIO),
.suspend = BFIELD(DA9063_REG_DVC_2, DA9063_VBIO_SEL), .suspend = BFIELD(DA9063_REG_DVC_2, DA9063_VBIO_SEL),
.ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A,
DA9063_BIO_ILIM_MASK),
}, },
{ {
DA9063_BUCK(DA9063, BPERI, 800, 20, 3340, DA9063_BUCK(DA9063, BPERI, 800, 20, 3340,
da9063_buck_b_limits), da9063_buck_b_limits,
DA9063_REG_BUCK_ILIM_B, DA9063_BPERI_ILIM_MASK),
DA9063_BUCK_COMMON_FIELDS(BPERI), DA9063_BUCK_COMMON_FIELDS(BPERI),
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPERI_SEL), .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBPERI_SEL),
.ilimit = BFIELD(DA9063_REG_BUCK_ILIM_B,
DA9063_BPERI_ILIM_MASK),
}, },
{ {
DA9063_BUCK(DA9063, BCORES_MERGED, 300, 10, 1570, DA9063_BUCK(DA9063, BCORES_MERGED, 300, 10, 1570,
da9063_bcores_merged_limits), da9063_bcores_merged_limits,
DA9063_REG_BUCK_ILIM_C, DA9063_BCORE1_ILIM_MASK),
/* BCORES_MERGED uses the same register fields as BCORE1 */ /* BCORES_MERGED uses the same register fields as BCORE1 */
DA9063_BUCK_COMMON_FIELDS(BCORE1), DA9063_BUCK_COMMON_FIELDS(BCORE1),
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL), .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBCORE1_SEL),
.ilimit = BFIELD(DA9063_REG_BUCK_ILIM_C,
DA9063_BCORE1_ILIM_MASK),
}, },
{ {
DA9063_BUCK(DA9063, BMEM_BIO_MERGED, 800, 20, 3340, DA9063_BUCK(DA9063, BMEM_BIO_MERGED, 800, 20, 3340,
da9063_bmem_bio_merged_limits), da9063_bmem_bio_merged_limits,
DA9063_REG_BUCK_ILIM_A, DA9063_BMEM_ILIM_MASK),
/* BMEM_BIO_MERGED uses the same register fields as BMEM */ /* BMEM_BIO_MERGED uses the same register fields as BMEM */
DA9063_BUCK_COMMON_FIELDS(BMEM), DA9063_BUCK_COMMON_FIELDS(BMEM),
.suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL), .suspend = BFIELD(DA9063_REG_DVC_1, DA9063_VBMEM_SEL),
.ilimit = BFIELD(DA9063_REG_BUCK_ILIM_A,
DA9063_BMEM_ILIM_MASK),
}, },
{ {
DA9063_LDO(DA9063, LDO3, 900, 20, 3440), DA9063_LDO(DA9063, LDO3, 900, 20, 3440),
...@@ -615,9 +565,12 @@ static irqreturn_t da9063_ldo_lim_event(int irq, void *data) ...@@ -615,9 +565,12 @@ static irqreturn_t da9063_ldo_lim_event(int irq, void *data)
if (regl->info->oc_event.reg != DA9063_REG_STATUS_D) if (regl->info->oc_event.reg != DA9063_REG_STATUS_D)
continue; continue;
if (BIT(regl->info->oc_event.lsb) & bits) if (BIT(regl->info->oc_event.lsb) & bits) {
regulator_lock(regl->rdev);
regulator_notifier_call_chain(regl->rdev, regulator_notifier_call_chain(regl->rdev,
REGULATOR_EVENT_OVER_CURRENT, NULL); REGULATOR_EVENT_OVER_CURRENT, NULL);
regulator_unlock(regl->rdev);
}
} }
return IRQ_HANDLED; return IRQ_HANDLED;
...@@ -861,13 +814,6 @@ static int da9063_regulator_probe(struct platform_device *pdev) ...@@ -861,13 +814,6 @@ static int da9063_regulator_probe(struct platform_device *pdev)
return PTR_ERR(regl->suspend_sleep); return PTR_ERR(regl->suspend_sleep);
} }
if (regl->info->ilimit.reg) {
regl->ilimit = devm_regmap_field_alloc(&pdev->dev,
da9063->regmap, regl->info->ilimit);
if (IS_ERR(regl->ilimit))
return PTR_ERR(regl->ilimit);
}
/* Register regulator */ /* Register regulator */
memset(&config, 0, sizeof(config)); memset(&config, 0, sizeof(config));
config.dev = &pdev->dev; config.dev = &pdev->dev;
......
/* // SPDX-License-Identifier: GPL-2.0+
* da9210-regulator.c - Regulator device driver for DA9210 //
* Copyright (C) 2013 Dialog Semiconductor Ltd. // 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/err.h>
#include <linux/i2c.h> #include <linux/i2c.h>
......
/* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* da9210-regulator.h - Regulator definitions for DA9210 * da9210-regulator.h - Regulator definitions for DA9210
* Copyright (C) 2013 Dialog Semiconductor Ltd. * 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__ #ifndef __DA9210_REGISTERS_H__
......
/* // SPDX-License-Identifier: GPL-2.0+
* da9211-regulator.c - Regulator device driver for DA9211/DA9212 //
* /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225 // da9211-regulator.c - Regulator device driver for DA9211/DA9212
* Copyright (C) 2015 Dialog Semiconductor Ltd. // /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225
* // Copyright (C) 2015 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.
*/
#include <linux/err.h> #include <linux/err.h>
#include <linux/i2c.h> #include <linux/i2c.h>
...@@ -322,8 +312,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) ...@@ -322,8 +312,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data)
goto error_i2c; goto error_i2c;
if (reg_val & DA9211_E_OV_CURR_A) { if (reg_val & DA9211_E_OV_CURR_A) {
regulator_lock(chip->rdev[0]);
regulator_notifier_call_chain(chip->rdev[0], regulator_notifier_call_chain(chip->rdev[0],
REGULATOR_EVENT_OVER_CURRENT, NULL); REGULATOR_EVENT_OVER_CURRENT, NULL);
regulator_unlock(chip->rdev[0]);
err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
DA9211_E_OV_CURR_A); DA9211_E_OV_CURR_A);
...@@ -334,8 +326,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data) ...@@ -334,8 +326,10 @@ static irqreturn_t da9211_irq_handler(int irq, void *data)
} }
if (reg_val & DA9211_E_OV_CURR_B) { if (reg_val & DA9211_E_OV_CURR_B) {
regulator_lock(chip->rdev[1]);
regulator_notifier_call_chain(chip->rdev[1], regulator_notifier_call_chain(chip->rdev[1],
REGULATOR_EVENT_OVER_CURRENT, NULL); REGULATOR_EVENT_OVER_CURRENT, NULL);
regulator_unlock(chip->rdev[1]);
err = regmap_write(chip->regmap, DA9211_REG_EVENT_B, err = regmap_write(chip->regmap, DA9211_REG_EVENT_B,
DA9211_E_OV_CURR_B); DA9211_E_OV_CURR_B);
......
/* SPDX-License-Identifier: GPL-2.0+ */
/* /*
* da9211-regulator.h - Regulator definitions for DA9211/DA9212 * da9211-regulator.h - Regulator definitions for DA9211/DA9212
* /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225 * /DA9213/DA9223/DA9214/DA9224/DA9215/DA9225
* Copyright (C) 2015 Dialog Semiconductor Ltd. * Copyright (C) 2015 Dialog Semiconductor 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.
*
* 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.
*/ */
#ifndef __DA9211_REGISTERS_H__ #ifndef __DA9211_REGISTERS_H__
......
This diff is collapsed.
...@@ -15,18 +15,14 @@ ...@@ -15,18 +15,14 @@
/** /**
* struct dbx500_regulator_info - dbx500 regulator information * struct dbx500_regulator_info - dbx500 regulator information
* @dev: device pointer
* @desc: regulator description * @desc: regulator description
* @rdev: regulator device pointer
* @is_enabled: status of the regulator * @is_enabled: status of the regulator
* @epod_id: id for EPOD (power domain) * @epod_id: id for EPOD (power domain)
* @is_ramret: RAM retention switch for EPOD (power domain) * @is_ramret: RAM retention switch for EPOD (power domain)
* *
*/ */
struct dbx500_regulator_info { struct dbx500_regulator_info {
struct device *dev;
struct regulator_desc desc; struct regulator_desc desc;
struct regulator_dev *rdev;
bool is_enabled; bool is_enabled;
u16 epod_id; u16 epod_id;
bool is_ramret; bool is_ramret;
......
/* // SPDX-License-Identifier: GPL-2.0
* FAN53555 Fairchild Digitally Programmable TinyBuck Regulator Driver. //
* // FAN53555 Fairchild Digitally Programmable TinyBuck Regulator Driver.
* Supported Part Numbers: //
* FAN53555UC00X/01X/03X/04X/05X // Supported Part Numbers:
* // FAN53555UC00X/01X/03X/04X/05X
* Copyright (c) 2012 Marvell Technology Ltd. //
* Yunfan Zhang <yfzhang@marvell.com> // Copyright (c) 2012 Marvell Technology Ltd.
* // Yunfan Zhang <yfzhang@marvell.com>
* This package 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/module.h>
#include <linux/param.h> #include <linux/param.h>
#include <linux/err.h> #include <linux/err.h>
...@@ -91,10 +87,8 @@ enum { ...@@ -91,10 +87,8 @@ enum {
struct fan53555_device_info { struct fan53555_device_info {
enum fan53555_vendor vendor; enum fan53555_vendor vendor;
struct regmap *regmap;
struct device *dev; struct device *dev;
struct regulator_desc desc; struct regulator_desc desc;
struct regulator_dev *rdev;
struct regulator_init_data *regulator; struct regulator_init_data *regulator;
/* IC Type and Rev */ /* IC Type and Rev */
int chip_id; int chip_id;
...@@ -106,8 +100,6 @@ struct fan53555_device_info { ...@@ -106,8 +100,6 @@ struct fan53555_device_info {
unsigned int vsel_min; unsigned int vsel_min;
unsigned int vsel_step; unsigned int vsel_step;
unsigned int vsel_count; unsigned int vsel_count;
/* Voltage slew rate limiting */
unsigned int slew_rate;
/* Mode */ /* Mode */
unsigned int mode_reg; unsigned int mode_reg;
unsigned int mode_mask; unsigned int mode_mask;
...@@ -125,7 +117,7 @@ static int fan53555_set_suspend_voltage(struct regulator_dev *rdev, int uV) ...@@ -125,7 +117,7 @@ static int fan53555_set_suspend_voltage(struct regulator_dev *rdev, int uV)
ret = regulator_map_voltage_linear(rdev, uV, uV); ret = regulator_map_voltage_linear(rdev, uV, uV);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = regmap_update_bits(di->regmap, di->sleep_reg, ret = regmap_update_bits(rdev->regmap, di->sleep_reg,
di->desc.vsel_mask, ret); di->desc.vsel_mask, ret);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -140,7 +132,7 @@ static int fan53555_set_suspend_enable(struct regulator_dev *rdev) ...@@ -140,7 +132,7 @@ static int fan53555_set_suspend_enable(struct regulator_dev *rdev)
{ {
struct fan53555_device_info *di = rdev_get_drvdata(rdev); struct fan53555_device_info *di = rdev_get_drvdata(rdev);
return regmap_update_bits(di->regmap, di->sleep_reg, return regmap_update_bits(rdev->regmap, di->sleep_reg,
VSEL_BUCK_EN, VSEL_BUCK_EN); VSEL_BUCK_EN, VSEL_BUCK_EN);
} }
...@@ -148,7 +140,7 @@ static int fan53555_set_suspend_disable(struct regulator_dev *rdev) ...@@ -148,7 +140,7 @@ static int fan53555_set_suspend_disable(struct regulator_dev *rdev)
{ {
struct fan53555_device_info *di = rdev_get_drvdata(rdev); struct fan53555_device_info *di = rdev_get_drvdata(rdev);
return regmap_update_bits(di->regmap, di->sleep_reg, return regmap_update_bits(rdev->regmap, di->sleep_reg,
VSEL_BUCK_EN, 0); VSEL_BUCK_EN, 0);
} }
...@@ -158,11 +150,11 @@ static int fan53555_set_mode(struct regulator_dev *rdev, unsigned int mode) ...@@ -158,11 +150,11 @@ static int fan53555_set_mode(struct regulator_dev *rdev, unsigned int mode)
switch (mode) { switch (mode) {
case REGULATOR_MODE_FAST: case REGULATOR_MODE_FAST:
regmap_update_bits(di->regmap, di->mode_reg, regmap_update_bits(rdev->regmap, di->mode_reg,
di->mode_mask, di->mode_mask); di->mode_mask, di->mode_mask);
break; break;
case REGULATOR_MODE_NORMAL: case REGULATOR_MODE_NORMAL:
regmap_update_bits(di->regmap, di->vol_reg, di->mode_mask, 0); regmap_update_bits(rdev->regmap, di->vol_reg, di->mode_mask, 0);
break; break;
default: default:
return -EINVAL; return -EINVAL;
...@@ -176,7 +168,7 @@ static unsigned int fan53555_get_mode(struct regulator_dev *rdev) ...@@ -176,7 +168,7 @@ static unsigned int fan53555_get_mode(struct regulator_dev *rdev)
unsigned int val; unsigned int val;
int ret = 0; int ret = 0;
ret = regmap_read(di->regmap, di->mode_reg, &val); ret = regmap_read(rdev->regmap, di->mode_reg, &val);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (val & di->mode_mask) if (val & di->mode_mask)
...@@ -213,7 +205,7 @@ static int fan53555_set_ramp(struct regulator_dev *rdev, int ramp) ...@@ -213,7 +205,7 @@ static int fan53555_set_ramp(struct regulator_dev *rdev, int ramp)
return -EINVAL; return -EINVAL;
} }
return regmap_update_bits(di->regmap, FAN53555_CONTROL, return regmap_update_bits(rdev->regmap, FAN53555_CONTROL,
CTL_SLEW_MASK, regval << CTL_SLEW_SHIFT); CTL_SLEW_MASK, regval << CTL_SLEW_SHIFT);
} }
...@@ -396,6 +388,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, ...@@ -396,6 +388,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
struct regulator_config *config) struct regulator_config *config)
{ {
struct regulator_desc *rdesc = &di->desc; struct regulator_desc *rdesc = &di->desc;
struct regulator_dev *rdev;
rdesc->name = "fan53555-reg"; rdesc->name = "fan53555-reg";
rdesc->supply_name = "vin"; rdesc->supply_name = "vin";
...@@ -410,8 +403,8 @@ static int fan53555_regulator_register(struct fan53555_device_info *di, ...@@ -410,8 +403,8 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
rdesc->vsel_mask = di->vsel_count - 1; rdesc->vsel_mask = di->vsel_count - 1;
rdesc->owner = THIS_MODULE; rdesc->owner = THIS_MODULE;
di->rdev = devm_regulator_register(di->dev, &di->desc, config); rdev = devm_regulator_register(di->dev, &di->desc, config);
return PTR_ERR_OR_ZERO(di->rdev); return PTR_ERR_OR_ZERO(rdev);
} }
static const struct regmap_config fan53555_regmap_config = { static const struct regmap_config fan53555_regmap_config = {
...@@ -466,6 +459,7 @@ static int fan53555_regulator_probe(struct i2c_client *client, ...@@ -466,6 +459,7 @@ static int fan53555_regulator_probe(struct i2c_client *client,
struct fan53555_device_info *di; struct fan53555_device_info *di;
struct fan53555_platform_data *pdata; struct fan53555_platform_data *pdata;
struct regulator_config config = { }; struct regulator_config config = { };
struct regmap *regmap;
unsigned int val; unsigned int val;
int ret; int ret;
...@@ -502,22 +496,22 @@ static int fan53555_regulator_probe(struct i2c_client *client, ...@@ -502,22 +496,22 @@ static int fan53555_regulator_probe(struct i2c_client *client,
di->vendor = id->driver_data; di->vendor = id->driver_data;
} }
di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config); regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config);
if (IS_ERR(di->regmap)) { if (IS_ERR(regmap)) {
dev_err(&client->dev, "Failed to allocate regmap!\n"); dev_err(&client->dev, "Failed to allocate regmap!\n");
return PTR_ERR(di->regmap); return PTR_ERR(regmap);
} }
di->dev = &client->dev; di->dev = &client->dev;
i2c_set_clientdata(client, di); i2c_set_clientdata(client, di);
/* Get chip ID */ /* Get chip ID */
ret = regmap_read(di->regmap, FAN53555_ID1, &val); ret = regmap_read(regmap, FAN53555_ID1, &val);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "Failed to get chip ID!\n"); dev_err(&client->dev, "Failed to get chip ID!\n");
return ret; return ret;
} }
di->chip_id = val & DIE_ID; di->chip_id = val & DIE_ID;
/* Get chip revision */ /* Get chip revision */
ret = regmap_read(di->regmap, FAN53555_ID2, &val); ret = regmap_read(regmap, FAN53555_ID2, &val);
if (ret < 0) { if (ret < 0) {
dev_err(&client->dev, "Failed to get chip Rev!\n"); dev_err(&client->dev, "Failed to get chip Rev!\n");
return ret; return ret;
...@@ -534,7 +528,7 @@ static int fan53555_regulator_probe(struct i2c_client *client, ...@@ -534,7 +528,7 @@ static int fan53555_regulator_probe(struct i2c_client *client,
/* Register regulator */ /* Register regulator */
config.dev = di->dev; config.dev = di->dev;
config.init_data = di->regulator; config.init_data = di->regulator;
config.regmap = di->regmap; config.regmap = regmap;
config.driver_data = di; config.driver_data = di;
config.of_node = np; config.of_node = np;
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
struct gpio_regulator_data { struct gpio_regulator_data {
struct regulator_desc desc; struct regulator_desc desc;
struct regulator_dev *dev;
struct gpio_desc **gpiods; struct gpio_desc **gpiods;
int nr_gpios; int nr_gpios;
...@@ -125,7 +124,7 @@ static int gpio_regulator_set_current_limit(struct regulator_dev *dev, ...@@ -125,7 +124,7 @@ static int gpio_regulator_set_current_limit(struct regulator_dev *dev,
return 0; return 0;
} }
static struct regulator_ops gpio_regulator_voltage_ops = { static const struct regulator_ops gpio_regulator_voltage_ops = {
.get_voltage = gpio_regulator_get_value, .get_voltage = gpio_regulator_get_value,
.set_voltage = gpio_regulator_set_voltage, .set_voltage = gpio_regulator_set_voltage,
.list_voltage = gpio_regulator_list_voltage, .list_voltage = gpio_regulator_list_voltage,
...@@ -221,7 +220,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, ...@@ -221,7 +220,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
return config; return config;
} }
static struct regulator_ops gpio_regulator_current_ops = { static const struct regulator_ops gpio_regulator_current_ops = {
.get_current_limit = gpio_regulator_get_value, .get_current_limit = gpio_regulator_get_value,
.set_current_limit = gpio_regulator_set_current_limit, .set_current_limit = gpio_regulator_set_current_limit,
}; };
...@@ -233,6 +232,7 @@ static int gpio_regulator_probe(struct platform_device *pdev) ...@@ -233,6 +232,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
struct device_node *np = dev->of_node; struct device_node *np = dev->of_node;
struct gpio_regulator_data *drvdata; struct gpio_regulator_data *drvdata;
struct regulator_config cfg = { }; struct regulator_config cfg = { };
struct regulator_dev *rdev;
enum gpiod_flags gflags; enum gpiod_flags gflags;
int ptr, ret, state, i; int ptr, ret, state, i;
...@@ -326,9 +326,9 @@ static int gpio_regulator_probe(struct platform_device *pdev) ...@@ -326,9 +326,9 @@ static int gpio_regulator_probe(struct platform_device *pdev)
if (IS_ERR(cfg.ena_gpiod)) if (IS_ERR(cfg.ena_gpiod))
return PTR_ERR(cfg.ena_gpiod); return PTR_ERR(cfg.ena_gpiod);
drvdata->dev = regulator_register(&drvdata->desc, &cfg); rdev = devm_regulator_register(dev, &drvdata->desc, &cfg);
if (IS_ERR(drvdata->dev)) { if (IS_ERR(rdev)) {
ret = PTR_ERR(drvdata->dev); ret = PTR_ERR(rdev);
dev_err(dev, "Failed to register regulator: %d\n", ret); dev_err(dev, "Failed to register regulator: %d\n", ret);
return ret; return ret;
} }
...@@ -338,15 +338,6 @@ static int gpio_regulator_probe(struct platform_device *pdev) ...@@ -338,15 +338,6 @@ static int gpio_regulator_probe(struct platform_device *pdev)
return 0; return 0;
} }
static int gpio_regulator_remove(struct platform_device *pdev)
{
struct gpio_regulator_data *drvdata = platform_get_drvdata(pdev);
regulator_unregister(drvdata->dev);
return 0;
}
#if defined(CONFIG_OF) #if defined(CONFIG_OF)
static const struct of_device_id regulator_gpio_of_match[] = { static const struct of_device_id regulator_gpio_of_match[] = {
{ .compatible = "regulator-gpio", }, { .compatible = "regulator-gpio", },
...@@ -357,7 +348,6 @@ MODULE_DEVICE_TABLE(of, regulator_gpio_of_match); ...@@ -357,7 +348,6 @@ MODULE_DEVICE_TABLE(of, regulator_gpio_of_match);
static struct platform_driver gpio_regulator_driver = { static struct platform_driver gpio_regulator_driver = {
.probe = gpio_regulator_probe, .probe = gpio_regulator_probe,
.remove = gpio_regulator_remove,
.driver = { .driver = {
.name = "gpio-regulator", .name = "gpio-regulator",
.of_match_table = of_match_ptr(regulator_gpio_of_match), .of_match_table = of_match_ptr(regulator_gpio_of_match),
......
This diff is collapsed.
/* // SPDX-License-Identifier: GPL-2.0
* Device driver for regulators in Hi6421V530 IC //
* // Device driver for regulators in Hi6421V530 IC
* Copyright (c) <2017> HiSilicon Technologies Co., Ltd. //
* http://www.hisilicon.com // Copyright (c) <2017> HiSilicon Technologies Co., Ltd.
* Copyright (c) <2017> Linaro Ltd. // http://www.hisilicon.com
* http://www.linaro.org // Copyright (c) <2017> Linaro Ltd.
* // http://www.linaro.org
* Author: Wang Xiaoyin <hw.wangxiaoyin@hisilicon.com> //
* Guodong Xu <guodong.xu@linaro.org> // Author: Wang Xiaoyin <hw.wangxiaoyin@hisilicon.com>
* // Guodong Xu <guodong.xu@linaro.org>
* 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/mfd/hi6421-pmic.h> #include <linux/mfd/hi6421-pmic.h>
#include <linux/module.h> #include <linux/module.h>
......
/* // SPDX-License-Identifier: GPL-2.0
* Device driver for regulators in Hi655x IC //
* // Device driver for regulators in Hi655x IC
* Copyright (c) 2016 Hisilicon. //
* // Copyright (c) 2016 Hisilicon.
* Authors: //
* Chen Feng <puck.chen@hisilicon.com> // Authors:
* Fei Wang <w.f@huawei.com> // Chen Feng <puck.chen@hisilicon.com>
* // Fei Wang <w.f@huawei.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/bitops.h> #include <linux/bitops.h>
#include <linux/device.h> #include <linux/device.h>
...@@ -28,7 +24,6 @@ ...@@ -28,7 +24,6 @@
struct hi655x_regulator { struct hi655x_regulator {
unsigned int disable_reg; unsigned int disable_reg;
unsigned int status_reg; unsigned int status_reg;
unsigned int ctrl_mask;
struct regulator_desc rdesc; struct regulator_desc rdesc;
}; };
...@@ -77,22 +72,18 @@ enum hi655x_regulator_id { ...@@ -77,22 +72,18 @@ enum hi655x_regulator_id {
static int hi655x_is_enabled(struct regulator_dev *rdev) static int hi655x_is_enabled(struct regulator_dev *rdev)
{ {
unsigned int value = 0; unsigned int value = 0;
struct hi655x_regulator *regulator = rdev_get_drvdata(rdev); struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
regmap_read(rdev->regmap, regulator->status_reg, &value); regmap_read(rdev->regmap, regulator->status_reg, &value);
return (value & BIT(regulator->ctrl_mask)); return (value & rdev->desc->enable_mask);
} }
static int hi655x_disable(struct regulator_dev *rdev) static int hi655x_disable(struct regulator_dev *rdev)
{ {
int ret = 0;
struct hi655x_regulator *regulator = rdev_get_drvdata(rdev); struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
ret = regmap_write(rdev->regmap, regulator->disable_reg, return regmap_write(rdev->regmap, regulator->disable_reg,
BIT(regulator->ctrl_mask)); rdev->desc->enable_mask);
return ret;
} }
static const struct regulator_ops hi655x_regulator_ops = { static const struct regulator_ops hi655x_regulator_ops = {
...@@ -132,7 +123,6 @@ static const struct regulator_ops hi655x_ldo_linear_ops = { ...@@ -132,7 +123,6 @@ static const struct regulator_ops hi655x_ldo_linear_ops = {
}, \ }, \
.disable_reg = HI655X_BUS_ADDR(dreg), \ .disable_reg = HI655X_BUS_ADDR(dreg), \
.status_reg = HI655X_BUS_ADDR(sreg), \ .status_reg = HI655X_BUS_ADDR(sreg), \
.ctrl_mask = cmask, \
} }
#define HI655X_LDO_LINEAR(_ID, vreg, vmask, ereg, dreg, \ #define HI655X_LDO_LINEAR(_ID, vreg, vmask, ereg, dreg, \
...@@ -155,10 +145,9 @@ static const struct regulator_ops hi655x_ldo_linear_ops = { ...@@ -155,10 +145,9 @@ static const struct regulator_ops hi655x_ldo_linear_ops = {
}, \ }, \
.disable_reg = HI655X_BUS_ADDR(dreg), \ .disable_reg = HI655X_BUS_ADDR(dreg), \
.status_reg = HI655X_BUS_ADDR(sreg), \ .status_reg = HI655X_BUS_ADDR(sreg), \
.ctrl_mask = cmask, \
} }
static struct hi655x_regulator regulators[] = { static const struct hi655x_regulator regulators[] = {
HI655X_LDO_LINEAR(LDO2, 0x72, 0x07, 0x29, 0x2a, 0x2b, 0x01, HI655X_LDO_LINEAR(LDO2, 0x72, 0x07, 0x29, 0x2a, 0x2b, 0x01,
2500000, 8, 100000), 2500000, 8, 100000),
HI655X_LDO(LDO7, 0x78, 0x07, 0x29, 0x2a, 0x2b, 0x06, ldo7_voltages), HI655X_LDO(LDO7, 0x78, 0x07, 0x29, 0x2a, 0x2b, 0x06, ldo7_voltages),
......
...@@ -48,7 +48,7 @@ static const int ldo_cont_enable_time[] = { ...@@ -48,7 +48,7 @@ static const int ldo_cont_enable_time[] = {
static int lm363x_regulator_enable_time(struct regulator_dev *rdev) static int lm363x_regulator_enable_time(struct regulator_dev *rdev)
{ {
enum lm363x_regulator_id id = rdev_get_id(rdev); enum lm363x_regulator_id id = rdev_get_id(rdev);
u8 val, addr, mask; unsigned int val, addr, mask;
switch (id) { switch (id) {
case LM3631_LDO_CONT: case LM3631_LDO_CONT:
...@@ -71,7 +71,7 @@ static int lm363x_regulator_enable_time(struct regulator_dev *rdev) ...@@ -71,7 +71,7 @@ static int lm363x_regulator_enable_time(struct regulator_dev *rdev)
return 0; return 0;
} }
if (regmap_read(rdev->regmap, addr, (unsigned int *)&val)) if (regmap_read(rdev->regmap, addr, &val))
return -EINVAL; return -EINVAL;
val = (val & mask) >> LM3631_ENTIME_SHIFT; val = (val & mask) >> LM3631_ENTIME_SHIFT;
...@@ -82,13 +82,13 @@ static int lm363x_regulator_enable_time(struct regulator_dev *rdev) ...@@ -82,13 +82,13 @@ static int lm363x_regulator_enable_time(struct regulator_dev *rdev)
return ENABLE_TIME_USEC * val; return ENABLE_TIME_USEC * val;
} }
static struct regulator_ops lm363x_boost_voltage_table_ops = { static const struct regulator_ops lm363x_boost_voltage_table_ops = {
.list_voltage = regulator_list_voltage_linear, .list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap,
}; };
static struct regulator_ops lm363x_regulator_voltage_table_ops = { static const struct regulator_ops lm363x_regulator_voltage_table_ops = {
.list_voltage = regulator_list_voltage_linear, .list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap,
......
...@@ -372,10 +372,13 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data) ...@@ -372,10 +372,13 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data)
for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
if ((flag0 & (0x4 << icnt)) if ((flag0 & (0x4 << icnt))
&& (pchip->irqmask & (0x04 << icnt)) && (pchip->irqmask & (0x04 << icnt))
&& (pchip->rdev[icnt] != NULL)) && (pchip->rdev[icnt] != NULL)) {
regulator_lock(pchip->rdev[icnt]);
regulator_notifier_call_chain(pchip->rdev[icnt], regulator_notifier_call_chain(pchip->rdev[icnt],
LP8755_EVENT_PWR_FAULT, LP8755_EVENT_PWR_FAULT,
NULL); NULL);
regulator_unlock(pchip->rdev[icnt]);
}
/* read flag1 register */ /* read flag1 register */
ret = lp8755_read(pchip, 0x0E, &flag1); ret = lp8755_read(pchip, 0x0E, &flag1);
...@@ -389,18 +392,24 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data) ...@@ -389,18 +392,24 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data)
/* send OCP event to all regulator devices */ /* send OCP event to all regulator devices */
if ((flag1 & 0x01) && (pchip->irqmask & 0x01)) if ((flag1 & 0x01) && (pchip->irqmask & 0x01))
for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
if (pchip->rdev[icnt] != NULL) if (pchip->rdev[icnt] != NULL) {
regulator_lock(pchip->rdev[icnt]);
regulator_notifier_call_chain(pchip->rdev[icnt], regulator_notifier_call_chain(pchip->rdev[icnt],
LP8755_EVENT_OCP, LP8755_EVENT_OCP,
NULL); NULL);
regulator_unlock(pchip->rdev[icnt]);
}
/* send OVP event to all regulator devices */ /* send OVP event to all regulator devices */
if ((flag1 & 0x02) && (pchip->irqmask & 0x02)) if ((flag1 & 0x02) && (pchip->irqmask & 0x02))
for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++) for (icnt = 0; icnt < LP8755_BUCK_MAX; icnt++)
if (pchip->rdev[icnt] != NULL) if (pchip->rdev[icnt] != NULL) {
regulator_lock(pchip->rdev[icnt]);
regulator_notifier_call_chain(pchip->rdev[icnt], regulator_notifier_call_chain(pchip->rdev[icnt],
LP8755_EVENT_OVP, LP8755_EVENT_OVP,
NULL); NULL);
regulator_unlock(pchip->rdev[icnt]);
}
return IRQ_HANDLED; return IRQ_HANDLED;
err_i2c: err_i2c:
......
...@@ -34,6 +34,10 @@ ...@@ -34,6 +34,10 @@
.ramp_delay = _delay, \ .ramp_delay = _delay, \
.linear_ranges = _lr, \ .linear_ranges = _lr, \
.n_linear_ranges = ARRAY_SIZE(_lr), \ .n_linear_ranges = ARRAY_SIZE(_lr), \
.curr_table = lp87565_buck_uA, \
.n_current_limits = ARRAY_SIZE(lp87565_buck_uA),\
.csel_reg = (_cr), \
.csel_mask = LP87565_BUCK_CTRL_2_ILIM, \
}, \ }, \
.ctrl2_reg = _cr, \ .ctrl2_reg = _cr, \
} }
...@@ -102,44 +106,7 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev *rdev, ...@@ -102,44 +106,7 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev *rdev,
return 0; return 0;
} }
static int lp87565_buck_set_current_limit(struct regulator_dev *rdev, /* Operations permitted on BUCKs */
int min_uA, int max_uA)
{
int id = rdev_get_id(rdev);
struct lp87565 *lp87565 = rdev_get_drvdata(rdev);
int i;
for (i = ARRAY_SIZE(lp87565_buck_uA) - 1; i >= 0; i--) {
if (lp87565_buck_uA[i] >= min_uA &&
lp87565_buck_uA[i] <= max_uA)
return regmap_update_bits(lp87565->regmap,
regulators[id].ctrl2_reg,
LP87565_BUCK_CTRL_2_ILIM,
i << __ffs(LP87565_BUCK_CTRL_2_ILIM));
}
return -EINVAL;
}
static int lp87565_buck_get_current_limit(struct regulator_dev *rdev)
{
int id = rdev_get_id(rdev);
struct lp87565 *lp87565 = rdev_get_drvdata(rdev);
int ret;
unsigned int val;
ret = regmap_read(lp87565->regmap, regulators[id].ctrl2_reg, &val);
if (ret)
return ret;
val = (val & LP87565_BUCK_CTRL_2_ILIM) >>
__ffs(LP87565_BUCK_CTRL_2_ILIM);
return (val < ARRAY_SIZE(lp87565_buck_uA)) ?
lp87565_buck_uA[val] : -EINVAL;
}
/* Operations permitted on BUCK0, BUCK1 */
static const struct regulator_ops lp87565_buck_ops = { static const struct regulator_ops lp87565_buck_ops = {
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
.enable = regulator_enable_regmap, .enable = regulator_enable_regmap,
...@@ -150,8 +117,8 @@ static const struct regulator_ops lp87565_buck_ops = { ...@@ -150,8 +117,8 @@ static const struct regulator_ops lp87565_buck_ops = {
.map_voltage = regulator_map_voltage_linear_range, .map_voltage = regulator_map_voltage_linear_range,
.set_voltage_time_sel = regulator_set_voltage_time_sel, .set_voltage_time_sel = regulator_set_voltage_time_sel,
.set_ramp_delay = lp87565_buck_set_ramp_delay, .set_ramp_delay = lp87565_buck_set_ramp_delay,
.set_current_limit = lp87565_buck_set_current_limit, .set_current_limit = regulator_set_current_limit_regmap,
.get_current_limit = lp87565_buck_get_current_limit, .get_current_limit = regulator_get_current_limit_regmap,
}; };
static const struct lp87565_regulator regulators[] = { static const struct lp87565_regulator regulators[] = {
...@@ -193,7 +160,7 @@ static int lp87565_regulator_probe(struct platform_device *pdev) ...@@ -193,7 +160,7 @@ static int lp87565_regulator_probe(struct platform_device *pdev)
struct lp87565 *lp87565 = dev_get_drvdata(pdev->dev.parent); struct lp87565 *lp87565 = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { }; struct regulator_config config = { };
struct regulator_dev *rdev; struct regulator_dev *rdev;
int i, min_idx = LP87565_BUCK_1, max_idx = LP87565_BUCK_3; int i, min_idx = LP87565_BUCK_0, max_idx = LP87565_BUCK_3;
platform_set_drvdata(pdev, lp87565); platform_set_drvdata(pdev, lp87565);
......
This diff is collapsed.
...@@ -285,17 +285,23 @@ static irqreturn_t ltc3676_isr(int irq, void *dev_id) ...@@ -285,17 +285,23 @@ static irqreturn_t ltc3676_isr(int irq, void *dev_id)
if (irqstat & LTC3676_IRQSTAT_THERMAL_WARN) { if (irqstat & LTC3676_IRQSTAT_THERMAL_WARN) {
dev_warn(dev, "Over-temperature Warning\n"); dev_warn(dev, "Over-temperature Warning\n");
event = REGULATOR_EVENT_OVER_TEMP; event = REGULATOR_EVENT_OVER_TEMP;
for (i = 0; i < LTC3676_NUM_REGULATORS; i++) for (i = 0; i < LTC3676_NUM_REGULATORS; i++) {
regulator_lock(ltc3676->regulators[i]);
regulator_notifier_call_chain(ltc3676->regulators[i], regulator_notifier_call_chain(ltc3676->regulators[i],
event, NULL); event, NULL);
regulator_unlock(ltc3676->regulators[i]);
}
} }
if (irqstat & LTC3676_IRQSTAT_UNDERVOLT_WARN) { if (irqstat & LTC3676_IRQSTAT_UNDERVOLT_WARN) {
dev_info(dev, "Undervoltage Warning\n"); dev_info(dev, "Undervoltage Warning\n");
event = REGULATOR_EVENT_UNDER_VOLTAGE; event = REGULATOR_EVENT_UNDER_VOLTAGE;
for (i = 0; i < LTC3676_NUM_REGULATORS; i++) for (i = 0; i < LTC3676_NUM_REGULATORS; i++) {
regulator_lock(ltc3676->regulators[i]);
regulator_notifier_call_chain(ltc3676->regulators[i], regulator_notifier_call_chain(ltc3676->regulators[i],
event, NULL); event, NULL);
regulator_unlock(ltc3676->regulators[i]);
}
} }
/* Clear warning condition */ /* Clear warning condition */
......
...@@ -155,58 +155,6 @@ static const struct regulator_desc max77836_supported_regulators[] = { ...@@ -155,58 +155,6 @@ static const struct regulator_desc max77836_supported_regulators[] = {
[MAX77836_LDO2] = MAX77836_LDO_REG(2), [MAX77836_LDO2] = MAX77836_LDO_REG(2),
}; };
#ifdef CONFIG_OF
static struct of_regulator_match max14577_regulator_matches[] = {
{ .name = "SAFEOUT", },
{ .name = "CHARGER", },
};
static struct of_regulator_match max77836_regulator_matches[] = {
{ .name = "SAFEOUT", },
{ .name = "CHARGER", },
{ .name = "LDO1", },
{ .name = "LDO2", },
};
static inline struct regulator_init_data *match_init_data(int index,
enum maxim_device_type dev_type)
{
switch (dev_type) {
case MAXIM_DEVICE_TYPE_MAX77836:
return max77836_regulator_matches[index].init_data;
case MAXIM_DEVICE_TYPE_MAX14577:
default:
return max14577_regulator_matches[index].init_data;
}
}
static inline struct device_node *match_of_node(int index,
enum maxim_device_type dev_type)
{
switch (dev_type) {
case MAXIM_DEVICE_TYPE_MAX77836:
return max77836_regulator_matches[index].of_node;
case MAXIM_DEVICE_TYPE_MAX14577:
default:
return max14577_regulator_matches[index].of_node;
}
}
#else /* CONFIG_OF */
static inline struct regulator_init_data *match_init_data(int index,
enum maxim_device_type dev_type)
{
return NULL;
}
static inline struct device_node *match_of_node(int index,
enum maxim_device_type dev_type)
{
return NULL;
}
#endif /* CONFIG_OF */
/** /**
* Registers for regulators of max77836 use different I2C slave addresses so * Registers for regulators of max77836 use different I2C slave addresses so
* different regmaps must be used for them. * different regmaps must be used for them.
...@@ -265,9 +213,6 @@ static int max14577_regulator_probe(struct platform_device *pdev) ...@@ -265,9 +213,6 @@ static int max14577_regulator_probe(struct platform_device *pdev)
if (pdata && pdata->regulators) { if (pdata && pdata->regulators) {
config.init_data = pdata->regulators[i].initdata; config.init_data = pdata->regulators[i].initdata;
config.of_node = pdata->regulators[i].of_node; config.of_node = pdata->regulators[i].of_node;
} else {
config.init_data = match_init_data(i, dev_type);
config.of_node = match_of_node(i, dev_type);
} }
config.regmap = max14577_get_regmap(max14577, config.regmap = max14577_get_regmap(max14577,
supported_regulators[i].id); supported_regulators[i].id);
......
...@@ -803,7 +803,7 @@ static int max77620_regulator_probe(struct platform_device *pdev) ...@@ -803,7 +803,7 @@ static int max77620_regulator_probe(struct platform_device *pdev)
continue; continue;
rdesc = &rinfo[id].desc; rdesc = &rinfo[id].desc;
pmic->rinfo[id] = &max77620_regs_info[id]; pmic->rinfo[id] = &rinfo[id];
pmic->enable_power_mode[id] = MAX77620_POWER_MODE_NORMAL; pmic->enable_power_mode[id] = MAX77620_POWER_MODE_NORMAL;
pmic->reg_pdata[id].active_fps_src = -1; pmic->reg_pdata[id].active_fps_src = -1;
pmic->reg_pdata[id].active_fps_pd_slot = -1; pmic->reg_pdata[id].active_fps_pd_slot = -1;
......
...@@ -41,7 +41,7 @@ struct max77650_regulator_desc { ...@@ -41,7 +41,7 @@ struct max77650_regulator_desc {
unsigned int regB; unsigned int regB;
}; };
static const u32 max77651_sbb1_regulator_volt_table[] = { static const unsigned int max77651_sbb1_regulator_volt_table[] = {
2400000, 3200000, 4000000, 4800000, 2400000, 3200000, 4000000, 4800000,
2450000, 3250000, 4050000, 4850000, 2450000, 3250000, 4050000, 4850000,
2500000, 3300000, 4100000, 4900000, 2500000, 3300000, 4100000, 4900000,
......
...@@ -159,6 +159,8 @@ static const struct regulator_ops max8925_regulator_ldo_ops = { ...@@ -159,6 +159,8 @@ static const struct regulator_ops max8925_regulator_ldo_ops = {
{ \ { \
.desc = { \ .desc = { \
.name = "SDV" #_id, \ .name = "SDV" #_id, \
.of_match = of_match_ptr("SDV" #_id), \
.regulators_node = of_match_ptr("regulators"), \
.ops = &max8925_regulator_sdv_ops, \ .ops = &max8925_regulator_sdv_ops, \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_SD##_id, \ .id = MAX8925_ID_SD##_id, \
...@@ -175,6 +177,8 @@ static const struct regulator_ops max8925_regulator_ldo_ops = { ...@@ -175,6 +177,8 @@ static const struct regulator_ops max8925_regulator_ldo_ops = {
{ \ { \
.desc = { \ .desc = { \
.name = "LDO" #_id, \ .name = "LDO" #_id, \
.of_match = of_match_ptr("LDO" #_id), \
.regulators_node = of_match_ptr("regulators"), \
.ops = &max8925_regulator_ldo_ops, \ .ops = &max8925_regulator_ldo_ops, \
.type = REGULATOR_VOLTAGE, \ .type = REGULATOR_VOLTAGE, \
.id = MAX8925_ID_LDO##_id, \ .id = MAX8925_ID_LDO##_id, \
...@@ -187,34 +191,6 @@ static const struct regulator_ops max8925_regulator_ldo_ops = { ...@@ -187,34 +191,6 @@ static const struct regulator_ops max8925_regulator_ldo_ops = {
.enable_reg = MAX8925_LDOCTL##_id, \ .enable_reg = MAX8925_LDOCTL##_id, \
} }
#ifdef CONFIG_OF
static struct of_regulator_match max8925_regulator_matches[] = {
{ .name = "SDV1",},
{ .name = "SDV2",},
{ .name = "SDV3",},
{ .name = "LDO1",},
{ .name = "LDO2",},
{ .name = "LDO3",},
{ .name = "LDO4",},
{ .name = "LDO5",},
{ .name = "LDO6",},
{ .name = "LDO7",},
{ .name = "LDO8",},
{ .name = "LDO9",},
{ .name = "LDO10",},
{ .name = "LDO11",},
{ .name = "LDO12",},
{ .name = "LDO13",},
{ .name = "LDO14",},
{ .name = "LDO15",},
{ .name = "LDO16",},
{ .name = "LDO17",},
{ .name = "LDO18",},
{ .name = "LDO19",},
{ .name = "LDO20",},
};
#endif
static struct max8925_regulator_info max8925_regulator_info[] = { static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_SDV(1, 637.5, 1425, 12.5), MAX8925_SDV(1, 637.5, 1425, 12.5),
MAX8925_SDV(2, 650, 2225, 25), MAX8925_SDV(2, 650, 2225, 25),
...@@ -242,37 +218,6 @@ static struct max8925_regulator_info max8925_regulator_info[] = { ...@@ -242,37 +218,6 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
MAX8925_LDO(20, 750, 3900, 50), MAX8925_LDO(20, 750, 3900, 50),
}; };
#ifdef CONFIG_OF
static int max8925_regulator_dt_init(struct platform_device *pdev,
struct regulator_config *config,
int ridx)
{
struct device_node *nproot, *np;
int rcount;
nproot = pdev->dev.parent->of_node;
if (!nproot)
return -ENODEV;
np = of_get_child_by_name(nproot, "regulators");
if (!np) {
dev_err(&pdev->dev, "failed to find regulators node\n");
return -ENODEV;
}
rcount = of_regulator_match(&pdev->dev, np,
&max8925_regulator_matches[ridx], 1);
of_node_put(np);
if (rcount < 0)
return rcount;
config->init_data = max8925_regulator_matches[ridx].init_data;
config->of_node = max8925_regulator_matches[ridx].of_node;
return 0;
}
#else
#define max8925_regulator_dt_init(x, y, z) (-1)
#endif
static int max8925_regulator_probe(struct platform_device *pdev) static int max8925_regulator_probe(struct platform_device *pdev)
{ {
struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent); struct max8925_chip *chip = dev_get_drvdata(pdev->dev.parent);
...@@ -281,7 +226,7 @@ static int max8925_regulator_probe(struct platform_device *pdev) ...@@ -281,7 +226,7 @@ static int max8925_regulator_probe(struct platform_device *pdev)
struct max8925_regulator_info *ri; struct max8925_regulator_info *ri;
struct resource *res; struct resource *res;
struct regulator_dev *rdev; struct regulator_dev *rdev;
int i, regulator_idx; int i;
res = platform_get_resource(pdev, IORESOURCE_REG, 0); res = platform_get_resource(pdev, IORESOURCE_REG, 0);
if (!res) { if (!res) {
...@@ -290,11 +235,9 @@ static int max8925_regulator_probe(struct platform_device *pdev) ...@@ -290,11 +235,9 @@ static int max8925_regulator_probe(struct platform_device *pdev)
} }
for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) { for (i = 0; i < ARRAY_SIZE(max8925_regulator_info); i++) {
ri = &max8925_regulator_info[i]; ri = &max8925_regulator_info[i];
if (ri->vol_reg == res->start) { if (ri->vol_reg == res->start)
regulator_idx = i;
break; break;
} }
}
if (i == ARRAY_SIZE(max8925_regulator_info)) { if (i == ARRAY_SIZE(max8925_regulator_info)) {
dev_err(&pdev->dev, "Failed to find regulator %llu\n", dev_err(&pdev->dev, "Failed to find regulator %llu\n",
...@@ -303,10 +246,9 @@ static int max8925_regulator_probe(struct platform_device *pdev) ...@@ -303,10 +246,9 @@ static int max8925_regulator_probe(struct platform_device *pdev)
} }
ri->i2c = chip->i2c; ri->i2c = chip->i2c;
config.dev = &pdev->dev; config.dev = chip->dev;
config.driver_data = ri; config.driver_data = ri;
if (max8925_regulator_dt_init(pdev, &config, regulator_idx))
if (pdata) if (pdata)
config.init_data = pdata; config.init_data = pdata;
......
This diff is collapsed.
...@@ -119,8 +119,6 @@ enum { ...@@ -119,8 +119,6 @@ enum {
* @lpm: LPM GPIO descriptor * @lpm: LPM GPIO descriptor
*/ */
struct mcp16502 { struct mcp16502 {
struct regulator_dev *rdev[NUM_REGULATORS];
struct regmap *rmap;
struct gpio_desc *lpm; struct gpio_desc *lpm;
}; };
...@@ -179,13 +177,12 @@ static unsigned int mcp16502_get_mode(struct regulator_dev *rdev) ...@@ -179,13 +177,12 @@ static unsigned int mcp16502_get_mode(struct regulator_dev *rdev)
{ {
unsigned int val; unsigned int val;
int ret, reg; int ret, reg;
struct mcp16502 *mcp = rdev_get_drvdata(rdev);
reg = mcp16502_get_reg(rdev, MCP16502_OPMODE_ACTIVE); reg = mcp16502_get_reg(rdev, MCP16502_OPMODE_ACTIVE);
if (reg < 0) if (reg < 0)
return reg; return reg;
ret = regmap_read(mcp->rmap, reg, &val); ret = regmap_read(rdev->regmap, reg, &val);
if (ret) if (ret)
return ret; return ret;
...@@ -211,7 +208,6 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode, ...@@ -211,7 +208,6 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode,
{ {
int val; int val;
int reg; int reg;
struct mcp16502 *mcp = rdev_get_drvdata(rdev);
reg = mcp16502_get_reg(rdev, op_mode); reg = mcp16502_get_reg(rdev, op_mode);
if (reg < 0) if (reg < 0)
...@@ -228,7 +224,7 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode, ...@@ -228,7 +224,7 @@ static int _mcp16502_set_mode(struct regulator_dev *rdev, unsigned int mode,
return -EINVAL; return -EINVAL;
} }
reg = regmap_update_bits(mcp->rmap, reg, MCP16502_MODE, val); reg = regmap_update_bits(rdev->regmap, reg, MCP16502_MODE, val);
return reg; return reg;
} }
...@@ -247,9 +243,8 @@ static int mcp16502_get_status(struct regulator_dev *rdev) ...@@ -247,9 +243,8 @@ static int mcp16502_get_status(struct regulator_dev *rdev)
{ {
int ret; int ret;
unsigned int val; unsigned int val;
struct mcp16502 *mcp = rdev_get_drvdata(rdev);
ret = regmap_read(mcp->rmap, MCP16502_STAT_BASE(rdev_get_id(rdev)), ret = regmap_read(rdev->regmap, MCP16502_STAT_BASE(rdev_get_id(rdev)),
&val); &val);
if (ret) if (ret)
return ret; return ret;
...@@ -290,7 +285,6 @@ static int mcp16502_suspend_get_target_reg(struct regulator_dev *rdev) ...@@ -290,7 +285,6 @@ static int mcp16502_suspend_get_target_reg(struct regulator_dev *rdev)
*/ */
static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV) static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV)
{ {
struct mcp16502 *mcp = rdev_get_drvdata(rdev);
int sel = regulator_map_voltage_linear_range(rdev, uV, uV); int sel = regulator_map_voltage_linear_range(rdev, uV, uV);
int reg = mcp16502_suspend_get_target_reg(rdev); int reg = mcp16502_suspend_get_target_reg(rdev);
...@@ -300,7 +294,7 @@ static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV) ...@@ -300,7 +294,7 @@ static int mcp16502_set_suspend_voltage(struct regulator_dev *rdev, int uV)
if (reg < 0) if (reg < 0)
return reg; return reg;
return regmap_update_bits(mcp->rmap, reg, MCP16502_VSEL, sel); return regmap_update_bits(rdev->regmap, reg, MCP16502_VSEL, sel);
} }
/* /*
...@@ -328,13 +322,12 @@ static int mcp16502_set_suspend_mode(struct regulator_dev *rdev, ...@@ -328,13 +322,12 @@ static int mcp16502_set_suspend_mode(struct regulator_dev *rdev,
*/ */
static int mcp16502_set_suspend_enable(struct regulator_dev *rdev) static int mcp16502_set_suspend_enable(struct regulator_dev *rdev)
{ {
struct mcp16502 *mcp = rdev_get_drvdata(rdev);
int reg = mcp16502_suspend_get_target_reg(rdev); int reg = mcp16502_suspend_get_target_reg(rdev);
if (reg < 0) if (reg < 0)
return reg; return reg;
return regmap_update_bits(mcp->rmap, reg, MCP16502_EN, MCP16502_EN); return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, MCP16502_EN);
} }
/* /*
...@@ -342,13 +335,12 @@ static int mcp16502_set_suspend_enable(struct regulator_dev *rdev) ...@@ -342,13 +335,12 @@ static int mcp16502_set_suspend_enable(struct regulator_dev *rdev)
*/ */
static int mcp16502_set_suspend_disable(struct regulator_dev *rdev) static int mcp16502_set_suspend_disable(struct regulator_dev *rdev)
{ {
struct mcp16502 *mcp = rdev_get_drvdata(rdev);
int reg = mcp16502_suspend_get_target_reg(rdev); int reg = mcp16502_suspend_get_target_reg(rdev);
if (reg < 0) if (reg < 0)
return reg; return reg;
return regmap_update_bits(mcp->rmap, reg, MCP16502_EN, 0); return regmap_update_bits(rdev->regmap, reg, MCP16502_EN, 0);
} }
#endif /* CONFIG_SUSPEND */ #endif /* CONFIG_SUSPEND */
...@@ -435,36 +427,15 @@ static const struct regmap_config mcp16502_regmap_config = { ...@@ -435,36 +427,15 @@ static const struct regmap_config mcp16502_regmap_config = {
.wr_table = &mcp16502_yes_reg_table, .wr_table = &mcp16502_yes_reg_table,
}; };
/*
* set_up_regulators() - initialize all regulators
*/
static int setup_regulators(struct mcp16502 *mcp, struct device *dev,
struct regulator_config config)
{
int i;
for (i = 0; i < NUM_REGULATORS; i++) {
mcp->rdev[i] = devm_regulator_register(dev,
&mcp16502_desc[i],
&config);
if (IS_ERR(mcp->rdev[i])) {
dev_err(dev,
"failed to register %s regulator %ld\n",
mcp16502_desc[i].name, PTR_ERR(mcp->rdev[i]));
return PTR_ERR(mcp->rdev[i]);
}
}
return 0;
}
static int mcp16502_probe(struct i2c_client *client, static int mcp16502_probe(struct i2c_client *client,
const struct i2c_device_id *id) const struct i2c_device_id *id)
{ {
struct regulator_config config = { }; struct regulator_config config = { };
struct regulator_dev *rdev;
struct device *dev; struct device *dev;
struct mcp16502 *mcp; struct mcp16502 *mcp;
int ret = 0; struct regmap *rmap;
int i, ret;
dev = &client->dev; dev = &client->dev;
config.dev = dev; config.dev = dev;
...@@ -473,15 +444,15 @@ static int mcp16502_probe(struct i2c_client *client, ...@@ -473,15 +444,15 @@ static int mcp16502_probe(struct i2c_client *client,
if (!mcp) if (!mcp)
return -ENOMEM; return -ENOMEM;
mcp->rmap = devm_regmap_init_i2c(client, &mcp16502_regmap_config); rmap = devm_regmap_init_i2c(client, &mcp16502_regmap_config);
if (IS_ERR(mcp->rmap)) { if (IS_ERR(rmap)) {
ret = PTR_ERR(mcp->rmap); ret = PTR_ERR(rmap);
dev_err(dev, "regmap init failed: %d\n", ret); dev_err(dev, "regmap init failed: %d\n", ret);
return ret; return ret;
} }
i2c_set_clientdata(client, mcp); i2c_set_clientdata(client, mcp);
config.regmap = mcp->rmap; config.regmap = rmap;
config.driver_data = mcp; config.driver_data = mcp;
mcp->lpm = devm_gpiod_get(dev, "lpm", GPIOD_OUT_LOW); mcp->lpm = devm_gpiod_get(dev, "lpm", GPIOD_OUT_LOW);
...@@ -490,9 +461,15 @@ static int mcp16502_probe(struct i2c_client *client, ...@@ -490,9 +461,15 @@ static int mcp16502_probe(struct i2c_client *client,
return PTR_ERR(mcp->lpm); return PTR_ERR(mcp->lpm);
} }
ret = setup_regulators(mcp, dev, config); for (i = 0; i < NUM_REGULATORS; i++) {
if (ret != 0) rdev = devm_regulator_register(dev, &mcp16502_desc[i], &config);
return ret; if (IS_ERR(rdev)) {
dev_err(dev,
"failed to register %s regulator %ld\n",
mcp16502_desc[i].name, PTR_ERR(rdev));
return PTR_ERR(rdev);
}
}
mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_ACTIVE); mcp16502_gpio_set_mode(mcp, MCP16502_OPMODE_ACTIVE);
......
/* // SPDX-License-Identifier: GPL-2.0
* Copyright (c) 2015 MediaTek Inc. //
* Author: Henry Chen <henryc.chen@mediatek.com> // Copyright (c) 2015 MediaTek Inc.
* // Author: Henry Chen <henryc.chen@mediatek.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.
*
* 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.
*/
#include <linux/err.h> #include <linux/err.h>
#include <linux/gpio.h> #include <linux/gpio.h>
......
/* SPDX-License-Identifier: GPL-2.0 */
/* /*
* Copyright (c) 2015 MediaTek Inc. * Copyright (c) 2015 MediaTek Inc.
* Author: Henry Chen <henryc.chen@mediatek.com> * Author: Henry Chen <henryc.chen@mediatek.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.
*
* 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.
*/ */
#ifndef __MT6311_REGULATOR_H__ #ifndef __MT6311_REGULATOR_H__
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment