Commit 68cc38ff authored by Linus Torvalds's avatar Linus Torvalds

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

Pull regulator updates from Mark Brown:
 "Quite a lot of core work this time around, though not 100% successful.

  We gained support for runtime mode changes thanks to David Collins and
  improved support for write only regulators (ones where we can't read
  back the configuration) from Douglas Anderson.

  There's been quite a bit of work from Linus Walleij on converting from
  specfying GPIOs by numbers to descriptors. Sadly the testing turned
  out to be less good than we had hoped and so a lot of this had to be
  reverted.

  We also have the start of updates to use coupled regulators from
  Maciej Purski, unfortunately there are further problems there so the
  last couple of patches have been reverted.

  We also have new drivers for BD71837 and SY8106A devices, SAW
  regulators on Qualcomm SPMI and dropped support for some preproduction
  chips that never made it to market from the AB8500 driver"

* tag 'regulator-v4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (57 commits)
  regulator: gpio: Revert
  ARM: pxa, regulator: fix building ezx e680
  regulator: Revert coupled regulator support again
  regulator: wm8994: Fix shared GPIOs
  regulator: max77686: Fix shared GPIOs
  regulator: bd71837: BD71837 PMIC regulator driver
  regulator: bd71837: Devicetree bindings for BD71837 regulators
  regulator: gpio: Get enable GPIO using GPIO descriptor
  regulator: fixed: Convert to use GPIO descriptor only
  regulator: s2mps11: Fix boot on Odroid XU3
  dt-bindings: qcom_spmi: Document SAW support
  regulator: qcom_spmi: Add support for SAW
  regulator: tps65090: Pass descriptor instead of GPIO number
  regulator: s5m8767: Pass descriptor instead of GPIO number
  regulator: pfuze100: Delete reference to ena_gpio
  regulator: max8952: Pass descriptor instead of GPIO number
  regulator: lp8788-ldo: Pass descriptor instead of GPIO number
  regulator: lm363x: Pass descriptor instead of GPIO number
  regulator: max8973: Pass descriptor instead of GPIO number
  regulator: mc13xxx-core: Switch to SPDX identifier
  ...
