Commit 81e29b7d authored by Linus Torvalds's avatar Linus Torvalds

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

Pull regulator updates from Mark Brown:
 "This time around most of the changes are a lot of new drivers along
  with the standard set of fixes and cleanups (thanks again largely to
  Axel Lin).  We do have one nice new feature in the core which factors
  out the disappointingly tricky code around DT parsing, only a couple
  of drivers have been converted so far:

   - Factor out the code for parsing the standard bindings for a set of
     regulators out of DT, making the probe part of a lot of drivers
     simplier.
   - New drivers for Dialog DA9213, HiSilicon HI6420, Intersil
     ISL9305/H, Ricoh RN5T618, Rockchip RK808, Skyworks SKY81452,
     Silergy SYR82x, and Qualcomm RPM"

* tag 'regulator-v3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (71 commits)
  regulator: da9211: Fix a bug in update of mask bit
  regulator: pwm-regulator: add devicetree bindings for pwm regulator
  regulator: pwm-regulator: get voltage and duty table from dts
  regulator: qcom_rpm: Fix FORCE_MODE_IS_2_BITS macro
  regulator: qcom_rpm: Don't explicitly initialise the first field of config
  regulator: ltc3589: fix broken voltage transitions
  regulator: qcom-rpm: Regulator driver for the Qualcomm RPM
  regulator: axp20x: Use parent device as regulator configuration device
  regulator: fan53555: Fix null pointer dereference
  regulator: fan53555: Fixup report wrong vendor message
  regulator: fan53555: fix wrong cast in probe
  regulator: fan53555: add support for Silergy SYR82x regulators
  regulator: fan53555: add devicetree support
  regulator: add devicetree bindings for Fairchild FAN53555 regulators
  regulator: rk808: Add function for ramp delay for buck1/buck2
  regulator: fan53555: use set_ramp_delay to set the ramp up slew rate
  regulator: fan53555: enable vin supply
  regulator: rk808: Fix missing of_node_put
  regulator: rk808: Remove unused variables
  regulator: of: Add stub OF match function for !OF case
  ...
