aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-07-04 14:55:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-07-04 14:55:21 -0400
commitd62eb5edf6643ede7e48b4d03ba972c0e8949acc (patch)
treeaeee580b787976558eb6c67173a42b77168d3e7a
parent36b8042262e7fbabf62ab300361399bec6499b6f (diff)
parent8d67f64f7739464c352d4b167ed1748f3b2c1f44 (diff)
Merge tag 'regulator-v4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates from Mark Brown: "A quiet release for the regulator API, a series of fairly small fixes plus one new feature and a few new drivers: - Support for regulators with different settling times for rising and falling voltage changes. - New drivers for Allwinner AXP803, HiSilicon HI6421V530 and TI LP87565" * tag 'regulator-v4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (21 commits) regulator: core: Fix size limit of supply_map regulator: core: Fix voltage change propagations to supply regulators regulator: lp87565: Fix the initial voltage range regulator: tps65910: wire up sleep control configuration regulator: hi6421v530: Describe consumed platform device regulator: tps65910: check TPS65910_NUM_REGS at build time regulator: core: Prioritise consumer mappings over regulator name regulator: lp87565: Fix the GPL header regulator: hi6421: Describe consumed platform device regulator: hi6421v530: add driver for hi6421v530 voltage regulator regulator: da9061: BUCK and LDO regulator driver regulator: bd9571mwv: Statize local symbols regulator: tps65917: Add support for SMPS12 regulator: lp87565: Add support for lp87565 PMIC regulators regulator: axp20x-regulator: add support for AXP803 regulator: lp8755: fix spelling mistake "acceess" -> "access" regulator: Allow for asymmetric settling times regulator: DT: Add properties for asymmetric settling times regulator: palmas: Drop unnecessary static MAINTAINERS: Update MAX77802 PMIC entry ...
-rw-r--r--Documentation/devicetree/bindings/mfd/tps65910.txt4
-rw-r--r--Documentation/devicetree/bindings/regulator/regulator.txt8
-rw-r--r--MAINTAINERS6
-rw-r--r--drivers/mfd/tps65910.c22
-rw-r--r--drivers/regulator/Kconfig22
-rw-r--r--drivers/regulator/Makefile2
-rw-r--r--drivers/regulator/axp20x-regulator.c153
-rw-r--r--drivers/regulator/bd9571mwv-regulator.c12
-rw-r--r--drivers/regulator/core.c55
-rw-r--r--drivers/regulator/da9062-regulator.c303
-rw-r--r--drivers/regulator/hi6421-regulator.c7
-rw-r--r--drivers/regulator/hi6421v530-regulator.c214
-rw-r--r--drivers/regulator/lp8755.c14
-rw-r--r--drivers/regulator/lp87565-regulator.c236
-rw-r--r--drivers/regulator/max8997-regulator.c9
-rw-r--r--drivers/regulator/of_regulator.c19
-rw-r--r--drivers/regulator/palmas-regulator.c20
-rw-r--r--drivers/regulator/tps65910-regulator.c5
-rw-r--r--include/linux/mfd/axp20x.h37
-rw-r--r--include/linux/mfd/palmas.h2
-rw-r--r--include/linux/mfd/tps65910.h2
-rw-r--r--include/linux/regulator/machine.h6
22 files changed, 1057 insertions, 101 deletions
diff --git a/Documentation/devicetree/bindings/mfd/tps65910.txt b/Documentation/devicetree/bindings/mfd/tps65910.txt
index 38833e63a59f..8af1202b381d 100644
--- a/Documentation/devicetree/bindings/mfd/tps65910.txt
+++ b/Documentation/devicetree/bindings/mfd/tps65910.txt
@@ -61,6 +61,10 @@ Optional properties:
61 There should be 9 entries here, one for each gpio. 61 There should be 9 entries here, one for each gpio.
62- ti,system-power-controller: Telling whether or not this pmic is controlling 62- ti,system-power-controller: Telling whether or not this pmic is controlling
63 the system power. 63 the system power.
64- ti,sleep-enable: Enable SLEEP state.
65- ti,sleep-keep-therm: Keep thermal monitoring on in sleep state.
66- ti,sleep-keep-ck32k: Keep the 32KHz clock output on in sleep state.
67- ti,sleep-keep-hsclk: Keep high speed internal clock on in sleep state.
64 68
65Regulator Optional properties: 69Regulator Optional properties:
66- ti,regulator-ext-sleep-control: enable external sleep 70- ti,regulator-ext-sleep-control: enable external sleep
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt
index d18edb075e1c..378f6dc8b8bd 100644
--- a/Documentation/devicetree/bindings/regulator/regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/regulator.txt
@@ -24,6 +24,14 @@ Optional properties:
24- regulator-settling-time-us: Settling time, in microseconds, for voltage 24- regulator-settling-time-us: Settling time, in microseconds, for voltage
25 change if regulator have the constant time for any level voltage change. 25 change if regulator have the constant time for any level voltage change.
26 This is useful when regulator have exponential voltage change. 26 This is useful when regulator have exponential voltage change.
27- regulator-settling-time-up-us: Settling time, in microseconds, for voltage
28 increase if the regulator needs a constant time to settle after voltage
29 increases of any level. This is useful for regulators with exponential
30 voltage changes.
31- regulator-settling-time-down-us: Settling time, in microseconds, for voltage
32 decrease if the regulator needs a constant time to settle after voltage
33 decreases of any level. This is useful for regulators with exponential
34 voltage changes.
27- regulator-soft-start: Enable soft start so that voltage ramps slowly 35- regulator-soft-start: Enable soft start so that voltage ramps slowly
28- regulator-state-mem sub-root node for Suspend-to-RAM mode 36- regulator-state-mem sub-root node for Suspend-to-RAM mode
29 : suspend to memory, the device goes to sleep, but all data stored in memory, 37 : suspend to memory, the device goes to sleep, but all data stored in memory,
diff --git a/MAINTAINERS b/MAINTAINERS
index 67ab1aba1fcc..1f949b5a39d3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8076,11 +8076,11 @@ S: Supported
8076F: drivers/power/supply/max14577_charger.c 8076F: drivers/power/supply/max14577_charger.c
8077F: drivers/power/supply/max77693_charger.c 8077F: drivers/power/supply/max77693_charger.c
8078 8078
8079MAXIM MAX77802 MULTIFUNCTION PMIC DEVICE DRIVERS 8079MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER
8080M: Javier Martinez Canillas <javier@osg.samsung.com> 8080M: Javier Martinez Canillas <javier@dowhile0.org>
8081L: linux-kernel@vger.kernel.org 8081L: linux-kernel@vger.kernel.org
8082S: Supported 8082S: Supported
8083F: drivers/*/*max77802*.c 8083F: drivers/regulator/max77802-regulator.c
8084F: Documentation/devicetree/bindings/*/*max77802.txt 8084F: Documentation/devicetree/bindings/*/*max77802.txt
8085F: include/dt-bindings/*/*max77802.h 8085F: include/dt-bindings/*/*max77802.h
8086 8086
diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
index 11cab1582f2f..8263605f6d2f 100644
--- a/drivers/mfd/tps65910.c
+++ b/drivers/mfd/tps65910.c
@@ -328,11 +328,7 @@ static int tps65910_sleepinit(struct tps65910 *tps65910,
328 goto err_sleep_init; 328 goto err_sleep_init;
329 } 329 }
330 330
331 /* Return if there is no sleep keepon data. */ 331 if (pmic_pdata->slp_keepon.therm_keepon) {
332 if (!pmic_pdata->slp_keepon)
333 return 0;
334
335 if (pmic_pdata->slp_keepon->therm_keepon) {
336 ret = tps65910_reg_set_bits(tps65910, 332 ret = tps65910_reg_set_bits(tps65910,
337 TPS65910_SLEEP_KEEP_RES_ON, 333 TPS65910_SLEEP_KEEP_RES_ON,
338 SLEEP_KEEP_RES_ON_THERM_KEEPON_MASK); 334 SLEEP_KEEP_RES_ON_THERM_KEEPON_MASK);
@@ -342,7 +338,7 @@ static int tps65910_sleepinit(struct tps65910 *tps65910,
342 } 338 }
343 } 339 }
344 340
345 if (pmic_pdata->slp_keepon->clkout32k_keepon) { 341 if (pmic_pdata->slp_keepon.clkout32k_keepon) {
346 ret = tps65910_reg_set_bits(tps65910, 342 ret = tps65910_reg_set_bits(tps65910,
347 TPS65910_SLEEP_KEEP_RES_ON, 343 TPS65910_SLEEP_KEEP_RES_ON,
348 SLEEP_KEEP_RES_ON_CLKOUT32K_KEEPON_MASK); 344 SLEEP_KEEP_RES_ON_CLKOUT32K_KEEPON_MASK);
@@ -352,7 +348,7 @@ static int tps65910_sleepinit(struct tps65910 *tps65910,
352 } 348 }
353 } 349 }
354 350
355 if (pmic_pdata->slp_keepon->i2chs_keepon) { 351 if (pmic_pdata->slp_keepon.i2chs_keepon) {
356 ret = tps65910_reg_set_bits(tps65910, 352 ret = tps65910_reg_set_bits(tps65910,
357 TPS65910_SLEEP_KEEP_RES_ON, 353 TPS65910_SLEEP_KEEP_RES_ON,
358 SLEEP_KEEP_RES_ON_I2CHS_KEEPON_MASK); 354 SLEEP_KEEP_RES_ON_I2CHS_KEEPON_MASK);
@@ -415,6 +411,18 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
415 prop = of_property_read_bool(np, "ti,en-ck32k-xtal"); 411 prop = of_property_read_bool(np, "ti,en-ck32k-xtal");
416 board_info->en_ck32k_xtal = prop; 412 board_info->en_ck32k_xtal = prop;
417 413
414 prop = of_property_read_bool(np, "ti,sleep-enable");
415 board_info->en_dev_slp = prop;
416
417 prop = of_property_read_bool(np, "ti,sleep-keep-therm");
418 board_info->slp_keepon.therm_keepon = prop;
419
420 prop = of_property_read_bool(np, "ti,sleep-keep-ck32k");
421 board_info->slp_keepon.clkout32k_keepon = prop;
422
423 prop = of_property_read_bool(np, "ti,sleep-keep-hsclk");
424 board_info->slp_keepon.i2chs_keepon = prop;
425
418 board_info->irq = client->irq; 426 board_info->irq = client->irq;
419 board_info->irq_base = -1; 427 board_info->irq_base = -1;
420 board_info->pm_off = of_property_read_bool(np, 428 board_info->pm_off = of_property_read_bool(np,
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 48db87d6dfef..99b9362331b5 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -214,11 +214,11 @@ config REGULATOR_DA9055
214 will be called da9055-regulator. 214 will be called da9055-regulator.
215 215
216config REGULATOR_DA9062 216config REGULATOR_DA9062
217 tristate "Dialog Semiconductor DA9062 regulators" 217 tristate "Dialog Semiconductor DA9061/62 regulators"
218 depends on MFD_DA9062 218 depends on MFD_DA9062
219 help 219 help
220 Say y here to support the BUCKs and LDOs regulators found on 220 Say y here to support the BUCKs and LDOs regulators found on
221 DA9062 PMICs. 221 DA9061 and DA9062 PMICs.
222 222
223 This driver can also be built as a module. If so, the module 223 This driver can also be built as a module. If so, the module
224 will be called da9062-regulator. 224 will be called da9062-regulator.
@@ -296,6 +296,16 @@ config REGULATOR_HI6421
296 21 general purpose LDOs, 3 dedicated LDOs, and 5 BUCKs. All 296 21 general purpose LDOs, 3 dedicated LDOs, and 5 BUCKs. All
297 of them come with support to either ECO (idle) or sleep mode. 297 of them come with support to either ECO (idle) or sleep mode.
298 298
299config REGULATOR_HI6421V530
300 tristate "HiSilicon Hi6421v530 PMIC voltage regulator support"
301 depends on MFD_HI6421_PMIC && OF
302 help
303 This driver provides support for the voltage regulators on
304 HiSilicon Hi6421v530 PMU / Codec IC.
305 Hi6421v530 is a multi-function device which, on regulator part,
306 provides 5 general purpose LDOs, and all of them come with support
307 to either ECO (idle) or sleep mode.
308
299config REGULATOR_HI655X 309config REGULATOR_HI655X
300 tristate "Hisilicon HI655X PMIC regulators support" 310 tristate "Hisilicon HI655X PMIC regulators support"
301 depends on ARCH_HISI || COMPILE_TEST 311 depends on ARCH_HISI || COMPILE_TEST
@@ -365,6 +375,14 @@ config REGULATOR_LP8755
365 chip contains six step-down DC/DC converters which can support 375 chip contains six step-down DC/DC converters which can support
366 9 mode multiphase configuration. 376 9 mode multiphase configuration.
367 377
378config REGULATOR_LP87565
379 tristate "TI LP87565 Power regulators"
380 depends on MFD_TI_LP87565 && OF
381 help
382 This driver supports LP87565 voltage regulator chips. LP87565
383 provides four step-down converters. It supports software based
384 voltage control for different voltage domains
385
368config REGULATOR_LP8788 386config REGULATOR_LP8788
369 tristate "TI LP8788 Power Regulators" 387 tristate "TI LP8788 Power Regulators"
370 depends on MFD_LP8788 388 depends on MFD_LP8788
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index dc3503fb3e30..95b1e86ae692 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_REGULATOR_DB8500_PRCMU) += db8500-prcmu.o
38obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o 38obj-$(CONFIG_REGULATOR_FAN53555) += fan53555.o
39obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o 39obj-$(CONFIG_REGULATOR_GPIO) += gpio-regulator.o
40obj-$(CONFIG_REGULATOR_HI6421) += hi6421-regulator.o 40obj-$(CONFIG_REGULATOR_HI6421) += hi6421-regulator.o
41obj-$(CONFIG_REGULATOR_HI6421V530) += hi6421v530-regulator.o
41obj-$(CONFIG_REGULATOR_HI655X) += hi655x-regulator.o 42obj-$(CONFIG_REGULATOR_HI655X) += hi655x-regulator.o
42obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o 43obj-$(CONFIG_REGULATOR_ISL6271A) += isl6271a-regulator.o
43obj-$(CONFIG_REGULATOR_ISL9305) += isl9305.o 44obj-$(CONFIG_REGULATOR_ISL9305) += isl9305.o
@@ -46,6 +47,7 @@ obj-$(CONFIG_REGULATOR_LP3971) += lp3971.o
46obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o 47obj-$(CONFIG_REGULATOR_LP3972) += lp3972.o
47obj-$(CONFIG_REGULATOR_LP872X) += lp872x.o 48obj-$(CONFIG_REGULATOR_LP872X) += lp872x.o
48obj-$(CONFIG_REGULATOR_LP873X) += lp873x-regulator.o 49obj-$(CONFIG_REGULATOR_LP873X) += lp873x-regulator.o
50obj-$(CONFIG_REGULATOR_LP87565) += lp87565-regulator.o
49obj-$(CONFIG_REGULATOR_LP8788) += lp8788-buck.o 51obj-$(CONFIG_REGULATOR_LP8788) += lp8788-buck.o
50obj-$(CONFIG_REGULATOR_LP8788) += lp8788-ldo.o 52obj-$(CONFIG_REGULATOR_LP8788) += lp8788-ldo.o
51obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o 53obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index 0b9d4e3e52c7..e2608fe770b9 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -244,6 +244,82 @@ static const struct regulator_desc axp22x_drivevbus_regulator = {
244 .ops = &axp20x_ops_sw, 244 .ops = &axp20x_ops_sw,
245}; 245};
246 246
247static const struct regulator_linear_range axp803_dcdc234_ranges[] = {
248 REGULATOR_LINEAR_RANGE(500000, 0x0, 0x46, 10000),
249 REGULATOR_LINEAR_RANGE(1220000, 0x47, 0x4b, 20000),
250};
251
252static const struct regulator_linear_range axp803_dcdc5_ranges[] = {
253 REGULATOR_LINEAR_RANGE(800000, 0x0, 0x20, 10000),
254 REGULATOR_LINEAR_RANGE(1140000, 0x21, 0x44, 20000),
255};
256
257static const struct regulator_linear_range axp803_dcdc6_ranges[] = {
258 REGULATOR_LINEAR_RANGE(600000, 0x0, 0x32, 10000),
259 REGULATOR_LINEAR_RANGE(1120000, 0x33, 0x47, 20000),
260};
261
262/* AXP806's CLDO2 and AXP809's DLDO1 shares the same range */
263static const struct regulator_linear_range axp803_dldo2_ranges[] = {
264 REGULATOR_LINEAR_RANGE(700000, 0x0, 0x1a, 100000),
265 REGULATOR_LINEAR_RANGE(3400000, 0x1b, 0x1f, 200000),
266};
267
268static const struct regulator_desc axp803_regulators[] = {
269 AXP_DESC(AXP803, DCDC1, "dcdc1", "vin1", 1600, 3400, 100,
270 AXP803_DCDC1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(0)),
271 AXP_DESC_RANGES(AXP803, DCDC2, "dcdc2", "vin2", axp803_dcdc234_ranges,
272 76, AXP803_DCDC2_V_OUT, 0x7f, AXP22X_PWR_OUT_CTRL1,
273 BIT(1)),
274 AXP_DESC_RANGES(AXP803, DCDC3, "dcdc3", "vin3", axp803_dcdc234_ranges,
275 76, AXP803_DCDC3_V_OUT, 0x7f, AXP22X_PWR_OUT_CTRL1,
276 BIT(2)),
277 AXP_DESC_RANGES(AXP803, DCDC4, "dcdc4", "vin4", axp803_dcdc234_ranges,
278 76, AXP803_DCDC4_V_OUT, 0x7f, AXP22X_PWR_OUT_CTRL1,
279 BIT(3)),
280 AXP_DESC_RANGES(AXP803, DCDC5, "dcdc5", "vin5", axp803_dcdc5_ranges,
281 68, AXP803_DCDC5_V_OUT, 0x7f, AXP22X_PWR_OUT_CTRL1,
282 BIT(4)),
283 AXP_DESC_RANGES(AXP803, DCDC6, "dcdc6", "vin6", axp803_dcdc6_ranges,
284 72, AXP803_DCDC6_V_OUT, 0x7f, AXP22X_PWR_OUT_CTRL1,
285 BIT(5)),
286 /* secondary switchable output of DCDC1 */
287 AXP_DESC_SW(AXP803, DC1SW, "dc1sw", NULL, AXP22X_PWR_OUT_CTRL2,
288 BIT(7)),
289 AXP_DESC(AXP803, ALDO1, "aldo1", "aldoin", 700, 3300, 100,
290 AXP22X_ALDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL3, BIT(5)),
291 AXP_DESC(AXP803, ALDO2, "aldo2", "aldoin", 700, 3300, 100,
292 AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL3, BIT(6)),
293 AXP_DESC(AXP803, ALDO3, "aldo3", "aldoin", 700, 3300, 100,
294 AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL3, BIT(7)),
295 AXP_DESC(AXP803, DLDO1, "dldo1", "dldoin", 700, 3300, 100,
296 AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(3)),
297 AXP_DESC_RANGES(AXP803, DLDO2, "dldo2", "dldoin", axp803_dldo2_ranges,
298 32, AXP22X_DLDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2,
299 BIT(4)),
300 AXP_DESC(AXP803, DLDO3, "dldo3", "dldoin", 700, 3300, 100,
301 AXP22X_DLDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)),
302 AXP_DESC(AXP803, DLDO4, "dldo4", "dldoin", 700, 3300, 100,
303 AXP22X_DLDO4_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(6)),
304 AXP_DESC(AXP803, ELDO1, "eldo1", "eldoin", 700, 1900, 50,
305 AXP22X_ELDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(0)),
306 AXP_DESC(AXP803, ELDO2, "eldo2", "eldoin", 700, 1900, 50,
307 AXP22X_ELDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(1)),
308 AXP_DESC(AXP803, ELDO3, "eldo3", "eldoin", 700, 1900, 50,
309 AXP22X_ELDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(2)),
310 AXP_DESC(AXP803, FLDO1, "fldo1", "fldoin", 700, 1450, 50,
311 AXP803_FLDO1_V_OUT, 0x0f, AXP22X_PWR_OUT_CTRL3, BIT(2)),
312 AXP_DESC(AXP803, FLDO2, "fldo2", "fldoin", 700, 1450, 50,
313 AXP803_FLDO2_V_OUT, 0x0f, AXP22X_PWR_OUT_CTRL3, BIT(3)),
314 AXP_DESC_IO(AXP803, LDO_IO0, "ldo-io0", "ips", 700, 3300, 100,
315 AXP22X_LDO_IO0_V_OUT, 0x1f, AXP20X_GPIO0_CTRL, 0x07,
316 AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
317 AXP_DESC_IO(AXP803, LDO_IO1, "ldo-io1", "ips", 700, 3300, 100,
318 AXP22X_LDO_IO1_V_OUT, 0x1f, AXP20X_GPIO1_CTRL, 0x07,
319 AXP22X_IO_ENABLED, AXP22X_IO_DISABLED),
320 AXP_DESC_FIXED(AXP803, RTC_LDO, "rtc-ldo", "ips", 3000),
321};
322
247static const struct regulator_linear_range axp806_dcdca_ranges[] = { 323static const struct regulator_linear_range axp806_dcdca_ranges[] = {
248 REGULATOR_LINEAR_RANGE(600000, 0x0, 0x32, 10000), 324 REGULATOR_LINEAR_RANGE(600000, 0x0, 0x32, 10000),
249 REGULATOR_LINEAR_RANGE(1120000, 0x33, 0x47, 20000), 325 REGULATOR_LINEAR_RANGE(1120000, 0x33, 0x47, 20000),
@@ -254,11 +330,6 @@ static const struct regulator_linear_range axp806_dcdcd_ranges[] = {
254 REGULATOR_LINEAR_RANGE(1600000, 0x2e, 0x3f, 100000), 330 REGULATOR_LINEAR_RANGE(1600000, 0x2e, 0x3f, 100000),
255}; 331};
256 332
257static const struct regulator_linear_range axp806_cldo2_ranges[] = {
258 REGULATOR_LINEAR_RANGE(700000, 0x0, 0x1a, 100000),
259 REGULATOR_LINEAR_RANGE(3400000, 0x1b, 0x1f, 200000),
260};
261
262static const struct regulator_desc axp806_regulators[] = { 333static const struct regulator_desc axp806_regulators[] = {
263 AXP_DESC_RANGES(AXP806, DCDCA, "dcdca", "vina", axp806_dcdca_ranges, 334 AXP_DESC_RANGES(AXP806, DCDCA, "dcdca", "vina", axp806_dcdca_ranges,
264 72, AXP806_DCDCA_V_CTRL, 0x7f, AXP806_PWR_OUT_CTRL1, 335 72, AXP806_DCDCA_V_CTRL, 0x7f, AXP806_PWR_OUT_CTRL1,
@@ -289,7 +360,7 @@ static const struct regulator_desc axp806_regulators[] = {
289 AXP806_BLDO4_V_CTRL, 0x0f, AXP806_PWR_OUT_CTRL2, BIT(3)), 360 AXP806_BLDO4_V_CTRL, 0x0f, AXP806_PWR_OUT_CTRL2, BIT(3)),
290 AXP_DESC(AXP806, CLDO1, "cldo1", "cldoin", 700, 3300, 100, 361 AXP_DESC(AXP806, CLDO1, "cldo1", "cldoin", 700, 3300, 100,
291 AXP806_CLDO1_V_CTRL, 0x1f, AXP806_PWR_OUT_CTRL2, BIT(4)), 362 AXP806_CLDO1_V_CTRL, 0x1f, AXP806_PWR_OUT_CTRL2, BIT(4)),
292 AXP_DESC_RANGES(AXP806, CLDO2, "cldo2", "cldoin", axp806_cldo2_ranges, 363 AXP_DESC_RANGES(AXP806, CLDO2, "cldo2", "cldoin", axp803_dldo2_ranges,
293 32, AXP806_CLDO2_V_CTRL, 0x1f, AXP806_PWR_OUT_CTRL2, 364 32, AXP806_CLDO2_V_CTRL, 0x1f, AXP806_PWR_OUT_CTRL2,
294 BIT(5)), 365 BIT(5)),
295 AXP_DESC(AXP806, CLDO3, "cldo3", "cldoin", 700, 3300, 100, 366 AXP_DESC(AXP806, CLDO3, "cldo3", "cldoin", 700, 3300, 100,
@@ -326,7 +397,7 @@ static const struct regulator_desc axp809_regulators[] = {
326 AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(7)), 397 AXP22X_ALDO2_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL1, BIT(7)),
327 AXP_DESC(AXP809, ALDO3, "aldo3", "aldoin", 700, 3300, 100, 398 AXP_DESC(AXP809, ALDO3, "aldo3", "aldoin", 700, 3300, 100,
328 AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)), 399 AXP22X_ALDO3_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, BIT(5)),
329 AXP_DESC_RANGES(AXP809, DLDO1, "dldo1", "dldoin", axp806_cldo2_ranges, 400 AXP_DESC_RANGES(AXP809, DLDO1, "dldo1", "dldoin", axp803_dldo2_ranges,
330 32, AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2, 401 32, AXP22X_DLDO1_V_OUT, 0x1f, AXP22X_PWR_OUT_CTRL2,
331 BIT(3)), 402 BIT(3)),
332 AXP_DESC(AXP809, DLDO2, "dldo2", "dldoin", 700, 3300, 100, 403 AXP_DESC(AXP809, DLDO2, "dldo2", "dldoin", 700, 3300, 100,
@@ -369,14 +440,21 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq)
369 def = 1500; 440 def = 1500;
370 step = 75; 441 step = 75;
371 break; 442 break;
372 case AXP806_ID: 443 case AXP803_ID:
373 /* 444 /*
374 * AXP806 DCDC work frequency setting has the same range and 445 * AXP803 DCDC work frequency setting has the same range and
375 * step as AXP22X, but at a different register. 446 * step as AXP22X, but at a different register.
376 * Fall through to the check below. 447 * Fall through to the check below.
377 * (See include/linux/mfd/axp20x.h) 448 * (See include/linux/mfd/axp20x.h)
378 */ 449 */
379 reg = AXP806_DCDC_FREQ_CTRL; 450 reg = AXP803_DCDC_FREQ_CTRL;
451 case AXP806_ID:
452 /*
453 * AXP806 also have DCDC work frequency setting register at a
454 * different position.
455 */
456 if (axp20x->variant == AXP806_ID)
457 reg = AXP806_DCDC_FREQ_CTRL;
380 case AXP221_ID: 458 case AXP221_ID:
381 case AXP223_ID: 459 case AXP223_ID:
382 case AXP809_ID: 460 case AXP809_ID:
@@ -475,6 +553,14 @@ static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 work
475 workmode <<= id - AXP22X_DCDC1; 553 workmode <<= id - AXP22X_DCDC1;
476 break; 554 break;
477 555
556 case AXP803_ID:
557 if (id < AXP803_DCDC1 || id > AXP803_DCDC6)
558 return -EINVAL;
559
560 mask = AXP22X_WORKMODE_DCDCX_MASK(id - AXP803_DCDC1);
561 workmode <<= id - AXP803_DCDC1;
562 break;
563
478 default: 564 default:
479 /* should not happen */ 565 /* should not happen */
480 WARN_ON(1); 566 WARN_ON(1);
@@ -492,20 +578,38 @@ static bool axp20x_is_polyphase_slave(struct axp20x_dev *axp20x, int id)
492{ 578{
493 u32 reg = 0; 579 u32 reg = 0;
494 580
495 /* Only AXP806 has poly-phase outputs */ 581 /*
496 if (axp20x->variant != AXP806_ID) 582 * Currently in our supported AXP variants, only AXP803 and AXP806
497 return false; 583 * have polyphase regulators.
584 */
585 switch (axp20x->variant) {
586 case AXP803_ID:
587 regmap_read(axp20x->regmap, AXP803_POLYPHASE_CTRL, &reg);
588
589 switch (id) {
590 case AXP803_DCDC3:
591 return !!(reg & BIT(6));
592 case AXP803_DCDC6:
593 return !!(reg & BIT(7));
594 }
595 break;
498 596
499 regmap_read(axp20x->regmap, AXP806_DCDC_MODE_CTRL2, &reg); 597 case AXP806_ID:
598 regmap_read(axp20x->regmap, AXP806_DCDC_MODE_CTRL2, &reg);
599
600 switch (id) {
601 case AXP806_DCDCB:
602 return (((reg & GENMASK(7, 6)) == BIT(6)) ||
603 ((reg & GENMASK(7, 6)) == BIT(7)));
604 case AXP806_DCDCC:
605 return ((reg & GENMASK(7, 6)) == BIT(7));
606 case AXP806_DCDCE:
607 return !!(reg & BIT(5));
608 }
609 break;
500 610
501 switch (id) { 611 default:
502 case AXP806_DCDCB: 612 return false;
503 return (((reg & GENMASK(7, 6)) == BIT(6)) ||
504 ((reg & GENMASK(7, 6)) == BIT(7)));
505 case AXP806_DCDCC:
506 return ((reg & GENMASK(7, 6)) == BIT(7));
507 case AXP806_DCDCE:
508 return !!(reg & BIT(5));
509 } 613 }
510 614
511 return false; 615 return false;
@@ -540,6 +644,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
540 drivevbus = of_property_read_bool(pdev->dev.parent->of_node, 644 drivevbus = of_property_read_bool(pdev->dev.parent->of_node,
541 "x-powers,drive-vbus-en"); 645 "x-powers,drive-vbus-en");
542 break; 646 break;
647 case AXP803_ID:
648 regulators = axp803_regulators;
649 nregulators = AXP803_REG_ID_MAX;
650 break;
543 case AXP806_ID: 651 case AXP806_ID:
544 regulators = axp806_regulators; 652 regulators = axp806_regulators;
545 nregulators = AXP806_REG_ID_MAX; 653 nregulators = AXP806_REG_ID_MAX;
@@ -579,6 +687,7 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
579 * name. 687 * name.
580 */ 688 */
581 if ((regulators == axp22x_regulators && i == AXP22X_DC1SW) || 689 if ((regulators == axp22x_regulators && i == AXP22X_DC1SW) ||
690 (regulators == axp803_regulators && i == AXP803_DC1SW) ||
582 (regulators == axp809_regulators && i == AXP809_DC1SW)) { 691 (regulators == axp809_regulators && i == AXP809_DC1SW)) {
583 new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc), 692 new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc),
584 GFP_KERNEL); 693 GFP_KERNEL);
diff --git a/drivers/regulator/bd9571mwv-regulator.c b/drivers/regulator/bd9571mwv-regulator.c
index 8ba206fec31e..c67a83d53c4c 100644
--- a/drivers/regulator/bd9571mwv-regulator.c
+++ b/drivers/regulator/bd9571mwv-regulator.c
@@ -43,7 +43,7 @@ enum bd9571mwv_regulators { VD09, VD18, VD25, VD33, DVFS };
43 .linear_min_sel = _lmin, \ 43 .linear_min_sel = _lmin, \
44 } 44 }
45 45
46int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev) 46static int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev)
47{ 47{
48 unsigned int val; 48 unsigned int val;
49 int ret; 49 int ret;
@@ -55,8 +55,8 @@ int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev)
55 return val & BD9571MWV_AVS_SET_MONI_MASK; 55 return val & BD9571MWV_AVS_SET_MONI_MASK;
56} 56}
57 57
58int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev *rdev, 58static int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev *rdev,
59 unsigned int sel) 59 unsigned int sel)
60{ 60{
61 int ret; 61 int ret;
62 62
@@ -68,7 +68,7 @@ int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev *rdev,
68 rdev->desc->vsel_mask, sel); 68 rdev->desc->vsel_mask, sel);
69} 69}
70 70
71int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev *rdev) 71static int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev *rdev)
72{ 72{
73 unsigned int val; 73 unsigned int val;
74 int ret; 74 int ret;
@@ -87,8 +87,8 @@ int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev *rdev)
87 return val; 87 return val;
88} 88}
89 89
90int bd9571mwv_reg_set_voltage_sel_regmap(struct regulator_dev *rdev, 90static int bd9571mwv_reg_set_voltage_sel_regmap(struct regulator_dev *rdev,
91 unsigned int sel) 91 unsigned int sel)
92{ 92{
93 return regmap_write_bits(rdev->regmap, BD9571MWV_DVFS_SETVID, 93 return regmap_write_bits(rdev->regmap, BD9571MWV_DVFS_SETVID,
94 rdev->desc->vsel_mask, sel); 94 rdev->desc->vsel_mask, sel);
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c0d9ae8d0860..e567fa54980b 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1462,7 +1462,7 @@ static struct regulator_dev *regulator_lookup_by_name(const char *name)
1462static struct regulator_dev *regulator_dev_lookup(struct device *dev, 1462static struct regulator_dev *regulator_dev_lookup(struct device *dev,
1463 const char *supply) 1463 const char *supply)
1464{ 1464{
1465 struct regulator_dev *r; 1465 struct regulator_dev *r = NULL;
1466 struct device_node *node; 1466 struct device_node *node;
1467 struct regulator_map *map; 1467 struct regulator_map *map;
1468 const char *devname = NULL; 1468 const char *devname = NULL;
@@ -1489,10 +1489,6 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
1489 if (dev) 1489 if (dev)
1490 devname = dev_name(dev); 1490 devname = dev_name(dev);
1491 1491
1492 r = regulator_lookup_by_name(supply);
1493 if (r)
1494 return r;
1495
1496 mutex_lock(&regulator_list_mutex); 1492 mutex_lock(&regulator_list_mutex);
1497 list_for_each_entry(map, &regulator_map_list, list) { 1493 list_for_each_entry(map, &regulator_map_list, list) {
1498 /* If the mapping has a device set up it must match */ 1494 /* If the mapping has a device set up it must match */
@@ -1511,6 +1507,10 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev,
1511 if (r) 1507 if (r)
1512 return r; 1508 return r;
1513 1509
1510 r = regulator_lookup_by_name(supply);
1511 if (r)
1512 return r;
1513
1514 return ERR_PTR(-ENODEV); 1514 return ERR_PTR(-ENODEV);
1515} 1515}
1516 1516
@@ -2767,6 +2767,12 @@ static int _regulator_set_voltage_time(struct regulator_dev *rdev,
2767 ramp_delay = rdev->desc->ramp_delay; 2767 ramp_delay = rdev->desc->ramp_delay;
2768 else if (rdev->constraints->settling_time) 2768 else if (rdev->constraints->settling_time)
2769 return rdev->constraints->settling_time; 2769 return rdev->constraints->settling_time;
2770 else if (rdev->constraints->settling_time_up &&
2771 (new_uV > old_uV))
2772 return rdev->constraints->settling_time_up;
2773 else if (rdev->constraints->settling_time_down &&
2774 (new_uV < old_uV))
2775 return rdev->constraints->settling_time_down;
2770 2776
2771 if (ramp_delay == 0) { 2777 if (ramp_delay == 0) {
2772 rdev_dbg(rdev, "ramp_delay not set\n"); 2778 rdev_dbg(rdev, "ramp_delay not set\n");
@@ -2938,7 +2944,8 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator,
2938 if (rdev->supply && 2944 if (rdev->supply &&
2939 regulator_ops_is_valid(rdev->supply->rdev, 2945 regulator_ops_is_valid(rdev->supply->rdev,
2940 REGULATOR_CHANGE_VOLTAGE) && 2946 REGULATOR_CHANGE_VOLTAGE) &&
2941 (rdev->desc->min_dropout_uV || !rdev->desc->ops->get_voltage)) { 2947 (rdev->desc->min_dropout_uV || !(rdev->desc->ops->get_voltage ||
2948 rdev->desc->ops->get_voltage_sel))) {
2942 int current_supply_uV; 2949 int current_supply_uV;
2943 int selector; 2950 int selector;
2944 2951
@@ -4311,41 +4318,31 @@ void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data)
4311EXPORT_SYMBOL_GPL(regulator_get_init_drvdata); 4318EXPORT_SYMBOL_GPL(regulator_get_init_drvdata);
4312 4319
4313#ifdef CONFIG_DEBUG_FS 4320#ifdef CONFIG_DEBUG_FS
4314static ssize_t supply_map_read_file(struct file *file, char __user *user_buf, 4321static int supply_map_show(struct seq_file *sf, void *data)
4315 size_t count, loff_t *ppos)
4316{ 4322{
4317 char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
4318 ssize_t len, ret = 0;
4319 struct regulator_map *map; 4323 struct regulator_map *map;
4320 4324
4321 if (!buf)
4322 return -ENOMEM;
4323
4324 list_for_each_entry(map, &regulator_map_list, list) { 4325 list_for_each_entry(map, &regulator_map_list, list) {
4325 len = snprintf(buf + ret, PAGE_SIZE - ret, 4326 seq_printf(sf, "%s -> %s.%s\n",
4326 "%s -> %s.%s\n", 4327 rdev_get_name(map->regulator), map->dev_name,
4327 rdev_get_name(map->regulator), map->dev_name, 4328 map->supply);
4328 map->supply);
4329 if (len >= 0)
4330 ret += len;
4331 if (ret > PAGE_SIZE) {
4332 ret = PAGE_SIZE;
4333 break;
4334 }
4335 } 4329 }
4336 4330
4337 ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret); 4331 return 0;
4338 4332}
4339 kfree(buf);
4340 4333
4341 return ret; 4334static int supply_map_open(struct inode *inode, struct file *file)
4335{
4336 return single_open(file, supply_map_show, inode->i_private);
4342} 4337}
4343#endif 4338#endif
4344 4339
4345static const struct file_operations supply_map_fops = { 4340static const struct file_operations supply_map_fops = {
4346#ifdef CONFIG_DEBUG_FS 4341#ifdef CONFIG_DEBUG_FS
4347 .read = supply_map_read_file, 4342 .open = supply_map_open,
4348 .llseek = default_llseek, 4343 .read = seq_read,
4344 .llseek = seq_lseek,
4345 .release = single_release,
4349#endif 4346#endif
4350}; 4347};
4351 4348
diff --git a/drivers/regulator/da9062-regulator.c b/drivers/regulator/da9062-regulator.c
index 0638c8b40521..34a70d9dc450 100644
--- a/drivers/regulator/da9062-regulator.c
+++ b/drivers/regulator/da9062-regulator.c
@@ -1,6 +1,6 @@
1/* 1/*
2 * da9062-regulator.c - REGULATOR device driver for DA9062 2 * Regulator device driver for DA9061 and DA9062.
3 * Copyright (C) 2015 Dialog Semiconductor Ltd. 3 * Copyright (C) 2015-2017 Dialog Semiconductor
4 * 4 *
5 * This program is free software; you can redistribute it and/or 5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License 6 * modify it under the terms of the GNU General Public License
@@ -28,6 +28,17 @@
28 28
29/* Regulator IDs */ 29/* Regulator IDs */
30enum { 30enum {
31 DA9061_ID_BUCK1,
32 DA9061_ID_BUCK2,
33 DA9061_ID_BUCK3,
34 DA9061_ID_LDO1,
35 DA9061_ID_LDO2,
36 DA9061_ID_LDO3,
37 DA9061_ID_LDO4,
38 DA9061_MAX_REGULATORS,
39};
40
41enum {
31 DA9062_ID_BUCK1, 42 DA9062_ID_BUCK1,
32 DA9062_ID_BUCK2, 43 DA9062_ID_BUCK2,
33 DA9062_ID_BUCK3, 44 DA9062_ID_BUCK3,
@@ -88,15 +99,21 @@ enum {
88 99
89/* Regulator operations */ 100/* Regulator operations */
90 101
91/* Current limits array (in uA) BUCK1 and BUCK3. 102/* Current limits array (in uA)
92 Entry indexes corresponds to register values. */ 103 * - DA9061_ID_[BUCK1|BUCK3]
104 * - DA9062_ID_[BUCK1|BUCK2|BUCK4]
105 * Entry indexes corresponds to register values.
106 */
93static const int da9062_buck_a_limits[] = { 107static const int da9062_buck_a_limits[] = {
94 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000, 108 500000, 600000, 700000, 800000, 900000, 1000000, 1100000, 1200000,
95 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000 109 1300000, 1400000, 1500000, 1600000, 1700000, 1800000, 1900000, 2000000
96}; 110};
97 111
98/* Current limits array (in uA) for BUCK2. 112/* Current limits array (in uA)
99 Entry indexes corresponds to register values. */ 113 * - DA9061_ID_BUCK2
114 * - DA9062_ID_BUCK3
115 * Entry indexes corresponds to register values.
116 */
100static const int da9062_buck_b_limits[] = { 117static const int da9062_buck_b_limits[] = {
101 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000, 118 1500000, 1600000, 1700000, 1800000, 1900000, 2000000, 2100000, 2200000,
102 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000 119 2300000, 2400000, 2500000, 2600000, 2700000, 2800000, 2900000, 3000000
@@ -405,8 +422,254 @@ static const struct regulator_ops da9062_ldo_ops = {
405 .set_suspend_mode = da9062_ldo_set_suspend_mode, 422 .set_suspend_mode = da9062_ldo_set_suspend_mode,
406}; 423};
407 424
408/* Regulator information */ 425/* DA9061 Regulator information */
409static const struct da9062_regulator_info local_regulator_info[] = { 426static const struct da9062_regulator_info local_da9061_regulator_info[] = {
427 {
428 .desc.id = DA9061_ID_BUCK1,
429 .desc.name = "DA9061 BUCK1",
430 .desc.of_match = of_match_ptr("buck1"),
431 .desc.regulators_node = of_match_ptr("regulators"),
432 .desc.ops = &da9062_buck_ops,
433 .desc.min_uV = (300) * 1000,
434 .desc.uV_step = (10) * 1000,
435 .desc.n_voltages = ((1570) - (300))/(10) + 1,
436 .current_limits = da9062_buck_a_limits,
437 .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
438 .desc.enable_reg = DA9062AA_BUCK1_CONT,
439 .desc.enable_mask = DA9062AA_BUCK1_EN_MASK,
440 .desc.vsel_reg = DA9062AA_VBUCK1_A,
441 .desc.vsel_mask = DA9062AA_VBUCK1_A_MASK,
442 .desc.linear_min_sel = 0,
443 .sleep = REG_FIELD(DA9062AA_VBUCK1_A,
444 __builtin_ffs((int)DA9062AA_BUCK1_SL_A_MASK) - 1,
445 sizeof(unsigned int) * 8 -
446 __builtin_clz((DA9062AA_BUCK1_SL_A_MASK)) - 1),
447 .suspend_sleep = REG_FIELD(DA9062AA_VBUCK1_B,
448 __builtin_ffs((int)DA9062AA_BUCK1_SL_B_MASK) - 1,
449 sizeof(unsigned int) * 8 -
450 __builtin_clz((DA9062AA_BUCK1_SL_B_MASK)) - 1),
451 .suspend_vsel_reg = DA9062AA_VBUCK1_B,
452 .mode = REG_FIELD(DA9062AA_BUCK1_CFG,
453 __builtin_ffs((int)DA9062AA_BUCK1_MODE_MASK) - 1,
454 sizeof(unsigned int) * 8 -
455 __builtin_clz((DA9062AA_BUCK1_MODE_MASK)) - 1),
456 .suspend = REG_FIELD(DA9062AA_DVC_1,
457 __builtin_ffs((int)DA9062AA_VBUCK1_SEL_MASK) - 1,
458 sizeof(unsigned int) * 8 -
459 __builtin_clz((DA9062AA_VBUCK1_SEL_MASK)) - 1),
460 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_C,
461 __builtin_ffs((int)DA9062AA_BUCK1_ILIM_MASK) - 1,
462 sizeof(unsigned int) * 8 -
463 __builtin_clz((DA9062AA_BUCK1_ILIM_MASK)) - 1),
464 },
465 {
466 .desc.id = DA9061_ID_BUCK2,
467 .desc.name = "DA9061 BUCK2",
468 .desc.of_match = of_match_ptr("buck2"),
469 .desc.regulators_node = of_match_ptr("regulators"),
470 .desc.ops = &da9062_buck_ops,
471 .desc.min_uV = (800) * 1000,
472 .desc.uV_step = (20) * 1000,
473 .desc.n_voltages = ((3340) - (800))/(20) + 1,
474 .current_limits = da9062_buck_b_limits,
475 .n_current_limits = ARRAY_SIZE(da9062_buck_b_limits),
476 .desc.enable_reg = DA9062AA_BUCK3_CONT,
477 .desc.enable_mask = DA9062AA_BUCK3_EN_MASK,
478 .desc.vsel_reg = DA9062AA_VBUCK3_A,
479 .desc.vsel_mask = DA9062AA_VBUCK3_A_MASK,
480 .desc.linear_min_sel = 0,
481 .sleep = REG_FIELD(DA9062AA_VBUCK3_A,
482 __builtin_ffs((int)DA9062AA_BUCK3_SL_A_MASK) - 1,
483 sizeof(unsigned int) * 8 -
484 __builtin_clz((DA9062AA_BUCK3_SL_A_MASK)) - 1),
485 .suspend_sleep = REG_FIELD(DA9062AA_VBUCK3_B,
486 __builtin_ffs((int)DA9062AA_BUCK3_SL_B_MASK) - 1,
487 sizeof(unsigned int) * 8 -
488 __builtin_clz((DA9062AA_BUCK3_SL_B_MASK)) - 1),
489 .suspend_vsel_reg = DA9062AA_VBUCK3_B,
490 .mode = REG_FIELD(DA9062AA_BUCK3_CFG,
491 __builtin_ffs((int)DA9062AA_BUCK3_MODE_MASK) - 1,
492 sizeof(unsigned int) * 8 -
493 __builtin_clz((DA9062AA_BUCK3_MODE_MASK)) - 1),
494 .suspend = REG_FIELD(DA9062AA_DVC_1,
495 __builtin_ffs((int)DA9062AA_VBUCK3_SEL_MASK) - 1,
496 sizeof(unsigned int) * 8 -
497 __builtin_clz((DA9062AA_VBUCK3_SEL_MASK)) - 1),
498 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_A,
499 __builtin_ffs((int)DA9062AA_BUCK3_ILIM_MASK) - 1,
500 sizeof(unsigned int) * 8 -
501 __builtin_clz((DA9062AA_BUCK3_ILIM_MASK)) - 1),
502 },
503 {
504 .desc.id = DA9061_ID_BUCK3,
505 .desc.name = "DA9061 BUCK3",
506 .desc.of_match = of_match_ptr("buck3"),
507 .desc.regulators_node = of_match_ptr("regulators"),
508 .desc.ops = &da9062_buck_ops,
509 .desc.min_uV = (530) * 1000,
510 .desc.uV_step = (10) * 1000,
511 .desc.n_voltages = ((1800) - (530))/(10) + 1,
512 .current_limits = da9062_buck_a_limits,
513 .n_current_limits = ARRAY_SIZE(da9062_buck_a_limits),
514 .desc.enable_reg = DA9062AA_BUCK4_CONT,
515 .desc.enable_mask = DA9062AA_BUCK4_EN_MASK,
516 .desc.vsel_reg = DA9062AA_VBUCK4_A,
517 .desc.vsel_mask = DA9062AA_VBUCK4_A_MASK,
518 .desc.linear_min_sel = 0,
519 .sleep = REG_FIELD(DA9062AA_VBUCK4_A,
520 __builtin_ffs((int)DA9062AA_BUCK4_SL_A_MASK) - 1,
521 sizeof(unsigned int) * 8 -
522 __builtin_clz((DA9062AA_BUCK4_SL_A_MASK)) - 1),
523 .suspend_sleep = REG_FIELD(DA9062AA_VBUCK4_B,
524 __builtin_ffs((int)DA9062AA_BUCK4_SL_B_MASK) - 1,
525 sizeof(unsigned int) * 8 -
526 __builtin_clz((DA9062AA_BUCK4_SL_B_MASK)) - 1),
527 .suspend_vsel_reg = DA9062AA_VBUCK4_B,
528 .mode = REG_FIELD(DA9062AA_BUCK4_CFG,
529 __builtin_ffs((int)DA9062AA_BUCK4_MODE_MASK) - 1,
530 sizeof(unsigned int) * 8 -
531 __builtin_clz((DA9062AA_BUCK4_MODE_MASK)) - 1),
532 .suspend = REG_FIELD(DA9062AA_DVC_1,
533 __builtin_ffs((int)DA9062AA_VBUCK4_SEL_MASK) - 1,
534 sizeof(unsigned int) * 8 -
535 __builtin_clz((DA9062AA_VBUCK4_SEL_MASK)) - 1),
536 .ilimit = REG_FIELD(DA9062AA_BUCK_ILIM_B,
537 __builtin_ffs((int)DA9062AA_BUCK4_ILIM_MASK) - 1,
538 sizeof(unsigned int) * 8 -
539 __builtin_clz((DA9062AA_BUCK4_ILIM_MASK)) - 1),
540 },
541 {
542 .desc.id = DA9061_ID_LDO1,
543 .desc.name = "DA9061 LDO1",
544 .desc.of_match = of_match_ptr("ldo1"),
545 .desc.regulators_node = of_match_ptr("regulators"),
546 .desc.ops = &da9062_ldo_ops,
547 .desc.min_uV = (900) * 1000,
548 .desc.uV_step = (50) * 1000,
549 .desc.n_voltages = ((3600) - (900))/(50) + 1,
550 .desc.enable_reg = DA9062AA_LDO1_CONT,
551 .desc.enable_mask = DA9062AA_LDO1_EN_MASK,
552 .desc.vsel_reg = DA9062AA_VLDO1_A,
553 .desc.vsel_mask = DA9062AA_VLDO1_A_MASK,
554 .desc.linear_min_sel = 0,
555 .sleep = REG_FIELD(DA9062AA_VLDO1_A,
556 __builtin_ffs((int)DA9062AA_LDO1_SL_A_MASK) - 1,
557 sizeof(unsigned int) * 8 -
558 __builtin_clz((DA9062AA_LDO1_SL_A_MASK)) - 1),
559 .suspend_sleep = REG_FIELD(DA9062AA_VLDO1_B,
560 __builtin_ffs((int)DA9062AA_LDO1_SL_B_MASK) - 1,
561 sizeof(unsigned int) * 8 -
562 __builtin_clz((DA9062AA_LDO1_SL_B_MASK)) - 1),
563 .suspend_vsel_reg = DA9062AA_VLDO1_B,
564 .suspend = REG_FIELD(DA9062AA_DVC_1,
565 __builtin_ffs((int)DA9062AA_VLDO1_SEL_MASK) - 1,
566 sizeof(unsigned int) * 8 -
567 __builtin_clz((DA9062AA_VLDO1_SEL_MASK)) - 1),
568 .oc_event = REG_FIELD(DA9062AA_STATUS_D,
569 __builtin_ffs((int)DA9062AA_LDO1_ILIM_MASK) - 1,
570 sizeof(unsigned int) * 8 -
571 __builtin_clz((DA9062AA_LDO1_ILIM_MASK)) - 1),
572 },
573 {
574 .desc.id = DA9061_ID_LDO2,
575 .desc.name = "DA9061 LDO2",
576 .desc.of_match = of_match_ptr("ldo2"),
577 .desc.regulators_node = of_match_ptr("regulators"),
578 .desc.ops = &da9062_ldo_ops,
579 .desc.min_uV = (900) * 1000,
580 .desc.uV_step = (50) * 1000,
581 .desc.n_voltages = ((3600) - (600))/(50) + 1,
582 .desc.enable_reg = DA9062AA_LDO2_CONT,
583 .desc.enable_mask = DA9062AA_LDO2_EN_MASK,
584 .desc.vsel_reg = DA9062AA_VLDO2_A,
585 .desc.vsel_mask = DA9062AA_VLDO2_A_MASK,
586 .desc.linear_min_sel = 0,
587 .sleep = REG_FIELD(DA9062AA_VLDO2_A,
588 __builtin_ffs((int)DA9062AA_LDO2_SL_A_MASK) - 1,
589 sizeof(unsigned int) * 8 -
590 __builtin_clz((DA9062AA_LDO2_SL_A_MASK)) - 1),
591 .suspend_sleep = REG_FIELD(DA9062AA_VLDO2_B,
592 __builtin_ffs((int)DA9062AA_LDO2_SL_B_MASK) - 1,
593 sizeof(unsigned int) * 8 -
594 __builtin_clz((DA9062AA_LDO2_SL_B_MASK)) - 1),
595 .suspend_vsel_reg = DA9062AA_VLDO2_B,
596 .suspend = REG_FIELD(DA9062AA_DVC_1,
597 __builtin_ffs((int)DA9062AA_VLDO2_SEL_MASK) - 1,
598 sizeof(unsigned int) * 8 -
599 __builtin_clz((DA9062AA_VLDO2_SEL_MASK)) - 1),
600 .oc_event = REG_FIELD(DA9062AA_STATUS_D,
601 __builtin_ffs((int)DA9062AA_LDO2_ILIM_MASK) - 1,
602 sizeof(unsigned int) * 8 -
603 __builtin_clz((DA9062AA_LDO2_ILIM_MASK)) - 1),
604 },
605 {
606 .desc.id = DA9061_ID_LDO3,
607 .desc.name = "DA9061 LDO3",
608 .desc.of_match = of_match_ptr("ldo3"),
609 .desc.regulators_node = of_match_ptr("regulators"),
610 .desc.ops = &da9062_ldo_ops,
611 .desc.min_uV = (900) * 1000,
612 .desc.uV_step = (50) * 1000,
613 .desc.n_voltages = ((3600) - (900))/(50) + 1,
614 .desc.enable_reg = DA9062AA_LDO3_CONT,
615 .desc.enable_mask = DA9062AA_LDO3_EN_MASK,
616 .desc.vsel_reg = DA9062AA_VLDO3_A,
617 .desc.vsel_mask = DA9062AA_VLDO3_A_MASK,
618 .desc.linear_min_sel = 0,
619 .sleep = REG_FIELD(DA9062AA_VLDO3_A,
620 __builtin_ffs((int)DA9062AA_LDO3_SL_A_MASK) - 1,
621 sizeof(unsigned int) * 8 -
622 __builtin_clz((DA9062AA_LDO3_SL_A_MASK)) - 1),
623 .suspend_sleep = REG_FIELD(DA9062AA_VLDO3_B,
624 __builtin_ffs((int)DA9062AA_LDO3_SL_B_MASK) - 1,
625 sizeof(unsigned int) * 8 -
626 __builtin_clz((DA9062AA_LDO3_SL_B_MASK)) - 1),
627 .suspend_vsel_reg = DA9062AA_VLDO3_B,
628 .suspend = REG_FIELD(DA9062AA_DVC_1,
629 __builtin_ffs((int)DA9062AA_VLDO3_SEL_MASK) - 1,
630 sizeof(unsigned int) * 8 -
631 __builtin_clz((DA9062AA_VLDO3_SEL_MASK)) - 1),
632 .oc_event = REG_FIELD(DA9062AA_STATUS_D,
633 __builtin_ffs((int)DA9062AA_LDO3_ILIM_MASK) - 1,
634 sizeof(unsigned int) * 8 -
635 __builtin_clz((DA9062AA_LDO3_ILIM_MASK)) - 1),
636 },
637 {
638 .desc.id = DA9061_ID_LDO4,
639 .desc.name = "DA9061 LDO4",
640 .desc.of_match = of_match_ptr("ldo4"),
641 .desc.regulators_node = of_match_ptr("regulators"),
642 .desc.ops = &da9062_ldo_ops,
643 .desc.min_uV = (900) * 1000,
644 .desc.uV_step = (50) * 1000,
645 .desc.n_voltages = ((3600) - (900))/(50) + 1,
646 .desc.enable_reg = DA9062AA_LDO4_CONT,
647 .desc.enable_mask = DA9062AA_LDO4_EN_MASK,
648 .desc.vsel_reg = DA9062AA_VLDO4_A,
649 .desc.vsel_mask = DA9062AA_VLDO4_A_MASK,
650 .desc.linear_min_sel = 0,
651 .sleep = REG_FIELD(DA9062AA_VLDO4_A,
652 __builtin_ffs((int)DA9062AA_LDO4_SL_A_MASK) - 1,
653 sizeof(unsigned int) * 8 -
654 __builtin_clz((DA9062AA_LDO4_SL_A_MASK)) - 1),
655 .suspend_sleep = REG_FIELD(DA9062AA_VLDO4_B,
656 __builtin_ffs((int)DA9062AA_LDO4_SL_B_MASK) - 1,
657 sizeof(unsigned int) * 8 -
658 __builtin_clz((DA9062AA_LDO4_SL_B_MASK)) - 1),
659 .suspend_vsel_reg = DA9062AA_VLDO4_B,
660 .suspend = REG_FIELD(DA9062AA_DVC_1,
661 __builtin_ffs((int)DA9062AA_VLDO4_SEL_MASK) - 1,
662 sizeof(unsigned int) * 8 -
663 __builtin_clz((DA9062AA_VLDO4_SEL_MASK)) - 1),
664 .oc_event = REG_FIELD(DA9062AA_STATUS_D,
665 __builtin_ffs((int)DA9062AA_LDO4_ILIM_MASK) - 1,
666 sizeof(unsigned int) * 8 -
667 __builtin_clz((DA9062AA_LDO4_ILIM_MASK)) - 1),
668 },
669};
670
671/* DA9062 Regulator information */
672static const struct da9062_regulator_info local_da9062_regulator_info[] = {
410 { 673 {
411 .desc.id = DA9062_ID_BUCK1, 674 .desc.id = DA9062_ID_BUCK1,
412 .desc.name = "DA9062 BUCK1", 675 .desc.name = "DA9062 BUCK1",
@@ -727,17 +990,33 @@ static int da9062_regulator_probe(struct platform_device *pdev)
727 struct da9062_regulators *regulators; 990 struct da9062_regulators *regulators;
728 struct da9062_regulator *regl; 991 struct da9062_regulator *regl;
729 struct regulator_config config = { }; 992 struct regulator_config config = { };
993 const struct da9062_regulator_info *rinfo;
730 int irq, n, ret; 994 int irq, n, ret;
731 size_t size; 995 size_t size;
996 int max_regulators;
997
998 switch (chip->chip_type) {
999 case COMPAT_TYPE_DA9061:
1000 max_regulators = DA9061_MAX_REGULATORS;
1001 rinfo = local_da9061_regulator_info;
1002 break;
1003 case COMPAT_TYPE_DA9062:
1004 max_regulators = DA9062_MAX_REGULATORS;
1005 rinfo = local_da9062_regulator_info;
1006 break;
1007 default:
1008 dev_err(chip->dev, "Unrecognised chip type\n");
1009 return -ENODEV;
1010 }
732 1011
733 /* Allocate memory required by usable regulators */ 1012 /* Allocate memory required by usable regulators */
734 size = sizeof(struct da9062_regulators) + 1013 size = sizeof(struct da9062_regulators) +
735 DA9062_MAX_REGULATORS * sizeof(struct da9062_regulator); 1014 max_regulators * sizeof(struct da9062_regulator);
736 regulators = devm_kzalloc(&pdev->dev, size, GFP_KERNEL); 1015 regulators = devm_kzalloc(&pdev->dev, size, GFP_KERNEL);
737 if (!regulators) 1016 if (!regulators)
738 return -ENOMEM; 1017 return -ENOMEM;
739 1018
740 regulators->n_regulators = DA9062_MAX_REGULATORS; 1019 regulators->n_regulators = max_regulators;
741 platform_set_drvdata(pdev, regulators); 1020 platform_set_drvdata(pdev, regulators);
742 1021
743 n = 0; 1022 n = 0;
@@ -745,7 +1024,7 @@ static int da9062_regulator_probe(struct platform_device *pdev)
745 /* Initialise regulator structure */ 1024 /* Initialise regulator structure */
746 regl = &regulators->regulator[n]; 1025 regl = &regulators->regulator[n];
747 regl->hw = chip; 1026 regl->hw = chip;
748 regl->info = &local_regulator_info[n]; 1027 regl->info = &rinfo[n];
749 regl->desc = regl->info->desc; 1028 regl->desc = regl->info->desc;
750 regl->desc.type = REGULATOR_VOLTAGE; 1029 regl->desc.type = REGULATOR_VOLTAGE;
751 regl->desc.owner = THIS_MODULE; 1030 regl->desc.owner = THIS_MODULE;
@@ -836,6 +1115,6 @@ module_exit(da9062_regulator_cleanup);
836 1115
837/* Module information */ 1116/* Module information */
838MODULE_AUTHOR("S Twiss <stwiss.opensource@diasemi.com>"); 1117MODULE_AUTHOR("S Twiss <stwiss.opensource@diasemi.com>");
839MODULE_DESCRIPTION("REGULATOR device driver for Dialog DA9062"); 1118MODULE_DESCRIPTION("REGULATOR device driver for Dialog DA9062 and DA9061");
840MODULE_LICENSE("GPL"); 1119MODULE_LICENSE("GPL");
841MODULE_ALIAS("platform:da9062-regulators"); 1120MODULE_ALIAS("platform:da9062-regulators");
diff --git a/drivers/regulator/hi6421-regulator.c b/drivers/regulator/hi6421-regulator.c
index 62c5f5445d44..259c3a865ac6 100644
--- a/drivers/regulator/hi6421-regulator.c
+++ b/drivers/regulator/hi6421-regulator.c
@@ -621,7 +621,14 @@ static int hi6421_regulator_probe(struct platform_device *pdev)
621 return 0; 621 return 0;
622} 622}
623 623
624static const struct platform_device_id hi6421_regulator_table[] = {
625 { .name = "hi6421-regulator" },
626 {},
627};
628MODULE_DEVICE_TABLE(platform, hi6421_regulator_table);
629
624static struct platform_driver hi6421_regulator_driver = { 630static struct platform_driver hi6421_regulator_driver = {
631 .id_table = hi6421_regulator_table,
625 .driver = { 632 .driver = {
626 .name = "hi6421-regulator", 633 .name = "hi6421-regulator",
627 }, 634 },
diff --git a/drivers/regulator/hi6421v530-regulator.c b/drivers/regulator/hi6421v530-regulator.c
new file mode 100644
index 000000000000..c09bc71538a5
--- /dev/null
+++ b/drivers/regulator/hi6421v530-regulator.c
@@ -0,0 +1,214 @@
1/*
2 * Device driver for regulators in Hi6421V530 IC
3 *
4 * Copyright (c) <2017> HiSilicon Technologies Co., Ltd.
5 * http://www.hisilicon.com
6 * Copyright (c) <2017> Linaro Ltd.
7 * http://www.linaro.org
8 *
9 * Author: Wang Xiaoyin <hw.wangxiaoyin@hisilicon.com>
10 * Guodong Xu <guodong.xu@linaro.org>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#include <linux/mfd/hi6421-pmic.h>
18#include <linux/module.h>
19#include <linux/of.h>
20#include <linux/platform_device.h>
21#include <linux/regmap.h>
22#include <linux/regulator/driver.h>
23
24/*
25 * struct hi6421v530_regulator_info - hi6421v530 regulator information
26 * @desc: regulator description
27 * @mode_mask: ECO mode bitmask of LDOs; for BUCKs, this masks sleep
28 * @eco_microamp: eco mode load upper limit (in uA), valid for LDOs only
29 */
30struct hi6421v530_regulator_info {
31 struct regulator_desc rdesc;
32 u8 mode_mask;
33 u32 eco_microamp;
34};
35
36/* HI6421v530 regulators */
37enum hi6421v530_regulator_id {
38 HI6421V530_LDO3,
39 HI6421V530_LDO9,
40 HI6421V530_LDO11,
41 HI6421V530_LDO15,
42 HI6421V530_LDO16,
43};
44
45static const unsigned int ldo_3_voltages[] = {
46 1800000, 1825000, 1850000, 1875000,
47 1900000, 1925000, 1950000, 1975000,
48 2000000, 2025000, 2050000, 2075000,
49 2100000, 2125000, 2150000, 2200000,
50};
51
52static const unsigned int ldo_9_11_voltages[] = {
53 1750000, 1800000, 1825000, 2800000,
54 2850000, 2950000, 3000000, 3300000,
55};
56
57static const unsigned int ldo_15_16_voltages[] = {
58 1750000, 1800000, 2400000, 2600000,
59 2700000, 2850000, 2950000, 3000000,
60};
61
62static const struct regulator_ops hi6421v530_ldo_ops;
63
64#define HI6421V530_LDO_ENABLE_TIME (350)
65
66/*
67 * _id - LDO id name string
68 * v_table - voltage table
69 * vreg - voltage select register
70 * vmask - voltage select mask
71 * ereg - enable register
72 * emask - enable mask
73 * odelay - off/on delay time in uS
74 * ecomask - eco mode mask
75 * ecoamp - eco mode load uppler limit in uA
76 */
77#define HI6421V530_LDO(_ID, v_table, vreg, vmask, ereg, emask, \
78 odelay, ecomask, ecoamp) { \
79 .rdesc = { \
80 .name = #_ID, \
81 .of_match = of_match_ptr(#_ID), \
82 .regulators_node = of_match_ptr("regulators"), \
83 .ops = &hi6421v530_ldo_ops, \
84 .type = REGULATOR_VOLTAGE, \
85 .id = HI6421V530_##_ID, \
86 .owner = THIS_MODULE, \
87 .n_voltages = ARRAY_SIZE(v_table), \
88 .volt_table = v_table, \
89 .vsel_reg = HI6421_REG_TO_BUS_ADDR(vreg), \
90 .vsel_mask = vmask, \
91 .enable_reg = HI6421_REG_TO_BUS_ADDR(ereg), \
92 .enable_mask = emask, \
93 .enable_time = HI6421V530_LDO_ENABLE_TIME, \
94 .off_on_delay = odelay, \
95 }, \
96 .mode_mask = ecomask, \
97 .eco_microamp = ecoamp, \
98}
99
100/* HI6421V530 regulator information */
101
102static struct hi6421v530_regulator_info hi6421v530_regulator_info[] = {
103 HI6421V530_LDO(LDO3, ldo_3_voltages, 0x061, 0xf, 0x060, 0x2,
104 20000, 0x6, 8000),
105 HI6421V530_LDO(LDO9, ldo_9_11_voltages, 0x06b, 0x7, 0x06a, 0x2,
106 40000, 0x6, 8000),
107 HI6421V530_LDO(LDO11, ldo_9_11_voltages, 0x06f, 0x7, 0x06e, 0x2,
108 40000, 0x6, 8000),
109 HI6421V530_LDO(LDO15, ldo_15_16_voltages, 0x077, 0x7, 0x076, 0x2,
110 40000, 0x6, 8000),
111 HI6421V530_LDO(LDO16, ldo_15_16_voltages, 0x079, 0x7, 0x078, 0x2,
112 40000, 0x6, 8000),
113};
114
115static unsigned int hi6421v530_regulator_ldo_get_mode(
116 struct regulator_dev *rdev)
117{
118 struct hi6421v530_regulator_info *info;
119 unsigned int reg_val;
120
121 info = rdev_get_drvdata(rdev);
122 regmap_read(rdev->regmap, rdev->desc->enable_reg, &reg_val);
123
124 if (reg_val & (info->mode_mask))
125 return REGULATOR_MODE_IDLE;
126
127 return REGULATOR_MODE_NORMAL;
128}
129
130static int hi6421v530_regulator_ldo_set_mode(struct regulator_dev *rdev,
131 unsigned int mode)
132{
133 struct hi6421v530_regulator_info *info;
134 unsigned int new_mode;
135
136 info = rdev_get_drvdata(rdev);
137 switch (mode) {
138 case REGULATOR_MODE_NORMAL:
139 new_mode = 0;
140 break;
141 case REGULATOR_MODE_IDLE:
142 new_mode = info->mode_mask;
143 break;
144 default:
145 return -EINVAL;
146 }
147
148 regmap_update_bits(rdev->regmap, rdev->desc->enable_reg,
149 info->mode_mask, new_mode);
150
151 return 0;
152}
153
154
155static const struct regulator_ops hi6421v530_ldo_ops = {
156 .is_enabled = regulator_is_enabled_regmap,
157 .enable = regulator_enable_regmap,
158 .disable = regulator_disable_regmap,
159 .list_voltage = regulator_list_voltage_table,
160 .map_voltage = regulator_map_voltage_ascend,
161 .get_voltage_sel = regulator_get_voltage_sel_regmap,
162 .set_voltage_sel = regulator_set_voltage_sel_regmap,
163 .get_mode = hi6421v530_regulator_ldo_get_mode,
164 .set_mode = hi6421v530_regulator_ldo_set_mode,
165};
166
167static int hi6421v530_regulator_probe(struct platform_device *pdev)
168{
169 struct hi6421_pmic *pmic;
170 struct regulator_dev *rdev;
171 struct regulator_config config = { };
172 unsigned int i;
173
174 pmic = dev_get_drvdata(pdev->dev.parent);
175 if (!pmic) {
176 dev_err(&pdev->dev, "no pmic in the regulator parent node\n");
177 return -ENODEV;
178 }
179
180 for (i = 0; i < ARRAY_SIZE(hi6421v530_regulator_info); i++) {
181 config.dev = pdev->dev.parent;
182 config.regmap = pmic->regmap;
183 config.driver_data = &hi6421v530_regulator_info[i];
184
185 rdev = devm_regulator_register(&pdev->dev,
186 &hi6421v530_regulator_info[i].rdesc,
187 &config);
188 if (IS_ERR(rdev)) {
189 dev_err(&pdev->dev, "failed to register regulator %s\n",
190 hi6421v530_regulator_info[i].rdesc.name);
191 return PTR_ERR(rdev);
192 }
193 }
194 return 0;
195}
196
197static const struct platform_device_id hi6421v530_regulator_table[] = {
198 { .name = "hi6421v530-regulator" },
199 {},
200};
201MODULE_DEVICE_TABLE(platform, hi6421v530_regulator_table);
202
203static struct platform_driver hi6421v530_regulator_driver = {
204 .id_table = hi6421v530_regulator_table,
205 .driver = {
206 .name = "hi6421v530-regulator",
207 },
208 .probe = hi6421v530_regulator_probe,
209};
210module_platform_driver(hi6421v530_regulator_driver);
211
212MODULE_AUTHOR("Wang Xiaoyin <hw.wangxiaoyin@hisilicon.com>");
213MODULE_DESCRIPTION("Hi6421v530 regulator driver");
214MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/lp8755.c b/drivers/regulator/lp8755.c
index db34e1da75ef..244822bb63cd 100644
--- a/drivers/regulator/lp8755.c
+++ b/drivers/regulator/lp8755.c
@@ -99,7 +99,7 @@ static int lp8755_buck_enable_time(struct regulator_dev *rdev)
99 99
100 ret = lp8755_read(pchip, 0x12 + id, &regval); 100 ret = lp8755_read(pchip, 0x12 + id, &regval);
101 if (ret < 0) { 101 if (ret < 0) {
102 dev_err(pchip->dev, "i2c acceess error %s\n", __func__); 102 dev_err(pchip->dev, "i2c access error %s\n", __func__);
103 return ret; 103 return ret;
104 } 104 }
105 return (regval & 0xff) * 100; 105 return (regval & 0xff) * 100;
@@ -144,7 +144,7 @@ static int lp8755_buck_set_mode(struct regulator_dev *rdev, unsigned int mode)
144 goto err_i2c; 144 goto err_i2c;
145 return ret; 145 return ret;
146err_i2c: 146err_i2c:
147 dev_err(pchip->dev, "i2c acceess error %s\n", __func__); 147 dev_err(pchip->dev, "i2c access error %s\n", __func__);
148 return ret; 148 return ret;
149} 149}
150 150
@@ -175,7 +175,7 @@ static unsigned int lp8755_buck_get_mode(struct regulator_dev *rdev)
175 return REGULATOR_MODE_NORMAL; 175 return REGULATOR_MODE_NORMAL;
176 176
177err_i2c: 177err_i2c:
178 dev_err(pchip->dev, "i2c acceess error %s\n", __func__); 178 dev_err(pchip->dev, "i2c access error %s\n", __func__);
179 return 0; 179 return 0;
180} 180}
181 181
@@ -223,7 +223,7 @@ static int lp8755_buck_set_ramp(struct regulator_dev *rdev, int ramp)
223 goto err_i2c; 223 goto err_i2c;
224 return ret; 224 return ret;
225err_i2c: 225err_i2c:
226 dev_err(pchip->dev, "i2c acceess error %s\n", __func__); 226 dev_err(pchip->dev, "i2c access error %s\n", __func__);
227 return ret; 227 return ret;
228} 228}
229 229
@@ -295,7 +295,7 @@ static int lp8755_init_data(struct lp8755_chip *pchip)
295 return ret; 295 return ret;
296 296
297out_i2c_error: 297out_i2c_error:
298 dev_err(pchip->dev, "i2c acceess error %s\n", __func__); 298 dev_err(pchip->dev, "i2c access error %s\n", __func__);
299 return ret; 299 return ret;
300} 300}
301 301
@@ -404,7 +404,7 @@ static irqreturn_t lp8755_irq_handler(int irq, void *data)
404 return IRQ_HANDLED; 404 return IRQ_HANDLED;
405 405
406err_i2c: 406err_i2c:
407 dev_err(pchip->dev, "i2c acceess error %s\n", __func__); 407 dev_err(pchip->dev, "i2c access error %s\n", __func__);
408 return IRQ_NONE; 408 return IRQ_NONE;
409} 409}
410 410
@@ -420,7 +420,7 @@ static int lp8755_int_config(struct lp8755_chip *pchip)
420 420
421 ret = lp8755_read(pchip, 0x0F, &regval); 421 ret = lp8755_read(pchip, 0x0F, &regval);
422 if (ret < 0) { 422 if (ret < 0) {
423 dev_err(pchip->dev, "i2c acceess error %s\n", __func__); 423 dev_err(pchip->dev, "i2c access error %s\n", __func__);
424 return ret; 424 return ret;
425 } 425 }
426 426
diff --git a/drivers/regulator/lp87565-regulator.c b/drivers/regulator/lp87565-regulator.c
new file mode 100644
index 000000000000..cfdbe294fb6a
--- /dev/null
+++ b/drivers/regulator/lp87565-regulator.c
@@ -0,0 +1,236 @@
1/*
2 * Regulator driver for LP87565 PMIC
3 *
4 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2.
9 */
10
11#include <linux/module.h>
12#include <linux/platform_device.h>
13#include <linux/regmap.h>
14
15#include <linux/mfd/lp87565.h>
16
17#define LP87565_REGULATOR(_name, _id, _of, _ops, _n, _vr, _vm, _er, _em, \
18 _delay, _lr, _cr) \
19 [_id] = { \
20 .desc = { \
21 .name = _name, \
22 .supply_name = _of "-in", \
23 .id = _id, \
24 .of_match = of_match_ptr(_of), \
25 .regulators_node = of_match_ptr("regulators"),\
26 .ops = &_ops, \
27 .n_voltages = _n, \
28 .type = REGULATOR_VOLTAGE, \
29 .owner = THIS_MODULE, \
30 .vsel_reg = _vr, \
31 .vsel_mask = _vm, \
32 .enable_reg = _er, \
33 .enable_mask = _em, \
34 .ramp_delay = _delay, \
35 .linear_ranges = _lr, \
36 .n_linear_ranges = ARRAY_SIZE(_lr), \
37 }, \
38 .ctrl2_reg = _cr, \
39 }
40
41struct lp87565_regulator {
42 struct regulator_desc desc;
43 unsigned int ctrl2_reg;
44};
45
46static const struct lp87565_regulator regulators[];
47
48static const struct regulator_linear_range buck0_1_2_3_ranges[] = {
49 REGULATOR_LINEAR_RANGE(600000, 0xA, 0x17, 10000),
50 REGULATOR_LINEAR_RANGE(735000, 0x18, 0x9d, 5000),
51 REGULATOR_LINEAR_RANGE(1420000, 0x9e, 0xff, 20000),
52};
53
54static unsigned int lp87565_buck_ramp_delay[] = {
55 30000, 15000, 10000, 7500, 3800, 1900, 940, 470
56};
57
58/* LP87565 BUCK current limit */
59static const unsigned int lp87565_buck_uA[] = {
60 1500000, 2000000, 2500000, 3000000, 3500000, 4000000, 4500000, 5000000,
61};
62
63static int lp87565_buck_set_ramp_delay(struct regulator_dev *rdev,
64 int ramp_delay)
65{
66 int id = rdev_get_id(rdev);
67 struct lp87565 *lp87565 = rdev_get_drvdata(rdev);
68 unsigned int reg;
69 int ret;
70
71 if (ramp_delay <= 470)
72 reg = 7;
73 else if (ramp_delay <= 940)
74 reg = 6;
75 else if (ramp_delay <= 1900)
76 reg = 5;
77 else if (ramp_delay <= 3800)
78 reg = 4;
79 else if (ramp_delay <= 7500)
80 reg = 3;
81 else if (ramp_delay <= 10000)
82 reg = 2;
83 else if (ramp_delay <= 15000)
84 reg = 1;
85 else
86 reg = 0;
87
88 ret = regmap_update_bits(lp87565->regmap, regulators[id].ctrl2_reg,
89 LP87565_BUCK_CTRL_2_SLEW_RATE,
90 reg << __ffs(LP87565_BUCK_CTRL_2_SLEW_RATE));
91 if (ret) {
92 dev_err(lp87565->dev, "SLEW RATE write failed: %d\n", ret);
93 return ret;
94 }
95
96 rdev->constraints->ramp_delay = lp87565_buck_ramp_delay[reg];
97
98 return 0;
99}
100
101static int lp87565_buck_set_current_limit(struct regulator_dev *rdev,
102 int min_uA, int max_uA)
103{
104 int id = rdev_get_id(rdev);
105 struct lp87565 *lp87565 = rdev_get_drvdata(rdev);
106 int i;
107
108 for (i = ARRAY_SIZE(lp87565_buck_uA) - 1; i >= 0; i--) {
109 if (lp87565_buck_uA[i] >= min_uA &&
110 lp87565_buck_uA[i] <= max_uA)
111 return regmap_update_bits(lp87565->regmap,
112 regulators[id].ctrl2_reg,
113 LP87565_BUCK_CTRL_2_ILIM,
114 i << __ffs(LP87565_BUCK_CTRL_2_ILIM));
115 }
116
117 return -EINVAL;
118}
119
120static int lp87565_buck_get_current_limit(struct regulator_dev *rdev)
121{
122 int id = rdev_get_id(rdev);
123 struct lp87565 *lp87565 = rdev_get_drvdata(rdev);
124 int ret;
125 unsigned int val;
126
127 ret = regmap_read(lp87565->regmap, regulators[id].ctrl2_reg, &val);
128 if (ret)
129 return ret;
130
131 val = (val & LP87565_BUCK_CTRL_2_ILIM) >>
132 __ffs(LP87565_BUCK_CTRL_2_ILIM);
133
134 return (val < ARRAY_SIZE(lp87565_buck_uA)) ?
135 lp87565_buck_uA[val] : -EINVAL;
136}
137
138/* Operations permitted on BUCK0, BUCK1 */
139static struct regulator_ops lp87565_buck_ops = {
140 .is_enabled = regulator_is_enabled_regmap,
141 .enable = regulator_enable_regmap,
142 .disable = regulator_disable_regmap,
143 .get_voltage_sel = regulator_get_voltage_sel_regmap,
144 .set_voltage_sel = regulator_set_voltage_sel_regmap,
145 .list_voltage = regulator_list_voltage_linear_range,
146 .map_voltage = regulator_map_voltage_linear_range,
147 .set_voltage_time_sel = regulator_set_voltage_time_sel,
148 .set_ramp_delay = lp87565_buck_set_ramp_delay,
149 .set_current_limit = lp87565_buck_set_current_limit,
150 .get_current_limit = lp87565_buck_get_current_limit,
151};
152
153static const struct lp87565_regulator regulators[] = {
154 LP87565_REGULATOR("BUCK0", LP87565_BUCK_0, "buck0", lp87565_buck_ops,
155 256, LP87565_REG_BUCK0_VOUT, LP87565_BUCK_VSET,
156 LP87565_REG_BUCK0_CTRL_1,
157 LP87565_BUCK_CTRL_1_EN, 3800,
158 buck0_1_2_3_ranges, LP87565_REG_BUCK0_CTRL_2),
159 LP87565_REGULATOR("BUCK1", LP87565_BUCK_1, "buck1", lp87565_buck_ops,
160 256, LP87565_REG_BUCK1_VOUT, LP87565_BUCK_VSET,
161 LP87565_REG_BUCK1_CTRL_1,
162 LP87565_BUCK_CTRL_1_EN, 3800,
163 buck0_1_2_3_ranges, LP87565_REG_BUCK1_CTRL_2),
164 LP87565_REGULATOR("BUCK2", LP87565_BUCK_2, "buck2", lp87565_buck_ops,
165 256, LP87565_REG_BUCK2_VOUT, LP87565_BUCK_VSET,
166 LP87565_REG_BUCK2_CTRL_1,
167 LP87565_BUCK_CTRL_1_EN, 3800,
168 buck0_1_2_3_ranges, LP87565_REG_BUCK2_CTRL_2),
169 LP87565_REGULATOR("BUCK3", LP87565_BUCK_3, "buck3", lp87565_buck_ops,
170 256, LP87565_REG_BUCK3_VOUT, LP87565_BUCK_VSET,
171 LP87565_REG_BUCK3_CTRL_1,
172 LP87565_BUCK_CTRL_1_EN, 3800,
173 buck0_1_2_3_ranges, LP87565_REG_BUCK3_CTRL_2),
174 LP87565_REGULATOR("BUCK10", LP87565_BUCK_10, "buck10", lp87565_buck_ops,
175 256, LP87565_REG_BUCK0_VOUT, LP87565_BUCK_VSET,
176 LP87565_REG_BUCK0_CTRL_1,
177 LP87565_BUCK_CTRL_1_EN, 3800,
178 buck0_1_2_3_ranges, LP87565_REG_BUCK0_CTRL_2),
179 LP87565_REGULATOR("BUCK23", LP87565_BUCK_23, "buck23", lp87565_buck_ops,
180 256, LP87565_REG_BUCK2_VOUT, LP87565_BUCK_VSET,
181 LP87565_REG_BUCK2_CTRL_1,
182 LP87565_BUCK_CTRL_1_EN, 3800,
183 buck0_1_2_3_ranges, LP87565_REG_BUCK2_CTRL_2),
184};
185
186static int lp87565_regulator_probe(struct platform_device *pdev)
187{
188 struct lp87565 *lp87565 = dev_get_drvdata(pdev->dev.parent);
189 struct regulator_config config = { };
190 struct regulator_dev *rdev;
191 int i, min_idx = LP87565_BUCK_1, max_idx = LP87565_BUCK_3;
192
193 platform_set_drvdata(pdev, lp87565);
194
195 config.dev = &pdev->dev;
196 config.dev->of_node = lp87565->dev->of_node;
197 config.driver_data = lp87565;
198 config.regmap = lp87565->regmap;
199
200 if (lp87565->dev_type == LP87565_DEVICE_TYPE_LP87565_Q1) {
201 min_idx = LP87565_BUCK_10;
202 max_idx = LP87565_BUCK_23;
203 }
204
205 for (i = min_idx; i <= max_idx; i++) {
206 rdev = devm_regulator_register(&pdev->dev, &regulators[i].desc,
207 &config);
208 if (IS_ERR(rdev)) {
209 dev_err(lp87565->dev, "failed to register %s regulator\n",
210 pdev->name);
211 return PTR_ERR(rdev);
212 }
213 }
214
215 return 0;
216}
217
218static const struct platform_device_id lp87565_regulator_id_table[] = {
219 { "lp87565-regulator", },
220 { "lp87565-q1-regulator", },
221 { /* sentinel */ }
222};
223MODULE_DEVICE_TABLE(platform, lp87565_regulator_id_table);
224
225static struct platform_driver lp87565_regulator_driver = {
226 .driver = {
227 .name = "lp87565-pmic",
228 },
229 .probe = lp87565_regulator_probe,
230 .id_table = lp87565_regulator_id_table,
231};
232module_platform_driver(lp87565_regulator_driver);
233
234MODULE_AUTHOR("J Keerthy <j-keerthy@ti.com>");
235MODULE_DESCRIPTION("LP87565 voltage regulator driver");
236MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/max8997-regulator.c b/drivers/regulator/max8997-regulator.c
index efabc0ea0e96..559b9ac45404 100644
--- a/drivers/regulator/max8997-regulator.c
+++ b/drivers/regulator/max8997-regulator.c
@@ -428,12 +428,9 @@ static int max8997_set_voltage_charger_cv(struct regulator_dev *rdev,
428 if (max_uV < 4000000 || min_uV > 4350000) 428 if (max_uV < 4000000 || min_uV > 4350000)
429 return -EINVAL; 429 return -EINVAL;
430 430
431 if (min_uV <= 4000000) { 431 if (min_uV <= 4000000)
432 if (max_uV >= 4000000) 432 val = 0x1;
433 return -EINVAL; 433 else if (min_uV <= 4200000 && max_uV >= 4200000)
434 else
435 val = 0x1;
436 } else if (min_uV <= 4200000 && max_uV >= 4200000)
437 val = 0x0; 434 val = 0x0;
438 else { 435 else {
439 lb = (min_uV - 4000001) / 20000 + 2; 436 lb = (min_uV - 4000001) / 20000 + 2;
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 09d677d5d3f0..96bf75458da5 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -90,6 +90,25 @@ static void of_get_regulation_constraints(struct device_node *np,
90 if (!ret) 90 if (!ret)
91 constraints->settling_time = pval; 91 constraints->settling_time = pval;
92 92
93 ret = of_property_read_u32(np, "regulator-settling-time-up-us", &pval);
94 if (!ret)
95 constraints->settling_time_up = pval;
96 if (constraints->settling_time_up && constraints->settling_time) {
97 pr_warn("%s: ambiguous configuration for settling time, ignoring 'regulator-settling-time-up-us'\n",
98 np->name);
99 constraints->settling_time_up = 0;
100 }
101
102 ret = of_property_read_u32(np, "regulator-settling-time-down-us",
103 &pval);
104 if (!ret)
105 constraints->settling_time_down = pval;
106 if (constraints->settling_time_down && constraints->settling_time) {
107 pr_warn("%s: ambiguous configuration for settling time, ignoring 'regulator-settling-time-down-us'\n",
108 np->name);
109 constraints->settling_time_down = 0;
110 }
111
93 ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval); 112 ret = of_property_read_u32(np, "regulator-enable-ramp-delay", &pval);
94 if (!ret) 113 if (!ret)
95 constraints->enable_time = pval; 114 constraints->enable_time = pval;
diff --git a/drivers/regulator/palmas-regulator.c b/drivers/regulator/palmas-regulator.c
index 31ae5ee3a80d..bb5ab7d78895 100644
--- a/drivers/regulator/palmas-regulator.c
+++ b/drivers/regulator/palmas-regulator.c
@@ -264,6 +264,13 @@ static struct palmas_regs_info tps65917_regs_info[] = {
264 .sleep_id = TPS65917_EXTERNAL_REQSTR_ID_SMPS5, 264 .sleep_id = TPS65917_EXTERNAL_REQSTR_ID_SMPS5,
265 }, 265 },
266 { 266 {
267 .name = "SMPS12",
268 .sname = "smps1-in",
269 .vsel_addr = TPS65917_SMPS1_VOLTAGE,
270 .ctrl_addr = TPS65917_SMPS1_CTRL,
271 .sleep_id = TPS65917_EXTERNAL_REQSTR_ID_SMPS12,
272 },
273 {
267 .name = "LDO1", 274 .name = "LDO1",
268 .sname = "ldo1-in", 275 .sname = "ldo1-in",
269 .vsel_addr = TPS65917_LDO1_VOLTAGE, 276 .vsel_addr = TPS65917_LDO1_VOLTAGE,
@@ -367,6 +374,7 @@ static struct palmas_sleep_requestor_info tps65917_sleep_req_info[] = {
367 EXTERNAL_REQUESTOR_TPS65917(SMPS3, 1, 2), 374 EXTERNAL_REQUESTOR_TPS65917(SMPS3, 1, 2),
368 EXTERNAL_REQUESTOR_TPS65917(SMPS4, 1, 3), 375 EXTERNAL_REQUESTOR_TPS65917(SMPS4, 1, 3),
369 EXTERNAL_REQUESTOR_TPS65917(SMPS5, 1, 4), 376 EXTERNAL_REQUESTOR_TPS65917(SMPS5, 1, 4),
377 EXTERNAL_REQUESTOR_TPS65917(SMPS12, 1, 5),
370 EXTERNAL_REQUESTOR_TPS65917(LDO1, 2, 0), 378 EXTERNAL_REQUESTOR_TPS65917(LDO1, 2, 0),
371 EXTERNAL_REQUESTOR_TPS65917(LDO2, 2, 1), 379 EXTERNAL_REQUESTOR_TPS65917(LDO2, 2, 1),
372 EXTERNAL_REQUESTOR_TPS65917(LDO3, 2, 2), 380 EXTERNAL_REQUESTOR_TPS65917(LDO3, 2, 2),
@@ -1305,7 +1313,8 @@ static int tps65917_smps_registration(struct palmas_pmic *pmic,
1305 */ 1313 */
1306 desc = &pmic->desc[id]; 1314 desc = &pmic->desc[id];
1307 desc->n_linear_ranges = 3; 1315 desc->n_linear_ranges = 3;
1308 if ((id == TPS65917_REG_SMPS2) && pmic->smps12) 1316 if ((id == TPS65917_REG_SMPS2 || id == TPS65917_REG_SMPS1) &&
1317 pmic->smps12)
1309 continue; 1318 continue;
1310 1319
1311 /* Initialise sleep/init values from platform data */ 1320 /* Initialise sleep/init values from platform data */
@@ -1427,6 +1436,7 @@ static struct of_regulator_match tps65917_matches[] = {
1427 { .name = "smps3", }, 1436 { .name = "smps3", },
1428 { .name = "smps4", }, 1437 { .name = "smps4", },
1429 { .name = "smps5", }, 1438 { .name = "smps5", },
1439 { .name = "smps12",},
1430 { .name = "ldo1", }, 1440 { .name = "ldo1", },
1431 { .name = "ldo2", }, 1441 { .name = "ldo2", },
1432 { .name = "ldo3", }, 1442 { .name = "ldo3", },
@@ -1455,7 +1465,7 @@ static struct palmas_pmic_driver_data palmas_ddata = {
1455 1465
1456static struct palmas_pmic_driver_data tps65917_ddata = { 1466static struct palmas_pmic_driver_data tps65917_ddata = {
1457 .smps_start = TPS65917_REG_SMPS1, 1467 .smps_start = TPS65917_REG_SMPS1,
1458 .smps_end = TPS65917_REG_SMPS5, 1468 .smps_end = TPS65917_REG_SMPS12,
1459 .ldo_begin = TPS65917_REG_LDO1, 1469 .ldo_begin = TPS65917_REG_LDO1,
1460 .ldo_end = TPS65917_REG_LDO5, 1470 .ldo_end = TPS65917_REG_LDO5,
1461 .max_reg = TPS65917_NUM_REGS, 1471 .max_reg = TPS65917_NUM_REGS,
@@ -1491,7 +1501,7 @@ static int palmas_dt_to_pdata(struct device *dev,
1491 } 1501 }
1492 1502
1493 for (idx = 0; idx < ddata->max_reg; idx++) { 1503 for (idx = 0; idx < ddata->max_reg; idx++) {
1494 static struct of_regulator_match *match; 1504 struct of_regulator_match *match;
1495 struct palmas_reg_init *rinit; 1505 struct palmas_reg_init *rinit;
1496 struct device_node *np; 1506 struct device_node *np;
1497 1507
@@ -1643,8 +1653,10 @@ static int palmas_regulators_probe(struct platform_device *pdev)
1643 if (ret) 1653 if (ret)
1644 return ret; 1654 return ret;
1645 1655
1646 if (reg & PALMAS_SMPS_CTRL_SMPS12_SMPS123_EN) 1656 if (reg & PALMAS_SMPS_CTRL_SMPS12_SMPS123_EN) {
1647 pmic->smps123 = 1; 1657 pmic->smps123 = 1;
1658 pmic->smps12 = 1;
1659 }
1648 1660
1649 if (reg & PALMAS_SMPS_CTRL_SMPS45_SMPS457_EN) 1661 if (reg & PALMAS_SMPS_CTRL_SMPS45_SMPS457_EN)
1650 pmic->smps457 = 1; 1662 pmic->smps457 = 1;
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c
index 696116ebdf50..81672a58fcc2 100644
--- a/drivers/regulator/tps65910-regulator.c
+++ b/drivers/regulator/tps65910-regulator.c
@@ -1107,6 +1107,7 @@ static int tps65910_probe(struct platform_device *pdev)
1107 1107
1108 switch (tps65910_chip_id(tps65910)) { 1108 switch (tps65910_chip_id(tps65910)) {
1109 case TPS65910: 1109 case TPS65910:
1110 BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65910_regs));
1110 pmic->get_ctrl_reg = &tps65910_get_ctrl_register; 1111 pmic->get_ctrl_reg = &tps65910_get_ctrl_register;
1111 pmic->num_regulators = ARRAY_SIZE(tps65910_regs); 1112 pmic->num_regulators = ARRAY_SIZE(tps65910_regs);
1112 pmic->ext_sleep_control = tps65910_ext_sleep_control; 1113 pmic->ext_sleep_control = tps65910_ext_sleep_control;
@@ -1119,6 +1120,7 @@ static int tps65910_probe(struct platform_device *pdev)
1119 DCDCCTRL_DCDCCKSYNC_MASK); 1120 DCDCCTRL_DCDCCKSYNC_MASK);
1120 break; 1121 break;
1121 case TPS65911: 1122 case TPS65911:
1123 BUILD_BUG_ON(TPS65910_NUM_REGS < ARRAY_SIZE(tps65911_regs));
1122 pmic->get_ctrl_reg = &tps65911_get_ctrl_register; 1124 pmic->get_ctrl_reg = &tps65911_get_ctrl_register;
1123 pmic->num_regulators = ARRAY_SIZE(tps65911_regs); 1125 pmic->num_regulators = ARRAY_SIZE(tps65911_regs);
1124 pmic->ext_sleep_control = tps65911_ext_sleep_control; 1126 pmic->ext_sleep_control = tps65911_ext_sleep_control;
@@ -1144,8 +1146,7 @@ static int tps65910_probe(struct platform_device *pdev)
1144 if (!pmic->rdev) 1146 if (!pmic->rdev)
1145 return -ENOMEM; 1147 return -ENOMEM;
1146 1148
1147 for (i = 0; i < pmic->num_regulators && i < TPS65910_NUM_REGS; 1149 for (i = 0; i < pmic->num_regulators; i++, info++) {
1148 i++, info++) {
1149 /* Register the regulators */ 1150 /* Register the regulators */
1150 pmic->info[i] = info; 1151 pmic->info[i] = info;
1151 1152
diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h
index cde56cfe8446..965b027e31b3 100644
--- a/include/linux/mfd/axp20x.h
+++ b/include/linux/mfd/axp20x.h
@@ -119,6 +119,17 @@ enum axp20x_variants {
119#define AXP806_BUS_ADDR_EXT 0xfe 119#define AXP806_BUS_ADDR_EXT 0xfe
120#define AXP806_REG_ADDR_EXT 0xff 120#define AXP806_REG_ADDR_EXT 0xff
121 121
122#define AXP803_POLYPHASE_CTRL 0x14
123#define AXP803_FLDO1_V_OUT 0x1c
124#define AXP803_FLDO2_V_OUT 0x1d
125#define AXP803_DCDC1_V_OUT 0x20
126#define AXP803_DCDC2_V_OUT 0x21
127#define AXP803_DCDC3_V_OUT 0x22
128#define AXP803_DCDC4_V_OUT 0x23
129#define AXP803_DCDC5_V_OUT 0x24
130#define AXP803_DCDC6_V_OUT 0x25
131#define AXP803_DCDC_FREQ_CTRL 0x3b
132
122/* Interrupt */ 133/* Interrupt */
123#define AXP152_IRQ1_EN 0x40 134#define AXP152_IRQ1_EN 0x40
124#define AXP152_IRQ2_EN 0x41 135#define AXP152_IRQ2_EN 0x41
@@ -350,6 +361,32 @@ enum {
350 AXP809_REG_ID_MAX, 361 AXP809_REG_ID_MAX,
351}; 362};
352 363
364enum {
365 AXP803_DCDC1 = 0,
366 AXP803_DCDC2,
367 AXP803_DCDC3,
368 AXP803_DCDC4,
369 AXP803_DCDC5,
370 AXP803_DCDC6,
371 AXP803_DC1SW,
372 AXP803_ALDO1,
373 AXP803_ALDO2,
374 AXP803_ALDO3,
375 AXP803_DLDO1,
376 AXP803_DLDO2,
377 AXP803_DLDO3,
378 AXP803_DLDO4,
379 AXP803_ELDO1,
380 AXP803_ELDO2,
381 AXP803_ELDO3,
382 AXP803_FLDO1,
383 AXP803_FLDO2,
384 AXP803_RTC_LDO,
385 AXP803_LDO_IO0,
386 AXP803_LDO_IO1,
387 AXP803_REG_ID_MAX,
388};
389
353/* IRQs */ 390/* IRQs */
354enum { 391enum {
355 AXP152_IRQ_LDO0IN_CONNECT = 1, 392 AXP152_IRQ_LDO0IN_CONNECT = 1,
diff --git a/include/linux/mfd/palmas.h b/include/linux/mfd/palmas.h
index 5c9a1d44c125..6dec43826303 100644
--- a/include/linux/mfd/palmas.h
+++ b/include/linux/mfd/palmas.h
@@ -250,6 +250,7 @@ enum tps65917_regulators {
250 TPS65917_REG_SMPS3, 250 TPS65917_REG_SMPS3,
251 TPS65917_REG_SMPS4, 251 TPS65917_REG_SMPS4,
252 TPS65917_REG_SMPS5, 252 TPS65917_REG_SMPS5,
253 TPS65917_REG_SMPS12,
253 /* LDO regulators */ 254 /* LDO regulators */
254 TPS65917_REG_LDO1, 255 TPS65917_REG_LDO1,
255 TPS65917_REG_LDO2, 256 TPS65917_REG_LDO2,
@@ -317,6 +318,7 @@ enum tps65917_external_requestor_id {
317 TPS65917_EXTERNAL_REQSTR_ID_SMPS3, 318 TPS65917_EXTERNAL_REQSTR_ID_SMPS3,
318 TPS65917_EXTERNAL_REQSTR_ID_SMPS4, 319 TPS65917_EXTERNAL_REQSTR_ID_SMPS4,
319 TPS65917_EXTERNAL_REQSTR_ID_SMPS5, 320 TPS65917_EXTERNAL_REQSTR_ID_SMPS5,
321 TPS65917_EXTERNAL_REQSTR_ID_SMPS12,
320 TPS65917_EXTERNAL_REQSTR_ID_LDO1, 322 TPS65917_EXTERNAL_REQSTR_ID_LDO1,
321 TPS65917_EXTERNAL_REQSTR_ID_LDO2, 323 TPS65917_EXTERNAL_REQSTR_ID_LDO2,
322 TPS65917_EXTERNAL_REQSTR_ID_LDO3, 324 TPS65917_EXTERNAL_REQSTR_ID_LDO3,
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h
index ffb21e79204d..deffdcd0236f 100644
--- a/include/linux/mfd/tps65910.h
+++ b/include/linux/mfd/tps65910.h
@@ -879,7 +879,7 @@ struct tps65910_board {
879 bool en_ck32k_xtal; 879 bool en_ck32k_xtal;
880 bool en_dev_slp; 880 bool en_dev_slp;
881 bool pm_off; 881 bool pm_off;
882 struct tps65910_sleep_keepon_data *slp_keepon; 882 struct tps65910_sleep_keepon_data slp_keepon;
883 bool en_gpio_sleep[TPS6591X_MAX_NUM_GPIO]; 883 bool en_gpio_sleep[TPS6591X_MAX_NUM_GPIO];
884 unsigned long regulator_ext_sleep_control[TPS65910_NUM_REGS]; 884 unsigned long regulator_ext_sleep_control[TPS65910_NUM_REGS];
885 struct regulator_init_data *tps65910_pmic_init_data[TPS65910_NUM_REGS]; 885 struct regulator_init_data *tps65910_pmic_init_data[TPS65910_NUM_REGS];
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 117699d1f7df..9cd4fef37203 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -110,6 +110,10 @@ struct regulator_state {
110 * @ramp_delay: Time to settle down after voltage change (unit: uV/us) 110 * @ramp_delay: Time to settle down after voltage change (unit: uV/us)
111 * @settling_time: Time to settle down after voltage change when voltage 111 * @settling_time: Time to settle down after voltage change when voltage
112 * change is non-linear (unit: microseconds). 112 * change is non-linear (unit: microseconds).
113 * @settling_time_up: Time to settle down after voltage increase when voltage
114 * change is non-linear (unit: microseconds).
115 * @settling_time_down : Time to settle down after voltage decrease when
116 * voltage change is non-linear (unit: microseconds).
113 * @active_discharge: Enable/disable active discharge. The enum 117 * @active_discharge: Enable/disable active discharge. The enum
114 * regulator_active_discharge values are used for 118 * regulator_active_discharge values are used for
115 * initialisation. 119 * initialisation.
@@ -152,6 +156,8 @@ struct regulation_constraints {
152 156
153 unsigned int ramp_delay; 157 unsigned int ramp_delay;
154 unsigned int settling_time; 158 unsigned int settling_time;
159 unsigned int settling_time_up;
160 unsigned int settling_time_down;
155 unsigned int enable_time; 161 unsigned int enable_time;
156 162
157 unsigned int active_discharge; 163 unsigned int active_discharge;