parents 410feb75 13ed4964
...@@ -43,7 +43,7 @@ Optional properties: ...@@ -43,7 +43,7 @@ Optional properties:
regulator to drive the OTG VBus, rather then regulator to drive the OTG VBus, rather then
as an input pin which signals whether the as an input pin which signals whether the
board is driving OTG VBus or not. board is driving OTG VBus or not.
(axp221 / axp223 / axp813 only) (axp221 / axp223 / axp803/ axp813 only)
- x-powers,master-mode: Boolean (axp806 only). Set this when the PMIC is - x-powers,master-mode: Boolean (axp806 only). Set this when the PMIC is
wired for master mode. The default is slave mode. wired for master mode. The default is slave mode.
...@@ -132,6 +132,7 @@ FLDO2 : LDO : fldoin-supply : shared supply ...@@ -132,6 +132,7 @@ FLDO2 : LDO : fldoin-supply : shared supply
LDO_IO0 : LDO : ips-supply : GPIO 0 LDO_IO0 : LDO : ips-supply : GPIO 0
LDO_IO1 : LDO : ips-supply : GPIO 1 LDO_IO1 : LDO : ips-supply : GPIO 1
RTC_LDO : LDO : ips-supply : always on RTC_LDO : LDO : ips-supply : always on
DRIVEVBUS : Enable output : drivevbus-supply : external regulator
AXP806 regulators, type, and corresponding input supply names: AXP806 regulators, type, and corresponding input supply names:
......
...@@ -25,6 +25,25 @@ Required properties: ...@@ -25,6 +25,25 @@ Required properties:
Each child node is defined using the standard Each child node is defined using the standard
binding for regulators. binding for regulators.
Optional properties:
- rohm,ddr-backup-power : Value to use for DDR-Backup Power (default 0).
This is a bitmask that specifies which DDR power
rails need to be kept powered when backup mode is
entered, for system suspend:
- bit 0: DDR0
- bit 1: DDR1
- bit 2: DDR0C
- bit 3: DDR1C
These bits match the KEEPON_DDR* bits in the
documentation for the "BKUP Mode Cnt" register.
- rohm,rstbmode-level: The RSTB signal is configured for level mode, to
accommodate a toggle power switch (the RSTBMODE pin is
strapped low).
- rohm,rstbmode-pulse: The RSTB signal is configured for pulse mode, to
accommodate a momentary power switch (the RSTBMODE pin
is strapped high).
The two properties above are mutually exclusive.
Example: Example:
pmic: pmic@30 { pmic: pmic@30 {
...@@ -36,6 +55,8 @@ Example: ...@@ -36,6 +55,8 @@ Example:
#interrupt-cells = <2>; #interrupt-cells = <2>;
gpio-controller; gpio-controller;
#gpio-cells = <2>; #gpio-cells = <2>;
rohm,ddr-backup-power = <0xf>;
rohm,rstbmode-pulse;
regulators { regulators {
dvfs: dvfs { dvfs: dvfs {
......
...@@ -21,7 +21,7 @@ Each regulator is defined using the standard binding for regulators. ...@@ -21,7 +21,7 @@ Each regulator is defined using the standard binding for regulators.
Example 1: PFUZE100 Example 1: PFUZE100
pmic: pfuze100@8 { pfuze100: pmic@8 {
compatible = "fsl,pfuze100"; compatible = "fsl,pfuze100";
reg = <0x08>; reg = <0x08>;
...@@ -122,7 +122,7 @@ Example 1: PFUZE100 ...@@ -122,7 +122,7 @@ Example 1: PFUZE100
Example 2: PFUZE200 Example 2: PFUZE200
pmic: pfuze200@8 { pfuze200: pmic@8 {
compatible = "fsl,pfuze200"; compatible = "fsl,pfuze200";
reg = <0x08>; reg = <0x08>;
...@@ -216,7 +216,7 @@ Example 2: PFUZE200 ...@@ -216,7 +216,7 @@ Example 2: PFUZE200
Example 3: PFUZE3000 Example 3: PFUZE3000
pmic: pfuze3000@8 { pfuze3000: pmic@8 {
compatible = "fsl,pfuze3000"; compatible = "fsl,pfuze3000";
reg = <0x08>; reg = <0x08>;
......
...@@ -110,6 +110,11 @@ Qualcomm SPMI Regulators ...@@ -110,6 +110,11 @@ Qualcomm SPMI Regulators
Definition: Reference to regulator supplying the input pin, as Definition: Reference to regulator supplying the input pin, as
described in the data sheet. described in the data sheet.
- qcom,saw-reg:
Usage: optional
Value type: <phandle>
Description: Reference to syscon node defining the SAW registers.
The regulator node houses sub-nodes for each regulator within the device. Each The regulator node houses sub-nodes for each regulator within the device. Each
sub-node is identified using the node's name, with valid values listed for each sub-node is identified using the node's name, with valid values listed for each
...@@ -201,6 +206,17 @@ see regulator.txt - with additional custom properties described below: ...@@ -201,6 +206,17 @@ see regulator.txt - with additional custom properties described below:
2 = 0.55 uA 2 = 0.55 uA
3 = 0.75 uA 3 = 0.75 uA
- qcom,saw-slave:
Usage: optional
Value type: <boo>
Description: SAW controlled gang slave. Will not be configured.
- qcom,saw-leader:
Usage: optional
Value type: <boo>
Description: SAW controlled gang leader. Will be configured as
SAW regulator.
Example: Example:
regulators { regulators {
...@@ -221,3 +237,32 @@ Example: ...@@ -221,3 +237,32 @@ Example:
.... ....
}; };
Example 2:
saw3: syscon@9A10000 {
compatible = "syscon";
reg = <0x9A10000 0x1000>;
};
...
spm-regulators {
compatible = "qcom,pm8994-regulators";
qcom,saw-reg = <&saw3>;
s8 {
qcom,saw-slave;
};
s9 {
qcom,saw-slave;
};
s10 {
qcom,saw-slave;
};
pm8994_s11_saw: s11 {
qcom,saw-leader;
regulator-always-on;
regulator-min-microvolt = <900000>;
regulator-max-microvolt = <1140000>;
};
};
...@@ -59,6 +59,11 @@ Optional properties: ...@@ -59,6 +59,11 @@ Optional properties:
- regulator-initial-mode: initial operating mode. The set of possible operating - regulator-initial-mode: initial operating mode. The set of possible operating
modes depends on the capabilities of every hardware so each device binding modes depends on the capabilities of every hardware so each device binding
documentation explains which values the regulator supports. documentation explains which values the regulator supports.
- regulator-allowed-modes: list of operating modes that software is allowed to
configure for the regulator at run-time. Elements may be specified in any
order. The set of possible operating modes depends on the capabilities of
every hardware so each device binding document explains which values the
regulator supports.
- regulator-system-load: Load in uA present on regulator that is not captured by - regulator-system-load: Load in uA present on regulator that is not captured by
any consumer request. any consumer request.
- regulator-pull-down: Enable pull down resistor when the regulator is disabled. - regulator-pull-down: Enable pull down resistor when the regulator is disabled.
...@@ -68,6 +73,11 @@ Optional properties: ...@@ -68,6 +73,11 @@ Optional properties:
0: Disable active discharge. 0: Disable active discharge.
1: Enable active discharge. 1: Enable active discharge.
Absence of this property will leave configuration to default. Absence of this property will leave configuration to default.
- regulator-coupled-with: Regulators with which the regulator
is coupled. The linkage is 2-way - all coupled regulators should be linked
with each other. A regulator should not be coupled with its supplier.
- regulator-coupled-max-spread: Max spread between voltages of coupled regulators
in microvolts.
Deprecated properties: Deprecated properties:
- regulator-compatible: If a regulator chip contains multiple - regulator-compatible: If a regulator chip contains multiple
......
ROHM BD71837 Power Management Integrated Circuit (PMIC) regulator bindings
BD71837MWV is a programmable Power Management
IC (PMIC) for powering single-core, dual-core, and
quad-core SoC’s such as NXP-i.MX 8M. It is optimized
for low BOM cost and compact solution footprint. It
integrates 8 Buck regulators and 7 LDO’s to provide all
the power rails required by the SoC and the commonly
used peripherals.
Required properties:
- regulator-name: should be "buck1", ..., "buck8" and "ldo1", ..., "ldo7"
List of regulators provided by this controller. BD71837 regulators node
should be sub node of the BD71837 MFD node. See BD71837 MFD bindings at
Documentation/devicetree/bindings/mfd/rohm,bd71837-pmic.txt
Regulator nodes should be named to BUCK_<number> and LDO_<number>. The
definition for each of these nodes is defined using the standard
binding for regulators at
Documentation/devicetree/bindings/regulator/regulator.txt.
Note that if BD71837 starts at RUN state you probably want to use
regulator-boot-on at least for BUCK6 and BUCK7 so that those are not
disabled by driver at startup. LDO5 and LDO6 are supplied by those and
if they are disabled at startup the voltage monitoring for LDO5/LDO6 will
cause PMIC to reset.
The valid names for regulator nodes are:
BUCK1, BUCK2, BUCK3, BUCK4, BUCK5, BUCK6, BUCK7, BUCK8
LDO1, LDO2, LDO3, LDO4, LDO5, LDO6, LDO7
Optional properties:
- Any optional property defined in bindings/regulator/regulator.txt
Example:
regulators {
buck1: BUCK1 {
regulator-name = "buck1";
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <1300000>;
regulator-boot-on;
regulator-ramp-delay = <1250>;
};
buck2: BUCK2 {
regulator-name = "buck2";
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <1300000>;
regulator-boot-on;
regulator-always-on;
regulator-ramp-delay = <1250>;
};
buck3: BUCK3 {
regulator-name = "buck3";
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <1300000>;
regulator-boot-on;
};
buck4: BUCK4 {
regulator-name = "buck4";
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <1300000>;
regulator-boot-on;
};
buck5: BUCK5 {
regulator-name = "buck5";
regulator-min-microvolt = <700000>;
regulator-max-microvolt = <1350000>;
regulator-boot-on;
};
buck6: BUCK6 {
regulator-name = "buck6";
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
};
buck7: BUCK7 {
regulator-name = "buck7";
regulator-min-microvolt = <1605000>;
regulator-max-microvolt = <1995000>;
regulator-boot-on;
};
buck8: BUCK8 {
regulator-name = "buck8";
regulator-min-microvolt = <800000>;
regulator-max-microvolt = <1400000>;
};
ldo1: LDO1 {
regulator-name = "ldo1";
regulator-min-microvolt = <3000000>;
regulator-max-microvolt = <3300000>;
regulator-boot-on;
};
ldo2: LDO2 {
regulator-name = "ldo2";
regulator-min-microvolt = <900000>;
regulator-max-microvolt = <900000>;
regulator-boot-on;
};
ldo3: LDO3 {
regulator-name = "ldo3";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
};
ldo4: LDO4 {
regulator-name = "ldo4";
regulator-min-microvolt = <900000>;
regulator-max-microvolt = <1800000>;
};
ldo5: LDO5 {
regulator-name = "ldo5";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
};
ldo6: LDO6 {
regulator-name = "ldo6";
regulator-min-microvolt = <900000>;
regulator-max-microvolt = <1800000>;
};
ldo7_reg: LDO7 {
regulator-name = "ldo7";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <3300000>;
};
};
SY8106A Voltage regulator
Required properties:
- compatible: Must be "silergy,sy8106a"
- reg: I2C slave address - must be <0x65>
- silergy,fixed-microvolt - the voltage when I2C regulating is disabled (set
by external resistor like a fixed voltage)
Any property defined as part of the core regulator binding, defined in
./regulator.txt, can also be used.
Example:
sy8106a {
compatible = "silergy,sy8106a";
reg = <0x65>;
regulator-name = "sy8106a-vdd";
silergy,fixed-microvolt = <1200000>;
regulator-min-microvolt = <1000000>;
regulator-max-microvolt = <1400000>;
regulator-boot-on;
regulator-always-on;
};
...@@ -13609,6 +13609,12 @@ S: Supported ...@@ -13609,6 +13609,12 @@ S: Supported
F: net/switchdev/ F: net/switchdev/
F: include/net/switchdev.h F: include/net/switchdev.h
SY8106A REGULATOR DRIVER
M: Icenowy Zheng <icenowy@aosc.io>
S: Maintained
F: drivers/regulator/sy8106a-regulator.c
F: Documentation/devicetree/bindings/regulator/sy8106a-regulator.txt
SYNC FILE FRAMEWORK SYNC FILE FRAMEWORK
M: Sumit Semwal <sumit.semwal@linaro.org> M: Sumit Semwal <sumit.semwal@linaro.org>
R: Gustavo Padovan <gustavo@padovan.org> R: Gustavo Padovan <gustavo@padovan.org>
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/spi/spi.h> #include <linux/spi/spi.h>
#include <linux/gpio/machine.h>
#include <linux/mfd/wm831x/irq.h> #include <linux/mfd/wm831x/irq.h>
#include <linux/mfd/wm831x/gpio.h> #include <linux/mfd/wm831x/gpio.h>
...@@ -206,9 +207,6 @@ static const struct i2c_board_info wm1277_devs[] = { ...@@ -206,9 +207,6 @@ static const struct i2c_board_info wm1277_devs[] = {
}; };
static struct arizona_pdata wm5102_reva_pdata = { static struct arizona_pdata wm5102_reva_pdata = {
.ldo1 = {
.ldoena = S3C64XX_GPN(7),
},
.gpio_base = CODEC_GPIO_BASE, .gpio_base = CODEC_GPIO_BASE,
.irq_flags = IRQF_TRIGGER_HIGH, .irq_flags = IRQF_TRIGGER_HIGH,
.micd_pol_gpio = CODEC_GPIO_BASE + 4, .micd_pol_gpio = CODEC_GPIO_BASE + 4,
...@@ -237,10 +235,16 @@ static struct spi_board_info wm5102_reva_spi_devs[] = { ...@@ -237,10 +235,16 @@ static struct spi_board_info wm5102_reva_spi_devs[] = {
}, },
}; };
static struct arizona_pdata wm5102_pdata = { static struct gpiod_lookup_table wm5102_reva_gpiod_table = {
.ldo1 = { .dev_id = "spi0.1", /* SPI device name */
.ldoena = S3C64XX_GPN(7), .table = {
GPIO_LOOKUP("GPION", 7,
"wlf,ldoena", GPIO_ACTIVE_HIGH),
{ },
}, },
};
static struct arizona_pdata wm5102_pdata = {
.gpio_base = CODEC_GPIO_BASE, .gpio_base = CODEC_GPIO_BASE,
.irq_flags = IRQF_TRIGGER_HIGH, .irq_flags = IRQF_TRIGGER_HIGH,
.micd_pol_gpio = CODEC_GPIO_BASE + 2, .micd_pol_gpio = CODEC_GPIO_BASE + 2,
...@@ -264,6 +268,15 @@ static struct spi_board_info wm5102_spi_devs[] = { ...@@ -264,6 +268,15 @@ static struct spi_board_info wm5102_spi_devs[] = {
}, },
}; };
static struct gpiod_lookup_table wm5102_gpiod_table = {
.dev_id = "spi0.1", /* SPI device name */
.table = {
GPIO_LOOKUP("GPION", 7,
"wlf,ldo1ena", GPIO_ACTIVE_HIGH),
{ },
},
};
static struct spi_board_info wm5110_spi_devs[] = { static struct spi_board_info wm5110_spi_devs[] = {
[0] = { [0] = {
.modalias = "wm5110", .modalias = "wm5110",
...@@ -366,6 +379,9 @@ static int wlf_gf_module_probe(struct i2c_client *i2c, ...@@ -366,6 +379,9 @@ static int wlf_gf_module_probe(struct i2c_client *i2c,
rev == gf_mods[i].rev)) rev == gf_mods[i].rev))
break; break;
gpiod_add_lookup_table(&wm5102_reva_gpiod_table);
gpiod_add_lookup_table(&wm5102_gpiod_table);
if (i < ARRAY_SIZE(gf_mods)) { if (i < ARRAY_SIZE(gf_mods)) {
dev_info(&i2c->dev, "%s revision %d\n", dev_info(&i2c->dev, "%s revision %d\n",
gf_mods[i].name, rev + 1); gf_mods[i].name, rev + 1);
......
...@@ -29,6 +29,7 @@ static const struct mfd_cell bd9571mwv_cells[] = { ...@@ -29,6 +29,7 @@ static const struct mfd_cell bd9571mwv_cells[] = {
static const struct regmap_range bd9571mwv_readable_yes_ranges[] = { static const struct regmap_range bd9571mwv_readable_yes_ranges[] = {
regmap_reg_range(BD9571MWV_VENDOR_CODE, BD9571MWV_PRODUCT_REVISION), regmap_reg_range(BD9571MWV_VENDOR_CODE, BD9571MWV_PRODUCT_REVISION),
regmap_reg_range(BD9571MWV_BKUP_MODE_CNT, BD9571MWV_BKUP_MODE_CNT),
regmap_reg_range(BD9571MWV_AVS_SET_MONI, BD9571MWV_AVS_DVFS_VID(3)), regmap_reg_range(BD9571MWV_AVS_SET_MONI, BD9571MWV_AVS_DVFS_VID(3)),
regmap_reg_range(BD9571MWV_VD18_VID, BD9571MWV_VD33_VID), regmap_reg_range(BD9571MWV_VD18_VID, BD9571MWV_VD33_VID),
regmap_reg_range(BD9571MWV_DVFS_VINIT, BD9571MWV_DVFS_VINIT), regmap_reg_range(BD9571MWV_DVFS_VINIT, BD9571MWV_DVFS_VINIT),
...@@ -44,6 +45,7 @@ static const struct regmap_access_table bd9571mwv_readable_table = { ...@@ -44,6 +45,7 @@ static const struct regmap_access_table bd9571mwv_readable_table = {
}; };
static const struct regmap_range bd9571mwv_writable_yes_ranges[] = { static const struct regmap_range bd9571mwv_writable_yes_ranges[] = {
regmap_reg_range(BD9571MWV_BKUP_MODE_CNT, BD9571MWV_BKUP_MODE_CNT),
regmap_reg_range(BD9571MWV_AVS_VD09_VID(0), BD9571MWV_AVS_VD09_VID(3)), regmap_reg_range(BD9571MWV_AVS_VD09_VID(0), BD9571MWV_AVS_VD09_VID(3)),
regmap_reg_range(BD9571MWV_DVFS_SETVID, BD9571MWV_DVFS_SETVID), regmap_reg_range(BD9571MWV_DVFS_SETVID, BD9571MWV_DVFS_SETVID),
regmap_reg_range(BD9571MWV_GPIO_DIR, BD9571MWV_GPIO_OUT), regmap_reg_range(BD9571MWV_GPIO_DIR, BD9571MWV_GPIO_OUT),
......
...@@ -180,6 +180,17 @@ config REGULATOR_BCM590XX ...@@ -180,6 +180,17 @@ config REGULATOR_BCM590XX
BCM590xx PMUs. This will enable support for the software BCM590xx PMUs. This will enable support for the software
controllable LDO/Switching regulators. controllable LDO/Switching regulators.
config REGULATOR_BD71837
tristate "ROHM BD71837 Power Regulator"
depends on MFD_BD71837
help
This driver supports voltage regulators on ROHM BD71837 PMIC.
This will enable support for the software controllable buck
and LDO regulators.
This driver can also be built as a module. If so, the module
will be called bd71837-regulator.
config REGULATOR_BD9571MWV config REGULATOR_BD9571MWV
tristate "ROHM BD9571MWV Regulators" tristate "ROHM BD9571MWV Regulators"
depends on MFD_BD9571MWV depends on MFD_BD9571MWV
...@@ -801,6 +812,13 @@ config REGULATOR_STW481X_VMMC ...@@ -801,6 +812,13 @@ config REGULATOR_STW481X_VMMC
This driver supports the internal VMMC regulator in the STw481x This driver supports the internal VMMC regulator in the STw481x
PMIC chips. PMIC chips.
config REGULATOR_SY8106A
tristate "Silergy SY8106A regulator"
depends on I2C && (OF || COMPILE_TEST)
select REGMAP_I2C
help
This driver supports SY8106A single output regulator.
config REGULATOR_TPS51632 config REGULATOR_TPS51632
tristate "TI TPS51632 Power Regulator" tristate "TI TPS51632 Power Regulator"
depends on I2C depends on I2C
......
...@@ -27,6 +27,7 @@ obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o ...@@ -27,6 +27,7 @@ obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o
obj-$(CONFIG_REGULATOR_BD71837) += bd71837-regulator.o
obj-$(CONFIG_REGULATOR_BD9571MWV) += bd9571mwv-regulator.o obj-$(CONFIG_REGULATOR_BD9571MWV) += bd9571mwv-regulator.o
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
...@@ -100,6 +101,7 @@ obj-$(CONFIG_REGULATOR_SC2731) += sc2731-regulator.o ...@@ -100,6 +101,7 @@ 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_STW481X_VMMC) += stw481x-vmmc.o obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
obj-$(CONFIG_REGULATOR_SY8106A) += sy8106a-regulator.o
obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o obj-$(CONFIG_REGULATOR_TPS62360) += tps62360-regulator.o
...@@ -125,5 +127,4 @@ obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o ...@@ -125,5 +127,4 @@ obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o obj-$(CONFIG_REGULATOR_WM8994) += wm8994-regulator.o
ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG ccflags-$(CONFIG_REGULATOR_DEBUG) += -DDEBUG
This diff is collapsed.
/* // SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved. //
*/ // Copyright (C) 2011 Freescale Semiconductor, Inc. All Rights Reserved.
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/device.h> #include <linux/device.h>
......
...@@ -17,12 +17,11 @@ ...@@ -17,12 +17,11 @@
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h> #include <linux/gpio/consumer.h>
#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>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/gpio.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/regulator/arizona-ldo1.h> #include <linux/regulator/arizona-ldo1.h>
...@@ -198,16 +197,6 @@ static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata, ...@@ -198,16 +197,6 @@ static int arizona_ldo1_of_get_pdata(struct arizona_ldo1_pdata *pdata,
struct device_node *init_node, *dcvdd_node; struct device_node *init_node, *dcvdd_node;
struct regulator_init_data *init_data; struct regulator_init_data *init_data;
pdata->ldoena = of_get_named_gpio(np, "wlf,ldoena", 0);
if (pdata->ldoena < 0) {
dev_warn(config->dev,
"LDOENA GPIO property missing/malformed: %d\n",
pdata->ldoena);
pdata->ldoena = 0;
} else {
config->ena_gpio_initialized = true;
}
init_node = of_get_child_by_name(np, "ldo1"); init_node = of_get_child_by_name(np, "ldo1");
dcvdd_node = of_parse_phandle(np, "DCVDD-supply", 0); dcvdd_node = of_parse_phandle(np, "DCVDD-supply", 0);
...@@ -264,7 +253,11 @@ static int arizona_ldo1_common_init(struct platform_device *pdev, ...@@ -264,7 +253,11 @@ static int arizona_ldo1_common_init(struct platform_device *pdev,
} }
} }
config.ena_gpio = pdata->ldoena; /* We assume that high output = regulator off */
config.ena_gpiod = devm_gpiod_get_optional(&pdev->dev, "wlf,ldoena",
GPIOD_OUT_HIGH);
if (IS_ERR(config.ena_gpiod))
return PTR_ERR(config.ena_gpiod);
if (pdata->init_data) if (pdata->init_data)
config.init_data = pdata->init_data; config.init_data = pdata->init_data;
......
...@@ -721,6 +721,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev) ...@@ -721,6 +721,8 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
case AXP803_ID: case AXP803_ID:
regulators = axp803_regulators; regulators = axp803_regulators;
nregulators = AXP803_REG_ID_MAX; nregulators = AXP803_REG_ID_MAX;
drivevbus = of_property_read_bool(pdev->dev.parent->of_node,
"x-powers,drive-vbus-en");
break; break;
case AXP806_ID: case AXP806_ID:
regulators = axp806_regulators; regulators = axp806_regulators;
......
This diff is collapsed.
...@@ -24,6 +24,18 @@ ...@@ -24,6 +24,18 @@
#include <linux/mfd/bd9571mwv.h> #include <linux/mfd/bd9571mwv.h>
struct bd9571mwv_reg {
struct bd9571mwv *bd;
/* DDR Backup Power */
u8 bkup_mode_cnt_keepon; /* from "rohm,ddr-backup-power" */
u8 bkup_mode_cnt_saved;
/* Power switch type */
bool rstbmode_level;
bool rstbmode_pulse;
};
enum bd9571mwv_regulators { VD09, VD18, VD25, VD33, DVFS }; enum bd9571mwv_regulators { VD09, VD18, VD25, VD33, DVFS };
#define BD9571MWV_REG(_name, _of, _id, _ops, _vr, _vm, _nv, _min, _step, _lmin)\ #define BD9571MWV_REG(_name, _of, _id, _ops, _vr, _vm, _nv, _min, _step, _lmin)\
...@@ -131,14 +143,99 @@ static struct regulator_desc regulators[] = { ...@@ -131,14 +143,99 @@ static struct regulator_desc regulators[] = {
0x80, 600000, 10000, 0x3c), 0x80, 600000, 10000, 0x3c),
}; };
#ifdef CONFIG_PM_SLEEP
static int bd9571mwv_bkup_mode_read(struct bd9571mwv *bd, unsigned int *mode)
{
int ret;
ret = regmap_read(bd->regmap, BD9571MWV_BKUP_MODE_CNT, mode);
if (ret) {
dev_err(bd->dev, "failed to read backup mode (%d)\n", ret);
return ret;
}
return 0;
}
static int bd9571mwv_bkup_mode_write(struct bd9571mwv *bd, unsigned int mode)
{
int ret;
ret = regmap_write(bd->regmap, BD9571MWV_BKUP_MODE_CNT, mode);
if (ret) {
dev_err(bd->dev, "failed to configure backup mode 0x%x (%d)\n",
mode, ret);
return ret;
}
return 0;
}
static int bd9571mwv_suspend(struct device *dev)
{
struct bd9571mwv_reg *bdreg = dev_get_drvdata(dev);
unsigned int mode;
int ret;
if (!device_may_wakeup(dev))
return 0;
/* Save DDR Backup Mode */
ret = bd9571mwv_bkup_mode_read(bdreg->bd, &mode);
if (ret)
return ret;
bdreg->bkup_mode_cnt_saved = mode;
if (!bdreg->rstbmode_pulse)
return 0;
/* Enable DDR Backup Mode */
mode &= ~BD9571MWV_BKUP_MODE_CNT_KEEPON_MASK;
mode |= bdreg->bkup_mode_cnt_keepon;
if (mode != bdreg->bkup_mode_cnt_saved)
return bd9571mwv_bkup_mode_write(bdreg->bd, mode);
return 0;
}
static int bd9571mwv_resume(struct device *dev)
{
struct bd9571mwv_reg *bdreg = dev_get_drvdata(dev);
if (!device_may_wakeup(dev))
return 0;
/* Restore DDR Backup Mode */
return bd9571mwv_bkup_mode_write(bdreg->bd, bdreg->bkup_mode_cnt_saved);
}
static const struct dev_pm_ops bd9571mwv_pm = {
SET_SYSTEM_SLEEP_PM_OPS(bd9571mwv_suspend, bd9571mwv_resume)
};
#define DEV_PM_OPS &bd9571mwv_pm
#else
#define DEV_PM_OPS NULL
#endif /* CONFIG_PM_SLEEP */
static int bd9571mwv_regulator_probe(struct platform_device *pdev) static int bd9571mwv_regulator_probe(struct platform_device *pdev)
{ {
struct bd9571mwv *bd = dev_get_drvdata(pdev->dev.parent); struct bd9571mwv *bd = dev_get_drvdata(pdev->dev.parent);
struct regulator_config config = { }; struct regulator_config config = { };
struct bd9571mwv_reg *bdreg;
struct regulator_dev *rdev; struct regulator_dev *rdev;
unsigned int val;
int i; int i;
platform_set_drvdata(pdev, bd); bdreg = devm_kzalloc(&pdev->dev, sizeof(*bdreg), GFP_KERNEL);
if (!bdreg)
return -ENOMEM;
bdreg->bd = bd;
platform_set_drvdata(pdev, bdreg);
config.dev = &pdev->dev; config.dev = &pdev->dev;
config.dev->of_node = bd->dev->of_node; config.dev->of_node = bd->dev->of_node;
...@@ -155,6 +252,33 @@ static int bd9571mwv_regulator_probe(struct platform_device *pdev) ...@@ -155,6 +252,33 @@ static int bd9571mwv_regulator_probe(struct platform_device *pdev)
} }
} }
val = 0;
of_property_read_u32(bd->dev->of_node, "rohm,ddr-backup-power", &val);
if (val & ~BD9571MWV_BKUP_MODE_CNT_KEEPON_MASK) {
dev_err(bd->dev, "invalid %s mode %u\n",
"rohm,ddr-backup-power", val);
return -EINVAL;
}
bdreg->bkup_mode_cnt_keepon = val;
bdreg->rstbmode_level = of_property_read_bool(bd->dev->of_node,
"rohm,rstbmode-level");
bdreg->rstbmode_pulse = of_property_read_bool(bd->dev->of_node,
"rohm,rstbmode-pulse");
if (bdreg->rstbmode_level && bdreg->rstbmode_pulse) {
dev_err(bd->dev, "only one rohm,rstbmode-* may be specified");
return -EINVAL;
}
if (bdreg->bkup_mode_cnt_keepon) {
device_set_wakeup_capable(&pdev->dev, true);
/*
* Wakeup is enabled by default in pulse mode, but needs
* explicit user setup in level mode.
*/
device_set_wakeup_enable(&pdev->dev, bdreg->rstbmode_pulse);
}
return 0; return 0;
} }
...@@ -167,6 +291,7 @@ MODULE_DEVICE_TABLE(platform, bd9571mwv_regulator_id_table); ...@@ -167,6 +291,7 @@ MODULE_DEVICE_TABLE(platform, bd9571mwv_regulator_id_table);
static struct platform_driver bd9571mwv_regulator_driver = { static struct platform_driver bd9571mwv_regulator_driver = {
.driver = { .driver = {
.name = "bd9571mwv-regulator", .name = "bd9571mwv-regulator",
.pm = DEV_PM_OPS,
}, },
.probe = bd9571mwv_regulator_probe, .probe = bd9571mwv_regulator_probe,
.id_table = bd9571mwv_regulator_id_table, .id_table = bd9571mwv_regulator_id_table,
......
This diff is collapsed.
...@@ -222,7 +222,7 @@ static unsigned int cpcap_map_mode(unsigned int mode) ...@@ -222,7 +222,7 @@ static unsigned int cpcap_map_mode(unsigned int mode)
case CPCAP_BIT_AUDIO_LOW_PWR: case CPCAP_BIT_AUDIO_LOW_PWR:
return REGULATOR_MODE_STANDBY; return REGULATOR_MODE_STANDBY;
default: default:
return -EINVAL; return REGULATOR_MODE_INVALID;
} }
} }
......
...@@ -56,14 +56,27 @@ static inline struct regulator_dev *dev_to_rdev(struct device *dev) ...@@ -56,14 +56,27 @@ static inline struct regulator_dev *dev_to_rdev(struct device *dev)
return container_of(dev, struct regulator_dev, dev); return container_of(dev, struct regulator_dev, dev);
} }
struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
#ifdef CONFIG_OF #ifdef CONFIG_OF
struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
struct regulator_init_data *regulator_of_get_init_data(struct device *dev, struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
const struct regulator_desc *desc, const struct regulator_desc *desc,
struct regulator_config *config, struct regulator_config *config,
struct device_node **node); struct device_node **node);
struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
int index);
int of_get_n_coupled(struct regulator_dev *rdev);
bool of_check_coupling_data(struct regulator_dev *rdev);
#else #else
static inline struct regulator_dev *
of_find_regulator_by_node(struct device_node *np)
{
return NULL;
}
static inline struct regulator_init_data * static inline struct regulator_init_data *
regulator_of_get_init_data(struct device *dev, regulator_of_get_init_data(struct device *dev,
const struct regulator_desc *desc, const struct regulator_desc *desc,
...@@ -72,8 +85,25 @@ regulator_of_get_init_data(struct device *dev, ...@@ -72,8 +85,25 @@ regulator_of_get_init_data(struct device *dev,
{ {
return NULL; return NULL;
} }
#endif
static inline struct regulator_dev *
of_parse_coupled_regulator(struct regulator_dev *rdev,
int index)
{
return NULL;
}
static inline int of_get_n_coupled(struct regulator_dev *rdev)
{
return 0;
}
static inline bool of_check_coupling_data(struct regulator_dev *rdev)
{
return false;
}
#endif
enum regulator_get_type { enum regulator_get_type {
NORMAL_GET, NORMAL_GET,
EXCLUSIVE_GET, EXCLUSIVE_GET,
...@@ -83,5 +113,4 @@ enum regulator_get_type { ...@@ -83,5 +113,4 @@ enum regulator_get_type {
struct regulator *_regulator_get(struct device *dev, const char *id, struct regulator *_regulator_get(struct device *dev, const char *id,
enum regulator_get_type get_type); enum regulator_get_type get_type);
#endif #endif
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <linux/mfd/ti-lmu-register.h> #include <linux/mfd/ti-lmu-register.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h> #include <linux/gpio/consumer.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
...@@ -219,7 +219,7 @@ static const struct regulator_desc lm363x_regulator_desc[] = { ...@@ -219,7 +219,7 @@ static const struct regulator_desc lm363x_regulator_desc[] = {
}, },
}; };
static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) static struct gpio_desc *lm363x_regulator_of_get_enable_gpio(struct device *dev, int id)
{ {
/* /*
* Check LCM_EN1/2_GPIO is configured. * Check LCM_EN1/2_GPIO is configured.
...@@ -227,11 +227,11 @@ static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id) ...@@ -227,11 +227,11 @@ static int lm363x_regulator_of_get_enable_gpio(struct device_node *np, int id)
*/ */
switch (id) { switch (id) {
case LM3632_LDO_POS: case LM3632_LDO_POS:
return of_get_named_gpio(np, "enable-gpios", 0); return devm_gpiod_get_index_optional(dev, "enable", 0, GPIOD_OUT_LOW);
case LM3632_LDO_NEG: case LM3632_LDO_NEG:
return of_get_named_gpio(np, "enable-gpios", 1); return devm_gpiod_get_index_optional(dev, "enable", 1, GPIOD_OUT_LOW);
default: default:
return -EINVAL; return NULL;
} }
} }
...@@ -243,7 +243,8 @@ static int lm363x_regulator_probe(struct platform_device *pdev) ...@@ -243,7 +243,8 @@ static int lm363x_regulator_probe(struct platform_device *pdev)
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int id = pdev->id; int id = pdev->id;
int ret, ena_gpio; struct gpio_desc *gpiod;
int ret;
cfg.dev = dev; cfg.dev = dev;
cfg.regmap = regmap; cfg.regmap = regmap;
...@@ -252,10 +253,9 @@ static int lm363x_regulator_probe(struct platform_device *pdev) ...@@ -252,10 +253,9 @@ static int lm363x_regulator_probe(struct platform_device *pdev)
* LM3632 LDOs can be controlled by external pin. * LM3632 LDOs can be controlled by external pin.
* Register update is required if the pin is used. * Register update is required if the pin is used.
*/ */
ena_gpio = lm363x_regulator_of_get_enable_gpio(dev->of_node, id); gpiod = lm363x_regulator_of_get_enable_gpio(dev, id);
if (gpio_is_valid(ena_gpio)) { if (gpiod) {
cfg.ena_gpio = ena_gpio; cfg.ena_gpiod = gpiod;
cfg.ena_gpio_flags = GPIOF_OUT_INIT_LOW;
ret = regmap_update_bits(regmap, LM3632_REG_BIAS_CONFIG, ret = regmap_update_bits(regmap, LM3632_REG_BIAS_CONFIG,
LM3632_EXT_EN_MASK, LM3632_EXT_EN_MASK,
......
...@@ -95,6 +95,10 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev *rdev, ...@@ -95,6 +95,10 @@ static int lp87565_buck_set_ramp_delay(struct regulator_dev *rdev,
rdev->constraints->ramp_delay = lp87565_buck_ramp_delay[reg]; rdev->constraints->ramp_delay = lp87565_buck_ramp_delay[reg];
/* Conservatively give a 15% margin */
rdev->constraints->ramp_delay =
rdev->constraints->ramp_delay * 85 / 100;
return 0; return 0;
} }
...@@ -154,32 +158,33 @@ static const struct lp87565_regulator regulators[] = { ...@@ -154,32 +158,33 @@ static const struct lp87565_regulator regulators[] = {
LP87565_REGULATOR("BUCK0", LP87565_BUCK_0, "buck0", lp87565_buck_ops, LP87565_REGULATOR("BUCK0", LP87565_BUCK_0, "buck0", lp87565_buck_ops,
256, LP87565_REG_BUCK0_VOUT, LP87565_BUCK_VSET, 256, LP87565_REG_BUCK0_VOUT, LP87565_BUCK_VSET,
LP87565_REG_BUCK0_CTRL_1, LP87565_REG_BUCK0_CTRL_1,
LP87565_BUCK_CTRL_1_EN, 3800, LP87565_BUCK_CTRL_1_EN, 3230,
buck0_1_2_3_ranges, LP87565_REG_BUCK0_CTRL_2), buck0_1_2_3_ranges, LP87565_REG_BUCK0_CTRL_2),
LP87565_REGULATOR("BUCK1", LP87565_BUCK_1, "buck1", lp87565_buck_ops, LP87565_REGULATOR("BUCK1", LP87565_BUCK_1, "buck1", lp87565_buck_ops,
256, LP87565_REG_BUCK1_VOUT, LP87565_BUCK_VSET, 256, LP87565_REG_BUCK1_VOUT, LP87565_BUCK_VSET,
LP87565_REG_BUCK1_CTRL_1, LP87565_REG_BUCK1_CTRL_1,
LP87565_BUCK_CTRL_1_EN, 3800, LP87565_BUCK_CTRL_1_EN, 3230,
buck0_1_2_3_ranges, LP87565_REG_BUCK1_CTRL_2), buck0_1_2_3_ranges, LP87565_REG_BUCK1_CTRL_2),
LP87565_REGULATOR("BUCK2", LP87565_BUCK_2, "buck2", lp87565_buck_ops, LP87565_REGULATOR("BUCK2", LP87565_BUCK_2, "buck2", lp87565_buck_ops,
256, LP87565_REG_BUCK2_VOUT, LP87565_BUCK_VSET, 256, LP87565_REG_BUCK2_VOUT, LP87565_BUCK_VSET,
LP87565_REG_BUCK2_CTRL_1, LP87565_REG_BUCK2_CTRL_1,
LP87565_BUCK_CTRL_1_EN, 3800, LP87565_BUCK_CTRL_1_EN, 3230,
buck0_1_2_3_ranges, LP87565_REG_BUCK2_CTRL_2), buck0_1_2_3_ranges, LP87565_REG_BUCK2_CTRL_2),
LP87565_REGULATOR("BUCK3", LP87565_BUCK_3, "buck3", lp87565_buck_ops, LP87565_REGULATOR("BUCK3", LP87565_BUCK_3, "buck3", lp87565_buck_ops,
256, LP87565_REG_BUCK3_VOUT, LP87565_BUCK_VSET, 256, LP87565_REG_BUCK3_VOUT, LP87565_BUCK_VSET,
LP87565_REG_BUCK3_CTRL_1, LP87565_REG_BUCK3_CTRL_1,
LP87565_BUCK_CTRL_1_EN, 3800, LP87565_BUCK_CTRL_1_EN, 3230,
buck0_1_2_3_ranges, LP87565_REG_BUCK3_CTRL_2), buck0_1_2_3_ranges, LP87565_REG_BUCK3_CTRL_2),
LP87565_REGULATOR("BUCK10", LP87565_BUCK_10, "buck10", lp87565_buck_ops, LP87565_REGULATOR("BUCK10", LP87565_BUCK_10, "buck10", lp87565_buck_ops,
256, LP87565_REG_BUCK0_VOUT, LP87565_BUCK_VSET, 256, LP87565_REG_BUCK0_VOUT, LP87565_BUCK_VSET,
LP87565_REG_BUCK0_CTRL_1, LP87565_REG_BUCK0_CTRL_1,
LP87565_BUCK_CTRL_1_EN, 3800, LP87565_BUCK_CTRL_1_EN |
LP87565_BUCK_CTRL_1_FPWM_MP_0_2, 3230,
buck0_1_2_3_ranges, LP87565_REG_BUCK0_CTRL_2), buck0_1_2_3_ranges, LP87565_REG_BUCK0_CTRL_2),
LP87565_REGULATOR("BUCK23", LP87565_BUCK_23, "buck23", lp87565_buck_ops, LP87565_REGULATOR("BUCK23", LP87565_BUCK_23, "buck23", lp87565_buck_ops,
256, LP87565_REG_BUCK2_VOUT, LP87565_BUCK_VSET, 256, LP87565_REG_BUCK2_VOUT, LP87565_BUCK_VSET,
LP87565_REG_BUCK2_CTRL_1, LP87565_REG_BUCK2_CTRL_1,
LP87565_BUCK_CTRL_1_EN, 3800, LP87565_BUCK_CTRL_1_EN, 3230,
buck0_1_2_3_ranges, LP87565_REG_BUCK2_CTRL_2), buck0_1_2_3_ranges, LP87565_REG_BUCK2_CTRL_2),
}; };
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/gpio.h> #include <linux/gpio/consumer.h>
#include <linux/mfd/lp8788.h> #include <linux/mfd/lp8788.h>
/* register address */ /* register address */
...@@ -85,8 +85,6 @@ ...@@ -85,8 +85,6 @@
#define LP8788_STARTUP_TIME_S 3 #define LP8788_STARTUP_TIME_S 3
#define ENABLE_TIME_USEC 32 #define ENABLE_TIME_USEC 32
#define ENABLE GPIOF_OUT_INIT_HIGH
#define DISABLE GPIOF_OUT_INIT_LOW
enum lp8788_ldo_id { enum lp8788_ldo_id {
DLDO1, DLDO1,
...@@ -117,7 +115,7 @@ struct lp8788_ldo { ...@@ -117,7 +115,7 @@ struct lp8788_ldo {
struct lp8788 *lp; struct lp8788 *lp;
struct regulator_desc *desc; struct regulator_desc *desc;
struct regulator_dev *regulator; struct regulator_dev *regulator;
struct lp8788_ldo_enable_pin *en_pin; struct gpio_desc *ena_gpiod;
}; };
/* DLDO 1, 2, 3, 9 voltage table */ /* DLDO 1, 2, 3, 9 voltage table */
...@@ -469,7 +467,6 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, ...@@ -469,7 +467,6 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev,
enum lp8788_ldo_id id) enum lp8788_ldo_id id)
{ {
struct lp8788 *lp = ldo->lp; struct lp8788 *lp = ldo->lp;
struct lp8788_platform_data *pdata = lp->pdata;
enum lp8788_ext_ldo_en_id enable_id; enum lp8788_ext_ldo_en_id enable_id;
u8 en_mask[] = { u8 en_mask[] = {
[EN_ALDO1] = LP8788_EN_SEL_ALDO1_M, [EN_ALDO1] = LP8788_EN_SEL_ALDO1_M,
...@@ -504,11 +501,18 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, ...@@ -504,11 +501,18 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev,
return 0; return 0;
} }
/* if no platform data for ldo pin, then set default enable mode */ /* FIXME: check default mode for GPIO here: high or low? */
if (!pdata || !pdata->ldo_pin || !pdata->ldo_pin[enable_id]) ldo->ena_gpiod = devm_gpiod_get_index_optional(&pdev->dev,
"enable",
enable_id,
GPIOD_OUT_HIGH);
if (IS_ERR(ldo->ena_gpiod))
return PTR_ERR(ldo->ena_gpiod);
/* if no GPIO for ldo pin, then set default enable mode */
if (!ldo->ena_gpiod)
goto set_default_ldo_enable_mode; goto set_default_ldo_enable_mode;
ldo->en_pin = pdata->ldo_pin[enable_id];
return 0; return 0;
set_default_ldo_enable_mode: set_default_ldo_enable_mode:
...@@ -533,10 +537,8 @@ static int lp8788_dldo_probe(struct platform_device *pdev) ...@@ -533,10 +537,8 @@ static int lp8788_dldo_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
if (ldo->en_pin) { if (ldo->ena_gpiod)
cfg.ena_gpio = ldo->en_pin->gpio; cfg.ena_gpiod = ldo->ena_gpiod;
cfg.ena_gpio_flags = ldo->en_pin->init_state;
}
cfg.dev = pdev->dev.parent; cfg.dev = pdev->dev.parent;
cfg.init_data = lp->pdata ? lp->pdata->dldo_data[id] : NULL; cfg.init_data = lp->pdata ? lp->pdata->dldo_data[id] : NULL;
...@@ -582,10 +584,8 @@ static int lp8788_aldo_probe(struct platform_device *pdev) ...@@ -582,10 +584,8 @@ static int lp8788_aldo_probe(struct platform_device *pdev)
if (ret) if (ret)
return ret; return ret;
if (ldo->en_pin) { if (ldo->ena_gpiod)
cfg.ena_gpio = ldo->en_pin->gpio; cfg.ena_gpiod = ldo->ena_gpiod;
cfg.ena_gpio_flags = ldo->en_pin->init_state;
}
cfg.dev = pdev->dev.parent; cfg.dev = pdev->dev.parent;
cfg.init_data = lp->pdata ? lp->pdata->aldo_data[id] : NULL; cfg.init_data = lp->pdata ? lp->pdata->aldo_data[id] : NULL;
......
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#define LTC3676_CLIRQ 0x1F #define LTC3676_CLIRQ 0x1F
#define LTC3676_DVBxA_REF_SELECT BIT(5) #define LTC3676_DVBxA_REF_SELECT BIT(5)
#define LTC3676_DVBxB_PGOOD_MASK BIT(5)
#define LTC3676_IRQSTAT_PGOOD_TIMEOUT BIT(3) #define LTC3676_IRQSTAT_PGOOD_TIMEOUT BIT(3)
#define LTC3676_IRQSTAT_UNDERVOLT_WARN BIT(4) #define LTC3676_IRQSTAT_UNDERVOLT_WARN BIT(4)
...@@ -123,6 +124,23 @@ static int ltc3676_set_suspend_mode(struct regulator_dev *rdev, ...@@ -123,6 +124,23 @@ static int ltc3676_set_suspend_mode(struct regulator_dev *rdev,
mask, val); mask, val);
} }
static int ltc3676_set_voltage_sel(struct regulator_dev *rdev, unsigned selector)
{
struct ltc3676 *ltc3676 = rdev_get_drvdata(rdev);
struct device *dev = ltc3676->dev;
int ret, dcdc = rdev_get_id(rdev);
dev_dbg(dev, "%s id=%d selector=%d\n", __func__, dcdc, selector);
ret = regmap_update_bits(ltc3676->regmap, rdev->desc->vsel_reg + 1,
LTC3676_DVBxB_PGOOD_MASK,
LTC3676_DVBxB_PGOOD_MASK);
if (ret)
return ret;
return regulator_set_voltage_sel_regmap(rdev, selector);
}
static inline unsigned int ltc3676_scale(unsigned int uV, u32 r1, u32 r2) static inline unsigned int ltc3676_scale(unsigned int uV, u32 r1, u32 r2)
{ {
uint64_t tmp; uint64_t tmp;
...@@ -166,7 +184,7 @@ static const struct regulator_ops ltc3676_linear_regulator_ops = { ...@@ -166,7 +184,7 @@ static const struct regulator_ops ltc3676_linear_regulator_ops = {
.disable = regulator_disable_regmap, .disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap, .is_enabled = regulator_is_enabled_regmap,
.list_voltage = regulator_list_voltage_linear, .list_voltage = regulator_list_voltage_linear,
.set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_sel = ltc3676_set_voltage_sel,
.get_voltage_sel = regulator_get_voltage_sel_regmap, .get_voltage_sel = regulator_get_voltage_sel_regmap,
.set_suspend_voltage = ltc3676_set_suspend_voltage, .set_suspend_voltage = ltc3676_set_suspend_voltage,
.set_suspend_mode = ltc3676_set_suspend_mode, .set_suspend_mode = ltc3676_set_suspend_mode,
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regulator/max8952.h> #include <linux/regulator/max8952.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
...@@ -148,7 +149,6 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev) ...@@ -148,7 +149,6 @@ static struct max8952_platform_data *max8952_parse_dt(struct device *dev)
pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0); pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0);
pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1); pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1);
pd->gpio_en = of_get_named_gpio(np, "max8952,en-gpio", 0);
if (of_property_read_u32(np, "max8952,default-mode", &pd->default_mode)) if (of_property_read_u32(np, "max8952,default-mode", &pd->default_mode))
dev_warn(dev, "Default mode not specified, assuming 0\n"); dev_warn(dev, "Default mode not specified, assuming 0\n");
...@@ -197,6 +197,8 @@ static int max8952_pmic_probe(struct i2c_client *client, ...@@ -197,6 +197,8 @@ static int max8952_pmic_probe(struct i2c_client *client,
struct regulator_config config = { }; struct regulator_config config = { };
struct max8952_data *max8952; struct max8952_data *max8952;
struct regulator_dev *rdev; struct regulator_dev *rdev;
struct gpio_desc *gpiod;
enum gpiod_flags gflags;
int ret = 0, err = 0; int ret = 0, err = 0;
...@@ -224,11 +226,17 @@ static int max8952_pmic_probe(struct i2c_client *client, ...@@ -224,11 +226,17 @@ static int max8952_pmic_probe(struct i2c_client *client,
config.driver_data = max8952; config.driver_data = max8952;
config.of_node = client->dev.of_node; config.of_node = client->dev.of_node;
config.ena_gpio = pdata->gpio_en;
if (client->dev.of_node)
config.ena_gpio_initialized = true;
if (pdata->reg_data->constraints.boot_on) if (pdata->reg_data->constraints.boot_on)
config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; gflags = GPIOD_OUT_HIGH;
else
gflags = GPIOD_OUT_LOW;
gpiod = devm_gpiod_get_optional(&client->dev,
"max8952,en",
gflags);
if (IS_ERR(gpiod))
return PTR_ERR(gpiod);
if (gpiod)
config.ena_gpiod = gpiod;
rdev = devm_regulator_register(&client->dev, &regulator, &config); rdev = devm_regulator_register(&client->dev, &regulator, &config);
if (IS_ERR(rdev)) { if (IS_ERR(rdev)) {
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/regulator/max8973-regulator.h> #include <linux/regulator/max8973-regulator.h>
#include <linux/regulator/of_regulator.h> #include <linux/regulator/of_regulator.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/i2c.h> #include <linux/i2c.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -114,7 +115,6 @@ struct max8973_chip { ...@@ -114,7 +115,6 @@ struct max8973_chip {
struct regulator_desc desc; struct regulator_desc desc;
struct regmap *regmap; struct regmap *regmap;
bool enable_external_control; bool enable_external_control;
int enable_gpio;
int dvs_gpio; int dvs_gpio;
int lru_index[MAX8973_MAX_VOUT_REG]; int lru_index[MAX8973_MAX_VOUT_REG];
int curr_vout_val[MAX8973_MAX_VOUT_REG]; int curr_vout_val[MAX8973_MAX_VOUT_REG];
...@@ -567,7 +567,6 @@ static struct max8973_regulator_platform_data *max8973_parse_dt( ...@@ -567,7 +567,6 @@ static struct max8973_regulator_platform_data *max8973_parse_dt(
pdata->enable_ext_control = of_property_read_bool(np, pdata->enable_ext_control = of_property_read_bool(np,
"maxim,externally-enable"); "maxim,externally-enable");
pdata->enable_gpio = of_get_named_gpio(np, "maxim,enable-gpio", 0);
pdata->dvs_gpio = of_get_named_gpio(np, "maxim,dvs-gpio", 0); pdata->dvs_gpio = of_get_named_gpio(np, "maxim,dvs-gpio", 0);
ret = of_property_read_u32(np, "maxim,dvs-default-state", &pval); ret = of_property_read_u32(np, "maxim,dvs-default-state", &pval);
...@@ -633,6 +632,8 @@ static int max8973_probe(struct i2c_client *client, ...@@ -633,6 +632,8 @@ static int max8973_probe(struct i2c_client *client,
struct max8973_chip *max; struct max8973_chip *max;
bool pdata_from_dt = false; bool pdata_from_dt = false;
unsigned int chip_id; unsigned int chip_id;
struct gpio_desc *gpiod;
enum gpiod_flags gflags;
int ret; int ret;
pdata = dev_get_platdata(&client->dev); pdata = dev_get_platdata(&client->dev);
...@@ -647,8 +648,7 @@ static int max8973_probe(struct i2c_client *client, ...@@ -647,8 +648,7 @@ static int max8973_probe(struct i2c_client *client,
return -EIO; return -EIO;
} }
if ((pdata->dvs_gpio == -EPROBE_DEFER) || if (pdata->dvs_gpio == -EPROBE_DEFER)
(pdata->enable_gpio == -EPROBE_DEFER))
return -EPROBE_DEFER; return -EPROBE_DEFER;
max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL); max = devm_kzalloc(&client->dev, sizeof(*max), GFP_KERNEL);
...@@ -696,15 +696,11 @@ static int max8973_probe(struct i2c_client *client, ...@@ -696,15 +696,11 @@ static int max8973_probe(struct i2c_client *client,
max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE; max->desc.n_voltages = MAX8973_BUCK_N_VOLTAGE;
max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL; max->dvs_gpio = (pdata->dvs_gpio) ? pdata->dvs_gpio : -EINVAL;
max->enable_gpio = (pdata->enable_gpio) ? pdata->enable_gpio : -EINVAL;
max->enable_external_control = pdata->enable_ext_control; max->enable_external_control = pdata->enable_ext_control;
max->curr_gpio_val = pdata->dvs_def_state; max->curr_gpio_val = pdata->dvs_def_state;
max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state; max->curr_vout_reg = MAX8973_VOUT + pdata->dvs_def_state;
max->junction_temp_warning = pdata->junction_temp_warning; max->junction_temp_warning = pdata->junction_temp_warning;
if (gpio_is_valid(max->enable_gpio))
max->enable_external_control = true;
max->lru_index[0] = max->curr_vout_reg; max->lru_index[0] = max->curr_vout_reg;
if (gpio_is_valid(max->dvs_gpio)) { if (gpio_is_valid(max->dvs_gpio)) {
...@@ -757,27 +753,35 @@ static int max8973_probe(struct i2c_client *client, ...@@ -757,27 +753,35 @@ static int max8973_probe(struct i2c_client *client,
break; break;
} }
if (gpio_is_valid(max->enable_gpio)) {
config.ena_gpio_flags = GPIOF_OUT_INIT_LOW;
if (ridata && (ridata->constraints.always_on || if (ridata && (ridata->constraints.always_on ||
ridata->constraints.boot_on)) ridata->constraints.boot_on))
config.ena_gpio_flags = GPIOF_OUT_INIT_HIGH; gflags = GPIOD_OUT_HIGH;
config.ena_gpio = max->enable_gpio; else
gflags = GPIOD_OUT_LOW;
gpiod = devm_gpiod_get_optional(&client->dev,
"maxim,enable",
gflags);
if (IS_ERR(gpiod))
return PTR_ERR(gpiod);
if (gpiod) {
config.ena_gpiod = gpiod;
max->enable_external_control = true;
} }
break; break;
case MAX77621: case MAX77621:
if (gpio_is_valid(max->enable_gpio)) { /*
ret = devm_gpio_request_one(&client->dev, * We do not let the core switch this regulator on/off,
max->enable_gpio, GPIOF_OUT_INIT_HIGH, * we just leave it on.
"max8973-en-gpio"); */
if (ret) { gpiod = devm_gpiod_get_optional(&client->dev,
dev_err(&client->dev, "maxim,enable",
"gpio_request for gpio %d failed: %d\n", GPIOD_OUT_HIGH);
max->enable_gpio, ret); if (IS_ERR(gpiod))
return ret; return PTR_ERR(gpiod);
} if (gpiod)
} max->enable_external_control = true;
max->desc.enable_reg = MAX8973_VOUT; max->desc.enable_reg = MAX8973_VOUT;
max->desc.enable_mask = MAX8973_VOUT_ENABLE; max->desc.enable_mask = MAX8973_VOUT_ENABLE;
......
...@@ -309,8 +309,7 @@ static int max8998_set_voltage_buck_sel(struct regulator_dev *rdev, ...@@ -309,8 +309,7 @@ static int max8998_set_voltage_buck_sel(struct regulator_dev *rdev,
unsigned selector) unsigned selector)
{ {
struct max8998_data *max8998 = rdev_get_drvdata(rdev); struct max8998_data *max8998 = rdev_get_drvdata(rdev);
struct max8998_platform_data *pdata = struct max8998_platform_data *pdata = max8998->iodev->pdata;
dev_get_platdata(max8998->iodev->dev);
struct i2c_client *i2c = max8998->iodev->i2c; struct i2c_client *i2c = max8998->iodev->i2c;
int buck = rdev_get_id(rdev); int buck = rdev_get_id(rdev);
int reg, shift = 0, mask, ret, j; int reg, shift = 0, mask, ret, j;
......
/* // SPDX-License-Identifier: GPL-2.0
* Regulator Driver for Freescale MC13783 PMIC //
* // Regulator Driver for Freescale MC13783 PMIC
* Copyright 2010 Yong Shen <yong.shen@linaro.org> //
* Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> // Copyright 2010 Yong Shen <yong.shen@linaro.org>
* Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com> // Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
* // Copyright 2009 Alberto Panizzo <maramaopercheseimorto@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.
*/
#include <linux/mfd/mc13783.h> #include <linux/mfd/mc13783.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
......
/* // SPDX-License-Identifier: GPL-2.0
* Regulator Driver for Freescale MC13892 PMIC //
* // Regulator Driver for Freescale MC13892 PMIC
* Copyright 2010 Yong Shen <yong.shen@linaro.org> //
* // Copyright 2010 Yong Shen <yong.shen@linaro.org>
* Based on draft driver from Arnaud Patard <arnaud.patard@rtp-net.org> //
* // Based on draft driver from Arnaud Patard <arnaud.patard@rtp-net.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/mc13892.h> #include <linux/mfd/mc13892.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
......
/* // SPDX-License-Identifier: GPL-2.0
* Regulator Driver for Freescale MC13xxx PMIC //
* // Regulator Driver for Freescale MC13xxx PMIC
* Copyright 2010 Yong Shen <yong.shen@linaro.org> //
* // Copyright 2010 Yong Shen <yong.shen@linaro.org>
* Based on mc13783 regulator driver : //
* Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> // Based on mc13783 regulator driver :
* Copyright 2009 Alberto Panizzo <maramaopercheseimorto@gmail.com> // Copyright (C) 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
* // Copyright 2009 Alberto Panizzo <maramaopercheseimorto@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 // Regs infos taken from mc13xxx drivers from freescale and mc13xxx.pdf file
* published by the Free Software Foundation. // from freescale
*
* Regs infos taken from mc13xxx drivers from freescale and mc13xxx.pdf file
* from freescale
*/
#include <linux/mfd/mc13xxx.h> #include <linux/mfd/mc13xxx.h>
#include <linux/regulator/machine.h> #include <linux/regulator/machine.h>
......
...@@ -31,7 +31,8 @@ static void of_get_regulation_constraints(struct device_node *np, ...@@ -31,7 +31,8 @@ static void of_get_regulation_constraints(struct device_node *np,
struct regulation_constraints *constraints = &(*init_data)->constraints; struct regulation_constraints *constraints = &(*init_data)->constraints;
struct regulator_state *suspend_state; struct regulator_state *suspend_state;
struct device_node *suspend_np; struct device_node *suspend_np;
int ret, i; unsigned int mode;
int ret, i, len;
u32 pval; u32 pval;
constraints->name = of_get_property(np, "regulator-name", NULL); constraints->name = of_get_property(np, "regulator-name", NULL);
...@@ -124,20 +125,51 @@ static void of_get_regulation_constraints(struct device_node *np, ...@@ -124,20 +125,51 @@ static void of_get_regulation_constraints(struct device_node *np,
if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) { if (!of_property_read_u32(np, "regulator-initial-mode", &pval)) {
if (desc && desc->of_map_mode) { if (desc && desc->of_map_mode) {
ret = desc->of_map_mode(pval); mode = desc->of_map_mode(pval);
if (ret == -EINVAL) if (mode == REGULATOR_MODE_INVALID)
pr_err("%s: invalid mode %u\n", np->name, pval); pr_err("%s: invalid mode %u\n", np->name, pval);
else else
constraints->initial_mode = ret; constraints->initial_mode = mode;
} else { } else {
pr_warn("%s: mapping for mode %d not defined\n", pr_warn("%s: mapping for mode %d not defined\n",
np->name, pval); np->name, pval);
} }
} }
len = of_property_count_elems_of_size(np, "regulator-allowed-modes",
sizeof(u32));
if (len > 0) {
if (desc && desc->of_map_mode) {
for (i = 0; i < len; i++) {
ret = of_property_read_u32_index(np,
"regulator-allowed-modes", i, &pval);
if (ret) {
pr_err("%s: couldn't read allowed modes index %d, ret=%d\n",
np->name, i, ret);
break;
}
mode = desc->of_map_mode(pval);
if (mode == REGULATOR_MODE_INVALID)
pr_err("%s: invalid regulator-allowed-modes element %u\n",
np->name, pval);
else
constraints->valid_modes_mask |= mode;
}
if (constraints->valid_modes_mask)
constraints->valid_ops_mask
|= REGULATOR_CHANGE_MODE;
} else {
pr_warn("%s: mode mapping not defined\n", np->name);
}
}
if (!of_property_read_u32(np, "regulator-system-load", &pval)) if (!of_property_read_u32(np, "regulator-system-load", &pval))
constraints->system_load = pval; constraints->system_load = pval;
if (!of_property_read_u32(np, "regulator-coupled-max-spread",
&pval))
constraints->max_spread = pval;
constraints->over_current_protection = of_property_read_bool(np, constraints->over_current_protection = of_property_read_bool(np,
"regulator-over-current-protection"); "regulator-over-current-protection");
...@@ -163,12 +195,12 @@ static void of_get_regulation_constraints(struct device_node *np, ...@@ -163,12 +195,12 @@ static void of_get_regulation_constraints(struct device_node *np,
if (!of_property_read_u32(suspend_np, "regulator-mode", if (!of_property_read_u32(suspend_np, "regulator-mode",
&pval)) { &pval)) {
if (desc && desc->of_map_mode) { if (desc && desc->of_map_mode) {
ret = desc->of_map_mode(pval); mode = desc->of_map_mode(pval);
if (ret == -EINVAL) if (mode == REGULATOR_MODE_INVALID)
pr_err("%s: invalid mode %u\n", pr_err("%s: invalid mode %u\n",
np->name, pval); np->name, pval);
else else
suspend_state->mode = ret; suspend_state->mode = mode;
} else { } else {
pr_warn("%s: mapping for mode %d not defined\n", pr_warn("%s: mapping for mode %d not defined\n",
np->name, pval); np->name, pval);
...@@ -407,3 +439,150 @@ struct regulator_dev *of_find_regulator_by_node(struct device_node *np) ...@@ -407,3 +439,150 @@ struct regulator_dev *of_find_regulator_by_node(struct device_node *np)
return dev ? dev_to_rdev(dev) : NULL; return dev ? dev_to_rdev(dev) : NULL;
} }
/*
* Returns number of regulators coupled with rdev.
*/
int of_get_n_coupled(struct regulator_dev *rdev)
{
struct device_node *node = rdev->dev.of_node;
int n_phandles;
n_phandles = of_count_phandle_with_args(node,
"regulator-coupled-with",
NULL);
return (n_phandles > 0) ? n_phandles : 0;
}
/* Looks for "to_find" device_node in src's "regulator-coupled-with" property */
static bool of_coupling_find_node(struct device_node *src,
struct device_node *to_find)
{
int n_phandles, i;
bool found = false;
n_phandles = of_count_phandle_with_args(src,
"regulator-coupled-with",
NULL);
for (i = 0; i < n_phandles; i++) {
struct device_node *tmp = of_parse_phandle(src,
"regulator-coupled-with", i);
if (!tmp)
break;
/* found */
if (tmp == to_find)
found = true;
of_node_put(tmp);
if (found)
break;
}
return found;
}
/**
* of_check_coupling_data - Parse rdev's coupling properties and check data
* consistency
* @rdev - pointer to regulator_dev whose data is checked
*
* Function checks if all the following conditions are met:
* - rdev's max_spread is greater than 0
* - all coupled regulators have the same max_spread
* - all coupled regulators have the same number of regulator_dev phandles
* - all regulators are linked to each other
*
* Returns true if all conditions are met.
*/
bool of_check_coupling_data(struct regulator_dev *rdev)
{
int max_spread = rdev->constraints->max_spread;
struct device_node *node = rdev->dev.of_node;
int n_phandles = of_get_n_coupled(rdev);
struct device_node *c_node;
int i;
bool ret = true;
if (max_spread <= 0) {
dev_err(&rdev->dev, "max_spread value invalid\n");
return false;
}
/* iterate over rdev's phandles */
for (i = 0; i < n_phandles; i++) {
int c_max_spread, c_n_phandles;
c_node = of_parse_phandle(node,
"regulator-coupled-with", i);
if (!c_node)
ret = false;
c_n_phandles = of_count_phandle_with_args(c_node,
"regulator-coupled-with",
NULL);
if (c_n_phandles != n_phandles) {
dev_err(&rdev->dev, "number of couped reg phandles mismatch\n");
ret = false;
goto clean;
}
if (of_property_read_u32(c_node, "regulator-coupled-max-spread",
&c_max_spread)) {
ret = false;
goto clean;
}
if (c_max_spread != max_spread) {
dev_err(&rdev->dev,
"coupled regulators max_spread mismatch\n");
ret = false;
goto clean;
}
if (!of_coupling_find_node(c_node, node)) {
dev_err(&rdev->dev, "missing 2-way linking for coupled regulators\n");
ret = false;
}
clean:
of_node_put(c_node);
if (!ret)
break;
}
return ret;
}
/**
* of_parse_coupled regulator - Get regulator_dev pointer from rdev's property
* @rdev: Pointer to regulator_dev, whose DTS is used as a source to parse
* "regulator-coupled-with" property
* @index: Index in phandles array
*
* Returns the regulator_dev pointer parsed from DTS. If it has not been yet
* registered, returns NULL
*/
struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
int index)
{
struct device_node *node = rdev->dev.of_node;
struct device_node *c_node;
struct regulator_dev *c_rdev;
c_node = of_parse_phandle(node, "regulator-coupled-with", index);
if (!c_node)
return NULL;
c_rdev = of_find_regulator_by_node(c_node);
of_node_put(c_node);
return c_rdev;
}
/* // SPDX-License-Identifier: GPL-2.0+
* Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved. //
* // Copyright (C) 2011-2013 Freescale Semiconductor, Inc. All Rights Reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -86,6 +73,13 @@ static const int pfuze100_coin[] = { ...@@ -86,6 +73,13 @@ static const int pfuze100_coin[] = {
2500000, 2700000, 2800000, 2900000, 3000000, 3100000, 3200000, 3300000, 2500000, 2700000, 2800000, 2900000, 3000000, 3100000, 3200000, 3300000,
}; };
static const int pfuze3000_sw1a[] = {
700000, 725000, 750000, 775000, 800000, 825000, 850000, 875000,
900000, 925000, 950000, 975000, 1000000, 1025000, 1050000, 1075000,
1100000, 1125000, 1150000, 1175000, 1200000, 1225000, 1250000, 1275000,
1300000, 1325000, 1350000, 1375000, 1400000, 1425000, 1800000, 3300000,
};
static const int pfuze3000_sw2lo[] = { static const int pfuze3000_sw2lo[] = {
1500000, 1550000, 1600000, 1650000, 1700000, 1750000, 1800000, 1850000, 1500000, 1550000, 1600000, 1650000, 1700000, 1750000, 1800000, 1850000,
}; };
...@@ -148,6 +142,9 @@ static const struct regulator_ops pfuze100_fixed_regulator_ops = { ...@@ -148,6 +142,9 @@ static const struct regulator_ops pfuze100_fixed_regulator_ops = {
}; };
static const struct regulator_ops pfuze100_sw_regulator_ops = { static const struct regulator_ops pfuze100_sw_regulator_ops = {
.enable = regulator_enable_regmap,
.disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.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,
...@@ -158,6 +155,7 @@ static const struct regulator_ops pfuze100_sw_regulator_ops = { ...@@ -158,6 +155,7 @@ static const struct regulator_ops pfuze100_sw_regulator_ops = {
static const struct regulator_ops pfuze100_swb_regulator_ops = { static const struct regulator_ops pfuze100_swb_regulator_ops = {
.enable = regulator_enable_regmap, .enable = regulator_enable_regmap,
.disable = regulator_disable_regmap, .disable = regulator_disable_regmap,
.is_enabled = regulator_is_enabled_regmap,
.list_voltage = regulator_list_voltage_table, .list_voltage = regulator_list_voltage_table,
.map_voltage = regulator_map_voltage_ascend, .map_voltage = regulator_map_voltage_ascend,
.set_voltage_sel = regulator_set_voltage_sel_regmap, .set_voltage_sel = regulator_set_voltage_sel_regmap,
...@@ -193,6 +191,11 @@ static const struct regulator_ops pfuze100_swb_regulator_ops = { ...@@ -193,6 +191,11 @@ static const struct regulator_ops pfuze100_swb_regulator_ops = {
.uV_step = (step), \ .uV_step = (step), \
.vsel_reg = (base) + PFUZE100_VOL_OFFSET, \ .vsel_reg = (base) + PFUZE100_VOL_OFFSET, \
.vsel_mask = 0x3f, \ .vsel_mask = 0x3f, \
.enable_reg = (base) + PFUZE100_MODE_OFFSET, \
.enable_val = 0xc, \
.disable_val = 0x0, \
.enable_mask = 0xf, \
.enable_time = 500, \
}, \ }, \
.stby_reg = (base) + PFUZE100_STANDBY_OFFSET, \ .stby_reg = (base) + PFUZE100_STANDBY_OFFSET, \
.stby_mask = 0x3f, \ .stby_mask = 0x3f, \
...@@ -343,7 +346,7 @@ static struct pfuze_regulator pfuze200_regulators[] = { ...@@ -343,7 +346,7 @@ static struct pfuze_regulator pfuze200_regulators[] = {
}; };
static struct pfuze_regulator pfuze3000_regulators[] = { static struct pfuze_regulator pfuze3000_regulators[] = {
PFUZE100_SW_REG(PFUZE3000, SW1A, PFUZE100_SW1ABVOL, 700000, 1475000, 25000), PFUZE100_SWB_REG(PFUZE3000, SW1A, PFUZE100_SW1ABVOL, 0x1f, pfuze3000_sw1a),
PFUZE100_SW_REG(PFUZE3000, SW1B, PFUZE100_SW1CVOL, 700000, 1475000, 25000), PFUZE100_SW_REG(PFUZE3000, SW1B, PFUZE100_SW1CVOL, 700000, 1475000, 25000),
PFUZE100_SWB_REG(PFUZE3000, SW2, PFUZE100_SW2VOL, 0x7, pfuze3000_sw2lo), PFUZE100_SWB_REG(PFUZE3000, SW2, PFUZE100_SW2VOL, 0x7, pfuze3000_sw2lo),
PFUZE3000_SW3_REG(PFUZE3000, SW3, PFUZE100_SW3AVOL, 900000, 1650000, 50000), PFUZE3000_SW3_REG(PFUZE3000, SW3, PFUZE100_SW3AVOL, 900000, 1650000, 50000),
...@@ -648,7 +651,6 @@ static int pfuze100_regulator_probe(struct i2c_client *client, ...@@ -648,7 +651,6 @@ static int pfuze100_regulator_probe(struct i2c_client *client,
config.init_data = init_data; config.init_data = init_data;
config.driver_data = pfuze_chip; config.driver_data = pfuze_chip;
config.of_node = match_of_node(i); config.of_node = match_of_node(i);
config.ena_gpio = -EINVAL;
pfuze_chip->regulators[i] = pfuze_chip->regulators[i] =
devm_regulator_register(&client->dev, desc, &config); devm_regulator_register(&client->dev, desc, &config);
......
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
#include <linux/regmap.h> #include <linux/regmap.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/mfd/syscon.h>
#include <linux/io.h>
/* Pin control enable input pins. */ /* Pin control enable input pins. */
#define SPMI_REGULATOR_PIN_CTRL_ENABLE_NONE 0x00 #define SPMI_REGULATOR_PIN_CTRL_ENABLE_NONE 0x00
...@@ -181,6 +183,23 @@ enum spmi_boost_byp_registers { ...@@ -181,6 +183,23 @@ enum spmi_boost_byp_registers {
SPMI_BOOST_BYP_REG_CURRENT_LIMIT = 0x4b, SPMI_BOOST_BYP_REG_CURRENT_LIMIT = 0x4b,
}; };
enum spmi_saw3_registers {
SAW3_SECURE = 0x00,
SAW3_ID = 0x04,
SAW3_SPM_STS = 0x0C,
SAW3_AVS_STS = 0x10,
SAW3_PMIC_STS = 0x14,
SAW3_RST = 0x18,
SAW3_VCTL = 0x1C,
SAW3_AVS_CTL = 0x20,
SAW3_AVS_LIMIT = 0x24,
SAW3_AVS_DLY = 0x28,
SAW3_AVS_HYSTERESIS = 0x2C,
SAW3_SPM_STS2 = 0x38,
SAW3_SPM_PMIC_DATA_3 = 0x4C,
SAW3_VERSION = 0xFD0,
};
/* Used for indexing into ctrl_reg. These are offets from 0x40 */ /* Used for indexing into ctrl_reg. These are offets from 0x40 */
enum spmi_common_control_register_index { enum spmi_common_control_register_index {
SPMI_COMMON_IDX_VOLTAGE_RANGE = 0, SPMI_COMMON_IDX_VOLTAGE_RANGE = 0,
...@@ -1035,6 +1054,89 @@ static irqreturn_t spmi_regulator_vs_ocp_isr(int irq, void *data) ...@@ -1035,6 +1054,89 @@ static irqreturn_t spmi_regulator_vs_ocp_isr(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
#define SAW3_VCTL_DATA_MASK 0xFF
#define SAW3_VCTL_CLEAR_MASK 0x700FF
#define SAW3_AVS_CTL_EN_MASK 0x1
#define SAW3_AVS_CTL_TGGL_MASK 0x8000000
#define SAW3_AVS_CTL_CLEAR_MASK 0x7efc00
static struct regmap *saw_regmap = NULL;
static void spmi_saw_set_vdd(void *data)
{
u32 vctl, data3, avs_ctl, pmic_sts;
bool avs_enabled = false;
unsigned long timeout;
u8 voltage_sel = *(u8 *)data;
regmap_read(saw_regmap, SAW3_AVS_CTL, &avs_ctl);
regmap_read(saw_regmap, SAW3_VCTL, &vctl);
regmap_read(saw_regmap, SAW3_SPM_PMIC_DATA_3, &data3);
/* select the band */
vctl &= ~SAW3_VCTL_CLEAR_MASK;
vctl |= (u32)voltage_sel;
data3 &= ~SAW3_VCTL_CLEAR_MASK;
data3 |= (u32)voltage_sel;
/* If AVS is enabled, switch it off during the voltage change */
avs_enabled = SAW3_AVS_CTL_EN_MASK & avs_ctl;
if (avs_enabled) {
avs_ctl &= ~SAW3_AVS_CTL_TGGL_MASK;
regmap_write(saw_regmap, SAW3_AVS_CTL, avs_ctl);
}
regmap_write(saw_regmap, SAW3_RST, 1);
regmap_write(saw_regmap, SAW3_VCTL, vctl);
regmap_write(saw_regmap, SAW3_SPM_PMIC_DATA_3, data3);
timeout = jiffies + usecs_to_jiffies(100);
do {
regmap_read(saw_regmap, SAW3_PMIC_STS, &pmic_sts);
pmic_sts &= SAW3_VCTL_DATA_MASK;
if (pmic_sts == (u32)voltage_sel)
break;
cpu_relax();
} while (time_before(jiffies, timeout));
/* After successful voltage change, switch the AVS back on */
if (avs_enabled) {
pmic_sts &= 0x3f;
avs_ctl &= ~SAW3_AVS_CTL_CLEAR_MASK;
avs_ctl |= ((pmic_sts - 4) << 10);
avs_ctl |= (pmic_sts << 17);
avs_ctl |= SAW3_AVS_CTL_TGGL_MASK;
regmap_write(saw_regmap, SAW3_AVS_CTL, avs_ctl);
}
}
static int
spmi_regulator_saw_set_voltage(struct regulator_dev *rdev, unsigned selector)
{
struct spmi_regulator *vreg = rdev_get_drvdata(rdev);
int ret;
u8 range_sel, voltage_sel;
ret = spmi_sw_selector_to_hw(vreg, selector, &range_sel, &voltage_sel);
if (ret)
return ret;
if (0 != range_sel) {
dev_dbg(&rdev->dev, "range_sel = %02X voltage_sel = %02X", \
range_sel, voltage_sel);
return -EINVAL;
}
/* Always do the SAW register writes on the first CPU */
return smp_call_function_single(0, spmi_saw_set_vdd, \
&voltage_sel, true);
}
static struct regulator_ops spmi_saw_ops = {};
static struct regulator_ops spmi_smps_ops = { static struct regulator_ops spmi_smps_ops = {
.enable = regulator_enable_regmap, .enable = regulator_enable_regmap,
.disable = regulator_disable_regmap, .disable = regulator_disable_regmap,
...@@ -1250,6 +1352,7 @@ static int spmi_regulator_match(struct spmi_regulator *vreg, u16 force_type) ...@@ -1250,6 +1352,7 @@ static int spmi_regulator_match(struct spmi_regulator *vreg, u16 force_type)
} }
dig_major_rev = version[SPMI_COMMON_REG_DIG_MAJOR_REV dig_major_rev = version[SPMI_COMMON_REG_DIG_MAJOR_REV
- SPMI_COMMON_REG_DIG_MAJOR_REV]; - SPMI_COMMON_REG_DIG_MAJOR_REV];
if (!force_type) { if (!force_type) {
type = version[SPMI_COMMON_REG_TYPE - type = version[SPMI_COMMON_REG_TYPE -
SPMI_COMMON_REG_DIG_MAJOR_REV]; SPMI_COMMON_REG_DIG_MAJOR_REV];
...@@ -1648,7 +1751,9 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev) ...@@ -1648,7 +1751,9 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
struct regmap *regmap; struct regmap *regmap;
const char *name; const char *name;
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
int ret; struct device_node *node = pdev->dev.of_node;
struct device_node *syscon;
int ret, lenp;
struct list_head *vreg_list; struct list_head *vreg_list;
vreg_list = devm_kzalloc(dev, sizeof(*vreg_list), GFP_KERNEL); vreg_list = devm_kzalloc(dev, sizeof(*vreg_list), GFP_KERNEL);
...@@ -1665,7 +1770,22 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev) ...@@ -1665,7 +1770,22 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
if (!match) if (!match)
return -ENODEV; return -ENODEV;
if (of_find_property(node, "qcom,saw-reg", &lenp)) {
syscon = of_parse_phandle(node, "qcom,saw-reg", 0);
saw_regmap = syscon_node_to_regmap(syscon);
of_node_put(syscon);
if (IS_ERR(regmap))
dev_err(dev, "ERROR reading SAW regmap\n");
}
for (reg = match->data; reg->name; reg++) { for (reg = match->data; reg->name; reg++) {
if (saw_regmap && \
of_find_property(of_find_node_by_name(node, reg->name), \
"qcom,saw-slave", &lenp)) {
continue;
}
vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL); vreg = devm_kzalloc(dev, sizeof(*vreg), GFP_KERNEL);
if (!vreg) if (!vreg)
return -ENOMEM; return -ENOMEM;
...@@ -1673,7 +1793,6 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev) ...@@ -1673,7 +1793,6 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
vreg->dev = dev; vreg->dev = dev;
vreg->base = reg->base; vreg->base = reg->base;
vreg->regmap = regmap; vreg->regmap = regmap;
if (reg->ocp) { if (reg->ocp) {
vreg->ocp_irq = platform_get_irq_byname(pdev, reg->ocp); vreg->ocp_irq = platform_get_irq_byname(pdev, reg->ocp);
if (vreg->ocp_irq < 0) { if (vreg->ocp_irq < 0) {
...@@ -1681,7 +1800,6 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev) ...@@ -1681,7 +1800,6 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
goto err; goto err;
} }
} }
vreg->desc.id = -1; vreg->desc.id = -1;
vreg->desc.owner = THIS_MODULE; vreg->desc.owner = THIS_MODULE;
vreg->desc.type = REGULATOR_VOLTAGE; vreg->desc.type = REGULATOR_VOLTAGE;
...@@ -1698,6 +1816,15 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev) ...@@ -1698,6 +1816,15 @@ static int qcom_spmi_regulator_probe(struct platform_device *pdev)
if (ret) if (ret)
continue; continue;
if (saw_regmap && \
of_find_property(of_find_node_by_name(node, reg->name), \
"qcom,saw-leader", &lenp)) {
spmi_saw_ops = *(vreg->desc.ops);
spmi_saw_ops.set_voltage_sel = \
spmi_regulator_saw_set_voltage;
vreg->desc.ops = &spmi_saw_ops;
}
config.dev = dev; config.dev = dev;
config.driver_data = vreg; config.driver_data = vreg;
config.regmap = regmap; config.regmap = regmap;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/err.h> #include <linux/err.h>
#include <linux/of_gpio.h> #include <linux/of_gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/regulator/driver.h> #include <linux/regulator/driver.h>
...@@ -459,15 +460,14 @@ static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767, ...@@ -459,15 +460,14 @@ static void s5m8767_regulator_config_ext_control(struct s5m8767_info *s5m8767,
return; return;
} }
if (!gpio_is_valid(rdata->ext_control_gpio)) { if (!rdata->ext_control_gpiod) {
dev_warn(s5m8767->dev, dev_warn(s5m8767->dev,
"ext-control for %s: GPIO not valid, ignoring\n", "ext-control for %s: GPIO not valid, ignoring\n",
rdata->reg_node->name); rdata->reg_node->name);
return; return;
} }
config->ena_gpio = rdata->ext_control_gpio; config->ena_gpiod = rdata->ext_control_gpiod;
config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
} }
/* /*
...@@ -577,8 +577,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, ...@@ -577,8 +577,14 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
continue; continue;
} }
rdata->ext_control_gpio = of_get_named_gpio(reg_np, rdata->ext_control_gpiod = devm_gpiod_get_from_of_node(&pdev->dev,
"s5m8767,pmic-ext-control-gpios", 0); reg_np,
"s5m8767,pmic-ext-control-gpios",
0,
GPIOD_OUT_HIGH,
"s5m8767");
if (IS_ERR(rdata->ext_control_gpiod))
return PTR_ERR(rdata->ext_control_gpiod);
rdata->id = i; rdata->id = i;
rdata->initdata = of_get_regulator_init_data( rdata->initdata = of_get_regulator_init_data(
...@@ -954,10 +960,8 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) ...@@ -954,10 +960,8 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
config.driver_data = s5m8767; config.driver_data = s5m8767;
config.regmap = iodev->regmap_pmic; config.regmap = iodev->regmap_pmic;
config.of_node = pdata->regulators[i].reg_node; config.of_node = pdata->regulators[i].reg_node;
config.ena_gpio = -EINVAL; config.ena_gpiod = NULL;
config.ena_gpio_flags = 0; if (pdata->regulators[i].ext_control_gpiod)
config.ena_gpio_initialized = true;
if (gpio_is_valid(pdata->regulators[i].ext_control_gpio))
s5m8767_regulator_config_ext_control(s5m8767, s5m8767_regulator_config_ext_control(s5m8767,
&pdata->regulators[i], &config); &pdata->regulators[i], &config);
...@@ -970,7 +974,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) ...@@ -970,7 +974,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
return ret; return ret;
} }
if (gpio_is_valid(pdata->regulators[i].ext_control_gpio)) { if (pdata->regulators[i].ext_control_gpiod) {
ret = s5m8767_enable_ext_control(s5m8767, rdev); ret = s5m8767_enable_ext_control(s5m8767, rdev);
if (ret < 0) { if (ret < 0) {
dev_err(s5m8767->dev, dev_err(s5m8767->dev,
......
This diff is collapsed.
This diff is collapsed.
...@@ -342,6 +342,7 @@ static struct tps6586x_regulator *find_regulator_info(int id, int version) ...@@ -342,6 +342,7 @@ static struct tps6586x_regulator *find_regulator_info(int id, int version)
switch (version) { switch (version) {
case TPS658623: case TPS658623:
case TPS658624:
table = tps658623_regulator; table = tps658623_regulator;
num = ARRAY_SIZE(tps658623_regulator); num = ARRAY_SIZE(tps658623_regulator);
break; break;
......
...@@ -274,7 +274,7 @@ static inline unsigned int twl4030reg_map_mode(unsigned int mode) ...@@ -274,7 +274,7 @@ static inline unsigned int twl4030reg_map_mode(unsigned int mode)
case RES_STATE_SLEEP: case RES_STATE_SLEEP:
return REGULATOR_MODE_STANDBY; return REGULATOR_MODE_STANDBY;
default: default:
return -EINVAL; return REGULATOR_MODE_INVALID;
} }
} }
......
...@@ -911,6 +911,7 @@ static unsigned int get_mode(int uA, const struct wm8350_dcdc_efficiency *eff) ...@@ -911,6 +911,7 @@ static unsigned int get_mode(int uA, const struct wm8350_dcdc_efficiency *eff)
while (eff[i].uA_load_min != -1) { while (eff[i].uA_load_min != -1) {
if (uA >= eff[i].uA_load_min && uA <= eff[i].uA_load_max) if (uA >= eff[i].uA_load_min && uA <= eff[i].uA_load_max)
return eff[i].mode; return eff[i].mode;
i++;
} }
return REGULATOR_MODE_NORMAL; return REGULATOR_MODE_NORMAL;
} }
......
...@@ -33,6 +33,11 @@ ...@@ -33,6 +33,11 @@
#define BD9571MWV_I2C_MD2_E1_BIT_2 0x12 #define BD9571MWV_I2C_MD2_E1_BIT_2 0x12
#define BD9571MWV_BKUP_MODE_CNT 0x20 #define BD9571MWV_BKUP_MODE_CNT 0x20
#define BD9571MWV_BKUP_MODE_CNT_KEEPON_MASK GENMASK(3, 0)
#define BD9571MWV_BKUP_MODE_CNT_KEEPON_DDR0 BIT(0)
#define BD9571MWV_BKUP_MODE_CNT_KEEPON_DDR1 BIT(1)
#define BD9571MWV_BKUP_MODE_CNT_KEEPON_DDR0C BIT(2)
#define BD9571MWV_BKUP_MODE_CNT_KEEPON_DDR1C BIT(3)
#define BD9571MWV_BKUP_MODE_STATUS 0x21 #define BD9571MWV_BKUP_MODE_STATUS 0x21
#define BD9571MWV_BKUP_RECOVERY_CNT 0x22 #define BD9571MWV_BKUP_RECOVERY_CNT 0x22
#define BD9571MWV_BKUP_CTRL_TIM_CNT 0x23 #define BD9571MWV_BKUP_CTRL_TIM_CNT 0x23
......
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