parents c831dd73 ad21edcd
* Dialog Semiconductor DA9211/DA9213 Voltage Regulator
Required properties:
- compatible: "dlg,da9211" or "dlg,da9213".
- reg: I2C slave address, usually 0x68.
- interrupts: the interrupt outputs of the controller
- regulators: A node that houses a sub-node for each regulator within the
device. Each sub-node is identified using the node's name, with valid
values listed below. The content of each sub-node is defined by the
standard binding for regulators; see regulator.txt.
BUCKA and BUCKB.
Optional properties:
- Any optional property defined in regulator.txt
Example 1) DA9211
pmic: da9211@68 {
compatible = "dlg,da9211";
reg = <0x68>;
interrupts = <3 27>;
regulators {
BUCKA {
regulator-name = "VBUCKA";
regulator-min-microvolt = < 300000>;
regulator-max-microvolt = <1570000>;
regulator-min-microamp = <2000000>;
regulator-max-microamp = <5000000>;
};
BUCKB {
regulator-name = "VBUCKB";
regulator-min-microvolt = < 300000>;
regulator-max-microvolt = <1570000>;
regulator-min-microamp = <2000000>;
regulator-max-microamp = <5000000>;
};
};
};
Example 2) DA92113
pmic: da9213@68 {
compatible = "dlg,da9213";
reg = <0x68>;
interrupts = <3 27>;
regulators {
BUCKA {
regulator-name = "VBUCKA";
regulator-min-microvolt = < 300000>;
regulator-max-microvolt = <1570000>;
regulator-min-microamp = <3000000>;
regulator-max-microamp = <6000000>;
};
BUCKB {
regulator-name = "VBUCKB";
regulator-min-microvolt = < 300000>;
regulator-max-microvolt = <1570000>;
regulator-min-microamp = <3000000>;
regulator-max-microamp = <6000000>;
};
};
};
Binding for Fairchild FAN53555 regulators
Required properties:
- compatible: one of "fcs,fan53555", "silergy,syr827", "silergy,syr828"
- reg: I2C address
Optional properties:
- fcs,suspend-voltage-selector: declare which of the two available
voltage selector registers should be used for the suspend
voltage. The other one is used for the runtime voltage setting
Possible values are either <0> or <1>
- vin-supply: regulator supplying the vin pin
Example:
regulator@40 {
compatible = "fcs,fan53555";
regulator-name = "fan53555";
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <1800000>;
vin-supply = <&parent_reg>;
fcs,suspend-voltage-selector = <1>;
};
Intersil ISL9305/ISL9305H voltage regulator
Required properties:
- compatible: "isl,isl9305" or "isl,isl9305h"
- reg: I2C slave address, usually 0x68.
- regulators: A node that houses a sub-node for each regulator within the
device. Each sub-node is identified using the node's name, with valid
values being "dcd1", "dcd2", "ldo1" and "ldo2". The content of each sub-node
is defined by the standard binding for regulators; see regulator.txt.
- VINDCD1-supply: A phandle to a regulator node supplying VINDCD1.
VINDCD2-supply: A phandle to a regulator node supplying VINDCD2.
VINLDO1-supply: A phandle to a regulator node supplying VINLDO1.
VINLDO2-supply: A phandle to a regulator node supplying VINLDO2.
Optional properties:
- Per-regulator optional properties are defined in regulator.txt
Example
pmic: isl9305@68 {
compatible = "isl,isl9305";
reg = <0x68>;
VINDCD1-supply = <&system_power>;
VINDCD2-supply = <&system_power>;
VINLDO1-supply = <&system_power>;
VINLDO2-supply = <&system_power>;
regulators {
dcd1 {
regulator-name = "VDD_DSP";
regulator-always-on;
};
};
};
Maxim MAX1586 voltage regulator
Required properties:
- compatible: must be "maxim,max1586"
- reg: I2C slave address, usually 0x14
- v3-gain: integer specifying the V3 gain as per datasheet
(1 + R24/R25 + R24/185.5kOhm)
- any required generic properties defined in regulator.txt
Example:
i2c_master {
max1586@14 {
compatible = "maxim,max1586";
reg = <0x14>;
v3-gain = <1000000>;
regulators {
vcc_core: v3 {
regulator-name = "vcc_core";
regulator-compatible = "Output_V3";
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <1705000>;
regulator-always-on;
};
};
};
};
Binding for Maxim MAX77802 regulators
This is a part of device tree bindings of MAX77802 multi-function device.
More information can be found in bindings/mfd/max77802.txt file.
The MAX77802 PMIC has 10 high-efficiency Buck and 32 Low-dropout (LDO)
regulators that can be controlled over I2C.
Following properties should be present in main device node of the MFD chip.
Optional node:
- regulators : The regulators of max77802 have to be instantiated
under subnode named "regulators" using the following format.
regulator-name {
standard regulator constraints....
};
refer Documentation/devicetree/bindings/regulator/regulator.txt
The regulator node name should be initialized with a string to get matched
with their hardware counterparts as follow. The valid names are:
-LDOn : for LDOs, where n can lie in ranges 1-15, 17-21, 23-30
and 32-35.
example: LDO1, LDO2, LDO35.
-BUCKn : for BUCKs, where n can lie in range 1 to 10.
example: BUCK1, BUCK5, BUCK10.
Example:
max77802@09 {
compatible = "maxim,max77802";
interrupt-parent = <&wakeup_eint>;
interrupts = <26 0>;
reg = <0x09>;
#address-cells = <1>;
#size-cells = <0>;
regulators {
ldo11_reg: LDO11 {
regulator-name = "vdd_ldo11";
regulator-min-microvolt = <1900000>;
regulator-max-microvolt = <1900000>;
regulator-always-on;
};
buck1_reg: BUCK1 {
regulator-name = "vdd_mif";
regulator-min-microvolt = <950000>;
regulator-max-microvolt = <1300000>;
regulator-always-on;
regulator-boot-on;
};
};
pwm regulator bindings
Required properties:
- compatible: Should be "pwm-regulator"
- pwms: OF device-tree PWM specification (see PWM binding pwm.txt)
- voltage-table: voltage and duty table, include 2 members in each set of
brackets, first one is voltage(unit: uv), the next is duty(unit: percent)
Any property defined as part of the core regulator binding defined in
regulator.txt can also be used.
Example:
pwm_regulator {
compatible = "pwm-regulator;
pwms = <&pwm1 0 8448 0>;
voltage-table = <1114000 0>,
<1095000 10>,
<1076000 20>,
<1056000 30>,
<1036000 40>,
<1016000 50>;
regulator-min-microvolt = <1016000>;
regulator-max-microvolt = <1114000>;
regulator-name = "vdd_logic";
};
SKY81452 voltage regulator
Required properties:
- any required generic properties defined in regulator.txt
Optional properties:
- any available generic properties defined in regulator.txt
Example:
regulator {
/* generic regulator properties */
regulator-name = "touch_en";
regulator-min-microvolt = <4500000>;
regulator-max-microvolt = <8000000>;
};
......@@ -49,6 +49,7 @@ epson Seiko Epson Corp.
est ESTeem Wireless Modems
eukrea Eukréa Electromatique
excito Excito
fcs Fairchild Semiconductor
fsl Freescale Semiconductor
GEFanuc GE Fanuc Intelligent Platforms Embedded Systems, Inc.
gef GE Fanuc Intelligent Platforms Embedded Systems, Inc.
......@@ -124,6 +125,7 @@ sil Silicon Image
silabs Silicon Laboratories
simtek
sii Seiko Instruments, Inc.
silergy Silergy Corp.
sirf SiRF Technology, Inc.
smsc Standard Microsystems Corporation
snps Synopsys, Inc.
......
......@@ -9895,6 +9895,7 @@ F: drivers/scsi/vmw_pvscsi.h
VOLTAGE AND CURRENT REGULATOR FRAMEWORK
M: Liam Girdwood <lgirdwood@gmail.com>
M: Mark Brown <broonie@kernel.org>
L: linux-kernel@vger.kernel.org
W: http://opensource.wolfsonmicro.com/node/15
W: http://www.slimlogic.co.uk/?p=48
T: git git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git
......
......@@ -199,13 +199,14 @@ config REGULATOR_DA9210
interface.
config REGULATOR_DA9211
tristate "Dialog Semiconductor DA9211/DA9212 regulator"
tristate "Dialog Semiconductor DA9211/DA9212/DA9213/DA9214 regulator"
depends on I2C
select REGMAP_I2C
help
Say y here to support for the Dialog Semiconductor DA9211/DA9212.
The DA9211/DA9212 is a multi-phase synchronous step down
converter 12A DC-DC Buck controlled through an I2C
Say y here to support for the Dialog Semiconductor DA9211/DA9212
/DA9213/DA9214.
The DA9211/DA9212/DA9213/DA9214 is a multi-phase synchronous
step down converter 12A or 16A DC-DC Buck controlled through an I2C
interface.
config REGULATOR_DBX500_PRCMU
......@@ -240,6 +241,23 @@ config REGULATOR_GPIO
and the platform has to provide a mapping of GPIO-states
to target volts/amps.
config REGULATOR_HI6421
tristate "HiSilicon Hi6421 PMIC voltage regulator support"
depends on MFD_HI6421_PMIC && OF
help
This driver provides support for the voltage regulators on the
HiSilicon Hi6421 PMU / Codec IC.
Hi6421 is a multi-function device which, on regulator part, provides
21 general purpose LDOs, 3 dedicated LDOs, and 5 BUCKs. All
of them come with support to either ECO (idle) or sleep mode.
config REGULATOR_ISL9305
tristate "Intersil ISL9305 regulator"
depends on I2C
select REGMAP_I2C
help
This driver supports ISL9305 voltage regulator chip.
config REGULATOR_ISL6271A
tristate "Intersil ISL6271A Power regulator"
depends on I2C
......@@ -387,6 +405,15 @@ config REGULATOR_MAX77693
and one current regulator 'CHARGER'. This is suitable for
Exynos-4x12 chips.
config REGULATOR_MAX77802
tristate "Maxim 77802 regulator"
depends on MFD_MAX77686
help
This driver controls a Maxim 77802 regulator
via I2C bus. The provided regulator is suitable for
Exynos5420/Exynos5800 SoCs to control various voltages.
It includes support for control of voltage and ramp speed.
config REGULATOR_MC13XXX_CORE
tristate
......@@ -449,6 +476,25 @@ config REGULATOR_PFUZE100
Say y here to support the regulators found on the Freescale
PFUZE100/PFUZE200 PMIC.
config REGULATOR_PWM
tristate "PWM voltage regulator"
depends on PWM
help
This driver supports PWM controlled voltage regulators. PWM
duty cycle can increase or decrease the voltage.
config REGULATOR_QCOM_RPM
tristate "Qualcomm RPM regulator driver"
depends on MFD_QCOM_RPM
help
If you say yes to this option, support will be included for the
regulators exposed by the Resource Power Manager found in Qualcomm
8660, 8960 and 8064 based devices.
Say M here if you want to include support for the regulators on the
Qualcomm RPM as a module. The module will be named
"qcom_rpm-regulator".
config REGULATOR_RC5T583
tristate "RICOH RC5T583 Power regulators"
depends on MFD_RC5T583
......@@ -459,6 +505,22 @@ config REGULATOR_RC5T583
through regulator interface. The device supports multiple DCDC/LDO
outputs which can be controlled by i2c communication.
config REGULATOR_RK808
tristate "Rockchip RK808 Power regulators"
depends on MFD_RK808
help
Select this option to enable the power regulator of ROCKCHIP
PMIC RK808.
This driver supports the control of different power rails of device
through regulator interface. The device supports multiple DCDC/LDO
outputs which can be controlled by i2c communication.
config REGULATOR_RN5T618
tristate "Ricoh RN5T618 voltage regulators"
depends on MFD_RN5T618
help
Say y here to support the regulators found on Ricoh RN5T618 PMIC.
config REGULATOR_S2MPA01
tristate "Samsung S2MPA01 voltage regulator"
depends on MFD_SEC_CORE
......@@ -483,11 +545,16 @@ config REGULATOR_S5M8767
via I2C bus. S5M8767A have 9 Bucks and 28 LDOs output and
supports DVS mode with 8bits of output voltage control.
config REGULATOR_ST_PWM
tristate "STMicroelectronics PWM voltage regulator"
depends on ARCH_STI
config REGULATOR_SKY81452
tristate "Skyworks Solutions SKY81452 voltage regulator"
depends on SKY81452
help
This driver supports ST's PWM controlled voltage regulators.
This driver supports Skyworks SKY81452 voltage output regulator
via I2C bus. SKY81452 has one voltage linear regulator can be
programmed from 4.5V to 20V.
This driver can also be built as a module. If so, the module
will be called sky81452-regulator.
config REGULATOR_TI_ABB
tristate "TI Adaptive Body Bias on-chip LDO"
......
......@@ -32,7 +32,9 @@ obj-$(CONFIG_REGULATOR_DBX500_PRCMU) += dbx500-prcmu.o
obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o
obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
obj-$(CONFIG_REGULATOR_HI6421) += hi6421-regulator.o
obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
obj-$(CONFIG_REGULATOR_ISL9305) += isl9305.o
obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o
obj-$(CONFIG_REGULATOR_LP872X) += lp872x.o
......@@ -52,20 +54,25 @@ obj-$(CONFIG_REGULATOR_MAX8997) += max8997.o
obj-$(CONFIG_REGULATOR_MAX8998) += max8998.o
obj-$(CONFIG_REGULATOR_MAX77686) += max77686.o
obj-$(CONFIG_REGULATOR_MAX77693) += max77693.o
obj-$(CONFIG_REGULATOR_MAX77802) += max77802.o
obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o
obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o
obj-$(CONFIG_REGULATOR_PALMAS) += palmas-regulator.o
obj-$(CONFIG_REGULATOR_PFUZE100) += pfuze100-regulator.o
obj-$(CONFIG_REGULATOR_PWM) += pwm-regulator.o
obj-$(CONFIG_REGULATOR_TPS51632) += tps51632-regulator.o
obj-$(CONFIG_REGULATOR_PBIAS) += pbias-regulator.o
obj-$(CONFIG_REGULATOR_PCAP) += pcap-regulator.o
obj-$(CONFIG_REGULATOR_PCF50633) += pcf50633-regulator.o
obj-$(CONFIG_REGULATOR_RC5T583) += rc5t583-regulator.o
obj-$(CONFIG_REGULATOR_RK808) += rk808-regulator.o
obj-$(CONFIG_REGULATOR_RN5T618) += rn5t618-regulator.o
obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
obj-$(CONFIG_REGULATOR_ST_PWM) += st-pwm.o
obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
......
......@@ -22,12 +22,10 @@
struct as3711_regulator_info {
struct regulator_desc desc;
unsigned int max_uV;
};
struct as3711_regulator {
struct as3711_regulator_info *reg_info;
struct regulator_dev *rdev;
};
/*
......@@ -132,39 +130,37 @@ static const struct regulator_linear_range as3711_dldo_ranges[] = {
REGULATOR_LINEAR_RANGE(1750000, 0x20, 0x3f, 50000),
};
#define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _vshift, _min_uV, _max_uV, _sfx) \
[AS3711_REGULATOR_ ## _id] = { \
.desc = { \
.name = "as3711-regulator-" # _id, \
.id = AS3711_REGULATOR_ ## _id, \
.n_voltages = (_vmask + 1), \
.ops = &as3711_ ## _sfx ## _ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.vsel_reg = AS3711_ ## _id ## _VOLTAGE, \
.vsel_mask = _vmask << _vshift, \
.enable_reg = AS3711_ ## _en_reg, \
.enable_mask = BIT(_en_bit), \
.min_uV = _min_uV, \
.linear_ranges = as3711_ ## _sfx ## _ranges, \
.n_linear_ranges = ARRAY_SIZE(as3711_ ## _sfx ## _ranges), \
}, \
.max_uV = _max_uV, \
#define AS3711_REG(_id, _en_reg, _en_bit, _vmask, _sfx) \
[AS3711_REGULATOR_ ## _id] = { \
.desc = { \
.name = "as3711-regulator-" # _id, \
.id = AS3711_REGULATOR_ ## _id, \
.n_voltages = (_vmask + 1), \
.ops = &as3711_ ## _sfx ## _ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.vsel_reg = AS3711_ ## _id ## _VOLTAGE, \
.vsel_mask = _vmask, \
.enable_reg = AS3711_ ## _en_reg, \
.enable_mask = BIT(_en_bit), \
.linear_ranges = as3711_ ## _sfx ## _ranges, \
.n_linear_ranges = ARRAY_SIZE(as3711_ ## _sfx ## _ranges), \
}, \
}
static struct as3711_regulator_info as3711_reg_info[] = {
AS3711_REG(SD_1, SD_CONTROL, 0, 0x7f, 0, 612500, 3350000, sd),
AS3711_REG(SD_2, SD_CONTROL, 1, 0x7f, 0, 612500, 3350000, sd),
AS3711_REG(SD_3, SD_CONTROL, 2, 0x7f, 0, 612500, 3350000, sd),
AS3711_REG(SD_4, SD_CONTROL, 3, 0x7f, 0, 612500, 3350000, sd),
AS3711_REG(LDO_1, LDO_1_VOLTAGE, 7, 0x1f, 0, 1200000, 3300000, aldo),
AS3711_REG(LDO_2, LDO_2_VOLTAGE, 7, 0x1f, 0, 1200000, 3300000, aldo),
AS3711_REG(LDO_3, LDO_3_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
AS3711_REG(LDO_4, LDO_4_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
AS3711_REG(LDO_5, LDO_5_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
AS3711_REG(LDO_6, LDO_6_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
AS3711_REG(LDO_7, LDO_7_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
AS3711_REG(LDO_8, LDO_8_VOLTAGE, 7, 0x3f, 0, 900000, 3300000, dldo),
AS3711_REG(SD_1, SD_CONTROL, 0, 0x7f, sd),
AS3711_REG(SD_2, SD_CONTROL, 1, 0x7f, sd),
AS3711_REG(SD_3, SD_CONTROL, 2, 0x7f, sd),
AS3711_REG(SD_4, SD_CONTROL, 3, 0x7f, sd),
AS3711_REG(LDO_1, LDO_1_VOLTAGE, 7, 0x1f, aldo),
AS3711_REG(LDO_2, LDO_2_VOLTAGE, 7, 0x1f, aldo),
AS3711_REG(LDO_3, LDO_3_VOLTAGE, 7, 0x3f, dldo),
AS3711_REG(LDO_4, LDO_4_VOLTAGE, 7, 0x3f, dldo),
AS3711_REG(LDO_5, LDO_5_VOLTAGE, 7, 0x3f, dldo),
AS3711_REG(LDO_6, LDO_6_VOLTAGE, 7, 0x3f, dldo),
AS3711_REG(LDO_7, LDO_7_VOLTAGE, 7, 0x3f, dldo),
AS3711_REG(LDO_8, LDO_8_VOLTAGE, 7, 0x3f, dldo),
/* StepUp output voltage depends on supplying regulator */
};
......@@ -263,7 +259,6 @@ static int as3711_regulator_probe(struct platform_device *pdev)
ri->desc.name);
return PTR_ERR(rdev);
}
reg->rdev = rdev;
}
platform_set_drvdata(pdev, regs);
return 0;
......
......@@ -245,7 +245,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
for (i = 0; i < AXP20X_REG_ID_MAX; i++) {
init_data = axp20x_matches[i].init_data;
config.dev = &pdev->dev;
config.dev = pdev->dev.parent;
config.init_data = init_data;
config.regmap = axp20x->regmap;
config.of_node = axp20x_matches[i].of_node;
......
......@@ -202,7 +202,6 @@ static struct bcm590xx_info bcm590xx_regs[] = {
struct bcm590xx_reg {
struct regulator_desc *desc;
struct bcm590xx *mfd;
struct bcm590xx_info **info;
};
static int bcm590xx_get_vsel_register(int id)
......@@ -389,11 +388,6 @@ static int bcm590xx_probe(struct platform_device *pdev)
if (!pmu->desc)
return -ENOMEM;
pmu->info = devm_kzalloc(&pdev->dev, BCM590XX_NUM_REGS *
sizeof(struct bcm590xx_info *), GFP_KERNEL);
if (!pmu->info)
return -ENOMEM;
info = bcm590xx_regs;
for (i = 0; i < BCM590XX_NUM_REGS; i++, info++) {
......@@ -403,8 +397,6 @@ static int bcm590xx_probe(struct platform_device *pdev)
reg_data = NULL;
/* Register the regulators */
pmu->info[i] = info;
pmu->desc[i].name = info->name;
pmu->desc[i].supply_name = info->vin_name;
pmu->desc[i].id = i;
......
This diff is collapsed.
/*
* da9211-regulator.c - Regulator device driver for DA9211
* da9211-regulator.c - Regulator device driver for DA9211/DA9213
* Copyright (C) 2014 Dialog Semiconductor Ltd.
*
* This library is free software; you can redistribute it and/or
......@@ -24,9 +24,14 @@
#include <linux/regmap.h>
#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/regulator/of_regulator.h>
#include <linux/regulator/da9211.h>
#include "da9211-regulator.h"
/* DEVICE IDs */
#define DA9211_DEVICE_ID 0x22
#define DA9213_DEVICE_ID 0x23
#define DA9211_BUCK_MODE_SLEEP 1
#define DA9211_BUCK_MODE_SYNC 2
#define DA9211_BUCK_MODE_AUTO 3
......@@ -42,6 +47,7 @@ struct da9211 {
struct regulator_dev *rdev[DA9211_MAX_REGULATORS];
int num_regulator;
int chip_irq;
int chip_id;
};
static const struct regmap_range_cfg da9211_regmap_range[] = {
......@@ -52,14 +58,14 @@ static const struct regmap_range_cfg da9211_regmap_range[] = {
.window_start = 0,
.window_len = 256,
.range_min = 0,
.range_max = 2*256,
.range_max = 5*128,
},
};
static const struct regmap_config da9211_regmap_config = {
.reg_bits = 8,
.val_bits = 8,
.max_register = 2 * 256,
.max_register = 5 * 128,
.ranges = da9211_regmap_range,
.num_ranges = ARRAY_SIZE(da9211_regmap_range),
};
......@@ -69,11 +75,20 @@ static const struct regmap_config da9211_regmap_config = {
#define DA9211_MAX_MV 1570
#define DA9211_STEP_MV 10
/* Current limits for buck (uA) indices corresponds with register values */
/* Current limits for DA9211 buck (uA) indices
* corresponds with register values
*/
static const int da9211_current_limits[] = {
2000000, 2200000, 2400000, 2600000, 2800000, 3000000, 3200000, 3400000,
3600000, 3800000, 4000000, 4200000, 4400000, 4600000, 4800000, 5000000
};
/* Current limits for DA9213 buck (uA) indices
* corresponds with register values
*/
static const int da9213_current_limits[] = {
3000000, 3200000, 3400000, 3600000, 3800000, 4000000, 4200000, 4400000,
4600000, 4800000, 5000000, 5200000, 5400000, 5600000, 5800000, 6000000
};
static unsigned int da9211_buck_get_mode(struct regulator_dev *rdev)
{
......@@ -129,12 +144,26 @@ static int da9211_set_current_limit(struct regulator_dev *rdev, int min,
{
int id = rdev_get_id(rdev);
struct da9211 *chip = rdev_get_drvdata(rdev);
int i;
int i, max_size;
const int *current_limits;
switch (chip->chip_id) {
case DA9211:
current_limits = da9211_current_limits;
max_size = ARRAY_SIZE(da9211_current_limits)-1;
break;
case DA9213:
current_limits = da9213_current_limits;
max_size = ARRAY_SIZE(da9213_current_limits)-1;
break;
default:
return -EINVAL;
}
/* search for closest to maximum */
for (i = ARRAY_SIZE(da9211_current_limits)-1; i >= 0; i--) {
if (min <= da9211_current_limits[i] &&
max >= da9211_current_limits[i]) {
for (i = max_size; i >= 0; i--) {
if (min <= current_limits[i] &&
max >= current_limits[i]) {
return regmap_update_bits(chip->regmap,
DA9211_REG_BUCK_ILIM,
(0x0F << id*4), (i << id*4));
......@@ -150,14 +179,28 @@ static int da9211_get_current_limit(struct regulator_dev *rdev)
struct da9211 *chip = rdev_get_drvdata(rdev);
unsigned int data;
int ret;
const int *current_limits;
switch (chip->chip_id) {
case DA9211:
current_limits = da9211_current_limits;
break;
case DA9213:
current_limits = da9213_current_limits;
break;
default:
return -EINVAL;
}
ret = regmap_read(chip->regmap, DA9211_REG_BUCK_ILIM, &data);
if (ret < 0)
return ret;
/* select one of 16 values: 0000 (2000mA) to 1111 (5000mA) */
/* select one of 16 values: 0000 (2000mA or 3000mA)
* to 1111 (5000mA or 6000mA).
*/
data = (data >> id*4) & 0x0F;
return da9211_current_limits[data];
return current_limits[data];
}
static struct regulator_ops da9211_buck_ops = {
......@@ -194,6 +237,59 @@ static struct regulator_desc da9211_regulators[] = {
DA9211_BUCK(BUCKB),
};
#ifdef CONFIG_OF
static struct of_regulator_match da9211_matches[] = {
[DA9211_ID_BUCKA] = { .name = "BUCKA" },
[DA9211_ID_BUCKB] = { .name = "BUCKB" },
};
static struct da9211_pdata *da9211_parse_regulators_dt(
struct device *dev)
{
struct da9211_pdata *pdata;
struct device_node *node;
int i, num, n;
node = of_get_child_by_name(dev->of_node, "regulators");
if (!node) {
dev_err(dev, "regulators node not found\n");
return ERR_PTR(-ENODEV);
}
num = of_regulator_match(dev, node, da9211_matches,
ARRAY_SIZE(da9211_matches));
of_node_put(node);
if (num < 0) {
dev_err(dev, "Failed to match regulators\n");
return ERR_PTR(-EINVAL);
}
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return ERR_PTR(-ENOMEM);
pdata->num_buck = num;
n = 0;
for (i = 0; i < ARRAY_SIZE(da9211_matches); i++) {
if (!da9211_matches[i].init_data)
continue;
pdata->init_data[n] = da9211_matches[i].init_data;
n++;
}
return pdata;
}
#else
static struct da9211_pdata *da9211_parse_regulators_dt(
struct device *dev)
{
return ERR_PTR(-ENODEV);
}
#endif
static irqreturn_t da9211_irq_handler(int irq, void *data)
{
struct da9211 *chip = data;
......@@ -264,13 +360,11 @@ static int da9211_regulator_init(struct da9211 *chip)
}
for (i = 0; i < chip->num_regulator; i++) {
if (chip->pdata)
config.init_data =
&(chip->pdata->init_data[i]);
config.init_data = chip->pdata->init_data[i];
config.dev = chip->dev;
config.driver_data = chip;
config.regmap = chip->regmap;
config.of_node = chip->dev->of_node;
chip->rdev[i] = devm_regulator_register(chip->dev,
&da9211_regulators[i], &config);
......@@ -282,7 +376,7 @@ static int da9211_regulator_init(struct da9211 *chip)
if (chip->chip_irq != 0) {
ret = regmap_update_bits(chip->regmap,
DA9211_REG_MASK_B, DA9211_M_OV_CURR_A << i, 1);
DA9211_REG_MASK_B, DA9211_M_OV_CURR_A << i, 0);
if (ret < 0) {
dev_err(chip->dev,
"Failed to update mask reg: %d\n", ret);
......@@ -293,6 +387,7 @@ static int da9211_regulator_init(struct da9211 *chip)
return 0;
}
/*
* I2C driver interface functions
*/
......@@ -301,14 +396,17 @@ static int da9211_i2c_probe(struct i2c_client *i2c,
{
struct da9211 *chip;
int error, ret;
unsigned int data;
chip = devm_kzalloc(&i2c->dev, sizeof(struct da9211), GFP_KERNEL);
if (!chip)
return -ENOMEM;
chip->dev = &i2c->dev;
chip->regmap = devm_regmap_init_i2c(i2c, &da9211_regmap_config);
if (IS_ERR(chip->regmap)) {
error = PTR_ERR(chip->regmap);
dev_err(&i2c->dev, "Failed to allocate register map: %d\n",
dev_err(chip->dev, "Failed to allocate register map: %d\n",
error);
return error;
}
......@@ -316,11 +414,33 @@ static int da9211_i2c_probe(struct i2c_client *i2c,
i2c_set_clientdata(i2c, chip);
chip->pdata = i2c->dev.platform_data;
if (!chip->pdata) {
dev_err(&i2c->dev, "No platform init data supplied\n");
ret = regmap_read(chip->regmap, DA9211_REG_DEVICE_ID, &data);
if (ret < 0) {
dev_err(chip->dev, "Failed to read DEVICE_ID reg: %d\n", ret);
return ret;
}
switch (data) {
case DA9211_DEVICE_ID:
chip->chip_id = DA9211;
break;
case DA9213_DEVICE_ID:
chip->chip_id = DA9213;
break;
default:
dev_err(chip->dev, "Unsupported device id = 0x%x.\n", data);
return -ENODEV;
}
if (!chip->pdata)
chip->pdata = da9211_parse_regulators_dt(chip->dev);
if (IS_ERR(chip->pdata)) {
dev_err(chip->dev, "No regulators defined for the platform\n");
return PTR_ERR(chip->pdata);
}
chip->chip_irq = i2c->irq;
if (chip->chip_irq != 0) {
......@@ -340,22 +460,32 @@ static int da9211_i2c_probe(struct i2c_client *i2c,
ret = da9211_regulator_init(chip);
if (ret < 0)
dev_err(&i2c->dev, "Failed to initialize regulator: %d\n", ret);
dev_err(chip->dev, "Failed to initialize regulator: %d\n", ret);
return ret;
}
static const struct i2c_device_id da9211_i2c_id[] = {
{"da9211", 0},
{"da9211", DA9211},
{"da9213", DA9213},
{},
};
MODULE_DEVICE_TABLE(i2c, da9211_i2c_id);
#ifdef CONFIG_OF
static const struct of_device_id da9211_dt_ids[] = {
{ .compatible = "dlg,da9211", .data = &da9211_i2c_id[0] },
{ .compatible = "dlg,da9213", .data = &da9211_i2c_id[1] },
{},
};
MODULE_DEVICE_TABLE(of, da9211_dt_ids);
#endif
static struct i2c_driver da9211_regulator_driver = {
.driver = {
.name = "da9211",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(da9211_dt_ids),
},
.probe = da9211_i2c_probe,
.id_table = da9211_i2c_id,
......@@ -364,5 +494,5 @@ static struct i2c_driver da9211_regulator_driver = {
module_i2c_driver(da9211_regulator_driver);
MODULE_AUTHOR("James Ban <James.Ban.opensource@diasemi.com>");
MODULE_DESCRIPTION("Regulator device driver for Dialog DA9211");
MODULE_DESCRIPTION("Regulator device driver for Dialog DA9211/DA9213");
MODULE_LICENSE("GPL v2");
/*
* da9211-regulator.h - Regulator definitions for DA9211
* da9211-regulator.h - Regulator definitions for DA9211/DA9213
* Copyright (C) 2014 Dialog Semiconductor Ltd.
*
* This library is free software; you can redistribute it and/or
......@@ -53,12 +53,15 @@
/* BUCK Phase Selection*/
#define DA9211_REG_CONFIG_E 0x147
/* Device ID */
#define DA9211_REG_DEVICE_ID 0x201
/*
* Registers bits
*/
/* DA9211_REG_PAGE_CON (addr=0x00) */
#define DA9211_REG_PAGE_SHIFT 1
#define DA9211_REG_PAGE_MASK 0x02
#define DA9211_REG_PAGE_MASK 0x06
/* On I2C registers 0x00 - 0xFF */
#define DA9211_REG_PAGE0 0
/* On I2C registers 0x100 - 0x1FF */
......
......@@ -18,6 +18,8 @@
#include <linux/platform_device.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/of_regulator.h>
#include <linux/of_device.h>
#include <linux/i2c.h>
#include <linux/slab.h>
#include <linux/regmap.h>
......@@ -50,6 +52,11 @@
#define FAN53555_NVOLTAGES 64 /* Numbers of voltages */
enum fan53555_vendor {
FAN53555_VENDOR_FAIRCHILD = 0,
FAN53555_VENDOR_SILERGY,
};
/* IC Type */
enum {
FAN53555_CHIP_ID_00 = 0,
......@@ -60,7 +67,12 @@ enum {
FAN53555_CHIP_ID_05,
};
enum {
SILERGY_SYR82X = 8,
};
struct fan53555_device_info {
enum fan53555_vendor vendor;
struct regmap *regmap;
struct device *dev;
struct regulator_desc desc;
......@@ -135,6 +147,38 @@ static unsigned int fan53555_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL;
}
static int slew_rates[] = {
64000,
32000,
16000,
8000,
4000,
2000,
1000,
500,
};
static int fan53555_set_ramp(struct regulator_dev *rdev, int ramp)
{
struct fan53555_device_info *di = rdev_get_drvdata(rdev);
int regval = -1, i;
for (i = 0; i < ARRAY_SIZE(slew_rates); i++) {
if (ramp <= slew_rates[i])
regval = i;
else
break;
}
if (regval < 0) {
dev_err(di->dev, "unsupported ramp value %d\n", ramp);
return -EINVAL;
}
return regmap_update_bits(di->regmap, FAN53555_CONTROL,
CTL_SLEW_MASK, regval << CTL_SLEW_SHIFT);
}
static struct regulator_ops fan53555_regulator_ops = {
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
......@@ -146,8 +190,50 @@ static struct regulator_ops fan53555_regulator_ops = {
.is_enabled = regulator_is_enabled_regmap,
.set_mode = fan53555_set_mode,
.get_mode = fan53555_get_mode,
.set_ramp_delay = fan53555_set_ramp,
};
static int fan53555_voltages_setup_fairchild(struct fan53555_device_info *di)
{
/* Init voltage range and step */
switch (di->chip_id) {
case FAN53555_CHIP_ID_00:
case FAN53555_CHIP_ID_01:
case FAN53555_CHIP_ID_03:
case FAN53555_CHIP_ID_05:
di->vsel_min = 600000;
di->vsel_step = 10000;
break;
case FAN53555_CHIP_ID_04:
di->vsel_min = 603000;
di->vsel_step = 12826;
break;
default:
dev_err(di->dev,
"Chip ID %d not supported!\n", di->chip_id);
return -EINVAL;
}
return 0;
}
static int fan53555_voltages_setup_silergy(struct fan53555_device_info *di)
{
/* Init voltage range and step */
switch (di->chip_id) {
case SILERGY_SYR82X:
di->vsel_min = 712500;
di->vsel_step = 12500;
break;
default:
dev_err(di->dev,
"Chip ID %d not supported!\n", di->chip_id);
return -EINVAL;
}
return 0;
}
/* For 00,01,03,05 options:
* VOUT = 0.60V + NSELx * 10mV, from 0.60 to 1.23V.
* For 04 option:
......@@ -156,7 +242,7 @@ static struct regulator_ops fan53555_regulator_ops = {
static int fan53555_device_setup(struct fan53555_device_info *di,
struct fan53555_platform_data *pdata)
{
unsigned int reg, data, mask;
int ret = 0;
/* Setup voltage control register */
switch (pdata->sleep_vsel_id) {
......@@ -172,33 +258,20 @@ static int fan53555_device_setup(struct fan53555_device_info *di,
dev_err(di->dev, "Invalid VSEL ID!\n");
return -EINVAL;
}
/* Init voltage range and step */
switch (di->chip_id) {
case FAN53555_CHIP_ID_00:
case FAN53555_CHIP_ID_01:
case FAN53555_CHIP_ID_03:
case FAN53555_CHIP_ID_05:
di->vsel_min = 600000;
di->vsel_step = 10000;
switch (di->vendor) {
case FAN53555_VENDOR_FAIRCHILD:
ret = fan53555_voltages_setup_fairchild(di);
break;
case FAN53555_CHIP_ID_04:
di->vsel_min = 603000;
di->vsel_step = 12826;
case FAN53555_VENDOR_SILERGY:
ret = fan53555_voltages_setup_silergy(di);
break;
default:
dev_err(di->dev,
"Chip ID[%d]\n not supported!\n", di->chip_id);
dev_err(di->dev, "vendor %d not supported!\n", di->vendor);
return -EINVAL;
}
/* Init slew rate */
if (pdata->slew_rate & 0x7)
di->slew_rate = pdata->slew_rate;
else
di->slew_rate = FAN53555_SLEW_RATE_64MV;
reg = FAN53555_CONTROL;
data = di->slew_rate << CTL_SLEW_SHIFT;
mask = CTL_SLEW_MASK;
return regmap_update_bits(di->regmap, reg, mask, data);
return ret;
}
static int fan53555_regulator_register(struct fan53555_device_info *di,
......@@ -207,6 +280,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
struct regulator_desc *rdesc = &di->desc;
rdesc->name = "fan53555-reg";
rdesc->supply_name = "vin";
rdesc->ops = &fan53555_regulator_ops;
rdesc->type = REGULATOR_VOLTAGE;
rdesc->n_voltages = FAN53555_NVOLTAGES;
......@@ -227,9 +301,46 @@ static struct regmap_config fan53555_regmap_config = {
.val_bits = 8,
};
static struct fan53555_platform_data *fan53555_parse_dt(struct device *dev,
struct device_node *np)
{
struct fan53555_platform_data *pdata;
int ret;
u32 tmp;
pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL);
if (!pdata)
return NULL;
pdata->regulator = of_get_regulator_init_data(dev, np);
ret = of_property_read_u32(np, "fcs,suspend-voltage-selector",
&tmp);
if (!ret)
pdata->sleep_vsel_id = tmp;
return pdata;
}
static const struct of_device_id fan53555_dt_ids[] = {
{
.compatible = "fcs,fan53555",
.data = (void *)FAN53555_VENDOR_FAIRCHILD
}, {
.compatible = "silergy,syr827",
.data = (void *)FAN53555_VENDOR_SILERGY,
}, {
.compatible = "silergy,syr828",
.data = (void *)FAN53555_VENDOR_SILERGY,
},
{ }
};
MODULE_DEVICE_TABLE(of, fan53555_dt_ids);
static int fan53555_regulator_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
struct device_node *np = client->dev.of_node;
struct fan53555_device_info *di;
struct fan53555_platform_data *pdata;
struct regulator_config config = { };
......@@ -237,6 +348,9 @@ static int fan53555_regulator_probe(struct i2c_client *client,
int ret;
pdata = dev_get_platdata(&client->dev);
if (!pdata)
pdata = fan53555_parse_dt(&client->dev, np);
if (!pdata || !pdata->regulator) {
dev_err(&client->dev, "Platform data not found!\n");
return -ENODEV;
......@@ -247,13 +361,35 @@ static int fan53555_regulator_probe(struct i2c_client *client,
if (!di)
return -ENOMEM;
di->regulator = pdata->regulator;
if (client->dev.of_node) {
const struct of_device_id *match;
match = of_match_device(of_match_ptr(fan53555_dt_ids),
&client->dev);
if (!match)
return -ENODEV;
di->vendor = (unsigned long) match->data;
} else {
/* if no ramp constraint set, get the pdata ramp_delay */
if (!di->regulator->constraints.ramp_delay) {
int slew_idx = (pdata->slew_rate & 0x7)
? pdata->slew_rate : 0;
di->regulator->constraints.ramp_delay
= slew_rates[slew_idx];
}
di->vendor = id->driver_data;
}
di->regmap = devm_regmap_init_i2c(client, &fan53555_regmap_config);
if (IS_ERR(di->regmap)) {
dev_err(&client->dev, "Failed to allocate regmap!\n");
return PTR_ERR(di->regmap);
}
di->dev = &client->dev;
di->regulator = pdata->regulator;
i2c_set_clientdata(client, di);
/* Get chip ID */
ret = regmap_read(di->regmap, FAN53555_ID1, &val);
......@@ -282,6 +418,8 @@ static int fan53555_regulator_probe(struct i2c_client *client,
config.init_data = di->regulator;
config.regmap = di->regmap;
config.driver_data = di;
config.of_node = np;
ret = fan53555_regulator_register(di, &config);
if (ret < 0)
dev_err(&client->dev, "Failed to register regulator!\n");
......@@ -290,13 +428,20 @@ static int fan53555_regulator_probe(struct i2c_client *client,
}
static const struct i2c_device_id fan53555_id[] = {
{"fan53555", -1},
{
.name = "fan53555",
.driver_data = FAN53555_VENDOR_FAIRCHILD
}, {
.name = "syr82x",
.driver_data = FAN53555_VENDOR_SILERGY
},
{ },
};
static struct i2c_driver fan53555_regulator_driver = {
.driver = {
.name = "fan53555-regulator",
.of_match_table = of_match_ptr(fan53555_dt_ids),
},
.probe = fan53555_regulator_probe,
.id_table = fan53555_id,
......
This diff is collapsed.
......@@ -35,4 +35,18 @@ struct regulator {
struct dentry *debugfs;
};
#ifdef CONFIG_OF
struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
const struct regulator_desc *desc,
struct device_node **node);
#else
static inline struct regulator_init_data *
regulator_of_get_init_data(struct device *dev,
const struct regulator_desc *desc,
struct device_node **node)
{
return NULL;
}
#endif
#endif
/*
* isl9305 - Intersil ISL9305 DCDC regulator
*
* Copyright 2014 Linaro Ltd
*
* Author: Mark Brown <broonie@kernel.org>
*
* 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/err.h>
#include <linux/i2c.h>
#include <linux/of.h>
#include <linux/platform_data/isl9305.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
#include <linux/slab.h>
/*
* Registers
*/
#define ISL9305_DCD1OUT 0x0
#define ISL9305_DCD2OUT 0x1
#define ISL9305_LDO1OUT 0x2
#define ISL9305_LDO2OUT 0x3
#define ISL9305_DCD_PARAMETER 0x4
#define ISL9305_SYSTEM_PARAMETER 0x5
#define ISL9305_DCD_SRCTL 0x6
#define ISL9305_MAX_REG ISL9305_DCD_SRCTL
/*
* DCD_PARAMETER
*/
#define ISL9305_DCD_PHASE 0x40
#define ISL9305_DCD2_ULTRA 0x20
#define ISL9305_DCD1_ULTRA 0x10
#define ISL9305_DCD2_BLD 0x08
#define ISL9305_DCD1_BLD 0x04
#define ISL9305_DCD2_MODE 0x02
#define ISL9305_DCD1_MODE 0x01
/*
* SYSTEM_PARAMETER
*/
#define ISL9305_I2C_EN 0x40
#define ISL9305_DCDPOR_MASK 0x30
#define ISL9305_LDO2_EN 0x08
#define ISL9305_LDO1_EN 0x04
#define ISL9305_DCD2_EN 0x02
#define ISL9305_DCD1_EN 0x01
/*
* DCD_SRCTL
*/
#define ISL9305_DCD2SR_MASK 0xc0
#define ISL9305_DCD1SR_MASK 0x07
static const struct regulator_ops isl9305_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.list_voltage = regulator_list_voltage_linear,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
};
static const struct regulator_desc isl9305_regulators[] = {
[ISL9305_DCD1] = {
.name = "DCD1",
.of_match = of_match_ptr("dcd1"),
.regulators_node = of_match_ptr("regulators"),
.n_voltages = 0x70,
.min_uV = 825000,
.uV_step = 25000,
.vsel_reg = ISL9305_DCD1OUT,
.vsel_mask = 0x7f,
.enable_reg = ISL9305_SYSTEM_PARAMETER,
.enable_mask = ISL9305_DCD1_EN,
.supply_name = "VINDCD1",
.ops = &isl9305_ops,
},
[ISL9305_DCD2] = {
.name = "DCD2",
.of_match = of_match_ptr("dcd2"),
.regulators_node = of_match_ptr("regulators"),
.n_voltages = 0x70,
.min_uV = 825000,
.uV_step = 25000,
.vsel_reg = ISL9305_DCD2OUT,
.vsel_mask = 0x7f,
.enable_reg = ISL9305_SYSTEM_PARAMETER,
.enable_mask = ISL9305_DCD2_EN,
.supply_name = "VINDCD2",
.ops = &isl9305_ops,
},
[ISL9305_LDO1] = {
.name = "LDO1",
.of_match = of_match_ptr("ldo1"),
.regulators_node = of_match_ptr("regulators"),
.n_voltages = 0x37,
.min_uV = 900000,
.uV_step = 50000,
.vsel_reg = ISL9305_LDO1OUT,
.vsel_mask = 0x3f,
.enable_reg = ISL9305_SYSTEM_PARAMETER,
.enable_mask = ISL9305_LDO1_EN,
.supply_name = "VINLDO1",
.ops = &isl9305_ops,
},
[ISL9305_LDO2] = {
.name = "LDO2",
.of_match = of_match_ptr("ldo2"),
.regulators_node = of_match_ptr("regulators"),
.n_voltages = 0x37,
.min_uV = 900000,
.uV_step = 50000,
.vsel_reg = ISL9305_LDO2OUT,
.vsel_mask = 0x3f,
.enable_reg = ISL9305_SYSTEM_PARAMETER,
.enable_mask = ISL9305_LDO2_EN,
.supply_name = "VINLDO2",
.ops = &isl9305_ops,
},
};
static const struct regmap_config isl9305_regmap = {
.reg_bits = 8,
.val_bits = 8,
.max_register = ISL9305_MAX_REG,
.cache_type = REGCACHE_RBTREE,
};
static int isl9305_i2c_probe(struct i2c_client *i2c,
const struct i2c_device_id *id)
{
struct regulator_config config = { };
struct isl9305_pdata *pdata = i2c->dev.platform_data;
struct regulator_dev *rdev;
struct regmap *regmap;
int i, ret;
regmap = devm_regmap_init_i2c(i2c, &isl9305_regmap);
if (IS_ERR(regmap)) {
ret = PTR_ERR(regmap);
dev_err(&i2c->dev, "Failed to create regmap: %d\n", ret);
return ret;
}
config.dev = &i2c->dev;
for (i = 0; i < ARRAY_SIZE(isl9305_regulators); i++) {
if (pdata)
config.init_data = pdata->init_data[i];
else
config.init_data = NULL;
rdev = devm_regulator_register(&i2c->dev,
&isl9305_regulators[i],
&config);
if (IS_ERR(rdev)) {
ret = PTR_ERR(rdev);
dev_err(&i2c->dev, "Failed to register %s: %d\n",
isl9305_regulators[i].name, ret);
return ret;
}
}
return 0;
}
#ifdef CONFIG_OF
static const struct of_device_id isl9305_dt_ids[] = {
{ .compatible = "isl,isl9305" },
{ .compatible = "isl,isl9305h" },
{},
};
#endif
static const struct i2c_device_id isl9305_i2c_id[] = {
{ "isl9305", },
{ "isl9305h", },
{ }
};
MODULE_DEVICE_TABLE(i2c, isl9305_i2c_id);
static struct i2c_driver isl9305_regulator_driver = {
.driver = {
.name = "isl9305",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(isl9305_dt_ids),
},
.probe = isl9305_i2c_probe,
.id_table = isl9305_i2c_id,
};
module_i2c_driver(isl9305_regulator_driver);
MODULE_AUTHOR("Mark Brown");
MODULE_DESCRIPTION("Intersil ISL9305 DCDC regulator");
MODULE_LICENSE("GPL");
......@@ -372,6 +372,7 @@ static bool ltc3589_volatile_reg(struct device *dev, unsigned int reg)
switch (reg) {
case LTC3589_IRQSTAT:
case LTC3589_PGSTAT:
case LTC3589_VCCR:
return true;
}
return false;
......
......@@ -24,6 +24,8 @@
#include <linux/regulator/driver.h>
#include <linux/slab.h>
#include <linux/regulator/max1586.h>
#include <linux/of_device.h>
#include <linux/regulator/of_regulator.h>
#define MAX1586_V3_MAX_VSEL 31
#define MAX1586_V6_MAX_VSEL 3
......@@ -157,13 +159,87 @@ static struct regulator_desc max1586_reg[] = {
},
};
static int of_get_max1586_platform_data(struct device *dev,
struct max1586_platform_data *pdata)
{
struct max1586_subdev_data *sub;
struct of_regulator_match rmatch[ARRAY_SIZE(max1586_reg)];
struct device_node *np = dev->of_node;
int i, matched;
if (of_property_read_u32(np, "v3-gain",
&pdata->v3_gain) < 0) {
dev_err(dev, "%s has no 'v3-gain' property\n", np->full_name);
return -EINVAL;
}
np = of_get_child_by_name(np, "regulators");
if (!np) {
dev_err(dev, "missing 'regulators' subnode in DT\n");
return -EINVAL;
}
for (i = 0; i < ARRAY_SIZE(rmatch); i++)
rmatch[i].name = max1586_reg[i].name;
matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(rmatch));
of_node_put(np);
/*
* If matched is 0, ie. neither Output_V3 nor Output_V6 have been found,
* return 0, which signals the normal situation where no subregulator is
* available. This is normal because the max1586 doesn't provide any
* readback support, so the subregulators can't report any status
* anyway. If matched < 0, return the error.
*/
if (matched <= 0)
return matched;
pdata->subdevs = devm_kzalloc(dev, sizeof(struct max1586_subdev_data) *
matched, GFP_KERNEL);
if (!pdata->subdevs)
return -ENOMEM;
pdata->num_subdevs = matched;
sub = pdata->subdevs;
for (i = 0; i < matched; i++) {
sub->id = i;
sub->name = rmatch[i].of_node->name;
sub->platform_data = rmatch[i].init_data;
sub++;
}
return 0;
}
static const struct of_device_id max1586_of_match[] = {
{ .compatible = "maxim,max1586", },
{},
};
MODULE_DEVICE_TABLE(of, max1586_of_match);
static int max1586_pmic_probe(struct i2c_client *client,
const struct i2c_device_id *i2c_id)
{
struct max1586_platform_data *pdata = dev_get_platdata(&client->dev);
struct max1586_platform_data *pdata, pdata_of;
struct regulator_config config = { };
struct max1586_data *max1586;
int i, id;
int i, id, ret;
const struct of_device_id *match;
pdata = dev_get_platdata(&client->dev);
if (client->dev.of_node && !pdata) {
match = of_match_device(of_match_ptr(max1586_of_match),
&client->dev);
if (!match) {
dev_err(&client->dev, "Error: No device match found\n");
return -ENODEV;
}
ret = of_get_max1586_platform_data(&client->dev, &pdata_of);
if (ret < 0)
return ret;
pdata = &pdata_of;
}
max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data),
GFP_KERNEL);
......@@ -229,6 +305,7 @@ static struct i2c_driver max1586_pmic_driver = {
.driver = {
.name = "max1586",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(max1586_of_match),
},
.id_table = max1586_id,
};
......
This diff is collapsed.
......@@ -526,6 +526,7 @@ static unsigned int mc13892_vcam_get_mode(struct regulator_dev *rdev)
return REGULATOR_MODE_NORMAL;
}
static struct regulator_ops mc13892_vcam_ops;
static int mc13892_regulator_probe(struct platform_device *pdev)
{
......@@ -582,10 +583,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
}
mc13xxx_unlock(mc13892);
mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
= mc13892_vcam_set_mode;
mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
= mc13892_vcam_get_mode;
/* update mc13892_vcam ops */
memcpy(&mc13892_vcam_ops, mc13892_regulators[MC13892_VCAM].desc.ops,
sizeof(struct regulator_ops));
mc13892_vcam_ops.set_mode = mc13892_vcam_set_mode,
mc13892_vcam_ops.get_mode = mc13892_vcam_get_mode,
mc13892_regulators[MC13892_VCAM].desc.ops = &mc13892_vcam_ops;
mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
ARRAY_SIZE(mc13892_regulators));
......
......@@ -14,8 +14,11 @@
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
#include "internal.h"
static void of_get_regulation_constraints(struct device_node *np,
struct regulator_init_data **init_data)
{
......@@ -189,3 +192,51 @@ int of_regulator_match(struct device *dev, struct device_node *node,
return count;
}
EXPORT_SYMBOL_GPL(of_regulator_match);
struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
const struct regulator_desc *desc,
struct device_node **node)
{
struct device_node *search, *child;
struct regulator_init_data *init_data = NULL;
const char *name;
if (!dev->of_node || !desc->of_match)
return NULL;
if (desc->regulators_node)
search = of_get_child_by_name(dev->of_node,
desc->regulators_node);
else
search = dev->of_node;
if (!search) {
dev_err(dev, "Failed to find regulator container node\n");
return NULL;
}
for_each_child_of_node(search, child) {
name = of_get_property(child, "regulator-compatible", NULL);
if (!name)
name = child->name;
if (strcmp(desc->of_match, name))
continue;
init_data = of_get_regulator_init_data(dev, child);
if (!init_data) {
dev_err(dev,
"failed to parse DT for regulator %s\n",
child->name);
break;
}
of_node_get(child);
*node = child;
break;
}
of_node_put(search);
return init_data;
}
/*
* Regulator driver for ST's PWM Regulators
* Regulator driver for PWM Regulators
*
* Copyright (C) 2014 - STMicroelectronics Inc.
*
......@@ -20,43 +20,40 @@
#include <linux/of_device.h>
#include <linux/pwm.h>
#define ST_PWM_REG_PERIOD 8448
struct st_pwm_regulator_pdata {
const struct regulator_desc *desc;
struct st_pwm_voltages *duty_cycle_table;
};
struct st_pwm_regulator_data {
const struct st_pwm_regulator_pdata *pdata;
struct pwm_regulator_data {
struct regulator_desc desc;
struct pwm_voltages *duty_cycle_table;
struct pwm_device *pwm;
bool enabled;
int state;
};
struct st_pwm_voltages {
struct pwm_voltages {
unsigned int uV;
unsigned int dutycycle;
};
static int st_pwm_regulator_get_voltage_sel(struct regulator_dev *dev)
static int pwm_regulator_get_voltage_sel(struct regulator_dev *dev)
{
struct st_pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
return drvdata->state;
}
static int st_pwm_regulator_set_voltage_sel(struct regulator_dev *dev,
unsigned selector)
static int pwm_regulator_set_voltage_sel(struct regulator_dev *dev,
unsigned selector)
{
struct st_pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
unsigned int pwm_reg_period;
int dutycycle;
int ret;
dutycycle = (ST_PWM_REG_PERIOD / 100) *
drvdata->pdata->duty_cycle_table[selector].dutycycle;
pwm_reg_period = pwm_get_period(drvdata->pwm);
ret = pwm_config(drvdata->pwm, dutycycle, ST_PWM_REG_PERIOD);
dutycycle = (pwm_reg_period *
drvdata->duty_cycle_table[selector].dutycycle) / 100;
ret = pwm_config(drvdata->pwm, dutycycle, pwm_reg_period);
if (ret) {
dev_err(&dev->dev, "Failed to configure PWM\n");
return ret;
......@@ -76,61 +73,40 @@ static int st_pwm_regulator_set_voltage_sel(struct regulator_dev *dev,
return 0;
}
static int st_pwm_regulator_list_voltage(struct regulator_dev *dev,
unsigned selector)
static int pwm_regulator_list_voltage(struct regulator_dev *dev,
unsigned selector)
{
struct st_pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
if (selector >= dev->desc->n_voltages)
if (selector >= drvdata->desc.n_voltages)
return -EINVAL;
return drvdata->pdata->duty_cycle_table[selector].uV;
return drvdata->duty_cycle_table[selector].uV;
}
static struct regulator_ops st_pwm_regulator_voltage_ops = {
.set_voltage_sel = st_pwm_regulator_set_voltage_sel,
.get_voltage_sel = st_pwm_regulator_get_voltage_sel,
.list_voltage = st_pwm_regulator_list_voltage,
static struct regulator_ops pwm_regulator_voltage_ops = {
.set_voltage_sel = pwm_regulator_set_voltage_sel,
.get_voltage_sel = pwm_regulator_get_voltage_sel,
.list_voltage = pwm_regulator_list_voltage,
.map_voltage = regulator_map_voltage_iterate,
};
static struct st_pwm_voltages b2105_duty_cycle_table[] = {
{ .uV = 1114000, .dutycycle = 0, },
{ .uV = 1095000, .dutycycle = 10, },
{ .uV = 1076000, .dutycycle = 20, },
{ .uV = 1056000, .dutycycle = 30, },
{ .uV = 1036000, .dutycycle = 40, },
{ .uV = 1016000, .dutycycle = 50, },
/* WARNING: Values above 50% duty-cycle cause boot failures. */
};
static const struct regulator_desc b2105_desc = {
.name = "b2105-pwm-regulator",
.ops = &st_pwm_regulator_voltage_ops,
static const struct regulator_desc pwm_regulator_desc = {
.name = "pwm-regulator",
.ops = &pwm_regulator_voltage_ops,
.type = REGULATOR_VOLTAGE,
.owner = THIS_MODULE,
.n_voltages = ARRAY_SIZE(b2105_duty_cycle_table),
.supply_name = "pwm",
};
static const struct st_pwm_regulator_pdata b2105_info = {
.desc = &b2105_desc,
.duty_cycle_table = b2105_duty_cycle_table,
};
static const struct of_device_id st_pwm_of_match[] = {
{ .compatible = "st,b2105-pwm-regulator", .data = &b2105_info, },
{ },
};
MODULE_DEVICE_TABLE(of, st_pwm_of_match);
static int st_pwm_regulator_probe(struct platform_device *pdev)
static int pwm_regulator_probe(struct platform_device *pdev)
{
struct st_pwm_regulator_data *drvdata;
struct pwm_regulator_data *drvdata;
struct property *prop;
struct regulator_dev *regulator;
struct regulator_config config = { };
struct device_node *np = pdev->dev.of_node;
const struct of_device_id *of_match;
int length, ret;
if (!np) {
dev_err(&pdev->dev, "Device Tree node missing\n");
......@@ -141,12 +117,37 @@ static int st_pwm_regulator_probe(struct platform_device *pdev)
if (!drvdata)
return -ENOMEM;
of_match = of_match_device(st_pwm_of_match, &pdev->dev);
if (!of_match) {
dev_err(&pdev->dev, "failed to match of device\n");
return -ENODEV;
memcpy(&drvdata->desc, &pwm_regulator_desc, sizeof(pwm_regulator_desc));
/* determine the number of voltage-table */
prop = of_find_property(np, "voltage-table", &length);
if (!prop) {
dev_err(&pdev->dev, "No voltage-table\n");
return -EINVAL;
}
if ((length < sizeof(*drvdata->duty_cycle_table)) ||
(length % sizeof(*drvdata->duty_cycle_table))) {
dev_err(&pdev->dev, "voltage-table length(%d) is invalid\n",
length);
return -EINVAL;
}
drvdata->desc.n_voltages = length / sizeof(*drvdata->duty_cycle_table);
drvdata->duty_cycle_table = devm_kzalloc(&pdev->dev,
length, GFP_KERNEL);
if (!drvdata->duty_cycle_table)
return -ENOMEM;
/* read voltage table from DT property */
ret = of_property_read_u32_array(np, "voltage-table",
(u32 *)drvdata->duty_cycle_table,
length / sizeof(u32));
if (ret < 0) {
dev_err(&pdev->dev, "read voltage-table failed\n");
return ret;
}
drvdata->pdata = of_match->data;
config.init_data = of_get_regulator_init_data(&pdev->dev, np);
if (!config.init_data)
......@@ -163,28 +164,34 @@ static int st_pwm_regulator_probe(struct platform_device *pdev)
}
regulator = devm_regulator_register(&pdev->dev,
drvdata->pdata->desc, &config);
&drvdata->desc, &config);
if (IS_ERR(regulator)) {
dev_err(&pdev->dev, "Failed to register regulator %s\n",
drvdata->pdata->desc->name);
drvdata->desc.name);
return PTR_ERR(regulator);
}
return 0;
}
static struct platform_driver st_pwm_regulator_driver = {
static const struct of_device_id pwm_of_match[] = {
{ .compatible = "pwm-regulator" },
{ },
};
MODULE_DEVICE_TABLE(of, pwm_of_match);
static struct platform_driver pwm_regulator_driver = {
.driver = {
.name = "st-pwm-regulator",
.name = "pwm-regulator",
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(st_pwm_of_match),
.of_match_table = of_match_ptr(pwm_of_match),
},
.probe = st_pwm_regulator_probe,
.probe = pwm_regulator_probe,
};
module_platform_driver(st_pwm_regulator_driver);
module_platform_driver(pwm_regulator_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Lee Jones <lee.jones@linaro.org>");
MODULE_DESCRIPTION("ST PWM Regulator Driver");
MODULE_ALIAS("platform:st_pwm-regulator");
MODULE_DESCRIPTION("PWM Regulator Driver");
MODULE_ALIAS("platform:pwm-regulator");
This diff is collapsed.
This diff is collapsed.
/*
* Regulator driver for Ricoh RN5T618 PMIC
*
* Copyright (C) 2014 Beniamino Galvani <b.galvani@gmail.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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <linux/mfd/rn5t618.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
static struct regulator_ops rn5t618_reg_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.set_voltage_sel = regulator_set_voltage_sel_regmap,
.get_voltage_sel = regulator_get_voltage_sel_regmap,
.list_voltage = regulator_list_voltage_linear,
};
#define REG(rid, ereg, emask, vreg, vmask, min, max, step) \
[RN5T618_##rid] = { \
.name = #rid, \
.id = RN5T618_##rid, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.ops = &rn5t618_reg_ops, \
.n_voltages = ((max) - (min)) / (step) + 1, \
.min_uV = (min), \
.uV_step = (step), \
.enable_reg = RN5T618_##ereg, \
.enable_mask = (emask), \
.vsel_reg = RN5T618_##vreg, \
.vsel_mask = (vmask), \
}
static struct regulator_desc rn5t618_regulators[] = {
/* DCDC */
REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500),
REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500),
REG(DCDC3, DC3CTL, BIT(0), DC3DAC, 0xff, 600000, 3500000, 12500),
/* LDO */
REG(LDO1, LDOEN1, BIT(0), LDO1DAC, 0x7f, 900000, 3500000, 25000),
REG(LDO2, LDOEN1, BIT(1), LDO2DAC, 0x7f, 900000, 3500000, 25000),
REG(LDO3, LDOEN1, BIT(2), LDO3DAC, 0x7f, 600000, 3500000, 25000),
REG(LDO4, LDOEN1, BIT(3), LDO4DAC, 0x7f, 900000, 3500000, 25000),
REG(LDO5, LDOEN1, BIT(4), LDO5DAC, 0x7f, 900000, 3500000, 25000),
/* LDO RTC */
REG(LDORTC1, LDOEN2, BIT(4), LDORTCDAC, 0x7f, 1700000, 3500000, 25000),
REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
};
static struct of_regulator_match rn5t618_matches[] = {
[RN5T618_DCDC1] = { .name = "DCDC1" },
[RN5T618_DCDC2] = { .name = "DCDC2" },
[RN5T618_DCDC3] = { .name = "DCDC3" },
[RN5T618_LDO1] = { .name = "LDO1" },
[RN5T618_LDO2] = { .name = "LDO2" },
[RN5T618_LDO3] = { .name = "LDO3" },
[RN5T618_LDO4] = { .name = "LDO4" },
[RN5T618_LDO5] = { .name = "LDO5" },
[RN5T618_LDORTC1] = { .name = "LDORTC1" },
[RN5T618_LDORTC2] = { .name = "LDORTC2" },
};
static int rn5t618_regulator_parse_dt(struct platform_device *pdev)
{
struct device_node *np, *regulators;
int ret;
np = of_node_get(pdev->dev.parent->of_node);
if (!np)
return 0;
regulators = of_get_child_by_name(np, "regulators");
if (!regulators) {
dev_err(&pdev->dev, "regulators node not found\n");
return -EINVAL;
}
ret = of_regulator_match(&pdev->dev, regulators, rn5t618_matches,
ARRAY_SIZE(rn5t618_matches));
of_node_put(regulators);
if (ret < 0) {
dev_err(&pdev->dev, "error parsing regulator init data: %d\n",
ret);
}
return 0;
}
static int rn5t618_regulator_probe(struct platform_device *pdev)
{
struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { };
struct regulator_dev *rdev;
int ret, i;
ret = rn5t618_regulator_parse_dt(pdev);
if (ret)
return ret;
for (i = 0; i < RN5T618_REG_NUM; i++) {
config.dev = &pdev->dev;
config.init_data = rn5t618_matches[i].init_data;
config.of_node = rn5t618_matches[i].of_node;
config.regmap = rn5t618->regmap;
rdev = devm_regulator_register(&pdev->dev,
&rn5t618_regulators[i],
&config);
if (IS_ERR(rdev)) {
dev_err(&pdev->dev, "failed to register %s regulator\n",
rn5t618_regulators[i].name);
return PTR_ERR(rdev);
}
}
return 0;
}
static struct platform_driver rn5t618_regulator_driver = {
.probe = rn5t618_regulator_probe,
.driver = {
.name = "rn5t618-regulator",
},
};
module_platform_driver(rn5t618_regulator_driver);
MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>");
MODULE_DESCRIPTION("RN5T618 regulator driver");
MODULE_LICENSE("GPL v2");
......@@ -235,28 +235,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
.set_ramp_delay = s2mpa01_set_ramp_delay,
};
#define regulator_desc_ldo1(num) { \
#define regulator_desc_ldo(num, step) { \
.name = "LDO"#num, \
.id = S2MPA01_LDO##num, \
.ops = &s2mpa01_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = S2MPA01_LDO_MIN, \
.uV_step = S2MPA01_LDO_STEP1, \
.n_voltages = S2MPA01_LDO_N_VOLTAGES, \
.vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPA01_LDO_VSEL_MASK, \
.enable_reg = S2MPA01_REG_L1CTRL + num - 1, \
.enable_mask = S2MPA01_ENABLE_MASK \
}
#define regulator_desc_ldo2(num) { \
.name = "LDO"#num, \
.id = S2MPA01_LDO##num, \
.ops = &s2mpa01_ldo_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = S2MPA01_LDO_MIN, \
.uV_step = S2MPA01_LDO_STEP2, \
.min_uV = MIN_800_MV, \
.uV_step = step, \
.n_voltages = S2MPA01_LDO_N_VOLTAGES, \
.vsel_reg = S2MPA01_REG_L1CTRL + num - 1, \
.vsel_mask = S2MPA01_LDO_VSEL_MASK, \
......@@ -270,8 +256,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = S2MPA01_BUCK_MIN1, \
.uV_step = S2MPA01_BUCK_STEP1, \
.min_uV = MIN_600_MV, \
.uV_step = STEP_6_25_MV, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B1CTRL2 + (num - 1) * 2, \
......@@ -286,8 +272,8 @@ static struct regulator_ops s2mpa01_buck_ops = {
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = S2MPA01_BUCK_MIN2, \
.uV_step = S2MPA01_BUCK_STEP1, \
.min_uV = MIN_800_MV, \
.uV_step = STEP_6_25_MV, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B5CTRL2, \
......@@ -296,14 +282,14 @@ static struct regulator_ops s2mpa01_buck_ops = {
.enable_mask = S2MPA01_ENABLE_MASK \
}
#define regulator_desc_buck6_7(num) { \
#define regulator_desc_buck6_10(num, min, step) { \
.name = "BUCK"#num, \
.id = S2MPA01_BUCK##num, \
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = S2MPA01_BUCK_MIN1, \
.uV_step = S2MPA01_BUCK_STEP1, \
.min_uV = min, \
.uV_step = step, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B6CTRL2 + (num - 6) * 2, \
......@@ -312,91 +298,43 @@ static struct regulator_ops s2mpa01_buck_ops = {
.enable_mask = S2MPA01_ENABLE_MASK \
}
#define regulator_desc_buck8 { \
.name = "BUCK8", \
.id = S2MPA01_BUCK8, \
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = S2MPA01_BUCK_MIN2, \
.uV_step = S2MPA01_BUCK_STEP2, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B8CTRL2, \
.vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
.enable_reg = S2MPA01_REG_B8CTRL1, \
.enable_mask = S2MPA01_ENABLE_MASK \
}
#define regulator_desc_buck9 { \
.name = "BUCK9", \
.id = S2MPA01_BUCK9, \
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = S2MPA01_BUCK_MIN4, \
.uV_step = S2MPA01_BUCK_STEP2, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B9CTRL2, \
.vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
.enable_reg = S2MPA01_REG_B9CTRL1, \
.enable_mask = S2MPA01_ENABLE_MASK \
}
#define regulator_desc_buck10 { \
.name = "BUCK10", \
.id = S2MPA01_BUCK10, \
.ops = &s2mpa01_buck_ops, \
.type = REGULATOR_VOLTAGE, \
.owner = THIS_MODULE, \
.min_uV = S2MPA01_BUCK_MIN3, \
.uV_step = S2MPA01_BUCK_STEP2, \
.n_voltages = S2MPA01_BUCK_N_VOLTAGES, \
.ramp_delay = S2MPA01_RAMP_DELAY, \
.vsel_reg = S2MPA01_REG_B10CTRL2, \
.vsel_mask = S2MPA01_BUCK_VSEL_MASK, \
.enable_reg = S2MPA01_REG_B10CTRL1, \
.enable_mask = S2MPA01_ENABLE_MASK \
}
static struct regulator_desc regulators[] = {
regulator_desc_ldo2(1),
regulator_desc_ldo1(2),
regulator_desc_ldo1(3),
regulator_desc_ldo1(4),
regulator_desc_ldo1(5),
regulator_desc_ldo2(6),
regulator_desc_ldo1(7),
regulator_desc_ldo1(8),
regulator_desc_ldo1(9),
regulator_desc_ldo1(10),
regulator_desc_ldo2(11),
regulator_desc_ldo1(12),
regulator_desc_ldo1(13),
regulator_desc_ldo1(14),
regulator_desc_ldo1(15),
regulator_desc_ldo1(16),
regulator_desc_ldo1(17),
regulator_desc_ldo1(18),
regulator_desc_ldo1(19),
regulator_desc_ldo1(20),
regulator_desc_ldo1(21),
regulator_desc_ldo2(22),
regulator_desc_ldo2(23),
regulator_desc_ldo1(24),
regulator_desc_ldo1(25),
regulator_desc_ldo1(26),
regulator_desc_ldo(1, STEP_25_MV),
regulator_desc_ldo(2, STEP_50_MV),
regulator_desc_ldo(3, STEP_50_MV),
regulator_desc_ldo(4, STEP_50_MV),
regulator_desc_ldo(5, STEP_50_MV),
regulator_desc_ldo(6, STEP_25_MV),
regulator_desc_ldo(7, STEP_50_MV),
regulator_desc_ldo(8, STEP_50_MV),
regulator_desc_ldo(9, STEP_50_MV),
regulator_desc_ldo(10, STEP_50_MV),
regulator_desc_ldo(11, STEP_25_MV),
regulator_desc_ldo(12, STEP_50_MV),
regulator_desc_ldo(13, STEP_50_MV),
regulator_desc_ldo(14, STEP_50_MV),
regulator_desc_ldo(15, STEP_50_MV),
regulator_desc_ldo(16, STEP_50_MV),
regulator_desc_ldo(17, STEP_50_MV),
regulator_desc_ldo(18, STEP_50_MV),
regulator_desc_ldo(19, STEP_50_MV),
regulator_desc_ldo(20, STEP_50_MV),
regulator_desc_ldo(21, STEP_50_MV),
regulator_desc_ldo(22, STEP_25_MV),
regulator_desc_ldo(23, STEP_25_MV),
regulator_desc_ldo(24, STEP_50_MV),
regulator_desc_ldo(25, STEP_50_MV),
regulator_desc_ldo(26, STEP_50_MV),
regulator_desc_buck1_4(1),
regulator_desc_buck1_4(2),
regulator_desc_buck1_4(3),
regulator_desc_buck1_4(4),
regulator_desc_buck5,
regulator_desc_buck6_7(6),
regulator_desc_buck6_7(7),
regulator_desc_buck8,
regulator_desc_buck9,
regulator_desc_buck10,
regulator_desc_buck6_10(6, MIN_600_MV, STEP_6_25_MV),
regulator_desc_buck6_10(7, MIN_600_MV, STEP_6_25_MV),
regulator_desc_buck6_10(8, MIN_800_MV, STEP_12_5_MV),
regulator_desc_buck6_10(9, MIN_1500_MV, STEP_12_5_MV),
regulator_desc_buck6_10(10, MIN_1000_MV, STEP_12_5_MV),
};
static int s2mpa01_pmic_probe(struct platform_device *pdev)
......
This diff is collapsed.
This diff is collapsed.
......@@ -211,9 +211,6 @@ static int tps_65023_probe(struct i2c_client *client,
int i;
int error;
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -EIO;
/**
* init_data points to array of regulator_init structures
* coming from the board-evm file.
......
This diff is collapsed.
......@@ -1047,7 +1047,7 @@ static struct tps65910_board *tps65910_parse_dt_reg_data(
*tps65910_reg_matches = matches;
for (idx = 0; idx < count; idx++) {
if (!matches[idx].init_data || !matches[idx].of_node)
if (!matches[idx].of_node)
continue;
pmic_plat_data->tps65910_pmic_init_data[idx] =
......@@ -1077,7 +1077,6 @@ static int tps65910_probe(struct platform_device *pdev)
struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { };
struct tps_info *info;
struct regulator_init_data *reg_data;
struct regulator_dev *rdev;
struct tps65910_reg *pmic;
struct tps65910_board *pmic_plat_data;
......@@ -1140,14 +1139,6 @@ static int tps65910_probe(struct platform_device *pdev)
for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS;
i++, info++) {
reg_data = pmic_plat_data->tps65910_pmic_init_data[i];
/* Regulator API handles empty constraints but not NULL
* constraints */
if (!reg_data)
continue;
/* Register the regulators */
pmic->info[i] = info;
......@@ -1199,7 +1190,7 @@ static int tps65910_probe(struct platform_device *pdev)
pmic->desc[i].enable_mask = TPS65910_SUPPLY_STATE_ENABLED;
config.dev = tps65910->dev;
config.init_data = reg_data;
config.init_data = pmic_plat_data->tps65910_pmic_init_data[i];
config.driver_data = pmic;
config.regmap = tps65910->regmap;
......
......@@ -14,6 +14,27 @@
#ifndef __LINUX_MFD_SEC_CORE_H
#define __LINUX_MFD_SEC_CORE_H
/* Macros to represent minimum voltages for LDO/BUCK */
#define MIN_3000_MV 3000000
#define MIN_2500_MV 2500000
#define MIN_2000_MV 2000000
#define MIN_1800_MV 1800000
#define MIN_1500_MV 1500000
#define MIN_1400_MV 1400000
#define MIN_1000_MV 1000000
#define MIN_900_MV 900000
#define MIN_850_MV 850000
#define MIN_800_MV 800000
#define MIN_750_MV 750000
#define MIN_600_MV 600000
/* Macros to represent steps for LDO/BUCK */
#define STEP_50_MV 50000
#define STEP_25_MV 25000
#define STEP_12_5_MV 12500
#define STEP_6_25_MV 6250
enum sec_device_type {
S5M8751X,
S5M8763X,
......
......@@ -155,18 +155,6 @@ enum s2mpa01_regulators {
S2MPA01_REGULATOR_MAX,
};
#define S2MPA01_BUCK_MIN1 600000
#define S2MPA01_BUCK_MIN2 800000
#define S2MPA01_BUCK_MIN3 1000000
#define S2MPA01_BUCK_MIN4 1500000
#define S2MPA01_LDO_MIN 800000
#define S2MPA01_BUCK_STEP1 6250
#define S2MPA01_BUCK_STEP2 12500
#define S2MPA01_LDO_STEP1 50000
#define S2MPA01_LDO_STEP2 25000
#define S2MPA01_LDO_VSEL_MASK 0x3F
#define S2MPA01_BUCK_VSEL_MASK 0xFF
#define S2MPA01_ENABLE_MASK (0x03 << S2MPA01_ENABLE_SHIFT)
......
......@@ -171,15 +171,6 @@ enum s2mps11_regulators {
S2MPS11_REGULATOR_MAX,
};
#define S2MPS11_BUCK_MIN1 600000
#define S2MPS11_BUCK_MIN2 750000
#define S2MPS11_BUCK_MIN3 3000000
#define S2MPS11_LDO_MIN 800000
#define S2MPS11_BUCK_STEP1 6250
#define S2MPS11_BUCK_STEP2 12500
#define S2MPS11_BUCK_STEP3 25000
#define S2MPS11_LDO_STEP1 50000
#define S2MPS11_LDO_STEP2 25000
#define S2MPS11_LDO_VSEL_MASK 0x3F
#define S2MPS11_BUCK_VSEL_MASK 0xFF
#define S2MPS11_ENABLE_MASK (0x03 << S2MPS11_ENABLE_SHIFT)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -40,7 +40,7 @@
*/
struct max1586_subdev_data {
int id;
char *name;
const char *name;
struct regulator_init_data *platform_data;
};
......
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