aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 19:32:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 19:32:25 -0400
commit8ded8d4e4facab78acf616bc34085ddd15c2c21c (patch)
tree7cb470ffbaffd4c1119d1baf4b0341f76cb4242a
parent7b053842b95914119f132fdac294fb2591b2e9a8 (diff)
parentbee546581424b5514ec6a034fb83fd4e95b804da (diff)
Merge tag 'regulator-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates from Mark Brown: "The diffstat and changelog here is dominated by Lee Jones' heroic efforts to sync the ab8500 driver that's been maintained out of tree with mainline (plus Axel's cleanup work on the results) but there's a few other things here: - Axel Lin added regulator_map_voltage_ascend() optimising a common pattern for drivers using the core code. - Milo Kim tought the regulator core to handle regulators sharing an enable GPIO, avoiding the need to do hacks to support such systems. - Andrew Bresticker added code to handle missing supplies for regulators more sensibly for device tree systems, reducing the need for stubbing there. plus the usual batch of driver specific updates and fixes" * tag 'regulator-v3.10' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (152 commits) regulator: mc13892: Fix MC13892_SWITCHERS0_SWxHI bit in set_voltage_sel regulator: Remove NULL test before calling regulator_unregister() regulator: mc13783: Add device tree probe support regulator: mc13xxx: Add warning of incorrect names of regulators regulator: max77686: Don't update max77686->opmode if update register fails regulator: max8952: Add missing config.of_node setting for regulator register regulator: ab3100: Fix regulator register error handling regulator: tps6524x: Use regulator_map_voltage_ascend regulator: lp8788-buck: Use regulator_map_voltage_ascend regulator: lp872x: Use regulator_map_voltage_ascend regulator: mc13892: Use regulator_map_voltage_ascend for mc13892_sw_regulator_ops regulator: tps65023: Use regulator_map_voltage_ascend regulator: tps65023: Merge tps65020 ldo1 and ldo2 vsel table regulator: tps6507x: Use regulator_map_voltage_ascend regulator: mc13892: Fix MC13892_SWITCHERS0_SWxHI bit in set_voltage_sel regulator: ab3100: device tree support regulator: ab3100: refactor probe to use IDs regulator: max8973: Don't override control1 variable when set ramp delay bits regulator: tps80031: Convert tps80031_dcdc_ops to [get|set]_voltage_sel_regmap regulator: tps80031: Fix LDO2 track mode for TPS80031 or TPS80032-ES1.0 ...
-rw-r--r--Documentation/devicetree/bindings/mfd/mc13xxx.txt36
-rw-r--r--Documentation/devicetree/bindings/regulator/max8952.txt52
-rw-r--r--MAINTAINERS2
-rw-r--r--arch/arm/mach-exynos/mach-universal_c210.c27
-rw-r--r--arch/arm/mach-ux500/board-mop500-regulators.c774
-rw-r--r--arch/arm/mach-ux500/board-mop500-regulators.h7
-rw-r--r--arch/arm/mach-ux500/board-mop500.c5
-rw-r--r--drivers/mfd/ab3100-core.c1
-rw-r--r--drivers/regulator/88pm8607.c36
-rw-r--r--drivers/regulator/Makefile2
-rw-r--r--drivers/regulator/ab3100.c236
-rw-r--r--drivers/regulator/ab8500-ext.c407
-rw-r--r--drivers/regulator/ab8500.c2662
-rw-r--r--drivers/regulator/arizona-ldo1.c2
-rw-r--r--drivers/regulator/as3711-regulator.c67
-rw-r--r--drivers/regulator/core.c220
-rw-r--r--drivers/regulator/dbx500-prcmu.h2
-rw-r--r--drivers/regulator/fan53555.c4
-rw-r--r--drivers/regulator/lp3971.c2
-rw-r--r--drivers/regulator/lp3972.c2
-rw-r--r--drivers/regulator/lp872x.c3
-rw-r--r--drivers/regulator/lp8788-buck.c2
-rw-r--r--drivers/regulator/lp8788-ldo.c157
-rw-r--r--drivers/regulator/max1586.c5
-rw-r--r--drivers/regulator/max77686.c32
-rw-r--r--drivers/regulator/max8649.c45
-rw-r--r--drivers/regulator/max8660.c3
-rw-r--r--drivers/regulator/max8925-regulator.c5
-rw-r--r--drivers/regulator/max8952.c75
-rw-r--r--drivers/regulator/max8973-regulator.c10
-rw-r--r--drivers/regulator/max8997.c4
-rw-r--r--drivers/regulator/max8998.c9
-rw-r--r--drivers/regulator/mc13783-regulator.c44
-rw-r--r--drivers/regulator/mc13892-regulator.c46
-rw-r--r--drivers/regulator/mc13xxx-regulator-core.c17
-rw-r--r--drivers/regulator/mc13xxx.h4
-rw-r--r--drivers/regulator/palmas-regulator.c365
-rw-r--r--drivers/regulator/rc5t583-regulator.c6
-rw-r--r--drivers/regulator/s5m8767.c8
-rw-r--r--drivers/regulator/tps62360-regulator.c2
-rw-r--r--drivers/regulator/tps65023-regulator.c48
-rw-r--r--drivers/regulator/tps6507x-regulator.c1
-rw-r--r--drivers/regulator/tps6524x-regulator.c4
-rw-r--r--drivers/regulator/tps6586x-regulator.c7
-rw-r--r--drivers/regulator/tps65910-regulator.c4
-rw-r--r--drivers/regulator/tps80031-regulator.c45
-rw-r--r--drivers/regulator/twl-regulator.c34
-rw-r--r--drivers/regulator/wm8994-regulator.c61
-rw-r--r--include/linux/mfd/abx500/ab8500.h11
-rw-r--r--include/linux/mfd/palmas.h24
-rw-r--r--include/linux/regulator/ab8500.h217
-rw-r--r--include/linux/regulator/consumer.h14
-rw-r--r--include/linux/regulator/driver.h9
-rw-r--r--include/linux/regulator/max8952.h10
54 files changed, 5047 insertions, 830 deletions
diff --git a/Documentation/devicetree/bindings/mfd/mc13xxx.txt b/Documentation/devicetree/bindings/mfd/mc13xxx.txt
index baf07987ae68..abd9e3cb2db7 100644
--- a/Documentation/devicetree/bindings/mfd/mc13xxx.txt
+++ b/Documentation/devicetree/bindings/mfd/mc13xxx.txt
@@ -10,10 +10,40 @@ Optional properties:
10- fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used 10- fsl,mc13xxx-uses-touch : Indicate the touchscreen controller is being used
11 11
12Sub-nodes: 12Sub-nodes:
13- regulators : Contain the regulator nodes. The MC13892 regulators are 13- regulators : Contain the regulator nodes. The regulators are bound using
14 bound using their names as listed below with their registers and bits 14 their names as listed below with their registers and bits for enabling.
15 for enabling.
16 15
16MC13783 regulators:
17 sw1a : regulator SW1A (register 24, bit 0)
18 sw1b : regulator SW1B (register 25, bit 0)
19 sw2a : regulator SW2A (register 26, bit 0)
20 sw2b : regulator SW2B (register 27, bit 0)
21 sw3 : regulator SW3 (register 29, bit 20)
22 vaudio : regulator VAUDIO (register 32, bit 0)
23 viohi : regulator VIOHI (register 32, bit 3)
24 violo : regulator VIOLO (register 32, bit 6)
25 vdig : regulator VDIG (register 32, bit 9)
26 vgen : regulator VGEN (register 32, bit 12)
27 vrfdig : regulator VRFDIG (register 32, bit 15)
28 vrfref : regulator VRFREF (register 32, bit 18)
29 vrfcp : regulator VRFCP (register 32, bit 21)
30 vsim : regulator VSIM (register 33, bit 0)
31 vesim : regulator VESIM (register 33, bit 3)
32 vcam : regulator VCAM (register 33, bit 6)
33 vrfbg : regulator VRFBG (register 33, bit 9)
34 vvib : regulator VVIB (register 33, bit 11)
35 vrf1 : regulator VRF1 (register 33, bit 12)
36 vrf2 : regulator VRF2 (register 33, bit 15)
37 vmmc1 : regulator VMMC1 (register 33, bit 18)
38 vmmc2 : regulator VMMC2 (register 33, bit 21)
39 gpo1 : regulator GPO1 (register 34, bit 6)
40 gpo2 : regulator GPO2 (register 34, bit 8)
41 gpo3 : regulator GPO3 (register 34, bit 10)
42 gpo4 : regulator GPO4 (register 34, bit 12)
43 pwgt1spi : regulator PWGT1SPI (register 34, bit 15)
44 pwgt2spi : regulator PWGT2SPI (register 34, bit 16)
45
46MC13892 regulators:
17 vcoincell : regulator VCOINCELL (register 13, bit 23) 47 vcoincell : regulator VCOINCELL (register 13, bit 23)
18 sw1 : regulator SW1 (register 24, bit 0) 48 sw1 : regulator SW1 (register 24, bit 0)
19 sw2 : regulator SW2 (register 25, bit 0) 49 sw2 : regulator SW2 (register 25, bit 0)
diff --git a/Documentation/devicetree/bindings/regulator/max8952.txt b/Documentation/devicetree/bindings/regulator/max8952.txt
new file mode 100644
index 000000000000..866fcdd0f4eb
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/max8952.txt
@@ -0,0 +1,52 @@
1Maxim MAX8952 voltage regulator
2
3Required properties:
4- compatible: must be equal to "maxim,max8952"
5- reg: I2C slave address, usually 0x60
6- max8952,dvs-mode-microvolt: array of 4 integer values defining DVS voltages
7 in microvolts. All values must be from range <770000, 1400000>
8- any required generic properties defined in regulator.txt
9
10Optional properties:
11- max8952,vid-gpios: array of two GPIO pins used for DVS voltage selection
12- max8952,en-gpio: GPIO used to control enable status of regulator
13- max8952,default-mode: index of default DVS voltage, from <0, 3> range
14- max8952,sync-freq: sync frequency, must be one of following values:
15 - 0: 26 MHz
16 - 1: 13 MHz
17 - 2: 19.2 MHz
18 Defaults to 26 MHz if not specified.
19- max8952,ramp-speed: voltage ramp speed, must be one of following values:
20 - 0: 32mV/us
21 - 1: 16mV/us
22 - 2: 8mV/us
23 - 3: 4mV/us
24 - 4: 2mV/us
25 - 5: 1mV/us
26 - 6: 0.5mV/us
27 - 7: 0.25mV/us
28 Defaults to 32mV/us if not specified.
29- any available generic properties defined in regulator.txt
30
31Example:
32
33 vdd_arm_reg: pmic@60 {
34 compatible = "maxim,max8952";
35 reg = <0x60>;
36
37 /* max8952-specific properties */
38 max8952,vid-gpios = <&gpx0 3 0>, <&gpx0 4 0>;
39 max8952,en-gpio = <&gpx0 1 0>;
40 max8952,default-mode = <0>;
41 max8952,dvs-mode-microvolt = <1250000>, <1200000>,
42 <1050000>, <950000>;
43 max8952,sync-freq = <0>;
44 max8952,ramp-speed = <0>;
45
46 /* generic regulator properties */
47 regulator-name = "vdd_arm";
48 regulator-min-microvolt = <770000>;
49 regulator-max-microvolt = <1400000>;
50 regulator-always-on;
51 regulator-boot-on;
52 };
diff --git a/MAINTAINERS b/MAINTAINERS
index f053dd144005..7f7a7f5f7386 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8732,7 +8732,7 @@ F: drivers/scsi/vmw_pvscsi.c
8732F: drivers/scsi/vmw_pvscsi.h 8732F: drivers/scsi/vmw_pvscsi.h
8733 8733
8734VOLTAGE AND CURRENT REGULATOR FRAMEWORK 8734VOLTAGE AND CURRENT REGULATOR FRAMEWORK
8735M: Liam Girdwood <lrg@ti.com> 8735M: Liam Girdwood <lgirdwood@gmail.com>
8736M: Mark Brown <broonie@kernel.org> 8736M: Mark Brown <broonie@kernel.org>
8737W: http://opensource.wolfsonmicro.com/node/15 8737W: http://opensource.wolfsonmicro.com/node/15
8738W: http://www.slimlogic.co.uk/?p=48 8738W: http://www.slimlogic.co.uk/?p=48
diff --git a/arch/arm/mach-exynos/mach-universal_c210.c b/arch/arm/mach-exynos/mach-universal_c210.c
index 497fcb793dc1..d28c7fbaba2d 100644
--- a/arch/arm/mach-exynos/mach-universal_c210.c
+++ b/arch/arm/mach-exynos/mach-universal_c210.c
@@ -97,6 +97,19 @@ static struct s3c2410_uartcfg universal_uartcfgs[] __initdata = {
97static struct regulator_consumer_supply max8952_consumer = 97static struct regulator_consumer_supply max8952_consumer =
98 REGULATOR_SUPPLY("vdd_arm", NULL); 98 REGULATOR_SUPPLY("vdd_arm", NULL);
99 99
100static struct regulator_init_data universal_max8952_reg_data = {
101 .constraints = {
102 .name = "VARM_1.2V",
103 .min_uV = 770000,
104 .max_uV = 1400000,
105 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
106 .always_on = 1,
107 .boot_on = 1,
108 },
109 .num_consumer_supplies = 1,
110 .consumer_supplies = &max8952_consumer,
111};
112
100static struct max8952_platform_data universal_max8952_pdata __initdata = { 113static struct max8952_platform_data universal_max8952_pdata __initdata = {
101 .gpio_vid0 = EXYNOS4_GPX0(3), 114 .gpio_vid0 = EXYNOS4_GPX0(3),
102 .gpio_vid1 = EXYNOS4_GPX0(4), 115 .gpio_vid1 = EXYNOS4_GPX0(4),
@@ -105,19 +118,7 @@ static struct max8952_platform_data universal_max8952_pdata __initdata = {
105 .dvs_mode = { 48, 32, 28, 18 }, /* 1.25, 1.20, 1.05, 0.95V */ 118 .dvs_mode = { 48, 32, 28, 18 }, /* 1.25, 1.20, 1.05, 0.95V */
106 .sync_freq = 0, /* default: fastest */ 119 .sync_freq = 0, /* default: fastest */
107 .ramp_speed = 0, /* default: fastest */ 120 .ramp_speed = 0, /* default: fastest */
108 121 .reg_data = &universal_max8952_reg_data,
109 .reg_data = {
110 .constraints = {
111 .name = "VARM_1.2V",
112 .min_uV = 770000,
113 .max_uV = 1400000,
114 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
115 .always_on = 1,
116 .boot_on = 1,
117 },
118 .num_consumer_supplies = 1,
119 .consumer_supplies = &max8952_consumer,
120 },
121}; 122};
122 123
123static struct regulator_consumer_supply lp3974_buck1_consumer = 124static struct regulator_consumer_supply lp3974_buck1_consumer =
diff --git a/arch/arm/mach-ux500/board-mop500-regulators.c b/arch/arm/mach-ux500/board-mop500-regulators.c
index 2a17bc506cff..ff3c9f016591 100644
--- a/arch/arm/mach-ux500/board-mop500-regulators.c
+++ b/arch/arm/mach-ux500/board-mop500-regulators.c
@@ -5,6 +5,7 @@
5 * 5 *
6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> 6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com>
7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> 7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com>
8 * Daniel Willerud <daniel.willerud@stericsson.com>
8 * 9 *
9 * MOP500 board specific initialization for regulators 10 * MOP500 board specific initialization for regulators
10 */ 11 */
@@ -12,6 +13,7 @@
12#include <linux/regulator/machine.h> 13#include <linux/regulator/machine.h>
13#include <linux/regulator/ab8500.h> 14#include <linux/regulator/ab8500.h>
14#include "board-mop500-regulators.h" 15#include "board-mop500-regulators.h"
16#include "id.h"
15 17
16static struct regulator_consumer_supply gpio_en_3v3_consumers[] = { 18static struct regulator_consumer_supply gpio_en_3v3_consumers[] = {
17 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"), 19 REGULATOR_SUPPLY("vdd33a", "smsc911x.0"),
@@ -53,21 +55,37 @@ struct regulator_init_data tps61052_regulator = {
53}; 55};
54 56
55static struct regulator_consumer_supply ab8500_vaux1_consumers[] = { 57static struct regulator_consumer_supply ab8500_vaux1_consumers[] = {
56 /* External displays, connector on board 2v5 power supply */ 58 /* Main display, u8500 R3 uib */
57 REGULATOR_SUPPLY("vaux12v5", "mcde.0"), 59 REGULATOR_SUPPLY("vddi", "mcde_disp_sony_acx424akp.0"),
60 /* Main display, u8500 uib and ST uib */
61 REGULATOR_SUPPLY("vdd1", "samsung_s6d16d0.0"),
62 /* Secondary display, ST uib */
63 REGULATOR_SUPPLY("vdd1", "samsung_s6d16d0.1"),
58 /* SFH7741 proximity sensor */ 64 /* SFH7741 proximity sensor */
59 REGULATOR_SUPPLY("vcc", "gpio-keys.0"), 65 REGULATOR_SUPPLY("vcc", "gpio-keys.0"),
60 /* BH1780GLS ambient light sensor */ 66 /* BH1780GLS ambient light sensor */
61 REGULATOR_SUPPLY("vcc", "2-0029"), 67 REGULATOR_SUPPLY("vcc", "2-0029"),
62 /* lsm303dlh accelerometer */ 68 /* lsm303dlh accelerometer */
63 REGULATOR_SUPPLY("vdd", "3-0018"), 69 REGULATOR_SUPPLY("vdd", "2-0018"),
70 /* lsm303dlhc accelerometer */
71 REGULATOR_SUPPLY("vdd", "2-0019"),
64 /* lsm303dlh magnetometer */ 72 /* lsm303dlh magnetometer */
65 REGULATOR_SUPPLY("vdd", "3-001e"), 73 REGULATOR_SUPPLY("vdd", "2-001e"),
66 /* Rohm BU21013 Touchscreen devices */ 74 /* Rohm BU21013 Touchscreen devices */
67 REGULATOR_SUPPLY("avdd", "3-005c"), 75 REGULATOR_SUPPLY("avdd", "3-005c"),
68 REGULATOR_SUPPLY("avdd", "3-005d"), 76 REGULATOR_SUPPLY("avdd", "3-005d"),
69 /* Synaptics RMI4 Touchscreen device */ 77 /* Synaptics RMI4 Touchscreen device */
70 REGULATOR_SUPPLY("vdd", "3-004b"), 78 REGULATOR_SUPPLY("vdd", "3-004b"),
79 /* L3G4200D Gyroscope device */
80 REGULATOR_SUPPLY("vdd", "2-0068"),
81 /* Ambient light sensor device */
82 REGULATOR_SUPPLY("vdd", "3-0029"),
83 /* Pressure sensor device */
84 REGULATOR_SUPPLY("vdd", "2-005c"),
85 /* Cypress TrueTouch Touchscreen device */
86 REGULATOR_SUPPLY("vcpin", "spi8.0"),
87 /* Camera device */
88 REGULATOR_SUPPLY("vaux12v5", "mmio_camera"),
71}; 89};
72 90
73static struct regulator_consumer_supply ab8500_vaux2_consumers[] = { 91static struct regulator_consumer_supply ab8500_vaux2_consumers[] = {
@@ -75,18 +93,50 @@ static struct regulator_consumer_supply ab8500_vaux2_consumers[] = {
75 REGULATOR_SUPPLY("vmmc", "sdi4"), 93 REGULATOR_SUPPLY("vmmc", "sdi4"),
76 /* AB8500 audio codec */ 94 /* AB8500 audio codec */
77 REGULATOR_SUPPLY("vcc-N2158", "ab8500-codec.0"), 95 REGULATOR_SUPPLY("vcc-N2158", "ab8500-codec.0"),
96 /* AB8500 accessory detect 1 */
97 REGULATOR_SUPPLY("vcc-N2158", "ab8500-acc-det.0"),
98 /* AB8500 Tv-out device */
99 REGULATOR_SUPPLY("vcc-N2158", "mcde_tv_ab8500.4"),
100 /* AV8100 HDMI device */
101 REGULATOR_SUPPLY("vcc-N2158", "av8100_hdmi.3"),
78}; 102};
79 103
80static struct regulator_consumer_supply ab8500_vaux3_consumers[] = { 104static struct regulator_consumer_supply ab8500_vaux3_consumers[] = {
105 REGULATOR_SUPPLY("v-SD-STM", "stm"),
81 /* External MMC slot power */ 106 /* External MMC slot power */
82 REGULATOR_SUPPLY("vmmc", "sdi0"), 107 REGULATOR_SUPPLY("vmmc", "sdi0"),
83}; 108};
84 109
110static struct regulator_consumer_supply ab8505_vaux4_consumers[] = {
111};
112
113static struct regulator_consumer_supply ab8505_vaux5_consumers[] = {
114};
115
116static struct regulator_consumer_supply ab8505_vaux6_consumers[] = {
117};
118
119static struct regulator_consumer_supply ab8505_vaux8_consumers[] = {
120 /* AB8500 audio codec device */
121 REGULATOR_SUPPLY("v-aux8", NULL),
122};
123
124static struct regulator_consumer_supply ab8505_vadc_consumers[] = {
125 /* Internal general-purpose ADC */
126 REGULATOR_SUPPLY("vddadc", "ab8500-gpadc.0"),
127 /* ADC for charger */
128 REGULATOR_SUPPLY("vddadc", "ab8500-charger.0"),
129};
130
85static struct regulator_consumer_supply ab8500_vtvout_consumers[] = { 131static struct regulator_consumer_supply ab8500_vtvout_consumers[] = {
86 /* TV-out DENC supply */ 132 /* TV-out DENC supply */
87 REGULATOR_SUPPLY("vtvout", "ab8500-denc.0"), 133 REGULATOR_SUPPLY("vtvout", "ab8500-denc.0"),
88 /* Internal general-purpose ADC */ 134 /* Internal general-purpose ADC */
89 REGULATOR_SUPPLY("vddadc", "ab8500-gpadc.0"), 135 REGULATOR_SUPPLY("vddadc", "ab8500-gpadc.0"),
136 /* ADC for charger */
137 REGULATOR_SUPPLY("vddadc", "ab8500-charger.0"),
138 /* AB8500 Tv-out device */
139 REGULATOR_SUPPLY("vtvout", "mcde_tv_ab8500.4"),
90}; 140};
91 141
92static struct regulator_consumer_supply ab8500_vaud_consumers[] = { 142static struct regulator_consumer_supply ab8500_vaud_consumers[] = {
@@ -114,77 +164,90 @@ static struct regulator_consumer_supply ab8500_vintcore_consumers[] = {
114 REGULATOR_SUPPLY("v-intcore", NULL), 164 REGULATOR_SUPPLY("v-intcore", NULL),
115 /* USB Transceiver */ 165 /* USB Transceiver */
116 REGULATOR_SUPPLY("vddulpivio18", "ab8500-usb.0"), 166 REGULATOR_SUPPLY("vddulpivio18", "ab8500-usb.0"),
167 /* Handled by abx500 clk driver */
168 REGULATOR_SUPPLY("v-intcore", "abx500-clk.0"),
169};
170
171static struct regulator_consumer_supply ab8505_usb_consumers[] = {
172 /* HS USB OTG physical interface */
173 REGULATOR_SUPPLY("v-ape", NULL),
117}; 174};
118 175
119static struct regulator_consumer_supply ab8500_vana_consumers[] = { 176static struct regulator_consumer_supply ab8500_vana_consumers[] = {
120 /* External displays, connector on board, 1v8 power supply */ 177 /* DB8500 DSI */
121 REGULATOR_SUPPLY("vsmps2", "mcde.0"), 178 REGULATOR_SUPPLY("vdddsi1v2", "mcde"),
179 REGULATOR_SUPPLY("vdddsi1v2", "b2r2_core"),
180 REGULATOR_SUPPLY("vdddsi1v2", "b2r2_1_core"),
181 REGULATOR_SUPPLY("vdddsi1v2", "dsilink.0"),
182 REGULATOR_SUPPLY("vdddsi1v2", "dsilink.1"),
183 REGULATOR_SUPPLY("vdddsi1v2", "dsilink.2"),
184 /* DB8500 CSI */
185 REGULATOR_SUPPLY("vddcsi1v2", "mmio_camera"),
122}; 186};
123 187
124/* ab8500 regulator register initialization */ 188/* ab8500 regulator register initialization */
125struct ab8500_regulator_reg_init 189static struct ab8500_regulator_reg_init ab8500_reg_init[] = {
126ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS] = {
127 /* 190 /*
128 * VanaRequestCtrl = HP/LP depending on VxRequest 191 * VanaRequestCtrl = HP/LP depending on VxRequest
129 * VextSupply1RequestCtrl = HP/LP depending on VxRequest 192 * VextSupply1RequestCtrl = HP/LP depending on VxRequest
130 */ 193 */
131 INIT_REGULATOR_REGISTER(AB8500_REGUREQUESTCTRL2, 0x00), 194 INIT_REGULATOR_REGISTER(AB8500_REGUREQUESTCTRL2, 0xf0, 0x00),
132 /* 195 /*
133 * VextSupply2RequestCtrl = HP/LP depending on VxRequest 196 * VextSupply2RequestCtrl = HP/LP depending on VxRequest
134 * VextSupply3RequestCtrl = HP/LP depending on VxRequest 197 * VextSupply3RequestCtrl = HP/LP depending on VxRequest
135 * Vaux1RequestCtrl = HP/LP depending on VxRequest 198 * Vaux1RequestCtrl = HP/LP depending on VxRequest
136 * Vaux2RequestCtrl = HP/LP depending on VxRequest 199 * Vaux2RequestCtrl = HP/LP depending on VxRequest
137 */ 200 */
138 INIT_REGULATOR_REGISTER(AB8500_REGUREQUESTCTRL3, 0x00), 201 INIT_REGULATOR_REGISTER(AB8500_REGUREQUESTCTRL3, 0xff, 0x00),
139 /* 202 /*
140 * Vaux3RequestCtrl = HP/LP depending on VxRequest 203 * Vaux3RequestCtrl = HP/LP depending on VxRequest
141 * SwHPReq = Control through SWValid disabled 204 * SwHPReq = Control through SWValid disabled
142 */ 205 */
143 INIT_REGULATOR_REGISTER(AB8500_REGUREQUESTCTRL4, 0x00), 206 INIT_REGULATOR_REGISTER(AB8500_REGUREQUESTCTRL4, 0x07, 0x00),
144 /* 207 /*
145 * VanaSysClkReq1HPValid = disabled 208 * VanaSysClkReq1HPValid = disabled
146 * Vaux1SysClkReq1HPValid = disabled 209 * Vaux1SysClkReq1HPValid = disabled
147 * Vaux2SysClkReq1HPValid = disabled 210 * Vaux2SysClkReq1HPValid = disabled
148 * Vaux3SysClkReq1HPValid = disabled 211 * Vaux3SysClkReq1HPValid = disabled
149 */ 212 */
150 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQ1HPVALID1, 0x00), 213 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQ1HPVALID1, 0xe8, 0x00),
151 /* 214 /*
152 * VextSupply1SysClkReq1HPValid = disabled 215 * VextSupply1SysClkReq1HPValid = disabled
153 * VextSupply2SysClkReq1HPValid = disabled 216 * VextSupply2SysClkReq1HPValid = disabled
154 * VextSupply3SysClkReq1HPValid = SysClkReq1 controlled 217 * VextSupply3SysClkReq1HPValid = SysClkReq1 controlled
155 */ 218 */
156 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQ1HPVALID2, 0x40), 219 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQ1HPVALID2, 0x70, 0x40),
157 /* 220 /*
158 * VanaHwHPReq1Valid = disabled 221 * VanaHwHPReq1Valid = disabled
159 * Vaux1HwHPreq1Valid = disabled 222 * Vaux1HwHPreq1Valid = disabled
160 * Vaux2HwHPReq1Valid = disabled 223 * Vaux2HwHPReq1Valid = disabled
161 * Vaux3HwHPReqValid = disabled 224 * Vaux3HwHPReqValid = disabled
162 */ 225 */
163 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ1VALID1, 0x00), 226 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ1VALID1, 0xe8, 0x00),
164 /* 227 /*
165 * VextSupply1HwHPReq1Valid = disabled 228 * VextSupply1HwHPReq1Valid = disabled
166 * VextSupply2HwHPReq1Valid = disabled 229 * VextSupply2HwHPReq1Valid = disabled
167 * VextSupply3HwHPReq1Valid = disabled 230 * VextSupply3HwHPReq1Valid = disabled
168 */ 231 */
169 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ1VALID2, 0x00), 232 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ1VALID2, 0x07, 0x00),
170 /* 233 /*
171 * VanaHwHPReq2Valid = disabled 234 * VanaHwHPReq2Valid = disabled
172 * Vaux1HwHPReq2Valid = disabled 235 * Vaux1HwHPReq2Valid = disabled
173 * Vaux2HwHPReq2Valid = disabled 236 * Vaux2HwHPReq2Valid = disabled
174 * Vaux3HwHPReq2Valid = disabled 237 * Vaux3HwHPReq2Valid = disabled
175 */ 238 */
176 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ2VALID1, 0x00), 239 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ2VALID1, 0xe8, 0x00),
177 /* 240 /*
178 * VextSupply1HwHPReq2Valid = disabled 241 * VextSupply1HwHPReq2Valid = disabled
179 * VextSupply2HwHPReq2Valid = disabled 242 * VextSupply2HwHPReq2Valid = disabled
180 * VextSupply3HwHPReq2Valid = HWReq2 controlled 243 * VextSupply3HwHPReq2Valid = HWReq2 controlled
181 */ 244 */
182 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ2VALID2, 0x04), 245 INIT_REGULATOR_REGISTER(AB8500_REGUHWHPREQ2VALID2, 0x07, 0x04),
183 /* 246 /*
184 * VanaSwHPReqValid = disabled 247 * VanaSwHPReqValid = disabled
185 * Vaux1SwHPReqValid = disabled 248 * Vaux1SwHPReqValid = disabled
186 */ 249 */
187 INIT_REGULATOR_REGISTER(AB8500_REGUSWHPREQVALID1, 0x00), 250 INIT_REGULATOR_REGISTER(AB8500_REGUSWHPREQVALID1, 0xa0, 0x00),
188 /* 251 /*
189 * Vaux2SwHPReqValid = disabled 252 * Vaux2SwHPReqValid = disabled
190 * Vaux3SwHPReqValid = disabled 253 * Vaux3SwHPReqValid = disabled
@@ -192,7 +255,7 @@ ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS] = {
192 * VextSupply2SwHPReqValid = disabled 255 * VextSupply2SwHPReqValid = disabled
193 * VextSupply3SwHPReqValid = disabled 256 * VextSupply3SwHPReqValid = disabled
194 */ 257 */
195 INIT_REGULATOR_REGISTER(AB8500_REGUSWHPREQVALID2, 0x00), 258 INIT_REGULATOR_REGISTER(AB8500_REGUSWHPREQVALID2, 0x1f, 0x00),
196 /* 259 /*
197 * SysClkReq2Valid1 = SysClkReq2 controlled 260 * SysClkReq2Valid1 = SysClkReq2 controlled
198 * SysClkReq3Valid1 = disabled 261 * SysClkReq3Valid1 = disabled
@@ -202,7 +265,7 @@ ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS] = {
202 * SysClkReq7Valid1 = disabled 265 * SysClkReq7Valid1 = disabled
203 * SysClkReq8Valid1 = disabled 266 * SysClkReq8Valid1 = disabled
204 */ 267 */
205 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQVALID1, 0x2a), 268 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQVALID1, 0xfe, 0x2a),
206 /* 269 /*
207 * SysClkReq2Valid2 = disabled 270 * SysClkReq2Valid2 = disabled
208 * SysClkReq3Valid2 = disabled 271 * SysClkReq3Valid2 = disabled
@@ -212,7 +275,7 @@ ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS] = {
212 * SysClkReq7Valid2 = disabled 275 * SysClkReq7Valid2 = disabled
213 * SysClkReq8Valid2 = disabled 276 * SysClkReq8Valid2 = disabled
214 */ 277 */
215 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQVALID2, 0x20), 278 INIT_REGULATOR_REGISTER(AB8500_REGUSYSCLKREQVALID2, 0xfe, 0x20),
216 /* 279 /*
217 * VTVoutEna = disabled 280 * VTVoutEna = disabled
218 * Vintcore12Ena = disabled 281 * Vintcore12Ena = disabled
@@ -220,66 +283,62 @@ ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS] = {
220 * Vintcore12LP = inactive (HP) 283 * Vintcore12LP = inactive (HP)
221 * VTVoutLP = inactive (HP) 284 * VTVoutLP = inactive (HP)
222 */ 285 */
223 INIT_REGULATOR_REGISTER(AB8500_REGUMISC1, 0x10), 286 INIT_REGULATOR_REGISTER(AB8500_REGUMISC1, 0xfe, 0x10),
224 /* 287 /*
225 * VaudioEna = disabled 288 * VaudioEna = disabled
226 * VdmicEna = disabled 289 * VdmicEna = disabled
227 * Vamic1Ena = disabled 290 * Vamic1Ena = disabled
228 * Vamic2Ena = disabled 291 * Vamic2Ena = disabled
229 */ 292 */
230 INIT_REGULATOR_REGISTER(AB8500_VAUDIOSUPPLY, 0x00), 293 INIT_REGULATOR_REGISTER(AB8500_VAUDIOSUPPLY, 0x1e, 0x00),
231 /* 294 /*
232 * Vamic1_dzout = high-Z when Vamic1 is disabled 295 * Vamic1_dzout = high-Z when Vamic1 is disabled
233 * Vamic2_dzout = high-Z when Vamic2 is disabled 296 * Vamic2_dzout = high-Z when Vamic2 is disabled
234 */ 297 */
235 INIT_REGULATOR_REGISTER(AB8500_REGUCTRL1VAMIC, 0x00), 298 INIT_REGULATOR_REGISTER(AB8500_REGUCTRL1VAMIC, 0x03, 0x00),
236 /* 299 /*
237 * VPll = Hw controlled 300 * VPll = Hw controlled (NOTE! PRCMU bits)
238 * VanaRegu = force off 301 * VanaRegu = force off
239 */ 302 */
240 INIT_REGULATOR_REGISTER(AB8500_VPLLVANAREGU, 0x02), 303 INIT_REGULATOR_REGISTER(AB8500_VPLLVANAREGU, 0x0f, 0x02),
241 /* 304 /*
242 * VrefDDREna = disabled 305 * VrefDDREna = disabled
243 * VrefDDRSleepMode = inactive (no pulldown) 306 * VrefDDRSleepMode = inactive (no pulldown)
244 */ 307 */
245 INIT_REGULATOR_REGISTER(AB8500_VREFDDR, 0x00), 308 INIT_REGULATOR_REGISTER(AB8500_VREFDDR, 0x03, 0x00),
246 /* 309 /*
247 * VextSupply1Regu = HW control 310 * VextSupply1Regu = force LP
248 * VextSupply2Regu = HW control 311 * VextSupply2Regu = force OFF
249 * VextSupply3Regu = HW control 312 * VextSupply3Regu = force HP (-> STBB2=LP and TPS=LP)
250 * ExtSupply2Bypass = ExtSupply12LPn ball is 0 when Ena is 0 313 * ExtSupply2Bypass = ExtSupply12LPn ball is 0 when Ena is 0
251 * ExtSupply3Bypass = ExtSupply3LPn ball is 0 when Ena is 0 314 * ExtSupply3Bypass = ExtSupply3LPn ball is 0 when Ena is 0
252 */ 315 */
253 INIT_REGULATOR_REGISTER(AB8500_EXTSUPPLYREGU, 0x2a), 316 INIT_REGULATOR_REGISTER(AB8500_EXTSUPPLYREGU, 0xff, 0x13),
254 /* 317 /*
255 * Vaux1Regu = force HP 318 * Vaux1Regu = force HP
256 * Vaux2Regu = force off 319 * Vaux2Regu = force off
257 */ 320 */
258 INIT_REGULATOR_REGISTER(AB8500_VAUX12REGU, 0x01), 321 INIT_REGULATOR_REGISTER(AB8500_VAUX12REGU, 0x0f, 0x01),
259 /* 322 /*
260 * Vaux3regu = force off 323 * Vaux3Regu = force off
261 */ 324 */
262 INIT_REGULATOR_REGISTER(AB8500_VRF1VAUX3REGU, 0x00), 325 INIT_REGULATOR_REGISTER(AB8500_VRF1VAUX3REGU, 0x03, 0x00),
263 /* 326 /*
264 * Vsmps1 = 1.15V 327 * Vaux1Sel = 2.8 V
265 */ 328 */
266 INIT_REGULATOR_REGISTER(AB8500_VSMPS1SEL1, 0x24), 329 INIT_REGULATOR_REGISTER(AB8500_VAUX1SEL, 0x0f, 0x0C),
267 /*
268 * Vaux1Sel = 2.5 V
269 */
270 INIT_REGULATOR_REGISTER(AB8500_VAUX1SEL, 0x08),
271 /* 330 /*
272 * Vaux2Sel = 2.9 V 331 * Vaux2Sel = 2.9 V
273 */ 332 */
274 INIT_REGULATOR_REGISTER(AB8500_VAUX2SEL, 0x0d), 333 INIT_REGULATOR_REGISTER(AB8500_VAUX2SEL, 0x0f, 0x0d),
275 /* 334 /*
276 * Vaux3Sel = 2.91 V 335 * Vaux3Sel = 2.91 V
277 */ 336 */
278 INIT_REGULATOR_REGISTER(AB8500_VRF1VAUX3SEL, 0x07), 337 INIT_REGULATOR_REGISTER(AB8500_VRF1VAUX3SEL, 0x07, 0x07),
279 /* 338 /*
280 * VextSupply12LP = disabled (no LP) 339 * VextSupply12LP = disabled (no LP)
281 */ 340 */
282 INIT_REGULATOR_REGISTER(AB8500_REGUCTRL2SPARE, 0x00), 341 INIT_REGULATOR_REGISTER(AB8500_REGUCTRL2SPARE, 0x01, 0x00),
283 /* 342 /*
284 * Vaux1Disch = short discharge time 343 * Vaux1Disch = short discharge time
285 * Vaux2Disch = short discharge time 344 * Vaux2Disch = short discharge time
@@ -288,33 +347,26 @@ ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS] = {
288 * VTVoutDisch = short discharge time 347 * VTVoutDisch = short discharge time
289 * VaudioDisch = short discharge time 348 * VaudioDisch = short discharge time
290 */ 349 */
291 INIT_REGULATOR_REGISTER(AB8500_REGUCTRLDISCH, 0x00), 350 INIT_REGULATOR_REGISTER(AB8500_REGUCTRLDISCH, 0xfc, 0x00),
292 /* 351 /*
293 * VanaDisch = short discharge time 352 * VanaDisch = short discharge time
294 * VdmicPullDownEna = pulldown disabled when Vdmic is disabled 353 * VdmicPullDownEna = pulldown disabled when Vdmic is disabled
295 * VdmicDisch = short discharge time 354 * VdmicDisch = short discharge time
296 */ 355 */
297 INIT_REGULATOR_REGISTER(AB8500_REGUCTRLDISCH2, 0x00), 356 INIT_REGULATOR_REGISTER(AB8500_REGUCTRLDISCH2, 0x16, 0x00),
298}; 357};
299 358
300/* AB8500 regulators */ 359/* AB8500 regulators */
301struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = { 360static struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
302 /* supplies to the display/camera */ 361 /* supplies to the display/camera */
303 [AB8500_LDO_AUX1] = { 362 [AB8500_LDO_AUX1] = {
304 .constraints = { 363 .constraints = {
305 .name = "V-DISPLAY", 364 .name = "V-DISPLAY",
306 .min_uV = 2500000, 365 .min_uV = 2800000,
307 .max_uV = 2900000, 366 .max_uV = 3300000,
308 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | 367 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
309 REGULATOR_CHANGE_STATUS, 368 REGULATOR_CHANGE_STATUS,
310 .boot_on = 1, /* display is on at boot */ 369 .boot_on = 1, /* display is on at boot */
311 /*
312 * This voltage cannot be disabled right now because
313 * it is somehow affecting the external MMC
314 * functionality, though that typically will use
315 * AUX3.
316 */
317 .always_on = 1,
318 }, 370 },
319 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaux1_consumers), 371 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaux1_consumers),
320 .consumer_supplies = ab8500_vaux1_consumers, 372 .consumer_supplies = ab8500_vaux1_consumers,
@@ -326,7 +378,10 @@ struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
326 .min_uV = 1100000, 378 .min_uV = 1100000,
327 .max_uV = 3300000, 379 .max_uV = 3300000,
328 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | 380 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
329 REGULATOR_CHANGE_STATUS, 381 REGULATOR_CHANGE_STATUS |
382 REGULATOR_CHANGE_MODE,
383 .valid_modes_mask = REGULATOR_MODE_NORMAL |
384 REGULATOR_MODE_IDLE,
330 }, 385 },
331 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaux2_consumers), 386 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaux2_consumers),
332 .consumer_supplies = ab8500_vaux2_consumers, 387 .consumer_supplies = ab8500_vaux2_consumers,
@@ -338,7 +393,10 @@ struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
338 .min_uV = 1100000, 393 .min_uV = 1100000,
339 .max_uV = 3300000, 394 .max_uV = 3300000,
340 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE | 395 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
341 REGULATOR_CHANGE_STATUS, 396 REGULATOR_CHANGE_STATUS |
397 REGULATOR_CHANGE_MODE,
398 .valid_modes_mask = REGULATOR_MODE_NORMAL |
399 REGULATOR_MODE_IDLE,
342 }, 400 },
343 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaux3_consumers), 401 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaux3_consumers),
344 .consumer_supplies = ab8500_vaux3_consumers, 402 .consumer_supplies = ab8500_vaux3_consumers,
@@ -392,18 +450,614 @@ struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS] = {
392 [AB8500_LDO_INTCORE] = { 450 [AB8500_LDO_INTCORE] = {
393 .constraints = { 451 .constraints = {
394 .name = "V-INTCORE", 452 .name = "V-INTCORE",
395 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 453 .min_uV = 1250000,
454 .max_uV = 1350000,
455 .input_uV = 1800000,
456 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
457 REGULATOR_CHANGE_STATUS |
458 REGULATOR_CHANGE_MODE |
459 REGULATOR_CHANGE_DRMS,
460 .valid_modes_mask = REGULATOR_MODE_NORMAL |
461 REGULATOR_MODE_IDLE,
396 }, 462 },
397 .num_consumer_supplies = ARRAY_SIZE(ab8500_vintcore_consumers), 463 .num_consumer_supplies = ARRAY_SIZE(ab8500_vintcore_consumers),
398 .consumer_supplies = ab8500_vintcore_consumers, 464 .consumer_supplies = ab8500_vintcore_consumers,
399 }, 465 },
400 /* supply for U8500 CSI/DSI, VANA LDO */ 466 /* supply for U8500 CSI-DSI, VANA LDO */
401 [AB8500_LDO_ANA] = { 467 [AB8500_LDO_ANA] = {
402 .constraints = { 468 .constraints = {
403 .name = "V-CSI/DSI", 469 .name = "V-CSI-DSI",
404 .valid_ops_mask = REGULATOR_CHANGE_STATUS, 470 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
405 }, 471 },
406 .num_consumer_supplies = ARRAY_SIZE(ab8500_vana_consumers), 472 .num_consumer_supplies = ARRAY_SIZE(ab8500_vana_consumers),
407 .consumer_supplies = ab8500_vana_consumers, 473 .consumer_supplies = ab8500_vana_consumers,
408 }, 474 },
409}; 475};
476
477/* supply for VextSupply3 */
478static struct regulator_consumer_supply ab8500_ext_supply3_consumers[] = {
479 /* SIM supply for 3 V SIM cards */
480 REGULATOR_SUPPLY("vinvsim", "sim-detect.0"),
481};
482
483/* extended configuration for VextSupply2, only used for HREFP_V20 boards */
484static struct ab8500_ext_regulator_cfg ab8500_ext_supply2 = {
485 .hwreq = true,
486};
487
488/*
489 * AB8500 external regulators
490 */
491static struct regulator_init_data ab8500_ext_regulators[] = {
492 /* fixed Vbat supplies VSMPS1_EXT_1V8 */
493 [AB8500_EXT_SUPPLY1] = {
494 .constraints = {
495 .name = "ab8500-ext-supply1",
496 .min_uV = 1800000,
497 .max_uV = 1800000,
498 .initial_mode = REGULATOR_MODE_IDLE,
499 .boot_on = 1,
500 .always_on = 1,
501 },
502 },
503 /* fixed Vbat supplies VSMPS2_EXT_1V36 and VSMPS5_EXT_1V15 */
504 [AB8500_EXT_SUPPLY2] = {
505 .constraints = {
506 .name = "ab8500-ext-supply2",
507 .min_uV = 1360000,
508 .max_uV = 1360000,
509 },
510 },
511 /* fixed Vbat supplies VSMPS3_EXT_3V4 and VSMPS4_EXT_3V4 */
512 [AB8500_EXT_SUPPLY3] = {
513 .constraints = {
514 .name = "ab8500-ext-supply3",
515 .min_uV = 3400000,
516 .max_uV = 3400000,
517 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
518 .boot_on = 1,
519 },
520 .num_consumer_supplies =
521 ARRAY_SIZE(ab8500_ext_supply3_consumers),
522 .consumer_supplies = ab8500_ext_supply3_consumers,
523 },
524};
525
526/* ab8505 regulator register initialization */
527static struct ab8500_regulator_reg_init ab8505_reg_init[] = {
528 /*
529 * VarmRequestCtrl
530 * VsmpsCRequestCtrl
531 * VsmpsARequestCtrl
532 * VsmpsBRequestCtrl
533 */
534 INIT_REGULATOR_REGISTER(AB8505_REGUREQUESTCTRL1, 0x00, 0x00),
535 /*
536 * VsafeRequestCtrl
537 * VpllRequestCtrl
538 * VanaRequestCtrl = HP/LP depending on VxRequest
539 */
540 INIT_REGULATOR_REGISTER(AB8505_REGUREQUESTCTRL2, 0x30, 0x00),
541 /*
542 * Vaux1RequestCtrl = HP/LP depending on VxRequest
543 * Vaux2RequestCtrl = HP/LP depending on VxRequest
544 */
545 INIT_REGULATOR_REGISTER(AB8505_REGUREQUESTCTRL3, 0xf0, 0x00),
546 /*
547 * Vaux3RequestCtrl = HP/LP depending on VxRequest
548 * SwHPReq = Control through SWValid disabled
549 */
550 INIT_REGULATOR_REGISTER(AB8505_REGUREQUESTCTRL4, 0x07, 0x00),
551 /*
552 * VsmpsASysClkReq1HPValid
553 * VsmpsBSysClkReq1HPValid
554 * VsafeSysClkReq1HPValid
555 * VanaSysClkReq1HPValid = disabled
556 * VpllSysClkReq1HPValid
557 * Vaux1SysClkReq1HPValid = disabled
558 * Vaux2SysClkReq1HPValid = disabled
559 * Vaux3SysClkReq1HPValid = disabled
560 */
561 INIT_REGULATOR_REGISTER(AB8505_REGUSYSCLKREQ1HPVALID1, 0xe8, 0x00),
562 /*
563 * VsmpsCSysClkReq1HPValid
564 * VarmSysClkReq1HPValid
565 * VbbSysClkReq1HPValid
566 * VsmpsMSysClkReq1HPValid
567 */
568 INIT_REGULATOR_REGISTER(AB8505_REGUSYSCLKREQ1HPVALID2, 0x00, 0x00),
569 /*
570 * VsmpsAHwHPReq1Valid
571 * VsmpsBHwHPReq1Valid
572 * VsafeHwHPReq1Valid
573 * VanaHwHPReq1Valid = disabled
574 * VpllHwHPReq1Valid
575 * Vaux1HwHPreq1Valid = disabled
576 * Vaux2HwHPReq1Valid = disabled
577 * Vaux3HwHPReqValid = disabled
578 */
579 INIT_REGULATOR_REGISTER(AB8505_REGUHWHPREQ1VALID1, 0xe8, 0x00),
580 /*
581 * VsmpsMHwHPReq1Valid
582 */
583 INIT_REGULATOR_REGISTER(AB8505_REGUHWHPREQ1VALID2, 0x00, 0x00),
584 /*
585 * VsmpsAHwHPReq2Valid
586 * VsmpsBHwHPReq2Valid
587 * VsafeHwHPReq2Valid
588 * VanaHwHPReq2Valid = disabled
589 * VpllHwHPReq2Valid
590 * Vaux1HwHPReq2Valid = disabled
591 * Vaux2HwHPReq2Valid = disabled
592 * Vaux3HwHPReq2Valid = disabled
593 */
594 INIT_REGULATOR_REGISTER(AB8505_REGUHWHPREQ2VALID1, 0xe8, 0x00),
595 /*
596 * VsmpsMHwHPReq2Valid
597 */
598 INIT_REGULATOR_REGISTER(AB8505_REGUHWHPREQ2VALID2, 0x00, 0x00),
599 /**
600 * VsmpsCSwHPReqValid
601 * VarmSwHPReqValid
602 * VsmpsASwHPReqValid
603 * VsmpsBSwHPReqValid
604 * VsafeSwHPReqValid
605 * VanaSwHPReqValid
606 * VanaSwHPReqValid = disabled
607 * VpllSwHPReqValid
608 * Vaux1SwHPReqValid = disabled
609 */
610 INIT_REGULATOR_REGISTER(AB8505_REGUSWHPREQVALID1, 0xa0, 0x00),
611 /*
612 * Vaux2SwHPReqValid = disabled
613 * Vaux3SwHPReqValid = disabled
614 * VsmpsMSwHPReqValid
615 */
616 INIT_REGULATOR_REGISTER(AB8505_REGUSWHPREQVALID2, 0x03, 0x00),
617 /*
618 * SysClkReq2Valid1 = SysClkReq2 controlled
619 * SysClkReq3Valid1 = disabled
620 * SysClkReq4Valid1 = SysClkReq4 controlled
621 */
622 INIT_REGULATOR_REGISTER(AB8505_REGUSYSCLKREQVALID1, 0x0e, 0x0a),
623 /*
624 * SysClkReq2Valid2 = disabled
625 * SysClkReq3Valid2 = disabled
626 * SysClkReq4Valid2 = disabled
627 */
628 INIT_REGULATOR_REGISTER(AB8505_REGUSYSCLKREQVALID2, 0x0e, 0x00),
629 /*
630 * Vaux4SwHPReqValid
631 * Vaux4HwHPReq2Valid
632 * Vaux4HwHPReq1Valid
633 * Vaux4SysClkReq1HPValid
634 */
635 INIT_REGULATOR_REGISTER(AB8505_REGUVAUX4REQVALID, 0x00, 0x00),
636 /*
637 * VadcEna = disabled
638 * VintCore12Ena = disabled
639 * VintCore12Sel = 1.25 V
640 * VintCore12LP = inactive (HP)
641 * VadcLP = inactive (HP)
642 */
643 INIT_REGULATOR_REGISTER(AB8505_REGUMISC1, 0xfe, 0x10),
644 /*
645 * VaudioEna = disabled
646 * Vaux8Ena = disabled
647 * Vamic1Ena = disabled
648 * Vamic2Ena = disabled
649 */
650 INIT_REGULATOR_REGISTER(AB8505_VAUDIOSUPPLY, 0x1e, 0x00),
651 /*
652 * Vamic1_dzout = high-Z when Vamic1 is disabled
653 * Vamic2_dzout = high-Z when Vamic2 is disabled
654 */
655 INIT_REGULATOR_REGISTER(AB8505_REGUCTRL1VAMIC, 0x03, 0x00),
656 /*
657 * VsmpsARegu
658 * VsmpsASelCtrl
659 * VsmpsAAutoMode
660 * VsmpsAPWMMode
661 */
662 INIT_REGULATOR_REGISTER(AB8505_VSMPSAREGU, 0x00, 0x00),
663 /*
664 * VsmpsBRegu
665 * VsmpsBSelCtrl
666 * VsmpsBAutoMode
667 * VsmpsBPWMMode
668 */
669 INIT_REGULATOR_REGISTER(AB8505_VSMPSBREGU, 0x00, 0x00),
670 /*
671 * VsafeRegu
672 * VsafeSelCtrl
673 * VsafeAutoMode
674 * VsafePWMMode
675 */
676 INIT_REGULATOR_REGISTER(AB8505_VSAFEREGU, 0x00, 0x00),
677 /*
678 * VPll = Hw controlled (NOTE! PRCMU bits)
679 * VanaRegu = force off
680 */
681 INIT_REGULATOR_REGISTER(AB8505_VPLLVANAREGU, 0x0f, 0x02),
682 /*
683 * VextSupply1Regu = force OFF (OTP_ExtSupply12LPnPolarity 1)
684 * VextSupply2Regu = force OFF (OTP_ExtSupply12LPnPolarity 1)
685 * VextSupply3Regu = force OFF (OTP_ExtSupply3LPnPolarity 0)
686 * ExtSupply2Bypass = ExtSupply12LPn ball is 0 when Ena is 0
687 * ExtSupply3Bypass = ExtSupply3LPn ball is 0 when Ena is 0
688 */
689 INIT_REGULATOR_REGISTER(AB8505_EXTSUPPLYREGU, 0xff, 0x30),
690 /*
691 * Vaux1Regu = force HP
692 * Vaux2Regu = force off
693 */
694 INIT_REGULATOR_REGISTER(AB8505_VAUX12REGU, 0x0f, 0x01),
695 /*
696 * Vaux3Regu = force off
697 */
698 INIT_REGULATOR_REGISTER(AB8505_VRF1VAUX3REGU, 0x03, 0x00),
699 /*
700 * VsmpsASel1
701 */
702 INIT_REGULATOR_REGISTER(AB8505_VSMPSASEL1, 0x00, 0x00),
703 /*
704 * VsmpsASel2
705 */
706 INIT_REGULATOR_REGISTER(AB8505_VSMPSASEL2, 0x00, 0x00),
707 /*
708 * VsmpsASel3
709 */
710 INIT_REGULATOR_REGISTER(AB8505_VSMPSASEL3, 0x00, 0x00),
711 /*
712 * VsmpsBSel1
713 */
714 INIT_REGULATOR_REGISTER(AB8505_VSMPSBSEL1, 0x00, 0x00),
715 /*
716 * VsmpsBSel2
717 */
718 INIT_REGULATOR_REGISTER(AB8505_VSMPSBSEL2, 0x00, 0x00),
719 /*
720 * VsmpsBSel3
721 */
722 INIT_REGULATOR_REGISTER(AB8505_VSMPSBSEL3, 0x00, 0x00),
723 /*
724 * VsafeSel1
725 */
726 INIT_REGULATOR_REGISTER(AB8505_VSAFESEL1, 0x00, 0x00),
727 /*
728 * VsafeSel2
729 */
730 INIT_REGULATOR_REGISTER(AB8505_VSAFESEL2, 0x00, 0x00),
731 /*
732 * VsafeSel3
733 */
734 INIT_REGULATOR_REGISTER(AB8505_VSAFESEL3, 0x00, 0x00),
735 /*
736 * Vaux1Sel = 2.8 V
737 */
738 INIT_REGULATOR_REGISTER(AB8505_VAUX1SEL, 0x0f, 0x0C),
739 /*
740 * Vaux2Sel = 2.9 V
741 */
742 INIT_REGULATOR_REGISTER(AB8505_VAUX2SEL, 0x0f, 0x0d),
743 /*
744 * Vaux3Sel = 2.91 V
745 */
746 INIT_REGULATOR_REGISTER(AB8505_VRF1VAUX3SEL, 0x07, 0x07),
747 /*
748 * Vaux4RequestCtrl
749 */
750 INIT_REGULATOR_REGISTER(AB8505_VAUX4REQCTRL, 0x00, 0x00),
751 /*
752 * Vaux4Regu
753 */
754 INIT_REGULATOR_REGISTER(AB8505_VAUX4REGU, 0x00, 0x00),
755 /*
756 * Vaux4Sel
757 */
758 INIT_REGULATOR_REGISTER(AB8505_VAUX4SEL, 0x00, 0x00),
759 /*
760 * Vaux1Disch = short discharge time
761 * Vaux2Disch = short discharge time
762 * Vaux3Disch = short discharge time
763 * Vintcore12Disch = short discharge time
764 * VTVoutDisch = short discharge time
765 * VaudioDisch = short discharge time
766 */
767 INIT_REGULATOR_REGISTER(AB8505_REGUCTRLDISCH, 0xfc, 0x00),
768 /*
769 * VanaDisch = short discharge time
770 * Vaux8PullDownEna = pulldown disabled when Vaux8 is disabled
771 * Vaux8Disch = short discharge time
772 */
773 INIT_REGULATOR_REGISTER(AB8505_REGUCTRLDISCH2, 0x16, 0x00),
774 /*
775 * Vaux4Disch = short discharge time
776 */
777 INIT_REGULATOR_REGISTER(AB8505_REGUCTRLDISCH3, 0x01, 0x00),
778 /*
779 * Vaux5Sel
780 * Vaux5LP
781 * Vaux5Ena
782 * Vaux5Disch
783 * Vaux5DisSfst
784 * Vaux5DisPulld
785 */
786 INIT_REGULATOR_REGISTER(AB8505_CTRLVAUX5, 0x00, 0x00),
787 /*
788 * Vaux6Sel
789 * Vaux6LP
790 * Vaux6Ena
791 * Vaux6DisPulld
792 */
793 INIT_REGULATOR_REGISTER(AB8505_CTRLVAUX6, 0x00, 0x00),
794};
795
796struct regulator_init_data ab8505_regulators[AB8505_NUM_REGULATORS] = {
797 /* supplies to the display/camera */
798 [AB8505_LDO_AUX1] = {
799 .constraints = {
800 .name = "V-DISPLAY",
801 .min_uV = 2800000,
802 .max_uV = 3300000,
803 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
804 REGULATOR_CHANGE_STATUS,
805 .boot_on = 1, /* display is on at boot */
806 },
807 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaux1_consumers),
808 .consumer_supplies = ab8500_vaux1_consumers,
809 },
810 /* supplies to the on-board eMMC */
811 [AB8505_LDO_AUX2] = {
812 .constraints = {
813 .name = "V-eMMC1",
814 .min_uV = 1100000,
815 .max_uV = 3300000,
816 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
817 REGULATOR_CHANGE_STATUS |
818 REGULATOR_CHANGE_MODE,
819 .valid_modes_mask = REGULATOR_MODE_NORMAL |
820 REGULATOR_MODE_IDLE,
821 },
822 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaux2_consumers),
823 .consumer_supplies = ab8500_vaux2_consumers,
824 },
825 /* supply for VAUX3, supplies to SDcard slots */
826 [AB8505_LDO_AUX3] = {
827 .constraints = {
828 .name = "V-MMC-SD",
829 .min_uV = 1100000,
830 .max_uV = 3300000,
831 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
832 REGULATOR_CHANGE_STATUS |
833 REGULATOR_CHANGE_MODE,
834 .valid_modes_mask = REGULATOR_MODE_NORMAL |
835 REGULATOR_MODE_IDLE,
836 },
837 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaux3_consumers),
838 .consumer_supplies = ab8500_vaux3_consumers,
839 },
840 /* supply for VAUX4, supplies to NFC and standalone secure element */
841 [AB8505_LDO_AUX4] = {
842 .constraints = {
843 .name = "V-NFC-SE",
844 .min_uV = 1100000,
845 .max_uV = 3300000,
846 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
847 REGULATOR_CHANGE_STATUS |
848 REGULATOR_CHANGE_MODE,
849 .valid_modes_mask = REGULATOR_MODE_NORMAL |
850 REGULATOR_MODE_IDLE,
851 },
852 .num_consumer_supplies = ARRAY_SIZE(ab8505_vaux4_consumers),
853 .consumer_supplies = ab8505_vaux4_consumers,
854 },
855 /* supply for VAUX5, supplies to TBD */
856 [AB8505_LDO_AUX5] = {
857 .constraints = {
858 .name = "V-AUX5",
859 .min_uV = 1050000,
860 .max_uV = 2790000,
861 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
862 REGULATOR_CHANGE_STATUS |
863 REGULATOR_CHANGE_MODE,
864 .valid_modes_mask = REGULATOR_MODE_NORMAL |
865 REGULATOR_MODE_IDLE,
866 },
867 .num_consumer_supplies = ARRAY_SIZE(ab8505_vaux5_consumers),
868 .consumer_supplies = ab8505_vaux5_consumers,
869 },
870 /* supply for VAUX6, supplies to TBD */
871 [AB8505_LDO_AUX6] = {
872 .constraints = {
873 .name = "V-AUX6",
874 .min_uV = 1050000,
875 .max_uV = 2790000,
876 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
877 REGULATOR_CHANGE_STATUS |
878 REGULATOR_CHANGE_MODE,
879 .valid_modes_mask = REGULATOR_MODE_NORMAL |
880 REGULATOR_MODE_IDLE,
881 },
882 .num_consumer_supplies = ARRAY_SIZE(ab8505_vaux6_consumers),
883 .consumer_supplies = ab8505_vaux6_consumers,
884 },
885 /* supply for gpadc, ADC LDO */
886 [AB8505_LDO_ADC] = {
887 .constraints = {
888 .name = "V-ADC",
889 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
890 },
891 .num_consumer_supplies = ARRAY_SIZE(ab8505_vadc_consumers),
892 .consumer_supplies = ab8505_vadc_consumers,
893 },
894 /* supply for ab8500-vaudio, VAUDIO LDO */
895 [AB8505_LDO_AUDIO] = {
896 .constraints = {
897 .name = "V-AUD",
898 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
899 },
900 .num_consumer_supplies = ARRAY_SIZE(ab8500_vaud_consumers),
901 .consumer_supplies = ab8500_vaud_consumers,
902 },
903 /* supply for v-anamic1 VAMic1-LDO */
904 [AB8505_LDO_ANAMIC1] = {
905 .constraints = {
906 .name = "V-AMIC1",
907 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
908 REGULATOR_CHANGE_MODE,
909 .valid_modes_mask = REGULATOR_MODE_NORMAL |
910 REGULATOR_MODE_IDLE,
911 },
912 .num_consumer_supplies = ARRAY_SIZE(ab8500_vamic1_consumers),
913 .consumer_supplies = ab8500_vamic1_consumers,
914 },
915 /* supply for v-amic2, VAMIC2 LDO, reuse constants for AMIC1 */
916 [AB8505_LDO_ANAMIC2] = {
917 .constraints = {
918 .name = "V-AMIC2",
919 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
920 REGULATOR_CHANGE_MODE,
921 .valid_modes_mask = REGULATOR_MODE_NORMAL |
922 REGULATOR_MODE_IDLE,
923 },
924 .num_consumer_supplies = ARRAY_SIZE(ab8500_vamic2_consumers),
925 .consumer_supplies = ab8500_vamic2_consumers,
926 },
927 /* supply for v-aux8, VAUX8 LDO */
928 [AB8505_LDO_AUX8] = {
929 .constraints = {
930 .name = "V-AUX8",
931 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
932 },
933 .num_consumer_supplies = ARRAY_SIZE(ab8505_vaux8_consumers),
934 .consumer_supplies = ab8505_vaux8_consumers,
935 },
936 /* supply for v-intcore12, VINTCORE12 LDO */
937 [AB8505_LDO_INTCORE] = {
938 .constraints = {
939 .name = "V-INTCORE",
940 .min_uV = 1250000,
941 .max_uV = 1350000,
942 .input_uV = 1800000,
943 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE |
944 REGULATOR_CHANGE_STATUS |
945 REGULATOR_CHANGE_MODE |
946 REGULATOR_CHANGE_DRMS,
947 .valid_modes_mask = REGULATOR_MODE_NORMAL |
948 REGULATOR_MODE_IDLE,
949 },
950 .num_consumer_supplies = ARRAY_SIZE(ab8500_vintcore_consumers),
951 .consumer_supplies = ab8500_vintcore_consumers,
952 },
953 /* supply for LDO USB */
954 [AB8505_LDO_USB] = {
955 .constraints = {
956 .name = "V-USB",
957 .valid_ops_mask = REGULATOR_CHANGE_STATUS |
958 REGULATOR_CHANGE_MODE,
959 .valid_modes_mask = REGULATOR_MODE_NORMAL |
960 REGULATOR_MODE_IDLE,
961 },
962 .num_consumer_supplies = ARRAY_SIZE(ab8505_usb_consumers),
963 .consumer_supplies = ab8505_usb_consumers,
964 },
965 /* supply for U8500 CSI-DSI, VANA LDO */
966 [AB8505_LDO_ANA] = {
967 .constraints = {
968 .name = "V-CSI-DSI",
969 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
970 },
971 .num_consumer_supplies = ARRAY_SIZE(ab8500_vana_consumers),
972 .consumer_supplies = ab8500_vana_consumers,
973 },
974};
975
976struct ab8500_regulator_platform_data ab8500_regulator_plat_data = {
977 .reg_init = ab8500_reg_init,
978 .num_reg_init = ARRAY_SIZE(ab8500_reg_init),
979 .regulator = ab8500_regulators,
980 .num_regulator = ARRAY_SIZE(ab8500_regulators),
981 .ext_regulator = ab8500_ext_regulators,
982 .num_ext_regulator = ARRAY_SIZE(ab8500_ext_regulators),
983};
984
985/* Use the AB8500 init settings for AB8505 as they are the same right now */
986struct ab8500_regulator_platform_data ab8505_regulator_plat_data = {
987 .reg_init = ab8505_reg_init,
988 .num_reg_init = ARRAY_SIZE(ab8505_reg_init),
989 .regulator = ab8505_regulators,
990 .num_regulator = ARRAY_SIZE(ab8505_regulators),
991};
992
993static void ab8500_modify_reg_init(int id, u8 mask, u8 value)
994{
995 int i;
996
997 if (cpu_is_u8520()) {
998 for (i = ARRAY_SIZE(ab8505_reg_init) - 1; i >= 0; i--) {
999 if (ab8505_reg_init[i].id == id) {
1000 u8 initval = ab8505_reg_init[i].value;
1001 initval = (initval & ~mask) | (value & mask);
1002 ab8505_reg_init[i].value = initval;
1003
1004 BUG_ON(mask & ~ab8505_reg_init[i].mask);
1005 return;
1006 }
1007 }
1008 } else {
1009 for (i = ARRAY_SIZE(ab8500_reg_init) - 1; i >= 0; i--) {
1010 if (ab8500_reg_init[i].id == id) {
1011 u8 initval = ab8500_reg_init[i].value;
1012 initval = (initval & ~mask) | (value & mask);
1013 ab8500_reg_init[i].value = initval;
1014
1015 BUG_ON(mask & ~ab8500_reg_init[i].mask);
1016 return;
1017 }
1018 }
1019 }
1020
1021 BUG_ON(1);
1022}
1023
1024void mop500_regulator_init(void)
1025{
1026 struct regulator_init_data *regulator;
1027
1028 /*
1029 * Temporarily turn on Vaux2 on 8520 machine
1030 */
1031 if (cpu_is_u8520()) {
1032 /* Vaux2 initialized to be on */
1033 ab8500_modify_reg_init(AB8505_VAUX12REGU, 0x0f, 0x05);
1034 }
1035
1036 /*
1037 * Handle AB8500_EXT_SUPPLY2 on HREFP_V20_V50 boards (do it for
1038 * all HREFP_V20 boards)
1039 */
1040 if (cpu_is_u8500v20()) {
1041 /* VextSupply2RequestCtrl = HP/OFF depending on VxRequest */
1042 ab8500_modify_reg_init(AB8500_REGUREQUESTCTRL3, 0x01, 0x01);
1043
1044 /* VextSupply2SysClkReq1HPValid = SysClkReq1 controlled */
1045 ab8500_modify_reg_init(AB8500_REGUSYSCLKREQ1HPVALID2,
1046 0x20, 0x20);
1047
1048 /* VextSupply2 = force HP at initialization */
1049 ab8500_modify_reg_init(AB8500_EXTSUPPLYREGU, 0x0c, 0x04);
1050
1051 /* enable VextSupply2 during platform active */
1052 regulator = &ab8500_ext_regulators[AB8500_EXT_SUPPLY2];
1053 regulator->constraints.always_on = 1;
1054
1055 /* disable VextSupply2 in suspend */
1056 regulator = &ab8500_ext_regulators[AB8500_EXT_SUPPLY2];
1057 regulator->constraints.state_mem.disabled = 1;
1058 regulator->constraints.state_standby.disabled = 1;
1059
1060 /* enable VextSupply2 HW control (used in suspend) */
1061 regulator->driver_data = (void *)&ab8500_ext_supply2;
1062 }
1063}
diff --git a/arch/arm/mach-ux500/board-mop500-regulators.h b/arch/arm/mach-ux500/board-mop500-regulators.h
index 78a0642a2206..9bece38fe933 100644
--- a/arch/arm/mach-ux500/board-mop500-regulators.h
+++ b/arch/arm/mach-ux500/board-mop500-regulators.h
@@ -14,10 +14,11 @@
14#include <linux/regulator/machine.h> 14#include <linux/regulator/machine.h>
15#include <linux/regulator/ab8500.h> 15#include <linux/regulator/ab8500.h>
16 16
17extern struct ab8500_regulator_reg_init 17extern struct ab8500_regulator_platform_data ab8500_regulator_plat_data;
18ab8500_regulator_reg_init[AB8500_NUM_REGULATOR_REGISTERS]; 18extern struct ab8500_regulator_platform_data ab8505_regulator_plat_data;
19extern struct regulator_init_data ab8500_regulators[AB8500_NUM_REGULATORS];
20extern struct regulator_init_data tps61052_regulator; 19extern struct regulator_init_data tps61052_regulator;
21extern struct regulator_init_data gpio_en_3v3_regulator; 20extern struct regulator_init_data gpio_en_3v3_regulator;
22 21
22void mop500_regulator_init(void);
23
23#endif 24#endif
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index 87d2d7b38ce9..ce672378a830 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -199,10 +199,7 @@ static struct platform_device snowball_sbnet_dev = {
199 199
200struct ab8500_platform_data ab8500_platdata = { 200struct ab8500_platform_data ab8500_platdata = {
201 .irq_base = MOP500_AB8500_IRQ_BASE, 201 .irq_base = MOP500_AB8500_IRQ_BASE,
202 .regulator_reg_init = ab8500_regulator_reg_init, 202 .regulator = &ab8500_regulator_plat_data,
203 .num_regulator_reg_init = ARRAY_SIZE(ab8500_regulator_reg_init),
204 .regulator = ab8500_regulators,
205 .num_regulator = ARRAY_SIZE(ab8500_regulators),
206 .gpio = &ab8500_gpio_pdata, 203 .gpio = &ab8500_gpio_pdata,
207 .codec = &ab8500_codec_pdata, 204 .codec = &ab8500_codec_pdata,
208}; 205};
diff --git a/drivers/mfd/ab3100-core.c b/drivers/mfd/ab3100-core.c
index 2ec7725f4a08..a9bb140bc86b 100644
--- a/drivers/mfd/ab3100-core.c
+++ b/drivers/mfd/ab3100-core.c
@@ -753,6 +753,7 @@ static struct mfd_cell ab3100_devs[] = {
753 }, 753 },
754 { 754 {
755 .name = "ab3100-regulators", 755 .name = "ab3100-regulators",
756 .of_compatible = "stericsson,ab3100-regulators",
756 .id = -1, 757 .id = -1,
757 }, 758 },
758 { 759 {
diff --git a/drivers/regulator/88pm8607.c b/drivers/regulator/88pm8607.c
index c79ab843333e..493948a38fca 100644
--- a/drivers/regulator/88pm8607.c
+++ b/drivers/regulator/88pm8607.c
@@ -220,35 +220,6 @@ static int pm8607_list_voltage(struct regulator_dev *rdev, unsigned index)
220 return ret; 220 return ret;
221} 221}
222 222
223static int pm8606_preg_enable(struct regulator_dev *rdev)
224{
225 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
226
227 return pm860x_set_bits(info->i2c, rdev->desc->enable_reg,
228 1 << rdev->desc->enable_mask, 0);
229}
230
231static int pm8606_preg_disable(struct regulator_dev *rdev)
232{
233 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
234
235 return pm860x_set_bits(info->i2c, rdev->desc->enable_reg,
236 1 << rdev->desc->enable_mask,
237 1 << rdev->desc->enable_mask);
238}
239
240static int pm8606_preg_is_enabled(struct regulator_dev *rdev)
241{
242 struct pm8607_regulator_info *info = rdev_get_drvdata(rdev);
243 int ret;
244
245 ret = pm860x_reg_read(info->i2c, rdev->desc->enable_reg);
246 if (ret < 0)
247 return ret;
248
249 return !((unsigned char)ret & (1 << rdev->desc->enable_mask));
250}
251
252static struct regulator_ops pm8607_regulator_ops = { 223static struct regulator_ops pm8607_regulator_ops = {
253 .list_voltage = pm8607_list_voltage, 224 .list_voltage = pm8607_list_voltage,
254 .set_voltage_sel = regulator_set_voltage_sel_regmap, 225 .set_voltage_sel = regulator_set_voltage_sel_regmap,
@@ -259,9 +230,9 @@ static struct regulator_ops pm8607_regulator_ops = {
259}; 230};
260 231
261static struct regulator_ops pm8606_preg_ops = { 232static struct regulator_ops pm8606_preg_ops = {
262 .enable = pm8606_preg_enable, 233 .enable = regulator_enable_regmap,
263 .disable = pm8606_preg_disable, 234 .disable = regulator_disable_regmap,
264 .is_enabled = pm8606_preg_is_enabled, 235 .is_enabled = regulator_is_enabled_regmap,
265}; 236};
266 237
267#define PM8606_PREG(ereg, ebit) \ 238#define PM8606_PREG(ereg, ebit) \
@@ -274,6 +245,7 @@ static struct regulator_ops pm8606_preg_ops = {
274 .owner = THIS_MODULE, \ 245 .owner = THIS_MODULE, \
275 .enable_reg = PM8606_##ereg, \ 246 .enable_reg = PM8606_##ereg, \
276 .enable_mask = (ebit), \ 247 .enable_mask = (ebit), \
248 .enable_is_inverted = true, \
277 }, \ 249 }, \
278} 250}
279 251
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 6e8250382def..47a34ff88f98 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -12,7 +12,7 @@ obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
12obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o 12obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
13obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o 13obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o
14obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o 14obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o
15obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o 15obj-$(CONFIG_REGULATOR_AB8500) += ab8500.o ab8500-ext.o
16obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o 16obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o
17obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o 17obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o
18obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o 18obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o
diff --git a/drivers/regulator/ab3100.c b/drivers/regulator/ab3100.c
index 111ec69a3e94..3be9e46594a1 100644
--- a/drivers/regulator/ab3100.c
+++ b/drivers/regulator/ab3100.c
@@ -17,6 +17,8 @@
17#include <linux/regulator/driver.h> 17#include <linux/regulator/driver.h>
18#include <linux/mfd/ab3100.h> 18#include <linux/mfd/ab3100.h>
19#include <linux/mfd/abx500.h> 19#include <linux/mfd/abx500.h>
20#include <linux/of.h>
21#include <linux/regulator/of_regulator.h>
20 22
21/* LDO registers and some handy masking definitions for AB3100 */ 23/* LDO registers and some handy masking definitions for AB3100 */
22#define AB3100_LDO_A 0x40 24#define AB3100_LDO_A 0x40
@@ -345,7 +347,11 @@ static int ab3100_get_voltage_regulator_external(struct regulator_dev *reg)
345{ 347{
346 struct ab3100_regulator *abreg = rdev_get_drvdata(reg); 348 struct ab3100_regulator *abreg = rdev_get_drvdata(reg);
347 349
348 return abreg->plfdata->external_voltage; 350 if (abreg->plfdata)
351 return abreg->plfdata->external_voltage;
352 else
353 /* TODO: encode external voltage into device tree */
354 return 0;
349} 355}
350 356
351static struct regulator_ops regulator_ops_fixed = { 357static struct regulator_ops regulator_ops_fixed = {
@@ -488,16 +494,174 @@ ab3100_regulator_desc[AB3100_NUM_REGULATORS] = {
488 }, 494 },
489}; 495};
490 496
497static int ab3100_regulator_register(struct platform_device *pdev,
498 struct ab3100_platform_data *plfdata,
499 struct regulator_init_data *init_data,
500 struct device_node *np,
501 int id)
502{
503 struct regulator_desc *desc;
504 struct ab3100_regulator *reg;
505 struct regulator_dev *rdev;
506 struct regulator_config config = { };
507 int err, i;
508
509 for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
510 desc = &ab3100_regulator_desc[i];
511 if (desc->id == id)
512 break;
513 }
514 if (desc->id != id)
515 return -ENODEV;
516
517 /* Same index used for this array */
518 reg = &ab3100_regulators[i];
519
520 /*
521 * Initialize per-regulator struct.
522 * Inherit platform data, this comes down from the
523 * i2c boarddata, from the machine. So if you want to
524 * see what it looks like for a certain machine, go
525 * into the machine I2C setup.
526 */
527 reg->dev = &pdev->dev;
528 if (plfdata) {
529 reg->plfdata = plfdata;
530 config.init_data = &plfdata->reg_constraints[i];
531 } else if (np) {
532 config.of_node = np;
533 config.init_data = init_data;
534 }
535 config.dev = &pdev->dev;
536 config.driver_data = reg;
537
538 rdev = regulator_register(desc, &config);
539 if (IS_ERR(rdev)) {
540 err = PTR_ERR(rdev);
541 dev_err(&pdev->dev,
542 "%s: failed to register regulator %s err %d\n",
543 __func__, desc->name,
544 err);
545 return err;
546 }
547
548 /* Then set a pointer back to the registered regulator */
549 reg->rdev = rdev;
550 return 0;
551}
552
553static struct of_regulator_match ab3100_regulator_matches[] = {
554 { .name = "ab3100_ldo_a", .driver_data = (void *) AB3100_LDO_A, },
555 { .name = "ab3100_ldo_c", .driver_data = (void *) AB3100_LDO_C, },
556 { .name = "ab3100_ldo_d", .driver_data = (void *) AB3100_LDO_D, },
557 { .name = "ab3100_ldo_e", .driver_data = (void *) AB3100_LDO_E, },
558 { .name = "ab3100_ldo_f", .driver_data = (void *) AB3100_LDO_F },
559 { .name = "ab3100_ldo_g", .driver_data = (void *) AB3100_LDO_G },
560 { .name = "ab3100_ldo_h", .driver_data = (void *) AB3100_LDO_H },
561 { .name = "ab3100_ldo_k", .driver_data = (void *) AB3100_LDO_K },
562 { .name = "ab3100_ext", .driver_data = (void *) AB3100_LDO_EXT },
563 { .name = "ab3100_buck", .driver_data = (void *) AB3100_BUCK },
564};
565
491/* 566/*
492 * NOTE: the following functions are regulators pluralis - it is the 567 * Initial settings of ab3100 registers.
493 * binding to the AB3100 core driver and the parent platform device 568 * Common for below LDO regulator settings are that
494 * for all the different regulators. 569 * bit 7-5 controls voltage. Bit 4 turns regulator ON(1) or OFF(0).
570 * Bit 3-2 controls sleep enable and bit 1-0 controls sleep mode.
495 */ 571 */
572/* LDO_A 0x16: 2.75V, ON, SLEEP_A, SLEEP OFF GND */
573#define LDO_A_SETTING 0x16
574/* LDO_C 0x10: 2.65V, ON, SLEEP_A or B, SLEEP full power */
575#define LDO_C_SETTING 0x10
576/* LDO_D 0x10: 2.65V, ON, sleep mode not used */
577#define LDO_D_SETTING 0x10
578/* LDO_E 0x10: 1.8V, ON, SLEEP_A or B, SLEEP full power */
579#define LDO_E_SETTING 0x10
580/* LDO_E SLEEP 0x00: 1.8V, not used, SLEEP_A or B, not used */
581#define LDO_E_SLEEP_SETTING 0x00
582/* LDO_F 0xD0: 2.5V, ON, SLEEP_A or B, SLEEP full power */
583#define LDO_F_SETTING 0xD0
584/* LDO_G 0x00: 2.85V, OFF, SLEEP_A or B, SLEEP full power */
585#define LDO_G_SETTING 0x00
586/* LDO_H 0x18: 2.75V, ON, SLEEP_B, SLEEP full power */
587#define LDO_H_SETTING 0x18
588/* LDO_K 0x00: 2.75V, OFF, SLEEP_A or B, SLEEP full power */
589#define LDO_K_SETTING 0x00
590/* LDO_EXT 0x00: Voltage not set, OFF, not used, not used */
591#define LDO_EXT_SETTING 0x00
592/* BUCK 0x7D: 1.2V, ON, SLEEP_A and B, SLEEP low power */
593#define BUCK_SETTING 0x7D
594/* BUCK SLEEP 0xAC: 1.05V, Not used, SLEEP_A and B, Not used */
595#define BUCK_SLEEP_SETTING 0xAC
596
597static const u8 ab3100_reg_initvals[] = {
598 LDO_A_SETTING,
599 LDO_C_SETTING,
600 LDO_E_SETTING,
601 LDO_E_SLEEP_SETTING,
602 LDO_F_SETTING,
603 LDO_G_SETTING,
604 LDO_H_SETTING,
605 LDO_K_SETTING,
606 LDO_EXT_SETTING,
607 BUCK_SETTING,
608 BUCK_SLEEP_SETTING,
609 LDO_D_SETTING,
610};
611
612static int ab3100_regulators_remove(struct platform_device *pdev)
613{
614 int i;
615
616 for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
617 struct ab3100_regulator *reg = &ab3100_regulators[i];
618
619 regulator_unregister(reg->rdev);
620 reg->rdev = NULL;
621 }
622 return 0;
623}
624
625static int
626ab3100_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
627{
628 int err, i;
629
630 /*
631 * Set up the regulator registers, as was previously done with
632 * platform data.
633 */
634 /* Set up regulators */
635 for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) {
636 err = abx500_set_register_interruptible(&pdev->dev, 0,
637 ab3100_reg_init_order[i],
638 ab3100_reg_initvals[i]);
639 if (err) {
640 dev_err(&pdev->dev, "regulator initialization failed with error %d\n",
641 err);
642 return err;
643 }
644 }
645
646 for (i = 0; i < ARRAY_SIZE(ab3100_regulator_matches); i++) {
647 err = ab3100_regulator_register(
648 pdev, NULL, ab3100_regulator_matches[i].init_data,
649 ab3100_regulator_matches[i].of_node,
650 (int) ab3100_regulator_matches[i].driver_data);
651 if (err) {
652 ab3100_regulators_remove(pdev);
653 return err;
654 }
655 }
656
657 return 0;
658}
659
496 660
497static int ab3100_regulators_probe(struct platform_device *pdev) 661static int ab3100_regulators_probe(struct platform_device *pdev)
498{ 662{
499 struct ab3100_platform_data *plfdata = pdev->dev.platform_data; 663 struct ab3100_platform_data *plfdata = pdev->dev.platform_data;
500 struct regulator_config config = { }; 664 struct device_node *np = pdev->dev.of_node;
501 int err = 0; 665 int err = 0;
502 u8 data; 666 u8 data;
503 int i; 667 int i;
@@ -516,6 +680,18 @@ static int ab3100_regulators_probe(struct platform_device *pdev)
516 dev_notice(&pdev->dev, 680 dev_notice(&pdev->dev,
517 "chip is in inactive mode (Cold start)\n"); 681 "chip is in inactive mode (Cold start)\n");
518 682
683 if (np) {
684 err = of_regulator_match(&pdev->dev, np,
685 ab3100_regulator_matches,
686 ARRAY_SIZE(ab3100_regulator_matches));
687 if (err < 0) {
688 dev_err(&pdev->dev,
689 "Error parsing regulator init data: %d\n", err);
690 return err;
691 }
692 return ab3100_regulator_of_probe(pdev, np);
693 }
694
519 /* Set up regulators */ 695 /* Set up regulators */
520 for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) { 696 for (i = 0; i < ARRAY_SIZE(ab3100_reg_init_order); i++) {
521 err = abx500_set_register_interruptible(&pdev->dev, 0, 697 err = abx500_set_register_interruptible(&pdev->dev, 0,
@@ -530,59 +706,19 @@ static int ab3100_regulators_probe(struct platform_device *pdev)
530 706
531 /* Register the regulators */ 707 /* Register the regulators */
532 for (i = 0; i < AB3100_NUM_REGULATORS; i++) { 708 for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
533 struct ab3100_regulator *reg = &ab3100_regulators[i]; 709 struct regulator_desc *desc = &ab3100_regulator_desc[i];
534 struct regulator_dev *rdev;
535
536 /*
537 * Initialize per-regulator struct.
538 * Inherit platform data, this comes down from the
539 * i2c boarddata, from the machine. So if you want to
540 * see what it looks like for a certain machine, go
541 * into the machine I2C setup.
542 */
543 reg->dev = &pdev->dev;
544 reg->plfdata = plfdata;
545 710
546 config.dev = &pdev->dev; 711 err = ab3100_regulator_register(pdev, plfdata, NULL, NULL,
547 config.driver_data = reg; 712 desc->id);
548 config.init_data = &plfdata->reg_constraints[i]; 713 if (err) {
549 714 ab3100_regulators_remove(pdev);
550 /*
551 * Register the regulator, pass around
552 * the ab3100_regulator struct
553 */
554 rdev = regulator_register(&ab3100_regulator_desc[i], &config);
555 if (IS_ERR(rdev)) {
556 err = PTR_ERR(rdev);
557 dev_err(&pdev->dev,
558 "%s: failed to register regulator %s err %d\n",
559 __func__, ab3100_regulator_desc[i].name,
560 err);
561 /* remove the already registered regulators */
562 while (--i >= 0)
563 regulator_unregister(ab3100_regulators[i].rdev);
564 return err; 715 return err;
565 } 716 }
566
567 /* Then set a pointer back to the registered regulator */
568 reg->rdev = rdev;
569 } 717 }
570 718
571 return 0; 719 return 0;
572} 720}
573 721
574static int ab3100_regulators_remove(struct platform_device *pdev)
575{
576 int i;
577
578 for (i = 0; i < AB3100_NUM_REGULATORS; i++) {
579 struct ab3100_regulator *reg = &ab3100_regulators[i];
580
581 regulator_unregister(reg->rdev);
582 }
583 return 0;
584}
585
586static struct platform_driver ab3100_regulators_driver = { 722static struct platform_driver ab3100_regulators_driver = {
587 .driver = { 723 .driver = {
588 .name = "ab3100-regulators", 724 .name = "ab3100-regulators",
diff --git a/drivers/regulator/ab8500-ext.c b/drivers/regulator/ab8500-ext.c
new file mode 100644
index 000000000000..b4d45472aae6
--- /dev/null
+++ b/drivers/regulator/ab8500-ext.c
@@ -0,0 +1,407 @@
1/*
2 * Copyright (C) ST-Ericsson SA 2010
3 *
4 * License Terms: GNU General Public License v2
5 *
6 * Authors: Bengt Jonsson <bengt.g.jonsson@stericsson.com>
7 *
8 * This file is based on drivers/regulator/ab8500.c
9 *
10 * AB8500 external regulators
11 *
12 * ab8500-ext supports the following regulators:
13 * - VextSupply3
14 */
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <linux/err.h>
18#include <linux/module.h>
19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h>
22#include <linux/mfd/abx500.h>
23#include <linux/mfd/abx500/ab8500.h>
24#include <linux/regulator/ab8500.h>
25
26/**
27 * struct ab8500_ext_regulator_info - ab8500 regulator information
28 * @dev: device pointer
29 * @desc: regulator description
30 * @rdev: regulator device
31 * @cfg: regulator configuration (extension of regulator FW configuration)
32 * @update_bank: bank to control on/off
33 * @update_reg: register to control on/off
34 * @update_mask: mask to enable/disable and set mode of regulator
35 * @update_val: bits holding the regulator current mode
36 * @update_val_hp: bits to set EN pin active (LPn pin deactive)
37 * normally this means high power mode
38 * @update_val_lp: bits to set EN pin active and LPn pin active
39 * normally this means low power mode
40 * @update_val_hw: bits to set regulator pins in HW control
41 * SysClkReq pins and logic will choose mode
42 */
43struct ab8500_ext_regulator_info {
44 struct device *dev;
45 struct regulator_desc desc;
46 struct regulator_dev *rdev;
47 struct ab8500_ext_regulator_cfg *cfg;
48 u8 update_bank;
49 u8 update_reg;
50 u8 update_mask;
51 u8 update_val;
52 u8 update_val_hp;
53 u8 update_val_lp;
54 u8 update_val_hw;
55};
56
57static int ab8500_ext_regulator_enable(struct regulator_dev *rdev)
58{
59 int ret;
60 struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev);
61 u8 regval;
62
63 if (info == NULL) {
64 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
65 return -EINVAL;
66 }
67
68 /*
69 * To satisfy both HW high power request and SW request, the regulator
70 * must be on in high power.
71 */
72 if (info->cfg && info->cfg->hwreq)
73 regval = info->update_val_hp;
74 else
75 regval = info->update_val;
76
77 ret = abx500_mask_and_set_register_interruptible(info->dev,
78 info->update_bank, info->update_reg,
79 info->update_mask, regval);
80 if (ret < 0) {
81 dev_err(rdev_get_dev(info->rdev),
82 "couldn't set enable bits for regulator\n");
83 return ret;
84 }
85
86 dev_dbg(rdev_get_dev(rdev),
87 "%s-enable (bank, reg, mask, value): 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
88 info->desc.name, info->update_bank, info->update_reg,
89 info->update_mask, regval);
90
91 return 0;
92}
93
94static int ab8500_ext_regulator_disable(struct regulator_dev *rdev)
95{
96 int ret;
97 struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev);
98 u8 regval;
99
100 if (info == NULL) {
101 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
102 return -EINVAL;
103 }
104
105 /*
106 * Set the regulator in HW request mode if configured
107 */
108 if (info->cfg && info->cfg->hwreq)
109 regval = info->update_val_hw;
110 else
111 regval = 0;
112
113 ret = abx500_mask_and_set_register_interruptible(info->dev,
114 info->update_bank, info->update_reg,
115 info->update_mask, regval);
116 if (ret < 0) {
117 dev_err(rdev_get_dev(info->rdev),
118 "couldn't set disable bits for regulator\n");
119 return ret;
120 }
121
122 dev_dbg(rdev_get_dev(rdev), "%s-disable (bank, reg, mask, value):"
123 " 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
124 info->desc.name, info->update_bank, info->update_reg,
125 info->update_mask, regval);
126
127 return 0;
128}
129
130static int ab8500_ext_regulator_is_enabled(struct regulator_dev *rdev)
131{
132 int ret;
133 struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev);
134 u8 regval;
135
136 if (info == NULL) {
137 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
138 return -EINVAL;
139 }
140
141 ret = abx500_get_register_interruptible(info->dev,
142 info->update_bank, info->update_reg, &regval);
143 if (ret < 0) {
144 dev_err(rdev_get_dev(rdev),
145 "couldn't read 0x%x register\n", info->update_reg);
146 return ret;
147 }
148
149 dev_dbg(rdev_get_dev(rdev), "%s-is_enabled (bank, reg, mask, value):"
150 " 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
151 info->desc.name, info->update_bank, info->update_reg,
152 info->update_mask, regval);
153
154 if (((regval & info->update_mask) == info->update_val_lp) ||
155 ((regval & info->update_mask) == info->update_val_hp))
156 return 1;
157 else
158 return 0;
159}
160
161static int ab8500_ext_regulator_set_mode(struct regulator_dev *rdev,
162 unsigned int mode)
163{
164 int ret = 0;
165 struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev);
166 u8 regval;
167
168 if (info == NULL) {
169 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
170 return -EINVAL;
171 }
172
173 switch (mode) {
174 case REGULATOR_MODE_NORMAL:
175 regval = info->update_val_hp;
176 break;
177 case REGULATOR_MODE_IDLE:
178 regval = info->update_val_lp;
179 break;
180
181 default:
182 return -EINVAL;
183 }
184
185 /* If regulator is enabled and info->cfg->hwreq is set, the regulator
186 must be on in high power, so we don't need to write the register with
187 the same value.
188 */
189 if (ab8500_ext_regulator_is_enabled(rdev) &&
190 !(info->cfg && info->cfg->hwreq)) {
191 ret = abx500_mask_and_set_register_interruptible(info->dev,
192 info->update_bank, info->update_reg,
193 info->update_mask, regval);
194 if (ret < 0) {
195 dev_err(rdev_get_dev(rdev),
196 "Could not set regulator mode.\n");
197 return ret;
198 }
199
200 dev_dbg(rdev_get_dev(rdev),
201 "%s-set_mode (bank, reg, mask, value): "
202 "0x%x, 0x%x, 0x%x, 0x%x\n",
203 info->desc.name, info->update_bank, info->update_reg,
204 info->update_mask, regval);
205 }
206
207 info->update_val = regval;
208
209 return 0;
210}
211
212static unsigned int ab8500_ext_regulator_get_mode(struct regulator_dev *rdev)
213{
214 struct ab8500_ext_regulator_info *info = rdev_get_drvdata(rdev);
215 int ret;
216
217 if (info == NULL) {
218 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
219 return -EINVAL;
220 }
221
222 if (info->update_val == info->update_val_hp)
223 ret = REGULATOR_MODE_NORMAL;
224 else if (info->update_val == info->update_val_lp)
225 ret = REGULATOR_MODE_IDLE;
226 else
227 ret = -EINVAL;
228
229 return ret;
230}
231
232static int ab8500_ext_list_voltage(struct regulator_dev *rdev,
233 unsigned selector)
234{
235 struct regulation_constraints *regu_constraints = rdev->constraints;
236
237 if (regu_constraints == NULL) {
238 dev_err(rdev_get_dev(rdev), "regulator constraints null pointer\n");
239 return -EINVAL;
240 }
241 /* return the uV for the fixed regulators */
242 if (regu_constraints->min_uV && regu_constraints->max_uV) {
243 if (regu_constraints->min_uV == regu_constraints->max_uV)
244 return regu_constraints->min_uV;
245 }
246 return -EINVAL;
247}
248
249static struct regulator_ops ab8500_ext_regulator_ops = {
250 .enable = ab8500_ext_regulator_enable,
251 .disable = ab8500_ext_regulator_disable,
252 .is_enabled = ab8500_ext_regulator_is_enabled,
253 .set_mode = ab8500_ext_regulator_set_mode,
254 .get_mode = ab8500_ext_regulator_get_mode,
255 .list_voltage = ab8500_ext_list_voltage,
256};
257
258static struct ab8500_ext_regulator_info
259 ab8500_ext_regulator_info[AB8500_NUM_EXT_REGULATORS] = {
260 [AB8500_EXT_SUPPLY1] = {
261 .desc = {
262 .name = "VEXTSUPPLY1",
263 .ops = &ab8500_ext_regulator_ops,
264 .type = REGULATOR_VOLTAGE,
265 .id = AB8500_EXT_SUPPLY1,
266 .owner = THIS_MODULE,
267 .n_voltages = 1,
268 },
269 .update_bank = 0x04,
270 .update_reg = 0x08,
271 .update_mask = 0x03,
272 .update_val = 0x01,
273 .update_val_hp = 0x01,
274 .update_val_lp = 0x03,
275 .update_val_hw = 0x02,
276 },
277 [AB8500_EXT_SUPPLY2] = {
278 .desc = {
279 .name = "VEXTSUPPLY2",
280 .ops = &ab8500_ext_regulator_ops,
281 .type = REGULATOR_VOLTAGE,
282 .id = AB8500_EXT_SUPPLY2,
283 .owner = THIS_MODULE,
284 .n_voltages = 1,
285 },
286 .update_bank = 0x04,
287 .update_reg = 0x08,
288 .update_mask = 0x0c,
289 .update_val = 0x04,
290 .update_val_hp = 0x04,
291 .update_val_lp = 0x0c,
292 .update_val_hw = 0x08,
293 },
294 [AB8500_EXT_SUPPLY3] = {
295 .desc = {
296 .name = "VEXTSUPPLY3",
297 .ops = &ab8500_ext_regulator_ops,
298 .type = REGULATOR_VOLTAGE,
299 .id = AB8500_EXT_SUPPLY3,
300 .owner = THIS_MODULE,
301 .n_voltages = 1,
302 },
303 .update_bank = 0x04,
304 .update_reg = 0x08,
305 .update_mask = 0x30,
306 .update_val = 0x10,
307 .update_val_hp = 0x10,
308 .update_val_lp = 0x30,
309 .update_val_hw = 0x20,
310 },
311};
312
313int ab8500_ext_regulator_init(struct platform_device *pdev)
314{
315 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
316 struct ab8500_platform_data *ppdata;
317 struct ab8500_regulator_platform_data *pdata;
318 struct regulator_config config = { };
319 int i, err;
320
321 if (!ab8500) {
322 dev_err(&pdev->dev, "null mfd parent\n");
323 return -EINVAL;
324 }
325 ppdata = dev_get_platdata(ab8500->dev);
326 if (!ppdata) {
327 dev_err(&pdev->dev, "null parent pdata\n");
328 return -EINVAL;
329 }
330
331 pdata = ppdata->regulator;
332 if (!pdata) {
333 dev_err(&pdev->dev, "null pdata\n");
334 return -EINVAL;
335 }
336
337 /* make sure the platform data has the correct size */
338 if (pdata->num_ext_regulator != ARRAY_SIZE(ab8500_ext_regulator_info)) {
339 dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
340 return -EINVAL;
341 }
342
343 /* check for AB8500 2.x */
344 if (is_ab8500_2p0_or_earlier(ab8500)) {
345 struct ab8500_ext_regulator_info *info;
346
347 /* VextSupply3LPn is inverted on AB8500 2.x */
348 info = &ab8500_ext_regulator_info[AB8500_EXT_SUPPLY3];
349 info->update_val = 0x30;
350 info->update_val_hp = 0x30;
351 info->update_val_lp = 0x10;
352 }
353
354 /* register all regulators */
355 for (i = 0; i < ARRAY_SIZE(ab8500_ext_regulator_info); i++) {
356 struct ab8500_ext_regulator_info *info = NULL;
357
358 /* assign per-regulator data */
359 info = &ab8500_ext_regulator_info[i];
360 info->dev = &pdev->dev;
361 info->cfg = (struct ab8500_ext_regulator_cfg *)
362 pdata->ext_regulator[i].driver_data;
363
364 config.dev = &pdev->dev;
365 config.init_data = &pdata->ext_regulator[i];
366 config.driver_data = info;
367
368 /* register regulator with framework */
369 info->rdev = regulator_register(&info->desc, &config);
370 if (IS_ERR(info->rdev)) {
371 err = PTR_ERR(info->rdev);
372 dev_err(&pdev->dev, "failed to register regulator %s\n",
373 info->desc.name);
374 /* when we fail, un-register all earlier regulators */
375 while (--i >= 0) {
376 info = &ab8500_ext_regulator_info[i];
377 regulator_unregister(info->rdev);
378 }
379 return err;
380 }
381
382 dev_dbg(rdev_get_dev(info->rdev),
383 "%s-probed\n", info->desc.name);
384 }
385
386 return 0;
387}
388
389void ab8500_ext_regulator_exit(struct platform_device *pdev)
390{
391 int i;
392
393 for (i = 0; i < ARRAY_SIZE(ab8500_ext_regulator_info); i++) {
394 struct ab8500_ext_regulator_info *info = NULL;
395 info = &ab8500_ext_regulator_info[i];
396
397 dev_vdbg(rdev_get_dev(info->rdev),
398 "%s-remove\n", info->desc.name);
399
400 regulator_unregister(info->rdev);
401 }
402}
403
404MODULE_LICENSE("GPL v2");
405MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
406MODULE_DESCRIPTION("AB8500 external regulator driver");
407MODULE_ALIAS("platform:ab8500-ext-regulator");
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c
index 09014f38a948..f6656b8c28b6 100644
--- a/drivers/regulator/ab8500.c
+++ b/drivers/regulator/ab8500.c
@@ -5,11 +5,15 @@
5 * 5 *
6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson 6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson 7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
8 * Daniel Willerud <daniel.willerud@stericsson.com> for ST-Ericsson
8 * 9 *
9 * AB8500 peripheral regulators 10 * AB8500 peripheral regulators
10 * 11 *
11 * AB8500 supports the following regulators: 12 * AB8500 supports the following regulators:
12 * VAUX1/2/3, VINTCORE, VTVOUT, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA 13 * VAUX1/2/3, VINTCORE, VTVOUT, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA
14 *
15 * AB8505 supports the following regulators:
16 * VAUX1/2/3/4/5/6, VINTCORE, VADC, VUSB, VAUDIO, VAMIC1/2, VDMIC, VANA
13 */ 17 */
14#include <linux/init.h> 18#include <linux/init.h>
15#include <linux/kernel.h> 19#include <linux/kernel.h>
@@ -26,33 +30,64 @@
26#include <linux/slab.h> 30#include <linux/slab.h>
27 31
28/** 32/**
33 * struct ab8500_shared_mode - is used when mode is shared between
34 * two regulators.
35 * @shared_regulator: pointer to the other sharing regulator
36 * @lp_mode_req: low power mode requested by this regulator
37 */
38struct ab8500_shared_mode {
39 struct ab8500_regulator_info *shared_regulator;
40 bool lp_mode_req;
41};
42
43/**
29 * struct ab8500_regulator_info - ab8500 regulator information 44 * struct ab8500_regulator_info - ab8500 regulator information
30 * @dev: device pointer 45 * @dev: device pointer
31 * @desc: regulator description 46 * @desc: regulator description
32 * @regulator_dev: regulator device 47 * @regulator_dev: regulator device
48 * @shared_mode: used when mode is shared between two regulators
49 * @load_lp_uA: maximum load in idle (low power) mode
33 * @update_bank: bank to control on/off 50 * @update_bank: bank to control on/off
34 * @update_reg: register to control on/off 51 * @update_reg: register to control on/off
35 * @update_mask: mask to enable/disable regulator 52 * @update_mask: mask to enable/disable and set mode of regulator
36 * @update_val_enable: bits to enable the regulator in normal (high power) mode 53 * @update_val: bits holding the regulator current mode
54 * @update_val_idle: bits to enable the regulator in idle (low power) mode
55 * @update_val_normal: bits to enable the regulator in normal (high power) mode
56 * @mode_bank: bank with location of mode register
57 * @mode_reg: mode register
58 * @mode_mask: mask for setting mode
59 * @mode_val_idle: mode setting for low power
60 * @mode_val_normal: mode setting for normal power
37 * @voltage_bank: bank to control regulator voltage 61 * @voltage_bank: bank to control regulator voltage
38 * @voltage_reg: register to control regulator voltage 62 * @voltage_reg: register to control regulator voltage
39 * @voltage_mask: mask to control regulator voltage 63 * @voltage_mask: mask to control regulator voltage
40 * @voltage_shift: shift to control regulator voltage
41 * @delay: startup/set voltage delay in us
42 */ 64 */
43struct ab8500_regulator_info { 65struct ab8500_regulator_info {
44 struct device *dev; 66 struct device *dev;
45 struct regulator_desc desc; 67 struct regulator_desc desc;
46 struct regulator_dev *regulator; 68 struct regulator_dev *regulator;
69 struct ab8500_shared_mode *shared_mode;
70 int load_lp_uA;
47 u8 update_bank; 71 u8 update_bank;
48 u8 update_reg; 72 u8 update_reg;
49 u8 update_mask; 73 u8 update_mask;
50 u8 update_val_enable; 74 u8 update_val;
75 u8 update_val_idle;
76 u8 update_val_normal;
77 u8 mode_bank;
78 u8 mode_reg;
79 u8 mode_mask;
80 u8 mode_val_idle;
81 u8 mode_val_normal;
51 u8 voltage_bank; 82 u8 voltage_bank;
52 u8 voltage_reg; 83 u8 voltage_reg;
53 u8 voltage_mask; 84 u8 voltage_mask;
54 u8 voltage_shift; 85 struct {
55 unsigned int delay; 86 u8 voltage_limit;
87 u8 voltage_bank;
88 u8 voltage_reg;
89 u8 voltage_mask;
90 } expand_register;
56}; 91};
57 92
58/* voltage tables for the vauxn/vintcore supplies */ 93/* voltage tables for the vauxn/vintcore supplies */
@@ -86,6 +121,44 @@ static const unsigned int ldo_vaux3_voltages[] = {
86 2910000, 121 2910000,
87}; 122};
88 123
124static const unsigned int ldo_vaux56_voltages[] = {
125 1800000,
126 1050000,
127 1100000,
128 1200000,
129 1500000,
130 2200000,
131 2500000,
132 2790000,
133};
134
135static const unsigned int ldo_vaux3_ab8540_voltages[] = {
136 1200000,
137 1500000,
138 1800000,
139 2100000,
140 2500000,
141 2750000,
142 2790000,
143 2910000,
144 3050000,
145};
146
147static const unsigned int ldo_vaux56_ab8540_voltages[] = {
148 750000, 760000, 770000, 780000, 790000, 800000,
149 810000, 820000, 830000, 840000, 850000, 860000,
150 870000, 880000, 890000, 900000, 910000, 920000,
151 930000, 940000, 950000, 960000, 970000, 980000,
152 990000, 1000000, 1010000, 1020000, 1030000,
153 1040000, 1050000, 1060000, 1070000, 1080000,
154 1090000, 1100000, 1110000, 1120000, 1130000,
155 1140000, 1150000, 1160000, 1170000, 1180000,
156 1190000, 1200000, 1210000, 1220000, 1230000,
157 1240000, 1250000, 1260000, 1270000, 1280000,
158 1290000, 1300000, 1310000, 1320000, 1330000,
159 1340000, 1350000, 1360000, 1800000, 2790000,
160};
161
89static const unsigned int ldo_vintcore_voltages[] = { 162static const unsigned int ldo_vintcore_voltages[] = {
90 1200000, 163 1200000,
91 1225000, 164 1225000,
@@ -96,6 +169,72 @@ static const unsigned int ldo_vintcore_voltages[] = {
96 1350000, 169 1350000,
97}; 170};
98 171
172static const unsigned int ldo_sdio_voltages[] = {
173 1160000,
174 1050000,
175 1100000,
176 1500000,
177 1800000,
178 2200000,
179 2910000,
180 3050000,
181};
182
183static const unsigned int fixed_1200000_voltage[] = {
184 1200000,
185};
186
187static const unsigned int fixed_1800000_voltage[] = {
188 1800000,
189};
190
191static const unsigned int fixed_2000000_voltage[] = {
192 2000000,
193};
194
195static const unsigned int fixed_2050000_voltage[] = {
196 2050000,
197};
198
199static const unsigned int fixed_3300000_voltage[] = {
200 3300000,
201};
202
203static const unsigned int ldo_vana_voltages[] = {
204 1050000,
205 1075000,
206 1100000,
207 1125000,
208 1150000,
209 1175000,
210 1200000,
211 1225000,
212};
213
214static const unsigned int ldo_vaudio_voltages[] = {
215 2000000,
216 2100000,
217 2200000,
218 2300000,
219 2400000,
220 2500000,
221 2600000,
222 2600000, /* Duplicated in Vaudio and IsoUicc Control register. */
223};
224
225static const unsigned int ldo_vdmic_voltages[] = {
226 1800000,
227 1900000,
228 2000000,
229 2850000,
230};
231
232static DEFINE_MUTEX(shared_mode_mutex);
233static struct ab8500_shared_mode ldo_anamic1_shared;
234static struct ab8500_shared_mode ldo_anamic2_shared;
235static struct ab8500_shared_mode ab8540_ldo_anamic1_shared;
236static struct ab8500_shared_mode ab8540_ldo_anamic2_shared;
237
99static int ab8500_regulator_enable(struct regulator_dev *rdev) 238static int ab8500_regulator_enable(struct regulator_dev *rdev)
100{ 239{
101 int ret; 240 int ret;
@@ -108,15 +247,17 @@ static int ab8500_regulator_enable(struct regulator_dev *rdev)
108 247
109 ret = abx500_mask_and_set_register_interruptible(info->dev, 248 ret = abx500_mask_and_set_register_interruptible(info->dev,
110 info->update_bank, info->update_reg, 249 info->update_bank, info->update_reg,
111 info->update_mask, info->update_val_enable); 250 info->update_mask, info->update_val);
112 if (ret < 0) 251 if (ret < 0) {
113 dev_err(rdev_get_dev(rdev), 252 dev_err(rdev_get_dev(rdev),
114 "couldn't set enable bits for regulator\n"); 253 "couldn't set enable bits for regulator\n");
254 return ret;
255 }
115 256
116 dev_vdbg(rdev_get_dev(rdev), 257 dev_vdbg(rdev_get_dev(rdev),
117 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n", 258 "%s-enable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
118 info->desc.name, info->update_bank, info->update_reg, 259 info->desc.name, info->update_bank, info->update_reg,
119 info->update_mask, info->update_val_enable); 260 info->update_mask, info->update_val);
120 261
121 return ret; 262 return ret;
122} 263}
@@ -134,9 +275,11 @@ static int ab8500_regulator_disable(struct regulator_dev *rdev)
134 ret = abx500_mask_and_set_register_interruptible(info->dev, 275 ret = abx500_mask_and_set_register_interruptible(info->dev,
135 info->update_bank, info->update_reg, 276 info->update_bank, info->update_reg,
136 info->update_mask, 0x0); 277 info->update_mask, 0x0);
137 if (ret < 0) 278 if (ret < 0) {
138 dev_err(rdev_get_dev(rdev), 279 dev_err(rdev_get_dev(rdev),
139 "couldn't set disable bits for regulator\n"); 280 "couldn't set disable bits for regulator\n");
281 return ret;
282 }
140 283
141 dev_vdbg(rdev_get_dev(rdev), 284 dev_vdbg(rdev_get_dev(rdev),
142 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n", 285 "%s-disable (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
@@ -172,14 +315,170 @@ static int ab8500_regulator_is_enabled(struct regulator_dev *rdev)
172 info->update_mask, regval); 315 info->update_mask, regval);
173 316
174 if (regval & info->update_mask) 317 if (regval & info->update_mask)
175 return true; 318 return 1;
319 else
320 return 0;
321}
322
323static unsigned int ab8500_regulator_get_optimum_mode(
324 struct regulator_dev *rdev, int input_uV,
325 int output_uV, int load_uA)
326{
327 unsigned int mode;
328
329 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
330
331 if (info == NULL) {
332 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
333 return -EINVAL;
334 }
335
336 if (load_uA <= info->load_lp_uA)
337 mode = REGULATOR_MODE_IDLE;
338 else
339 mode = REGULATOR_MODE_NORMAL;
340
341 return mode;
342}
343
344static int ab8500_regulator_set_mode(struct regulator_dev *rdev,
345 unsigned int mode)
346{
347 int ret = 0;
348 u8 bank, reg, mask, val;
349 bool lp_mode_req = false;
350 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
351
352 if (info == NULL) {
353 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
354 return -EINVAL;
355 }
356
357 if (info->mode_mask) {
358 bank = info->mode_bank;
359 reg = info->mode_reg;
360 mask = info->mode_mask;
361 } else {
362 bank = info->update_bank;
363 reg = info->update_reg;
364 mask = info->update_mask;
365 }
366
367 if (info->shared_mode)
368 mutex_lock(&shared_mode_mutex);
369
370 switch (mode) {
371 case REGULATOR_MODE_NORMAL:
372 if (info->shared_mode)
373 lp_mode_req = false;
374
375 if (info->mode_mask)
376 val = info->mode_val_normal;
377 else
378 val = info->update_val_normal;
379 break;
380 case REGULATOR_MODE_IDLE:
381 if (info->shared_mode) {
382 struct ab8500_regulator_info *shared_regulator;
383
384 shared_regulator = info->shared_mode->shared_regulator;
385 if (!shared_regulator->shared_mode->lp_mode_req) {
386 /* Other regulator prevent LP mode */
387 info->shared_mode->lp_mode_req = true;
388 goto out_unlock;
389 }
390
391 lp_mode_req = true;
392 }
393
394 if (info->mode_mask)
395 val = info->mode_val_idle;
396 else
397 val = info->update_val_idle;
398 break;
399 default:
400 ret = -EINVAL;
401 goto out_unlock;
402 }
403
404 if (info->mode_mask || ab8500_regulator_is_enabled(rdev)) {
405 ret = abx500_mask_and_set_register_interruptible(info->dev,
406 bank, reg, mask, val);
407 if (ret < 0) {
408 dev_err(rdev_get_dev(rdev),
409 "couldn't set regulator mode\n");
410 goto out_unlock;
411 }
412
413 dev_vdbg(rdev_get_dev(rdev),
414 "%s-set_mode (bank, reg, mask, value): "
415 "0x%x, 0x%x, 0x%x, 0x%x\n",
416 info->desc.name, bank, reg,
417 mask, val);
418 }
419
420 if (!info->mode_mask)
421 info->update_val = val;
422
423 if (info->shared_mode)
424 info->shared_mode->lp_mode_req = lp_mode_req;
425
426out_unlock:
427 if (info->shared_mode)
428 mutex_unlock(&shared_mode_mutex);
429
430 return ret;
431}
432
433static unsigned int ab8500_regulator_get_mode(struct regulator_dev *rdev)
434{
435 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
436 int ret;
437 u8 val;
438 u8 val_normal;
439 u8 val_idle;
440
441 if (info == NULL) {
442 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
443 return -EINVAL;
444 }
445
446 /* Need special handling for shared mode */
447 if (info->shared_mode) {
448 if (info->shared_mode->lp_mode_req)
449 return REGULATOR_MODE_IDLE;
450 else
451 return REGULATOR_MODE_NORMAL;
452 }
453
454 if (info->mode_mask) {
455 /* Dedicated register for handling mode */
456 ret = abx500_get_register_interruptible(info->dev,
457 info->mode_bank, info->mode_reg, &val);
458 val = val & info->mode_mask;
459
460 val_normal = info->mode_val_normal;
461 val_idle = info->mode_val_idle;
462 } else {
463 /* Mode register same as enable register */
464 val = info->update_val;
465 val_normal = info->update_val_normal;
466 val_idle = info->update_val_idle;
467 }
468
469 if (val == val_normal)
470 ret = REGULATOR_MODE_NORMAL;
471 else if (val == val_idle)
472 ret = REGULATOR_MODE_IDLE;
176 else 473 else
177 return false; 474 ret = -EINVAL;
475
476 return ret;
178} 477}
179 478
180static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev) 479static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
181{ 480{
182 int ret, val; 481 int ret, voltage_shift;
183 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 482 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
184 u8 regval; 483 u8 regval;
185 484
@@ -188,6 +487,8 @@ static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
188 return -EINVAL; 487 return -EINVAL;
189 } 488 }
190 489
490 voltage_shift = ffs(info->voltage_mask) - 1;
491
191 ret = abx500_get_register_interruptible(info->dev, 492 ret = abx500_get_register_interruptible(info->dev,
192 info->voltage_bank, info->voltage_reg, &regval); 493 info->voltage_bank, info->voltage_reg, &regval);
193 if (ret < 0) { 494 if (ret < 0) {
@@ -201,16 +502,62 @@ static int ab8500_regulator_get_voltage_sel(struct regulator_dev *rdev)
201 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", 502 "0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n",
202 info->desc.name, info->voltage_bank, 503 info->desc.name, info->voltage_bank,
203 info->voltage_reg, info->voltage_mask, 504 info->voltage_reg, info->voltage_mask,
204 info->voltage_shift, regval); 505 voltage_shift, regval);
205 506
206 val = regval & info->voltage_mask; 507 return (regval & info->voltage_mask) >> voltage_shift;
207 return val >> info->voltage_shift; 508}
509
510static int ab8540_aux3_regulator_get_voltage_sel(struct regulator_dev *rdev)
511{
512 int ret, voltage_shift;
513 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
514 u8 regval, regval_expand;
515
516 if (info == NULL) {
517 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
518 return -EINVAL;
519 }
520
521 ret = abx500_get_register_interruptible(info->dev,
522 info->expand_register.voltage_bank,
523 info->expand_register.voltage_reg, &regval_expand);
524 if (ret < 0) {
525 dev_err(rdev_get_dev(rdev),
526 "couldn't read voltage expand reg for regulator\n");
527 return ret;
528 }
529
530 dev_vdbg(rdev_get_dev(rdev),
531 "%s-get_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
532 info->desc.name, info->expand_register.voltage_bank,
533 info->expand_register.voltage_reg,
534 info->expand_register.voltage_mask, regval_expand);
535
536 if (regval_expand & info->expand_register.voltage_mask)
537 return info->expand_register.voltage_limit;
538
539 ret = abx500_get_register_interruptible(info->dev,
540 info->voltage_bank, info->voltage_reg, &regval);
541 if (ret < 0) {
542 dev_err(rdev_get_dev(rdev),
543 "couldn't read voltage reg for regulator\n");
544 return ret;
545 }
546
547 dev_vdbg(rdev_get_dev(rdev),
548 "%s-get_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
549 info->desc.name, info->voltage_bank, info->voltage_reg,
550 info->voltage_mask, regval);
551
552 voltage_shift = ffs(info->voltage_mask) - 1;
553
554 return (regval & info->voltage_mask) >> voltage_shift;
208} 555}
209 556
210static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev, 557static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
211 unsigned selector) 558 unsigned selector)
212{ 559{
213 int ret; 560 int ret, voltage_shift;
214 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 561 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
215 u8 regval; 562 u8 regval;
216 563
@@ -219,8 +566,10 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
219 return -EINVAL; 566 return -EINVAL;
220 } 567 }
221 568
569 voltage_shift = ffs(info->voltage_mask) - 1;
570
222 /* set the registers for the request */ 571 /* set the registers for the request */
223 regval = (u8)selector << info->voltage_shift; 572 regval = (u8)selector << voltage_shift;
224 ret = abx500_mask_and_set_register_interruptible(info->dev, 573 ret = abx500_mask_and_set_register_interruptible(info->dev,
225 info->voltage_bank, info->voltage_reg, 574 info->voltage_bank, info->voltage_reg,
226 info->voltage_mask, regval); 575 info->voltage_mask, regval);
@@ -237,32 +586,121 @@ static int ab8500_regulator_set_voltage_sel(struct regulator_dev *rdev,
237 return ret; 586 return ret;
238} 587}
239 588
240static int ab8500_regulator_set_voltage_time_sel(struct regulator_dev *rdev, 589static int ab8540_aux3_regulator_set_voltage_sel(struct regulator_dev *rdev,
241 unsigned int old_sel, 590 unsigned selector)
242 unsigned int new_sel)
243{ 591{
592 int ret;
244 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev); 593 struct ab8500_regulator_info *info = rdev_get_drvdata(rdev);
594 u8 regval, regval_expand;
595
596 if (info == NULL) {
597 dev_err(rdev_get_dev(rdev), "regulator info null pointer\n");
598 return -EINVAL;
599 }
600
601 if (selector < info->expand_register.voltage_limit) {
602 int voltage_shift = ffs(info->voltage_mask) - 1;
603
604 regval = (u8)selector << voltage_shift;
605 ret = abx500_mask_and_set_register_interruptible(info->dev,
606 info->voltage_bank, info->voltage_reg,
607 info->voltage_mask, regval);
608 if (ret < 0) {
609 dev_err(rdev_get_dev(rdev),
610 "couldn't set voltage reg for regulator\n");
611 return ret;
612 }
245 613
246 return info->delay; 614 dev_vdbg(rdev_get_dev(rdev),
615 "%s-set_voltage (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
616 info->desc.name, info->voltage_bank, info->voltage_reg,
617 info->voltage_mask, regval);
618
619 regval_expand = 0;
620 } else {
621 regval_expand = info->expand_register.voltage_mask;
622 }
623
624 ret = abx500_mask_and_set_register_interruptible(info->dev,
625 info->expand_register.voltage_bank,
626 info->expand_register.voltage_reg,
627 info->expand_register.voltage_mask,
628 regval_expand);
629 if (ret < 0) {
630 dev_err(rdev_get_dev(rdev),
631 "couldn't set expand voltage reg for regulator\n");
632 return ret;
633 }
634
635 dev_vdbg(rdev_get_dev(rdev),
636 "%s-set_voltage expand (bank, reg, mask, value): 0x%x, 0x%x, 0x%x, 0x%x\n",
637 info->desc.name, info->expand_register.voltage_bank,
638 info->expand_register.voltage_reg,
639 info->expand_register.voltage_mask, regval_expand);
640
641 return 0;
247} 642}
248 643
249static struct regulator_ops ab8500_regulator_ops = { 644static struct regulator_ops ab8500_regulator_volt_mode_ops = {
645 .enable = ab8500_regulator_enable,
646 .disable = ab8500_regulator_disable,
647 .is_enabled = ab8500_regulator_is_enabled,
648 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
649 .set_mode = ab8500_regulator_set_mode,
650 .get_mode = ab8500_regulator_get_mode,
651 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
652 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
653 .list_voltage = regulator_list_voltage_table,
654};
655
656static struct regulator_ops ab8540_aux3_regulator_volt_mode_ops = {
657 .enable = ab8500_regulator_enable,
658 .disable = ab8500_regulator_disable,
659 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
660 .set_mode = ab8500_regulator_set_mode,
661 .get_mode = ab8500_regulator_get_mode,
662 .is_enabled = ab8500_regulator_is_enabled,
663 .get_voltage_sel = ab8540_aux3_regulator_get_voltage_sel,
664 .set_voltage_sel = ab8540_aux3_regulator_set_voltage_sel,
665 .list_voltage = regulator_list_voltage_table,
666};
667
668static struct regulator_ops ab8500_regulator_volt_ops = {
250 .enable = ab8500_regulator_enable, 669 .enable = ab8500_regulator_enable,
251 .disable = ab8500_regulator_disable, 670 .disable = ab8500_regulator_disable,
252 .is_enabled = ab8500_regulator_is_enabled, 671 .is_enabled = ab8500_regulator_is_enabled,
253 .get_voltage_sel = ab8500_regulator_get_voltage_sel, 672 .get_voltage_sel = ab8500_regulator_get_voltage_sel,
254 .set_voltage_sel = ab8500_regulator_set_voltage_sel, 673 .set_voltage_sel = ab8500_regulator_set_voltage_sel,
255 .list_voltage = regulator_list_voltage_table, 674 .list_voltage = regulator_list_voltage_table,
256 .set_voltage_time_sel = ab8500_regulator_set_voltage_time_sel,
257}; 675};
258 676
259static struct regulator_ops ab8500_regulator_fixed_ops = { 677static struct regulator_ops ab8500_regulator_mode_ops = {
678 .enable = ab8500_regulator_enable,
679 .disable = ab8500_regulator_disable,
680 .is_enabled = ab8500_regulator_is_enabled,
681 .get_optimum_mode = ab8500_regulator_get_optimum_mode,
682 .set_mode = ab8500_regulator_set_mode,
683 .get_mode = ab8500_regulator_get_mode,
684 .list_voltage = regulator_list_voltage_table,
685};
686
687static struct regulator_ops ab8500_regulator_ops = {
688 .enable = ab8500_regulator_enable,
689 .disable = ab8500_regulator_disable,
690 .is_enabled = ab8500_regulator_is_enabled,
691 .list_voltage = regulator_list_voltage_table,
692};
693
694static struct regulator_ops ab8500_regulator_anamic_mode_ops = {
260 .enable = ab8500_regulator_enable, 695 .enable = ab8500_regulator_enable,
261 .disable = ab8500_regulator_disable, 696 .disable = ab8500_regulator_disable,
262 .is_enabled = ab8500_regulator_is_enabled, 697 .is_enabled = ab8500_regulator_is_enabled,
263 .list_voltage = regulator_list_voltage_linear, 698 .set_mode = ab8500_regulator_set_mode,
699 .get_mode = ab8500_regulator_get_mode,
700 .list_voltage = regulator_list_voltage_table,
264}; 701};
265 702
703/* AB8500 regulator information */
266static struct ab8500_regulator_info 704static struct ab8500_regulator_info
267 ab8500_regulator_info[AB8500_NUM_REGULATORS] = { 705 ab8500_regulator_info[AB8500_NUM_REGULATORS] = {
268 /* 706 /*
@@ -274,17 +712,21 @@ static struct ab8500_regulator_info
274 [AB8500_LDO_AUX1] = { 712 [AB8500_LDO_AUX1] = {
275 .desc = { 713 .desc = {
276 .name = "LDO-AUX1", 714 .name = "LDO-AUX1",
277 .ops = &ab8500_regulator_ops, 715 .ops = &ab8500_regulator_volt_mode_ops,
278 .type = REGULATOR_VOLTAGE, 716 .type = REGULATOR_VOLTAGE,
279 .id = AB8500_LDO_AUX1, 717 .id = AB8500_LDO_AUX1,
280 .owner = THIS_MODULE, 718 .owner = THIS_MODULE,
281 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), 719 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
282 .volt_table = ldo_vauxn_voltages, 720 .volt_table = ldo_vauxn_voltages,
721 .enable_time = 200,
283 }, 722 },
723 .load_lp_uA = 5000,
284 .update_bank = 0x04, 724 .update_bank = 0x04,
285 .update_reg = 0x09, 725 .update_reg = 0x09,
286 .update_mask = 0x03, 726 .update_mask = 0x03,
287 .update_val_enable = 0x01, 727 .update_val = 0x01,
728 .update_val_idle = 0x03,
729 .update_val_normal = 0x01,
288 .voltage_bank = 0x04, 730 .voltage_bank = 0x04,
289 .voltage_reg = 0x1f, 731 .voltage_reg = 0x1f,
290 .voltage_mask = 0x0f, 732 .voltage_mask = 0x0f,
@@ -292,17 +734,21 @@ static struct ab8500_regulator_info
292 [AB8500_LDO_AUX2] = { 734 [AB8500_LDO_AUX2] = {
293 .desc = { 735 .desc = {
294 .name = "LDO-AUX2", 736 .name = "LDO-AUX2",
295 .ops = &ab8500_regulator_ops, 737 .ops = &ab8500_regulator_volt_mode_ops,
296 .type = REGULATOR_VOLTAGE, 738 .type = REGULATOR_VOLTAGE,
297 .id = AB8500_LDO_AUX2, 739 .id = AB8500_LDO_AUX2,
298 .owner = THIS_MODULE, 740 .owner = THIS_MODULE,
299 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages), 741 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
300 .volt_table = ldo_vauxn_voltages, 742 .volt_table = ldo_vauxn_voltages,
743 .enable_time = 200,
301 }, 744 },
745 .load_lp_uA = 5000,
302 .update_bank = 0x04, 746 .update_bank = 0x04,
303 .update_reg = 0x09, 747 .update_reg = 0x09,
304 .update_mask = 0x0c, 748 .update_mask = 0x0c,
305 .update_val_enable = 0x04, 749 .update_val = 0x04,
750 .update_val_idle = 0x0c,
751 .update_val_normal = 0x04,
306 .voltage_bank = 0x04, 752 .voltage_bank = 0x04,
307 .voltage_reg = 0x20, 753 .voltage_reg = 0x20,
308 .voltage_mask = 0x0f, 754 .voltage_mask = 0x0f,
@@ -310,17 +756,21 @@ static struct ab8500_regulator_info
310 [AB8500_LDO_AUX3] = { 756 [AB8500_LDO_AUX3] = {
311 .desc = { 757 .desc = {
312 .name = "LDO-AUX3", 758 .name = "LDO-AUX3",
313 .ops = &ab8500_regulator_ops, 759 .ops = &ab8500_regulator_volt_mode_ops,
314 .type = REGULATOR_VOLTAGE, 760 .type = REGULATOR_VOLTAGE,
315 .id = AB8500_LDO_AUX3, 761 .id = AB8500_LDO_AUX3,
316 .owner = THIS_MODULE, 762 .owner = THIS_MODULE,
317 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages), 763 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
318 .volt_table = ldo_vaux3_voltages, 764 .volt_table = ldo_vaux3_voltages,
765 .enable_time = 450,
319 }, 766 },
767 .load_lp_uA = 5000,
320 .update_bank = 0x04, 768 .update_bank = 0x04,
321 .update_reg = 0x0a, 769 .update_reg = 0x0a,
322 .update_mask = 0x03, 770 .update_mask = 0x03,
323 .update_val_enable = 0x01, 771 .update_val = 0x01,
772 .update_val_idle = 0x03,
773 .update_val_normal = 0x01,
324 .voltage_bank = 0x04, 774 .voltage_bank = 0x04,
325 .voltage_reg = 0x21, 775 .voltage_reg = 0x21,
326 .voltage_mask = 0x07, 776 .voltage_mask = 0x07,
@@ -328,21 +778,24 @@ static struct ab8500_regulator_info
328 [AB8500_LDO_INTCORE] = { 778 [AB8500_LDO_INTCORE] = {
329 .desc = { 779 .desc = {
330 .name = "LDO-INTCORE", 780 .name = "LDO-INTCORE",
331 .ops = &ab8500_regulator_ops, 781 .ops = &ab8500_regulator_volt_mode_ops,
332 .type = REGULATOR_VOLTAGE, 782 .type = REGULATOR_VOLTAGE,
333 .id = AB8500_LDO_INTCORE, 783 .id = AB8500_LDO_INTCORE,
334 .owner = THIS_MODULE, 784 .owner = THIS_MODULE,
335 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages), 785 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
336 .volt_table = ldo_vintcore_voltages, 786 .volt_table = ldo_vintcore_voltages,
787 .enable_time = 750,
337 }, 788 },
789 .load_lp_uA = 5000,
338 .update_bank = 0x03, 790 .update_bank = 0x03,
339 .update_reg = 0x80, 791 .update_reg = 0x80,
340 .update_mask = 0x44, 792 .update_mask = 0x44,
341 .update_val_enable = 0x04, 793 .update_val = 0x44,
794 .update_val_idle = 0x44,
795 .update_val_normal = 0x04,
342 .voltage_bank = 0x03, 796 .voltage_bank = 0x03,
343 .voltage_reg = 0x80, 797 .voltage_reg = 0x80,
344 .voltage_mask = 0x38, 798 .voltage_mask = 0x38,
345 .voltage_shift = 3,
346 }, 799 },
347 800
348 /* 801 /*
@@ -353,112 +806,984 @@ static struct ab8500_regulator_info
353 [AB8500_LDO_TVOUT] = { 806 [AB8500_LDO_TVOUT] = {
354 .desc = { 807 .desc = {
355 .name = "LDO-TVOUT", 808 .name = "LDO-TVOUT",
356 .ops = &ab8500_regulator_fixed_ops, 809 .ops = &ab8500_regulator_mode_ops,
357 .type = REGULATOR_VOLTAGE, 810 .type = REGULATOR_VOLTAGE,
358 .id = AB8500_LDO_TVOUT, 811 .id = AB8500_LDO_TVOUT,
359 .owner = THIS_MODULE, 812 .owner = THIS_MODULE,
360 .n_voltages = 1, 813 .n_voltages = 1,
361 .min_uV = 2000000, 814 .volt_table = fixed_2000000_voltage,
815 .enable_time = 500,
816 },
817 .load_lp_uA = 1000,
818 .update_bank = 0x03,
819 .update_reg = 0x80,
820 .update_mask = 0x82,
821 .update_val = 0x02,
822 .update_val_idle = 0x82,
823 .update_val_normal = 0x02,
824 },
825 [AB8500_LDO_AUDIO] = {
826 .desc = {
827 .name = "LDO-AUDIO",
828 .ops = &ab8500_regulator_ops,
829 .type = REGULATOR_VOLTAGE,
830 .id = AB8500_LDO_AUDIO,
831 .owner = THIS_MODULE,
832 .n_voltages = 1,
833 .enable_time = 140,
834 .volt_table = fixed_2000000_voltage,
835 },
836 .update_bank = 0x03,
837 .update_reg = 0x83,
838 .update_mask = 0x02,
839 .update_val = 0x02,
840 },
841 [AB8500_LDO_ANAMIC1] = {
842 .desc = {
843 .name = "LDO-ANAMIC1",
844 .ops = &ab8500_regulator_ops,
845 .type = REGULATOR_VOLTAGE,
846 .id = AB8500_LDO_ANAMIC1,
847 .owner = THIS_MODULE,
848 .n_voltages = 1,
849 .enable_time = 500,
850 .volt_table = fixed_2050000_voltage,
851 },
852 .update_bank = 0x03,
853 .update_reg = 0x83,
854 .update_mask = 0x08,
855 .update_val = 0x08,
856 },
857 [AB8500_LDO_ANAMIC2] = {
858 .desc = {
859 .name = "LDO-ANAMIC2",
860 .ops = &ab8500_regulator_ops,
861 .type = REGULATOR_VOLTAGE,
862 .id = AB8500_LDO_ANAMIC2,
863 .owner = THIS_MODULE,
864 .n_voltages = 1,
865 .enable_time = 500,
866 .volt_table = fixed_2050000_voltage,
867 },
868 .update_bank = 0x03,
869 .update_reg = 0x83,
870 .update_mask = 0x10,
871 .update_val = 0x10,
872 },
873 [AB8500_LDO_DMIC] = {
874 .desc = {
875 .name = "LDO-DMIC",
876 .ops = &ab8500_regulator_ops,
877 .type = REGULATOR_VOLTAGE,
878 .id = AB8500_LDO_DMIC,
879 .owner = THIS_MODULE,
880 .n_voltages = 1,
881 .enable_time = 420,
882 .volt_table = fixed_1800000_voltage,
883 },
884 .update_bank = 0x03,
885 .update_reg = 0x83,
886 .update_mask = 0x04,
887 .update_val = 0x04,
888 },
889
890 /*
891 * Regulators with fixed voltage and normal/idle modes
892 */
893 [AB8500_LDO_ANA] = {
894 .desc = {
895 .name = "LDO-ANA",
896 .ops = &ab8500_regulator_mode_ops,
897 .type = REGULATOR_VOLTAGE,
898 .id = AB8500_LDO_ANA,
899 .owner = THIS_MODULE,
900 .n_voltages = 1,
901 .enable_time = 140,
902 .volt_table = fixed_1200000_voltage,
903 },
904 .load_lp_uA = 1000,
905 .update_bank = 0x04,
906 .update_reg = 0x06,
907 .update_mask = 0x0c,
908 .update_val = 0x04,
909 .update_val_idle = 0x0c,
910 .update_val_normal = 0x04,
911 },
912};
913
914/* AB8505 regulator information */
915static struct ab8500_regulator_info
916 ab8505_regulator_info[AB8505_NUM_REGULATORS] = {
917 /*
918 * Variable Voltage Regulators
919 * name, min mV, max mV,
920 * update bank, reg, mask, enable val
921 * volt bank, reg, mask
922 */
923 [AB8505_LDO_AUX1] = {
924 .desc = {
925 .name = "LDO-AUX1",
926 .ops = &ab8500_regulator_volt_mode_ops,
927 .type = REGULATOR_VOLTAGE,
928 .id = AB8505_LDO_AUX1,
929 .owner = THIS_MODULE,
930 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
931 .volt_table = ldo_vauxn_voltages,
932 },
933 .load_lp_uA = 5000,
934 .update_bank = 0x04,
935 .update_reg = 0x09,
936 .update_mask = 0x03,
937 .update_val = 0x01,
938 .update_val_idle = 0x03,
939 .update_val_normal = 0x01,
940 .voltage_bank = 0x04,
941 .voltage_reg = 0x1f,
942 .voltage_mask = 0x0f,
943 },
944 [AB8505_LDO_AUX2] = {
945 .desc = {
946 .name = "LDO-AUX2",
947 .ops = &ab8500_regulator_volt_mode_ops,
948 .type = REGULATOR_VOLTAGE,
949 .id = AB8505_LDO_AUX2,
950 .owner = THIS_MODULE,
951 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
952 .volt_table = ldo_vauxn_voltages,
953 },
954 .load_lp_uA = 5000,
955 .update_bank = 0x04,
956 .update_reg = 0x09,
957 .update_mask = 0x0c,
958 .update_val = 0x04,
959 .update_val_idle = 0x0c,
960 .update_val_normal = 0x04,
961 .voltage_bank = 0x04,
962 .voltage_reg = 0x20,
963 .voltage_mask = 0x0f,
964 },
965 [AB8505_LDO_AUX3] = {
966 .desc = {
967 .name = "LDO-AUX3",
968 .ops = &ab8500_regulator_volt_mode_ops,
969 .type = REGULATOR_VOLTAGE,
970 .id = AB8505_LDO_AUX3,
971 .owner = THIS_MODULE,
972 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
973 .volt_table = ldo_vaux3_voltages,
974 },
975 .load_lp_uA = 5000,
976 .update_bank = 0x04,
977 .update_reg = 0x0a,
978 .update_mask = 0x03,
979 .update_val = 0x01,
980 .update_val_idle = 0x03,
981 .update_val_normal = 0x01,
982 .voltage_bank = 0x04,
983 .voltage_reg = 0x21,
984 .voltage_mask = 0x07,
985 },
986 [AB8505_LDO_AUX4] = {
987 .desc = {
988 .name = "LDO-AUX4",
989 .ops = &ab8500_regulator_volt_mode_ops,
990 .type = REGULATOR_VOLTAGE,
991 .id = AB8505_LDO_AUX4,
992 .owner = THIS_MODULE,
993 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
994 .volt_table = ldo_vauxn_voltages,
995 },
996 .load_lp_uA = 5000,
997 /* values for Vaux4Regu register */
998 .update_bank = 0x04,
999 .update_reg = 0x2e,
1000 .update_mask = 0x03,
1001 .update_val = 0x01,
1002 .update_val_idle = 0x03,
1003 .update_val_normal = 0x01,
1004 /* values for Vaux4SEL register */
1005 .voltage_bank = 0x04,
1006 .voltage_reg = 0x2f,
1007 .voltage_mask = 0x0f,
1008 },
1009 [AB8505_LDO_AUX5] = {
1010 .desc = {
1011 .name = "LDO-AUX5",
1012 .ops = &ab8500_regulator_volt_mode_ops,
1013 .type = REGULATOR_VOLTAGE,
1014 .id = AB8505_LDO_AUX5,
1015 .owner = THIS_MODULE,
1016 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
1017 .volt_table = ldo_vaux56_voltages,
1018 },
1019 .load_lp_uA = 2000,
1020 /* values for CtrlVaux5 register */
1021 .update_bank = 0x01,
1022 .update_reg = 0x55,
1023 .update_mask = 0x18,
1024 .update_val = 0x10,
1025 .update_val_idle = 0x18,
1026 .update_val_normal = 0x10,
1027 .voltage_bank = 0x01,
1028 .voltage_reg = 0x55,
1029 .voltage_mask = 0x07,
1030 },
1031 [AB8505_LDO_AUX6] = {
1032 .desc = {
1033 .name = "LDO-AUX6",
1034 .ops = &ab8500_regulator_volt_mode_ops,
1035 .type = REGULATOR_VOLTAGE,
1036 .id = AB8505_LDO_AUX6,
1037 .owner = THIS_MODULE,
1038 .n_voltages = ARRAY_SIZE(ldo_vaux56_voltages),
1039 .volt_table = ldo_vaux56_voltages,
1040 },
1041 .load_lp_uA = 2000,
1042 /* values for CtrlVaux6 register */
1043 .update_bank = 0x01,
1044 .update_reg = 0x56,
1045 .update_mask = 0x18,
1046 .update_val = 0x10,
1047 .update_val_idle = 0x18,
1048 .update_val_normal = 0x10,
1049 .voltage_bank = 0x01,
1050 .voltage_reg = 0x56,
1051 .voltage_mask = 0x07,
1052 },
1053 [AB8505_LDO_INTCORE] = {
1054 .desc = {
1055 .name = "LDO-INTCORE",
1056 .ops = &ab8500_regulator_volt_mode_ops,
1057 .type = REGULATOR_VOLTAGE,
1058 .id = AB8505_LDO_INTCORE,
1059 .owner = THIS_MODULE,
1060 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
1061 .volt_table = ldo_vintcore_voltages,
1062 },
1063 .load_lp_uA = 5000,
1064 .update_bank = 0x03,
1065 .update_reg = 0x80,
1066 .update_mask = 0x44,
1067 .update_val = 0x04,
1068 .update_val_idle = 0x44,
1069 .update_val_normal = 0x04,
1070 .voltage_bank = 0x03,
1071 .voltage_reg = 0x80,
1072 .voltage_mask = 0x38,
1073 },
1074
1075 /*
1076 * Fixed Voltage Regulators
1077 * name, fixed mV,
1078 * update bank, reg, mask, enable val
1079 */
1080 [AB8505_LDO_ADC] = {
1081 .desc = {
1082 .name = "LDO-ADC",
1083 .ops = &ab8500_regulator_mode_ops,
1084 .type = REGULATOR_VOLTAGE,
1085 .id = AB8505_LDO_ADC,
1086 .owner = THIS_MODULE,
1087 .n_voltages = 1,
1088 .volt_table = fixed_2000000_voltage,
362 .enable_time = 10000, 1089 .enable_time = 10000,
363 }, 1090 },
364 .delay = 10000, 1091 .load_lp_uA = 1000,
365 .update_bank = 0x03, 1092 .update_bank = 0x03,
366 .update_reg = 0x80, 1093 .update_reg = 0x80,
367 .update_mask = 0x82, 1094 .update_mask = 0x82,
368 .update_val_enable = 0x02, 1095 .update_val = 0x02,
1096 .update_val_idle = 0x82,
1097 .update_val_normal = 0x02,
369 }, 1098 },
370 [AB8500_LDO_USB] = { 1099 [AB8505_LDO_USB] = {
371 .desc = { 1100 .desc = {
372 .name = "LDO-USB", 1101 .name = "LDO-USB",
373 .ops = &ab8500_regulator_fixed_ops, 1102 .ops = &ab8500_regulator_mode_ops,
374 .type = REGULATOR_VOLTAGE, 1103 .type = REGULATOR_VOLTAGE,
375 .id = AB8500_LDO_USB, 1104 .id = AB8505_LDO_USB,
376 .owner = THIS_MODULE, 1105 .owner = THIS_MODULE,
377 .n_voltages = 1, 1106 .n_voltages = 1,
378 .min_uV = 3300000, 1107 .volt_table = fixed_3300000_voltage,
379 }, 1108 },
380 .update_bank = 0x03, 1109 .update_bank = 0x03,
381 .update_reg = 0x82, 1110 .update_reg = 0x82,
382 .update_mask = 0x03, 1111 .update_mask = 0x03,
383 .update_val_enable = 0x01, 1112 .update_val = 0x01,
1113 .update_val_idle = 0x03,
1114 .update_val_normal = 0x01,
384 }, 1115 },
385 [AB8500_LDO_AUDIO] = { 1116 [AB8505_LDO_AUDIO] = {
386 .desc = { 1117 .desc = {
387 .name = "LDO-AUDIO", 1118 .name = "LDO-AUDIO",
388 .ops = &ab8500_regulator_fixed_ops, 1119 .ops = &ab8500_regulator_volt_ops,
389 .type = REGULATOR_VOLTAGE, 1120 .type = REGULATOR_VOLTAGE,
390 .id = AB8500_LDO_AUDIO, 1121 .id = AB8505_LDO_AUDIO,
1122 .owner = THIS_MODULE,
1123 .n_voltages = ARRAY_SIZE(ldo_vaudio_voltages),
1124 .volt_table = ldo_vaudio_voltages,
1125 },
1126 .update_bank = 0x03,
1127 .update_reg = 0x83,
1128 .update_mask = 0x02,
1129 .update_val = 0x02,
1130 .voltage_bank = 0x01,
1131 .voltage_reg = 0x57,
1132 .voltage_mask = 0x70,
1133 },
1134 [AB8505_LDO_ANAMIC1] = {
1135 .desc = {
1136 .name = "LDO-ANAMIC1",
1137 .ops = &ab8500_regulator_anamic_mode_ops,
1138 .type = REGULATOR_VOLTAGE,
1139 .id = AB8505_LDO_ANAMIC1,
1140 .owner = THIS_MODULE,
1141 .n_voltages = 1,
1142 .volt_table = fixed_2050000_voltage,
1143 },
1144 .shared_mode = &ldo_anamic1_shared,
1145 .update_bank = 0x03,
1146 .update_reg = 0x83,
1147 .update_mask = 0x08,
1148 .update_val = 0x08,
1149 .mode_bank = 0x01,
1150 .mode_reg = 0x54,
1151 .mode_mask = 0x04,
1152 .mode_val_idle = 0x04,
1153 .mode_val_normal = 0x00,
1154 },
1155 [AB8505_LDO_ANAMIC2] = {
1156 .desc = {
1157 .name = "LDO-ANAMIC2",
1158 .ops = &ab8500_regulator_anamic_mode_ops,
1159 .type = REGULATOR_VOLTAGE,
1160 .id = AB8505_LDO_ANAMIC2,
391 .owner = THIS_MODULE, 1161 .owner = THIS_MODULE,
392 .n_voltages = 1, 1162 .n_voltages = 1,
393 .min_uV = 2000000, 1163 .volt_table = fixed_2050000_voltage,
1164 },
1165 .shared_mode = &ldo_anamic2_shared,
1166 .update_bank = 0x03,
1167 .update_reg = 0x83,
1168 .update_mask = 0x10,
1169 .update_val = 0x10,
1170 .mode_bank = 0x01,
1171 .mode_reg = 0x54,
1172 .mode_mask = 0x04,
1173 .mode_val_idle = 0x04,
1174 .mode_val_normal = 0x00,
1175 },
1176 [AB8505_LDO_AUX8] = {
1177 .desc = {
1178 .name = "LDO-AUX8",
1179 .ops = &ab8500_regulator_ops,
1180 .type = REGULATOR_VOLTAGE,
1181 .id = AB8505_LDO_AUX8,
1182 .owner = THIS_MODULE,
1183 .n_voltages = 1,
1184 .volt_table = fixed_1800000_voltage,
1185 },
1186 .update_bank = 0x03,
1187 .update_reg = 0x83,
1188 .update_mask = 0x04,
1189 .update_val = 0x04,
1190 },
1191 /*
1192 * Regulators with fixed voltage and normal/idle modes
1193 */
1194 [AB8505_LDO_ANA] = {
1195 .desc = {
1196 .name = "LDO-ANA",
1197 .ops = &ab8500_regulator_volt_mode_ops,
1198 .type = REGULATOR_VOLTAGE,
1199 .id = AB8505_LDO_ANA,
1200 .owner = THIS_MODULE,
1201 .n_voltages = ARRAY_SIZE(ldo_vana_voltages),
1202 .volt_table = ldo_vana_voltages,
1203 },
1204 .load_lp_uA = 1000,
1205 .update_bank = 0x04,
1206 .update_reg = 0x06,
1207 .update_mask = 0x0c,
1208 .update_val = 0x04,
1209 .update_val_idle = 0x0c,
1210 .update_val_normal = 0x04,
1211 .voltage_bank = 0x04,
1212 .voltage_reg = 0x29,
1213 .voltage_mask = 0x7,
1214 },
1215};
1216
1217/* AB9540 regulator information */
1218static struct ab8500_regulator_info
1219 ab9540_regulator_info[AB9540_NUM_REGULATORS] = {
1220 /*
1221 * Variable Voltage Regulators
1222 * name, min mV, max mV,
1223 * update bank, reg, mask, enable val
1224 * volt bank, reg, mask
1225 */
1226 [AB9540_LDO_AUX1] = {
1227 .desc = {
1228 .name = "LDO-AUX1",
1229 .ops = &ab8500_regulator_volt_mode_ops,
1230 .type = REGULATOR_VOLTAGE,
1231 .id = AB9540_LDO_AUX1,
1232 .owner = THIS_MODULE,
1233 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
1234 .volt_table = ldo_vauxn_voltages,
1235 },
1236 .load_lp_uA = 5000,
1237 .update_bank = 0x04,
1238 .update_reg = 0x09,
1239 .update_mask = 0x03,
1240 .update_val = 0x01,
1241 .update_val_idle = 0x03,
1242 .update_val_normal = 0x01,
1243 .voltage_bank = 0x04,
1244 .voltage_reg = 0x1f,
1245 .voltage_mask = 0x0f,
1246 },
1247 [AB9540_LDO_AUX2] = {
1248 .desc = {
1249 .name = "LDO-AUX2",
1250 .ops = &ab8500_regulator_volt_mode_ops,
1251 .type = REGULATOR_VOLTAGE,
1252 .id = AB9540_LDO_AUX2,
1253 .owner = THIS_MODULE,
1254 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
1255 .volt_table = ldo_vauxn_voltages,
1256 },
1257 .load_lp_uA = 5000,
1258 .update_bank = 0x04,
1259 .update_reg = 0x09,
1260 .update_mask = 0x0c,
1261 .update_val = 0x04,
1262 .update_val_idle = 0x0c,
1263 .update_val_normal = 0x04,
1264 .voltage_bank = 0x04,
1265 .voltage_reg = 0x20,
1266 .voltage_mask = 0x0f,
1267 },
1268 [AB9540_LDO_AUX3] = {
1269 .desc = {
1270 .name = "LDO-AUX3",
1271 .ops = &ab8500_regulator_volt_mode_ops,
1272 .type = REGULATOR_VOLTAGE,
1273 .id = AB9540_LDO_AUX3,
1274 .owner = THIS_MODULE,
1275 .n_voltages = ARRAY_SIZE(ldo_vaux3_voltages),
1276 .volt_table = ldo_vaux3_voltages,
1277 },
1278 .load_lp_uA = 5000,
1279 .update_bank = 0x04,
1280 .update_reg = 0x0a,
1281 .update_mask = 0x03,
1282 .update_val = 0x01,
1283 .update_val_idle = 0x03,
1284 .update_val_normal = 0x01,
1285 .voltage_bank = 0x04,
1286 .voltage_reg = 0x21,
1287 .voltage_mask = 0x07,
1288 },
1289 [AB9540_LDO_AUX4] = {
1290 .desc = {
1291 .name = "LDO-AUX4",
1292 .ops = &ab8500_regulator_volt_mode_ops,
1293 .type = REGULATOR_VOLTAGE,
1294 .id = AB9540_LDO_AUX4,
1295 .owner = THIS_MODULE,
1296 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
1297 .volt_table = ldo_vauxn_voltages,
1298 },
1299 .load_lp_uA = 5000,
1300 /* values for Vaux4Regu register */
1301 .update_bank = 0x04,
1302 .update_reg = 0x2e,
1303 .update_mask = 0x03,
1304 .update_val = 0x01,
1305 .update_val_idle = 0x03,
1306 .update_val_normal = 0x01,
1307 /* values for Vaux4SEL register */
1308 .voltage_bank = 0x04,
1309 .voltage_reg = 0x2f,
1310 .voltage_mask = 0x0f,
1311 },
1312 [AB9540_LDO_INTCORE] = {
1313 .desc = {
1314 .name = "LDO-INTCORE",
1315 .ops = &ab8500_regulator_volt_mode_ops,
1316 .type = REGULATOR_VOLTAGE,
1317 .id = AB9540_LDO_INTCORE,
1318 .owner = THIS_MODULE,
1319 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
1320 .volt_table = ldo_vintcore_voltages,
1321 },
1322 .load_lp_uA = 5000,
1323 .update_bank = 0x03,
1324 .update_reg = 0x80,
1325 .update_mask = 0x44,
1326 .update_val = 0x44,
1327 .update_val_idle = 0x44,
1328 .update_val_normal = 0x04,
1329 .voltage_bank = 0x03,
1330 .voltage_reg = 0x80,
1331 .voltage_mask = 0x38,
1332 },
1333
1334 /*
1335 * Fixed Voltage Regulators
1336 * name, fixed mV,
1337 * update bank, reg, mask, enable val
1338 */
1339 [AB9540_LDO_TVOUT] = {
1340 .desc = {
1341 .name = "LDO-TVOUT",
1342 .ops = &ab8500_regulator_mode_ops,
1343 .type = REGULATOR_VOLTAGE,
1344 .id = AB9540_LDO_TVOUT,
1345 .owner = THIS_MODULE,
1346 .n_voltages = 1,
1347 .volt_table = fixed_2000000_voltage,
1348 .enable_time = 10000,
1349 },
1350 .load_lp_uA = 1000,
1351 .update_bank = 0x03,
1352 .update_reg = 0x80,
1353 .update_mask = 0x82,
1354 .update_val = 0x02,
1355 .update_val_idle = 0x82,
1356 .update_val_normal = 0x02,
1357 },
1358 [AB9540_LDO_USB] = {
1359 .desc = {
1360 .name = "LDO-USB",
1361 .ops = &ab8500_regulator_ops,
1362 .type = REGULATOR_VOLTAGE,
1363 .id = AB9540_LDO_USB,
1364 .owner = THIS_MODULE,
1365 .n_voltages = 1,
1366 .volt_table = fixed_3300000_voltage,
1367 },
1368 .update_bank = 0x03,
1369 .update_reg = 0x82,
1370 .update_mask = 0x03,
1371 .update_val = 0x01,
1372 .update_val_idle = 0x03,
1373 .update_val_normal = 0x01,
1374 },
1375 [AB9540_LDO_AUDIO] = {
1376 .desc = {
1377 .name = "LDO-AUDIO",
1378 .ops = &ab8500_regulator_ops,
1379 .type = REGULATOR_VOLTAGE,
1380 .id = AB9540_LDO_AUDIO,
1381 .owner = THIS_MODULE,
1382 .n_voltages = 1,
1383 .volt_table = fixed_2000000_voltage,
394 }, 1384 },
395 .update_bank = 0x03, 1385 .update_bank = 0x03,
396 .update_reg = 0x83, 1386 .update_reg = 0x83,
397 .update_mask = 0x02, 1387 .update_mask = 0x02,
398 .update_val_enable = 0x02, 1388 .update_val = 0x02,
399 }, 1389 },
400 [AB8500_LDO_ANAMIC1] = { 1390 [AB9540_LDO_ANAMIC1] = {
401 .desc = { 1391 .desc = {
402 .name = "LDO-ANAMIC1", 1392 .name = "LDO-ANAMIC1",
403 .ops = &ab8500_regulator_fixed_ops, 1393 .ops = &ab8500_regulator_ops,
404 .type = REGULATOR_VOLTAGE, 1394 .type = REGULATOR_VOLTAGE,
405 .id = AB8500_LDO_ANAMIC1, 1395 .id = AB9540_LDO_ANAMIC1,
406 .owner = THIS_MODULE, 1396 .owner = THIS_MODULE,
407 .n_voltages = 1, 1397 .n_voltages = 1,
408 .min_uV = 2050000, 1398 .volt_table = fixed_2050000_voltage,
409 }, 1399 },
410 .update_bank = 0x03, 1400 .update_bank = 0x03,
411 .update_reg = 0x83, 1401 .update_reg = 0x83,
412 .update_mask = 0x08, 1402 .update_mask = 0x08,
413 .update_val_enable = 0x08, 1403 .update_val = 0x08,
414 }, 1404 },
415 [AB8500_LDO_ANAMIC2] = { 1405 [AB9540_LDO_ANAMIC2] = {
416 .desc = { 1406 .desc = {
417 .name = "LDO-ANAMIC2", 1407 .name = "LDO-ANAMIC2",
418 .ops = &ab8500_regulator_fixed_ops, 1408 .ops = &ab8500_regulator_ops,
419 .type = REGULATOR_VOLTAGE, 1409 .type = REGULATOR_VOLTAGE,
420 .id = AB8500_LDO_ANAMIC2, 1410 .id = AB9540_LDO_ANAMIC2,
421 .owner = THIS_MODULE, 1411 .owner = THIS_MODULE,
422 .n_voltages = 1, 1412 .n_voltages = 1,
423 .min_uV = 2050000, 1413 .volt_table = fixed_2050000_voltage,
424 }, 1414 },
425 .update_bank = 0x03, 1415 .update_bank = 0x03,
426 .update_reg = 0x83, 1416 .update_reg = 0x83,
427 .update_mask = 0x10, 1417 .update_mask = 0x10,
428 .update_val_enable = 0x10, 1418 .update_val = 0x10,
429 }, 1419 },
430 [AB8500_LDO_DMIC] = { 1420 [AB9540_LDO_DMIC] = {
431 .desc = { 1421 .desc = {
432 .name = "LDO-DMIC", 1422 .name = "LDO-DMIC",
433 .ops = &ab8500_regulator_fixed_ops, 1423 .ops = &ab8500_regulator_ops,
434 .type = REGULATOR_VOLTAGE, 1424 .type = REGULATOR_VOLTAGE,
435 .id = AB8500_LDO_DMIC, 1425 .id = AB9540_LDO_DMIC,
436 .owner = THIS_MODULE, 1426 .owner = THIS_MODULE,
437 .n_voltages = 1, 1427 .n_voltages = 1,
438 .min_uV = 1800000, 1428 .volt_table = fixed_1800000_voltage,
439 }, 1429 },
440 .update_bank = 0x03, 1430 .update_bank = 0x03,
441 .update_reg = 0x83, 1431 .update_reg = 0x83,
442 .update_mask = 0x04, 1432 .update_mask = 0x04,
443 .update_val_enable = 0x04, 1433 .update_val = 0x04,
444 }, 1434 },
445 [AB8500_LDO_ANA] = { 1435
1436 /*
1437 * Regulators with fixed voltage and normal/idle modes
1438 */
1439 [AB9540_LDO_ANA] = {
446 .desc = { 1440 .desc = {
447 .name = "LDO-ANA", 1441 .name = "LDO-ANA",
448 .ops = &ab8500_regulator_fixed_ops, 1442 .ops = &ab8500_regulator_mode_ops,
449 .type = REGULATOR_VOLTAGE, 1443 .type = REGULATOR_VOLTAGE,
450 .id = AB8500_LDO_ANA, 1444 .id = AB9540_LDO_ANA,
451 .owner = THIS_MODULE, 1445 .owner = THIS_MODULE,
452 .n_voltages = 1, 1446 .n_voltages = 1,
453 .min_uV = 1200000, 1447 .volt_table = fixed_1200000_voltage,
454 }, 1448 },
1449 .load_lp_uA = 1000,
455 .update_bank = 0x04, 1450 .update_bank = 0x04,
456 .update_reg = 0x06, 1451 .update_reg = 0x06,
457 .update_mask = 0x0c, 1452 .update_mask = 0x0c,
458 .update_val_enable = 0x04, 1453 .update_val = 0x08,
1454 .update_val_idle = 0x0c,
1455 .update_val_normal = 0x08,
459 }, 1456 },
1457};
460 1458
1459/* AB8540 regulator information */
1460static struct ab8500_regulator_info
1461 ab8540_regulator_info[AB8540_NUM_REGULATORS] = {
1462 /*
1463 * Variable Voltage Regulators
1464 * name, min mV, max mV,
1465 * update bank, reg, mask, enable val
1466 * volt bank, reg, mask
1467 */
1468 [AB8540_LDO_AUX1] = {
1469 .desc = {
1470 .name = "LDO-AUX1",
1471 .ops = &ab8500_regulator_volt_mode_ops,
1472 .type = REGULATOR_VOLTAGE,
1473 .id = AB8540_LDO_AUX1,
1474 .owner = THIS_MODULE,
1475 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
1476 .volt_table = ldo_vauxn_voltages,
1477 },
1478 .load_lp_uA = 5000,
1479 .update_bank = 0x04,
1480 .update_reg = 0x09,
1481 .update_mask = 0x03,
1482 .update_val = 0x01,
1483 .update_val_idle = 0x03,
1484 .update_val_normal = 0x01,
1485 .voltage_bank = 0x04,
1486 .voltage_reg = 0x1f,
1487 .voltage_mask = 0x0f,
1488 },
1489 [AB8540_LDO_AUX2] = {
1490 .desc = {
1491 .name = "LDO-AUX2",
1492 .ops = &ab8500_regulator_volt_mode_ops,
1493 .type = REGULATOR_VOLTAGE,
1494 .id = AB8540_LDO_AUX2,
1495 .owner = THIS_MODULE,
1496 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
1497 .volt_table = ldo_vauxn_voltages,
1498 },
1499 .load_lp_uA = 5000,
1500 .update_bank = 0x04,
1501 .update_reg = 0x09,
1502 .update_mask = 0x0c,
1503 .update_val = 0x04,
1504 .update_val_idle = 0x0c,
1505 .update_val_normal = 0x04,
1506 .voltage_bank = 0x04,
1507 .voltage_reg = 0x20,
1508 .voltage_mask = 0x0f,
1509 },
1510 [AB8540_LDO_AUX3] = {
1511 .desc = {
1512 .name = "LDO-AUX3",
1513 .ops = &ab8540_aux3_regulator_volt_mode_ops,
1514 .type = REGULATOR_VOLTAGE,
1515 .id = AB8540_LDO_AUX3,
1516 .owner = THIS_MODULE,
1517 .n_voltages = ARRAY_SIZE(ldo_vaux3_ab8540_voltages),
1518 .volt_table = ldo_vaux3_ab8540_voltages,
1519 },
1520 .load_lp_uA = 5000,
1521 .update_bank = 0x04,
1522 .update_reg = 0x0a,
1523 .update_mask = 0x03,
1524 .update_val = 0x01,
1525 .update_val_idle = 0x03,
1526 .update_val_normal = 0x01,
1527 .voltage_bank = 0x04,
1528 .voltage_reg = 0x21,
1529 .voltage_mask = 0x07,
1530 .expand_register = {
1531 .voltage_limit = 8,
1532 .voltage_bank = 0x04,
1533 .voltage_reg = 0x01,
1534 .voltage_mask = 0x10,
1535 }
1536 },
1537 [AB8540_LDO_AUX4] = {
1538 .desc = {
1539 .name = "LDO-AUX4",
1540 .ops = &ab8500_regulator_volt_mode_ops,
1541 .type = REGULATOR_VOLTAGE,
1542 .id = AB8540_LDO_AUX4,
1543 .owner = THIS_MODULE,
1544 .n_voltages = ARRAY_SIZE(ldo_vauxn_voltages),
1545 .volt_table = ldo_vauxn_voltages,
1546 },
1547 .load_lp_uA = 5000,
1548 /* values for Vaux4Regu register */
1549 .update_bank = 0x04,
1550 .update_reg = 0x2e,
1551 .update_mask = 0x03,
1552 .update_val = 0x01,
1553 .update_val_idle = 0x03,
1554 .update_val_normal = 0x01,
1555 /* values for Vaux4SEL register */
1556 .voltage_bank = 0x04,
1557 .voltage_reg = 0x2f,
1558 .voltage_mask = 0x0f,
1559 },
1560 [AB8540_LDO_AUX5] = {
1561 .desc = {
1562 .name = "LDO-AUX5",
1563 .ops = &ab8500_regulator_volt_mode_ops,
1564 .type = REGULATOR_VOLTAGE,
1565 .id = AB8540_LDO_AUX5,
1566 .owner = THIS_MODULE,
1567 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
1568 .volt_table = ldo_vaux56_ab8540_voltages,
1569 },
1570 .load_lp_uA = 20000,
1571 /* values for Vaux5Regu register */
1572 .update_bank = 0x04,
1573 .update_reg = 0x32,
1574 .update_mask = 0x03,
1575 .update_val = 0x01,
1576 .update_val_idle = 0x03,
1577 .update_val_normal = 0x01,
1578 /* values for Vaux5SEL register */
1579 .voltage_bank = 0x04,
1580 .voltage_reg = 0x33,
1581 .voltage_mask = 0x3f,
1582 },
1583 [AB8540_LDO_AUX6] = {
1584 .desc = {
1585 .name = "LDO-AUX6",
1586 .ops = &ab8500_regulator_volt_mode_ops,
1587 .type = REGULATOR_VOLTAGE,
1588 .id = AB8540_LDO_AUX6,
1589 .owner = THIS_MODULE,
1590 .n_voltages = ARRAY_SIZE(ldo_vaux56_ab8540_voltages),
1591 .volt_table = ldo_vaux56_ab8540_voltages,
1592 },
1593 .load_lp_uA = 20000,
1594 /* values for Vaux6Regu register */
1595 .update_bank = 0x04,
1596 .update_reg = 0x35,
1597 .update_mask = 0x03,
1598 .update_val = 0x01,
1599 .update_val_idle = 0x03,
1600 .update_val_normal = 0x01,
1601 /* values for Vaux6SEL register */
1602 .voltage_bank = 0x04,
1603 .voltage_reg = 0x36,
1604 .voltage_mask = 0x3f,
1605 },
1606 [AB8540_LDO_INTCORE] = {
1607 .desc = {
1608 .name = "LDO-INTCORE",
1609 .ops = &ab8500_regulator_volt_mode_ops,
1610 .type = REGULATOR_VOLTAGE,
1611 .id = AB8540_LDO_INTCORE,
1612 .owner = THIS_MODULE,
1613 .n_voltages = ARRAY_SIZE(ldo_vintcore_voltages),
1614 .volt_table = ldo_vintcore_voltages,
1615 },
1616 .load_lp_uA = 5000,
1617 .update_bank = 0x03,
1618 .update_reg = 0x80,
1619 .update_mask = 0x44,
1620 .update_val = 0x44,
1621 .update_val_idle = 0x44,
1622 .update_val_normal = 0x04,
1623 .voltage_bank = 0x03,
1624 .voltage_reg = 0x80,
1625 .voltage_mask = 0x38,
1626 },
461 1627
1628 /*
1629 * Fixed Voltage Regulators
1630 * name, fixed mV,
1631 * update bank, reg, mask, enable val
1632 */
1633 [AB8540_LDO_TVOUT] = {
1634 .desc = {
1635 .name = "LDO-TVOUT",
1636 .ops = &ab8500_regulator_mode_ops,
1637 .type = REGULATOR_VOLTAGE,
1638 .id = AB8540_LDO_TVOUT,
1639 .owner = THIS_MODULE,
1640 .n_voltages = 1,
1641 .volt_table = fixed_2000000_voltage,
1642 .enable_time = 10000,
1643 },
1644 .load_lp_uA = 1000,
1645 .update_bank = 0x03,
1646 .update_reg = 0x80,
1647 .update_mask = 0x82,
1648 .update_val = 0x02,
1649 .update_val_idle = 0x82,
1650 .update_val_normal = 0x02,
1651 },
1652 [AB8540_LDO_AUDIO] = {
1653 .desc = {
1654 .name = "LDO-AUDIO",
1655 .ops = &ab8500_regulator_ops,
1656 .type = REGULATOR_VOLTAGE,
1657 .id = AB8540_LDO_AUDIO,
1658 .owner = THIS_MODULE,
1659 .n_voltages = 1,
1660 .volt_table = fixed_2000000_voltage,
1661 },
1662 .update_bank = 0x03,
1663 .update_reg = 0x83,
1664 .update_mask = 0x02,
1665 .update_val = 0x02,
1666 },
1667 [AB8540_LDO_ANAMIC1] = {
1668 .desc = {
1669 .name = "LDO-ANAMIC1",
1670 .ops = &ab8500_regulator_anamic_mode_ops,
1671 .type = REGULATOR_VOLTAGE,
1672 .id = AB8540_LDO_ANAMIC1,
1673 .owner = THIS_MODULE,
1674 .n_voltages = 1,
1675 .volt_table = fixed_2050000_voltage,
1676 },
1677 .shared_mode = &ab8540_ldo_anamic1_shared,
1678 .update_bank = 0x03,
1679 .update_reg = 0x83,
1680 .update_mask = 0x08,
1681 .update_val = 0x08,
1682 .mode_bank = 0x03,
1683 .mode_reg = 0x83,
1684 .mode_mask = 0x20,
1685 .mode_val_idle = 0x20,
1686 .mode_val_normal = 0x00,
1687 },
1688 [AB8540_LDO_ANAMIC2] = {
1689 .desc = {
1690 .name = "LDO-ANAMIC2",
1691 .ops = &ab8500_regulator_anamic_mode_ops,
1692 .type = REGULATOR_VOLTAGE,
1693 .id = AB8540_LDO_ANAMIC2,
1694 .owner = THIS_MODULE,
1695 .n_voltages = 1,
1696 .volt_table = fixed_2050000_voltage,
1697 },
1698 .shared_mode = &ab8540_ldo_anamic2_shared,
1699 .update_bank = 0x03,
1700 .update_reg = 0x83,
1701 .update_mask = 0x10,
1702 .update_val = 0x10,
1703 .mode_bank = 0x03,
1704 .mode_reg = 0x83,
1705 .mode_mask = 0x20,
1706 .mode_val_idle = 0x20,
1707 .mode_val_normal = 0x00,
1708 },
1709 [AB8540_LDO_DMIC] = {
1710 .desc = {
1711 .name = "LDO-DMIC",
1712 .ops = &ab8500_regulator_volt_mode_ops,
1713 .type = REGULATOR_VOLTAGE,
1714 .id = AB8540_LDO_DMIC,
1715 .owner = THIS_MODULE,
1716 .n_voltages = ARRAY_SIZE(ldo_vdmic_voltages),
1717 .volt_table = ldo_vdmic_voltages,
1718 },
1719 .load_lp_uA = 1000,
1720 .update_bank = 0x03,
1721 .update_reg = 0x83,
1722 .update_mask = 0x04,
1723 .update_val = 0x04,
1724 .voltage_bank = 0x03,
1725 .voltage_reg = 0x83,
1726 .voltage_mask = 0xc0,
1727 },
1728
1729 /*
1730 * Regulators with fixed voltage and normal/idle modes
1731 */
1732 [AB8540_LDO_ANA] = {
1733 .desc = {
1734 .name = "LDO-ANA",
1735 .ops = &ab8500_regulator_mode_ops,
1736 .type = REGULATOR_VOLTAGE,
1737 .id = AB8540_LDO_ANA,
1738 .owner = THIS_MODULE,
1739 .n_voltages = 1,
1740 .volt_table = fixed_1200000_voltage,
1741 },
1742 .load_lp_uA = 1000,
1743 .update_bank = 0x04,
1744 .update_reg = 0x06,
1745 .update_mask = 0x0c,
1746 .update_val = 0x04,
1747 .update_val_idle = 0x0c,
1748 .update_val_normal = 0x04,
1749 },
1750 [AB8540_LDO_SDIO] = {
1751 .desc = {
1752 .name = "LDO-SDIO",
1753 .ops = &ab8500_regulator_volt_mode_ops,
1754 .type = REGULATOR_VOLTAGE,
1755 .id = AB8540_LDO_SDIO,
1756 .owner = THIS_MODULE,
1757 .n_voltages = ARRAY_SIZE(ldo_sdio_voltages),
1758 .volt_table = ldo_sdio_voltages,
1759 },
1760 .load_lp_uA = 5000,
1761 .update_bank = 0x03,
1762 .update_reg = 0x88,
1763 .update_mask = 0x30,
1764 .update_val = 0x10,
1765 .update_val_idle = 0x30,
1766 .update_val_normal = 0x10,
1767 .voltage_bank = 0x03,
1768 .voltage_reg = 0x88,
1769 .voltage_mask = 0x07,
1770 },
1771};
1772
1773static struct ab8500_shared_mode ldo_anamic1_shared = {
1774 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC2],
1775};
1776
1777static struct ab8500_shared_mode ldo_anamic2_shared = {
1778 .shared_regulator = &ab8505_regulator_info[AB8505_LDO_ANAMIC1],
1779};
1780
1781static struct ab8500_shared_mode ab8540_ldo_anamic1_shared = {
1782 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC2],
1783};
1784
1785static struct ab8500_shared_mode ab8540_ldo_anamic2_shared = {
1786 .shared_regulator = &ab8540_regulator_info[AB8540_LDO_ANAMIC1],
462}; 1787};
463 1788
464struct ab8500_reg_init { 1789struct ab8500_reg_init {
@@ -474,13 +1799,13 @@ struct ab8500_reg_init {
474 .mask = _mask, \ 1799 .mask = _mask, \
475 } 1800 }
476 1801
1802/* AB8500 register init */
477static struct ab8500_reg_init ab8500_reg_init[] = { 1803static struct ab8500_reg_init ab8500_reg_init[] = {
478 /* 1804 /*
479 * 0x30, VanaRequestCtrl 1805 * 0x30, VanaRequestCtrl
480 * 0x0C, VpllRequestCtrl
481 * 0xc0, VextSupply1RequestCtrl 1806 * 0xc0, VextSupply1RequestCtrl
482 */ 1807 */
483 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xfc), 1808 REG_INIT(AB8500_REGUREQUESTCTRL2, 0x03, 0x04, 0xf0),
484 /* 1809 /*
485 * 0x03, VextSupply2RequestCtrl 1810 * 0x03, VextSupply2RequestCtrl
486 * 0x0c, VextSupply3RequestCtrl 1811 * 0x0c, VextSupply3RequestCtrl
@@ -547,13 +1872,21 @@ static struct ab8500_reg_init ab8500_reg_init[] = {
547 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f), 1872 REG_INIT(AB8500_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
548 /* 1873 /*
549 * 0x02, SysClkReq2Valid1 1874 * 0x02, SysClkReq2Valid1
550 * ... 1875 * 0x04, SysClkReq3Valid1
1876 * 0x08, SysClkReq4Valid1
1877 * 0x10, SysClkReq5Valid1
1878 * 0x20, SysClkReq6Valid1
1879 * 0x40, SysClkReq7Valid1
551 * 0x80, SysClkReq8Valid1 1880 * 0x80, SysClkReq8Valid1
552 */ 1881 */
553 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe), 1882 REG_INIT(AB8500_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
554 /* 1883 /*
555 * 0x02, SysClkReq2Valid2 1884 * 0x02, SysClkReq2Valid2
556 * ... 1885 * 0x04, SysClkReq3Valid2
1886 * 0x08, SysClkReq4Valid2
1887 * 0x10, SysClkReq5Valid2
1888 * 0x20, SysClkReq6Valid2
1889 * 0x40, SysClkReq7Valid2
557 * 0x80, SysClkReq8Valid2 1890 * 0x80, SysClkReq8Valid2
558 */ 1891 */
559 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe), 1892 REG_INIT(AB8500_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
@@ -578,8 +1911,8 @@ static struct ab8500_reg_init ab8500_reg_init[] = {
578 */ 1911 */
579 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03), 1912 REG_INIT(AB8500_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
580 /* 1913 /*
1914 * 0x03, VpllRegu (NOTE! PRCMU register bits)
581 * 0x0c, VanaRegu 1915 * 0x0c, VanaRegu
582 * 0x03, VpllRegu
583 */ 1916 */
584 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f), 1917 REG_INIT(AB8500_VPLLVANAREGU, 0x04, 0x06, 0x0f),
585 /* 1918 /*
@@ -605,10 +1938,6 @@ static struct ab8500_reg_init ab8500_reg_init[] = {
605 */ 1938 */
606 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03), 1939 REG_INIT(AB8500_VRF1VAUX3REGU, 0x04, 0x0a, 0x03),
607 /* 1940 /*
608 * 0x3f, Vsmps1Sel1
609 */
610 REG_INIT(AB8500_VSMPS1SEL1, 0x04, 0x13, 0x3f),
611 /*
612 * 0x0f, Vaux1Sel 1941 * 0x0f, Vaux1Sel
613 */ 1942 */
614 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f), 1943 REG_INIT(AB8500_VAUX1SEL, 0x04, 0x1f, 0x0f),
@@ -641,52 +1970,1073 @@ static struct ab8500_reg_init ab8500_reg_init[] = {
641 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16), 1970 REG_INIT(AB8500_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
642}; 1971};
643 1972
644static int 1973/* AB8505 register init */
645ab8500_regulator_init_registers(struct platform_device *pdev, int id, int value) 1974static struct ab8500_reg_init ab8505_reg_init[] = {
1975 /*
1976 * 0x03, VarmRequestCtrl
1977 * 0x0c, VsmpsCRequestCtrl
1978 * 0x30, VsmpsARequestCtrl
1979 * 0xc0, VsmpsBRequestCtrl
1980 */
1981 REG_INIT(AB8505_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
1982 /*
1983 * 0x03, VsafeRequestCtrl
1984 * 0x0c, VpllRequestCtrl
1985 * 0x30, VanaRequestCtrl
1986 */
1987 REG_INIT(AB8505_REGUREQUESTCTRL2, 0x03, 0x04, 0x3f),
1988 /*
1989 * 0x30, Vaux1RequestCtrl
1990 * 0xc0, Vaux2RequestCtrl
1991 */
1992 REG_INIT(AB8505_REGUREQUESTCTRL3, 0x03, 0x05, 0xf0),
1993 /*
1994 * 0x03, Vaux3RequestCtrl
1995 * 0x04, SwHPReq
1996 */
1997 REG_INIT(AB8505_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
1998 /*
1999 * 0x01, VsmpsASysClkReq1HPValid
2000 * 0x02, VsmpsBSysClkReq1HPValid
2001 * 0x04, VsafeSysClkReq1HPValid
2002 * 0x08, VanaSysClkReq1HPValid
2003 * 0x10, VpllSysClkReq1HPValid
2004 * 0x20, Vaux1SysClkReq1HPValid
2005 * 0x40, Vaux2SysClkReq1HPValid
2006 * 0x80, Vaux3SysClkReq1HPValid
2007 */
2008 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2009 /*
2010 * 0x01, VsmpsCSysClkReq1HPValid
2011 * 0x02, VarmSysClkReq1HPValid
2012 * 0x04, VbbSysClkReq1HPValid
2013 * 0x08, VsmpsMSysClkReq1HPValid
2014 */
2015 REG_INIT(AB8505_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x0f),
2016 /*
2017 * 0x01, VsmpsAHwHPReq1Valid
2018 * 0x02, VsmpsBHwHPReq1Valid
2019 * 0x04, VsafeHwHPReq1Valid
2020 * 0x08, VanaHwHPReq1Valid
2021 * 0x10, VpllHwHPReq1Valid
2022 * 0x20, Vaux1HwHPReq1Valid
2023 * 0x40, Vaux2HwHPReq1Valid
2024 * 0x80, Vaux3HwHPReq1Valid
2025 */
2026 REG_INIT(AB8505_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2027 /*
2028 * 0x08, VsmpsMHwHPReq1Valid
2029 */
2030 REG_INIT(AB8505_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x08),
2031 /*
2032 * 0x01, VsmpsAHwHPReq2Valid
2033 * 0x02, VsmpsBHwHPReq2Valid
2034 * 0x04, VsafeHwHPReq2Valid
2035 * 0x08, VanaHwHPReq2Valid
2036 * 0x10, VpllHwHPReq2Valid
2037 * 0x20, Vaux1HwHPReq2Valid
2038 * 0x40, Vaux2HwHPReq2Valid
2039 * 0x80, Vaux3HwHPReq2Valid
2040 */
2041 REG_INIT(AB8505_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2042 /*
2043 * 0x08, VsmpsMHwHPReq2Valid
2044 */
2045 REG_INIT(AB8505_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x08),
2046 /*
2047 * 0x01, VsmpsCSwHPReqValid
2048 * 0x02, VarmSwHPReqValid
2049 * 0x04, VsmpsASwHPReqValid
2050 * 0x08, VsmpsBSwHPReqValid
2051 * 0x10, VsafeSwHPReqValid
2052 * 0x20, VanaSwHPReqValid
2053 * 0x40, VpllSwHPReqValid
2054 * 0x80, Vaux1SwHPReqValid
2055 */
2056 REG_INIT(AB8505_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2057 /*
2058 * 0x01, Vaux2SwHPReqValid
2059 * 0x02, Vaux3SwHPReqValid
2060 * 0x20, VsmpsMSwHPReqValid
2061 */
2062 REG_INIT(AB8505_REGUSWHPREQVALID2, 0x03, 0x0e, 0x23),
2063 /*
2064 * 0x02, SysClkReq2Valid1
2065 * 0x04, SysClkReq3Valid1
2066 * 0x08, SysClkReq4Valid1
2067 */
2068 REG_INIT(AB8505_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0x0e),
2069 /*
2070 * 0x02, SysClkReq2Valid2
2071 * 0x04, SysClkReq3Valid2
2072 * 0x08, SysClkReq4Valid2
2073 */
2074 REG_INIT(AB8505_REGUSYSCLKREQVALID2, 0x03, 0x10, 0x0e),
2075 /*
2076 * 0x01, Vaux4SwHPReqValid
2077 * 0x02, Vaux4HwHPReq2Valid
2078 * 0x04, Vaux4HwHPReq1Valid
2079 * 0x08, Vaux4SysClkReq1HPValid
2080 */
2081 REG_INIT(AB8505_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2082 /*
2083 * 0x02, VadcEna
2084 * 0x04, VintCore12Ena
2085 * 0x38, VintCore12Sel
2086 * 0x40, VintCore12LP
2087 * 0x80, VadcLP
2088 */
2089 REG_INIT(AB8505_REGUMISC1, 0x03, 0x80, 0xfe),
2090 /*
2091 * 0x02, VaudioEna
2092 * 0x04, VdmicEna
2093 * 0x08, Vamic1Ena
2094 * 0x10, Vamic2Ena
2095 */
2096 REG_INIT(AB8505_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2097 /*
2098 * 0x01, Vamic1_dzout
2099 * 0x02, Vamic2_dzout
2100 */
2101 REG_INIT(AB8505_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2102 /*
2103 * 0x03, VsmpsARegu
2104 * 0x0c, VsmpsASelCtrl
2105 * 0x10, VsmpsAAutoMode
2106 * 0x20, VsmpsAPWMMode
2107 */
2108 REG_INIT(AB8505_VSMPSAREGU, 0x04, 0x03, 0x3f),
2109 /*
2110 * 0x03, VsmpsBRegu
2111 * 0x0c, VsmpsBSelCtrl
2112 * 0x10, VsmpsBAutoMode
2113 * 0x20, VsmpsBPWMMode
2114 */
2115 REG_INIT(AB8505_VSMPSBREGU, 0x04, 0x04, 0x3f),
2116 /*
2117 * 0x03, VsafeRegu
2118 * 0x0c, VsafeSelCtrl
2119 * 0x10, VsafeAutoMode
2120 * 0x20, VsafePWMMode
2121 */
2122 REG_INIT(AB8505_VSAFEREGU, 0x04, 0x05, 0x3f),
2123 /*
2124 * 0x03, VpllRegu (NOTE! PRCMU register bits)
2125 * 0x0c, VanaRegu
2126 */
2127 REG_INIT(AB8505_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2128 /*
2129 * 0x03, VextSupply1Regu
2130 * 0x0c, VextSupply2Regu
2131 * 0x30, VextSupply3Regu
2132 * 0x40, ExtSupply2Bypass
2133 * 0x80, ExtSupply3Bypass
2134 */
2135 REG_INIT(AB8505_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2136 /*
2137 * 0x03, Vaux1Regu
2138 * 0x0c, Vaux2Regu
2139 */
2140 REG_INIT(AB8505_VAUX12REGU, 0x04, 0x09, 0x0f),
2141 /*
2142 * 0x0f, Vaux3Regu
2143 */
2144 REG_INIT(AB8505_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2145 /*
2146 * 0x3f, VsmpsASel1
2147 */
2148 REG_INIT(AB8505_VSMPSASEL1, 0x04, 0x13, 0x3f),
2149 /*
2150 * 0x3f, VsmpsASel2
2151 */
2152 REG_INIT(AB8505_VSMPSASEL2, 0x04, 0x14, 0x3f),
2153 /*
2154 * 0x3f, VsmpsASel3
2155 */
2156 REG_INIT(AB8505_VSMPSASEL3, 0x04, 0x15, 0x3f),
2157 /*
2158 * 0x3f, VsmpsBSel1
2159 */
2160 REG_INIT(AB8505_VSMPSBSEL1, 0x04, 0x17, 0x3f),
2161 /*
2162 * 0x3f, VsmpsBSel2
2163 */
2164 REG_INIT(AB8505_VSMPSBSEL2, 0x04, 0x18, 0x3f),
2165 /*
2166 * 0x3f, VsmpsBSel3
2167 */
2168 REG_INIT(AB8505_VSMPSBSEL3, 0x04, 0x19, 0x3f),
2169 /*
2170 * 0x7f, VsafeSel1
2171 */
2172 REG_INIT(AB8505_VSAFESEL1, 0x04, 0x1b, 0x7f),
2173 /*
2174 * 0x3f, VsafeSel2
2175 */
2176 REG_INIT(AB8505_VSAFESEL2, 0x04, 0x1c, 0x7f),
2177 /*
2178 * 0x3f, VsafeSel3
2179 */
2180 REG_INIT(AB8505_VSAFESEL3, 0x04, 0x1d, 0x7f),
2181 /*
2182 * 0x0f, Vaux1Sel
2183 */
2184 REG_INIT(AB8505_VAUX1SEL, 0x04, 0x1f, 0x0f),
2185 /*
2186 * 0x0f, Vaux2Sel
2187 */
2188 REG_INIT(AB8505_VAUX2SEL, 0x04, 0x20, 0x0f),
2189 /*
2190 * 0x07, Vaux3Sel
2191 * 0x30, VRF1Sel
2192 */
2193 REG_INIT(AB8505_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2194 /*
2195 * 0x03, Vaux4RequestCtrl
2196 */
2197 REG_INIT(AB8505_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2198 /*
2199 * 0x03, Vaux4Regu
2200 */
2201 REG_INIT(AB8505_VAUX4REGU, 0x04, 0x2e, 0x03),
2202 /*
2203 * 0x0f, Vaux4Sel
2204 */
2205 REG_INIT(AB8505_VAUX4SEL, 0x04, 0x2f, 0x0f),
2206 /*
2207 * 0x04, Vaux1Disch
2208 * 0x08, Vaux2Disch
2209 * 0x10, Vaux3Disch
2210 * 0x20, Vintcore12Disch
2211 * 0x40, VTVoutDisch
2212 * 0x80, VaudioDisch
2213 */
2214 REG_INIT(AB8505_REGUCTRLDISCH, 0x04, 0x43, 0xfc),
2215 /*
2216 * 0x02, VanaDisch
2217 * 0x04, VdmicPullDownEna
2218 * 0x10, VdmicDisch
2219 */
2220 REG_INIT(AB8505_REGUCTRLDISCH2, 0x04, 0x44, 0x16),
2221 /*
2222 * 0x01, Vaux4Disch
2223 */
2224 REG_INIT(AB8505_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2225 /*
2226 * 0x07, Vaux5Sel
2227 * 0x08, Vaux5LP
2228 * 0x10, Vaux5Ena
2229 * 0x20, Vaux5Disch
2230 * 0x40, Vaux5DisSfst
2231 * 0x80, Vaux5DisPulld
2232 */
2233 REG_INIT(AB8505_CTRLVAUX5, 0x01, 0x55, 0xff),
2234 /*
2235 * 0x07, Vaux6Sel
2236 * 0x08, Vaux6LP
2237 * 0x10, Vaux6Ena
2238 * 0x80, Vaux6DisPulld
2239 */
2240 REG_INIT(AB8505_CTRLVAUX6, 0x01, 0x56, 0x9f),
2241};
2242
2243/* AB9540 register init */
2244static struct ab8500_reg_init ab9540_reg_init[] = {
2245 /*
2246 * 0x03, VarmRequestCtrl
2247 * 0x0c, VapeRequestCtrl
2248 * 0x30, Vsmps1RequestCtrl
2249 * 0xc0, Vsmps2RequestCtrl
2250 */
2251 REG_INIT(AB9540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2252 /*
2253 * 0x03, Vsmps3RequestCtrl
2254 * 0x0c, VpllRequestCtrl
2255 * 0x30, VanaRequestCtrl
2256 * 0xc0, VextSupply1RequestCtrl
2257 */
2258 REG_INIT(AB9540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2259 /*
2260 * 0x03, VextSupply2RequestCtrl
2261 * 0x0c, VextSupply3RequestCtrl
2262 * 0x30, Vaux1RequestCtrl
2263 * 0xc0, Vaux2RequestCtrl
2264 */
2265 REG_INIT(AB9540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2266 /*
2267 * 0x03, Vaux3RequestCtrl
2268 * 0x04, SwHPReq
2269 */
2270 REG_INIT(AB9540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2271 /*
2272 * 0x01, Vsmps1SysClkReq1HPValid
2273 * 0x02, Vsmps2SysClkReq1HPValid
2274 * 0x04, Vsmps3SysClkReq1HPValid
2275 * 0x08, VanaSysClkReq1HPValid
2276 * 0x10, VpllSysClkReq1HPValid
2277 * 0x20, Vaux1SysClkReq1HPValid
2278 * 0x40, Vaux2SysClkReq1HPValid
2279 * 0x80, Vaux3SysClkReq1HPValid
2280 */
2281 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2282 /*
2283 * 0x01, VapeSysClkReq1HPValid
2284 * 0x02, VarmSysClkReq1HPValid
2285 * 0x04, VbbSysClkReq1HPValid
2286 * 0x08, VmodSysClkReq1HPValid
2287 * 0x10, VextSupply1SysClkReq1HPValid
2288 * 0x20, VextSupply2SysClkReq1HPValid
2289 * 0x40, VextSupply3SysClkReq1HPValid
2290 */
2291 REG_INIT(AB9540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x7f),
2292 /*
2293 * 0x01, Vsmps1HwHPReq1Valid
2294 * 0x02, Vsmps2HwHPReq1Valid
2295 * 0x04, Vsmps3HwHPReq1Valid
2296 * 0x08, VanaHwHPReq1Valid
2297 * 0x10, VpllHwHPReq1Valid
2298 * 0x20, Vaux1HwHPReq1Valid
2299 * 0x40, Vaux2HwHPReq1Valid
2300 * 0x80, Vaux3HwHPReq1Valid
2301 */
2302 REG_INIT(AB9540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2303 /*
2304 * 0x01, VextSupply1HwHPReq1Valid
2305 * 0x02, VextSupply2HwHPReq1Valid
2306 * 0x04, VextSupply3HwHPReq1Valid
2307 * 0x08, VmodHwHPReq1Valid
2308 */
2309 REG_INIT(AB9540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x0f),
2310 /*
2311 * 0x01, Vsmps1HwHPReq2Valid
2312 * 0x02, Vsmps2HwHPReq2Valid
2313 * 0x03, Vsmps3HwHPReq2Valid
2314 * 0x08, VanaHwHPReq2Valid
2315 * 0x10, VpllHwHPReq2Valid
2316 * 0x20, Vaux1HwHPReq2Valid
2317 * 0x40, Vaux2HwHPReq2Valid
2318 * 0x80, Vaux3HwHPReq2Valid
2319 */
2320 REG_INIT(AB9540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2321 /*
2322 * 0x01, VextSupply1HwHPReq2Valid
2323 * 0x02, VextSupply2HwHPReq2Valid
2324 * 0x04, VextSupply3HwHPReq2Valid
2325 * 0x08, VmodHwHPReq2Valid
2326 */
2327 REG_INIT(AB9540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x0f),
2328 /*
2329 * 0x01, VapeSwHPReqValid
2330 * 0x02, VarmSwHPReqValid
2331 * 0x04, Vsmps1SwHPReqValid
2332 * 0x08, Vsmps2SwHPReqValid
2333 * 0x10, Vsmps3SwHPReqValid
2334 * 0x20, VanaSwHPReqValid
2335 * 0x40, VpllSwHPReqValid
2336 * 0x80, Vaux1SwHPReqValid
2337 */
2338 REG_INIT(AB9540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2339 /*
2340 * 0x01, Vaux2SwHPReqValid
2341 * 0x02, Vaux3SwHPReqValid
2342 * 0x04, VextSupply1SwHPReqValid
2343 * 0x08, VextSupply2SwHPReqValid
2344 * 0x10, VextSupply3SwHPReqValid
2345 * 0x20, VmodSwHPReqValid
2346 */
2347 REG_INIT(AB9540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x3f),
2348 /*
2349 * 0x02, SysClkReq2Valid1
2350 * ...
2351 * 0x80, SysClkReq8Valid1
2352 */
2353 REG_INIT(AB9540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xfe),
2354 /*
2355 * 0x02, SysClkReq2Valid2
2356 * ...
2357 * 0x80, SysClkReq8Valid2
2358 */
2359 REG_INIT(AB9540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xfe),
2360 /*
2361 * 0x01, Vaux4SwHPReqValid
2362 * 0x02, Vaux4HwHPReq2Valid
2363 * 0x04, Vaux4HwHPReq1Valid
2364 * 0x08, Vaux4SysClkReq1HPValid
2365 */
2366 REG_INIT(AB9540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2367 /*
2368 * 0x02, VTVoutEna
2369 * 0x04, Vintcore12Ena
2370 * 0x38, Vintcore12Sel
2371 * 0x40, Vintcore12LP
2372 * 0x80, VTVoutLP
2373 */
2374 REG_INIT(AB9540_REGUMISC1, 0x03, 0x80, 0xfe),
2375 /*
2376 * 0x02, VaudioEna
2377 * 0x04, VdmicEna
2378 * 0x08, Vamic1Ena
2379 * 0x10, Vamic2Ena
2380 */
2381 REG_INIT(AB9540_VAUDIOSUPPLY, 0x03, 0x83, 0x1e),
2382 /*
2383 * 0x01, Vamic1_dzout
2384 * 0x02, Vamic2_dzout
2385 */
2386 REG_INIT(AB9540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2387 /*
2388 * 0x03, Vsmps1Regu
2389 * 0x0c, Vsmps1SelCtrl
2390 * 0x10, Vsmps1AutoMode
2391 * 0x20, Vsmps1PWMMode
2392 */
2393 REG_INIT(AB9540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2394 /*
2395 * 0x03, Vsmps2Regu
2396 * 0x0c, Vsmps2SelCtrl
2397 * 0x10, Vsmps2AutoMode
2398 * 0x20, Vsmps2PWMMode
2399 */
2400 REG_INIT(AB9540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2401 /*
2402 * 0x03, Vsmps3Regu
2403 * 0x0c, Vsmps3SelCtrl
2404 * NOTE! PRCMU register
2405 */
2406 REG_INIT(AB9540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2407 /*
2408 * 0x03, VpllRegu
2409 * 0x0c, VanaRegu
2410 */
2411 REG_INIT(AB9540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2412 /*
2413 * 0x03, VextSupply1Regu
2414 * 0x0c, VextSupply2Regu
2415 * 0x30, VextSupply3Regu
2416 * 0x40, ExtSupply2Bypass
2417 * 0x80, ExtSupply3Bypass
2418 */
2419 REG_INIT(AB9540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2420 /*
2421 * 0x03, Vaux1Regu
2422 * 0x0c, Vaux2Regu
2423 */
2424 REG_INIT(AB9540_VAUX12REGU, 0x04, 0x09, 0x0f),
2425 /*
2426 * 0x0c, Vrf1Regu
2427 * 0x03, Vaux3Regu
2428 */
2429 REG_INIT(AB9540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2430 /*
2431 * 0x3f, Vsmps1Sel1
2432 */
2433 REG_INIT(AB9540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2434 /*
2435 * 0x3f, Vsmps1Sel2
2436 */
2437 REG_INIT(AB9540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2438 /*
2439 * 0x3f, Vsmps1Sel3
2440 */
2441 REG_INIT(AB9540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2442 /*
2443 * 0x3f, Vsmps2Sel1
2444 */
2445 REG_INIT(AB9540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2446 /*
2447 * 0x3f, Vsmps2Sel2
2448 */
2449 REG_INIT(AB9540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2450 /*
2451 * 0x3f, Vsmps2Sel3
2452 */
2453 REG_INIT(AB9540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2454 /*
2455 * 0x7f, Vsmps3Sel1
2456 * NOTE! PRCMU register
2457 */
2458 REG_INIT(AB9540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2459 /*
2460 * 0x7f, Vsmps3Sel2
2461 * NOTE! PRCMU register
2462 */
2463 REG_INIT(AB9540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2464 /*
2465 * 0x0f, Vaux1Sel
2466 */
2467 REG_INIT(AB9540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2468 /*
2469 * 0x0f, Vaux2Sel
2470 */
2471 REG_INIT(AB9540_VAUX2SEL, 0x04, 0x20, 0x0f),
2472 /*
2473 * 0x07, Vaux3Sel
2474 * 0x30, Vrf1Sel
2475 */
2476 REG_INIT(AB9540_VRF1VAUX3SEL, 0x04, 0x21, 0x37),
2477 /*
2478 * 0x01, VextSupply12LP
2479 */
2480 REG_INIT(AB9540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2481 /*
2482 * 0x03, Vaux4RequestCtrl
2483 */
2484 REG_INIT(AB9540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2485 /*
2486 * 0x03, Vaux4Regu
2487 */
2488 REG_INIT(AB9540_VAUX4REGU, 0x04, 0x2e, 0x03),
2489 /*
2490 * 0x08, Vaux4Sel
2491 */
2492 REG_INIT(AB9540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2493 /*
2494 * 0x01, VpllDisch
2495 * 0x02, Vrf1Disch
2496 * 0x04, Vaux1Disch
2497 * 0x08, Vaux2Disch
2498 * 0x10, Vaux3Disch
2499 * 0x20, Vintcore12Disch
2500 * 0x40, VTVoutDisch
2501 * 0x80, VaudioDisch
2502 */
2503 REG_INIT(AB9540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2504 /*
2505 * 0x01, VsimDisch
2506 * 0x02, VanaDisch
2507 * 0x04, VdmicPullDownEna
2508 * 0x08, VpllPullDownEna
2509 * 0x10, VdmicDisch
2510 */
2511 REG_INIT(AB9540_REGUCTRLDISCH2, 0x04, 0x44, 0x1f),
2512 /*
2513 * 0x01, Vaux4Disch
2514 */
2515 REG_INIT(AB9540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2516};
2517
2518/* AB8540 register init */
2519static struct ab8500_reg_init ab8540_reg_init[] = {
2520 /*
2521 * 0x01, VSimSycClkReq1Valid
2522 * 0x02, VSimSycClkReq2Valid
2523 * 0x04, VSimSycClkReq3Valid
2524 * 0x08, VSimSycClkReq4Valid
2525 * 0x10, VSimSycClkReq5Valid
2526 * 0x20, VSimSycClkReq6Valid
2527 * 0x40, VSimSycClkReq7Valid
2528 * 0x80, VSimSycClkReq8Valid
2529 */
2530 REG_INIT(AB8540_VSIMSYSCLKCTRL, 0x02, 0x33, 0xff),
2531 /*
2532 * 0x03, VarmRequestCtrl
2533 * 0x0c, VapeRequestCtrl
2534 * 0x30, Vsmps1RequestCtrl
2535 * 0xc0, Vsmps2RequestCtrl
2536 */
2537 REG_INIT(AB8540_REGUREQUESTCTRL1, 0x03, 0x03, 0xff),
2538 /*
2539 * 0x03, Vsmps3RequestCtrl
2540 * 0x0c, VpllRequestCtrl
2541 * 0x30, VanaRequestCtrl
2542 * 0xc0, VextSupply1RequestCtrl
2543 */
2544 REG_INIT(AB8540_REGUREQUESTCTRL2, 0x03, 0x04, 0xff),
2545 /*
2546 * 0x03, VextSupply2RequestCtrl
2547 * 0x0c, VextSupply3RequestCtrl
2548 * 0x30, Vaux1RequestCtrl
2549 * 0xc0, Vaux2RequestCtrl
2550 */
2551 REG_INIT(AB8540_REGUREQUESTCTRL3, 0x03, 0x05, 0xff),
2552 /*
2553 * 0x03, Vaux3RequestCtrl
2554 * 0x04, SwHPReq
2555 */
2556 REG_INIT(AB8540_REGUREQUESTCTRL4, 0x03, 0x06, 0x07),
2557 /*
2558 * 0x01, Vsmps1SysClkReq1HPValid
2559 * 0x02, Vsmps2SysClkReq1HPValid
2560 * 0x04, Vsmps3SysClkReq1HPValid
2561 * 0x08, VanaSysClkReq1HPValid
2562 * 0x10, VpllSysClkReq1HPValid
2563 * 0x20, Vaux1SysClkReq1HPValid
2564 * 0x40, Vaux2SysClkReq1HPValid
2565 * 0x80, Vaux3SysClkReq1HPValid
2566 */
2567 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID1, 0x03, 0x07, 0xff),
2568 /*
2569 * 0x01, VapeSysClkReq1HPValid
2570 * 0x02, VarmSysClkReq1HPValid
2571 * 0x04, VbbSysClkReq1HPValid
2572 * 0x10, VextSupply1SysClkReq1HPValid
2573 * 0x20, VextSupply2SysClkReq1HPValid
2574 * 0x40, VextSupply3SysClkReq1HPValid
2575 */
2576 REG_INIT(AB8540_REGUSYSCLKREQ1HPVALID2, 0x03, 0x08, 0x77),
2577 /*
2578 * 0x01, Vsmps1HwHPReq1Valid
2579 * 0x02, Vsmps2HwHPReq1Valid
2580 * 0x04, Vsmps3HwHPReq1Valid
2581 * 0x08, VanaHwHPReq1Valid
2582 * 0x10, VpllHwHPReq1Valid
2583 * 0x20, Vaux1HwHPReq1Valid
2584 * 0x40, Vaux2HwHPReq1Valid
2585 * 0x80, Vaux3HwHPReq1Valid
2586 */
2587 REG_INIT(AB8540_REGUHWHPREQ1VALID1, 0x03, 0x09, 0xff),
2588 /*
2589 * 0x01, VextSupply1HwHPReq1Valid
2590 * 0x02, VextSupply2HwHPReq1Valid
2591 * 0x04, VextSupply3HwHPReq1Valid
2592 */
2593 REG_INIT(AB8540_REGUHWHPREQ1VALID2, 0x03, 0x0a, 0x07),
2594 /*
2595 * 0x01, Vsmps1HwHPReq2Valid
2596 * 0x02, Vsmps2HwHPReq2Valid
2597 * 0x03, Vsmps3HwHPReq2Valid
2598 * 0x08, VanaHwHPReq2Valid
2599 * 0x10, VpllHwHPReq2Valid
2600 * 0x20, Vaux1HwHPReq2Valid
2601 * 0x40, Vaux2HwHPReq2Valid
2602 * 0x80, Vaux3HwHPReq2Valid
2603 */
2604 REG_INIT(AB8540_REGUHWHPREQ2VALID1, 0x03, 0x0b, 0xff),
2605 /*
2606 * 0x01, VextSupply1HwHPReq2Valid
2607 * 0x02, VextSupply2HwHPReq2Valid
2608 * 0x04, VextSupply3HwHPReq2Valid
2609 */
2610 REG_INIT(AB8540_REGUHWHPREQ2VALID2, 0x03, 0x0c, 0x07),
2611 /*
2612 * 0x01, VapeSwHPReqValid
2613 * 0x02, VarmSwHPReqValid
2614 * 0x04, Vsmps1SwHPReqValid
2615 * 0x08, Vsmps2SwHPReqValid
2616 * 0x10, Vsmps3SwHPReqValid
2617 * 0x20, VanaSwHPReqValid
2618 * 0x40, VpllSwHPReqValid
2619 * 0x80, Vaux1SwHPReqValid
2620 */
2621 REG_INIT(AB8540_REGUSWHPREQVALID1, 0x03, 0x0d, 0xff),
2622 /*
2623 * 0x01, Vaux2SwHPReqValid
2624 * 0x02, Vaux3SwHPReqValid
2625 * 0x04, VextSupply1SwHPReqValid
2626 * 0x08, VextSupply2SwHPReqValid
2627 * 0x10, VextSupply3SwHPReqValid
2628 */
2629 REG_INIT(AB8540_REGUSWHPREQVALID2, 0x03, 0x0e, 0x1f),
2630 /*
2631 * 0x02, SysClkReq2Valid1
2632 * ...
2633 * 0x80, SysClkReq8Valid1
2634 */
2635 REG_INIT(AB8540_REGUSYSCLKREQVALID1, 0x03, 0x0f, 0xff),
2636 /*
2637 * 0x02, SysClkReq2Valid2
2638 * ...
2639 * 0x80, SysClkReq8Valid2
2640 */
2641 REG_INIT(AB8540_REGUSYSCLKREQVALID2, 0x03, 0x10, 0xff),
2642 /*
2643 * 0x01, Vaux4SwHPReqValid
2644 * 0x02, Vaux4HwHPReq2Valid
2645 * 0x04, Vaux4HwHPReq1Valid
2646 * 0x08, Vaux4SysClkReq1HPValid
2647 */
2648 REG_INIT(AB8540_REGUVAUX4REQVALID, 0x03, 0x11, 0x0f),
2649 /*
2650 * 0x01, Vaux5SwHPReqValid
2651 * 0x02, Vaux5HwHPReq2Valid
2652 * 0x04, Vaux5HwHPReq1Valid
2653 * 0x08, Vaux5SysClkReq1HPValid
2654 */
2655 REG_INIT(AB8540_REGUVAUX5REQVALID, 0x03, 0x12, 0x0f),
2656 /*
2657 * 0x01, Vaux6SwHPReqValid
2658 * 0x02, Vaux6HwHPReq2Valid
2659 * 0x04, Vaux6HwHPReq1Valid
2660 * 0x08, Vaux6SysClkReq1HPValid
2661 */
2662 REG_INIT(AB8540_REGUVAUX6REQVALID, 0x03, 0x13, 0x0f),
2663 /*
2664 * 0x01, VclkbSwHPReqValid
2665 * 0x02, VclkbHwHPReq2Valid
2666 * 0x04, VclkbHwHPReq1Valid
2667 * 0x08, VclkbSysClkReq1HPValid
2668 */
2669 REG_INIT(AB8540_REGUVCLKBREQVALID, 0x03, 0x14, 0x0f),
2670 /*
2671 * 0x01, Vrf1SwHPReqValid
2672 * 0x02, Vrf1HwHPReq2Valid
2673 * 0x04, Vrf1HwHPReq1Valid
2674 * 0x08, Vrf1SysClkReq1HPValid
2675 */
2676 REG_INIT(AB8540_REGUVRF1REQVALID, 0x03, 0x15, 0x0f),
2677 /*
2678 * 0x02, VTVoutEna
2679 * 0x04, Vintcore12Ena
2680 * 0x38, Vintcore12Sel
2681 * 0x40, Vintcore12LP
2682 * 0x80, VTVoutLP
2683 */
2684 REG_INIT(AB8540_REGUMISC1, 0x03, 0x80, 0xfe),
2685 /*
2686 * 0x02, VaudioEna
2687 * 0x04, VdmicEna
2688 * 0x08, Vamic1Ena
2689 * 0x10, Vamic2Ena
2690 * 0x20, Vamic12LP
2691 * 0xC0, VdmicSel
2692 */
2693 REG_INIT(AB8540_VAUDIOSUPPLY, 0x03, 0x83, 0xfe),
2694 /*
2695 * 0x01, Vamic1_dzout
2696 * 0x02, Vamic2_dzout
2697 */
2698 REG_INIT(AB8540_REGUCTRL1VAMIC, 0x03, 0x84, 0x03),
2699 /*
2700 * 0x07, VHSICSel
2701 * 0x08, VHSICOffState
2702 * 0x10, VHSIEna
2703 * 0x20, VHSICLP
2704 */
2705 REG_INIT(AB8540_VHSIC, 0x03, 0x87, 0x3f),
2706 /*
2707 * 0x07, VSDIOSel
2708 * 0x08, VSDIOOffState
2709 * 0x10, VSDIOEna
2710 * 0x20, VSDIOLP
2711 */
2712 REG_INIT(AB8540_VSDIO, 0x03, 0x88, 0x3f),
2713 /*
2714 * 0x03, Vsmps1Regu
2715 * 0x0c, Vsmps1SelCtrl
2716 * 0x10, Vsmps1AutoMode
2717 * 0x20, Vsmps1PWMMode
2718 */
2719 REG_INIT(AB8540_VSMPS1REGU, 0x04, 0x03, 0x3f),
2720 /*
2721 * 0x03, Vsmps2Regu
2722 * 0x0c, Vsmps2SelCtrl
2723 * 0x10, Vsmps2AutoMode
2724 * 0x20, Vsmps2PWMMode
2725 */
2726 REG_INIT(AB8540_VSMPS2REGU, 0x04, 0x04, 0x3f),
2727 /*
2728 * 0x03, Vsmps3Regu
2729 * 0x0c, Vsmps3SelCtrl
2730 * 0x10, Vsmps3AutoMode
2731 * 0x20, Vsmps3PWMMode
2732 * NOTE! PRCMU register
2733 */
2734 REG_INIT(AB8540_VSMPS3REGU, 0x04, 0x05, 0x0f),
2735 /*
2736 * 0x03, VpllRegu
2737 * 0x0c, VanaRegu
2738 */
2739 REG_INIT(AB8540_VPLLVANAREGU, 0x04, 0x06, 0x0f),
2740 /*
2741 * 0x03, VextSupply1Regu
2742 * 0x0c, VextSupply2Regu
2743 * 0x30, VextSupply3Regu
2744 * 0x40, ExtSupply2Bypass
2745 * 0x80, ExtSupply3Bypass
2746 */
2747 REG_INIT(AB8540_EXTSUPPLYREGU, 0x04, 0x08, 0xff),
2748 /*
2749 * 0x03, Vaux1Regu
2750 * 0x0c, Vaux2Regu
2751 */
2752 REG_INIT(AB8540_VAUX12REGU, 0x04, 0x09, 0x0f),
2753 /*
2754 * 0x0c, VRF1Regu
2755 * 0x03, Vaux3Regu
2756 */
2757 REG_INIT(AB8540_VRF1VAUX3REGU, 0x04, 0x0a, 0x0f),
2758 /*
2759 * 0x3f, Vsmps1Sel1
2760 */
2761 REG_INIT(AB8540_VSMPS1SEL1, 0x04, 0x13, 0x3f),
2762 /*
2763 * 0x3f, Vsmps1Sel2
2764 */
2765 REG_INIT(AB8540_VSMPS1SEL2, 0x04, 0x14, 0x3f),
2766 /*
2767 * 0x3f, Vsmps1Sel3
2768 */
2769 REG_INIT(AB8540_VSMPS1SEL3, 0x04, 0x15, 0x3f),
2770 /*
2771 * 0x3f, Vsmps2Sel1
2772 */
2773 REG_INIT(AB8540_VSMPS2SEL1, 0x04, 0x17, 0x3f),
2774 /*
2775 * 0x3f, Vsmps2Sel2
2776 */
2777 REG_INIT(AB8540_VSMPS2SEL2, 0x04, 0x18, 0x3f),
2778 /*
2779 * 0x3f, Vsmps2Sel3
2780 */
2781 REG_INIT(AB8540_VSMPS2SEL3, 0x04, 0x19, 0x3f),
2782 /*
2783 * 0x7f, Vsmps3Sel1
2784 * NOTE! PRCMU register
2785 */
2786 REG_INIT(AB8540_VSMPS3SEL1, 0x04, 0x1b, 0x7f),
2787 /*
2788 * 0x7f, Vsmps3Sel2
2789 * NOTE! PRCMU register
2790 */
2791 REG_INIT(AB8540_VSMPS3SEL2, 0x04, 0x1c, 0x7f),
2792 /*
2793 * 0x0f, Vaux1Sel
2794 */
2795 REG_INIT(AB8540_VAUX1SEL, 0x04, 0x1f, 0x0f),
2796 /*
2797 * 0x0f, Vaux2Sel
2798 */
2799 REG_INIT(AB8540_VAUX2SEL, 0x04, 0x20, 0x0f),
2800 /*
2801 * 0x07, Vaux3Sel
2802 * 0x70, Vrf1Sel
2803 */
2804 REG_INIT(AB8540_VRF1VAUX3SEL, 0x04, 0x21, 0x77),
2805 /*
2806 * 0x01, VextSupply12LP
2807 */
2808 REG_INIT(AB8540_REGUCTRL2SPARE, 0x04, 0x22, 0x01),
2809 /*
2810 * 0x07, Vanasel
2811 * 0x30, Vpllsel
2812 */
2813 REG_INIT(AB8540_VANAVPLLSEL, 0x04, 0x29, 0x37),
2814 /*
2815 * 0x03, Vaux4RequestCtrl
2816 */
2817 REG_INIT(AB8540_VAUX4REQCTRL, 0x04, 0x2d, 0x03),
2818 /*
2819 * 0x03, Vaux4Regu
2820 */
2821 REG_INIT(AB8540_VAUX4REGU, 0x04, 0x2e, 0x03),
2822 /*
2823 * 0x0f, Vaux4Sel
2824 */
2825 REG_INIT(AB8540_VAUX4SEL, 0x04, 0x2f, 0x0f),
2826 /*
2827 * 0x03, Vaux5RequestCtrl
2828 */
2829 REG_INIT(AB8540_VAUX5REQCTRL, 0x04, 0x31, 0x03),
2830 /*
2831 * 0x03, Vaux5Regu
2832 */
2833 REG_INIT(AB8540_VAUX5REGU, 0x04, 0x32, 0x03),
2834 /*
2835 * 0x3f, Vaux5Sel
2836 */
2837 REG_INIT(AB8540_VAUX5SEL, 0x04, 0x33, 0x3f),
2838 /*
2839 * 0x03, Vaux6RequestCtrl
2840 */
2841 REG_INIT(AB8540_VAUX6REQCTRL, 0x04, 0x34, 0x03),
2842 /*
2843 * 0x03, Vaux6Regu
2844 */
2845 REG_INIT(AB8540_VAUX6REGU, 0x04, 0x35, 0x03),
2846 /*
2847 * 0x3f, Vaux6Sel
2848 */
2849 REG_INIT(AB8540_VAUX6SEL, 0x04, 0x36, 0x3f),
2850 /*
2851 * 0x03, VCLKBRequestCtrl
2852 */
2853 REG_INIT(AB8540_VCLKBREQCTRL, 0x04, 0x37, 0x03),
2854 /*
2855 * 0x03, VCLKBRegu
2856 */
2857 REG_INIT(AB8540_VCLKBREGU, 0x04, 0x38, 0x03),
2858 /*
2859 * 0x07, VCLKBSel
2860 */
2861 REG_INIT(AB8540_VCLKBSEL, 0x04, 0x39, 0x07),
2862 /*
2863 * 0x03, Vrf1RequestCtrl
2864 */
2865 REG_INIT(AB8540_VRF1REQCTRL, 0x04, 0x3a, 0x03),
2866 /*
2867 * 0x01, VpllDisch
2868 * 0x02, Vrf1Disch
2869 * 0x04, Vaux1Disch
2870 * 0x08, Vaux2Disch
2871 * 0x10, Vaux3Disch
2872 * 0x20, Vintcore12Disch
2873 * 0x40, VTVoutDisch
2874 * 0x80, VaudioDisch
2875 */
2876 REG_INIT(AB8540_REGUCTRLDISCH, 0x04, 0x43, 0xff),
2877 /*
2878 * 0x02, VanaDisch
2879 * 0x04, VdmicPullDownEna
2880 * 0x08, VpllPullDownEna
2881 * 0x10, VdmicDisch
2882 */
2883 REG_INIT(AB8540_REGUCTRLDISCH2, 0x04, 0x44, 0x1e),
2884 /*
2885 * 0x01, Vaux4Disch
2886 */
2887 REG_INIT(AB8540_REGUCTRLDISCH3, 0x04, 0x48, 0x01),
2888 /*
2889 * 0x01, Vaux5Disch
2890 * 0x02, Vaux6Disch
2891 * 0x04, VCLKBDisch
2892 */
2893 REG_INIT(AB8540_REGUCTRLDISCH4, 0x04, 0x49, 0x07),
2894};
2895
2896static struct of_regulator_match ab8500_regulator_match[] = {
2897 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
2898 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
2899 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
2900 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
2901 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
2902 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
2903 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
2904 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
2905 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
2906 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
2907};
2908
2909static struct of_regulator_match ab8505_regulator_match[] = {
2910 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8505_LDO_AUX1, },
2911 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8505_LDO_AUX2, },
2912 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8505_LDO_AUX3, },
2913 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8505_LDO_AUX4, },
2914 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8505_LDO_AUX5, },
2915 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8505_LDO_AUX6, },
2916 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8505_LDO_INTCORE, },
2917 { .name = "ab8500_ldo_adc", .driver_data = (void *) AB8505_LDO_ADC, },
2918 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8505_LDO_AUDIO, },
2919 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8505_LDO_ANAMIC1, },
2920 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8505_LDO_ANAMIC2, },
2921 { .name = "ab8500_ldo_aux8", .driver_data = (void *) AB8505_LDO_AUX8, },
2922 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8505_LDO_ANA, },
2923};
2924
2925static struct of_regulator_match ab8540_regulator_match[] = {
2926 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8540_LDO_AUX1, },
2927 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8540_LDO_AUX2, },
2928 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8540_LDO_AUX3, },
2929 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB8540_LDO_AUX4, },
2930 { .name = "ab8500_ldo_aux5", .driver_data = (void *) AB8540_LDO_AUX5, },
2931 { .name = "ab8500_ldo_aux6", .driver_data = (void *) AB8540_LDO_AUX6, },
2932 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8540_LDO_INTCORE, },
2933 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8540_LDO_TVOUT, },
2934 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8540_LDO_AUDIO, },
2935 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8540_LDO_ANAMIC1, },
2936 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8540_LDO_ANAMIC2, },
2937 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8540_LDO_DMIC, },
2938 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8540_LDO_ANA, },
2939 { .name = "ab8500_ldo_sdio", .driver_data = (void *) AB8540_LDO_SDIO, },
2940};
2941
2942static struct of_regulator_match ab9540_regulator_match[] = {
2943 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB9540_LDO_AUX1, },
2944 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB9540_LDO_AUX2, },
2945 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB9540_LDO_AUX3, },
2946 { .name = "ab8500_ldo_aux4", .driver_data = (void *) AB9540_LDO_AUX4, },
2947 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB9540_LDO_INTCORE, },
2948 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB9540_LDO_TVOUT, },
2949 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB9540_LDO_AUDIO, },
2950 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB9540_LDO_ANAMIC1, },
2951 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB9540_LDO_ANAMIC2, },
2952 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB9540_LDO_DMIC, },
2953 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB9540_LDO_ANA, },
2954};
2955
2956static struct {
2957 struct ab8500_regulator_info *info;
2958 int info_size;
2959 struct ab8500_reg_init *init;
2960 int init_size;
2961 struct of_regulator_match *match;
2962 int match_size;
2963} abx500_regulator;
2964
2965static void abx500_get_regulator_info(struct ab8500 *ab8500)
2966{
2967 if (is_ab9540(ab8500)) {
2968 abx500_regulator.info = ab9540_regulator_info;
2969 abx500_regulator.info_size = ARRAY_SIZE(ab9540_regulator_info);
2970 abx500_regulator.init = ab9540_reg_init;
2971 abx500_regulator.init_size = AB9540_NUM_REGULATOR_REGISTERS;
2972 abx500_regulator.match = ab9540_regulator_match;
2973 abx500_regulator.match_size = ARRAY_SIZE(ab9540_regulator_match);
2974 } else if (is_ab8505(ab8500)) {
2975 abx500_regulator.info = ab8505_regulator_info;
2976 abx500_regulator.info_size = ARRAY_SIZE(ab8505_regulator_info);
2977 abx500_regulator.init = ab8505_reg_init;
2978 abx500_regulator.init_size = AB8505_NUM_REGULATOR_REGISTERS;
2979 abx500_regulator.match = ab8505_regulator_match;
2980 abx500_regulator.match_size = ARRAY_SIZE(ab8505_regulator_match);
2981 } else if (is_ab8540(ab8500)) {
2982 abx500_regulator.info = ab8540_regulator_info;
2983 abx500_regulator.info_size = ARRAY_SIZE(ab8540_regulator_info);
2984 abx500_regulator.init = ab8540_reg_init;
2985 abx500_regulator.init_size = AB8540_NUM_REGULATOR_REGISTERS;
2986 abx500_regulator.match = ab8540_regulator_match;
2987 abx500_regulator.match_size = ARRAY_SIZE(ab8540_regulator_match);
2988 } else {
2989 abx500_regulator.info = ab8500_regulator_info;
2990 abx500_regulator.info_size = ARRAY_SIZE(ab8500_regulator_info);
2991 abx500_regulator.init = ab8500_reg_init;
2992 abx500_regulator.init_size = AB8500_NUM_REGULATOR_REGISTERS;
2993 abx500_regulator.match = ab8500_regulator_match;
2994 abx500_regulator.match_size = ARRAY_SIZE(ab8500_regulator_match);
2995 }
2996}
2997
2998static int ab8500_regulator_init_registers(struct platform_device *pdev,
2999 int id, int mask, int value)
646{ 3000{
3001 struct ab8500_reg_init *reg_init = abx500_regulator.init;
647 int err; 3002 int err;
648 3003
649 if (value & ~ab8500_reg_init[id].mask) { 3004 BUG_ON(value & ~mask);
650 dev_err(&pdev->dev, 3005 BUG_ON(mask & ~reg_init[id].mask);
651 "Configuration error: value outside mask.\n");
652 return -EINVAL;
653 }
654 3006
3007 /* initialize register */
655 err = abx500_mask_and_set_register_interruptible( 3008 err = abx500_mask_and_set_register_interruptible(
656 &pdev->dev, 3009 &pdev->dev,
657 ab8500_reg_init[id].bank, 3010 reg_init[id].bank,
658 ab8500_reg_init[id].addr, 3011 reg_init[id].addr,
659 ab8500_reg_init[id].mask, 3012 mask, value);
660 value);
661 if (err < 0) { 3013 if (err < 0) {
662 dev_err(&pdev->dev, 3014 dev_err(&pdev->dev,
663 "Failed to initialize 0x%02x, 0x%02x.\n", 3015 "Failed to initialize 0x%02x, 0x%02x.\n",
664 ab8500_reg_init[id].bank, 3016 reg_init[id].bank,
665 ab8500_reg_init[id].addr); 3017 reg_init[id].addr);
666 return err; 3018 return err;
667 } 3019 }
668
669 dev_vdbg(&pdev->dev, 3020 dev_vdbg(&pdev->dev,
670 "init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", 3021 " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
671 ab8500_reg_init[id].bank, 3022 reg_init[id].bank,
672 ab8500_reg_init[id].addr, 3023 reg_init[id].addr,
673 ab8500_reg_init[id].mask, 3024 mask, value);
674 value);
675 3025
676 return 0; 3026 return 0;
677} 3027}
678 3028
679static int ab8500_regulator_register(struct platform_device *pdev, 3029static int ab8500_regulator_register(struct platform_device *pdev,
680 struct regulator_init_data *init_data, 3030 struct regulator_init_data *init_data,
681 int id, 3031 int id, struct device_node *np)
682 struct device_node *np)
683{ 3032{
3033 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
684 struct ab8500_regulator_info *info = NULL; 3034 struct ab8500_regulator_info *info = NULL;
685 struct regulator_config config = { }; 3035 struct regulator_config config = { };
686 int err; 3036 int err;
687 3037
688 /* assign per-regulator data */ 3038 /* assign per-regulator data */
689 info = &ab8500_regulator_info[id]; 3039 info = &abx500_regulator.info[id];
690 info->dev = &pdev->dev; 3040 info->dev = &pdev->dev;
691 3041
692 config.dev = &pdev->dev; 3042 config.dev = &pdev->dev;
@@ -695,7 +3045,7 @@ static int ab8500_regulator_register(struct platform_device *pdev,
695 config.of_node = np; 3045 config.of_node = np;
696 3046
697 /* fix for hardware before ab8500v2.0 */ 3047 /* fix for hardware before ab8500v2.0 */
698 if (abx500_get_chip_id(info->dev) < 0x20) { 3048 if (is_ab8500_1p1_or_earlier(ab8500)) {
699 if (info->desc.id == AB8500_LDO_AUX3) { 3049 if (info->desc.id == AB8500_LDO_AUX3) {
700 info->desc.n_voltages = 3050 info->desc.n_voltages =
701 ARRAY_SIZE(ldo_vauxn_voltages); 3051 ARRAY_SIZE(ldo_vauxn_voltages);
@@ -712,7 +3062,7 @@ static int ab8500_regulator_register(struct platform_device *pdev,
712 info->desc.name); 3062 info->desc.name);
713 /* when we fail, un-register all earlier regulators */ 3063 /* when we fail, un-register all earlier regulators */
714 while (--id >= 0) { 3064 while (--id >= 0) {
715 info = &ab8500_regulator_info[id]; 3065 info = &abx500_regulator.info[id];
716 regulator_unregister(info->regulator); 3066 regulator_unregister(info->regulator);
717 } 3067 }
718 return err; 3068 return err;
@@ -721,29 +3071,16 @@ static int ab8500_regulator_register(struct platform_device *pdev,
721 return 0; 3071 return 0;
722} 3072}
723 3073
724static struct of_regulator_match ab8500_regulator_matches[] = {
725 { .name = "ab8500_ldo_aux1", .driver_data = (void *) AB8500_LDO_AUX1, },
726 { .name = "ab8500_ldo_aux2", .driver_data = (void *) AB8500_LDO_AUX2, },
727 { .name = "ab8500_ldo_aux3", .driver_data = (void *) AB8500_LDO_AUX3, },
728 { .name = "ab8500_ldo_intcore", .driver_data = (void *) AB8500_LDO_INTCORE, },
729 { .name = "ab8500_ldo_tvout", .driver_data = (void *) AB8500_LDO_TVOUT, },
730 { .name = "ab8500_ldo_usb", .driver_data = (void *) AB8500_LDO_USB, },
731 { .name = "ab8500_ldo_audio", .driver_data = (void *) AB8500_LDO_AUDIO, },
732 { .name = "ab8500_ldo_anamic1", .driver_data = (void *) AB8500_LDO_ANAMIC1, },
733 { .name = "ab8500_ldo_amamic2", .driver_data = (void *) AB8500_LDO_ANAMIC2, },
734 { .name = "ab8500_ldo_dmic", .driver_data = (void *) AB8500_LDO_DMIC, },
735 { .name = "ab8500_ldo_ana", .driver_data = (void *) AB8500_LDO_ANA, },
736};
737
738static int 3074static int
739ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np) 3075ab8500_regulator_of_probe(struct platform_device *pdev,
3076 struct device_node *np)
740{ 3077{
3078 struct of_regulator_match *match = abx500_regulator.match;
741 int err, i; 3079 int err, i;
742 3080
743 for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { 3081 for (i = 0; i < abx500_regulator.info_size; i++) {
744 err = ab8500_regulator_register( 3082 err = ab8500_regulator_register(
745 pdev, ab8500_regulator_matches[i].init_data, 3083 pdev, match[i].init_data, i, match[i].of_node);
746 i, ab8500_regulator_matches[i].of_node);
747 if (err) 3084 if (err)
748 return err; 3085 return err;
749 } 3086 }
@@ -754,14 +3091,22 @@ ab8500_regulator_of_probe(struct platform_device *pdev, struct device_node *np)
754static int ab8500_regulator_probe(struct platform_device *pdev) 3091static int ab8500_regulator_probe(struct platform_device *pdev)
755{ 3092{
756 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); 3093 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
757 struct ab8500_platform_data *pdata;
758 struct device_node *np = pdev->dev.of_node; 3094 struct device_node *np = pdev->dev.of_node;
3095 struct ab8500_platform_data *ppdata;
3096 struct ab8500_regulator_platform_data *pdata;
759 int i, err; 3097 int i, err;
760 3098
3099 if (!ab8500) {
3100 dev_err(&pdev->dev, "null mfd parent\n");
3101 return -EINVAL;
3102 }
3103
3104 abx500_get_regulator_info(ab8500);
3105
761 if (np) { 3106 if (np) {
762 err = of_regulator_match(&pdev->dev, np, 3107 err = of_regulator_match(&pdev->dev, np,
763 ab8500_regulator_matches, 3108 abx500_regulator.match,
764 ARRAY_SIZE(ab8500_regulator_matches)); 3109 abx500_regulator.match_size);
765 if (err < 0) { 3110 if (err < 0) {
766 dev_err(&pdev->dev, 3111 dev_err(&pdev->dev,
767 "Error parsing regulator init data: %d\n", err); 3112 "Error parsing regulator init data: %d\n", err);
@@ -772,46 +3117,61 @@ static int ab8500_regulator_probe(struct platform_device *pdev)
772 return err; 3117 return err;
773 } 3118 }
774 3119
775 if (!ab8500) { 3120 ppdata = dev_get_platdata(ab8500->dev);
776 dev_err(&pdev->dev, "null mfd parent\n"); 3121 if (!ppdata) {
3122 dev_err(&pdev->dev, "null parent pdata\n");
777 return -EINVAL; 3123 return -EINVAL;
778 } 3124 }
779 pdata = dev_get_platdata(ab8500->dev); 3125
3126 pdata = ppdata->regulator;
780 if (!pdata) { 3127 if (!pdata) {
781 dev_err(&pdev->dev, "null pdata\n"); 3128 dev_err(&pdev->dev, "null pdata\n");
782 return -EINVAL; 3129 return -EINVAL;
783 } 3130 }
784 3131
785 /* make sure the platform data has the correct size */ 3132 /* make sure the platform data has the correct size */
786 if (pdata->num_regulator != ARRAY_SIZE(ab8500_regulator_info)) { 3133 if (pdata->num_regulator != abx500_regulator.info_size) {
787 dev_err(&pdev->dev, "Configuration error: size mismatch.\n"); 3134 dev_err(&pdev->dev, "Configuration error: size mismatch.\n");
788 return -EINVAL; 3135 return -EINVAL;
789 } 3136 }
790 3137
3138 /* initialize debug (initial state is recorded with this call) */
3139 err = ab8500_regulator_debug_init(pdev);
3140 if (err)
3141 return err;
3142
791 /* initialize registers */ 3143 /* initialize registers */
792 for (i = 0; i < pdata->num_regulator_reg_init; i++) { 3144 for (i = 0; i < pdata->num_reg_init; i++) {
793 int id, value; 3145 int id, mask, value;
794 3146
795 id = pdata->regulator_reg_init[i].id; 3147 id = pdata->reg_init[i].id;
796 value = pdata->regulator_reg_init[i].value; 3148 mask = pdata->reg_init[i].mask;
3149 value = pdata->reg_init[i].value;
797 3150
798 /* check for configuration errors */ 3151 /* check for configuration errors */
799 if (id >= AB8500_NUM_REGULATOR_REGISTERS) { 3152 BUG_ON(id >= abx500_regulator.init_size);
800 dev_err(&pdev->dev,
801 "Configuration error: id outside range.\n");
802 return -EINVAL;
803 }
804 3153
805 err = ab8500_regulator_init_registers(pdev, id, value); 3154 err = ab8500_regulator_init_registers(pdev, id, mask, value);
806 if (err < 0) 3155 if (err < 0)
807 return err; 3156 return err;
808 } 3157 }
809 3158
3159 if (!is_ab8505(ab8500)) {
3160 /* register external regulators (before Vaux1, 2 and 3) */
3161 err = ab8500_ext_regulator_init(pdev);
3162 if (err)
3163 return err;
3164 }
3165
810 /* register all regulators */ 3166 /* register all regulators */
811 for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { 3167 for (i = 0; i < abx500_regulator.info_size; i++) {
812 err = ab8500_regulator_register(pdev, &pdata->regulator[i], i, NULL); 3168 err = ab8500_regulator_register(pdev, &pdata->regulator[i],
813 if (err < 0) 3169 i, NULL);
3170 if (err < 0) {
3171 if (!is_ab8505(ab8500))
3172 ab8500_ext_regulator_exit(pdev);
814 return err; 3173 return err;
3174 }
815 } 3175 }
816 3176
817 return 0; 3177 return 0;
@@ -819,11 +3179,12 @@ static int ab8500_regulator_probe(struct platform_device *pdev)
819 3179
820static int ab8500_regulator_remove(struct platform_device *pdev) 3180static int ab8500_regulator_remove(struct platform_device *pdev)
821{ 3181{
822 int i; 3182 int i, err;
3183 struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent);
823 3184
824 for (i = 0; i < ARRAY_SIZE(ab8500_regulator_info); i++) { 3185 for (i = 0; i < abx500_regulator.info_size; i++) {
825 struct ab8500_regulator_info *info = NULL; 3186 struct ab8500_regulator_info *info = NULL;
826 info = &ab8500_regulator_info[i]; 3187 info = &abx500_regulator.info[i];
827 3188
828 dev_vdbg(rdev_get_dev(info->regulator), 3189 dev_vdbg(rdev_get_dev(info->regulator),
829 "%s-remove\n", info->desc.name); 3190 "%s-remove\n", info->desc.name);
@@ -831,6 +3192,15 @@ static int ab8500_regulator_remove(struct platform_device *pdev)
831 regulator_unregister(info->regulator); 3192 regulator_unregister(info->regulator);
832 } 3193 }
833 3194
3195 /* remove external regulators (after Vaux1, 2 and 3) */
3196 if (!is_ab8505(ab8500))
3197 ab8500_ext_regulator_exit(pdev);
3198
3199 /* remove regulator debug */
3200 err = ab8500_regulator_debug_exit(pdev);
3201 if (err)
3202 return err;
3203
834 return 0; 3204 return 0;
835} 3205}
836 3206
@@ -863,5 +3233,7 @@ module_exit(ab8500_regulator_exit);
863 3233
864MODULE_LICENSE("GPL v2"); 3234MODULE_LICENSE("GPL v2");
865MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>"); 3235MODULE_AUTHOR("Sundar Iyer <sundar.iyer@stericsson.com>");
3236MODULE_AUTHOR("Bengt Jonsson <bengt.g.jonsson@stericsson.com>");
3237MODULE_AUTHOR("Daniel Willerud <daniel.willerud@stericsson.com>");
866MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC"); 3238MODULE_DESCRIPTION("Regulator Driver for ST-Ericsson AB8500 Mixed-Sig PMIC");
867MODULE_ALIAS("platform:ab8500-regulator"); 3239MODULE_ALIAS("platform:ab8500-regulator");
diff --git a/drivers/regulator/arizona-ldo1.c b/drivers/regulator/arizona-ldo1.c
index ed7beec53af8..81d8681c3195 100644
--- a/drivers/regulator/arizona-ldo1.c
+++ b/drivers/regulator/arizona-ldo1.c
@@ -131,7 +131,7 @@ static const struct regulator_desc arizona_ldo1_hc = {
131 .min_uV = 900000, 131 .min_uV = 900000,
132 .uV_step = 50000, 132 .uV_step = 50000,
133 .n_voltages = 8, 133 .n_voltages = 8,
134 .enable_time = 500, 134 .enable_time = 1500,
135 135
136 .owner = THIS_MODULE, 136 .owner = THIS_MODULE,
137}; 137};
diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c
index f0ba8c4eefa9..3da6bd6950cf 100644
--- a/drivers/regulator/as3711-regulator.c
+++ b/drivers/regulator/as3711-regulator.c
@@ -13,9 +13,11 @@
13#include <linux/init.h> 13#include <linux/init.h>
14#include <linux/mfd/as3711.h> 14#include <linux/mfd/as3711.h>
15#include <linux/module.h> 15#include <linux/module.h>
16#include <linux/of.h>
16#include <linux/platform_device.h> 17#include <linux/platform_device.h>
17#include <linux/regmap.h> 18#include <linux/regmap.h>
18#include <linux/regulator/driver.h> 19#include <linux/regulator/driver.h>
20#include <linux/regulator/of_regulator.h>
19#include <linux/slab.h> 21#include <linux/slab.h>
20 22
21struct as3711_regulator_info { 23struct as3711_regulator_info {
@@ -276,6 +278,53 @@ static struct as3711_regulator_info as3711_reg_info[] = {
276 278
277#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info) 279#define AS3711_REGULATOR_NUM ARRAY_SIZE(as3711_reg_info)
278 280
281static struct of_regulator_match
282as3711_regulator_matches[AS3711_REGULATOR_NUM] = {
283 [AS3711_REGULATOR_SD_1] = { .name = "sd1" },
284 [AS3711_REGULATOR_SD_2] = { .name = "sd2" },
285 [AS3711_REGULATOR_SD_3] = { .name = "sd3" },
286 [AS3711_REGULATOR_SD_4] = { .name = "sd4" },
287 [AS3711_REGULATOR_LDO_1] = { .name = "ldo1" },
288 [AS3711_REGULATOR_LDO_2] = { .name = "ldo2" },
289 [AS3711_REGULATOR_LDO_3] = { .name = "ldo3" },
290 [AS3711_REGULATOR_LDO_4] = { .name = "ldo4" },
291 [AS3711_REGULATOR_LDO_5] = { .name = "ldo5" },
292 [AS3711_REGULATOR_LDO_6] = { .name = "ldo6" },
293 [AS3711_REGULATOR_LDO_7] = { .name = "ldo7" },
294 [AS3711_REGULATOR_LDO_8] = { .name = "ldo8" },
295};
296
297static int as3711_regulator_parse_dt(struct device *dev,
298 struct device_node **of_node, const int count)
299{
300 struct as3711_regulator_pdata *pdata = dev_get_platdata(dev);
301 struct device_node *regulators =
302 of_find_node_by_name(dev->parent->of_node, "regulators");
303 struct of_regulator_match *match;
304 int ret, i;
305
306 if (!regulators) {
307 dev_err(dev, "regulator node not found\n");
308 return -ENODEV;
309 }
310
311 ret = of_regulator_match(dev->parent, regulators,
312 as3711_regulator_matches, count);
313 of_node_put(regulators);
314 if (ret < 0) {
315 dev_err(dev, "Error parsing regulator init data: %d\n", ret);
316 return ret;
317 }
318
319 for (i = 0, match = as3711_regulator_matches; i < count; i++, match++)
320 if (match->of_node) {
321 pdata->init_data[i] = match->init_data;
322 of_node[i] = match->of_node;
323 }
324
325 return 0;
326}
327
279static int as3711_regulator_probe(struct platform_device *pdev) 328static int as3711_regulator_probe(struct platform_device *pdev)
280{ 329{
281 struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev); 330 struct as3711_regulator_pdata *pdata = dev_get_platdata(&pdev->dev);
@@ -284,13 +333,24 @@ static int as3711_regulator_probe(struct platform_device *pdev)
284 struct regulator_config config = {.dev = &pdev->dev,}; 333 struct regulator_config config = {.dev = &pdev->dev,};
285 struct as3711_regulator *reg = NULL; 334 struct as3711_regulator *reg = NULL;
286 struct as3711_regulator *regs; 335 struct as3711_regulator *regs;
336 struct device_node *of_node[AS3711_REGULATOR_NUM] = {};
287 struct regulator_dev *rdev; 337 struct regulator_dev *rdev;
288 struct as3711_regulator_info *ri; 338 struct as3711_regulator_info *ri;
289 int ret; 339 int ret;
290 int id; 340 int id;
291 341
292 if (!pdata) 342 if (!pdata) {
293 dev_dbg(&pdev->dev, "No platform data...\n"); 343 dev_err(&pdev->dev, "No platform data...\n");
344 return -ENODEV;
345 }
346
347 if (pdev->dev.parent->of_node) {
348 ret = as3711_regulator_parse_dt(&pdev->dev, of_node, AS3711_REGULATOR_NUM);
349 if (ret < 0) {
350 dev_err(&pdev->dev, "DT parsing failed: %d\n", ret);
351 return ret;
352 }
353 }
294 354
295 regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM * 355 regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM *
296 sizeof(struct as3711_regulator), GFP_KERNEL); 356 sizeof(struct as3711_regulator), GFP_KERNEL);
@@ -300,7 +360,7 @@ static int as3711_regulator_probe(struct platform_device *pdev)
300 } 360 }
301 361
302 for (id = 0, ri = as3711_reg_info; id < AS3711_REGULATOR_NUM; ++id, ri++) { 362 for (id = 0, ri = as3711_reg_info; id < AS3711_REGULATOR_NUM; ++id, ri++) {
303 reg_data = pdata ? pdata->init_data[id] : NULL; 363 reg_data = pdata->init_data[id];
304 364
305 /* No need to register if there is no regulator data */ 365 /* No need to register if there is no regulator data */
306 if (!reg_data) 366 if (!reg_data)
@@ -312,6 +372,7 @@ static int as3711_regulator_probe(struct platform_device *pdev)
312 config.init_data = reg_data; 372 config.init_data = reg_data;
313 config.driver_data = reg; 373 config.driver_data = reg;
314 config.regmap = as3711->regmap; 374 config.regmap = as3711->regmap;
375 config.of_node = of_node[id];
315 376
316 rdev = regulator_register(&ri->desc, &config); 377 rdev = regulator_register(&ri->desc, &config);
317 if (IS_ERR(rdev)) { 378 if (IS_ERR(rdev)) {
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e3661c20cf38..6e5017841582 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -51,6 +51,7 @@
51static DEFINE_MUTEX(regulator_list_mutex); 51static DEFINE_MUTEX(regulator_list_mutex);
52static LIST_HEAD(regulator_list); 52static LIST_HEAD(regulator_list);
53static LIST_HEAD(regulator_map_list); 53static LIST_HEAD(regulator_map_list);
54static LIST_HEAD(regulator_ena_gpio_list);
54static bool has_full_constraints; 55static bool has_full_constraints;
55static bool board_wants_dummy_regulator; 56static bool board_wants_dummy_regulator;
56 57
@@ -69,6 +70,19 @@ struct regulator_map {
69}; 70};
70 71
71/* 72/*
73 * struct regulator_enable_gpio
74 *
75 * Management for shared enable GPIO pin
76 */
77struct regulator_enable_gpio {
78 struct list_head list;
79 int gpio;
80 u32 enable_count; /* a number of enabled shared GPIO */
81 u32 request_count; /* a number of requested shared GPIO */
82 unsigned int ena_gpio_invert:1;
83};
84
85/*
72 * struct regulator 86 * struct regulator
73 * 87 *
74 * One for each consumer device. 88 * One for each consumer device.
@@ -116,7 +130,7 @@ static const char *rdev_get_name(struct regulator_dev *rdev)
116 * @supply: regulator supply name 130 * @supply: regulator supply name
117 * 131 *
118 * Extract the regulator device node corresponding to the supply name. 132 * Extract the regulator device node corresponding to the supply name.
119 * retruns the device node corresponding to the regulator if found, else 133 * returns the device node corresponding to the regulator if found, else
120 * returns NULL. 134 * returns NULL.
121 */ 135 */
122static struct device_node *of_get_regulator(struct device *dev, const char *supply) 136static struct device_node *of_get_regulator(struct device *dev, const char *supply)
@@ -1229,7 +1243,7 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
1229 struct regulator_dev *rdev; 1243 struct regulator_dev *rdev;
1230 struct regulator *regulator = ERR_PTR(-EPROBE_DEFER); 1244 struct regulator *regulator = ERR_PTR(-EPROBE_DEFER);
1231 const char *devname = NULL; 1245 const char *devname = NULL;
1232 int ret; 1246 int ret = 0;
1233 1247
1234 if (id == NULL) { 1248 if (id == NULL) {
1235 pr_err("get() with no identifier\n"); 1249 pr_err("get() with no identifier\n");
@@ -1245,6 +1259,15 @@ static struct regulator *_regulator_get(struct device *dev, const char *id,
1245 if (rdev) 1259 if (rdev)
1246 goto found; 1260 goto found;
1247 1261
1262 /*
1263 * If we have return value from dev_lookup fail, we do not expect to
1264 * succeed, so, quit with appropriate error value
1265 */
1266 if (ret) {
1267 regulator = ERR_PTR(ret);
1268 goto out;
1269 }
1270
1248 if (board_wants_dummy_regulator) { 1271 if (board_wants_dummy_regulator) {
1249 rdev = dummy_regulator_rdev; 1272 rdev = dummy_regulator_rdev;
1250 goto found; 1273 goto found;
@@ -1456,6 +1479,101 @@ void devm_regulator_put(struct regulator *regulator)
1456} 1479}
1457EXPORT_SYMBOL_GPL(devm_regulator_put); 1480EXPORT_SYMBOL_GPL(devm_regulator_put);
1458 1481
1482/* Manage enable GPIO list. Same GPIO pin can be shared among regulators */
1483static int regulator_ena_gpio_request(struct regulator_dev *rdev,
1484 const struct regulator_config *config)
1485{
1486 struct regulator_enable_gpio *pin;
1487 int ret;
1488
1489 list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
1490 if (pin->gpio == config->ena_gpio) {
1491 rdev_dbg(rdev, "GPIO %d is already used\n",
1492 config->ena_gpio);
1493 goto update_ena_gpio_to_rdev;
1494 }
1495 }
1496
1497 ret = gpio_request_one(config->ena_gpio,
1498 GPIOF_DIR_OUT | config->ena_gpio_flags,
1499 rdev_get_name(rdev));
1500 if (ret)
1501 return ret;
1502
1503 pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL);
1504 if (pin == NULL) {
1505 gpio_free(config->ena_gpio);
1506 return -ENOMEM;
1507 }
1508
1509 pin->gpio = config->ena_gpio;
1510 pin->ena_gpio_invert = config->ena_gpio_invert;
1511 list_add(&pin->list, &regulator_ena_gpio_list);
1512
1513update_ena_gpio_to_rdev:
1514 pin->request_count++;
1515 rdev->ena_pin = pin;
1516 return 0;
1517}
1518
1519static void regulator_ena_gpio_free(struct regulator_dev *rdev)
1520{
1521 struct regulator_enable_gpio *pin, *n;
1522
1523 if (!rdev->ena_pin)
1524 return;
1525
1526 /* Free the GPIO only in case of no use */
1527 list_for_each_entry_safe(pin, n, &regulator_ena_gpio_list, list) {
1528 if (pin->gpio == rdev->ena_pin->gpio) {
1529 if (pin->request_count <= 1) {
1530 pin->request_count = 0;
1531 gpio_free(pin->gpio);
1532 list_del(&pin->list);
1533 kfree(pin);
1534 } else {
1535 pin->request_count--;
1536 }
1537 }
1538 }
1539}
1540
1541/**
1542 * Balance enable_count of each GPIO and actual GPIO pin control.
1543 * GPIO is enabled in case of initial use. (enable_count is 0)
1544 * GPIO is disabled when it is not shared any more. (enable_count <= 1)
1545 */
1546static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
1547{
1548 struct regulator_enable_gpio *pin = rdev->ena_pin;
1549
1550 if (!pin)
1551 return -EINVAL;
1552
1553 if (enable) {
1554 /* Enable GPIO at initial use */
1555 if (pin->enable_count == 0)
1556 gpio_set_value_cansleep(pin->gpio,
1557 !pin->ena_gpio_invert);
1558
1559 pin->enable_count++;
1560 } else {
1561 if (pin->enable_count > 1) {
1562 pin->enable_count--;
1563 return 0;
1564 }
1565
1566 /* Disable GPIO if not used */
1567 if (pin->enable_count <= 1) {
1568 gpio_set_value_cansleep(pin->gpio,
1569 pin->ena_gpio_invert);
1570 pin->enable_count = 0;
1571 }
1572 }
1573
1574 return 0;
1575}
1576
1459static int _regulator_do_enable(struct regulator_dev *rdev) 1577static int _regulator_do_enable(struct regulator_dev *rdev)
1460{ 1578{
1461 int ret, delay; 1579 int ret, delay;
@@ -1471,9 +1589,10 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
1471 1589
1472 trace_regulator_enable(rdev_get_name(rdev)); 1590 trace_regulator_enable(rdev_get_name(rdev));
1473 1591
1474 if (rdev->ena_gpio) { 1592 if (rdev->ena_pin) {
1475 gpio_set_value_cansleep(rdev->ena_gpio, 1593 ret = regulator_ena_gpio_ctrl(rdev, true);
1476 !rdev->ena_gpio_invert); 1594 if (ret < 0)
1595 return ret;
1477 rdev->ena_gpio_state = 1; 1596 rdev->ena_gpio_state = 1;
1478 } else if (rdev->desc->ops->enable) { 1597 } else if (rdev->desc->ops->enable) {
1479 ret = rdev->desc->ops->enable(rdev); 1598 ret = rdev->desc->ops->enable(rdev);
@@ -1575,9 +1694,10 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
1575 1694
1576 trace_regulator_disable(rdev_get_name(rdev)); 1695 trace_regulator_disable(rdev_get_name(rdev));
1577 1696
1578 if (rdev->ena_gpio) { 1697 if (rdev->ena_pin) {
1579 gpio_set_value_cansleep(rdev->ena_gpio, 1698 ret = regulator_ena_gpio_ctrl(rdev, false);
1580 rdev->ena_gpio_invert); 1699 if (ret < 0)
1700 return ret;
1581 rdev->ena_gpio_state = 0; 1701 rdev->ena_gpio_state = 0;
1582 1702
1583 } else if (rdev->desc->ops->disable) { 1703 } else if (rdev->desc->ops->disable) {
@@ -1794,7 +1914,10 @@ int regulator_is_enabled_regmap(struct regulator_dev *rdev)
1794 if (ret != 0) 1914 if (ret != 0)
1795 return ret; 1915 return ret;
1796 1916
1797 return (val & rdev->desc->enable_mask) != 0; 1917 if (rdev->desc->enable_is_inverted)
1918 return (val & rdev->desc->enable_mask) == 0;
1919 else
1920 return (val & rdev->desc->enable_mask) != 0;
1798} 1921}
1799EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap); 1922EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
1800 1923
@@ -1809,9 +1932,15 @@ EXPORT_SYMBOL_GPL(regulator_is_enabled_regmap);
1809 */ 1932 */
1810int regulator_enable_regmap(struct regulator_dev *rdev) 1933int regulator_enable_regmap(struct regulator_dev *rdev)
1811{ 1934{
1935 unsigned int val;
1936
1937 if (rdev->desc->enable_is_inverted)
1938 val = 0;
1939 else
1940 val = rdev->desc->enable_mask;
1941
1812 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 1942 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
1813 rdev->desc->enable_mask, 1943 rdev->desc->enable_mask, val);
1814 rdev->desc->enable_mask);
1815} 1944}
1816EXPORT_SYMBOL_GPL(regulator_enable_regmap); 1945EXPORT_SYMBOL_GPL(regulator_enable_regmap);
1817 1946
@@ -1826,15 +1955,22 @@ EXPORT_SYMBOL_GPL(regulator_enable_regmap);
1826 */ 1955 */
1827int regulator_disable_regmap(struct regulator_dev *rdev) 1956int regulator_disable_regmap(struct regulator_dev *rdev)
1828{ 1957{
1958 unsigned int val;
1959
1960 if (rdev->desc->enable_is_inverted)
1961 val = rdev->desc->enable_mask;
1962 else
1963 val = 0;
1964
1829 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 1965 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
1830 rdev->desc->enable_mask, 0); 1966 rdev->desc->enable_mask, val);
1831} 1967}
1832EXPORT_SYMBOL_GPL(regulator_disable_regmap); 1968EXPORT_SYMBOL_GPL(regulator_disable_regmap);
1833 1969
1834static int _regulator_is_enabled(struct regulator_dev *rdev) 1970static int _regulator_is_enabled(struct regulator_dev *rdev)
1835{ 1971{
1836 /* A GPIO control always takes precedence */ 1972 /* A GPIO control always takes precedence */
1837 if (rdev->ena_gpio) 1973 if (rdev->ena_pin)
1838 return rdev->ena_gpio_state; 1974 return rdev->ena_gpio_state;
1839 1975
1840 /* If we don't know then assume that the regulator is always on */ 1976 /* If we don't know then assume that the regulator is always on */
@@ -2138,6 +2274,37 @@ int regulator_map_voltage_iterate(struct regulator_dev *rdev,
2138EXPORT_SYMBOL_GPL(regulator_map_voltage_iterate); 2274EXPORT_SYMBOL_GPL(regulator_map_voltage_iterate);
2139 2275
2140/** 2276/**
2277 * regulator_map_voltage_ascend - map_voltage() for ascendant voltage list
2278 *
2279 * @rdev: Regulator to operate on
2280 * @min_uV: Lower bound for voltage
2281 * @max_uV: Upper bound for voltage
2282 *
2283 * Drivers that have ascendant voltage list can use this as their
2284 * map_voltage() operation.
2285 */
2286int regulator_map_voltage_ascend(struct regulator_dev *rdev,
2287 int min_uV, int max_uV)
2288{
2289 int i, ret;
2290
2291 for (i = 0; i < rdev->desc->n_voltages; i++) {
2292 ret = rdev->desc->ops->list_voltage(rdev, i);
2293 if (ret < 0)
2294 continue;
2295
2296 if (ret > max_uV)
2297 break;
2298
2299 if (ret >= min_uV && ret <= max_uV)
2300 return i;
2301 }
2302
2303 return -EINVAL;
2304}
2305EXPORT_SYMBOL_GPL(regulator_map_voltage_ascend);
2306
2307/**
2141 * regulator_map_voltage_linear - map_voltage() for simple linear mappings 2308 * regulator_map_voltage_linear - map_voltage() for simple linear mappings
2142 * 2309 *
2143 * @rdev: Regulator to operate on 2310 * @rdev: Regulator to operate on
@@ -3237,7 +3404,7 @@ static int add_regulator_attributes(struct regulator_dev *rdev)
3237 if (status < 0) 3404 if (status < 0)
3238 return status; 3405 return status;
3239 } 3406 }
3240 if (rdev->ena_gpio || ops->is_enabled) { 3407 if (rdev->ena_pin || ops->is_enabled) {
3241 status = device_create_file(dev, &dev_attr_state); 3408 status = device_create_file(dev, &dev_attr_state);
3242 if (status < 0) 3409 if (status < 0)
3243 return status; 3410 return status;
@@ -3439,22 +3606,17 @@ regulator_register(const struct regulator_desc *regulator_desc,
3439 dev_set_drvdata(&rdev->dev, rdev); 3606 dev_set_drvdata(&rdev->dev, rdev);
3440 3607
3441 if (config->ena_gpio && gpio_is_valid(config->ena_gpio)) { 3608 if (config->ena_gpio && gpio_is_valid(config->ena_gpio)) {
3442 ret = gpio_request_one(config->ena_gpio, 3609 ret = regulator_ena_gpio_request(rdev, config);
3443 GPIOF_DIR_OUT | config->ena_gpio_flags,
3444 rdev_get_name(rdev));
3445 if (ret != 0) { 3610 if (ret != 0) {
3446 rdev_err(rdev, "Failed to request enable GPIO%d: %d\n", 3611 rdev_err(rdev, "Failed to request enable GPIO%d: %d\n",
3447 config->ena_gpio, ret); 3612 config->ena_gpio, ret);
3448 goto wash; 3613 goto wash;
3449 } 3614 }
3450 3615
3451 rdev->ena_gpio = config->ena_gpio;
3452 rdev->ena_gpio_invert = config->ena_gpio_invert;
3453
3454 if (config->ena_gpio_flags & GPIOF_OUT_INIT_HIGH) 3616 if (config->ena_gpio_flags & GPIOF_OUT_INIT_HIGH)
3455 rdev->ena_gpio_state = 1; 3617 rdev->ena_gpio_state = 1;
3456 3618
3457 if (rdev->ena_gpio_invert) 3619 if (config->ena_gpio_invert)
3458 rdev->ena_gpio_state = !rdev->ena_gpio_state; 3620 rdev->ena_gpio_state = !rdev->ena_gpio_state;
3459 } 3621 }
3460 3622
@@ -3481,7 +3643,14 @@ regulator_register(const struct regulator_desc *regulator_desc,
3481 3643
3482 r = regulator_dev_lookup(dev, supply, &ret); 3644 r = regulator_dev_lookup(dev, supply, &ret);
3483 3645
3484 if (!r) { 3646 if (ret == -ENODEV) {
3647 /*
3648 * No supply was specified for this regulator and
3649 * there will never be one.
3650 */
3651 ret = 0;
3652 goto add_dev;
3653 } else if (!r) {
3485 dev_err(dev, "Failed to find supply %s\n", supply); 3654 dev_err(dev, "Failed to find supply %s\n", supply);
3486 ret = -EPROBE_DEFER; 3655 ret = -EPROBE_DEFER;
3487 goto scrub; 3656 goto scrub;
@@ -3499,6 +3668,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
3499 } 3668 }
3500 } 3669 }
3501 3670
3671add_dev:
3502 /* add consumers devices */ 3672 /* add consumers devices */
3503 if (init_data) { 3673 if (init_data) {
3504 for (i = 0; i < init_data->num_consumer_supplies; i++) { 3674 for (i = 0; i < init_data->num_consumer_supplies; i++) {
@@ -3526,8 +3696,7 @@ unset_supplies:
3526scrub: 3696scrub:
3527 if (rdev->supply) 3697 if (rdev->supply)
3528 _regulator_put(rdev->supply); 3698 _regulator_put(rdev->supply);
3529 if (rdev->ena_gpio) 3699 regulator_ena_gpio_free(rdev);
3530 gpio_free(rdev->ena_gpio);
3531 kfree(rdev->constraints); 3700 kfree(rdev->constraints);
3532wash: 3701wash:
3533 device_unregister(&rdev->dev); 3702 device_unregister(&rdev->dev);
@@ -3562,8 +3731,7 @@ void regulator_unregister(struct regulator_dev *rdev)
3562 unset_regulator_supplies(rdev); 3731 unset_regulator_supplies(rdev);
3563 list_del(&rdev->list); 3732 list_del(&rdev->list);
3564 kfree(rdev->constraints); 3733 kfree(rdev->constraints);
3565 if (rdev->ena_gpio) 3734 regulator_ena_gpio_free(rdev);
3566 gpio_free(rdev->ena_gpio);
3567 device_unregister(&rdev->dev); 3735 device_unregister(&rdev->dev);
3568 mutex_unlock(&regulator_list_mutex); 3736 mutex_unlock(&regulator_list_mutex);
3569} 3737}
diff --git a/drivers/regulator/dbx500-prcmu.h b/drivers/regulator/dbx500-prcmu.h
index e763883a44f4..c8e51ace9f06 100644
--- a/drivers/regulator/dbx500-prcmu.h
+++ b/drivers/regulator/dbx500-prcmu.h
@@ -21,7 +21,6 @@
21 * @is_enabled: status of the regulator 21 * @is_enabled: status of the regulator
22 * @epod_id: id for EPOD (power domain) 22 * @epod_id: id for EPOD (power domain)
23 * @is_ramret: RAM retention switch for EPOD (power domain) 23 * @is_ramret: RAM retention switch for EPOD (power domain)
24 * @operating_point: operating point (only for vape, to be removed)
25 * 24 *
26 */ 25 */
27struct dbx500_regulator_info { 26struct dbx500_regulator_info {
@@ -32,7 +31,6 @@ struct dbx500_regulator_info {
32 u16 epod_id; 31 u16 epod_id;
33 bool is_ramret; 32 bool is_ramret;
34 bool exclude_from_power_state; 33 bool exclude_from_power_state;
35 unsigned int operating_point;
36}; 34};
37 35
38void power_state_active_enable(void); 36void power_state_active_enable(void);
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 9165b0c40ed3..f0e1ae52bb05 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -219,9 +219,7 @@ static int fan53555_regulator_register(struct fan53555_device_info *di,
219 rdesc->owner = THIS_MODULE; 219 rdesc->owner = THIS_MODULE;
220 220
221 di->rdev = regulator_register(&di->desc, config); 221 di->rdev = regulator_register(&di->desc, config);
222 if (IS_ERR(di->rdev)) 222 return PTR_RET(di->rdev);
223 return PTR_ERR(di->rdev);
224 return 0;
225 223
226} 224}
227 225
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c
index 9cb2c0f34515..d8af9e773310 100644
--- a/drivers/regulator/lp3971.c
+++ b/drivers/regulator/lp3971.c
@@ -163,6 +163,7 @@ static int lp3971_ldo_set_voltage_sel(struct regulator_dev *dev,
163 163
164static struct regulator_ops lp3971_ldo_ops = { 164static struct regulator_ops lp3971_ldo_ops = {
165 .list_voltage = regulator_list_voltage_table, 165 .list_voltage = regulator_list_voltage_table,
166 .map_voltage = regulator_map_voltage_ascend,
166 .is_enabled = lp3971_ldo_is_enabled, 167 .is_enabled = lp3971_ldo_is_enabled,
167 .enable = lp3971_ldo_enable, 168 .enable = lp3971_ldo_enable,
168 .disable = lp3971_ldo_disable, 169 .disable = lp3971_ldo_disable,
@@ -236,6 +237,7 @@ static int lp3971_dcdc_set_voltage_sel(struct regulator_dev *dev,
236 237
237static struct regulator_ops lp3971_dcdc_ops = { 238static struct regulator_ops lp3971_dcdc_ops = {
238 .list_voltage = regulator_list_voltage_table, 239 .list_voltage = regulator_list_voltage_table,
240 .map_voltage = regulator_map_voltage_ascend,
239 .is_enabled = lp3971_dcdc_is_enabled, 241 .is_enabled = lp3971_dcdc_is_enabled,
240 .enable = lp3971_dcdc_enable, 242 .enable = lp3971_dcdc_enable,
241 .disable = lp3971_dcdc_disable, 243 .disable = lp3971_dcdc_disable,
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c
index 0baabcfb578a..61e4cf9edf6e 100644
--- a/drivers/regulator/lp3972.c
+++ b/drivers/regulator/lp3972.c
@@ -309,6 +309,7 @@ static int lp3972_ldo_set_voltage_sel(struct regulator_dev *dev,
309 309
310static struct regulator_ops lp3972_ldo_ops = { 310static struct regulator_ops lp3972_ldo_ops = {
311 .list_voltage = regulator_list_voltage_table, 311 .list_voltage = regulator_list_voltage_table,
312 .map_voltage = regulator_map_voltage_ascend,
312 .is_enabled = lp3972_ldo_is_enabled, 313 .is_enabled = lp3972_ldo_is_enabled,
313 .enable = lp3972_ldo_enable, 314 .enable = lp3972_ldo_enable,
314 .disable = lp3972_ldo_disable, 315 .disable = lp3972_ldo_disable,
@@ -389,6 +390,7 @@ static int lp3972_dcdc_set_voltage_sel(struct regulator_dev *dev,
389 390
390static struct regulator_ops lp3972_dcdc_ops = { 391static struct regulator_ops lp3972_dcdc_ops = {
391 .list_voltage = regulator_list_voltage_table, 392 .list_voltage = regulator_list_voltage_table,
393 .map_voltage = regulator_map_voltage_ascend,
392 .is_enabled = lp3972_dcdc_is_enabled, 394 .is_enabled = lp3972_dcdc_is_enabled,
393 .enable = lp3972_dcdc_enable, 395 .enable = lp3972_dcdc_enable,
394 .disable = lp3972_dcdc_disable, 396 .disable = lp3972_dcdc_disable,
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index 8e3c7ae0047f..f5fc4a142cdf 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -478,6 +478,7 @@ static unsigned int lp872x_buck_get_mode(struct regulator_dev *rdev)
478 478
479static struct regulator_ops lp872x_ldo_ops = { 479static struct regulator_ops lp872x_ldo_ops = {
480 .list_voltage = regulator_list_voltage_table, 480 .list_voltage = regulator_list_voltage_table,
481 .map_voltage = regulator_map_voltage_ascend,
481 .set_voltage_sel = regulator_set_voltage_sel_regmap, 482 .set_voltage_sel = regulator_set_voltage_sel_regmap,
482 .get_voltage_sel = regulator_get_voltage_sel_regmap, 483 .get_voltage_sel = regulator_get_voltage_sel_regmap,
483 .enable = regulator_enable_regmap, 484 .enable = regulator_enable_regmap,
@@ -488,6 +489,7 @@ static struct regulator_ops lp872x_ldo_ops = {
488 489
489static struct regulator_ops lp8720_buck_ops = { 490static struct regulator_ops lp8720_buck_ops = {
490 .list_voltage = regulator_list_voltage_table, 491 .list_voltage = regulator_list_voltage_table,
492 .map_voltage = regulator_map_voltage_ascend,
491 .set_voltage_sel = lp872x_buck_set_voltage_sel, 493 .set_voltage_sel = lp872x_buck_set_voltage_sel,
492 .get_voltage_sel = lp872x_buck_get_voltage_sel, 494 .get_voltage_sel = lp872x_buck_get_voltage_sel,
493 .enable = regulator_enable_regmap, 495 .enable = regulator_enable_regmap,
@@ -500,6 +502,7 @@ static struct regulator_ops lp8720_buck_ops = {
500 502
501static struct regulator_ops lp8725_buck_ops = { 503static struct regulator_ops lp8725_buck_ops = {
502 .list_voltage = regulator_list_voltage_table, 504 .list_voltage = regulator_list_voltage_table,
505 .map_voltage = regulator_map_voltage_ascend,
503 .set_voltage_sel = lp872x_buck_set_voltage_sel, 506 .set_voltage_sel = lp872x_buck_set_voltage_sel,
504 .get_voltage_sel = lp872x_buck_get_voltage_sel, 507 .get_voltage_sel = lp872x_buck_get_voltage_sel,
505 .enable = regulator_enable_regmap, 508 .enable = regulator_enable_regmap,
diff --git a/drivers/regulator/lp8788-buck.c b/drivers/regulator/lp8788-buck.c
index 97891a7ea7b2..eb1e1e88ae51 100644
--- a/drivers/regulator/lp8788-buck.c
+++ b/drivers/regulator/lp8788-buck.c
@@ -346,6 +346,7 @@ static unsigned int lp8788_buck_get_mode(struct regulator_dev *rdev)
346 346
347static struct regulator_ops lp8788_buck12_ops = { 347static struct regulator_ops lp8788_buck12_ops = {
348 .list_voltage = regulator_list_voltage_table, 348 .list_voltage = regulator_list_voltage_table,
349 .map_voltage = regulator_map_voltage_ascend,
349 .set_voltage_sel = lp8788_buck12_set_voltage_sel, 350 .set_voltage_sel = lp8788_buck12_set_voltage_sel,
350 .get_voltage_sel = lp8788_buck12_get_voltage_sel, 351 .get_voltage_sel = lp8788_buck12_get_voltage_sel,
351 .enable = regulator_enable_regmap, 352 .enable = regulator_enable_regmap,
@@ -358,6 +359,7 @@ static struct regulator_ops lp8788_buck12_ops = {
358 359
359static struct regulator_ops lp8788_buck34_ops = { 360static struct regulator_ops lp8788_buck34_ops = {
360 .list_voltage = regulator_list_voltage_table, 361 .list_voltage = regulator_list_voltage_table,
362 .map_voltage = regulator_map_voltage_ascend,
361 .set_voltage_sel = regulator_set_voltage_sel_regmap, 363 .set_voltage_sel = regulator_set_voltage_sel_regmap,
362 .get_voltage_sel = regulator_get_voltage_sel_regmap, 364 .get_voltage_sel = regulator_get_voltage_sel_regmap,
363 .enable = regulator_enable_regmap, 365 .enable = regulator_enable_regmap,
diff --git a/drivers/regulator/lp8788-ldo.c b/drivers/regulator/lp8788-ldo.c
index cd5a14ad9263..0ce2c4c194b3 100644
--- a/drivers/regulator/lp8788-ldo.c
+++ b/drivers/regulator/lp8788-ldo.c
@@ -156,68 +156,6 @@ static const int lp8788_aldo7_vtbl[] = {
156 1200000, 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1800000, 156 1200000, 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1800000,
157}; 157};
158 158
159static enum lp8788_ldo_id lp8788_dldo_id[] = {
160 DLDO1,
161 DLDO2,
162 DLDO3,
163 DLDO4,
164 DLDO5,
165 DLDO6,
166 DLDO7,
167 DLDO8,
168 DLDO9,
169 DLDO10,
170 DLDO11,
171 DLDO12,
172};
173
174static enum lp8788_ldo_id lp8788_aldo_id[] = {
175 ALDO1,
176 ALDO2,
177 ALDO3,
178 ALDO4,
179 ALDO5,
180 ALDO6,
181 ALDO7,
182 ALDO8,
183 ALDO9,
184 ALDO10,
185};
186
187static int lp8788_ldo_enable(struct regulator_dev *rdev)
188{
189 struct lp8788_ldo *ldo = rdev_get_drvdata(rdev);
190
191 if (ldo->en_pin) {
192 gpio_set_value(ldo->en_pin->gpio, ENABLE);
193 return 0;
194 } else {
195 return regulator_enable_regmap(rdev);
196 }
197}
198
199static int lp8788_ldo_disable(struct regulator_dev *rdev)
200{
201 struct lp8788_ldo *ldo = rdev_get_drvdata(rdev);
202
203 if (ldo->en_pin) {
204 gpio_set_value(ldo->en_pin->gpio, DISABLE);
205 return 0;
206 } else {
207 return regulator_disable_regmap(rdev);
208 }
209}
210
211static int lp8788_ldo_is_enabled(struct regulator_dev *rdev)
212{
213 struct lp8788_ldo *ldo = rdev_get_drvdata(rdev);
214
215 if (ldo->en_pin)
216 return gpio_get_value(ldo->en_pin->gpio) ? 1 : 0;
217 else
218 return regulator_is_enabled_regmap(rdev);
219}
220
221static int lp8788_ldo_enable_time(struct regulator_dev *rdev) 159static int lp8788_ldo_enable_time(struct regulator_dev *rdev)
222{ 160{
223 struct lp8788_ldo *ldo = rdev_get_drvdata(rdev); 161 struct lp8788_ldo *ldo = rdev_get_drvdata(rdev);
@@ -232,38 +170,21 @@ static int lp8788_ldo_enable_time(struct regulator_dev *rdev)
232 return ENABLE_TIME_USEC * val; 170 return ENABLE_TIME_USEC * val;
233} 171}
234 172
235static int lp8788_ldo_fixed_get_voltage(struct regulator_dev *rdev)
236{
237 enum lp8788_ldo_id id = rdev_get_id(rdev);
238
239 switch (id) {
240 case ALDO2 ... ALDO5:
241 return 2850000;
242 case DLDO12:
243 case ALDO8 ... ALDO9:
244 return 2500000;
245 case ALDO10:
246 return 1100000;
247 default:
248 return -EINVAL;
249 }
250}
251
252static struct regulator_ops lp8788_ldo_voltage_table_ops = { 173static struct regulator_ops lp8788_ldo_voltage_table_ops = {
253 .list_voltage = regulator_list_voltage_table, 174 .list_voltage = regulator_list_voltage_table,
254 .set_voltage_sel = regulator_set_voltage_sel_regmap, 175 .set_voltage_sel = regulator_set_voltage_sel_regmap,
255 .get_voltage_sel = regulator_get_voltage_sel_regmap, 176 .get_voltage_sel = regulator_get_voltage_sel_regmap,
256 .enable = lp8788_ldo_enable, 177 .enable = regulator_enable_regmap,
257 .disable = lp8788_ldo_disable, 178 .disable = regulator_disable_regmap,
258 .is_enabled = lp8788_ldo_is_enabled, 179 .is_enabled = regulator_is_enabled_regmap,
259 .enable_time = lp8788_ldo_enable_time, 180 .enable_time = lp8788_ldo_enable_time,
260}; 181};
261 182
262static struct regulator_ops lp8788_ldo_voltage_fixed_ops = { 183static struct regulator_ops lp8788_ldo_voltage_fixed_ops = {
263 .get_voltage = lp8788_ldo_fixed_get_voltage, 184 .list_voltage = regulator_list_voltage_linear,
264 .enable = lp8788_ldo_enable, 185 .enable = regulator_enable_regmap,
265 .disable = lp8788_ldo_disable, 186 .disable = regulator_disable_regmap,
266 .is_enabled = lp8788_ldo_is_enabled, 187 .is_enabled = regulator_is_enabled_regmap,
267 .enable_time = lp8788_ldo_enable_time, 188 .enable_time = lp8788_ldo_enable_time,
268}; 189};
269 190
@@ -420,6 +341,7 @@ static struct regulator_desc lp8788_dldo_desc[] = {
420 .owner = THIS_MODULE, 341 .owner = THIS_MODULE,
421 .enable_reg = LP8788_EN_LDO_B, 342 .enable_reg = LP8788_EN_LDO_B,
422 .enable_mask = LP8788_EN_DLDO12_M, 343 .enable_mask = LP8788_EN_DLDO12_M,
344 .min_uV = 2500000,
423 }, 345 },
424}; 346};
425 347
@@ -446,6 +368,7 @@ static struct regulator_desc lp8788_aldo_desc[] = {
446 .owner = THIS_MODULE, 368 .owner = THIS_MODULE,
447 .enable_reg = LP8788_EN_LDO_B, 369 .enable_reg = LP8788_EN_LDO_B,
448 .enable_mask = LP8788_EN_ALDO2_M, 370 .enable_mask = LP8788_EN_ALDO2_M,
371 .min_uV = 2850000,
449 }, 372 },
450 { 373 {
451 .name = "aldo3", 374 .name = "aldo3",
@@ -456,6 +379,7 @@ static struct regulator_desc lp8788_aldo_desc[] = {
456 .owner = THIS_MODULE, 379 .owner = THIS_MODULE,
457 .enable_reg = LP8788_EN_LDO_B, 380 .enable_reg = LP8788_EN_LDO_B,
458 .enable_mask = LP8788_EN_ALDO3_M, 381 .enable_mask = LP8788_EN_ALDO3_M,
382 .min_uV = 2850000,
459 }, 383 },
460 { 384 {
461 .name = "aldo4", 385 .name = "aldo4",
@@ -466,6 +390,7 @@ static struct regulator_desc lp8788_aldo_desc[] = {
466 .owner = THIS_MODULE, 390 .owner = THIS_MODULE,
467 .enable_reg = LP8788_EN_LDO_B, 391 .enable_reg = LP8788_EN_LDO_B,
468 .enable_mask = LP8788_EN_ALDO4_M, 392 .enable_mask = LP8788_EN_ALDO4_M,
393 .min_uV = 2850000,
469 }, 394 },
470 { 395 {
471 .name = "aldo5", 396 .name = "aldo5",
@@ -476,6 +401,7 @@ static struct regulator_desc lp8788_aldo_desc[] = {
476 .owner = THIS_MODULE, 401 .owner = THIS_MODULE,
477 .enable_reg = LP8788_EN_LDO_C, 402 .enable_reg = LP8788_EN_LDO_C,
478 .enable_mask = LP8788_EN_ALDO5_M, 403 .enable_mask = LP8788_EN_ALDO5_M,
404 .min_uV = 2850000,
479 }, 405 },
480 { 406 {
481 .name = "aldo6", 407 .name = "aldo6",
@@ -512,6 +438,7 @@ static struct regulator_desc lp8788_aldo_desc[] = {
512 .owner = THIS_MODULE, 438 .owner = THIS_MODULE,
513 .enable_reg = LP8788_EN_LDO_C, 439 .enable_reg = LP8788_EN_LDO_C,
514 .enable_mask = LP8788_EN_ALDO8_M, 440 .enable_mask = LP8788_EN_ALDO8_M,
441 .min_uV = 2500000,
515 }, 442 },
516 { 443 {
517 .name = "aldo9", 444 .name = "aldo9",
@@ -522,6 +449,7 @@ static struct regulator_desc lp8788_aldo_desc[] = {
522 .owner = THIS_MODULE, 449 .owner = THIS_MODULE,
523 .enable_reg = LP8788_EN_LDO_C, 450 .enable_reg = LP8788_EN_LDO_C,
524 .enable_mask = LP8788_EN_ALDO9_M, 451 .enable_mask = LP8788_EN_ALDO9_M,
452 .min_uV = 2500000,
525 }, 453 },
526 { 454 {
527 .name = "aldo10", 455 .name = "aldo10",
@@ -532,46 +460,14 @@ static struct regulator_desc lp8788_aldo_desc[] = {
532 .owner = THIS_MODULE, 460 .owner = THIS_MODULE,
533 .enable_reg = LP8788_EN_LDO_C, 461 .enable_reg = LP8788_EN_LDO_C,
534 .enable_mask = LP8788_EN_ALDO10_M, 462 .enable_mask = LP8788_EN_ALDO10_M,
463 .min_uV = 1100000,
535 }, 464 },
536}; 465};
537 466
538static int lp8788_gpio_request_ldo_en(struct platform_device *pdev,
539 struct lp8788_ldo *ldo,
540 enum lp8788_ext_ldo_en_id id)
541{
542 struct device *dev = &pdev->dev;
543 struct lp8788_ldo_enable_pin *pin = ldo->en_pin;
544 int ret, gpio, pinstate;
545 char *name[] = {
546 [EN_ALDO1] = "LP8788_EN_ALDO1",
547 [EN_ALDO234] = "LP8788_EN_ALDO234",
548 [EN_ALDO5] = "LP8788_EN_ALDO5",
549 [EN_ALDO7] = "LP8788_EN_ALDO7",
550 [EN_DLDO7] = "LP8788_EN_DLDO7",
551 [EN_DLDO911] = "LP8788_EN_DLDO911",
552 };
553
554 gpio = pin->gpio;
555 if (!gpio_is_valid(gpio)) {
556 dev_err(dev, "invalid gpio: %d\n", gpio);
557 return -EINVAL;
558 }
559
560 pinstate = pin->init_state;
561 ret = devm_gpio_request_one(dev, gpio, pinstate, name[id]);
562 if (ret == -EBUSY) {
563 dev_warn(dev, "gpio%d already used\n", gpio);
564 return 0;
565 }
566
567 return ret;
568}
569
570static int lp8788_config_ldo_enable_mode(struct platform_device *pdev, 467static int lp8788_config_ldo_enable_mode(struct platform_device *pdev,
571 struct lp8788_ldo *ldo, 468 struct lp8788_ldo *ldo,
572 enum lp8788_ldo_id id) 469 enum lp8788_ldo_id id)
573{ 470{
574 int ret;
575 struct lp8788 *lp = ldo->lp; 471 struct lp8788 *lp = ldo->lp;
576 struct lp8788_platform_data *pdata = lp->pdata; 472 struct lp8788_platform_data *pdata = lp->pdata;
577 enum lp8788_ext_ldo_en_id enable_id; 473 enum lp8788_ext_ldo_en_id enable_id;
@@ -613,14 +509,7 @@ static int lp8788_config_ldo_enable_mode(struct platform_device *pdev,
613 goto set_default_ldo_enable_mode; 509 goto set_default_ldo_enable_mode;
614 510
615 ldo->en_pin = pdata->ldo_pin[enable_id]; 511 ldo->en_pin = pdata->ldo_pin[enable_id];
616 512 return 0;
617 ret = lp8788_gpio_request_ldo_en(pdev, ldo, enable_id);
618 if (ret) {
619 ldo->en_pin = NULL;
620 goto set_default_ldo_enable_mode;
621 }
622
623 return ret;
624 513
625set_default_ldo_enable_mode: 514set_default_ldo_enable_mode:
626 return lp8788_update_bits(lp, LP8788_EN_SEL, en_mask[enable_id], 0); 515 return lp8788_update_bits(lp, LP8788_EN_SEL, en_mask[enable_id], 0);
@@ -640,10 +529,15 @@ static int lp8788_dldo_probe(struct platform_device *pdev)
640 return -ENOMEM; 529 return -ENOMEM;
641 530
642 ldo->lp = lp; 531 ldo->lp = lp;
643 ret = lp8788_config_ldo_enable_mode(pdev, ldo, lp8788_dldo_id[id]); 532 ret = lp8788_config_ldo_enable_mode(pdev, ldo, id);
644 if (ret) 533 if (ret)
645 return ret; 534 return ret;
646 535
536 if (ldo->en_pin) {
537 cfg.ena_gpio = ldo->en_pin->gpio;
538 cfg.ena_gpio_flags = ldo->en_pin->init_state;
539 }
540
647 cfg.dev = pdev->dev.parent; 541 cfg.dev = pdev->dev.parent;
648 cfg.init_data = lp->pdata ? lp->pdata->dldo_data[id] : NULL; 542 cfg.init_data = lp->pdata ? lp->pdata->dldo_data[id] : NULL;
649 cfg.driver_data = ldo; 543 cfg.driver_data = ldo;
@@ -696,10 +590,15 @@ static int lp8788_aldo_probe(struct platform_device *pdev)
696 return -ENOMEM; 590 return -ENOMEM;
697 591
698 ldo->lp = lp; 592 ldo->lp = lp;
699 ret = lp8788_config_ldo_enable_mode(pdev, ldo, lp8788_aldo_id[id]); 593 ret = lp8788_config_ldo_enable_mode(pdev, ldo, id + ALDO1);
700 if (ret) 594 if (ret)
701 return ret; 595 return ret;
702 596
597 if (ldo->en_pin) {
598 cfg.ena_gpio = ldo->en_pin->gpio;
599 cfg.ena_gpio_flags = ldo->en_pin->init_state;
600 }
601
703 cfg.dev = pdev->dev.parent; 602 cfg.dev = pdev->dev.parent;
704 cfg.init_data = lp->pdata ? lp->pdata->aldo_data[id] : NULL; 603 cfg.init_data = lp->pdata ? lp->pdata->aldo_data[id] : NULL;
705 cfg.driver_data = ldo; 604 cfg.driver_data = ldo;
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index 8c5a54f541b5..54af61015814 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -56,7 +56,7 @@ struct max1586_data {
56 * set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3) 56 * set V6 to either 0V, 1.8V, 2.5V, 3V depending on (x & 0x3)
57 * As regulator framework doesn't accept voltages to be 0V, we use 1uV. 57 * As regulator framework doesn't accept voltages to be 0V, we use 1uV.
58 */ 58 */
59static int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 }; 59static const unsigned int v6_voltages_uv[] = { 1, 1800000, 2500000, 3000000 };
60 60
61/* 61/*
62 * V3 voltage 62 * V3 voltage
@@ -232,8 +232,7 @@ static int max1586_pmic_remove(struct i2c_client *client)
232 int i; 232 int i;
233 233
234 for (i = 0; i <= MAX1586_V6; i++) 234 for (i = 0; i <= MAX1586_V6; i++)
235 if (max1586->rdev[i]) 235 regulator_unregister(max1586->rdev[i]);
236 regulator_unregister(max1586->rdev[i]);
237 return 0; 236 return 0;
238} 237}
239 238
diff --git a/drivers/regulator/max77686.c b/drivers/regulator/max77686.c
index e4586ee8858d..20935b1a6ed4 100644
--- a/drivers/regulator/max77686.c
+++ b/drivers/regulator/max77686.c
@@ -75,17 +75,20 @@ static int max77686_buck_set_suspend_disable(struct regulator_dev *rdev)
75{ 75{
76 unsigned int val; 76 unsigned int val;
77 struct max77686_data *max77686 = rdev_get_drvdata(rdev); 77 struct max77686_data *max77686 = rdev_get_drvdata(rdev);
78 int id = rdev_get_id(rdev); 78 int ret, id = rdev_get_id(rdev);
79 79
80 if (id == MAX77686_BUCK1) 80 if (id == MAX77686_BUCK1)
81 val = 0x1; 81 val = 0x1;
82 else 82 else
83 val = 0x1 << MAX77686_OPMODE_BUCK234_SHIFT; 83 val = 0x1 << MAX77686_OPMODE_BUCK234_SHIFT;
84 84
85 ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
86 rdev->desc->enable_mask, val);
87 if (ret)
88 return ret;
89
85 max77686->opmode[id] = val; 90 max77686->opmode[id] = val;
86 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 91 return 0;
87 rdev->desc->enable_mask,
88 val);
89} 92}
90 93
91/* Some LDOs supports [LPM/Normal]ON mode during suspend state */ 94/* Some LDOs supports [LPM/Normal]ON mode during suspend state */
@@ -94,7 +97,7 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev,
94{ 97{
95 struct max77686_data *max77686 = rdev_get_drvdata(rdev); 98 struct max77686_data *max77686 = rdev_get_drvdata(rdev);
96 unsigned int val; 99 unsigned int val;
97 int id = rdev_get_id(rdev); 100 int ret, id = rdev_get_id(rdev);
98 101
99 /* BUCK[5-9] doesn't support this feature */ 102 /* BUCK[5-9] doesn't support this feature */
100 if (id >= MAX77686_BUCK5) 103 if (id >= MAX77686_BUCK5)
@@ -113,10 +116,13 @@ static int max77686_set_suspend_mode(struct regulator_dev *rdev,
113 return -EINVAL; 116 return -EINVAL;
114 } 117 }
115 118
119 ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
120 rdev->desc->enable_mask, val);
121 if (ret)
122 return ret;
123
116 max77686->opmode[id] = val; 124 max77686->opmode[id] = val;
117 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 125 return 0;
118 rdev->desc->enable_mask,
119 val);
120} 126}
121 127
122/* Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state */ 128/* Some LDOs supports LPM-ON/OFF/Normal-ON mode during suspend state */
@@ -125,6 +131,7 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev,
125{ 131{
126 unsigned int val; 132 unsigned int val;
127 struct max77686_data *max77686 = rdev_get_drvdata(rdev); 133 struct max77686_data *max77686 = rdev_get_drvdata(rdev);
134 int ret;
128 135
129 switch (mode) { 136 switch (mode) {
130 case REGULATOR_MODE_STANDBY: /* switch off */ 137 case REGULATOR_MODE_STANDBY: /* switch off */
@@ -142,10 +149,13 @@ static int max77686_ldo_set_suspend_mode(struct regulator_dev *rdev,
142 return -EINVAL; 149 return -EINVAL;
143 } 150 }
144 151
152 ret = regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
153 rdev->desc->enable_mask, val);
154 if (ret)
155 return ret;
156
145 max77686->opmode[rdev_get_id(rdev)] = val; 157 max77686->opmode[rdev_get_id(rdev)] = val;
146 return regmap_update_bits(rdev->regmap, rdev->desc->enable_reg, 158 return 0;
147 rdev->desc->enable_mask,
148 val);
149} 159}
150 160
151static int max77686_enable(struct regulator_dev *rdev) 161static int max77686_enable(struct regulator_dev *rdev)
diff --git a/drivers/regulator/max8649.c b/drivers/regulator/max8649.c
index 3ca14380f22d..db6c9be10f3f 100644
--- a/drivers/regulator/max8649.c
+++ b/drivers/regulator/max8649.c
@@ -60,36 +60,6 @@ struct max8649_regulator_info {
60 unsigned ramp_down:1; 60 unsigned ramp_down:1;
61}; 61};
62 62
63/* EN_PD means pulldown on EN input */
64static int max8649_enable(struct regulator_dev *rdev)
65{
66 struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
67 return regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_EN_PD, 0);
68}
69
70/*
71 * Applied internal pulldown resistor on EN input pin.
72 * If pulldown EN pin outside, it would be better.
73 */
74static int max8649_disable(struct regulator_dev *rdev)
75{
76 struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
77 return regmap_update_bits(info->regmap, MAX8649_CONTROL, MAX8649_EN_PD,
78 MAX8649_EN_PD);
79}
80
81static int max8649_is_enabled(struct regulator_dev *rdev)
82{
83 struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
84 unsigned int val;
85 int ret;
86
87 ret = regmap_read(info->regmap, MAX8649_CONTROL, &val);
88 if (ret != 0)
89 return ret;
90 return !((unsigned char)val & MAX8649_EN_PD);
91}
92
93static int max8649_enable_time(struct regulator_dev *rdev) 63static int max8649_enable_time(struct regulator_dev *rdev)
94{ 64{
95 struct max8649_regulator_info *info = rdev_get_drvdata(rdev); 65 struct max8649_regulator_info *info = rdev_get_drvdata(rdev);
@@ -151,9 +121,9 @@ static struct regulator_ops max8649_dcdc_ops = {
151 .get_voltage_sel = regulator_get_voltage_sel_regmap, 121 .get_voltage_sel = regulator_get_voltage_sel_regmap,
152 .list_voltage = regulator_list_voltage_linear, 122 .list_voltage = regulator_list_voltage_linear,
153 .map_voltage = regulator_map_voltage_linear, 123 .map_voltage = regulator_map_voltage_linear,
154 .enable = max8649_enable, 124 .enable = regulator_enable_regmap,
155 .disable = max8649_disable, 125 .disable = regulator_disable_regmap,
156 .is_enabled = max8649_is_enabled, 126 .is_enabled = regulator_is_enabled_regmap,
157 .enable_time = max8649_enable_time, 127 .enable_time = max8649_enable_time,
158 .set_mode = max8649_set_mode, 128 .set_mode = max8649_set_mode,
159 .get_mode = max8649_get_mode, 129 .get_mode = max8649_get_mode,
@@ -169,6 +139,9 @@ static struct regulator_desc dcdc_desc = {
169 .vsel_mask = MAX8649_VOL_MASK, 139 .vsel_mask = MAX8649_VOL_MASK,
170 .min_uV = MAX8649_DCDC_VMIN, 140 .min_uV = MAX8649_DCDC_VMIN,
171 .uV_step = MAX8649_DCDC_STEP, 141 .uV_step = MAX8649_DCDC_STEP,
142 .enable_reg = MAX8649_CONTROL,
143 .enable_mask = MAX8649_EN_PD,
144 .enable_is_inverted = true,
172}; 145};
173 146
174static struct regmap_config max8649_regmap_config = { 147static struct regmap_config max8649_regmap_config = {
@@ -275,10 +248,8 @@ static int max8649_regulator_remove(struct i2c_client *client)
275{ 248{
276 struct max8649_regulator_info *info = i2c_get_clientdata(client); 249 struct max8649_regulator_info *info = i2c_get_clientdata(client);
277 250
278 if (info) { 251 if (info)
279 if (info->regulator) 252 regulator_unregister(info->regulator);
280 regulator_unregister(info->regulator);
281 }
282 253
283 return 0; 254 return 0;
284} 255}
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
index 4d7c635c36c2..d428ef9a626f 100644
--- a/drivers/regulator/max8660.c
+++ b/drivers/regulator/max8660.c
@@ -426,8 +426,7 @@ static int max8660_remove(struct i2c_client *client)
426 int i; 426 int i;
427 427
428 for (i = 0; i < MAX8660_V_END; i++) 428 for (i = 0; i < MAX8660_V_END; i++)
429 if (max8660->rdev[i]) 429 regulator_unregister(max8660->rdev[i]);
430 regulator_unregister(max8660->rdev[i]);
431 return 0; 430 return 0;
432} 431}
433 432
diff --git a/drivers/regulator/max8925-regulator.c b/drivers/regulator/max8925-regulator.c
index 0d5f64a805a0..3597da8f0dca 100644
--- a/drivers/regulator/max8925-regulator.c
+++ b/drivers/regulator/max8925-regulator.c
@@ -246,7 +246,6 @@ static struct max8925_regulator_info max8925_regulator_info[] = {
246 246
247#ifdef CONFIG_OF 247#ifdef CONFIG_OF
248static int max8925_regulator_dt_init(struct platform_device *pdev, 248static int max8925_regulator_dt_init(struct platform_device *pdev,
249 struct max8925_regulator_info *info,
250 struct regulator_config *config, 249 struct regulator_config *config,
251 int ridx) 250 int ridx)
252{ 251{
@@ -272,7 +271,7 @@ static int max8925_regulator_dt_init(struct platform_device *pdev,
272 return 0; 271 return 0;
273} 272}
274#else 273#else
275#define max8925_regulator_dt_init(w, x, y, z) (-1) 274#define max8925_regulator_dt_init(x, y, z) (-1)
276#endif 275#endif
277 276
278static int max8925_regulator_probe(struct platform_device *pdev) 277static int max8925_regulator_probe(struct platform_device *pdev)
@@ -309,7 +308,7 @@ static int max8925_regulator_probe(struct platform_device *pdev)
309 config.dev = &pdev->dev; 308 config.dev = &pdev->dev;
310 config.driver_data = ri; 309 config.driver_data = ri;
311 310
312 if (max8925_regulator_dt_init(pdev, ri, &config, regulator_idx)) 311 if (max8925_regulator_dt_init(pdev, &config, regulator_idx))
313 if (pdata) 312 if (pdata)
314 config.init_data = pdata; 313 config.init_data = pdata;
315 314
diff --git a/drivers/regulator/max8952.c b/drivers/regulator/max8952.c
index fc7935a19e3a..5259c2fea90a 100644
--- a/drivers/regulator/max8952.c
+++ b/drivers/regulator/max8952.c
@@ -28,6 +28,9 @@
28#include <linux/regulator/max8952.h> 28#include <linux/regulator/max8952.h>
29#include <linux/gpio.h> 29#include <linux/gpio.h>
30#include <linux/io.h> 30#include <linux/io.h>
31#include <linux/of.h>
32#include <linux/of_gpio.h>
33#include <linux/regulator/of_regulator.h>
31#include <linux/slab.h> 34#include <linux/slab.h>
32 35
33/* Registers */ 36/* Registers */
@@ -126,6 +129,69 @@ static const struct regulator_desc regulator = {
126 .owner = THIS_MODULE, 129 .owner = THIS_MODULE,
127}; 130};
128 131
132#ifdef CONFIG_OF
133static struct of_device_id max8952_dt_match[] = {
134 { .compatible = "maxim,max8952" },
135 {},
136};
137MODULE_DEVICE_TABLE(of, max8952_dt_match);
138
139static struct max8952_platform_data *max8952_parse_dt(struct device *dev)
140{
141 struct max8952_platform_data *pd;
142 struct device_node *np = dev->of_node;
143 int ret;
144 int i;
145
146 pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
147 if (!pd) {
148 dev_err(dev, "Failed to allocate platform data\n");
149 return NULL;
150 }
151
152 pd->gpio_vid0 = of_get_named_gpio(np, "max8952,vid-gpios", 0);
153 pd->gpio_vid1 = of_get_named_gpio(np, "max8952,vid-gpios", 1);
154 pd->gpio_en = of_get_named_gpio(np, "max8952,en-gpio", 0);
155
156 if (of_property_read_u32(np, "max8952,default-mode", &pd->default_mode))
157 dev_warn(dev, "Default mode not specified, assuming 0\n");
158
159 ret = of_property_read_u32_array(np, "max8952,dvs-mode-microvolt",
160 pd->dvs_mode, ARRAY_SIZE(pd->dvs_mode));
161 if (ret) {
162 dev_err(dev, "max8952,dvs-mode-microvolt property not specified");
163 return NULL;
164 }
165
166 for (i = 0; i < ARRAY_SIZE(pd->dvs_mode); ++i) {
167 if (pd->dvs_mode[i] < 770000 || pd->dvs_mode[i] > 1400000) {
168 dev_err(dev, "DVS voltage %d out of range\n", i);
169 return NULL;
170 }
171 pd->dvs_mode[i] = (pd->dvs_mode[i] - 770000) / 10000;
172 }
173
174 if (of_property_read_u32(np, "max8952,sync-freq", &pd->sync_freq))
175 dev_warn(dev, "max8952,sync-freq property not specified, defaulting to 26MHz\n");
176
177 if (of_property_read_u32(np, "max8952,ramp-speed", &pd->ramp_speed))
178 dev_warn(dev, "max8952,ramp-speed property not specified, defaulting to 32mV/us\n");
179
180 pd->reg_data = of_get_regulator_init_data(dev, np);
181 if (!pd->reg_data) {
182 dev_err(dev, "Failed to parse regulator init data\n");
183 return NULL;
184 }
185
186 return pd;
187}
188#else
189static struct max8952_platform_data *max8952_parse_dt(struct device *dev)
190{
191 return NULL;
192}
193#endif
194
129static int max8952_pmic_probe(struct i2c_client *client, 195static int max8952_pmic_probe(struct i2c_client *client,
130 const struct i2c_device_id *i2c_id) 196 const struct i2c_device_id *i2c_id)
131{ 197{
@@ -136,6 +202,9 @@ static int max8952_pmic_probe(struct i2c_client *client,
136 202
137 int ret = 0, err = 0; 203 int ret = 0, err = 0;
138 204
205 if (client->dev.of_node)
206 pdata = max8952_parse_dt(&client->dev);
207
139 if (!pdata) { 208 if (!pdata) {
140 dev_err(&client->dev, "Require the platform data\n"); 209 dev_err(&client->dev, "Require the platform data\n");
141 return -EINVAL; 210 return -EINVAL;
@@ -154,11 +223,12 @@ static int max8952_pmic_probe(struct i2c_client *client,
154 max8952->pdata = pdata; 223 max8952->pdata = pdata;
155 224
156 config.dev = max8952->dev; 225 config.dev = max8952->dev;
157 config.init_data = &pdata->reg_data; 226 config.init_data = pdata->reg_data;
158 config.driver_data = max8952; 227 config.driver_data = max8952;
228 config.of_node = client->dev.of_node;
159 229
160 config.ena_gpio = pdata->gpio_en; 230 config.ena_gpio = pdata->gpio_en;
161 if (pdata->reg_data.constraints.boot_on) 231 if (pdata->reg_data->constraints.boot_on)
162 config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH; 232 config.ena_gpio_flags |= GPIOF_OUT_INIT_HIGH;
163 233
164 max8952->rdev = regulator_register(&regulator, &config); 234 max8952->rdev = regulator_register(&regulator, &config);
@@ -271,6 +341,7 @@ static struct i2c_driver max8952_pmic_driver = {
271 .remove = max8952_pmic_remove, 341 .remove = max8952_pmic_remove,
272 .driver = { 342 .driver = {
273 .name = "max8952", 343 .name = "max8952",
344 .of_match_table = of_match_ptr(max8952_dt_match),
274 }, 345 },
275 .id_table = max8952_ids, 346 .id_table = max8952_ids,
276}; 347};
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
index 9a8ea9163005..adb1414e5e37 100644
--- a/drivers/regulator/max8973-regulator.c
+++ b/drivers/regulator/max8973-regulator.c
@@ -274,15 +274,15 @@ static int max8973_init_dcdc(struct max8973_chip *max,
274 if (pdata->reg_init_data && 274 if (pdata->reg_init_data &&
275 pdata->reg_init_data->constraints.ramp_delay) { 275 pdata->reg_init_data->constraints.ramp_delay) {
276 if (pdata->reg_init_data->constraints.ramp_delay < 25000) 276 if (pdata->reg_init_data->constraints.ramp_delay < 25000)
277 control1 = MAX8973_RAMP_12mV_PER_US; 277 control1 |= MAX8973_RAMP_12mV_PER_US;
278 else if (pdata->reg_init_data->constraints.ramp_delay < 50000) 278 else if (pdata->reg_init_data->constraints.ramp_delay < 50000)
279 control1 = MAX8973_RAMP_25mV_PER_US; 279 control1 |= MAX8973_RAMP_25mV_PER_US;
280 else if (pdata->reg_init_data->constraints.ramp_delay < 200000) 280 else if (pdata->reg_init_data->constraints.ramp_delay < 200000)
281 control1 = MAX8973_RAMP_50mV_PER_US; 281 control1 |= MAX8973_RAMP_50mV_PER_US;
282 else 282 else
283 control1 = MAX8973_RAMP_200mV_PER_US; 283 control1 |= MAX8973_RAMP_200mV_PER_US;
284 } else { 284 } else {
285 control1 = MAX8973_RAMP_12mV_PER_US; 285 control1 |= MAX8973_RAMP_12mV_PER_US;
286 max->desc.ramp_delay = 12500; 286 max->desc.ramp_delay = 12500;
287 } 287 }
288 288
diff --git a/drivers/regulator/max8997.c b/drivers/regulator/max8997.c
index 0ac7a87519b4..df20069f0537 100644
--- a/drivers/regulator/max8997.c
+++ b/drivers/regulator/max8997.c
@@ -1035,8 +1035,8 @@ static int max8997_pmic_probe(struct platform_device *pdev)
1035 int i, ret, size, nr_dvs; 1035 int i, ret, size, nr_dvs;
1036 u8 max_buck1 = 0, max_buck2 = 0, max_buck5 = 0; 1036 u8 max_buck1 = 0, max_buck2 = 0, max_buck5 = 0;
1037 1037
1038 if (IS_ERR_OR_NULL(pdata)) { 1038 if (!pdata) {
1039 dev_err(pdev->dev.parent, "No platform init data supplied.\n"); 1039 dev_err(&pdev->dev, "No platform init data supplied.\n");
1040 return -ENODEV; 1040 return -ENODEV;
1041 } 1041 }
1042 1042
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c
index b588f07c7cad..a57a1b15cdba 100644
--- a/drivers/regulator/max8998.c
+++ b/drivers/regulator/max8998.c
@@ -665,14 +665,16 @@ static int max8998_pmic_probe(struct platform_device *pdev)
665 gpio_is_valid(pdata->buck1_set2)) { 665 gpio_is_valid(pdata->buck1_set2)) {
666 /* Check if SET1 is not equal to 0 */ 666 /* Check if SET1 is not equal to 0 */
667 if (!pdata->buck1_set1) { 667 if (!pdata->buck1_set1) {
668 printk(KERN_ERR "MAX8998 SET1 GPIO defined as 0 !\n"); 668 dev_err(&pdev->dev,
669 "MAX8998 SET1 GPIO defined as 0 !\n");
669 WARN_ON(!pdata->buck1_set1); 670 WARN_ON(!pdata->buck1_set1);
670 ret = -EIO; 671 ret = -EIO;
671 goto err_out; 672 goto err_out;
672 } 673 }
673 /* Check if SET2 is not equal to 0 */ 674 /* Check if SET2 is not equal to 0 */
674 if (!pdata->buck1_set2) { 675 if (!pdata->buck1_set2) {
675 printk(KERN_ERR "MAX8998 SET2 GPIO defined as 0 !\n"); 676 dev_err(&pdev->dev,
677 "MAX8998 SET2 GPIO defined as 0 !\n");
676 WARN_ON(!pdata->buck1_set2); 678 WARN_ON(!pdata->buck1_set2);
677 ret = -EIO; 679 ret = -EIO;
678 goto err_out; 680 goto err_out;
@@ -738,7 +740,8 @@ static int max8998_pmic_probe(struct platform_device *pdev)
738 if (gpio_is_valid(pdata->buck2_set3)) { 740 if (gpio_is_valid(pdata->buck2_set3)) {
739 /* Check if SET3 is not equal to 0 */ 741 /* Check if SET3 is not equal to 0 */
740 if (!pdata->buck2_set3) { 742 if (!pdata->buck2_set3) {
741 printk(KERN_ERR "MAX8998 SET3 GPIO defined as 0 !\n"); 743 dev_err(&pdev->dev,
744 "MAX8998 SET3 GPIO defined as 0 !\n");
742 WARN_ON(!pdata->buck2_set3); 745 WARN_ON(!pdata->buck2_set3);
743 ret = -EIO; 746 ret = -EIO;
744 goto err_out; 747 goto err_out;
diff --git a/drivers/regulator/mc13783-regulator.c b/drivers/regulator/mc13783-regulator.c
index c46c6705cd74..fdf7f0a09090 100644
--- a/drivers/regulator/mc13783-regulator.c
+++ b/drivers/regulator/mc13783-regulator.c
@@ -398,33 +398,51 @@ static int mc13783_regulator_probe(struct platform_device *pdev)
398 struct mc13xxx *mc13783 = dev_get_drvdata(pdev->dev.parent); 398 struct mc13xxx *mc13783 = dev_get_drvdata(pdev->dev.parent);
399 struct mc13xxx_regulator_platform_data *pdata = 399 struct mc13xxx_regulator_platform_data *pdata =
400 dev_get_platdata(&pdev->dev); 400 dev_get_platdata(&pdev->dev);
401 struct mc13xxx_regulator_init_data *init_data; 401 struct mc13xxx_regulator_init_data *mc13xxx_data;
402 struct regulator_config config = { }; 402 struct regulator_config config = { };
403 int i, ret; 403 int i, ret, num_regulators;
404 404
405 dev_dbg(&pdev->dev, "%s id %d\n", __func__, pdev->id); 405 num_regulators = mc13xxx_get_num_regulators_dt(pdev);
406 406
407 if (!pdata) 407 if (num_regulators <= 0 && pdata)
408 num_regulators = pdata->num_regulators;
409 if (num_regulators <= 0)
408 return -EINVAL; 410 return -EINVAL;
409 411
410 priv = devm_kzalloc(&pdev->dev, sizeof(*priv) + 412 priv = devm_kzalloc(&pdev->dev, sizeof(*priv) +
411 pdata->num_regulators * sizeof(priv->regulators[0]), 413 num_regulators * sizeof(priv->regulators[0]),
412 GFP_KERNEL); 414 GFP_KERNEL);
413 if (!priv) 415 if (!priv)
414 return -ENOMEM; 416 return -ENOMEM;
415 417
418 priv->num_regulators = num_regulators;
416 priv->mc13xxx_regulators = mc13783_regulators; 419 priv->mc13xxx_regulators = mc13783_regulators;
417 priv->mc13xxx = mc13783; 420 priv->mc13xxx = mc13783;
421 platform_set_drvdata(pdev, priv);
418 422
419 for (i = 0; i < pdata->num_regulators; i++) { 423 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13783_regulators,
420 struct regulator_desc *desc; 424 ARRAY_SIZE(mc13783_regulators));
421 425
422 init_data = &pdata->regulators[i]; 426 for (i = 0; i < priv->num_regulators; i++) {
423 desc = &mc13783_regulators[init_data->id].desc; 427 struct regulator_init_data *init_data;
428 struct regulator_desc *desc;
429 struct device_node *node = NULL;
430 int id;
431
432 if (mc13xxx_data) {
433 id = mc13xxx_data[i].id;
434 init_data = mc13xxx_data[i].init_data;
435 node = mc13xxx_data[i].node;
436 } else {
437 id = pdata->regulators[i].id;
438 init_data = pdata->regulators[i].init_data;
439 }
440 desc = &mc13783_regulators[id].desc;
424 441
425 config.dev = &pdev->dev; 442 config.dev = &pdev->dev;
426 config.init_data = init_data->init_data; 443 config.init_data = init_data;
427 config.driver_data = priv; 444 config.driver_data = priv;
445 config.of_node = node;
428 446
429 priv->regulators[i] = regulator_register(desc, &config); 447 priv->regulators[i] = regulator_register(desc, &config);
430 if (IS_ERR(priv->regulators[i])) { 448 if (IS_ERR(priv->regulators[i])) {
@@ -435,8 +453,6 @@ static int mc13783_regulator_probe(struct platform_device *pdev)
435 } 453 }
436 } 454 }
437 455
438 platform_set_drvdata(pdev, priv);
439
440 return 0; 456 return 0;
441err: 457err:
442 while (--i >= 0) 458 while (--i >= 0)
@@ -448,13 +464,11 @@ err:
448static int mc13783_regulator_remove(struct platform_device *pdev) 464static int mc13783_regulator_remove(struct platform_device *pdev)
449{ 465{
450 struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); 466 struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev);
451 struct mc13xxx_regulator_platform_data *pdata =
452 dev_get_platdata(&pdev->dev);
453 int i; 467 int i;
454 468
455 platform_set_drvdata(pdev, NULL); 469 platform_set_drvdata(pdev, NULL);
456 470
457 for (i = 0; i < pdata->num_regulators; i++) 471 for (i = 0; i < priv->num_regulators; i++)
458 regulator_unregister(priv->regulators[i]); 472 regulator_unregister(priv->regulators[i]);
459 473
460 return 0; 474 return 0;
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
index 9891aec47b57..b716283a8760 100644
--- a/drivers/regulator/mc13892-regulator.c
+++ b/drivers/regulator/mc13892-regulator.c
@@ -465,13 +465,13 @@ static int mc13892_sw_regulator_set_voltage_sel(struct regulator_dev *rdev,
465 */ 465 */
466 466
467 if (mc13892_regulators[id].vsel_reg != MC13892_SWITCHERS0) { 467 if (mc13892_regulators[id].vsel_reg != MC13892_SWITCHERS0) {
468 mask |= MC13892_SWITCHERS0_SWxHI;
469
468 if (volt > 1375000) { 470 if (volt > 1375000) {
469 reg_value -= MC13892_SWxHI_SEL_OFFSET; 471 reg_value -= MC13892_SWxHI_SEL_OFFSET;
470 reg_value |= MC13892_SWITCHERS0_SWxHI; 472 reg_value |= MC13892_SWITCHERS0_SWxHI;
471 mask |= MC13892_SWITCHERS0_SWxHI; 473 } else {
472 } else if (volt < 1100000) {
473 reg_value &= ~MC13892_SWITCHERS0_SWxHI; 474 reg_value &= ~MC13892_SWITCHERS0_SWxHI;
474 mask |= MC13892_SWITCHERS0_SWxHI;
475 } 475 }
476 } 476 }
477 477
@@ -485,6 +485,7 @@ static int mc13892_sw_regulator_set_voltage_sel(struct regulator_dev *rdev,
485 485
486static struct regulator_ops mc13892_sw_regulator_ops = { 486static struct regulator_ops mc13892_sw_regulator_ops = {
487 .list_voltage = regulator_list_voltage_table, 487 .list_voltage = regulator_list_voltage_table,
488 .map_voltage = regulator_map_voltage_ascend,
488 .set_voltage_sel = mc13892_sw_regulator_set_voltage_sel, 489 .set_voltage_sel = mc13892_sw_regulator_set_voltage_sel,
489 .get_voltage_sel = mc13892_sw_regulator_get_voltage_sel, 490 .get_voltage_sel = mc13892_sw_regulator_get_voltage_sel,
490}; 491};
@@ -535,7 +536,7 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
535 struct mc13xxx_regulator_init_data *mc13xxx_data; 536 struct mc13xxx_regulator_init_data *mc13xxx_data;
536 struct regulator_config config = { }; 537 struct regulator_config config = { };
537 int i, ret; 538 int i, ret;
538 int num_regulators = 0, num_parsed; 539 int num_regulators = 0;
539 u32 val; 540 u32 val;
540 541
541 num_regulators = mc13xxx_get_num_regulators_dt(pdev); 542 num_regulators = mc13xxx_get_num_regulators_dt(pdev);
@@ -545,8 +546,6 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
545 if (num_regulators <= 0) 546 if (num_regulators <= 0)
546 return -EINVAL; 547 return -EINVAL;
547 548
548 num_parsed = num_regulators;
549
550 priv = devm_kzalloc(&pdev->dev, sizeof(*priv) + 549 priv = devm_kzalloc(&pdev->dev, sizeof(*priv) +
551 num_regulators * sizeof(priv->regulators[0]), 550 num_regulators * sizeof(priv->regulators[0]),
552 GFP_KERNEL); 551 GFP_KERNEL);
@@ -589,40 +588,9 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
589 = mc13892_vcam_get_mode; 588 = mc13892_vcam_get_mode;
590 589
591 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators, 590 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
592 ARRAY_SIZE(mc13892_regulators), 591 ARRAY_SIZE(mc13892_regulators));
593 &num_parsed);
594
595 /*
596 * Perform a little sanity check on the regulator tree - if we found
597 * a number of regulators from mc13xxx_get_num_regulators_dt and
598 * then parsed a smaller number in mc13xxx_parse_regulators_dt then
599 * there is a regulator defined in the regulators node which has
600 * not matched any usable regulator in the driver. In this case,
601 * there is one missing and what will happen is the first regulator
602 * will get registered again.
603 *
604 * Fix this by basically making our number of registerable regulators
605 * equal to the number of regulators we parsed. We are allocating
606 * too much memory for priv, but this is unavoidable at this point.
607 *
608 * As an example of how this can happen, try making a typo in your
609 * regulators node (vviohi {} instead of viohi {}) so that the name
610 * does not match..
611 *
612 * The check will basically pass for platform data (non-DT) because
613 * mc13xxx_parse_regulators_dt for !CONFIG_OF will not touch num_parsed.
614 *
615 */
616 if (num_parsed != num_regulators) {
617 dev_warn(&pdev->dev,
618 "parsed %d != regulators %d - check your device tree!\n",
619 num_parsed, num_regulators);
620
621 num_regulators = num_parsed;
622 priv->num_regulators = num_regulators;
623 }
624 592
625 for (i = 0; i < num_regulators; i++) { 593 for (i = 0; i < priv->num_regulators; i++) {
626 struct regulator_init_data *init_data; 594 struct regulator_init_data *init_data;
627 struct regulator_desc *desc; 595 struct regulator_desc *desc;
628 struct device_node *node = NULL; 596 struct device_node *node = NULL;
diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c
index 23cf9f9c383b..da4859282302 100644
--- a/drivers/regulator/mc13xxx-regulator-core.c
+++ b/drivers/regulator/mc13xxx-regulator-core.c
@@ -180,15 +180,13 @@ EXPORT_SYMBOL_GPL(mc13xxx_get_num_regulators_dt);
180 180
181struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( 181struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
182 struct platform_device *pdev, struct mc13xxx_regulator *regulators, 182 struct platform_device *pdev, struct mc13xxx_regulator *regulators,
183 int num_regulators, int *num_parsed) 183 int num_regulators)
184{ 184{
185 struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev); 185 struct mc13xxx_regulator_priv *priv = platform_get_drvdata(pdev);
186 struct mc13xxx_regulator_init_data *data, *p; 186 struct mc13xxx_regulator_init_data *data, *p;
187 struct device_node *parent, *child; 187 struct device_node *parent, *child;
188 int i, parsed = 0; 188 int i, parsed = 0;
189 189
190 *num_parsed = 0;
191
192 of_node_get(pdev->dev.parent->of_node); 190 of_node_get(pdev->dev.parent->of_node);
193 parent = of_find_node_by_name(pdev->dev.parent->of_node, "regulators"); 191 parent = of_find_node_by_name(pdev->dev.parent->of_node, "regulators");
194 if (!parent) 192 if (!parent)
@@ -204,10 +202,13 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
204 p = data; 202 p = data;
205 203
206 for_each_child_of_node(parent, child) { 204 for_each_child_of_node(parent, child) {
205 int found = 0;
206
207 for (i = 0; i < num_regulators; i++) { 207 for (i = 0; i < num_regulators; i++) {
208 if (!regulators[i].desc.name)
209 continue;
208 if (!of_node_cmp(child->name, 210 if (!of_node_cmp(child->name,
209 regulators[i].desc.name)) { 211 regulators[i].desc.name)) {
210
211 p->id = i; 212 p->id = i;
212 p->init_data = of_get_regulator_init_data( 213 p->init_data = of_get_regulator_init_data(
213 &pdev->dev, child); 214 &pdev->dev, child);
@@ -215,13 +216,19 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
215 p++; 216 p++;
216 217
217 parsed++; 218 parsed++;
219 found = 1;
218 break; 220 break;
219 } 221 }
220 } 222 }
223
224 if (!found)
225 dev_warn(&pdev->dev,
226 "Unknown regulator: %s\n", child->name);
221 } 227 }
222 of_node_put(parent); 228 of_node_put(parent);
223 229
224 *num_parsed = parsed; 230 priv->num_regulators = parsed;
231
225 return data; 232 return data;
226} 233}
227EXPORT_SYMBOL_GPL(mc13xxx_parse_regulators_dt); 234EXPORT_SYMBOL_GPL(mc13xxx_parse_regulators_dt);
diff --git a/drivers/regulator/mc13xxx.h b/drivers/regulator/mc13xxx.h
index 007f83387fd6..06c8903f182a 100644
--- a/drivers/regulator/mc13xxx.h
+++ b/drivers/regulator/mc13xxx.h
@@ -39,7 +39,7 @@ extern int mc13xxx_fixed_regulator_set_voltage(struct regulator_dev *rdev,
39extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev); 39extern int mc13xxx_get_num_regulators_dt(struct platform_device *pdev);
40extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( 40extern struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
41 struct platform_device *pdev, struct mc13xxx_regulator *regulators, 41 struct platform_device *pdev, struct mc13xxx_regulator *regulators,
42 int num_regulators, int *num_parsed); 42 int num_regulators);
43#else 43#else
44static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev) 44static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
45{ 45{
@@ -48,7 +48,7 @@ static inline int mc13xxx_get_num_regulators_dt(struct platform_device *pdev)
48 48
49static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( 49static inline struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
50 struct platform_device *pdev, struct mc13xxx_regulator *regulators, 50 struct platform_device *pdev, struct mc13xxx_regulator *regulators,
51 int num_regulators, int *num_parsed) 51 int num_regulators)
52{ 52{
53 return NULL; 53 return NULL;
54} 54}
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 39cf14606784..92ceed0fc65e 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for Regulator part of Palmas PMIC Chips 2 * Driver for Regulator part of Palmas PMIC Chips
3 * 3 *
4 * Copyright 2011-2012 Texas Instruments Inc. 4 * Copyright 2011-2013 Texas Instruments Inc.
5 * 5 *
6 * Author: Graeme Gregory <gg@slimlogic.co.uk> 6 * Author: Graeme Gregory <gg@slimlogic.co.uk>
7 * Author: Ian Lartey <ian@slimlogic.co.uk> 7 * Author: Ian Lartey <ian@slimlogic.co.uk>
@@ -29,6 +29,7 @@
29 29
30struct regs_info { 30struct regs_info {
31 char *name; 31 char *name;
32 char *sname;
32 u8 vsel_addr; 33 u8 vsel_addr;
33 u8 ctrl_addr; 34 u8 ctrl_addr;
34 u8 tstep_addr; 35 u8 tstep_addr;
@@ -37,115 +38,159 @@ struct regs_info {
37static const struct regs_info palmas_regs_info[] = { 38static const struct regs_info palmas_regs_info[] = {
38 { 39 {
39 .name = "SMPS12", 40 .name = "SMPS12",
41 .sname = "smps1-in",
40 .vsel_addr = PALMAS_SMPS12_VOLTAGE, 42 .vsel_addr = PALMAS_SMPS12_VOLTAGE,
41 .ctrl_addr = PALMAS_SMPS12_CTRL, 43 .ctrl_addr = PALMAS_SMPS12_CTRL,
42 .tstep_addr = PALMAS_SMPS12_TSTEP, 44 .tstep_addr = PALMAS_SMPS12_TSTEP,
43 }, 45 },
44 { 46 {
45 .name = "SMPS123", 47 .name = "SMPS123",
48 .sname = "smps1-in",
46 .vsel_addr = PALMAS_SMPS12_VOLTAGE, 49 .vsel_addr = PALMAS_SMPS12_VOLTAGE,
47 .ctrl_addr = PALMAS_SMPS12_CTRL, 50 .ctrl_addr = PALMAS_SMPS12_CTRL,
48 .tstep_addr = PALMAS_SMPS12_TSTEP, 51 .tstep_addr = PALMAS_SMPS12_TSTEP,
49 }, 52 },
50 { 53 {
51 .name = "SMPS3", 54 .name = "SMPS3",
55 .sname = "smps3-in",
52 .vsel_addr = PALMAS_SMPS3_VOLTAGE, 56 .vsel_addr = PALMAS_SMPS3_VOLTAGE,
53 .ctrl_addr = PALMAS_SMPS3_CTRL, 57 .ctrl_addr = PALMAS_SMPS3_CTRL,
54 }, 58 },
55 { 59 {
56 .name = "SMPS45", 60 .name = "SMPS45",
61 .sname = "smps4-in",
57 .vsel_addr = PALMAS_SMPS45_VOLTAGE, 62 .vsel_addr = PALMAS_SMPS45_VOLTAGE,
58 .ctrl_addr = PALMAS_SMPS45_CTRL, 63 .ctrl_addr = PALMAS_SMPS45_CTRL,
59 .tstep_addr = PALMAS_SMPS45_TSTEP, 64 .tstep_addr = PALMAS_SMPS45_TSTEP,
60 }, 65 },
61 { 66 {
62 .name = "SMPS457", 67 .name = "SMPS457",
68 .sname = "smps4-in",
63 .vsel_addr = PALMAS_SMPS45_VOLTAGE, 69 .vsel_addr = PALMAS_SMPS45_VOLTAGE,
64 .ctrl_addr = PALMAS_SMPS45_CTRL, 70 .ctrl_addr = PALMAS_SMPS45_CTRL,
65 .tstep_addr = PALMAS_SMPS45_TSTEP, 71 .tstep_addr = PALMAS_SMPS45_TSTEP,
66 }, 72 },
67 { 73 {
68 .name = "SMPS6", 74 .name = "SMPS6",
75 .sname = "smps6-in",
69 .vsel_addr = PALMAS_SMPS6_VOLTAGE, 76 .vsel_addr = PALMAS_SMPS6_VOLTAGE,
70 .ctrl_addr = PALMAS_SMPS6_CTRL, 77 .ctrl_addr = PALMAS_SMPS6_CTRL,
71 .tstep_addr = PALMAS_SMPS6_TSTEP, 78 .tstep_addr = PALMAS_SMPS6_TSTEP,
72 }, 79 },
73 { 80 {
74 .name = "SMPS7", 81 .name = "SMPS7",
82 .sname = "smps7-in",
75 .vsel_addr = PALMAS_SMPS7_VOLTAGE, 83 .vsel_addr = PALMAS_SMPS7_VOLTAGE,
76 .ctrl_addr = PALMAS_SMPS7_CTRL, 84 .ctrl_addr = PALMAS_SMPS7_CTRL,
77 }, 85 },
78 { 86 {
79 .name = "SMPS8", 87 .name = "SMPS8",
88 .sname = "smps8-in",
80 .vsel_addr = PALMAS_SMPS8_VOLTAGE, 89 .vsel_addr = PALMAS_SMPS8_VOLTAGE,
81 .ctrl_addr = PALMAS_SMPS8_CTRL, 90 .ctrl_addr = PALMAS_SMPS8_CTRL,
82 .tstep_addr = PALMAS_SMPS8_TSTEP, 91 .tstep_addr = PALMAS_SMPS8_TSTEP,
83 }, 92 },
84 { 93 {
85 .name = "SMPS9", 94 .name = "SMPS9",
95 .sname = "smps9-in",
86 .vsel_addr = PALMAS_SMPS9_VOLTAGE, 96 .vsel_addr = PALMAS_SMPS9_VOLTAGE,
87 .ctrl_addr = PALMAS_SMPS9_CTRL, 97 .ctrl_addr = PALMAS_SMPS9_CTRL,
88 }, 98 },
89 { 99 {
90 .name = "SMPS10", 100 .name = "SMPS10",
101 .sname = "smps10-in",
102 .ctrl_addr = PALMAS_SMPS10_CTRL,
91 }, 103 },
92 { 104 {
93 .name = "LDO1", 105 .name = "LDO1",
106 .sname = "ldo1-in",
94 .vsel_addr = PALMAS_LDO1_VOLTAGE, 107 .vsel_addr = PALMAS_LDO1_VOLTAGE,
95 .ctrl_addr = PALMAS_LDO1_CTRL, 108 .ctrl_addr = PALMAS_LDO1_CTRL,
96 }, 109 },
97 { 110 {
98 .name = "LDO2", 111 .name = "LDO2",
112 .sname = "ldo2-in",
99 .vsel_addr = PALMAS_LDO2_VOLTAGE, 113 .vsel_addr = PALMAS_LDO2_VOLTAGE,
100 .ctrl_addr = PALMAS_LDO2_CTRL, 114 .ctrl_addr = PALMAS_LDO2_CTRL,
101 }, 115 },
102 { 116 {
103 .name = "LDO3", 117 .name = "LDO3",
118 .sname = "ldo3-in",
104 .vsel_addr = PALMAS_LDO3_VOLTAGE, 119 .vsel_addr = PALMAS_LDO3_VOLTAGE,
105 .ctrl_addr = PALMAS_LDO3_CTRL, 120 .ctrl_addr = PALMAS_LDO3_CTRL,
106 }, 121 },
107 { 122 {
108 .name = "LDO4", 123 .name = "LDO4",
124 .sname = "ldo4-in",
109 .vsel_addr = PALMAS_LDO4_VOLTAGE, 125 .vsel_addr = PALMAS_LDO4_VOLTAGE,
110 .ctrl_addr = PALMAS_LDO4_CTRL, 126 .ctrl_addr = PALMAS_LDO4_CTRL,
111 }, 127 },
112 { 128 {
113 .name = "LDO5", 129 .name = "LDO5",
130 .sname = "ldo5-in",
114 .vsel_addr = PALMAS_LDO5_VOLTAGE, 131 .vsel_addr = PALMAS_LDO5_VOLTAGE,
115 .ctrl_addr = PALMAS_LDO5_CTRL, 132 .ctrl_addr = PALMAS_LDO5_CTRL,
116 }, 133 },
117 { 134 {
118 .name = "LDO6", 135 .name = "LDO6",
136 .sname = "ldo6-in",
119 .vsel_addr = PALMAS_LDO6_VOLTAGE, 137 .vsel_addr = PALMAS_LDO6_VOLTAGE,
120 .ctrl_addr = PALMAS_LDO6_CTRL, 138 .ctrl_addr = PALMAS_LDO6_CTRL,
121 }, 139 },
122 { 140 {
123 .name = "LDO7", 141 .name = "LDO7",
142 .sname = "ldo7-in",
124 .vsel_addr = PALMAS_LDO7_VOLTAGE, 143 .vsel_addr = PALMAS_LDO7_VOLTAGE,
125 .ctrl_addr = PALMAS_LDO7_CTRL, 144 .ctrl_addr = PALMAS_LDO7_CTRL,
126 }, 145 },
127 { 146 {
128 .name = "LDO8", 147 .name = "LDO8",
148 .sname = "ldo8-in",
129 .vsel_addr = PALMAS_LDO8_VOLTAGE, 149 .vsel_addr = PALMAS_LDO8_VOLTAGE,
130 .ctrl_addr = PALMAS_LDO8_CTRL, 150 .ctrl_addr = PALMAS_LDO8_CTRL,
131 }, 151 },
132 { 152 {
133 .name = "LDO9", 153 .name = "LDO9",
154 .sname = "ldo9-in",
134 .vsel_addr = PALMAS_LDO9_VOLTAGE, 155 .vsel_addr = PALMAS_LDO9_VOLTAGE,
135 .ctrl_addr = PALMAS_LDO9_CTRL, 156 .ctrl_addr = PALMAS_LDO9_CTRL,
136 }, 157 },
137 { 158 {
138 .name = "LDOLN", 159 .name = "LDOLN",
160 .sname = "ldoln-in",
139 .vsel_addr = PALMAS_LDOLN_VOLTAGE, 161 .vsel_addr = PALMAS_LDOLN_VOLTAGE,
140 .ctrl_addr = PALMAS_LDOLN_CTRL, 162 .ctrl_addr = PALMAS_LDOLN_CTRL,
141 }, 163 },
142 { 164 {
143 .name = "LDOUSB", 165 .name = "LDOUSB",
166 .sname = "ldousb-in",
144 .vsel_addr = PALMAS_LDOUSB_VOLTAGE, 167 .vsel_addr = PALMAS_LDOUSB_VOLTAGE,
145 .ctrl_addr = PALMAS_LDOUSB_CTRL, 168 .ctrl_addr = PALMAS_LDOUSB_CTRL,
146 }, 169 },
170 {
171 .name = "REGEN1",
172 .ctrl_addr = PALMAS_REGEN1_CTRL,
173 },
174 {
175 .name = "REGEN2",
176 .ctrl_addr = PALMAS_REGEN2_CTRL,
177 },
178 {
179 .name = "REGEN3",
180 .ctrl_addr = PALMAS_REGEN3_CTRL,
181 },
182 {
183 .name = "SYSEN1",
184 .ctrl_addr = PALMAS_SYSEN1_CTRL,
185 },
186 {
187 .name = "SYSEN2",
188 .ctrl_addr = PALMAS_SYSEN2_CTRL,
189 },
147}; 190};
148 191
192static unsigned int palmas_smps_ramp_delay[4] = {0, 10000, 5000, 2500};
193
149#define SMPS_CTRL_MODE_OFF 0x00 194#define SMPS_CTRL_MODE_OFF 0x00
150#define SMPS_CTRL_MODE_ON 0x01 195#define SMPS_CTRL_MODE_ON 0x01
151#define SMPS_CTRL_MODE_ECO 0x02 196#define SMPS_CTRL_MODE_ECO 0x02
@@ -231,7 +276,10 @@ static int palmas_enable_smps(struct regulator_dev *dev)
231 palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg); 276 palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg);
232 277
233 reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; 278 reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
234 reg |= SMPS_CTRL_MODE_ON; 279 if (pmic->current_reg_mode[id])
280 reg |= pmic->current_reg_mode[id];
281 else
282 reg |= SMPS_CTRL_MODE_ON;
235 283
236 palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg); 284 palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg);
237 285
@@ -253,16 +301,19 @@ static int palmas_disable_smps(struct regulator_dev *dev)
253 return 0; 301 return 0;
254} 302}
255 303
256
257static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode) 304static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode)
258{ 305{
259 struct palmas_pmic *pmic = rdev_get_drvdata(dev); 306 struct palmas_pmic *pmic = rdev_get_drvdata(dev);
260 int id = rdev_get_id(dev); 307 int id = rdev_get_id(dev);
261 unsigned int reg; 308 unsigned int reg;
309 bool rail_enable = true;
262 310
263 palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg); 311 palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg);
264 reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK; 312 reg &= ~PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
265 313
314 if (reg == SMPS_CTRL_MODE_OFF)
315 rail_enable = false;
316
266 switch (mode) { 317 switch (mode) {
267 case REGULATOR_MODE_NORMAL: 318 case REGULATOR_MODE_NORMAL:
268 reg |= SMPS_CTRL_MODE_ON; 319 reg |= SMPS_CTRL_MODE_ON;
@@ -276,8 +327,11 @@ static int palmas_set_mode_smps(struct regulator_dev *dev, unsigned int mode)
276 default: 327 default:
277 return -EINVAL; 328 return -EINVAL;
278 } 329 }
279 palmas_smps_write(pmic->palmas, palmas_regs_info[id].ctrl_addr, reg);
280 330
331 pmic->current_reg_mode[id] = reg & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
332 if (rail_enable)
333 palmas_smps_write(pmic->palmas,
334 palmas_regs_info[id].ctrl_addr, reg);
281 return 0; 335 return 0;
282} 336}
283 337
@@ -287,9 +341,7 @@ static unsigned int palmas_get_mode_smps(struct regulator_dev *dev)
287 int id = rdev_get_id(dev); 341 int id = rdev_get_id(dev);
288 unsigned int reg; 342 unsigned int reg;
289 343
290 palmas_smps_read(pmic->palmas, palmas_regs_info[id].ctrl_addr, &reg); 344 reg = pmic->current_reg_mode[id] & PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
291 reg &= PALMAS_SMPS12_CTRL_STATUS_MASK;
292 reg >>= PALMAS_SMPS12_CTRL_STATUS_SHIFT;
293 345
294 switch (reg) { 346 switch (reg) {
295 case SMPS_CTRL_MODE_ON: 347 case SMPS_CTRL_MODE_ON:
@@ -356,6 +408,63 @@ static int palmas_map_voltage_smps(struct regulator_dev *rdev,
356 return ret; 408 return ret;
357} 409}
358 410
411static int palma_smps_set_voltage_smps_time_sel(struct regulator_dev *rdev,
412 unsigned int old_selector, unsigned int new_selector)
413{
414 struct palmas_pmic *pmic = rdev_get_drvdata(rdev);
415 int id = rdev_get_id(rdev);
416 int old_uv, new_uv;
417 unsigned int ramp_delay = pmic->ramp_delay[id];
418
419 if (!ramp_delay)
420 return 0;
421
422 old_uv = palmas_list_voltage_smps(rdev, old_selector);
423 if (old_uv < 0)
424 return old_uv;
425
426 new_uv = palmas_list_voltage_smps(rdev, new_selector);
427 if (new_uv < 0)
428 return new_uv;
429
430 return DIV_ROUND_UP(abs(old_uv - new_uv), ramp_delay);
431}
432
433static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,
434 int ramp_delay)
435{
436 struct palmas_pmic *pmic = rdev_get_drvdata(rdev);
437 int id = rdev_get_id(rdev);
438 unsigned int reg = 0;
439 unsigned int addr = palmas_regs_info[id].tstep_addr;
440 int ret;
441
442 /* SMPS3 and SMPS7 do not have tstep_addr setting */
443 switch (id) {
444 case PALMAS_REG_SMPS3:
445 case PALMAS_REG_SMPS7:
446 return 0;
447 }
448
449 if (ramp_delay <= 0)
450 reg = 0;
451 else if (ramp_delay <= 2500)
452 reg = 3;
453 else if (ramp_delay <= 5000)
454 reg = 2;
455 else
456 reg = 1;
457
458 ret = palmas_smps_write(pmic->palmas, addr, reg);
459 if (ret < 0) {
460 dev_err(pmic->palmas->dev, "TSTEP write failed: %d\n", ret);
461 return ret;
462 }
463
464 pmic->ramp_delay[id] = palmas_smps_ramp_delay[reg];
465 return ret;
466}
467
359static struct regulator_ops palmas_ops_smps = { 468static struct regulator_ops palmas_ops_smps = {
360 .is_enabled = palmas_is_enabled_smps, 469 .is_enabled = palmas_is_enabled_smps,
361 .enable = palmas_enable_smps, 470 .enable = palmas_enable_smps,
@@ -366,6 +475,8 @@ static struct regulator_ops palmas_ops_smps = {
366 .set_voltage_sel = regulator_set_voltage_sel_regmap, 475 .set_voltage_sel = regulator_set_voltage_sel_regmap,
367 .list_voltage = palmas_list_voltage_smps, 476 .list_voltage = palmas_list_voltage_smps,
368 .map_voltage = palmas_map_voltage_smps, 477 .map_voltage = palmas_map_voltage_smps,
478 .set_voltage_time_sel = palma_smps_set_voltage_smps_time_sel,
479 .set_ramp_delay = palmas_smps_set_ramp_delay,
369}; 480};
370 481
371static struct regulator_ops palmas_ops_smps10 = { 482static struct regulator_ops palmas_ops_smps10 = {
@@ -401,6 +512,12 @@ static struct regulator_ops palmas_ops_ldo = {
401 .map_voltage = regulator_map_voltage_linear, 512 .map_voltage = regulator_map_voltage_linear,
402}; 513};
403 514
515static struct regulator_ops palmas_ops_extreg = {
516 .is_enabled = regulator_is_enabled_regmap,
517 .enable = regulator_enable_regmap,
518 .disable = regulator_disable_regmap,
519};
520
404/* 521/*
405 * setup the hardware based sleep configuration of the SMPS/LDO regulators 522 * setup the hardware based sleep configuration of the SMPS/LDO regulators
406 * from the platform data. This is different to the software based control 523 * from the platform data. This is different to the software based control
@@ -422,40 +539,32 @@ static int palmas_smps_init(struct palmas *palmas, int id,
422 539
423 switch (id) { 540 switch (id) {
424 case PALMAS_REG_SMPS10: 541 case PALMAS_REG_SMPS10:
425 if (reg_init->mode_sleep) { 542 reg &= ~PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK;
426 reg &= ~PALMAS_SMPS10_CTRL_MODE_SLEEP_MASK; 543 if (reg_init->mode_sleep)
427 reg |= reg_init->mode_sleep << 544 reg |= reg_init->mode_sleep <<
428 PALMAS_SMPS10_CTRL_MODE_SLEEP_SHIFT; 545 PALMAS_SMPS10_CTRL_MODE_SLEEP_SHIFT;
429 }
430 break; 546 break;
431 default: 547 default:
432 if (reg_init->warm_reset) 548 if (reg_init->warm_reset)
433 reg |= PALMAS_SMPS12_CTRL_WR_S; 549 reg |= PALMAS_SMPS12_CTRL_WR_S;
550 else
551 reg &= ~PALMAS_SMPS12_CTRL_WR_S;
434 552
435 if (reg_init->roof_floor) 553 if (reg_init->roof_floor)
436 reg |= PALMAS_SMPS12_CTRL_ROOF_FLOOR_EN; 554 reg |= PALMAS_SMPS12_CTRL_ROOF_FLOOR_EN;
555 else
556 reg &= ~PALMAS_SMPS12_CTRL_ROOF_FLOOR_EN;
437 557
438 if (reg_init->mode_sleep) { 558 reg &= ~PALMAS_SMPS12_CTRL_MODE_SLEEP_MASK;
439 reg &= ~PALMAS_SMPS12_CTRL_MODE_SLEEP_MASK; 559 if (reg_init->mode_sleep)
440 reg |= reg_init->mode_sleep << 560 reg |= reg_init->mode_sleep <<
441 PALMAS_SMPS12_CTRL_MODE_SLEEP_SHIFT; 561 PALMAS_SMPS12_CTRL_MODE_SLEEP_SHIFT;
442 }
443 } 562 }
444 563
445 ret = palmas_smps_write(palmas, addr, reg); 564 ret = palmas_smps_write(palmas, addr, reg);
446 if (ret) 565 if (ret)
447 return ret; 566 return ret;
448 567
449 if (palmas_regs_info[id].tstep_addr && reg_init->tstep) {
450 addr = palmas_regs_info[id].tstep_addr;
451
452 reg = reg_init->tstep & PALMAS_SMPS12_TSTEP_TSTEP_MASK;
453
454 ret = palmas_smps_write(palmas, addr, reg);
455 if (ret)
456 return ret;
457 }
458
459 if (palmas_regs_info[id].vsel_addr && reg_init->vsel) { 568 if (palmas_regs_info[id].vsel_addr && reg_init->vsel) {
460 addr = palmas_regs_info[id].vsel_addr; 569 addr = palmas_regs_info[id].vsel_addr;
461 570
@@ -485,9 +594,13 @@ static int palmas_ldo_init(struct palmas *palmas, int id,
485 594
486 if (reg_init->warm_reset) 595 if (reg_init->warm_reset)
487 reg |= PALMAS_LDO1_CTRL_WR_S; 596 reg |= PALMAS_LDO1_CTRL_WR_S;
597 else
598 reg &= ~PALMAS_LDO1_CTRL_WR_S;
488 599
489 if (reg_init->mode_sleep) 600 if (reg_init->mode_sleep)
490 reg |= PALMAS_LDO1_CTRL_MODE_SLEEP; 601 reg |= PALMAS_LDO1_CTRL_MODE_SLEEP;
602 else
603 reg &= ~PALMAS_LDO1_CTRL_MODE_SLEEP;
491 604
492 ret = palmas_ldo_write(palmas, addr, reg); 605 ret = palmas_ldo_write(palmas, addr, reg);
493 if (ret) 606 if (ret)
@@ -496,6 +609,68 @@ static int palmas_ldo_init(struct palmas *palmas, int id,
496 return 0; 609 return 0;
497} 610}
498 611
612static int palmas_extreg_init(struct palmas *palmas, int id,
613 struct palmas_reg_init *reg_init)
614{
615 unsigned int addr;
616 int ret;
617 unsigned int val = 0;
618
619 addr = palmas_regs_info[id].ctrl_addr;
620
621 if (reg_init->mode_sleep)
622 val = PALMAS_REGEN1_CTRL_MODE_SLEEP;
623
624 ret = palmas_update_bits(palmas, PALMAS_RESOURCE_BASE,
625 addr, PALMAS_REGEN1_CTRL_MODE_SLEEP, val);
626 if (ret < 0) {
627 dev_err(palmas->dev, "Resource reg 0x%02x update failed %d\n",
628 addr, ret);
629 return ret;
630 }
631 return 0;
632}
633
634static void palmas_enable_ldo8_track(struct palmas *palmas)
635{
636 unsigned int reg;
637 unsigned int addr;
638 int ret;
639
640 addr = palmas_regs_info[PALMAS_REG_LDO8].ctrl_addr;
641
642 ret = palmas_ldo_read(palmas, addr, &reg);
643 if (ret) {
644 dev_err(palmas->dev, "Error in reading ldo8 control reg\n");
645 return;
646 }
647
648 reg |= PALMAS_LDO8_CTRL_LDO_TRACKING_EN;
649 ret = palmas_ldo_write(palmas, addr, reg);
650 if (ret < 0) {
651 dev_err(palmas->dev, "Error in enabling tracking mode\n");
652 return;
653 }
654 /*
655 * When SMPS45 is set to off and LDO8 tracking is enabled, the LDO8
656 * output is defined by the LDO8_VOLTAGE.VSEL register divided by two,
657 * and can be set from 0.45 to 1.65 V.
658 */
659 addr = palmas_regs_info[PALMAS_REG_LDO8].vsel_addr;
660 ret = palmas_ldo_read(palmas, addr, &reg);
661 if (ret) {
662 dev_err(palmas->dev, "Error in reading ldo8 voltage reg\n");
663 return;
664 }
665
666 reg = (reg << 1) & PALMAS_LDO8_VOLTAGE_VSEL_MASK;
667 ret = palmas_ldo_write(palmas, addr, reg);
668 if (ret < 0)
669 dev_err(palmas->dev, "Error in setting ldo8 voltage reg\n");
670
671 return;
672}
673
499static struct of_regulator_match palmas_matches[] = { 674static struct of_regulator_match palmas_matches[] = {
500 { .name = "smps12", }, 675 { .name = "smps12", },
501 { .name = "smps123", }, 676 { .name = "smps123", },
@@ -518,6 +693,11 @@ static struct of_regulator_match palmas_matches[] = {
518 { .name = "ldo9", }, 693 { .name = "ldo9", },
519 { .name = "ldoln", }, 694 { .name = "ldoln", },
520 { .name = "ldousb", }, 695 { .name = "ldousb", },
696 { .name = "regen1", },
697 { .name = "regen2", },
698 { .name = "regen3", },
699 { .name = "sysen1", },
700 { .name = "sysen2", },
521}; 701};
522 702
523static void palmas_dt_to_pdata(struct device *dev, 703static void palmas_dt_to_pdata(struct device *dev,
@@ -553,39 +733,36 @@ static void palmas_dt_to_pdata(struct device *dev,
553 pdata->reg_init[idx] = devm_kzalloc(dev, 733 pdata->reg_init[idx] = devm_kzalloc(dev,
554 sizeof(struct palmas_reg_init), GFP_KERNEL); 734 sizeof(struct palmas_reg_init), GFP_KERNEL);
555 735
556 ret = of_property_read_u32(palmas_matches[idx].of_node, 736 pdata->reg_init[idx]->warm_reset =
557 "ti,warm_reset", &prop); 737 of_property_read_bool(palmas_matches[idx].of_node,
558 if (!ret) 738 "ti,warm-reset");
559 pdata->reg_init[idx]->warm_reset = prop;
560 739
561 ret = of_property_read_u32(palmas_matches[idx].of_node, 740 pdata->reg_init[idx]->roof_floor =
562 "ti,roof_floor", &prop); 741 of_property_read_bool(palmas_matches[idx].of_node,
563 if (!ret) 742 "ti,roof-floor");
564 pdata->reg_init[idx]->roof_floor = prop;
565 743
566 ret = of_property_read_u32(palmas_matches[idx].of_node, 744 ret = of_property_read_u32(palmas_matches[idx].of_node,
567 "ti,mode_sleep", &prop); 745 "ti,mode-sleep", &prop);
568 if (!ret) 746 if (!ret)
569 pdata->reg_init[idx]->mode_sleep = prop; 747 pdata->reg_init[idx]->mode_sleep = prop;
570 748
571 ret = of_property_read_u32(palmas_matches[idx].of_node, 749 ret = of_property_read_bool(palmas_matches[idx].of_node,
572 "ti,tstep", &prop); 750 "ti,smps-range");
573 if (!ret) 751 if (ret)
574 pdata->reg_init[idx]->tstep = prop; 752 pdata->reg_init[idx]->vsel =
753 PALMAS_SMPS12_VOLTAGE_RANGE;
575 754
576 ret = of_property_read_u32(palmas_matches[idx].of_node, 755 if (idx == PALMAS_REG_LDO8)
577 "ti,vsel", &prop); 756 pdata->enable_ldo8_tracking = of_property_read_bool(
578 if (!ret) 757 palmas_matches[idx].of_node,
579 pdata->reg_init[idx]->vsel = prop; 758 "ti,enable-ldo8-tracking");
580 } 759 }
581 760
582 ret = of_property_read_u32(node, "ti,ldo6_vibrator", &prop); 761 pdata->ldo6_vibrator = of_property_read_bool(node, "ti,ldo6-vibrator");
583 if (!ret)
584 pdata->ldo6_vibrator = prop;
585} 762}
586 763
587 764
588static int palmas_probe(struct platform_device *pdev) 765static int palmas_regulators_probe(struct platform_device *pdev)
589{ 766{
590 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent); 767 struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
591 struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data; 768 struct palmas_pmic_platform_data *pdata = pdev->dev.platform_data;
@@ -630,6 +807,7 @@ static int palmas_probe(struct platform_device *pdev)
630 config.driver_data = pmic; 807 config.driver_data = pmic;
631 808
632 for (id = 0; id < PALMAS_REG_LDO1; id++) { 809 for (id = 0; id < PALMAS_REG_LDO1; id++) {
810 bool ramp_delay_support = false;
633 811
634 /* 812 /*
635 * Miss out regulators which are not available due 813 * Miss out regulators which are not available due
@@ -640,19 +818,42 @@ static int palmas_probe(struct platform_device *pdev)
640 case PALMAS_REG_SMPS3: 818 case PALMAS_REG_SMPS3:
641 if (pmic->smps123) 819 if (pmic->smps123)
642 continue; 820 continue;
821 if (id == PALMAS_REG_SMPS12)
822 ramp_delay_support = true;
643 break; 823 break;
644 case PALMAS_REG_SMPS123: 824 case PALMAS_REG_SMPS123:
645 if (!pmic->smps123) 825 if (!pmic->smps123)
646 continue; 826 continue;
827 ramp_delay_support = true;
647 break; 828 break;
648 case PALMAS_REG_SMPS45: 829 case PALMAS_REG_SMPS45:
649 case PALMAS_REG_SMPS7: 830 case PALMAS_REG_SMPS7:
650 if (pmic->smps457) 831 if (pmic->smps457)
651 continue; 832 continue;
833 if (id == PALMAS_REG_SMPS45)
834 ramp_delay_support = true;
652 break; 835 break;
653 case PALMAS_REG_SMPS457: 836 case PALMAS_REG_SMPS457:
654 if (!pmic->smps457) 837 if (!pmic->smps457)
655 continue; 838 continue;
839 ramp_delay_support = true;
840 break;
841 }
842
843 if ((id == PALMAS_REG_SMPS6) && (id == PALMAS_REG_SMPS8))
844 ramp_delay_support = true;
845
846 if (ramp_delay_support) {
847 addr = palmas_regs_info[id].tstep_addr;
848 ret = palmas_smps_read(pmic->palmas, addr, &reg);
849 if (ret < 0) {
850 dev_err(&pdev->dev,
851 "reading TSTEP reg failed: %d\n", ret);
852 goto err_unregister_regulator;
853 }
854 pmic->desc[id].ramp_delay =
855 palmas_smps_ramp_delay[reg & 0x3];
856 pmic->ramp_delay[id] = pmic->desc[id].ramp_delay;
656 } 857 }
657 858
658 /* Initialise sleep/init values from platform data */ 859 /* Initialise sleep/init values from platform data */
@@ -686,7 +887,8 @@ static int palmas_probe(struct platform_device *pdev)
686 /* 887 /*
687 * Read and store the RANGE bit for later use 888 * Read and store the RANGE bit for later use
688 * This must be done before regulator is probed, 889 * This must be done before regulator is probed,
689 * otherwise we error in probe with unsupportable ranges. 890 * otherwise we error in probe with unsupportable
891 * ranges. Read the current smps mode for later use.
690 */ 892 */
691 addr = palmas_regs_info[id].vsel_addr; 893 addr = palmas_regs_info[id].vsel_addr;
692 894
@@ -703,6 +905,14 @@ static int palmas_probe(struct platform_device *pdev)
703 palmas_regs_info[id].vsel_addr); 905 palmas_regs_info[id].vsel_addr);
704 pmic->desc[id].vsel_mask = 906 pmic->desc[id].vsel_mask =
705 PALMAS_SMPS12_VOLTAGE_VSEL_MASK; 907 PALMAS_SMPS12_VOLTAGE_VSEL_MASK;
908
909 /* Read the smps mode for later use. */
910 addr = palmas_regs_info[id].ctrl_addr;
911 ret = palmas_smps_read(pmic->palmas, addr, &reg);
912 if (ret)
913 goto err_unregister_regulator;
914 pmic->current_reg_mode[id] = reg &
915 PALMAS_SMPS12_CTRL_MODE_ACTIVE_MASK;
706 } 916 }
707 917
708 pmic->desc[id].type = REGULATOR_VOLTAGE; 918 pmic->desc[id].type = REGULATOR_VOLTAGE;
@@ -713,6 +923,7 @@ static int palmas_probe(struct platform_device *pdev)
713 else 923 else
714 config.init_data = NULL; 924 config.init_data = NULL;
715 925
926 pmic->desc[id].supply_name = palmas_regs_info[id].sname;
716 config.of_node = palmas_matches[id].of_node; 927 config.of_node = palmas_matches[id].of_node;
717 928
718 rdev = regulator_register(&pmic->desc[id], &config); 929 rdev = regulator_register(&pmic->desc[id], &config);
@@ -738,27 +949,49 @@ static int palmas_probe(struct platform_device *pdev)
738 /* Register the regulators */ 949 /* Register the regulators */
739 pmic->desc[id].name = palmas_regs_info[id].name; 950 pmic->desc[id].name = palmas_regs_info[id].name;
740 pmic->desc[id].id = id; 951 pmic->desc[id].id = id;
741 pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES;
742
743 pmic->desc[id].ops = &palmas_ops_ldo;
744
745 pmic->desc[id].type = REGULATOR_VOLTAGE; 952 pmic->desc[id].type = REGULATOR_VOLTAGE;
746 pmic->desc[id].owner = THIS_MODULE; 953 pmic->desc[id].owner = THIS_MODULE;
747 pmic->desc[id].min_uV = 900000; 954
748 pmic->desc[id].uV_step = 50000; 955 if (id < PALMAS_REG_REGEN1) {
749 pmic->desc[id].linear_min_sel = 1; 956 pmic->desc[id].n_voltages = PALMAS_LDO_NUM_VOLTAGES;
750 pmic->desc[id].vsel_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, 957 pmic->desc[id].ops = &palmas_ops_ldo;
958 pmic->desc[id].min_uV = 900000;
959 pmic->desc[id].uV_step = 50000;
960 pmic->desc[id].linear_min_sel = 1;
961 pmic->desc[id].vsel_reg =
962 PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
751 palmas_regs_info[id].vsel_addr); 963 palmas_regs_info[id].vsel_addr);
752 pmic->desc[id].vsel_mask = PALMAS_LDO1_VOLTAGE_VSEL_MASK; 964 pmic->desc[id].vsel_mask =
753 pmic->desc[id].enable_reg = PALMAS_BASE_TO_REG(PALMAS_LDO_BASE, 965 PALMAS_LDO1_VOLTAGE_VSEL_MASK;
966 pmic->desc[id].enable_reg =
967 PALMAS_BASE_TO_REG(PALMAS_LDO_BASE,
968 palmas_regs_info[id].ctrl_addr);
969 pmic->desc[id].enable_mask =
970 PALMAS_LDO1_CTRL_MODE_ACTIVE;
971
972 /* Check if LDO8 is in tracking mode or not */
973 if (pdata && (id == PALMAS_REG_LDO8) &&
974 pdata->enable_ldo8_tracking) {
975 palmas_enable_ldo8_track(palmas);
976 pmic->desc[id].min_uV = 450000;
977 pmic->desc[id].uV_step = 25000;
978 }
979 } else {
980 pmic->desc[id].n_voltages = 1;
981 pmic->desc[id].ops = &palmas_ops_extreg;
982 pmic->desc[id].enable_reg =
983 PALMAS_BASE_TO_REG(PALMAS_RESOURCE_BASE,
754 palmas_regs_info[id].ctrl_addr); 984 palmas_regs_info[id].ctrl_addr);
755 pmic->desc[id].enable_mask = PALMAS_LDO1_CTRL_MODE_ACTIVE; 985 pmic->desc[id].enable_mask =
986 PALMAS_REGEN1_CTRL_MODE_ACTIVE;
987 }
756 988
757 if (pdata) 989 if (pdata)
758 config.init_data = pdata->reg_data[id]; 990 config.init_data = pdata->reg_data[id];
759 else 991 else
760 config.init_data = NULL; 992 config.init_data = NULL;
761 993
994 pmic->desc[id].supply_name = palmas_regs_info[id].sname;
762 config.of_node = palmas_matches[id].of_node; 995 config.of_node = palmas_matches[id].of_node;
763 996
764 rdev = regulator_register(&pmic->desc[id], &config); 997 rdev = regulator_register(&pmic->desc[id], &config);
@@ -777,7 +1010,12 @@ static int palmas_probe(struct platform_device *pdev)
777 if (pdata) { 1010 if (pdata) {
778 reg_init = pdata->reg_init[id]; 1011 reg_init = pdata->reg_init[id];
779 if (reg_init) { 1012 if (reg_init) {
780 ret = palmas_ldo_init(palmas, id, reg_init); 1013 if (id < PALMAS_REG_REGEN1)
1014 ret = palmas_ldo_init(palmas,
1015 id, reg_init);
1016 else
1017 ret = palmas_extreg_init(palmas,
1018 id, reg_init);
781 if (ret) { 1019 if (ret) {
782 regulator_unregister(pmic->rdev[id]); 1020 regulator_unregister(pmic->rdev[id]);
783 goto err_unregister_regulator; 1021 goto err_unregister_regulator;
@@ -786,6 +1024,7 @@ static int palmas_probe(struct platform_device *pdev)
786 } 1024 }
787 } 1025 }
788 1026
1027
789 return 0; 1028 return 0;
790 1029
791err_unregister_regulator: 1030err_unregister_regulator:
@@ -794,7 +1033,7 @@ err_unregister_regulator:
794 return ret; 1033 return ret;
795} 1034}
796 1035
797static int palmas_remove(struct platform_device *pdev) 1036static int palmas_regulators_remove(struct platform_device *pdev)
798{ 1037{
799 struct palmas_pmic *pmic = platform_get_drvdata(pdev); 1038 struct palmas_pmic *pmic = platform_get_drvdata(pdev);
800 int id; 1039 int id;
@@ -806,6 +1045,12 @@ static int palmas_remove(struct platform_device *pdev)
806 1045
807static struct of_device_id of_palmas_match_tbl[] = { 1046static struct of_device_id of_palmas_match_tbl[] = {
808 { .compatible = "ti,palmas-pmic", }, 1047 { .compatible = "ti,palmas-pmic", },
1048 { .compatible = "ti,twl6035-pmic", },
1049 { .compatible = "ti,twl6036-pmic", },
1050 { .compatible = "ti,twl6037-pmic", },
1051 { .compatible = "ti,tps65913-pmic", },
1052 { .compatible = "ti,tps65914-pmic", },
1053 { .compatible = "ti,tps80036-pmic", },
809 { /* end */ } 1054 { /* end */ }
810}; 1055};
811 1056
@@ -815,8 +1060,8 @@ static struct platform_driver palmas_driver = {
815 .of_match_table = of_palmas_match_tbl, 1060 .of_match_table = of_palmas_match_tbl,
816 .owner = THIS_MODULE, 1061 .owner = THIS_MODULE,
817 }, 1062 },
818 .probe = palmas_probe, 1063 .probe = palmas_regulators_probe,
819 .remove = palmas_remove, 1064 .remove = palmas_regulators_remove,
820}; 1065};
821 1066
822static int __init palmas_init(void) 1067static int __init palmas_init(void)
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c
index 9e6f78694bf1..5885b4504596 100644
--- a/drivers/regulator/rc5t583-regulator.c
+++ b/drivers/regulator/rc5t583-regulator.c
@@ -49,10 +49,6 @@ struct rc5t583_regulator_info {
49 49
50struct rc5t583_regulator { 50struct rc5t583_regulator {
51 struct rc5t583_regulator_info *reg_info; 51 struct rc5t583_regulator_info *reg_info;
52
53 /* Devices */
54 struct device *dev;
55 struct rc5t583 *mfd;
56 struct regulator_dev *rdev; 52 struct regulator_dev *rdev;
57}; 53};
58 54
@@ -155,8 +151,6 @@ static int rc5t583_regulator_probe(struct platform_device *pdev)
155 reg = &regs[id]; 151 reg = &regs[id];
156 ri = &rc5t583_reg_info[id]; 152 ri = &rc5t583_reg_info[id];
157 reg->reg_info = ri; 153 reg->reg_info = ri;
158 reg->mfd = rc5t583;
159 reg->dev = &pdev->dev;
160 154
161 if (ri->deepsleep_id == RC5T583_DS_NONE) 155 if (ri->deepsleep_id == RC5T583_DS_NONE)
162 goto skip_ext_pwr_config; 156 goto skip_ext_pwr_config;
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 8a831947c351..c24448bc43cf 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -549,7 +549,7 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
549 549
550 rmode = devm_kzalloc(&pdev->dev, sizeof(*rmode) * 550 rmode = devm_kzalloc(&pdev->dev, sizeof(*rmode) *
551 pdata->num_regulators, GFP_KERNEL); 551 pdata->num_regulators, GFP_KERNEL);
552 if (!rdata) { 552 if (!rmode) {
553 dev_err(iodev->dev, 553 dev_err(iodev->dev,
554 "could not allocate memory for regulator mode\n"); 554 "could not allocate memory for regulator mode\n");
555 return -ENOMEM; 555 return -ENOMEM;
@@ -923,8 +923,7 @@ static int s5m8767_pmic_probe(struct platform_device *pdev)
923 return 0; 923 return 0;
924err: 924err:
925 for (i = 0; i < s5m8767->num_regulators; i++) 925 for (i = 0; i < s5m8767->num_regulators; i++)
926 if (rdev[i]) 926 regulator_unregister(rdev[i]);
927 regulator_unregister(rdev[i]);
928 927
929 return ret; 928 return ret;
930} 929}
@@ -936,8 +935,7 @@ static int s5m8767_pmic_remove(struct platform_device *pdev)
936 int i; 935 int i;
937 936
938 for (i = 0; i < s5m8767->num_regulators; i++) 937 for (i = 0; i < s5m8767->num_regulators; i++)
939 if (rdev[i]) 938 regulator_unregister(rdev[i]);
940 regulator_unregister(rdev[i]);
941 939
942 return 0; 940 return 0;
943} 941}
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c
index acbd63fde415..612919c3081c 100644
--- a/drivers/regulator/tps62360-regulator.c
+++ b/drivers/regulator/tps62360-regulator.c
@@ -278,7 +278,7 @@ static int tps62360_init_dcdc(struct tps62360_chip *tps,
278 __func__, REG_RAMPCTRL, ret); 278 __func__, REG_RAMPCTRL, ret);
279 return ret; 279 return ret;
280 } 280 }
281 ramp_ctrl = (ramp_ctrl >> 4) & 0x7; 281 ramp_ctrl = (ramp_ctrl >> 5) & 0x7;
282 282
283 /* ramp mV/us = 32/(2^ramp_ctrl) */ 283 /* ramp mV/us = 32/(2^ramp_ctrl) */
284 tps->desc.ramp_delay = DIV_ROUND_UP(32000, BIT(ramp_ctrl)); 284 tps->desc.ramp_delay = DIV_ROUND_UP(32000, BIT(ramp_ctrl));
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c
index 9b9af6d889c8..9d053e23e9eb 100644
--- a/drivers/regulator/tps65023-regulator.c
+++ b/drivers/regulator/tps65023-regulator.c
@@ -107,12 +107,7 @@ static const unsigned int DCDC_FIXED_1800000_VSEL_table[] = {
107}; 107};
108 108
109/* Supported voltage values for LDO regulators for tps65020 */ 109/* Supported voltage values for LDO regulators for tps65020 */
110static const unsigned int TPS65020_LDO1_VSEL_table[] = { 110static const unsigned int TPS65020_LDO_VSEL_table[] = {
111 1000000, 1050000, 1100000, 1300000,
112 1800000, 2500000, 3000000, 3300000,
113};
114
115static const unsigned int TPS65020_LDO2_VSEL_table[] = {
116 1000000, 1050000, 1100000, 1300000, 111 1000000, 1050000, 1100000, 1300000,
117 1800000, 2500000, 3000000, 3300000, 112 1800000, 2500000, 3000000, 3300000,
118}; 113};
@@ -154,20 +149,15 @@ struct tps_driver_data {
154static int tps65023_dcdc_get_voltage_sel(struct regulator_dev *dev) 149static int tps65023_dcdc_get_voltage_sel(struct regulator_dev *dev)
155{ 150{
156 struct tps_pmic *tps = rdev_get_drvdata(dev); 151 struct tps_pmic *tps = rdev_get_drvdata(dev);
157 int ret; 152 int dcdc = rdev_get_id(dev);
158 int data, dcdc = rdev_get_id(dev);
159 153
160 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3) 154 if (dcdc < TPS65023_DCDC_1 || dcdc > TPS65023_DCDC_3)
161 return -EINVAL; 155 return -EINVAL;
162 156
163 if (dcdc == tps->core_regulator) { 157 if (dcdc != tps->core_regulator)
164 ret = regmap_read(tps->regmap, TPS65023_REG_DEF_CORE, &data);
165 if (ret != 0)
166 return ret;
167 data &= (tps->info[dcdc]->table_len - 1);
168 return data;
169 } else
170 return 0; 158 return 0;
159
160 return regulator_get_voltage_sel_regmap(dev);
171} 161}
172 162
173static int tps65023_dcdc_set_voltage_sel(struct regulator_dev *dev, 163static int tps65023_dcdc_set_voltage_sel(struct regulator_dev *dev,
@@ -175,23 +165,11 @@ static int tps65023_dcdc_set_voltage_sel(struct regulator_dev *dev,
175{ 165{
176 struct tps_pmic *tps = rdev_get_drvdata(dev); 166 struct tps_pmic *tps = rdev_get_drvdata(dev);
177 int dcdc = rdev_get_id(dev); 167 int dcdc = rdev_get_id(dev);
178 int ret;
179 168
180 if (dcdc != tps->core_regulator) 169 if (dcdc != tps->core_regulator)
181 return -EINVAL; 170 return -EINVAL;
182 171
183 ret = regmap_write(tps->regmap, TPS65023_REG_DEF_CORE, selector); 172 return regulator_set_voltage_sel_regmap(dev, selector);
184 if (ret)
185 goto out;
186
187 /* Tell the chip that we have changed the value in DEFCORE
188 * and its time to update the core voltage
189 */
190 ret = regmap_update_bits(tps->regmap, TPS65023_REG_CON_CTRL2,
191 TPS65023_REG_CTRL2_GO, TPS65023_REG_CTRL2_GO);
192
193out:
194 return ret;
195} 173}
196 174
197/* Operations permitted on VDCDCx */ 175/* Operations permitted on VDCDCx */
@@ -202,6 +180,7 @@ static struct regulator_ops tps65023_dcdc_ops = {
202 .get_voltage_sel = tps65023_dcdc_get_voltage_sel, 180 .get_voltage_sel = tps65023_dcdc_get_voltage_sel,
203 .set_voltage_sel = tps65023_dcdc_set_voltage_sel, 181 .set_voltage_sel = tps65023_dcdc_set_voltage_sel,
204 .list_voltage = regulator_list_voltage_table, 182 .list_voltage = regulator_list_voltage_table,
183 .map_voltage = regulator_map_voltage_ascend,
205}; 184};
206 185
207/* Operations permitted on LDOx */ 186/* Operations permitted on LDOx */
@@ -212,6 +191,7 @@ static struct regulator_ops tps65023_ldo_ops = {
212 .get_voltage_sel = regulator_get_voltage_sel_regmap, 191 .get_voltage_sel = regulator_get_voltage_sel_regmap,
213 .set_voltage_sel = regulator_set_voltage_sel_regmap, 192 .set_voltage_sel = regulator_set_voltage_sel_regmap,
214 .list_voltage = regulator_list_voltage_table, 193 .list_voltage = regulator_list_voltage_table,
194 .map_voltage = regulator_map_voltage_ascend,
215}; 195};
216 196
217static struct regmap_config tps65023_regmap_config = { 197static struct regmap_config tps65023_regmap_config = {
@@ -285,6 +265,10 @@ static int tps_65023_probe(struct i2c_client *client,
285 default: /* DCDCx */ 265 default: /* DCDCx */
286 tps->desc[i].enable_mask = 266 tps->desc[i].enable_mask =
287 1 << (TPS65023_NUM_REGULATOR - i); 267 1 << (TPS65023_NUM_REGULATOR - i);
268 tps->desc[i].vsel_reg = TPS65023_REG_DEF_CORE;
269 tps->desc[i].vsel_mask = info->table_len - 1;
270 tps->desc[i].apply_reg = TPS65023_REG_CON_CTRL2;
271 tps->desc[i].apply_bit = TPS65023_REG_CTRL2_GO;
288 } 272 }
289 273
290 config.dev = &client->dev; 274 config.dev = &client->dev;
@@ -347,13 +331,13 @@ static const struct tps_info tps65020_regs[] = {
347 }, 331 },
348 { 332 {
349 .name = "LDO1", 333 .name = "LDO1",
350 .table_len = ARRAY_SIZE(TPS65020_LDO1_VSEL_table), 334 .table_len = ARRAY_SIZE(TPS65020_LDO_VSEL_table),
351 .table = TPS65020_LDO1_VSEL_table, 335 .table = TPS65020_LDO_VSEL_table,
352 }, 336 },
353 { 337 {
354 .name = "LDO2", 338 .name = "LDO2",
355 .table_len = ARRAY_SIZE(TPS65020_LDO2_VSEL_table), 339 .table_len = ARRAY_SIZE(TPS65020_LDO_VSEL_table),
356 .table = TPS65020_LDO2_VSEL_table, 340 .table = TPS65020_LDO_VSEL_table,
357 }, 341 },
358}; 342};
359 343
diff --git a/drivers/regulator/tps6507x-regulator.c b/drivers/regulator/tps6507x-regulator.c
index 54aa2da7283b..4117ff52dba1 100644
--- a/drivers/regulator/tps6507x-regulator.c
+++ b/drivers/regulator/tps6507x-regulator.c
@@ -356,6 +356,7 @@ static struct regulator_ops tps6507x_pmic_ops = {
356 .get_voltage_sel = tps6507x_pmic_get_voltage_sel, 356 .get_voltage_sel = tps6507x_pmic_get_voltage_sel,
357 .set_voltage_sel = tps6507x_pmic_set_voltage_sel, 357 .set_voltage_sel = tps6507x_pmic_set_voltage_sel,
358 .list_voltage = regulator_list_voltage_table, 358 .list_voltage = regulator_list_voltage_table,
359 .map_voltage = regulator_map_voltage_ascend,
359}; 360};
360 361
361#ifdef CONFIG_OF 362#ifdef CONFIG_OF
diff --git a/drivers/regulator/tps6524x-regulator.c b/drivers/regulator/tps6524x-regulator.c
index 843ee0a9bb92..1094393155ed 100644
--- a/drivers/regulator/tps6524x-regulator.c
+++ b/drivers/regulator/tps6524x-regulator.c
@@ -572,6 +572,7 @@ static struct regulator_ops regulator_ops = {
572 .get_voltage_sel = get_voltage_sel, 572 .get_voltage_sel = get_voltage_sel,
573 .set_voltage_sel = set_voltage_sel, 573 .set_voltage_sel = set_voltage_sel,
574 .list_voltage = regulator_list_voltage_table, 574 .list_voltage = regulator_list_voltage_table,
575 .map_voltage = regulator_map_voltage_ascend,
575 .set_current_limit = set_current_limit, 576 .set_current_limit = set_current_limit,
576 .get_current_limit = get_current_limit, 577 .get_current_limit = get_current_limit,
577}; 578};
@@ -584,8 +585,7 @@ static int pmic_remove(struct spi_device *spi)
584 if (!hw) 585 if (!hw)
585 return 0; 586 return 0;
586 for (i = 0; i < N_REGULATORS; i++) { 587 for (i = 0; i < N_REGULATORS; i++) {
587 if (hw->rdev[i]) 588 regulator_unregister(hw->rdev[i]);
588 regulator_unregister(hw->rdev[i]);
589 hw->rdev[i] = NULL; 589 hw->rdev[i] = NULL;
590 } 590 }
591 spi_set_drvdata(spi, NULL); 591 spi_set_drvdata(spi, NULL);
diff --git a/drivers/regulator/tps6586x-regulator.c b/drivers/regulator/tps6586x-regulator.c
index e68382d0e1ea..d8fa37d5c734 100644
--- a/drivers/regulator/tps6586x-regulator.c
+++ b/drivers/regulator/tps6586x-regulator.c
@@ -70,6 +70,7 @@ static inline struct device *to_tps6586x_dev(struct regulator_dev *rdev)
70 70
71static struct regulator_ops tps6586x_regulator_ops = { 71static struct regulator_ops tps6586x_regulator_ops = {
72 .list_voltage = regulator_list_voltage_table, 72 .list_voltage = regulator_list_voltage_table,
73 .map_voltage = regulator_map_voltage_ascend,
73 .get_voltage_sel = regulator_get_voltage_sel_regmap, 74 .get_voltage_sel = regulator_get_voltage_sel_regmap,
74 .set_voltage_sel = regulator_set_voltage_sel_regmap, 75 .set_voltage_sel = regulator_set_voltage_sel_regmap,
75 76
@@ -245,7 +246,7 @@ static int tps6586x_regulator_set_slew_rate(struct platform_device *pdev,
245 reg = TPS6586X_SM1SL; 246 reg = TPS6586X_SM1SL;
246 break; 247 break;
247 default: 248 default:
248 dev_warn(&pdev->dev, "Only SM0/SM1 can set slew rate\n"); 249 dev_err(&pdev->dev, "Only SM0/SM1 can set slew rate\n");
249 return -EINVAL; 250 return -EINVAL;
250 } 251 }
251 252
@@ -304,14 +305,12 @@ static struct tps6586x_platform_data *tps6586x_parse_regulator_dt(
304 } 305 }
305 306
306 err = of_regulator_match(&pdev->dev, regs, tps6586x_matches, num); 307 err = of_regulator_match(&pdev->dev, regs, tps6586x_matches, num);
308 of_node_put(regs);
307 if (err < 0) { 309 if (err < 0) {
308 dev_err(&pdev->dev, "Regulator match failed, e %d\n", err); 310 dev_err(&pdev->dev, "Regulator match failed, e %d\n", err);
309 of_node_put(regs);
310 return NULL; 311 return NULL;
311 } 312 }
312 313
313 of_node_put(regs);
314
315 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 314 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
316 if (!pdata) { 315 if (!pdata) {
317 dev_err(&pdev->dev, "Memory alloction failed\n"); 316 dev_err(&pdev->dev, "Memory alloction failed\n");
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index 6ba6931ac855..45c16447744b 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -748,6 +748,7 @@ static struct regulator_ops tps65910_ops_dcdc = {
748 .set_voltage_sel = tps65910_set_voltage_dcdc_sel, 748 .set_voltage_sel = tps65910_set_voltage_dcdc_sel,
749 .set_voltage_time_sel = regulator_set_voltage_time_sel, 749 .set_voltage_time_sel = regulator_set_voltage_time_sel,
750 .list_voltage = tps65910_list_voltage_dcdc, 750 .list_voltage = tps65910_list_voltage_dcdc,
751 .map_voltage = regulator_map_voltage_ascend,
751}; 752};
752 753
753static struct regulator_ops tps65910_ops_vdd3 = { 754static struct regulator_ops tps65910_ops_vdd3 = {
@@ -758,6 +759,7 @@ static struct regulator_ops tps65910_ops_vdd3 = {
758 .get_mode = tps65910_get_mode, 759 .get_mode = tps65910_get_mode,
759 .get_voltage = tps65910_get_voltage_vdd3, 760 .get_voltage = tps65910_get_voltage_vdd3,
760 .list_voltage = regulator_list_voltage_table, 761 .list_voltage = regulator_list_voltage_table,
762 .map_voltage = regulator_map_voltage_ascend,
761}; 763};
762 764
763static struct regulator_ops tps65910_ops = { 765static struct regulator_ops tps65910_ops = {
@@ -769,6 +771,7 @@ static struct regulator_ops tps65910_ops = {
769 .get_voltage_sel = tps65910_get_voltage_sel, 771 .get_voltage_sel = tps65910_get_voltage_sel,
770 .set_voltage_sel = tps65910_set_voltage_sel, 772 .set_voltage_sel = tps65910_set_voltage_sel,
771 .list_voltage = regulator_list_voltage_table, 773 .list_voltage = regulator_list_voltage_table,
774 .map_voltage = regulator_map_voltage_ascend,
772}; 775};
773 776
774static struct regulator_ops tps65911_ops = { 777static struct regulator_ops tps65911_ops = {
@@ -780,6 +783,7 @@ static struct regulator_ops tps65911_ops = {
780 .get_voltage_sel = tps65911_get_voltage_sel, 783 .get_voltage_sel = tps65911_get_voltage_sel,
781 .set_voltage_sel = tps65911_set_voltage_sel, 784 .set_voltage_sel = tps65911_set_voltage_sel,
782 .list_voltage = tps65911_list_voltage, 785 .list_voltage = tps65911_list_voltage,
786 .map_voltage = regulator_map_voltage_ascend,
783}; 787};
784 788
785static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic, 789static int tps65910_set_ext_sleep_config(struct tps65910_reg *pmic,
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c
index 9019d0e7ecb6..6511d0bfd896 100644
--- a/drivers/regulator/tps80031-regulator.c
+++ b/drivers/regulator/tps80031-regulator.c
@@ -238,12 +238,11 @@ static int tps80031_dcdc_get_voltage_sel(struct regulator_dev *rdev)
238 return vsel & SMPS_VSEL_MASK; 238 return vsel & SMPS_VSEL_MASK;
239} 239}
240 240
241static int tps80031_ldo_set_voltage_sel(struct regulator_dev *rdev, 241static int tps80031_ldo_list_voltage(struct regulator_dev *rdev,
242 unsigned sel) 242 unsigned int sel)
243{ 243{
244 struct tps80031_regulator *ri = rdev_get_drvdata(rdev); 244 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
245 struct device *parent = to_tps80031_dev(rdev); 245 struct device *parent = to_tps80031_dev(rdev);
246 int ret;
247 246
248 /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */ 247 /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */
249 if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) && 248 if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
@@ -260,28 +259,27 @@ static int tps80031_ldo_set_voltage_sel(struct regulator_dev *rdev,
260 } 259 }
261 } 260 }
262 261
263 ret = tps80031_write(parent, ri->rinfo->volt_id, 262 return regulator_list_voltage_linear(rdev, sel);
264 ri->rinfo->volt_reg, sel);
265 if (ret < 0)
266 dev_err(ri->dev, "Error in writing reg 0x%02x, e = %d\n",
267 ri->rinfo->volt_reg, ret);
268 return ret;
269} 263}
270 264
271static int tps80031_ldo_get_voltage_sel(struct regulator_dev *rdev) 265static int tps80031_ldo_map_voltage(struct regulator_dev *rdev,
266 int min_uV, int max_uV)
272{ 267{
273 struct tps80031_regulator *ri = rdev_get_drvdata(rdev); 268 struct tps80031_regulator *ri = rdev_get_drvdata(rdev);
274 struct device *parent = to_tps80031_dev(rdev); 269 struct device *parent = to_tps80031_dev(rdev);
275 uint8_t vsel;
276 int ret;
277 270
278 ret = tps80031_read(parent, ri->rinfo->volt_id, 271 /* Check for valid setting for TPS80031 or TPS80032-ES1.0 */
279 ri->rinfo->volt_reg, &vsel); 272 if ((ri->rinfo->desc.id == TPS80031_REGULATOR_LDO2) &&
280 if (ret < 0) { 273 (ri->device_flags & TRACK_MODE_ENABLE)) {
281 dev_err(ri->dev, "Error in writing the Voltage register\n"); 274 if (((tps80031_get_chip_info(parent) == TPS80031) ||
282 return ret; 275 ((tps80031_get_chip_info(parent) == TPS80032) &&
276 (tps80031_get_pmu_version(parent) == 0x0)))) {
277 return regulator_map_voltage_iterate(rdev, min_uV,
278 max_uV);
279 }
283 } 280 }
284 return vsel & rdev->desc->vsel_mask; 281
282 return regulator_map_voltage_linear(rdev, min_uV, max_uV);
285} 283}
286 284
287static int tps80031_vbus_is_enabled(struct regulator_dev *rdev) 285static int tps80031_vbus_is_enabled(struct regulator_dev *rdev)
@@ -390,9 +388,10 @@ static struct regulator_ops tps80031_dcdc_ops = {
390}; 388};
391 389
392static struct regulator_ops tps80031_ldo_ops = { 390static struct regulator_ops tps80031_ldo_ops = {
393 .list_voltage = regulator_list_voltage_linear, 391 .list_voltage = tps80031_ldo_list_voltage,
394 .set_voltage_sel = tps80031_ldo_set_voltage_sel, 392 .map_voltage = tps80031_ldo_map_voltage,
395 .get_voltage_sel = tps80031_ldo_get_voltage_sel, 393 .set_voltage_sel = regulator_set_voltage_sel_regmap,
394 .get_voltage_sel = regulator_get_voltage_sel_regmap,
396 .enable = tps80031_reg_enable, 395 .enable = tps80031_reg_enable,
397 .disable = tps80031_reg_disable, 396 .disable = tps80031_reg_disable,
398 .is_enabled = tps80031_reg_is_enabled, 397 .is_enabled = tps80031_reg_is_enabled,
@@ -459,6 +458,7 @@ static struct regulator_ops tps80031_ext_reg_ops = {
459 .uV_step = 100000, \ 458 .uV_step = 100000, \
460 .linear_min_sel = 1, \ 459 .linear_min_sel = 1, \
461 .n_voltages = 25, \ 460 .n_voltages = 25, \
461 .vsel_reg = TPS80031_##_id##_CFG_VOLTAGE, \
462 .vsel_mask = LDO_VSEL_MASK, \ 462 .vsel_mask = LDO_VSEL_MASK, \
463 .enable_time = 500, \ 463 .enable_time = 500, \
464 }, \ 464 }, \
@@ -680,6 +680,7 @@ static int tps80031_regulator_probe(struct platform_device *pdev)
680 struct tps80031_regulator *pmic; 680 struct tps80031_regulator *pmic;
681 struct regulator_dev *rdev; 681 struct regulator_dev *rdev;
682 struct regulator_config config = { }; 682 struct regulator_config config = { };
683 struct tps80031 *tps80031_mfd = dev_get_drvdata(pdev->dev.parent);
683 int ret; 684 int ret;
684 int num; 685 int num;
685 686
@@ -707,6 +708,8 @@ static int tps80031_regulator_probe(struct platform_device *pdev)
707 config.dev = &pdev->dev; 708 config.dev = &pdev->dev;
708 config.init_data = NULL; 709 config.init_data = NULL;
709 config.driver_data = ri; 710 config.driver_data = ri;
711 config.regmap = tps80031_mfd->regmap[ri->rinfo->volt_id];
712
710 if (tps_pdata) { 713 if (tps_pdata) {
711 config.init_data = tps_pdata->reg_init_data; 714 config.init_data = tps_pdata->reg_init_data;
712 ri->config_flags = tps_pdata->config_flags; 715 ri->config_flags = tps_pdata->config_flags;
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c
index f705d25b437c..fb6e67d74ffb 100644
--- a/drivers/regulator/twl-regulator.c
+++ b/drivers/regulator/twl-regulator.c
@@ -441,12 +441,6 @@ static const u16 VSIM_VSEL_table[] = {
441static const u16 VDAC_VSEL_table[] = { 441static const u16 VDAC_VSEL_table[] = {
442 1200, 1300, 1800, 1800, 442 1200, 1300, 1800, 1800,
443}; 443};
444static const u16 VDD1_VSEL_table[] = {
445 800, 1450,
446};
447static const u16 VDD2_VSEL_table[] = {
448 800, 1450, 1500,
449};
450static const u16 VIO_VSEL_table[] = { 444static const u16 VIO_VSEL_table[] = {
451 1800, 1850, 445 1800, 1850,
452}; 446};
@@ -615,18 +609,8 @@ static struct regulator_ops twl6030ldo_ops = {
615 609
616/*----------------------------------------------------------------------*/ 610/*----------------------------------------------------------------------*/
617 611
618/*
619 * Fixed voltage LDOs don't have a VSEL field to update.
620 */
621static int twlfixed_list_voltage(struct regulator_dev *rdev, unsigned index)
622{
623 struct twlreg_info *info = rdev_get_drvdata(rdev);
624
625 return info->min_mV * 1000;
626}
627
628static struct regulator_ops twl4030fixed_ops = { 612static struct regulator_ops twl4030fixed_ops = {
629 .list_voltage = twlfixed_list_voltage, 613 .list_voltage = regulator_list_voltage_linear,
630 614
631 .enable = twl4030reg_enable, 615 .enable = twl4030reg_enable,
632 .disable = twl4030reg_disable, 616 .disable = twl4030reg_disable,
@@ -638,7 +622,7 @@ static struct regulator_ops twl4030fixed_ops = {
638}; 622};
639 623
640static struct regulator_ops twl6030fixed_ops = { 624static struct regulator_ops twl6030fixed_ops = {
641 .list_voltage = twlfixed_list_voltage, 625 .list_voltage = regulator_list_voltage_linear,
642 626
643 .enable = twl6030reg_enable, 627 .enable = twl6030reg_enable,
644 .disable = twl6030reg_disable, 628 .disable = twl6030reg_disable,
@@ -944,19 +928,7 @@ static const struct twlreg_info TWLFIXED_INFO_##label = { \
944 .ops = &operations, \ 928 .ops = &operations, \
945 .type = REGULATOR_VOLTAGE, \ 929 .type = REGULATOR_VOLTAGE, \
946 .owner = THIS_MODULE, \ 930 .owner = THIS_MODULE, \
947 .enable_time = turnon_delay, \ 931 .min_uV = mVolts * 1000, \
948 }, \
949 }
950
951#define TWL6030_FIXED_RESOURCE(label, offset, turnon_delay) \
952static struct twlreg_info TWLRES_INFO_##label = { \
953 .base = offset, \
954 .desc = { \
955 .name = #label, \
956 .id = TWL6030_REG_##label, \
957 .ops = &twl6030_fixed_resource, \
958 .type = REGULATOR_VOLTAGE, \
959 .owner = THIS_MODULE, \
960 .enable_time = turnon_delay, \ 932 .enable_time = turnon_delay, \
961 }, \ 933 }, \
962 } 934 }
diff --git a/drivers/regulator/wm8994-regulator.c b/drivers/regulator/wm8994-regulator.c
index 6ff872342648..a612c356a697 100644
--- a/drivers/regulator/wm8994-regulator.c
+++ b/drivers/regulator/wm8994-regulator.c
@@ -18,6 +18,7 @@
18#include <linux/err.h> 18#include <linux/err.h>
19#include <linux/platform_device.h> 19#include <linux/platform_device.h>
20#include <linux/regulator/driver.h> 20#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h>
21#include <linux/gpio.h> 22#include <linux/gpio.h>
22#include <linux/slab.h> 23#include <linux/slab.h>
23 24
@@ -28,6 +29,8 @@
28struct wm8994_ldo { 29struct wm8994_ldo {
29 struct regulator_dev *regulator; 30 struct regulator_dev *regulator;
30 struct wm8994 *wm8994; 31 struct wm8994 *wm8994;
32 struct regulator_consumer_supply supply;
33 struct regulator_init_data init_data;
31}; 34};
32 35
33#define WM8994_LDO1_MAX_SELECTOR 0x7 36#define WM8994_LDO1_MAX_SELECTOR 0x7
@@ -99,6 +102,26 @@ static const struct regulator_desc wm8994_ldo_desc[] = {
99 }, 102 },
100}; 103};
101 104
105static const struct regulator_consumer_supply wm8994_ldo_consumer[] = {
106 { .supply = "AVDD1" },
107 { .supply = "DCVDD" },
108};
109
110static const struct regulator_init_data wm8994_ldo_default[] = {
111 {
112 .constraints = {
113 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
114 },
115 .num_consumer_supplies = 1,
116 },
117 {
118 .constraints = {
119 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
120 },
121 .num_consumer_supplies = 1,
122 },
123};
124
102static int wm8994_ldo_probe(struct platform_device *pdev) 125static int wm8994_ldo_probe(struct platform_device *pdev)
103{ 126{
104 struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent); 127 struct wm8994 *wm8994 = dev_get_drvdata(pdev->dev.parent);
@@ -117,13 +140,29 @@ static int wm8994_ldo_probe(struct platform_device *pdev)
117 } 140 }
118 141
119 ldo->wm8994 = wm8994; 142 ldo->wm8994 = wm8994;
143 ldo->supply = wm8994_ldo_consumer[id];
144 ldo->supply.dev_name = dev_name(wm8994->dev);
120 145
121 config.dev = wm8994->dev; 146 config.dev = wm8994->dev;
122 config.driver_data = ldo; 147 config.driver_data = ldo;
123 config.regmap = wm8994->regmap; 148 config.regmap = wm8994->regmap;
124 if (pdata) { 149 config.init_data = &ldo->init_data;
125 config.init_data = pdata->ldo[id].init_data; 150 if (pdata)
126 config.ena_gpio = pdata->ldo[id].enable; 151 config.ena_gpio = pdata->ldo[id].enable;
152 else if (wm8994->dev->of_node)
153 config.ena_gpio = wm8994->pdata.ldo[id].enable;
154
155 /* Use default constraints if none set up */
156 if (!pdata || !pdata->ldo[id].init_data || wm8994->dev->of_node) {
157 dev_dbg(wm8994->dev, "Using default init data, supply %s %s\n",
158 ldo->supply.dev_name, ldo->supply.supply);
159
160 ldo->init_data = wm8994_ldo_default[id];
161 ldo->init_data.consumer_supplies = &ldo->supply;
162 if (!config.ena_gpio)
163 ldo->init_data.constraints.valid_ops_mask = 0;
164 } else {
165 ldo->init_data = *pdata->ldo[id].init_data;
127 } 166 }
128 167
129 ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config); 168 ldo->regulator = regulator_register(&wm8994_ldo_desc[id], &config);
@@ -162,23 +201,7 @@ static struct platform_driver wm8994_ldo_driver = {
162 }, 201 },
163}; 202};
164 203
165static int __init wm8994_ldo_init(void) 204module_platform_driver(wm8994_ldo_driver);
166{
167 int ret;
168
169 ret = platform_driver_register(&wm8994_ldo_driver);
170 if (ret != 0)
171 pr_err("Failed to register Wm8994 GP LDO driver: %d\n", ret);
172
173 return ret;
174}
175subsys_initcall(wm8994_ldo_init);
176
177static void __exit wm8994_ldo_exit(void)
178{
179 platform_driver_unregister(&wm8994_ldo_driver);
180}
181module_exit(wm8994_ldo_exit);
182 205
183/* Module information */ 206/* Module information */
184MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>"); 207MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
diff --git a/include/linux/mfd/abx500/ab8500.h b/include/linux/mfd/abx500/ab8500.h
index 9db0bda446a0..84f449475c25 100644
--- a/include/linux/mfd/abx500/ab8500.h
+++ b/include/linux/mfd/abx500/ab8500.h
@@ -364,8 +364,7 @@ struct ab8500 {
364 const int *irq_reg_offset; 364 const int *irq_reg_offset;
365}; 365};
366 366
367struct regulator_reg_init; 367struct ab8500_regulator_platform_data;
368struct regulator_init_data;
369struct ab8500_gpio_platform_data; 368struct ab8500_gpio_platform_data;
370struct ab8500_codec_platform_data; 369struct ab8500_codec_platform_data;
371struct ab8500_sysctrl_platform_data; 370struct ab8500_sysctrl_platform_data;
@@ -375,19 +374,13 @@ struct ab8500_sysctrl_platform_data;
375 * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used 374 * @irq_base: start of AB8500 IRQs, AB8500_NR_IRQS will be used
376 * @pm_power_off: Should machine pm power off hook be registered or not 375 * @pm_power_off: Should machine pm power off hook be registered or not
377 * @init: board-specific initialization after detection of ab8500 376 * @init: board-specific initialization after detection of ab8500
378 * @num_regulator_reg_init: number of regulator init registers
379 * @regulator_reg_init: regulator init registers
380 * @num_regulator: number of regulators
381 * @regulator: machine-specific constraints for regulators 377 * @regulator: machine-specific constraints for regulators
382 */ 378 */
383struct ab8500_platform_data { 379struct ab8500_platform_data {
384 int irq_base; 380 int irq_base;
385 bool pm_power_off; 381 bool pm_power_off;
386 void (*init) (struct ab8500 *); 382 void (*init) (struct ab8500 *);
387 int num_regulator_reg_init; 383 struct ab8500_regulator_platform_data *regulator;
388 struct ab8500_regulator_reg_init *regulator_reg_init;
389 int num_regulator;
390 struct regulator_init_data *regulator;
391 struct abx500_gpio_platform_data *gpio; 384 struct abx500_gpio_platform_data *gpio;
392 struct ab8500_codec_platform_data *codec; 385 struct ab8500_codec_platform_data *codec;
393 struct ab8500_sysctrl_platform_data *sysctrl; 386 struct ab8500_sysctrl_platform_data *sysctrl;
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 3bbda22721ea..ecddc5173c7c 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -109,19 +109,6 @@ struct palmas_reg_init {
109 */ 109 */
110 int mode_sleep; 110 int mode_sleep;
111 111
112 /* tstep is the timestep loaded to the TSTEP register
113 *
114 * For SMPS
115 *
116 * 0: Jump (no slope control)
117 * 1: 10mV/us
118 * 2: 5mV/us
119 * 3: 2.5mV/us
120 *
121 * For LDO unused
122 */
123 int tstep;
124
125 /* voltage_sel is the bitfield loaded onto the SMPSX_VOLTAGE 112 /* voltage_sel is the bitfield loaded onto the SMPSX_VOLTAGE
126 * register. Set this is the default voltage set in OTP needs 113 * register. Set this is the default voltage set in OTP needs
127 * to be overridden. 114 * to be overridden.
@@ -154,6 +141,12 @@ enum palmas_regulators {
154 PALMAS_REG_LDO9, 141 PALMAS_REG_LDO9,
155 PALMAS_REG_LDOLN, 142 PALMAS_REG_LDOLN,
156 PALMAS_REG_LDOUSB, 143 PALMAS_REG_LDOUSB,
144 /* External regulators */
145 PALMAS_REG_REGEN1,
146 PALMAS_REG_REGEN2,
147 PALMAS_REG_REGEN3,
148 PALMAS_REG_SYSEN1,
149 PALMAS_REG_SYSEN2,
157 /* Total number of regulators */ 150 /* Total number of regulators */
158 PALMAS_NUM_REGS, 151 PALMAS_NUM_REGS,
159}; 152};
@@ -171,6 +164,9 @@ struct palmas_pmic_platform_data {
171 164
172 /* use LDO6 for vibrator control */ 165 /* use LDO6 for vibrator control */
173 int ldo6_vibrator; 166 int ldo6_vibrator;
167
168 /* Enable tracking mode of LDO8 */
169 bool enable_ldo8_tracking;
174}; 170};
175 171
176struct palmas_usb_platform_data { 172struct palmas_usb_platform_data {
@@ -331,6 +327,8 @@ struct palmas_pmic {
331 int smps457; 327 int smps457;
332 328
333 int range[PALMAS_REG_SMPS10]; 329 int range[PALMAS_REG_SMPS10];
330 unsigned int ramp_delay[PALMAS_REG_SMPS10];
331 unsigned int current_reg_mode[PALMAS_REG_SMPS10];
334}; 332};
335 333
336struct palmas_resource { 334struct palmas_resource {
diff --git a/include/linux/regulator/ab8500.h b/include/linux/regulator/ab8500.h
index 7bd73bbdfd1b..7c5ff0c55773 100644
--- a/include/linux/regulator/ab8500.h
+++ b/include/linux/regulator/ab8500.h
@@ -5,11 +5,14 @@
5 * 5 *
6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson 6 * Authors: Sundar Iyer <sundar.iyer@stericsson.com> for ST-Ericsson
7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson 7 * Bengt Jonsson <bengt.g.jonsson@stericsson.com> for ST-Ericsson
8 * Daniel Willerud <daniel.willerud@stericsson.com> for ST-Ericsson
8 */ 9 */
9 10
10#ifndef __LINUX_MFD_AB8500_REGULATOR_H 11#ifndef __LINUX_MFD_AB8500_REGULATOR_H
11#define __LINUX_MFD_AB8500_REGULATOR_H 12#define __LINUX_MFD_AB8500_REGULATOR_H
12 13
14#include <linux/platform_device.h>
15
13/* AB8500 regulators */ 16/* AB8500 regulators */
14enum ab8500_regulator_id { 17enum ab8500_regulator_id {
15 AB8500_LDO_AUX1, 18 AB8500_LDO_AUX1,
@@ -17,7 +20,6 @@ enum ab8500_regulator_id {
17 AB8500_LDO_AUX3, 20 AB8500_LDO_AUX3,
18 AB8500_LDO_INTCORE, 21 AB8500_LDO_INTCORE,
19 AB8500_LDO_TVOUT, 22 AB8500_LDO_TVOUT,
20 AB8500_LDO_USB,
21 AB8500_LDO_AUDIO, 23 AB8500_LDO_AUDIO,
22 AB8500_LDO_ANAMIC1, 24 AB8500_LDO_ANAMIC1,
23 AB8500_LDO_ANAMIC2, 25 AB8500_LDO_ANAMIC2,
@@ -26,7 +28,28 @@ enum ab8500_regulator_id {
26 AB8500_NUM_REGULATORS, 28 AB8500_NUM_REGULATORS,
27}; 29};
28 30
29/* AB9450 regulators */ 31/* AB8505 regulators */
32enum ab8505_regulator_id {
33 AB8505_LDO_AUX1,
34 AB8505_LDO_AUX2,
35 AB8505_LDO_AUX3,
36 AB8505_LDO_AUX4,
37 AB8505_LDO_AUX5,
38 AB8505_LDO_AUX6,
39 AB8505_LDO_INTCORE,
40 AB8505_LDO_ADC,
41 AB8505_LDO_USB,
42 AB8505_LDO_AUDIO,
43 AB8505_LDO_ANAMIC1,
44 AB8505_LDO_ANAMIC2,
45 AB8505_LDO_AUX8,
46 AB8505_LDO_ANA,
47 AB8505_SYSCLKREQ_2,
48 AB8505_SYSCLKREQ_4,
49 AB8505_NUM_REGULATORS,
50};
51
52/* AB9540 regulators */
30enum ab9540_regulator_id { 53enum ab9540_regulator_id {
31 AB9540_LDO_AUX1, 54 AB9540_LDO_AUX1,
32 AB9540_LDO_AUX2, 55 AB9540_LDO_AUX2,
@@ -45,16 +68,39 @@ enum ab9540_regulator_id {
45 AB9540_NUM_REGULATORS, 68 AB9540_NUM_REGULATORS,
46}; 69};
47 70
48/* AB8500 and AB9540 register initialization */ 71/* AB8540 regulators */
72enum ab8540_regulator_id {
73 AB8540_LDO_AUX1,
74 AB8540_LDO_AUX2,
75 AB8540_LDO_AUX3,
76 AB8540_LDO_AUX4,
77 AB8540_LDO_AUX5,
78 AB8540_LDO_AUX6,
79 AB8540_LDO_INTCORE,
80 AB8540_LDO_TVOUT,
81 AB8540_LDO_AUDIO,
82 AB8540_LDO_ANAMIC1,
83 AB8540_LDO_ANAMIC2,
84 AB8540_LDO_DMIC,
85 AB8540_LDO_ANA,
86 AB8540_LDO_SDIO,
87 AB8540_SYSCLKREQ_2,
88 AB8540_SYSCLKREQ_4,
89 AB8540_NUM_REGULATORS,
90};
91
92/* AB8500, AB8505, and AB9540 register initialization */
49struct ab8500_regulator_reg_init { 93struct ab8500_regulator_reg_init {
50 int id; 94 int id;
95 u8 mask;
51 u8 value; 96 u8 value;
52}; 97};
53 98
54#define INIT_REGULATOR_REGISTER(_id, _value) \ 99#define INIT_REGULATOR_REGISTER(_id, _mask, _value) \
55 { \ 100 { \
56 .id = _id, \ 101 .id = _id, \
57 .value = _value, \ 102 .mask = _mask, \
103 .value = _value, \
58 } 104 }
59 105
60/* AB8500 registers */ 106/* AB8500 registers */
@@ -86,10 +132,58 @@ enum ab8500_regulator_reg {
86 AB8500_REGUCTRL2SPARE, 132 AB8500_REGUCTRL2SPARE,
87 AB8500_REGUCTRLDISCH, 133 AB8500_REGUCTRLDISCH,
88 AB8500_REGUCTRLDISCH2, 134 AB8500_REGUCTRLDISCH2,
89 AB8500_VSMPS1SEL1,
90 AB8500_NUM_REGULATOR_REGISTERS, 135 AB8500_NUM_REGULATOR_REGISTERS,
91}; 136};
92 137
138/* AB8505 registers */
139enum ab8505_regulator_reg {
140 AB8505_REGUREQUESTCTRL1,
141 AB8505_REGUREQUESTCTRL2,
142 AB8505_REGUREQUESTCTRL3,
143 AB8505_REGUREQUESTCTRL4,
144 AB8505_REGUSYSCLKREQ1HPVALID1,
145 AB8505_REGUSYSCLKREQ1HPVALID2,
146 AB8505_REGUHWHPREQ1VALID1,
147 AB8505_REGUHWHPREQ1VALID2,
148 AB8505_REGUHWHPREQ2VALID1,
149 AB8505_REGUHWHPREQ2VALID2,
150 AB8505_REGUSWHPREQVALID1,
151 AB8505_REGUSWHPREQVALID2,
152 AB8505_REGUSYSCLKREQVALID1,
153 AB8505_REGUSYSCLKREQVALID2,
154 AB8505_REGUVAUX4REQVALID,
155 AB8505_REGUMISC1,
156 AB8505_VAUDIOSUPPLY,
157 AB8505_REGUCTRL1VAMIC,
158 AB8505_VSMPSAREGU,
159 AB8505_VSMPSBREGU,
160 AB8505_VSAFEREGU, /* NOTE! PRCMU register */
161 AB8505_VPLLVANAREGU,
162 AB8505_EXTSUPPLYREGU,
163 AB8505_VAUX12REGU,
164 AB8505_VRF1VAUX3REGU,
165 AB8505_VSMPSASEL1,
166 AB8505_VSMPSASEL2,
167 AB8505_VSMPSASEL3,
168 AB8505_VSMPSBSEL1,
169 AB8505_VSMPSBSEL2,
170 AB8505_VSMPSBSEL3,
171 AB8505_VSAFESEL1, /* NOTE! PRCMU register */
172 AB8505_VSAFESEL2, /* NOTE! PRCMU register */
173 AB8505_VSAFESEL3, /* NOTE! PRCMU register */
174 AB8505_VAUX1SEL,
175 AB8505_VAUX2SEL,
176 AB8505_VRF1VAUX3SEL,
177 AB8505_VAUX4REQCTRL,
178 AB8505_VAUX4REGU,
179 AB8505_VAUX4SEL,
180 AB8505_REGUCTRLDISCH,
181 AB8505_REGUCTRLDISCH2,
182 AB8505_REGUCTRLDISCH3,
183 AB8505_CTRLVAUX5,
184 AB8505_CTRLVAUX6,
185 AB8505_NUM_REGULATOR_REGISTERS,
186};
93 187
94/* AB9540 registers */ 188/* AB9540 registers */
95enum ab9540_regulator_reg { 189enum ab9540_regulator_reg {
@@ -139,4 +233,111 @@ enum ab9540_regulator_reg {
139 AB9540_NUM_REGULATOR_REGISTERS, 233 AB9540_NUM_REGULATOR_REGISTERS,
140}; 234};
141 235
236/* AB8540 registers */
237enum ab8540_regulator_reg {
238 AB8540_REGUREQUESTCTRL1,
239 AB8540_REGUREQUESTCTRL2,
240 AB8540_REGUREQUESTCTRL3,
241 AB8540_REGUREQUESTCTRL4,
242 AB8540_REGUSYSCLKREQ1HPVALID1,
243 AB8540_REGUSYSCLKREQ1HPVALID2,
244 AB8540_REGUHWHPREQ1VALID1,
245 AB8540_REGUHWHPREQ1VALID2,
246 AB8540_REGUHWHPREQ2VALID1,
247 AB8540_REGUHWHPREQ2VALID2,
248 AB8540_REGUSWHPREQVALID1,
249 AB8540_REGUSWHPREQVALID2,
250 AB8540_REGUSYSCLKREQVALID1,
251 AB8540_REGUSYSCLKREQVALID2,
252 AB8540_REGUVAUX4REQVALID,
253 AB8540_REGUVAUX5REQVALID,
254 AB8540_REGUVAUX6REQVALID,
255 AB8540_REGUVCLKBREQVALID,
256 AB8540_REGUVRF1REQVALID,
257 AB8540_REGUMISC1,
258 AB8540_VAUDIOSUPPLY,
259 AB8540_REGUCTRL1VAMIC,
260 AB8540_VHSIC,
261 AB8540_VSDIO,
262 AB8540_VSMPS1REGU,
263 AB8540_VSMPS2REGU,
264 AB8540_VSMPS3REGU,
265 AB8540_VPLLVANAREGU,
266 AB8540_EXTSUPPLYREGU,
267 AB8540_VAUX12REGU,
268 AB8540_VRF1VAUX3REGU,
269 AB8540_VSMPS1SEL1,
270 AB8540_VSMPS1SEL2,
271 AB8540_VSMPS1SEL3,
272 AB8540_VSMPS2SEL1,
273 AB8540_VSMPS2SEL2,
274 AB8540_VSMPS2SEL3,
275 AB8540_VSMPS3SEL1,
276 AB8540_VSMPS3SEL2,
277 AB8540_VAUX1SEL,
278 AB8540_VAUX2SEL,
279 AB8540_VRF1VAUX3SEL,
280 AB8540_REGUCTRL2SPARE,
281 AB8540_VAUX4REQCTRL,
282 AB8540_VAUX4REGU,
283 AB8540_VAUX4SEL,
284 AB8540_VAUX5REQCTRL,
285 AB8540_VAUX5REGU,
286 AB8540_VAUX5SEL,
287 AB8540_VAUX6REQCTRL,
288 AB8540_VAUX6REGU,
289 AB8540_VAUX6SEL,
290 AB8540_VCLKBREQCTRL,
291 AB8540_VCLKBREGU,
292 AB8540_VCLKBSEL,
293 AB8540_VRF1REQCTRL,
294 AB8540_REGUCTRLDISCH,
295 AB8540_REGUCTRLDISCH2,
296 AB8540_REGUCTRLDISCH3,
297 AB8540_REGUCTRLDISCH4,
298 AB8540_VSIMSYSCLKCTRL,
299 AB8540_VANAVPLLSEL,
300 AB8540_NUM_REGULATOR_REGISTERS,
301};
302
303/* AB8500 external regulators */
304struct ab8500_ext_regulator_cfg {
305 bool hwreq; /* requires hw mode or high power mode */
306};
307
308enum ab8500_ext_regulator_id {
309 AB8500_EXT_SUPPLY1,
310 AB8500_EXT_SUPPLY2,
311 AB8500_EXT_SUPPLY3,
312 AB8500_NUM_EXT_REGULATORS,
313};
314
315/* AB8500 regulator platform data */
316struct ab8500_regulator_platform_data {
317 int num_reg_init;
318 struct ab8500_regulator_reg_init *reg_init;
319 int num_regulator;
320 struct regulator_init_data *regulator;
321 int num_ext_regulator;
322 struct regulator_init_data *ext_regulator;
323};
324
325#ifdef CONFIG_REGULATOR_AB8500_DEBUG
326int ab8500_regulator_debug_init(struct platform_device *pdev);
327int ab8500_regulator_debug_exit(struct platform_device *pdev);
328#else
329static inline int ab8500_regulator_debug_init(struct platform_device *pdev)
330{
331 return 0;
332}
333static inline int ab8500_regulator_debug_exit(struct platform_device *pdev)
334{
335 return 0;
336}
337#endif
338
339/* AB8500 external regulator functions. */
340int ab8500_ext_regulator_init(struct platform_device *pdev);
341void ab8500_ext_regulator_exit(struct platform_device *pdev);
342
142#endif 343#endif
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 7bc732ce6e50..145022a83085 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -141,18 +141,18 @@ void regulator_put(struct regulator *regulator);
141void devm_regulator_put(struct regulator *regulator); 141void devm_regulator_put(struct regulator *regulator);
142 142
143/* regulator output control and status */ 143/* regulator output control and status */
144int regulator_enable(struct regulator *regulator); 144int __must_check regulator_enable(struct regulator *regulator);
145int regulator_disable(struct regulator *regulator); 145int regulator_disable(struct regulator *regulator);
146int regulator_force_disable(struct regulator *regulator); 146int regulator_force_disable(struct regulator *regulator);
147int regulator_is_enabled(struct regulator *regulator); 147int regulator_is_enabled(struct regulator *regulator);
148int regulator_disable_deferred(struct regulator *regulator, int ms); 148int regulator_disable_deferred(struct regulator *regulator, int ms);
149 149
150int regulator_bulk_get(struct device *dev, int num_consumers, 150int __must_check regulator_bulk_get(struct device *dev, int num_consumers,
151 struct regulator_bulk_data *consumers); 151 struct regulator_bulk_data *consumers);
152int devm_regulator_bulk_get(struct device *dev, int num_consumers, 152int __must_check devm_regulator_bulk_get(struct device *dev, int num_consumers,
153 struct regulator_bulk_data *consumers); 153 struct regulator_bulk_data *consumers);
154int regulator_bulk_enable(int num_consumers, 154int __must_check regulator_bulk_enable(int num_consumers,
155 struct regulator_bulk_data *consumers); 155 struct regulator_bulk_data *consumers);
156int regulator_bulk_disable(int num_consumers, 156int regulator_bulk_disable(int num_consumers,
157 struct regulator_bulk_data *consumers); 157 struct regulator_bulk_data *consumers);
158int regulator_bulk_force_disable(int num_consumers, 158int regulator_bulk_force_disable(int num_consumers,
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 7df93f52db08..6700cc94bdd1 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -22,6 +22,7 @@
22struct regmap; 22struct regmap;
23struct regulator_dev; 23struct regulator_dev;
24struct regulator_init_data; 24struct regulator_init_data;
25struct regulator_enable_gpio;
25 26
26enum regulator_status { 27enum regulator_status {
27 REGULATOR_STATUS_OFF, 28 REGULATOR_STATUS_OFF,
@@ -199,6 +200,8 @@ enum regulator_type {
199 * output when using regulator_set_voltage_sel_regmap 200 * output when using regulator_set_voltage_sel_regmap
200 * @enable_reg: Register for control when using regmap enable/disable ops 201 * @enable_reg: Register for control when using regmap enable/disable ops
201 * @enable_mask: Mask for control when using regmap enable/disable ops 202 * @enable_mask: Mask for control when using regmap enable/disable ops
203 * @enable_is_inverted: A flag to indicate set enable_mask bits to disable
204 * when using regulator_enable_regmap and friends APIs.
202 * @bypass_reg: Register for control when using regmap set_bypass 205 * @bypass_reg: Register for control when using regmap set_bypass
203 * @bypass_mask: Mask for control when using regmap set_bypass 206 * @bypass_mask: Mask for control when using regmap set_bypass
204 * 207 *
@@ -228,6 +231,7 @@ struct regulator_desc {
228 unsigned int apply_bit; 231 unsigned int apply_bit;
229 unsigned int enable_reg; 232 unsigned int enable_reg;
230 unsigned int enable_mask; 233 unsigned int enable_mask;
234 bool enable_is_inverted;
231 unsigned int bypass_reg; 235 unsigned int bypass_reg;
232 unsigned int bypass_mask; 236 unsigned int bypass_mask;
233 237
@@ -302,8 +306,7 @@ struct regulator_dev {
302 306
303 struct dentry *debugfs; 307 struct dentry *debugfs;
304 308
305 int ena_gpio; 309 struct regulator_enable_gpio *ena_pin;
306 unsigned int ena_gpio_invert:1;
307 unsigned int ena_gpio_state:1; 310 unsigned int ena_gpio_state:1;
308}; 311};
309 312
@@ -329,6 +332,8 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
329 int min_uV, int max_uV); 332 int min_uV, int max_uV);
330int regulator_map_voltage_iterate(struct regulator_dev *rdev, 333int regulator_map_voltage_iterate(struct regulator_dev *rdev,
331 int min_uV, int max_uV); 334 int min_uV, int max_uV);
335int regulator_map_voltage_ascend(struct regulator_dev *rdev,
336 int min_uV, int max_uV);
332int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev); 337int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev);
333int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel); 338int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel);
334int regulator_is_enabled_regmap(struct regulator_dev *rdev); 339int regulator_is_enabled_regmap(struct regulator_dev *rdev);
diff --git a/include/linux/regulator/max8952.h b/include/linux/regulator/max8952.h
index 45e42855ad05..4dbb63a1d4ab 100644
--- a/include/linux/regulator/max8952.h
+++ b/include/linux/regulator/max8952.h
@@ -122,13 +122,13 @@ struct max8952_platform_data {
122 int gpio_vid1; 122 int gpio_vid1;
123 int gpio_en; 123 int gpio_en;
124 124
125 u8 default_mode; 125 u32 default_mode;
126 u8 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */ 126 u32 dvs_mode[MAX8952_NUM_DVS_MODE]; /* MAX8952_DVS_MODEx_XXXXmV */
127 127
128 u8 sync_freq; 128 u32 sync_freq;
129 u8 ramp_speed; 129 u32 ramp_speed;
130 130
131 struct regulator_init_data reg_data; 131 struct regulator_init_data *reg_data;
132}; 132};
133 133
134 134