aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2018-09-28 10:07:30 -0400
committerMark Brown <broonie@kernel.org>2018-09-28 10:07:30 -0400
commit5451521409ce1c04d56c03854008fe8861893b05 (patch)
tree8d8ee36c9021cd511fdf2f0416664d05b5ec406d
parent5a7d7d0f9f791b1e13f26dbbb07c86482912ad62 (diff)
parent2ece646c90c5b45dd76c76ea207a3f3459f2c472 (diff)
Merge tag 'bd71847-support' into regulator-4.20
regulator/mfd: Support for the ROHM BD71847 This adds support for the BD71847 which touches both MFD and regulator. There's a few other bits and pieces included as some dependency patches had already been applied so would've required rebasing.
-rw-r--r--Documentation/devicetree/bindings/mfd/rohm,bd71837-pmic.txt17
-rw-r--r--Documentation/devicetree/bindings/regulator/rohm,bd71837-regulator.txt12
-rw-r--r--drivers/mfd/rohm-bd718x7.c162
-rw-r--r--drivers/regulator/Kconfig2
-rw-r--r--drivers/regulator/Makefile2
-rw-r--r--drivers/regulator/bd71837-regulator.c626
-rw-r--r--drivers/regulator/bd718x7-regulator.c1138
-rw-r--r--drivers/regulator/core.c9
-rw-r--r--drivers/regulator/helpers.c232
-rw-r--r--drivers/regulator/of_regulator.c2
-rw-r--r--include/linux/mfd/da9063/pdata.h16
-rw-r--r--include/linux/mfd/rohm-bd718x7.h374
-rw-r--r--include/linux/regulator/driver.h20
-rw-r--r--include/linux/regulator/machine.h6
14 files changed, 1694 insertions, 924 deletions
diff --git a/Documentation/devicetree/bindings/mfd/rohm,bd71837-pmic.txt b/Documentation/devicetree/bindings/mfd/rohm,bd71837-pmic.txt
index 3ca56fdb5ffe..a4b056761eaa 100644
--- a/Documentation/devicetree/bindings/mfd/rohm,bd71837-pmic.txt
+++ b/Documentation/devicetree/bindings/mfd/rohm,bd71837-pmic.txt
@@ -1,16 +1,17 @@
1* ROHM BD71837 Power Management Integrated Circuit bindings 1* ROHM BD71837 and BD71847 Power Management Integrated Circuit bindings
2 2
3BD71837MWV is a programmable Power Management IC for powering single-core, 3BD71837MWV and BD71847MWV are programmable Power Management ICs for powering
4dual-core, and quad-core SoCs such as NXP-i.MX 8M. It is optimized for 4single-core, dual-core, and quad-core SoCs such as NXP-i.MX 8M. They are
5low BOM cost and compact solution footprint. It integrates 8 Buck 5optimized for low BOM cost and compact solution footprint. BD71837MWV
6egulators and 7 LDOs to provide all the power rails required by the SoC and 6integrates 8 Buck regulators and 7 LDOs. BD71847MWV contains 6 Buck regulators
7the commonly used peripherals. 7and 6 LDOs.
8 8
9Datasheet for PMIC is available at: 9Datasheet for BD71837 is available at:
10https://www.rohm.com/datasheet/BD71837MWV/bd71837mwv-e 10https://www.rohm.com/datasheet/BD71837MWV/bd71837mwv-e
11 11
12Required properties: 12Required properties:
13 - compatible : Should be "rohm,bd71837". 13 - compatible : Should be "rohm,bd71837" for bd71837
14 "rohm,bd71847" for bd71847.
14 - reg : I2C slave address. 15 - reg : I2C slave address.
15 - interrupt-parent : Phandle to the parent interrupt controller. 16 - interrupt-parent : Phandle to the parent interrupt controller.
16 - interrupts : The interrupt line the device is connected to. 17 - interrupts : The interrupt line the device is connected to.
diff --git a/Documentation/devicetree/bindings/regulator/rohm,bd71837-regulator.txt b/Documentation/devicetree/bindings/regulator/rohm,bd71837-regulator.txt
index 76ead07072b1..4b98ca26e61a 100644
--- a/Documentation/devicetree/bindings/regulator/rohm,bd71837-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/rohm,bd71837-regulator.txt
@@ -1,7 +1,9 @@
1ROHM BD71837 Power Management Integrated Circuit (PMIC) regulator bindings 1ROHM BD71837 and BD71847 Power Management Integrated Circuit regulator bindings
2 2
3Required properties: 3Required properties:
4 - regulator-name: should be "buck1", ..., "buck8" and "ldo1", ..., "ldo7" 4 - regulator-name: should be "buck1", ..., "buck8" and "ldo1", ..., "ldo7" for
5 BD71837. For BD71847 names should be "buck1", ..., "buck6"
6 and "ldo1", ..., "ldo6"
5 7
6List of regulators provided by this controller. BD71837 regulators node 8List of regulators provided by this controller. BD71837 regulators node
7should be sub node of the BD71837 MFD node. See BD71837 MFD bindings at 9should be sub node of the BD71837 MFD node. See BD71837 MFD bindings at
@@ -16,10 +18,14 @@ disabled by driver at startup. LDO5 and LDO6 are supplied by those and
16if they are disabled at startup the voltage monitoring for LDO5/LDO6 will 18if they are disabled at startup the voltage monitoring for LDO5/LDO6 will
17cause PMIC to reset. 19cause PMIC to reset.
18 20
19The valid names for regulator nodes are: 21The valid names for BD71837 regulator nodes are:
20BUCK1, BUCK2, BUCK3, BUCK4, BUCK5, BUCK6, BUCK7, BUCK8 22BUCK1, BUCK2, BUCK3, BUCK4, BUCK5, BUCK6, BUCK7, BUCK8
21LDO1, LDO2, LDO3, LDO4, LDO5, LDO6, LDO7 23LDO1, LDO2, LDO3, LDO4, LDO5, LDO6, LDO7
22 24
25The valid names for BD71847 regulator nodes are:
26BUCK1, BUCK2, BUCK3, BUCK4, BUCK5, BUCK6
27LDO1, LDO2, LDO3, LDO4, LDO5, LDO6
28
23Optional properties: 29Optional properties:
24- Any optional property defined in bindings/regulator/regulator.txt 30- Any optional property defined in bindings/regulator/regulator.txt
25 31
diff --git a/drivers/mfd/rohm-bd718x7.c b/drivers/mfd/rohm-bd718x7.c
index 75c8ec659547..161c8aac6d86 100644
--- a/drivers/mfd/rohm-bd718x7.c
+++ b/drivers/mfd/rohm-bd718x7.c
@@ -2,26 +2,21 @@
2// 2//
3// Copyright (C) 2018 ROHM Semiconductors 3// Copyright (C) 2018 ROHM Semiconductors
4// 4//
5// ROHM BD71837MWV PMIC driver 5// ROHM BD71837MWV and BD71847MWV PMIC driver
6// 6//
7// Datasheet available from 7// Datasheet for BD71837MWV available from
8// https://www.rohm.com/datasheet/BD71837MWV/bd71837mwv-e 8// https://www.rohm.com/datasheet/BD71837MWV/bd71837mwv-e
9 9
10#include <linux/gpio_keys.h>
10#include <linux/i2c.h> 11#include <linux/i2c.h>
11#include <linux/input.h> 12#include <linux/input.h>
12#include <linux/interrupt.h> 13#include <linux/interrupt.h>
13#include <linux/mfd/rohm-bd718x7.h> 14#include <linux/mfd/rohm-bd718x7.h>
14#include <linux/mfd/core.h> 15#include <linux/mfd/core.h>
15#include <linux/module.h> 16#include <linux/module.h>
17#include <linux/of_device.h>
16#include <linux/regmap.h> 18#include <linux/regmap.h>
17 19#include <linux/types.h>
18/*
19 * gpio_keys.h requires definiton of bool. It is brought in
20 * by above includes. Keep this as last until gpio_keys.h gets fixed.
21 */
22#include <linux/gpio_keys.h>
23
24static const u8 supported_revisions[] = { 0xA2 /* BD71837 */ };
25 20
26static struct gpio_keys_button button = { 21static struct gpio_keys_button button = {
27 .code = KEY_POWER, 22 .code = KEY_POWER,
@@ -35,42 +30,42 @@ static struct gpio_keys_platform_data bd718xx_powerkey_data = {
35 .name = "bd718xx-pwrkey", 30 .name = "bd718xx-pwrkey",
36}; 31};
37 32
38static struct mfd_cell bd71837_mfd_cells[] = { 33static struct mfd_cell bd718xx_mfd_cells[] = {
39 { 34 {
40 .name = "gpio-keys", 35 .name = "gpio-keys",
41 .platform_data = &bd718xx_powerkey_data, 36 .platform_data = &bd718xx_powerkey_data,
42 .pdata_size = sizeof(bd718xx_powerkey_data), 37 .pdata_size = sizeof(bd718xx_powerkey_data),
43 }, 38 },
44 { .name = "bd71837-clk", }, 39 { .name = "bd718xx-clk", },
45 { .name = "bd71837-pmic", }, 40 { .name = "bd718xx-pmic", },
46}; 41};
47 42
48static const struct regmap_irq bd71837_irqs[] = { 43static const struct regmap_irq bd718xx_irqs[] = {
49 REGMAP_IRQ_REG(BD71837_INT_SWRST, 0, BD71837_INT_SWRST_MASK), 44 REGMAP_IRQ_REG(BD718XX_INT_SWRST, 0, BD718XX_INT_SWRST_MASK),
50 REGMAP_IRQ_REG(BD71837_INT_PWRBTN_S, 0, BD71837_INT_PWRBTN_S_MASK), 45 REGMAP_IRQ_REG(BD718XX_INT_PWRBTN_S, 0, BD718XX_INT_PWRBTN_S_MASK),
51 REGMAP_IRQ_REG(BD71837_INT_PWRBTN_L, 0, BD71837_INT_PWRBTN_L_MASK), 46 REGMAP_IRQ_REG(BD718XX_INT_PWRBTN_L, 0, BD718XX_INT_PWRBTN_L_MASK),
52 REGMAP_IRQ_REG(BD71837_INT_PWRBTN, 0, BD71837_INT_PWRBTN_MASK), 47 REGMAP_IRQ_REG(BD718XX_INT_PWRBTN, 0, BD718XX_INT_PWRBTN_MASK),
53 REGMAP_IRQ_REG(BD71837_INT_WDOG, 0, BD71837_INT_WDOG_MASK), 48 REGMAP_IRQ_REG(BD718XX_INT_WDOG, 0, BD718XX_INT_WDOG_MASK),
54 REGMAP_IRQ_REG(BD71837_INT_ON_REQ, 0, BD71837_INT_ON_REQ_MASK), 49 REGMAP_IRQ_REG(BD718XX_INT_ON_REQ, 0, BD718XX_INT_ON_REQ_MASK),
55 REGMAP_IRQ_REG(BD71837_INT_STBY_REQ, 0, BD71837_INT_STBY_REQ_MASK), 50 REGMAP_IRQ_REG(BD718XX_INT_STBY_REQ, 0, BD718XX_INT_STBY_REQ_MASK),
56}; 51};
57 52
58static struct regmap_irq_chip bd71837_irq_chip = { 53static struct regmap_irq_chip bd718xx_irq_chip = {
59 .name = "bd71837-irq", 54 .name = "bd718xx-irq",
60 .irqs = bd71837_irqs, 55 .irqs = bd718xx_irqs,
61 .num_irqs = ARRAY_SIZE(bd71837_irqs), 56 .num_irqs = ARRAY_SIZE(bd718xx_irqs),
62 .num_regs = 1, 57 .num_regs = 1,
63 .irq_reg_stride = 1, 58 .irq_reg_stride = 1,
64 .status_base = BD71837_REG_IRQ, 59 .status_base = BD718XX_REG_IRQ,
65 .mask_base = BD71837_REG_MIRQ, 60 .mask_base = BD718XX_REG_MIRQ,
66 .ack_base = BD71837_REG_IRQ, 61 .ack_base = BD718XX_REG_IRQ,
67 .init_ack_masked = true, 62 .init_ack_masked = true,
68 .mask_invert = false, 63 .mask_invert = false,
69}; 64};
70 65
71static const struct regmap_range pmic_status_range = { 66static const struct regmap_range pmic_status_range = {
72 .range_min = BD71837_REG_IRQ, 67 .range_min = BD718XX_REG_IRQ,
73 .range_max = BD71837_REG_POW_STATE, 68 .range_max = BD718XX_REG_POW_STATE,
74}; 69};
75 70
76static const struct regmap_access_table volatile_regs = { 71static const struct regmap_access_table volatile_regs = {
@@ -78,67 +73,53 @@ static const struct regmap_access_table volatile_regs = {
78 .n_yes_ranges = 1, 73 .n_yes_ranges = 1,
79}; 74};
80 75
81static const struct regmap_config bd71837_regmap_config = { 76static const struct regmap_config bd718xx_regmap_config = {
82 .reg_bits = 8, 77 .reg_bits = 8,
83 .val_bits = 8, 78 .val_bits = 8,
84 .volatile_table = &volatile_regs, 79 .volatile_table = &volatile_regs,
85 .max_register = BD71837_MAX_REGISTER - 1, 80 .max_register = BD718XX_MAX_REGISTER - 1,
86 .cache_type = REGCACHE_RBTREE, 81 .cache_type = REGCACHE_RBTREE,
87}; 82};
88 83
89static int bd71837_i2c_probe(struct i2c_client *i2c, 84static int bd718xx_i2c_probe(struct i2c_client *i2c,
90 const struct i2c_device_id *id) 85 const struct i2c_device_id *id)
91{ 86{
92 struct bd71837 *bd71837; 87 struct bd718xx *bd718xx;
93 int ret, i; 88 int ret;
94 unsigned int val;
95
96 bd71837 = devm_kzalloc(&i2c->dev, sizeof(struct bd71837), GFP_KERNEL);
97 89
98 if (!bd71837) 90 if (!i2c->irq) {
99 return -ENOMEM;
100
101 bd71837->chip_irq = i2c->irq;
102
103 if (!bd71837->chip_irq) {
104 dev_err(&i2c->dev, "No IRQ configured\n"); 91 dev_err(&i2c->dev, "No IRQ configured\n");
105 return -EINVAL; 92 return -EINVAL;
106 } 93 }
107 94
108 bd71837->dev = &i2c->dev; 95 bd718xx = devm_kzalloc(&i2c->dev, sizeof(struct bd718xx), GFP_KERNEL);
109 dev_set_drvdata(&i2c->dev, bd71837);
110 96
111 bd71837->regmap = devm_regmap_init_i2c(i2c, &bd71837_regmap_config); 97 if (!bd718xx)
112 if (IS_ERR(bd71837->regmap)) { 98 return -ENOMEM;
113 dev_err(&i2c->dev, "regmap initialization failed\n");
114 return PTR_ERR(bd71837->regmap);
115 }
116 99
117 ret = regmap_read(bd71837->regmap, BD71837_REG_REV, &val); 100 bd718xx->chip_irq = i2c->irq;
118 if (ret) { 101 bd718xx->chip_type = (unsigned int)
119 dev_err(&i2c->dev, "Read BD71837_REG_DEVICE failed\n"); 102 of_device_get_match_data(&i2c->dev);
120 return ret; 103 bd718xx->dev = &i2c->dev;
121 } 104 dev_set_drvdata(&i2c->dev, bd718xx);
122 for (i = 0; i < ARRAY_SIZE(supported_revisions); i++)
123 if (supported_revisions[i] == val)
124 break;
125 105
126 if (i == ARRAY_SIZE(supported_revisions)) { 106 bd718xx->regmap = devm_regmap_init_i2c(i2c, &bd718xx_regmap_config);
127 dev_err(&i2c->dev, "Unsupported chip revision\n"); 107 if (IS_ERR(bd718xx->regmap)) {
128 return -ENODEV; 108 dev_err(&i2c->dev, "regmap initialization failed\n");
109 return PTR_ERR(bd718xx->regmap);
129 } 110 }
130 111
131 ret = devm_regmap_add_irq_chip(&i2c->dev, bd71837->regmap, 112 ret = devm_regmap_add_irq_chip(&i2c->dev, bd718xx->regmap,
132 bd71837->chip_irq, IRQF_ONESHOT, 0, 113 bd718xx->chip_irq, IRQF_ONESHOT, 0,
133 &bd71837_irq_chip, &bd71837->irq_data); 114 &bd718xx_irq_chip, &bd718xx->irq_data);
134 if (ret) { 115 if (ret) {
135 dev_err(&i2c->dev, "Failed to add irq_chip\n"); 116 dev_err(&i2c->dev, "Failed to add irq_chip\n");
136 return ret; 117 return ret;
137 } 118 }
138 119
139 /* Configure short press to 10 milliseconds */ 120 /* Configure short press to 10 milliseconds */
140 ret = regmap_update_bits(bd71837->regmap, 121 ret = regmap_update_bits(bd718xx->regmap,
141 BD71837_REG_PWRONCONFIG0, 122 BD718XX_REG_PWRONCONFIG0,
142 BD718XX_PWRBTN_PRESS_DURATION_MASK, 123 BD718XX_PWRBTN_PRESS_DURATION_MASK,
143 BD718XX_PWRBTN_SHORT_PRESS_10MS); 124 BD718XX_PWRBTN_SHORT_PRESS_10MS);
144 if (ret) { 125 if (ret) {
@@ -148,8 +129,8 @@ static int bd71837_i2c_probe(struct i2c_client *i2c,
148 } 129 }
149 130
150 /* Configure long press to 10 seconds */ 131 /* Configure long press to 10 seconds */
151 ret = regmap_update_bits(bd71837->regmap, 132 ret = regmap_update_bits(bd718xx->regmap,
152 BD71837_REG_PWRONCONFIG1, 133 BD718XX_REG_PWRONCONFIG1,
153 BD718XX_PWRBTN_PRESS_DURATION_MASK, 134 BD718XX_PWRBTN_PRESS_DURATION_MASK,
154 BD718XX_PWRBTN_LONG_PRESS_10S); 135 BD718XX_PWRBTN_LONG_PRESS_10S);
155 136
@@ -159,7 +140,7 @@ static int bd71837_i2c_probe(struct i2c_client *i2c,
159 return ret; 140 return ret;
160 } 141 }
161 142
162 ret = regmap_irq_get_virq(bd71837->irq_data, BD71837_INT_PWRBTN_S); 143 ret = regmap_irq_get_virq(bd718xx->irq_data, BD718XX_INT_PWRBTN_S);
163 144
164 if (ret < 0) { 145 if (ret < 0) {
165 dev_err(&i2c->dev, "Failed to get the IRQ\n"); 146 dev_err(&i2c->dev, "Failed to get the IRQ\n");
@@ -168,44 +149,51 @@ static int bd71837_i2c_probe(struct i2c_client *i2c,
168 149
169 button.irq = ret; 150 button.irq = ret;
170 151
171 ret = devm_mfd_add_devices(bd71837->dev, PLATFORM_DEVID_AUTO, 152 ret = devm_mfd_add_devices(bd718xx->dev, PLATFORM_DEVID_AUTO,
172 bd71837_mfd_cells, 153 bd718xx_mfd_cells,
173 ARRAY_SIZE(bd71837_mfd_cells), NULL, 0, 154 ARRAY_SIZE(bd718xx_mfd_cells), NULL, 0,
174 regmap_irq_get_domain(bd71837->irq_data)); 155 regmap_irq_get_domain(bd718xx->irq_data));
175 if (ret) 156 if (ret)
176 dev_err(&i2c->dev, "Failed to create subdevices\n"); 157 dev_err(&i2c->dev, "Failed to create subdevices\n");
177 158
178 return ret; 159 return ret;
179} 160}
180 161
181static const struct of_device_id bd71837_of_match[] = { 162static const struct of_device_id bd718xx_of_match[] = {
182 { .compatible = "rohm,bd71837", }, 163 {
164 .compatible = "rohm,bd71837",
165 .data = (void *)BD718XX_TYPE_BD71837,
166 },
167 {
168 .compatible = "rohm,bd71847",
169 .data = (void *)BD718XX_TYPE_BD71847,
170 },
183 { } 171 { }
184}; 172};
185MODULE_DEVICE_TABLE(of, bd71837_of_match); 173MODULE_DEVICE_TABLE(of, bd718xx_of_match);
186 174
187static struct i2c_driver bd71837_i2c_driver = { 175static struct i2c_driver bd718xx_i2c_driver = {
188 .driver = { 176 .driver = {
189 .name = "rohm-bd718x7", 177 .name = "rohm-bd718x7",
190 .of_match_table = bd71837_of_match, 178 .of_match_table = bd718xx_of_match,
191 }, 179 },
192 .probe = bd71837_i2c_probe, 180 .probe = bd718xx_i2c_probe,
193}; 181};
194 182
195static int __init bd71837_i2c_init(void) 183static int __init bd718xx_i2c_init(void)
196{ 184{
197 return i2c_add_driver(&bd71837_i2c_driver); 185 return i2c_add_driver(&bd718xx_i2c_driver);
198} 186}
199 187
200/* Initialise early so consumer devices can complete system boot */ 188/* Initialise early so consumer devices can complete system boot */
201subsys_initcall(bd71837_i2c_init); 189subsys_initcall(bd718xx_i2c_init);
202 190
203static void __exit bd71837_i2c_exit(void) 191static void __exit bd718xx_i2c_exit(void)
204{ 192{
205 i2c_del_driver(&bd71837_i2c_driver); 193 i2c_del_driver(&bd718xx_i2c_driver);
206} 194}
207module_exit(bd71837_i2c_exit); 195module_exit(bd718xx_i2c_exit);
208 196
209MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>"); 197MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
210MODULE_DESCRIPTION("ROHM BD71837 Power Management IC driver"); 198MODULE_DESCRIPTION("ROHM BD71837/BD71847 Power Management IC driver");
211MODULE_LICENSE("GPL"); 199MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 329cdd33ed62..6e96ef1bd74a 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -189,7 +189,7 @@ config REGULATOR_BD718XX
189 and LDO regulators. 189 and LDO regulators.
190 190
191 This driver can also be built as a module. If so, the module 191 This driver can also be built as a module. If so, the module
192 will be called bd71837-regulator. 192 will be called bd718x7-regulator.
193 193
194config REGULATOR_BD9571MWV 194config REGULATOR_BD9571MWV
195 tristate "ROHM BD9571MWV Regulators" 195 tristate "ROHM BD9571MWV Regulators"
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 801d9a34a203..eac4d794f3b8 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -27,7 +27,7 @@ obj-$(CONFIG_REGULATOR_AS3711) += as3711-regulator.o
27obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o 27obj-$(CONFIG_REGULATOR_AS3722) += as3722-regulator.o
28obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o 28obj-$(CONFIG_REGULATOR_AXP20X) += axp20x-regulator.o
29obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o 29obj-$(CONFIG_REGULATOR_BCM590XX) += bcm590xx-regulator.o
30obj-$(CONFIG_REGULATOR_BD718XX) += bd71837-regulator.o 30obj-$(CONFIG_REGULATOR_BD718XX) += bd718x7-regulator.o
31obj-$(CONFIG_REGULATOR_BD9571MWV) += bd9571mwv-regulator.o 31obj-$(CONFIG_REGULATOR_BD9571MWV) += bd9571mwv-regulator.o
32obj-$(CONFIG_REGULATOR_DA903X) += da903x.o 32obj-$(CONFIG_REGULATOR_DA903X) += da903x.o
33obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o 33obj-$(CONFIG_REGULATOR_DA9052) += da9052-regulator.o
diff --git a/drivers/regulator/bd71837-regulator.c b/drivers/regulator/bd71837-regulator.c
deleted file mode 100644
index 4fe519581235..000000000000
--- a/drivers/regulator/bd71837-regulator.c
+++ /dev/null
@@ -1,626 +0,0 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2018 ROHM Semiconductors
3// bd71837-regulator.c ROHM BD71837MWV regulator driver
4
5#include <linux/delay.h>
6#include <linux/err.h>
7#include <linux/gpio.h>
8#include <linux/interrupt.h>
9#include <linux/kernel.h>
10#include <linux/mfd/rohm-bd718x7.h>
11#include <linux/module.h>
12#include <linux/of.h>
13#include <linux/platform_device.h>
14#include <linux/regulator/driver.h>
15#include <linux/regulator/machine.h>
16#include <linux/regulator/of_regulator.h>
17#include <linux/slab.h>
18
19struct bd71837_pmic {
20 struct regulator_desc descs[BD71837_REGULATOR_CNT];
21 struct bd71837 *mfd;
22 struct platform_device *pdev;
23 struct regulator_dev *rdev[BD71837_REGULATOR_CNT];
24};
25
26/*
27 * BUCK1/2/3/4
28 * BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting
29 * 00: 10.00mV/usec 10mV 1uS
30 * 01: 5.00mV/usec 10mV 2uS
31 * 10: 2.50mV/usec 10mV 4uS
32 * 11: 1.25mV/usec 10mV 8uS
33 */
34static int bd71837_buck1234_set_ramp_delay(struct regulator_dev *rdev,
35 int ramp_delay)
36{
37 struct bd71837_pmic *pmic = rdev_get_drvdata(rdev);
38 struct bd71837 *mfd = pmic->mfd;
39 int id = rdev->desc->id;
40 unsigned int ramp_value = BUCK_RAMPRATE_10P00MV;
41
42 dev_dbg(&pmic->pdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1,
43 ramp_delay);
44 switch (ramp_delay) {
45 case 1 ... 1250:
46 ramp_value = BUCK_RAMPRATE_1P25MV;
47 break;
48 case 1251 ... 2500:
49 ramp_value = BUCK_RAMPRATE_2P50MV;
50 break;
51 case 2501 ... 5000:
52 ramp_value = BUCK_RAMPRATE_5P00MV;
53 break;
54 case 5001 ... 10000:
55 ramp_value = BUCK_RAMPRATE_10P00MV;
56 break;
57 default:
58 ramp_value = BUCK_RAMPRATE_10P00MV;
59 dev_err(&pmic->pdev->dev,
60 "%s: ramp_delay: %d not supported, setting 10000mV//us\n",
61 rdev->desc->name, ramp_delay);
62 }
63
64 return regmap_update_bits(mfd->regmap, BD71837_REG_BUCK1_CTRL + id,
65 BUCK_RAMPRATE_MASK, ramp_value << 6);
66}
67
68/* Bucks 1 to 4 support DVS. PWM mode is used when voltage is changed.
69 * Bucks 5 to 8 and LDOs can use PFM and must be disabled when voltage
70 * is changed. Hence we return -EBUSY for these if voltage is changed
71 * when BUCK/LDO is enabled.
72 */
73static int bd71837_set_voltage_sel_restricted(struct regulator_dev *rdev,
74 unsigned int sel)
75{
76 if (regulator_is_enabled_regmap(rdev))
77 return -EBUSY;
78
79 return regulator_set_voltage_sel_regmap(rdev, sel);
80}
81
82static struct regulator_ops bd71837_ldo_regulator_ops = {
83 .enable = regulator_enable_regmap,
84 .disable = regulator_disable_regmap,
85 .is_enabled = regulator_is_enabled_regmap,
86 .list_voltage = regulator_list_voltage_linear_range,
87 .set_voltage_sel = bd71837_set_voltage_sel_restricted,
88 .get_voltage_sel = regulator_get_voltage_sel_regmap,
89};
90
91static struct regulator_ops bd71837_ldo_regulator_nolinear_ops = {
92 .enable = regulator_enable_regmap,
93 .disable = regulator_disable_regmap,
94 .is_enabled = regulator_is_enabled_regmap,
95 .list_voltage = regulator_list_voltage_table,
96 .set_voltage_sel = bd71837_set_voltage_sel_restricted,
97 .get_voltage_sel = regulator_get_voltage_sel_regmap,
98};
99
100static struct regulator_ops bd71837_buck_regulator_ops = {
101 .enable = regulator_enable_regmap,
102 .disable = regulator_disable_regmap,
103 .is_enabled = regulator_is_enabled_regmap,
104 .list_voltage = regulator_list_voltage_linear_range,
105 .set_voltage_sel = bd71837_set_voltage_sel_restricted,
106 .get_voltage_sel = regulator_get_voltage_sel_regmap,
107 .set_voltage_time_sel = regulator_set_voltage_time_sel,
108};
109
110static struct regulator_ops bd71837_buck_regulator_nolinear_ops = {
111 .enable = regulator_enable_regmap,
112 .disable = regulator_disable_regmap,
113 .is_enabled = regulator_is_enabled_regmap,
114 .list_voltage = regulator_list_voltage_table,
115 .set_voltage_sel = bd71837_set_voltage_sel_restricted,
116 .get_voltage_sel = regulator_get_voltage_sel_regmap,
117 .set_voltage_time_sel = regulator_set_voltage_time_sel,
118};
119
120static struct regulator_ops bd71837_buck1234_regulator_ops = {
121 .enable = regulator_enable_regmap,
122 .disable = regulator_disable_regmap,
123 .is_enabled = regulator_is_enabled_regmap,
124 .list_voltage = regulator_list_voltage_linear_range,
125 .set_voltage_sel = regulator_set_voltage_sel_regmap,
126 .get_voltage_sel = regulator_get_voltage_sel_regmap,
127 .set_voltage_time_sel = regulator_set_voltage_time_sel,
128 .set_ramp_delay = bd71837_buck1234_set_ramp_delay,
129};
130
131/*
132 * BUCK1/2/3/4
133 * 0.70 to 1.30V (10mV step)
134 */
135static const struct regulator_linear_range bd71837_buck1234_voltage_ranges[] = {
136 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x3C, 10000),
137 REGULATOR_LINEAR_RANGE(1300000, 0x3D, 0x3F, 0),
138};
139
140/*
141 * BUCK5
142 * 0.9V to 1.35V ()
143 */
144static const struct regulator_linear_range bd71837_buck5_voltage_ranges[] = {
145 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
146 REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
147 REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
148};
149
150/*
151 * BUCK6
152 * 3.0V to 3.3V (step 100mV)
153 */
154static const struct regulator_linear_range bd71837_buck6_voltage_ranges[] = {
155 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
156};
157
158/*
159 * BUCK7
160 * 000 = 1.605V
161 * 001 = 1.695V
162 * 010 = 1.755V
163 * 011 = 1.8V (Initial)
164 * 100 = 1.845V
165 * 101 = 1.905V
166 * 110 = 1.95V
167 * 111 = 1.995V
168 */
169static const unsigned int buck_7_volts[] = {
170 1605000, 1695000, 1755000, 1800000, 1845000, 1905000, 1950000, 1995000
171};
172
173/*
174 * BUCK8
175 * 0.8V to 1.40V (step 10mV)
176 */
177static const struct regulator_linear_range bd71837_buck8_voltage_ranges[] = {
178 REGULATOR_LINEAR_RANGE(800000, 0x00, 0x3C, 10000),
179 REGULATOR_LINEAR_RANGE(1400000, 0x3D, 0x3F, 0),
180};
181
182/*
183 * LDO1
184 * 3.0 to 3.3V (100mV step)
185 */
186static const struct regulator_linear_range bd71837_ldo1_voltage_ranges[] = {
187 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
188};
189
190/*
191 * LDO2
192 * 0.8 or 0.9V
193 */
194static const unsigned int ldo_2_volts[] = {
195 900000, 800000
196};
197
198/*
199 * LDO3
200 * 1.8 to 3.3V (100mV step)
201 */
202static const struct regulator_linear_range bd71837_ldo3_voltage_ranges[] = {
203 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
204};
205
206/*
207 * LDO4
208 * 0.9 to 1.8V (100mV step)
209 */
210static const struct regulator_linear_range bd71837_ldo4_voltage_ranges[] = {
211 REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
212 REGULATOR_LINEAR_RANGE(1800000, 0x0A, 0x0F, 0),
213};
214
215/*
216 * LDO5
217 * 1.8 to 3.3V (100mV step)
218 */
219static const struct regulator_linear_range bd71837_ldo5_voltage_ranges[] = {
220 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
221};
222
223/*
224 * LDO6
225 * 0.9 to 1.8V (100mV step)
226 */
227static const struct regulator_linear_range bd71837_ldo6_voltage_ranges[] = {
228 REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
229 REGULATOR_LINEAR_RANGE(1800000, 0x0A, 0x0F, 0),
230};
231
232/*
233 * LDO7
234 * 1.8 to 3.3V (100mV step)
235 */
236static const struct regulator_linear_range bd71837_ldo7_voltage_ranges[] = {
237 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
238};
239
240static const struct regulator_desc bd71837_regulators[] = {
241 {
242 .name = "buck1",
243 .of_match = of_match_ptr("BUCK1"),
244 .regulators_node = of_match_ptr("regulators"),
245 .id = BD71837_BUCK1,
246 .ops = &bd71837_buck1234_regulator_ops,
247 .type = REGULATOR_VOLTAGE,
248 .n_voltages = BD71837_BUCK1_VOLTAGE_NUM,
249 .linear_ranges = bd71837_buck1234_voltage_ranges,
250 .n_linear_ranges = ARRAY_SIZE(bd71837_buck1234_voltage_ranges),
251 .vsel_reg = BD71837_REG_BUCK1_VOLT_RUN,
252 .vsel_mask = BUCK1_RUN_MASK,
253 .enable_reg = BD71837_REG_BUCK1_CTRL,
254 .enable_mask = BD71837_BUCK_EN,
255 .owner = THIS_MODULE,
256 },
257 {
258 .name = "buck2",
259 .of_match = of_match_ptr("BUCK2"),
260 .regulators_node = of_match_ptr("regulators"),
261 .id = BD71837_BUCK2,
262 .ops = &bd71837_buck1234_regulator_ops,
263 .type = REGULATOR_VOLTAGE,
264 .n_voltages = BD71837_BUCK2_VOLTAGE_NUM,
265 .linear_ranges = bd71837_buck1234_voltage_ranges,
266 .n_linear_ranges = ARRAY_SIZE(bd71837_buck1234_voltage_ranges),
267 .vsel_reg = BD71837_REG_BUCK2_VOLT_RUN,
268 .vsel_mask = BUCK2_RUN_MASK,
269 .enable_reg = BD71837_REG_BUCK2_CTRL,
270 .enable_mask = BD71837_BUCK_EN,
271 .owner = THIS_MODULE,
272 },
273 {
274 .name = "buck3",
275 .of_match = of_match_ptr("BUCK3"),
276 .regulators_node = of_match_ptr("regulators"),
277 .id = BD71837_BUCK3,
278 .ops = &bd71837_buck1234_regulator_ops,
279 .type = REGULATOR_VOLTAGE,
280 .n_voltages = BD71837_BUCK3_VOLTAGE_NUM,
281 .linear_ranges = bd71837_buck1234_voltage_ranges,
282 .n_linear_ranges = ARRAY_SIZE(bd71837_buck1234_voltage_ranges),
283 .vsel_reg = BD71837_REG_BUCK3_VOLT_RUN,
284 .vsel_mask = BUCK3_RUN_MASK,
285 .enable_reg = BD71837_REG_BUCK3_CTRL,
286 .enable_mask = BD71837_BUCK_EN,
287 .owner = THIS_MODULE,
288 },
289 {
290 .name = "buck4",
291 .of_match = of_match_ptr("BUCK4"),
292 .regulators_node = of_match_ptr("regulators"),
293 .id = BD71837_BUCK4,
294 .ops = &bd71837_buck1234_regulator_ops,
295 .type = REGULATOR_VOLTAGE,
296 .n_voltages = BD71837_BUCK4_VOLTAGE_NUM,
297 .linear_ranges = bd71837_buck1234_voltage_ranges,
298 .n_linear_ranges = ARRAY_SIZE(bd71837_buck1234_voltage_ranges),
299 .vsel_reg = BD71837_REG_BUCK4_VOLT_RUN,
300 .vsel_mask = BUCK4_RUN_MASK,
301 .enable_reg = BD71837_REG_BUCK4_CTRL,
302 .enable_mask = BD71837_BUCK_EN,
303 .owner = THIS_MODULE,
304 },
305 {
306 .name = "buck5",
307 .of_match = of_match_ptr("BUCK5"),
308 .regulators_node = of_match_ptr("regulators"),
309 .id = BD71837_BUCK5,
310 .ops = &bd71837_buck_regulator_ops,
311 .type = REGULATOR_VOLTAGE,
312 .n_voltages = BD71837_BUCK5_VOLTAGE_NUM,
313 .linear_ranges = bd71837_buck5_voltage_ranges,
314 .n_linear_ranges = ARRAY_SIZE(bd71837_buck5_voltage_ranges),
315 .vsel_reg = BD71837_REG_BUCK5_VOLT,
316 .vsel_mask = BUCK5_MASK,
317 .enable_reg = BD71837_REG_BUCK5_CTRL,
318 .enable_mask = BD71837_BUCK_EN,
319 .owner = THIS_MODULE,
320 },
321 {
322 .name = "buck6",
323 .of_match = of_match_ptr("BUCK6"),
324 .regulators_node = of_match_ptr("regulators"),
325 .id = BD71837_BUCK6,
326 .ops = &bd71837_buck_regulator_ops,
327 .type = REGULATOR_VOLTAGE,
328 .n_voltages = BD71837_BUCK6_VOLTAGE_NUM,
329 .linear_ranges = bd71837_buck6_voltage_ranges,
330 .n_linear_ranges = ARRAY_SIZE(bd71837_buck6_voltage_ranges),
331 .vsel_reg = BD71837_REG_BUCK6_VOLT,
332 .vsel_mask = BUCK6_MASK,
333 .enable_reg = BD71837_REG_BUCK6_CTRL,
334 .enable_mask = BD71837_BUCK_EN,
335 .owner = THIS_MODULE,
336 },
337 {
338 .name = "buck7",
339 .of_match = of_match_ptr("BUCK7"),
340 .regulators_node = of_match_ptr("regulators"),
341 .id = BD71837_BUCK7,
342 .ops = &bd71837_buck_regulator_nolinear_ops,
343 .type = REGULATOR_VOLTAGE,
344 .volt_table = &buck_7_volts[0],
345 .n_voltages = ARRAY_SIZE(buck_7_volts),
346 .vsel_reg = BD71837_REG_BUCK7_VOLT,
347 .vsel_mask = BUCK7_MASK,
348 .enable_reg = BD71837_REG_BUCK7_CTRL,
349 .enable_mask = BD71837_BUCK_EN,
350 .owner = THIS_MODULE,
351 },
352 {
353 .name = "buck8",
354 .of_match = of_match_ptr("BUCK8"),
355 .regulators_node = of_match_ptr("regulators"),
356 .id = BD71837_BUCK8,
357 .ops = &bd71837_buck_regulator_ops,
358 .type = REGULATOR_VOLTAGE,
359 .n_voltages = BD71837_BUCK8_VOLTAGE_NUM,
360 .linear_ranges = bd71837_buck8_voltage_ranges,
361 .n_linear_ranges = ARRAY_SIZE(bd71837_buck8_voltage_ranges),
362 .vsel_reg = BD71837_REG_BUCK8_VOLT,
363 .vsel_mask = BUCK8_MASK,
364 .enable_reg = BD71837_REG_BUCK8_CTRL,
365 .enable_mask = BD71837_BUCK_EN,
366 .owner = THIS_MODULE,
367 },
368 {
369 .name = "ldo1",
370 .of_match = of_match_ptr("LDO1"),
371 .regulators_node = of_match_ptr("regulators"),
372 .id = BD71837_LDO1,
373 .ops = &bd71837_ldo_regulator_ops,
374 .type = REGULATOR_VOLTAGE,
375 .n_voltages = BD71837_LDO1_VOLTAGE_NUM,
376 .linear_ranges = bd71837_ldo1_voltage_ranges,
377 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo1_voltage_ranges),
378 .vsel_reg = BD71837_REG_LDO1_VOLT,
379 .vsel_mask = LDO1_MASK,
380 .enable_reg = BD71837_REG_LDO1_VOLT,
381 .enable_mask = BD71837_LDO_EN,
382 .owner = THIS_MODULE,
383 },
384 {
385 .name = "ldo2",
386 .of_match = of_match_ptr("LDO2"),
387 .regulators_node = of_match_ptr("regulators"),
388 .id = BD71837_LDO2,
389 .ops = &bd71837_ldo_regulator_nolinear_ops,
390 .type = REGULATOR_VOLTAGE,
391 .volt_table = &ldo_2_volts[0],
392 .n_voltages = ARRAY_SIZE(ldo_2_volts),
393 .vsel_reg = BD71837_REG_LDO2_VOLT,
394 .vsel_mask = LDO2_MASK,
395 .enable_reg = BD71837_REG_LDO2_VOLT,
396 .enable_mask = BD71837_LDO_EN,
397 .owner = THIS_MODULE,
398 },
399 {
400 .name = "ldo3",
401 .of_match = of_match_ptr("LDO3"),
402 .regulators_node = of_match_ptr("regulators"),
403 .id = BD71837_LDO3,
404 .ops = &bd71837_ldo_regulator_ops,
405 .type = REGULATOR_VOLTAGE,
406 .n_voltages = BD71837_LDO3_VOLTAGE_NUM,
407 .linear_ranges = bd71837_ldo3_voltage_ranges,
408 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo3_voltage_ranges),
409 .vsel_reg = BD71837_REG_LDO3_VOLT,
410 .vsel_mask = LDO3_MASK,
411 .enable_reg = BD71837_REG_LDO3_VOLT,
412 .enable_mask = BD71837_LDO_EN,
413 .owner = THIS_MODULE,
414 },
415 {
416 .name = "ldo4",
417 .of_match = of_match_ptr("LDO4"),
418 .regulators_node = of_match_ptr("regulators"),
419 .id = BD71837_LDO4,
420 .ops = &bd71837_ldo_regulator_ops,
421 .type = REGULATOR_VOLTAGE,
422 .n_voltages = BD71837_LDO4_VOLTAGE_NUM,
423 .linear_ranges = bd71837_ldo4_voltage_ranges,
424 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo4_voltage_ranges),
425 .vsel_reg = BD71837_REG_LDO4_VOLT,
426 .vsel_mask = LDO4_MASK,
427 .enable_reg = BD71837_REG_LDO4_VOLT,
428 .enable_mask = BD71837_LDO_EN,
429 .owner = THIS_MODULE,
430 },
431 {
432 .name = "ldo5",
433 .of_match = of_match_ptr("LDO5"),
434 .regulators_node = of_match_ptr("regulators"),
435 .id = BD71837_LDO5,
436 .ops = &bd71837_ldo_regulator_ops,
437 .type = REGULATOR_VOLTAGE,
438 .n_voltages = BD71837_LDO5_VOLTAGE_NUM,
439 .linear_ranges = bd71837_ldo5_voltage_ranges,
440 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo5_voltage_ranges),
441 /* LDO5 is supplied by buck6 */
442 .supply_name = "buck6",
443 .vsel_reg = BD71837_REG_LDO5_VOLT,
444 .vsel_mask = LDO5_MASK,
445 .enable_reg = BD71837_REG_LDO5_VOLT,
446 .enable_mask = BD71837_LDO_EN,
447 .owner = THIS_MODULE,
448 },
449 {
450 .name = "ldo6",
451 .of_match = of_match_ptr("LDO6"),
452 .regulators_node = of_match_ptr("regulators"),
453 .id = BD71837_LDO6,
454 .ops = &bd71837_ldo_regulator_ops,
455 .type = REGULATOR_VOLTAGE,
456 .n_voltages = BD71837_LDO6_VOLTAGE_NUM,
457 .linear_ranges = bd71837_ldo6_voltage_ranges,
458 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo6_voltage_ranges),
459 /* LDO6 is supplied by buck7 */
460 .supply_name = "buck7",
461 .vsel_reg = BD71837_REG_LDO6_VOLT,
462 .vsel_mask = LDO6_MASK,
463 .enable_reg = BD71837_REG_LDO6_VOLT,
464 .enable_mask = BD71837_LDO_EN,
465 .owner = THIS_MODULE,
466 },
467 {
468 .name = "ldo7",
469 .of_match = of_match_ptr("LDO7"),
470 .regulators_node = of_match_ptr("regulators"),
471 .id = BD71837_LDO7,
472 .ops = &bd71837_ldo_regulator_ops,
473 .type = REGULATOR_VOLTAGE,
474 .n_voltages = BD71837_LDO7_VOLTAGE_NUM,
475 .linear_ranges = bd71837_ldo7_voltage_ranges,
476 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo7_voltage_ranges),
477 .vsel_reg = BD71837_REG_LDO7_VOLT,
478 .vsel_mask = LDO7_MASK,
479 .enable_reg = BD71837_REG_LDO7_VOLT,
480 .enable_mask = BD71837_LDO_EN,
481 .owner = THIS_MODULE,
482 },
483};
484
485struct reg_init {
486 unsigned int reg;
487 unsigned int mask;
488};
489
490static int bd71837_probe(struct platform_device *pdev)
491{
492 struct bd71837_pmic *pmic;
493 struct regulator_config config = { 0 };
494 struct reg_init pmic_regulator_inits[] = {
495 {
496 .reg = BD71837_REG_BUCK1_CTRL,
497 .mask = BD71837_BUCK_SEL,
498 }, {
499 .reg = BD71837_REG_BUCK2_CTRL,
500 .mask = BD71837_BUCK_SEL,
501 }, {
502 .reg = BD71837_REG_BUCK3_CTRL,
503 .mask = BD71837_BUCK_SEL,
504 }, {
505 .reg = BD71837_REG_BUCK4_CTRL,
506 .mask = BD71837_BUCK_SEL,
507 }, {
508 .reg = BD71837_REG_BUCK5_CTRL,
509 .mask = BD71837_BUCK_SEL,
510 }, {
511 .reg = BD71837_REG_BUCK6_CTRL,
512 .mask = BD71837_BUCK_SEL,
513 }, {
514 .reg = BD71837_REG_BUCK7_CTRL,
515 .mask = BD71837_BUCK_SEL,
516 }, {
517 .reg = BD71837_REG_BUCK8_CTRL,
518 .mask = BD71837_BUCK_SEL,
519 }, {
520 .reg = BD71837_REG_LDO1_VOLT,
521 .mask = BD71837_LDO_SEL,
522 }, {
523 .reg = BD71837_REG_LDO2_VOLT,
524 .mask = BD71837_LDO_SEL,
525 }, {
526 .reg = BD71837_REG_LDO3_VOLT,
527 .mask = BD71837_LDO_SEL,
528 }, {
529 .reg = BD71837_REG_LDO4_VOLT,
530 .mask = BD71837_LDO_SEL,
531 }, {
532 .reg = BD71837_REG_LDO5_VOLT,
533 .mask = BD71837_LDO_SEL,
534 }, {
535 .reg = BD71837_REG_LDO6_VOLT,
536 .mask = BD71837_LDO_SEL,
537 }, {
538 .reg = BD71837_REG_LDO7_VOLT,
539 .mask = BD71837_LDO_SEL,
540 }
541 };
542
543 int i, err;
544
545 pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
546 if (!pmic)
547 return -ENOMEM;
548
549 memcpy(pmic->descs, bd71837_regulators, sizeof(pmic->descs));
550
551 pmic->pdev = pdev;
552 pmic->mfd = dev_get_drvdata(pdev->dev.parent);
553
554 if (!pmic->mfd) {
555 dev_err(&pdev->dev, "No MFD driver data\n");
556 err = -EINVAL;
557 goto err;
558 }
559 platform_set_drvdata(pdev, pmic);
560
561 /* Register LOCK release */
562 err = regmap_update_bits(pmic->mfd->regmap, BD71837_REG_REGLOCK,
563 (REGLOCK_PWRSEQ | REGLOCK_VREG), 0);
564 if (err) {
565 dev_err(&pmic->pdev->dev, "Failed to unlock PMIC (%d)\n", err);
566 goto err;
567 } else {
568 dev_dbg(&pmic->pdev->dev, "Unlocked lock register 0x%x\n",
569 BD71837_REG_REGLOCK);
570 }
571
572 for (i = 0; i < ARRAY_SIZE(pmic_regulator_inits); i++) {
573
574 struct regulator_desc *desc;
575 struct regulator_dev *rdev;
576
577 desc = &pmic->descs[i];
578
579 config.dev = pdev->dev.parent;
580 config.driver_data = pmic;
581 config.regmap = pmic->mfd->regmap;
582
583 rdev = devm_regulator_register(&pdev->dev, desc, &config);
584 if (IS_ERR(rdev)) {
585 dev_err(pmic->mfd->dev,
586 "failed to register %s regulator\n",
587 desc->name);
588 err = PTR_ERR(rdev);
589 goto err;
590 }
591 /* Regulator register gets the regulator constraints and
592 * applies them (set_machine_constraints). This should have
593 * turned the control register(s) to correct values and we
594 * can now switch the control from PMIC state machine to the
595 * register interface
596 */
597 err = regmap_update_bits(pmic->mfd->regmap,
598 pmic_regulator_inits[i].reg,
599 pmic_regulator_inits[i].mask,
600 0xFFFFFFFF);
601 if (err) {
602 dev_err(&pmic->pdev->dev,
603 "Failed to write BUCK/LDO SEL bit for (%s)\n",
604 desc->name);
605 goto err;
606 }
607
608 pmic->rdev[i] = rdev;
609 }
610
611err:
612 return err;
613}
614
615static struct platform_driver bd71837_regulator = {
616 .driver = {
617 .name = "bd71837-pmic",
618 },
619 .probe = bd71837_probe,
620};
621
622module_platform_driver(bd71837_regulator);
623
624MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
625MODULE_DESCRIPTION("BD71837 voltage regulator driver");
626MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c
new file mode 100644
index 000000000000..d2522d4e1505
--- /dev/null
+++ b/drivers/regulator/bd718x7-regulator.c
@@ -0,0 +1,1138 @@
1// SPDX-License-Identifier: GPL-2.0
2// Copyright (C) 2018 ROHM Semiconductors
3// bd71837-regulator.c ROHM BD71837MWV/BD71847MWV regulator driver
4
5#include <linux/delay.h>
6#include <linux/err.h>
7#include <linux/gpio.h>
8#include <linux/interrupt.h>
9#include <linux/kernel.h>
10#include <linux/mfd/rohm-bd718x7.h>
11#include <linux/module.h>
12#include <linux/platform_device.h>
13#include <linux/regulator/driver.h>
14#include <linux/regulator/machine.h>
15#include <linux/regulator/of_regulator.h>
16#include <linux/slab.h>
17
18struct bd718xx_pmic {
19 struct bd718xx_regulator_data *rdata;
20 struct bd718xx *mfd;
21 struct platform_device *pdev;
22 struct regulator_dev *rdev[BD718XX_REGULATOR_AMOUNT];
23};
24
25/*
26 * BUCK1/2/3/4
27 * BUCK1RAMPRATE[1:0] BUCK1 DVS ramp rate setting
28 * 00: 10.00mV/usec 10mV 1uS
29 * 01: 5.00mV/usec 10mV 2uS
30 * 10: 2.50mV/usec 10mV 4uS
31 * 11: 1.25mV/usec 10mV 8uS
32 */
33static int bd718xx_buck1234_set_ramp_delay(struct regulator_dev *rdev,
34 int ramp_delay)
35{
36 struct bd718xx_pmic *pmic = rdev_get_drvdata(rdev);
37 struct bd718xx *mfd = pmic->mfd;
38 int id = rdev->desc->id;
39 unsigned int ramp_value = BUCK_RAMPRATE_10P00MV;
40
41 dev_dbg(&pmic->pdev->dev, "Buck[%d] Set Ramp = %d\n", id + 1,
42 ramp_delay);
43 switch (ramp_delay) {
44 case 1 ... 1250:
45 ramp_value = BUCK_RAMPRATE_1P25MV;
46 break;
47 case 1251 ... 2500:
48 ramp_value = BUCK_RAMPRATE_2P50MV;
49 break;
50 case 2501 ... 5000:
51 ramp_value = BUCK_RAMPRATE_5P00MV;
52 break;
53 case 5001 ... 10000:
54 ramp_value = BUCK_RAMPRATE_10P00MV;
55 break;
56 default:
57 ramp_value = BUCK_RAMPRATE_10P00MV;
58 dev_err(&pmic->pdev->dev,
59 "%s: ramp_delay: %d not supported, setting 10000mV//us\n",
60 rdev->desc->name, ramp_delay);
61 }
62
63 return regmap_update_bits(mfd->regmap, BD718XX_REG_BUCK1_CTRL + id,
64 BUCK_RAMPRATE_MASK, ramp_value << 6);
65}
66
67/* Bucks 1 to 4 support DVS. PWM mode is used when voltage is changed.
68 * Bucks 5 to 8 and LDOs can use PFM and must be disabled when voltage
69 * is changed. Hence we return -EBUSY for these if voltage is changed
70 * when BUCK/LDO is enabled.
71 */
72static int bd718xx_set_voltage_sel_restricted(struct regulator_dev *rdev,
73 unsigned int sel)
74{
75 if (regulator_is_enabled_regmap(rdev))
76 return -EBUSY;
77
78 return regulator_set_voltage_sel_regmap(rdev, sel);
79}
80
81static int bd718xx_set_voltage_sel_pickable_restricted(
82 struct regulator_dev *rdev, unsigned int sel)
83{
84 if (regulator_is_enabled_regmap(rdev))
85 return -EBUSY;
86
87 return regulator_set_voltage_sel_pickable_regmap(rdev, sel);
88}
89
90static struct regulator_ops bd718xx_pickable_range_ldo_ops = {
91 .enable = regulator_enable_regmap,
92 .disable = regulator_disable_regmap,
93 .is_enabled = regulator_is_enabled_regmap,
94 .list_voltage = regulator_list_voltage_pickable_linear_range,
95 .set_voltage_sel = bd718xx_set_voltage_sel_pickable_restricted,
96 .get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
97};
98
99static struct regulator_ops bd718xx_pickable_range_buck_ops = {
100 .enable = regulator_enable_regmap,
101 .disable = regulator_disable_regmap,
102 .is_enabled = regulator_is_enabled_regmap,
103 .list_voltage = regulator_list_voltage_pickable_linear_range,
104 .set_voltage_sel = bd718xx_set_voltage_sel_pickable_restricted,
105 .get_voltage_sel = regulator_get_voltage_sel_pickable_regmap,
106 .set_voltage_time_sel = regulator_set_voltage_time_sel,
107};
108
109static struct regulator_ops bd718xx_ldo_regulator_ops = {
110 .enable = regulator_enable_regmap,
111 .disable = regulator_disable_regmap,
112 .is_enabled = regulator_is_enabled_regmap,
113 .list_voltage = regulator_list_voltage_linear_range,
114 .set_voltage_sel = bd718xx_set_voltage_sel_restricted,
115 .get_voltage_sel = regulator_get_voltage_sel_regmap,
116};
117
118static struct regulator_ops bd718xx_ldo_regulator_nolinear_ops = {
119 .enable = regulator_enable_regmap,
120 .disable = regulator_disable_regmap,
121 .is_enabled = regulator_is_enabled_regmap,
122 .list_voltage = regulator_list_voltage_table,
123 .set_voltage_sel = bd718xx_set_voltage_sel_restricted,
124 .get_voltage_sel = regulator_get_voltage_sel_regmap,
125};
126
127static struct regulator_ops bd718xx_buck_regulator_ops = {
128 .enable = regulator_enable_regmap,
129 .disable = regulator_disable_regmap,
130 .is_enabled = regulator_is_enabled_regmap,
131 .list_voltage = regulator_list_voltage_linear_range,
132 .set_voltage_sel = bd718xx_set_voltage_sel_restricted,
133 .get_voltage_sel = regulator_get_voltage_sel_regmap,
134 .set_voltage_time_sel = regulator_set_voltage_time_sel,
135};
136
137static struct regulator_ops bd718xx_buck_regulator_nolinear_ops = {
138 .enable = regulator_enable_regmap,
139 .disable = regulator_disable_regmap,
140 .is_enabled = regulator_is_enabled_regmap,
141 .list_voltage = regulator_list_voltage_table,
142 .set_voltage_sel = bd718xx_set_voltage_sel_restricted,
143 .get_voltage_sel = regulator_get_voltage_sel_regmap,
144 .set_voltage_time_sel = regulator_set_voltage_time_sel,
145};
146
147static struct regulator_ops bd718xx_dvs_buck_regulator_ops = {
148 .enable = regulator_enable_regmap,
149 .disable = regulator_disable_regmap,
150 .is_enabled = regulator_is_enabled_regmap,
151 .list_voltage = regulator_list_voltage_linear_range,
152 .set_voltage_sel = regulator_set_voltage_sel_regmap,
153 .get_voltage_sel = regulator_get_voltage_sel_regmap,
154 .set_voltage_time_sel = regulator_set_voltage_time_sel,
155 .set_ramp_delay = bd718xx_buck1234_set_ramp_delay,
156};
157
158/*
159 * BD71837 BUCK1/2/3/4
160 * BD71847 BUCK1/2
161 * 0.70 to 1.30V (10mV step)
162 */
163static const struct regulator_linear_range bd718xx_dvs_buck_volts[] = {
164 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x3C, 10000),
165 REGULATOR_LINEAR_RANGE(1300000, 0x3D, 0x3F, 0),
166};
167
168/*
169 * BD71837 BUCK5
170 * 0.7V to 1.35V (range 0)
171 * and
172 * 0.675 to 1.325 (range 1)
173 */
174static const struct regulator_linear_range bd71837_buck5_volts[] = {
175 /* Ranges when VOLT_SEL bit is 0 */
176 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
177 REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
178 REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
179 /* Ranges when VOLT_SEL bit is 1 */
180 REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
181 REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
182 REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
183};
184
185/*
186 * Range selector for first 3 linear ranges is 0x0
187 * and 0x1 for last 3 ranges.
188 */
189static const unsigned int bd71837_buck5_volt_range_sel[] = {
190 0x0, 0x0, 0x0, 0x80, 0x80, 0x80
191};
192
193/*
194 * BD71847 BUCK3
195 */
196static const struct regulator_linear_range bd71847_buck3_volts[] = {
197 /* Ranges when VOLT_SEL bits are 00 */
198 REGULATOR_LINEAR_RANGE(700000, 0x00, 0x03, 100000),
199 REGULATOR_LINEAR_RANGE(1050000, 0x04, 0x05, 50000),
200 REGULATOR_LINEAR_RANGE(1200000, 0x06, 0x07, 150000),
201 /* Ranges when VOLT_SEL bits are 01 */
202 REGULATOR_LINEAR_RANGE(550000, 0x0, 0x7, 50000),
203 /* Ranges when VOLT_SEL bits are 11 */
204 REGULATOR_LINEAR_RANGE(675000, 0x0, 0x3, 100000),
205 REGULATOR_LINEAR_RANGE(1025000, 0x4, 0x5, 50000),
206 REGULATOR_LINEAR_RANGE(1175000, 0x6, 0x7, 150000),
207};
208
209static const unsigned int bd71847_buck3_volt_range_sel[] = {
210 0x0, 0x0, 0x0, 0x40, 0x80, 0x80, 0x80
211};
212
213static const struct regulator_linear_range bd71847_buck4_volts[] = {
214 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
215 REGULATOR_LINEAR_RANGE(2600000, 0x00, 0x03, 100000),
216};
217
218static const unsigned int bd71847_buck4_volt_range_sel[] = { 0x0, 0x40 };
219
220/*
221 * BUCK6
222 * 3.0V to 3.3V (step 100mV)
223 */
224static const struct regulator_linear_range bd71837_buck6_volts[] = {
225 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
226};
227
228/*
229 * BD71837 BUCK7
230 * BD71847 BUCK5
231 * 000 = 1.605V
232 * 001 = 1.695V
233 * 010 = 1.755V
234 * 011 = 1.8V (Initial)
235 * 100 = 1.845V
236 * 101 = 1.905V
237 * 110 = 1.95V
238 * 111 = 1.995V
239 */
240static const unsigned int bd718xx_3rd_nodvs_buck_volts[] = {
241 1605000, 1695000, 1755000, 1800000, 1845000, 1905000, 1950000, 1995000
242};
243
244/*
245 * BUCK8
246 * 0.8V to 1.40V (step 10mV)
247 */
248static const struct regulator_linear_range bd718xx_4th_nodvs_buck_volts[] = {
249 REGULATOR_LINEAR_RANGE(800000, 0x00, 0x3C, 10000),
250};
251
252/*
253 * LDO1
254 * 3.0 to 3.3V (100mV step)
255 */
256static const struct regulator_linear_range bd718xx_ldo1_volts[] = {
257 REGULATOR_LINEAR_RANGE(3000000, 0x00, 0x03, 100000),
258 REGULATOR_LINEAR_RANGE(1600000, 0x00, 0x03, 100000),
259};
260
261static const unsigned int bd718xx_ldo1_volt_range_sel[] = { 0x0, 0x20 };
262
263/*
264 * LDO2
265 * 0.8 or 0.9V
266 */
267static const unsigned int ldo_2_volts[] = {
268 900000, 800000
269};
270
271/*
272 * LDO3
273 * 1.8 to 3.3V (100mV step)
274 */
275static const struct regulator_linear_range bd718xx_ldo3_volts[] = {
276 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
277};
278
279/*
280 * LDO4
281 * 0.9 to 1.8V (100mV step)
282 */
283static const struct regulator_linear_range bd718xx_ldo4_volts[] = {
284 REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
285};
286
287/*
288 * LDO5 for BD71837
289 * 1.8 to 3.3V (100mV step)
290 */
291static const struct regulator_linear_range bd71837_ldo5_volts[] = {
292 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
293};
294
295/*
296 * LDO5 for BD71837
297 * 1.8 to 3.3V (100mV step)
298 */
299static const struct regulator_linear_range bd71847_ldo5_volts[] = {
300 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
301 REGULATOR_LINEAR_RANGE(800000, 0x00, 0x0F, 100000),
302};
303
304static const unsigned int bd71847_ldo5_volt_range_sel[] = { 0x0, 0x20 };
305
306/*
307 * LDO6
308 * 0.9 to 1.8V (100mV step)
309 */
310static const struct regulator_linear_range bd718xx_ldo6_volts[] = {
311 REGULATOR_LINEAR_RANGE(900000, 0x00, 0x09, 100000),
312};
313
314/*
315 * LDO7
316 * 1.8 to 3.3V (100mV step)
317 */
318static const struct regulator_linear_range bd71837_ldo7_volts[] = {
319 REGULATOR_LINEAR_RANGE(1800000, 0x00, 0x0F, 100000),
320};
321
322struct reg_init {
323 unsigned int reg;
324 unsigned int mask;
325 unsigned int val;
326};
327struct bd718xx_regulator_data {
328 struct regulator_desc desc;
329 const struct reg_init init;
330 const struct reg_init *additional_inits;
331 int additional_init_amnt;
332};
333
334/*
335 * There is a HW quirk in BD71837. The shutdown sequence timings for
336 * bucks/LDOs which are controlled via register interface are changed.
337 * At PMIC poweroff the voltage for BUCK6/7 is cut immediately at the
338 * beginning of shut-down sequence. As bucks 6 and 7 are parent
339 * supplies for LDO5 and LDO6 - this causes LDO5/6 voltage
340 * monitoring to errorneously detect under voltage and force PMIC to
341 * emergency state instead of poweroff. In order to avoid this we
342 * disable voltage monitoring for LDO5 and LDO6
343 */
344static const struct reg_init bd71837_ldo5_inits[] = {
345 {
346 .reg = BD718XX_REG_MVRFLTMASK2,
347 .mask = BD718XX_LDO5_VRMON80,
348 .val = BD718XX_LDO5_VRMON80,
349 },
350};
351
352static const struct reg_init bd71837_ldo6_inits[] = {
353 {
354 .reg = BD718XX_REG_MVRFLTMASK2,
355 .mask = BD718XX_LDO6_VRMON80,
356 .val = BD718XX_LDO6_VRMON80,
357 },
358};
359
360static const struct bd718xx_regulator_data bd71847_regulators[] = {
361 {
362 .desc = {
363 .name = "buck1",
364 .of_match = of_match_ptr("BUCK1"),
365 .regulators_node = of_match_ptr("regulators"),
366 .id = BD718XX_BUCK1,
367 .ops = &bd718xx_dvs_buck_regulator_ops,
368 .type = REGULATOR_VOLTAGE,
369 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
370 .linear_ranges = bd718xx_dvs_buck_volts,
371 .n_linear_ranges =
372 ARRAY_SIZE(bd718xx_dvs_buck_volts),
373 .vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
374 .vsel_mask = DVS_BUCK_RUN_MASK,
375 .enable_reg = BD718XX_REG_BUCK1_CTRL,
376 .enable_mask = BD718XX_BUCK_EN,
377 .owner = THIS_MODULE,
378 },
379 .init = {
380 .reg = BD718XX_REG_BUCK1_CTRL,
381 .mask = BD718XX_BUCK_SEL,
382 .val = BD718XX_BUCK_SEL,
383 },
384 },
385 {
386 .desc = {
387 .name = "buck2",
388 .of_match = of_match_ptr("BUCK2"),
389 .regulators_node = of_match_ptr("regulators"),
390 .id = BD718XX_BUCK2,
391 .ops = &bd718xx_dvs_buck_regulator_ops,
392 .type = REGULATOR_VOLTAGE,
393 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
394 .linear_ranges = bd718xx_dvs_buck_volts,
395 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
396 .vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
397 .vsel_mask = DVS_BUCK_RUN_MASK,
398 .enable_reg = BD718XX_REG_BUCK2_CTRL,
399 .enable_mask = BD718XX_BUCK_EN,
400 .owner = THIS_MODULE,
401 },
402 .init = {
403 .reg = BD718XX_REG_BUCK2_CTRL,
404 .mask = BD718XX_BUCK_SEL,
405 .val = BD718XX_BUCK_SEL,
406 },
407 },
408 {
409 .desc = {
410 .name = "buck3",
411 .of_match = of_match_ptr("BUCK3"),
412 .regulators_node = of_match_ptr("regulators"),
413 .id = BD718XX_BUCK3,
414 .ops = &bd718xx_pickable_range_buck_ops,
415 .type = REGULATOR_VOLTAGE,
416 .n_voltages = BD71847_BUCK3_VOLTAGE_NUM,
417 .linear_ranges = bd71847_buck3_volts,
418 .n_linear_ranges =
419 ARRAY_SIZE(bd71847_buck3_volts),
420 .vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
421 .vsel_mask = BD718XX_1ST_NODVS_BUCK_MASK,
422 .vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
423 .vsel_range_mask = BD71847_BUCK3_RANGE_MASK,
424 .linear_range_selectors = bd71847_buck3_volt_range_sel,
425 .enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
426 .enable_mask = BD718XX_BUCK_EN,
427 .owner = THIS_MODULE,
428 },
429 .init = {
430 .reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
431 .mask = BD718XX_BUCK_SEL,
432 .val = BD718XX_BUCK_SEL,
433 },
434 },
435 {
436 .desc = {
437 .name = "buck4",
438 .of_match = of_match_ptr("BUCK4"),
439 .regulators_node = of_match_ptr("regulators"),
440 .id = BD718XX_BUCK4,
441 .ops = &bd718xx_pickable_range_buck_ops,
442 .type = REGULATOR_VOLTAGE,
443 .n_voltages = BD71847_BUCK4_VOLTAGE_NUM,
444 .linear_ranges = bd71847_buck4_volts,
445 .n_linear_ranges =
446 ARRAY_SIZE(bd71847_buck4_volts),
447 .enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
448 .vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
449 .vsel_mask = BD71847_BUCK4_MASK,
450 .vsel_range_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
451 .vsel_range_mask = BD71847_BUCK4_RANGE_MASK,
452 .linear_range_selectors = bd71847_buck4_volt_range_sel,
453 .enable_mask = BD718XX_BUCK_EN,
454 .owner = THIS_MODULE,
455 },
456 .init = {
457 .reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
458 .mask = BD718XX_BUCK_SEL,
459 .val = BD718XX_BUCK_SEL,
460 },
461 },
462 {
463 .desc = {
464 .name = "buck5",
465 .of_match = of_match_ptr("BUCK5"),
466 .regulators_node = of_match_ptr("regulators"),
467 .id = BD718XX_BUCK5,
468 .ops = &bd718xx_buck_regulator_nolinear_ops,
469 .type = REGULATOR_VOLTAGE,
470 .volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
471 .n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
472 .vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
473 .vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
474 .enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
475 .enable_mask = BD718XX_BUCK_EN,
476 .owner = THIS_MODULE,
477 },
478 .init = {
479 .reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
480 .mask = BD718XX_BUCK_SEL,
481 .val = BD718XX_BUCK_SEL,
482 },
483 },
484 {
485 .desc = {
486 .name = "buck6",
487 .of_match = of_match_ptr("BUCK6"),
488 .regulators_node = of_match_ptr("regulators"),
489 .id = BD718XX_BUCK6,
490 .ops = &bd718xx_buck_regulator_ops,
491 .type = REGULATOR_VOLTAGE,
492 .n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
493 .linear_ranges = bd718xx_4th_nodvs_buck_volts,
494 .n_linear_ranges =
495 ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
496 .vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
497 .vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
498 .enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
499 .enable_mask = BD718XX_BUCK_EN,
500 .owner = THIS_MODULE,
501 },
502 .init = {
503 .reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
504 .mask = BD718XX_BUCK_SEL,
505 .val = BD718XX_BUCK_SEL,
506 },
507 },
508 {
509 .desc = {
510 .name = "ldo1",
511 .of_match = of_match_ptr("LDO1"),
512 .regulators_node = of_match_ptr("regulators"),
513 .id = BD718XX_LDO1,
514 .ops = &bd718xx_pickable_range_ldo_ops,
515 .type = REGULATOR_VOLTAGE,
516 .n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
517 .linear_ranges = bd718xx_ldo1_volts,
518 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
519 .vsel_reg = BD718XX_REG_LDO1_VOLT,
520 .vsel_mask = BD718XX_LDO1_MASK,
521 .vsel_range_reg = BD718XX_REG_LDO1_VOLT,
522 .vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
523 .linear_range_selectors = bd718xx_ldo1_volt_range_sel,
524 .enable_reg = BD718XX_REG_LDO1_VOLT,
525 .enable_mask = BD718XX_LDO_EN,
526 .owner = THIS_MODULE,
527 },
528 .init = {
529 .reg = BD718XX_REG_LDO1_VOLT,
530 .mask = BD718XX_LDO_SEL,
531 .val = BD718XX_LDO_SEL,
532 },
533 },
534 {
535 .desc = {
536 .name = "ldo2",
537 .of_match = of_match_ptr("LDO2"),
538 .regulators_node = of_match_ptr("regulators"),
539 .id = BD718XX_LDO2,
540 .ops = &bd718xx_ldo_regulator_nolinear_ops,
541 .type = REGULATOR_VOLTAGE,
542 .volt_table = &ldo_2_volts[0],
543 .vsel_reg = BD718XX_REG_LDO2_VOLT,
544 .vsel_mask = BD718XX_LDO2_MASK,
545 .n_voltages = ARRAY_SIZE(ldo_2_volts),
546 .enable_reg = BD718XX_REG_LDO2_VOLT,
547 .enable_mask = BD718XX_LDO_EN,
548 .owner = THIS_MODULE,
549 },
550 .init = {
551 .reg = BD718XX_REG_LDO2_VOLT,
552 .mask = BD718XX_LDO_SEL,
553 .val = BD718XX_LDO_SEL,
554 },
555 },
556 {
557 .desc = {
558 .name = "ldo3",
559 .of_match = of_match_ptr("LDO3"),
560 .regulators_node = of_match_ptr("regulators"),
561 .id = BD718XX_LDO3,
562 .ops = &bd718xx_ldo_regulator_ops,
563 .type = REGULATOR_VOLTAGE,
564 .n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
565 .linear_ranges = bd718xx_ldo3_volts,
566 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
567 .vsel_reg = BD718XX_REG_LDO3_VOLT,
568 .vsel_mask = BD718XX_LDO3_MASK,
569 .enable_reg = BD718XX_REG_LDO3_VOLT,
570 .enable_mask = BD718XX_LDO_EN,
571 .owner = THIS_MODULE,
572 },
573 .init = {
574 .reg = BD718XX_REG_LDO3_VOLT,
575 .mask = BD718XX_LDO_SEL,
576 .val = BD718XX_LDO_SEL,
577 },
578 },
579 {
580 .desc = {
581 .name = "ldo4",
582 .of_match = of_match_ptr("LDO4"),
583 .regulators_node = of_match_ptr("regulators"),
584 .id = BD718XX_LDO4,
585 .ops = &bd718xx_ldo_regulator_ops,
586 .type = REGULATOR_VOLTAGE,
587 .n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
588 .linear_ranges = bd718xx_ldo4_volts,
589 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
590 .vsel_reg = BD718XX_REG_LDO4_VOLT,
591 .vsel_mask = BD718XX_LDO4_MASK,
592 .enable_reg = BD718XX_REG_LDO4_VOLT,
593 .enable_mask = BD718XX_LDO_EN,
594 .owner = THIS_MODULE,
595 },
596 .init = {
597 .reg = BD718XX_REG_LDO4_VOLT,
598 .mask = BD718XX_LDO_SEL,
599 .val = BD718XX_LDO_SEL,
600 },
601 },
602 {
603 .desc = {
604 .name = "ldo5",
605 .of_match = of_match_ptr("LDO5"),
606 .regulators_node = of_match_ptr("regulators"),
607 .id = BD718XX_LDO5,
608 .ops = &bd718xx_pickable_range_ldo_ops,
609 .type = REGULATOR_VOLTAGE,
610 .n_voltages = BD71847_LDO5_VOLTAGE_NUM,
611 .linear_ranges = bd71847_ldo5_volts,
612 .n_linear_ranges = ARRAY_SIZE(bd71847_ldo5_volts),
613 .vsel_reg = BD718XX_REG_LDO5_VOLT,
614 .vsel_mask = BD71847_LDO5_MASK,
615 .vsel_range_reg = BD718XX_REG_LDO5_VOLT,
616 .vsel_range_mask = BD71847_LDO5_RANGE_MASK,
617 .linear_range_selectors = bd71847_ldo5_volt_range_sel,
618 .enable_reg = BD718XX_REG_LDO5_VOLT,
619 .enable_mask = BD718XX_LDO_EN,
620 .owner = THIS_MODULE,
621 },
622 .init = {
623 .reg = BD718XX_REG_LDO5_VOLT,
624 .mask = BD718XX_LDO_SEL,
625 .val = BD718XX_LDO_SEL,
626 },
627 },
628 {
629 .desc = {
630 .name = "ldo6",
631 .of_match = of_match_ptr("LDO6"),
632 .regulators_node = of_match_ptr("regulators"),
633 .id = BD718XX_LDO6,
634 .ops = &bd718xx_ldo_regulator_ops,
635 .type = REGULATOR_VOLTAGE,
636 .n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
637 .linear_ranges = bd718xx_ldo6_volts,
638 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
639 /* LDO6 is supplied by buck5 */
640 .supply_name = "buck5",
641 .vsel_reg = BD718XX_REG_LDO6_VOLT,
642 .vsel_mask = BD718XX_LDO6_MASK,
643 .enable_reg = BD718XX_REG_LDO6_VOLT,
644 .enable_mask = BD718XX_LDO_EN,
645 .owner = THIS_MODULE,
646 },
647 .init = {
648 .reg = BD718XX_REG_LDO6_VOLT,
649 .mask = BD718XX_LDO_SEL,
650 .val = BD718XX_LDO_SEL,
651 },
652 },
653};
654
655static const struct bd718xx_regulator_data bd71837_regulators[] = {
656 {
657 .desc = {
658 .name = "buck1",
659 .of_match = of_match_ptr("BUCK1"),
660 .regulators_node = of_match_ptr("regulators"),
661 .id = BD718XX_BUCK1,
662 .ops = &bd718xx_dvs_buck_regulator_ops,
663 .type = REGULATOR_VOLTAGE,
664 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
665 .linear_ranges = bd718xx_dvs_buck_volts,
666 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
667 .vsel_reg = BD718XX_REG_BUCK1_VOLT_RUN,
668 .vsel_mask = DVS_BUCK_RUN_MASK,
669 .enable_reg = BD718XX_REG_BUCK1_CTRL,
670 .enable_mask = BD718XX_BUCK_EN,
671 .owner = THIS_MODULE,
672 },
673 .init = {
674 .reg = BD718XX_REG_BUCK1_CTRL,
675 .mask = BD718XX_BUCK_SEL,
676 .val = BD718XX_BUCK_SEL,
677 },
678 },
679 {
680 .desc = {
681 .name = "buck2",
682 .of_match = of_match_ptr("BUCK2"),
683 .regulators_node = of_match_ptr("regulators"),
684 .id = BD718XX_BUCK2,
685 .ops = &bd718xx_dvs_buck_regulator_ops,
686 .type = REGULATOR_VOLTAGE,
687 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
688 .linear_ranges = bd718xx_dvs_buck_volts,
689 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
690 .vsel_reg = BD718XX_REG_BUCK2_VOLT_RUN,
691 .vsel_mask = DVS_BUCK_RUN_MASK,
692 .enable_reg = BD718XX_REG_BUCK2_CTRL,
693 .enable_mask = BD718XX_BUCK_EN,
694 .owner = THIS_MODULE,
695 },
696 .init = {
697 .reg = BD718XX_REG_BUCK2_CTRL,
698 .mask = BD718XX_BUCK_SEL,
699 .val = BD718XX_BUCK_SEL,
700 },
701 },
702 {
703 .desc = {
704 .name = "buck3",
705 .of_match = of_match_ptr("BUCK3"),
706 .regulators_node = of_match_ptr("regulators"),
707 .id = BD718XX_BUCK3,
708 .ops = &bd718xx_dvs_buck_regulator_ops,
709 .type = REGULATOR_VOLTAGE,
710 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
711 .linear_ranges = bd718xx_dvs_buck_volts,
712 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
713 .vsel_reg = BD71837_REG_BUCK3_VOLT_RUN,
714 .vsel_mask = DVS_BUCK_RUN_MASK,
715 .enable_reg = BD71837_REG_BUCK3_CTRL,
716 .enable_mask = BD718XX_BUCK_EN,
717 .owner = THIS_MODULE,
718 },
719 .init = {
720 .reg = BD71837_REG_BUCK3_CTRL,
721 .mask = BD718XX_BUCK_SEL,
722 .val = BD718XX_BUCK_SEL,
723 },
724 },
725 {
726 .desc = {
727 .name = "buck4",
728 .of_match = of_match_ptr("BUCK4"),
729 .regulators_node = of_match_ptr("regulators"),
730 .id = BD718XX_BUCK4,
731 .ops = &bd718xx_dvs_buck_regulator_ops,
732 .type = REGULATOR_VOLTAGE,
733 .n_voltages = BD718XX_DVS_BUCK_VOLTAGE_NUM,
734 .linear_ranges = bd718xx_dvs_buck_volts,
735 .n_linear_ranges = ARRAY_SIZE(bd718xx_dvs_buck_volts),
736 .vsel_reg = BD71837_REG_BUCK4_VOLT_RUN,
737 .vsel_mask = DVS_BUCK_RUN_MASK,
738 .enable_reg = BD71837_REG_BUCK4_CTRL,
739 .enable_mask = BD718XX_BUCK_EN,
740 .owner = THIS_MODULE,
741 },
742 .init = {
743 .reg = BD71837_REG_BUCK4_CTRL,
744 .mask = BD718XX_BUCK_SEL,
745 .val = BD718XX_BUCK_SEL,
746 },
747 },
748 {
749 .desc = {
750 .name = "buck5",
751 .of_match = of_match_ptr("BUCK5"),
752 .regulators_node = of_match_ptr("regulators"),
753 .id = BD718XX_BUCK5,
754 .ops = &bd718xx_pickable_range_buck_ops,
755 .type = REGULATOR_VOLTAGE,
756 .n_voltages = BD71837_BUCK5_VOLTAGE_NUM,
757 .linear_ranges = bd71837_buck5_volts,
758 .n_linear_ranges =
759 ARRAY_SIZE(bd71837_buck5_volts),
760 .vsel_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
761 .vsel_mask = BD71837_BUCK5_MASK,
762 .vsel_range_reg = BD718XX_REG_1ST_NODVS_BUCK_VOLT,
763 .vsel_range_mask = BD71837_BUCK5_RANGE_MASK,
764 .linear_range_selectors = bd71837_buck5_volt_range_sel,
765 .enable_reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
766 .enable_mask = BD718XX_BUCK_EN,
767 .owner = THIS_MODULE,
768 },
769 .init = {
770 .reg = BD718XX_REG_1ST_NODVS_BUCK_CTRL,
771 .mask = BD718XX_BUCK_SEL,
772 .val = BD718XX_BUCK_SEL,
773 },
774 },
775 {
776 .desc = {
777 .name = "buck6",
778 .of_match = of_match_ptr("BUCK6"),
779 .regulators_node = of_match_ptr("regulators"),
780 .id = BD718XX_BUCK6,
781 .ops = &bd718xx_buck_regulator_ops,
782 .type = REGULATOR_VOLTAGE,
783 .n_voltages = BD71837_BUCK6_VOLTAGE_NUM,
784 .linear_ranges = bd71837_buck6_volts,
785 .n_linear_ranges =
786 ARRAY_SIZE(bd71837_buck6_volts),
787 .vsel_reg = BD718XX_REG_2ND_NODVS_BUCK_VOLT,
788 .vsel_mask = BD71837_BUCK6_MASK,
789 .enable_reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
790 .enable_mask = BD718XX_BUCK_EN,
791 .owner = THIS_MODULE,
792 },
793 .init = {
794 .reg = BD718XX_REG_2ND_NODVS_BUCK_CTRL,
795 .mask = BD718XX_BUCK_SEL,
796 .val = BD718XX_BUCK_SEL,
797 },
798 },
799 {
800 .desc = {
801 .name = "buck7",
802 .of_match = of_match_ptr("BUCK7"),
803 .regulators_node = of_match_ptr("regulators"),
804 .id = BD718XX_BUCK7,
805 .ops = &bd718xx_buck_regulator_nolinear_ops,
806 .type = REGULATOR_VOLTAGE,
807 .volt_table = &bd718xx_3rd_nodvs_buck_volts[0],
808 .n_voltages = ARRAY_SIZE(bd718xx_3rd_nodvs_buck_volts),
809 .vsel_reg = BD718XX_REG_3RD_NODVS_BUCK_VOLT,
810 .vsel_mask = BD718XX_3RD_NODVS_BUCK_MASK,
811 .enable_reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
812 .enable_mask = BD718XX_BUCK_EN,
813 .owner = THIS_MODULE,
814 },
815 .init = {
816 .reg = BD718XX_REG_3RD_NODVS_BUCK_CTRL,
817 .mask = BD718XX_BUCK_SEL,
818 .val = BD718XX_BUCK_SEL,
819 },
820 },
821 {
822 .desc = {
823 .name = "buck8",
824 .of_match = of_match_ptr("BUCK8"),
825 .regulators_node = of_match_ptr("regulators"),
826 .id = BD718XX_BUCK8,
827 .ops = &bd718xx_buck_regulator_ops,
828 .type = REGULATOR_VOLTAGE,
829 .n_voltages = BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM,
830 .linear_ranges = bd718xx_4th_nodvs_buck_volts,
831 .n_linear_ranges =
832 ARRAY_SIZE(bd718xx_4th_nodvs_buck_volts),
833 .vsel_reg = BD718XX_REG_4TH_NODVS_BUCK_VOLT,
834 .vsel_mask = BD718XX_4TH_NODVS_BUCK_MASK,
835 .enable_reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
836 .enable_mask = BD718XX_BUCK_EN,
837 .owner = THIS_MODULE,
838 },
839 .init = {
840 .reg = BD718XX_REG_4TH_NODVS_BUCK_CTRL,
841 .mask = BD718XX_BUCK_SEL,
842 .val = BD718XX_BUCK_SEL,
843 },
844 },
845 {
846 .desc = {
847 .name = "ldo1",
848 .of_match = of_match_ptr("LDO1"),
849 .regulators_node = of_match_ptr("regulators"),
850 .id = BD718XX_LDO1,
851 .ops = &bd718xx_pickable_range_ldo_ops,
852 .type = REGULATOR_VOLTAGE,
853 .n_voltages = BD718XX_LDO1_VOLTAGE_NUM,
854 .linear_ranges = bd718xx_ldo1_volts,
855 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo1_volts),
856 .vsel_reg = BD718XX_REG_LDO1_VOLT,
857 .vsel_mask = BD718XX_LDO1_MASK,
858 .vsel_range_reg = BD718XX_REG_LDO1_VOLT,
859 .vsel_range_mask = BD718XX_LDO1_RANGE_MASK,
860 .linear_range_selectors = bd718xx_ldo1_volt_range_sel,
861 .enable_reg = BD718XX_REG_LDO1_VOLT,
862 .enable_mask = BD718XX_LDO_EN,
863 .owner = THIS_MODULE,
864 },
865 .init = {
866 .reg = BD718XX_REG_LDO1_VOLT,
867 .mask = BD718XX_LDO_SEL,
868 .val = BD718XX_LDO_SEL,
869 },
870 },
871 {
872 .desc = {
873 .name = "ldo2",
874 .of_match = of_match_ptr("LDO2"),
875 .regulators_node = of_match_ptr("regulators"),
876 .id = BD718XX_LDO2,
877 .ops = &bd718xx_ldo_regulator_nolinear_ops,
878 .type = REGULATOR_VOLTAGE,
879 .volt_table = &ldo_2_volts[0],
880 .vsel_reg = BD718XX_REG_LDO2_VOLT,
881 .vsel_mask = BD718XX_LDO2_MASK,
882 .n_voltages = ARRAY_SIZE(ldo_2_volts),
883 .enable_reg = BD718XX_REG_LDO2_VOLT,
884 .enable_mask = BD718XX_LDO_EN,
885 .owner = THIS_MODULE,
886 },
887 .init = {
888 .reg = BD718XX_REG_LDO2_VOLT,
889 .mask = BD718XX_LDO_SEL,
890 .val = BD718XX_LDO_SEL,
891 },
892 },
893 {
894 .desc = {
895 .name = "ldo3",
896 .of_match = of_match_ptr("LDO3"),
897 .regulators_node = of_match_ptr("regulators"),
898 .id = BD718XX_LDO3,
899 .ops = &bd718xx_ldo_regulator_ops,
900 .type = REGULATOR_VOLTAGE,
901 .n_voltages = BD718XX_LDO3_VOLTAGE_NUM,
902 .linear_ranges = bd718xx_ldo3_volts,
903 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo3_volts),
904 .vsel_reg = BD718XX_REG_LDO3_VOLT,
905 .vsel_mask = BD718XX_LDO3_MASK,
906 .enable_reg = BD718XX_REG_LDO3_VOLT,
907 .enable_mask = BD718XX_LDO_EN,
908 .owner = THIS_MODULE,
909 },
910 .init = {
911 .reg = BD718XX_REG_LDO3_VOLT,
912 .mask = BD718XX_LDO_SEL,
913 .val = BD718XX_LDO_SEL,
914 },
915 },
916 {
917 .desc = {
918 .name = "ldo4",
919 .of_match = of_match_ptr("LDO4"),
920 .regulators_node = of_match_ptr("regulators"),
921 .id = BD718XX_LDO4,
922 .ops = &bd718xx_ldo_regulator_ops,
923 .type = REGULATOR_VOLTAGE,
924 .n_voltages = BD718XX_LDO4_VOLTAGE_NUM,
925 .linear_ranges = bd718xx_ldo4_volts,
926 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo4_volts),
927 .vsel_reg = BD718XX_REG_LDO4_VOLT,
928 .vsel_mask = BD718XX_LDO4_MASK,
929 .enable_reg = BD718XX_REG_LDO4_VOLT,
930 .enable_mask = BD718XX_LDO_EN,
931 .owner = THIS_MODULE,
932 },
933 .init = {
934 .reg = BD718XX_REG_LDO4_VOLT,
935 .mask = BD718XX_LDO_SEL,
936 .val = BD718XX_LDO_SEL,
937 },
938 },
939 {
940 .desc = {
941 .name = "ldo5",
942 .of_match = of_match_ptr("LDO5"),
943 .regulators_node = of_match_ptr("regulators"),
944 .id = BD718XX_LDO5,
945 .ops = &bd718xx_ldo_regulator_ops,
946 .type = REGULATOR_VOLTAGE,
947 .n_voltages = BD71837_LDO5_VOLTAGE_NUM,
948 .linear_ranges = bd71837_ldo5_volts,
949 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo5_volts),
950 /* LDO5 is supplied by buck6 */
951 .supply_name = "buck6",
952 .vsel_reg = BD718XX_REG_LDO5_VOLT,
953 .vsel_mask = BD71837_LDO5_MASK,
954 .enable_reg = BD718XX_REG_LDO5_VOLT,
955 .enable_mask = BD718XX_LDO_EN,
956 .owner = THIS_MODULE,
957 },
958 .init = {
959 .reg = BD718XX_REG_LDO5_VOLT,
960 .mask = BD718XX_LDO_SEL,
961 .val = BD718XX_LDO_SEL,
962 },
963 .additional_inits = bd71837_ldo5_inits,
964 .additional_init_amnt = ARRAY_SIZE(bd71837_ldo5_inits),
965 },
966 {
967 .desc = {
968 .name = "ldo6",
969 .of_match = of_match_ptr("LDO6"),
970 .regulators_node = of_match_ptr("regulators"),
971 .id = BD718XX_LDO6,
972 .ops = &bd718xx_ldo_regulator_ops,
973 .type = REGULATOR_VOLTAGE,
974 .n_voltages = BD718XX_LDO6_VOLTAGE_NUM,
975 .linear_ranges = bd718xx_ldo6_volts,
976 .n_linear_ranges = ARRAY_SIZE(bd718xx_ldo6_volts),
977 /* LDO6 is supplied by buck7 */
978 .supply_name = "buck7",
979 .vsel_reg = BD718XX_REG_LDO6_VOLT,
980 .vsel_mask = BD718XX_LDO6_MASK,
981 .enable_reg = BD718XX_REG_LDO6_VOLT,
982 .enable_mask = BD718XX_LDO_EN,
983 .owner = THIS_MODULE,
984 },
985 .init = {
986 .reg = BD718XX_REG_LDO6_VOLT,
987 .mask = BD718XX_LDO_SEL,
988 .val = BD718XX_LDO_SEL,
989 },
990 .additional_inits = bd71837_ldo6_inits,
991 .additional_init_amnt = ARRAY_SIZE(bd71837_ldo6_inits),
992 },
993 {
994 .desc = {
995 .name = "ldo7",
996 .of_match = of_match_ptr("LDO7"),
997 .regulators_node = of_match_ptr("regulators"),
998 .id = BD718XX_LDO7,
999 .ops = &bd718xx_ldo_regulator_ops,
1000 .type = REGULATOR_VOLTAGE,
1001 .n_voltages = BD71837_LDO7_VOLTAGE_NUM,
1002 .linear_ranges = bd71837_ldo7_volts,
1003 .n_linear_ranges = ARRAY_SIZE(bd71837_ldo7_volts),
1004 .vsel_reg = BD71837_REG_LDO7_VOLT,
1005 .vsel_mask = BD71837_LDO7_MASK,
1006 .enable_reg = BD71837_REG_LDO7_VOLT,
1007 .enable_mask = BD718XX_LDO_EN,
1008 .owner = THIS_MODULE,
1009 },
1010 .init = {
1011 .reg = BD71837_REG_LDO7_VOLT,
1012 .mask = BD718XX_LDO_SEL,
1013 .val = BD718XX_LDO_SEL,
1014 },
1015 },
1016};
1017
1018struct bd718xx_pmic_inits {
1019 const struct bd718xx_regulator_data (*r_datas)[];
1020 unsigned int r_amount;
1021};
1022
1023static int bd718xx_probe(struct platform_device *pdev)
1024{
1025 struct bd718xx_pmic *pmic;
1026 struct regulator_config config = { 0 };
1027 struct bd718xx_pmic_inits pmic_regulators[] = {
1028 [BD718XX_TYPE_BD71837] = {
1029 .r_datas = &bd71837_regulators,
1030 .r_amount = ARRAY_SIZE(bd71837_regulators),
1031 },
1032 [BD718XX_TYPE_BD71847] = {
1033 .r_datas = &bd71847_regulators,
1034 .r_amount = ARRAY_SIZE(bd71847_regulators),
1035 },
1036 };
1037
1038 int i, j, err;
1039
1040 pmic = devm_kzalloc(&pdev->dev, sizeof(*pmic), GFP_KERNEL);
1041 if (!pmic)
1042 return -ENOMEM;
1043
1044 pmic->pdev = pdev;
1045 pmic->mfd = dev_get_drvdata(pdev->dev.parent);
1046
1047 if (!pmic->mfd) {
1048 dev_err(&pdev->dev, "No MFD driver data\n");
1049 err = -EINVAL;
1050 goto err;
1051 }
1052 if (pmic->mfd->chip_type >= BD718XX_TYPE_AMOUNT ||
1053 !pmic_regulators[pmic->mfd->chip_type].r_datas) {
1054 dev_err(&pdev->dev, "Unsupported chip type\n");
1055 err = -EINVAL;
1056 goto err;
1057 }
1058
1059 platform_set_drvdata(pdev, pmic);
1060
1061 /* Register LOCK release */
1062 err = regmap_update_bits(pmic->mfd->regmap, BD718XX_REG_REGLOCK,
1063 (REGLOCK_PWRSEQ | REGLOCK_VREG), 0);
1064 if (err) {
1065 dev_err(&pmic->pdev->dev, "Failed to unlock PMIC (%d)\n", err);
1066 goto err;
1067 } else {
1068 dev_dbg(&pmic->pdev->dev, "Unlocked lock register 0x%x\n",
1069 BD718XX_REG_REGLOCK);
1070 }
1071
1072 for (i = 0; i < pmic_regulators[pmic->mfd->chip_type].r_amount; i++) {
1073
1074 const struct regulator_desc *desc;
1075 struct regulator_dev *rdev;
1076 const struct bd718xx_regulator_data *r;
1077
1078 r = &(*pmic_regulators[pmic->mfd->chip_type].r_datas)[i];
1079 desc = &r->desc;
1080
1081 config.dev = pdev->dev.parent;
1082 config.driver_data = pmic;
1083 config.regmap = pmic->mfd->regmap;
1084
1085 rdev = devm_regulator_register(&pdev->dev, desc, &config);
1086 if (IS_ERR(rdev)) {
1087 dev_err(pmic->mfd->dev,
1088 "failed to register %s regulator\n",
1089 desc->name);
1090 err = PTR_ERR(rdev);
1091 goto err;
1092 }
1093 /* Regulator register gets the regulator constraints and
1094 * applies them (set_machine_constraints). This should have
1095 * turned the control register(s) to correct values and we
1096 * can now switch the control from PMIC state machine to the
1097 * register interface
1098 */
1099 err = regmap_update_bits(pmic->mfd->regmap, r->init.reg,
1100 r->init.mask, r->init.val);
1101 if (err) {
1102 dev_err(&pmic->pdev->dev,
1103 "Failed to write BUCK/LDO SEL bit for (%s)\n",
1104 desc->name);
1105 goto err;
1106 }
1107 for (j = 0; j < r->additional_init_amnt; j++) {
1108 err = regmap_update_bits(pmic->mfd->regmap,
1109 r->additional_inits[j].reg,
1110 r->additional_inits[j].mask,
1111 r->additional_inits[j].val);
1112 if (err) {
1113 dev_err(&pmic->pdev->dev,
1114 "Buck (%s) initialization failed\n",
1115 desc->name);
1116 goto err;
1117 }
1118 }
1119
1120 pmic->rdev[i] = rdev;
1121 }
1122
1123err:
1124 return err;
1125}
1126
1127static struct platform_driver bd718xx_regulator = {
1128 .driver = {
1129 .name = "bd718xx-pmic",
1130 },
1131 .probe = bd718xx_probe,
1132};
1133
1134module_platform_driver(bd718xx_regulator);
1135
1136MODULE_AUTHOR("Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>");
1137MODULE_DESCRIPTION("BD71837/BD71847 voltage regulator driver");
1138MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 45fee12b9878..2c66b528aede 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2788,6 +2788,11 @@ static int regulator_map_voltage(struct regulator_dev *rdev, int min_uV,
2788 if (desc->ops->list_voltage == regulator_list_voltage_linear_range) 2788 if (desc->ops->list_voltage == regulator_list_voltage_linear_range)
2789 return regulator_map_voltage_linear_range(rdev, min_uV, max_uV); 2789 return regulator_map_voltage_linear_range(rdev, min_uV, max_uV);
2790 2790
2791 if (desc->ops->list_voltage ==
2792 regulator_list_voltage_pickable_linear_range)
2793 return regulator_map_voltage_pickable_linear_range(rdev,
2794 min_uV, max_uV);
2795
2791 return regulator_map_voltage_iterate(rdev, min_uV, max_uV); 2796 return regulator_map_voltage_iterate(rdev, min_uV, max_uV);
2792} 2797}
2793 2798
@@ -3166,7 +3171,7 @@ static inline int regulator_suspend_toggle(struct regulator_dev *rdev,
3166 if (!rstate->changeable) 3171 if (!rstate->changeable)
3167 return -EPERM; 3172 return -EPERM;
3168 3173
3169 rstate->enabled = en; 3174 rstate->enabled = (en) ? ENABLE_IN_SUSPEND : DISABLE_IN_SUSPEND;
3170 3175
3171 return 0; 3176 return 0;
3172} 3177}
@@ -4404,13 +4409,13 @@ regulator_register(const struct regulator_desc *regulator_desc,
4404 !rdev->desc->fixed_uV) 4409 !rdev->desc->fixed_uV)
4405 rdev->is_switch = true; 4410 rdev->is_switch = true;
4406 4411
4412 dev_set_drvdata(&rdev->dev, rdev);
4407 ret = device_register(&rdev->dev); 4413 ret = device_register(&rdev->dev);
4408 if (ret != 0) { 4414 if (ret != 0) {
4409 put_device(&rdev->dev); 4415 put_device(&rdev->dev);
4410 goto unset_supplies; 4416 goto unset_supplies;
4411 } 4417 }
4412 4418
4413 dev_set_drvdata(&rdev->dev, rdev);
4414 rdev_init_debugfs(rdev); 4419 rdev_init_debugfs(rdev);
4415 4420
4416 /* try to resolve regulators supply since a new one was registered */ 4421 /* try to resolve regulators supply since a new one was registered */
diff --git a/drivers/regulator/helpers.c b/drivers/regulator/helpers.c
index ef09021dc46e..5686a1335bd3 100644
--- a/drivers/regulator/helpers.c
+++ b/drivers/regulator/helpers.c
@@ -103,6 +103,128 @@ int regulator_disable_regmap(struct regulator_dev *rdev)
103} 103}
104EXPORT_SYMBOL_GPL(regulator_disable_regmap); 104EXPORT_SYMBOL_GPL(regulator_disable_regmap);
105 105
106static int regulator_range_selector_to_index(struct regulator_dev *rdev,
107 unsigned int rval)
108{
109 int i;
110
111 if (!rdev->desc->linear_range_selectors)
112 return -EINVAL;
113
114 rval &= rdev->desc->vsel_range_mask;
115
116 for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
117 if (rdev->desc->linear_range_selectors[i] == rval)
118 return i;
119 }
120 return -EINVAL;
121}
122
123/**
124 * regulator_get_voltage_sel_pickable_regmap - pickable range get_voltage_sel
125 *
126 * @rdev: regulator to operate on
127 *
128 * Regulators that use regmap for their register I/O and use pickable
129 * ranges can set the vsel_reg, vsel_mask, vsel_range_reg and vsel_range_mask
130 * fields in their descriptor and then use this as their get_voltage_vsel
131 * operation, saving some code.
132 */
133int regulator_get_voltage_sel_pickable_regmap(struct regulator_dev *rdev)
134{
135 unsigned int r_val;
136 int range;
137 unsigned int val;
138 int ret, i;
139 unsigned int voltages_in_range = 0;
140
141 if (!rdev->desc->linear_ranges)
142 return -EINVAL;
143
144 ret = regmap_read(rdev->regmap, rdev->desc->vsel_reg, &val);
145 if (ret != 0)
146 return ret;
147
148 ret = regmap_read(rdev->regmap, rdev->desc->vsel_range_reg, &r_val);
149 if (ret != 0)
150 return ret;
151
152 val &= rdev->desc->vsel_mask;
153 val >>= ffs(rdev->desc->vsel_mask) - 1;
154
155 range = regulator_range_selector_to_index(rdev, r_val);
156 if (range < 0)
157 return -EINVAL;
158
159 for (i = 0; i < range; i++)
160 voltages_in_range += (rdev->desc->linear_ranges[i].max_sel -
161 rdev->desc->linear_ranges[i].min_sel) + 1;
162
163 return val + voltages_in_range;
164}
165EXPORT_SYMBOL_GPL(regulator_get_voltage_sel_pickable_regmap);
166
167/**
168 * regulator_set_voltage_sel_pickable_regmap - pickable range set_voltage_sel
169 *
170 * @rdev: regulator to operate on
171 * @sel: Selector to set
172 *
173 * Regulators that use regmap for their register I/O and use pickable
174 * ranges can set the vsel_reg, vsel_mask, vsel_range_reg and vsel_range_mask
175 * fields in their descriptor and then use this as their set_voltage_vsel
176 * operation, saving some code.
177 */
178int regulator_set_voltage_sel_pickable_regmap(struct regulator_dev *rdev,
179 unsigned int sel)
180{
181 unsigned int range;
182 int ret, i;
183 unsigned int voltages_in_range = 0;
184
185 for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
186 voltages_in_range = (rdev->desc->linear_ranges[i].max_sel -
187 rdev->desc->linear_ranges[i].min_sel) + 1;
188 if (sel < voltages_in_range)
189 break;
190 sel -= voltages_in_range;
191 }
192
193 if (i == rdev->desc->n_linear_ranges)
194 return -EINVAL;
195
196 sel <<= ffs(rdev->desc->vsel_mask) - 1;
197 sel += rdev->desc->linear_ranges[i].min_sel;
198
199 range = rdev->desc->linear_range_selectors[i];
200
201 if (rdev->desc->vsel_reg == rdev->desc->vsel_range_reg) {
202 ret = regmap_update_bits(rdev->regmap,
203 rdev->desc->vsel_reg,
204 rdev->desc->vsel_range_mask |
205 rdev->desc->vsel_mask, sel | range);
206 } else {
207 ret = regmap_update_bits(rdev->regmap,
208 rdev->desc->vsel_range_reg,
209 rdev->desc->vsel_range_mask, range);
210 if (ret)
211 return ret;
212
213 ret = regmap_update_bits(rdev->regmap, rdev->desc->vsel_reg,
214 rdev->desc->vsel_mask, sel);
215 }
216
217 if (ret)
218 return ret;
219
220 if (rdev->desc->apply_bit)
221 ret = regmap_update_bits(rdev->regmap, rdev->desc->apply_reg,
222 rdev->desc->apply_bit,
223 rdev->desc->apply_bit);
224 return ret;
225}
226EXPORT_SYMBOL_GPL(regulator_set_voltage_sel_pickable_regmap);
227
106/** 228/**
107 * regulator_get_voltage_sel_regmap - standard get_voltage_sel for regmap users 229 * regulator_get_voltage_sel_regmap - standard get_voltage_sel for regmap users
108 * 230 *
@@ -338,6 +460,76 @@ int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
338EXPORT_SYMBOL_GPL(regulator_map_voltage_linear_range); 460EXPORT_SYMBOL_GPL(regulator_map_voltage_linear_range);
339 461
340/** 462/**
463 * regulator_map_voltage_pickable_linear_range - map_voltage, pickable ranges
464 *
465 * @rdev: Regulator to operate on
466 * @min_uV: Lower bound for voltage
467 * @max_uV: Upper bound for voltage
468 *
469 * Drivers providing pickable linear_ranges in their descriptor can use
470 * this as their map_voltage() callback.
471 */
472int regulator_map_voltage_pickable_linear_range(struct regulator_dev *rdev,
473 int min_uV, int max_uV)
474{
475 const struct regulator_linear_range *range;
476 int ret = -EINVAL;
477 int voltage, i;
478 unsigned int selector = 0;
479
480 if (!rdev->desc->n_linear_ranges) {
481 BUG_ON(!rdev->desc->n_linear_ranges);
482 return -EINVAL;
483 }
484
485 for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
486 int linear_max_uV;
487
488 range = &rdev->desc->linear_ranges[i];
489 linear_max_uV = range->min_uV +
490 (range->max_sel - range->min_sel) * range->uV_step;
491
492 if (!(min_uV <= linear_max_uV && max_uV >= range->min_uV)) {
493 selector += (range->max_sel - range->min_sel + 1);
494 continue;
495 }
496
497 if (min_uV <= range->min_uV)
498 min_uV = range->min_uV;
499
500 /* range->uV_step == 0 means fixed voltage range */
501 if (range->uV_step == 0) {
502 ret = 0;
503 } else {
504 ret = DIV_ROUND_UP(min_uV - range->min_uV,
505 range->uV_step);
506 if (ret < 0)
507 return ret;
508 }
509
510 ret += selector;
511
512 voltage = rdev->desc->ops->list_voltage(rdev, ret);
513
514 /*
515 * Map back into a voltage to verify we're still in bounds.
516 * We may have overlapping voltage ranges. Hence we don't
517 * exit but retry until we have checked all ranges.
518 */
519 if (voltage < min_uV || voltage > max_uV)
520 selector += (range->max_sel - range->min_sel + 1);
521 else
522 break;
523 }
524
525 if (i == rdev->desc->n_linear_ranges)
526 return -EINVAL;
527
528 return ret;
529}
530EXPORT_SYMBOL_GPL(regulator_map_voltage_pickable_linear_range);
531
532/**
341 * regulator_list_voltage_linear - List voltages with simple calculation 533 * regulator_list_voltage_linear - List voltages with simple calculation
342 * 534 *
343 * @rdev: Regulator device 535 * @rdev: Regulator device
@@ -362,6 +554,46 @@ int regulator_list_voltage_linear(struct regulator_dev *rdev,
362EXPORT_SYMBOL_GPL(regulator_list_voltage_linear); 554EXPORT_SYMBOL_GPL(regulator_list_voltage_linear);
363 555
364/** 556/**
557 * regulator_list_voltage_pickable_linear_range - pickable range list voltages
558 *
559 * @rdev: Regulator device
560 * @selector: Selector to convert into a voltage
561 *
562 * list_voltage() operation, intended to be used by drivers utilizing pickable
563 * ranges helpers.
564 */
565int regulator_list_voltage_pickable_linear_range(struct regulator_dev *rdev,
566 unsigned int selector)
567{
568 const struct regulator_linear_range *range;
569 int i;
570 unsigned int all_sels = 0;
571
572 if (!rdev->desc->n_linear_ranges) {
573 BUG_ON(!rdev->desc->n_linear_ranges);
574 return -EINVAL;
575 }
576
577 for (i = 0; i < rdev->desc->n_linear_ranges; i++) {
578 unsigned int sels_in_range;
579
580 range = &rdev->desc->linear_ranges[i];
581
582 sels_in_range = range->max_sel - range->min_sel;
583
584 if (all_sels + sels_in_range >= selector) {
585 selector -= all_sels;
586 return range->min_uV + (range->uV_step * selector);
587 }
588
589 all_sels += (sels_in_range + 1);
590 }
591
592 return -EINVAL;
593}
594EXPORT_SYMBOL_GPL(regulator_list_voltage_pickable_linear_range);
595
596/**
365 * regulator_list_voltage_linear_range - List voltages for linear ranges 597 * regulator_list_voltage_linear_range - List voltages for linear ranges
366 * 598 *
367 * @rdev: Regulator device 599 * @rdev: Regulator device
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 92a516b959a7..c4223b3e0dff 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -213,8 +213,6 @@ static void of_get_regulation_constraints(struct device_node *np,
213 else if (of_property_read_bool(suspend_np, 213 else if (of_property_read_bool(suspend_np,
214 "regulator-off-in-suspend")) 214 "regulator-off-in-suspend"))
215 suspend_state->enabled = DISABLE_IN_SUSPEND; 215 suspend_state->enabled = DISABLE_IN_SUSPEND;
216 else
217 suspend_state->enabled = DO_NOTHING_IN_SUSPEND;
218 216
219 if (!of_property_read_u32(np, "regulator-suspend-min-microvolt", 217 if (!of_property_read_u32(np, "regulator-suspend-min-microvolt",
220 &pval)) 218 &pval))
diff --git a/include/linux/mfd/da9063/pdata.h b/include/linux/mfd/da9063/pdata.h
index 8a125701ef7b..50bed4f89c1a 100644
--- a/include/linux/mfd/da9063/pdata.h
+++ b/include/linux/mfd/da9063/pdata.h
@@ -21,7 +21,7 @@
21/* 21/*
22 * Regulator configuration 22 * Regulator configuration
23 */ 23 */
24/* DA9063 regulator IDs */ 24/* DA9063 and DA9063L regulator IDs */
25enum { 25enum {
26 /* BUCKs */ 26 /* BUCKs */
27 DA9063_ID_BCORE1, 27 DA9063_ID_BCORE1,
@@ -37,18 +37,20 @@ enum {
37 DA9063_ID_BMEM_BIO_MERGED, 37 DA9063_ID_BMEM_BIO_MERGED,
38 /* When two BUCKs are merged, they cannot be reused separately */ 38 /* When two BUCKs are merged, they cannot be reused separately */
39 39
40 /* LDOs */ 40 /* LDOs on both DA9063 and DA9063L */
41 DA9063_ID_LDO3,
42 DA9063_ID_LDO7,
43 DA9063_ID_LDO8,
44 DA9063_ID_LDO9,
45 DA9063_ID_LDO11,
46
47 /* DA9063-only LDOs */
41 DA9063_ID_LDO1, 48 DA9063_ID_LDO1,
42 DA9063_ID_LDO2, 49 DA9063_ID_LDO2,
43 DA9063_ID_LDO3,
44 DA9063_ID_LDO4, 50 DA9063_ID_LDO4,
45 DA9063_ID_LDO5, 51 DA9063_ID_LDO5,
46 DA9063_ID_LDO6, 52 DA9063_ID_LDO6,
47 DA9063_ID_LDO7,
48 DA9063_ID_LDO8,
49 DA9063_ID_LDO9,
50 DA9063_ID_LDO10, 53 DA9063_ID_LDO10,
51 DA9063_ID_LDO11,
52}; 54};
53 55
54/* Regulators platform data */ 56/* Regulators platform data */
diff --git a/include/linux/mfd/rohm-bd718x7.h b/include/linux/mfd/rohm-bd718x7.h
index a528747f8aed..26acf9a92498 100644
--- a/include/linux/mfd/rohm-bd718x7.h
+++ b/include/linux/mfd/rohm-bd718x7.h
@@ -1,112 +1,127 @@
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/* Copyright (C) 2018 ROHM Semiconductors */ 2/* Copyright (C) 2018 ROHM Semiconductors */
3 3
4#ifndef __LINUX_MFD_BD71837_H__ 4#ifndef __LINUX_MFD_BD718XX_H__
5#define __LINUX_MFD_BD71837_H__ 5#define __LINUX_MFD_BD718XX_H__
6 6
7#include <linux/regmap.h> 7#include <linux/regmap.h>
8 8
9enum { 9enum {
10 BD71837_BUCK1 = 0, 10 BD718XX_TYPE_BD71837 = 0,
11 BD71837_BUCK2, 11 BD718XX_TYPE_BD71847,
12 BD71837_BUCK3, 12 BD718XX_TYPE_AMOUNT
13 BD71837_BUCK4,
14 BD71837_BUCK5,
15 BD71837_BUCK6,
16 BD71837_BUCK7,
17 BD71837_BUCK8,
18 BD71837_LDO1,
19 BD71837_LDO2,
20 BD71837_LDO3,
21 BD71837_LDO4,
22 BD71837_LDO5,
23 BD71837_LDO6,
24 BD71837_LDO7,
25 BD71837_REGULATOR_CNT,
26}; 13};
27 14
28#define BD71837_BUCK1_VOLTAGE_NUM 0x40 15enum {
29#define BD71837_BUCK2_VOLTAGE_NUM 0x40 16 BD718XX_BUCK1 = 0,
30#define BD71837_BUCK3_VOLTAGE_NUM 0x40 17 BD718XX_BUCK2,
31#define BD71837_BUCK4_VOLTAGE_NUM 0x40 18 BD718XX_BUCK3,
19 BD718XX_BUCK4,
20 BD718XX_BUCK5,
21 BD718XX_BUCK6,
22 BD718XX_BUCK7,
23 BD718XX_BUCK8,
24 BD718XX_LDO1,
25 BD718XX_LDO2,
26 BD718XX_LDO3,
27 BD718XX_LDO4,
28 BD718XX_LDO5,
29 BD718XX_LDO6,
30 BD718XX_LDO7,
31 BD718XX_REGULATOR_AMOUNT,
32};
33
34/* Common voltage configurations */
35#define BD718XX_DVS_BUCK_VOLTAGE_NUM 0x3D
36#define BD718XX_4TH_NODVS_BUCK_VOLTAGE_NUM 0x3D
37
38#define BD718XX_LDO1_VOLTAGE_NUM 0x08
39#define BD718XX_LDO2_VOLTAGE_NUM 0x02
40#define BD718XX_LDO3_VOLTAGE_NUM 0x10
41#define BD718XX_LDO4_VOLTAGE_NUM 0x0A
42#define BD718XX_LDO6_VOLTAGE_NUM 0x0A
32 43
33#define BD71837_BUCK5_VOLTAGE_NUM 0x08 44/* BD71837 specific voltage configurations */
45#define BD71837_BUCK5_VOLTAGE_NUM 0x10
34#define BD71837_BUCK6_VOLTAGE_NUM 0x04 46#define BD71837_BUCK6_VOLTAGE_NUM 0x04
35#define BD71837_BUCK7_VOLTAGE_NUM 0x08 47#define BD71837_BUCK7_VOLTAGE_NUM 0x08
36#define BD71837_BUCK8_VOLTAGE_NUM 0x40
37
38#define BD71837_LDO1_VOLTAGE_NUM 0x04
39#define BD71837_LDO2_VOLTAGE_NUM 0x02
40#define BD71837_LDO3_VOLTAGE_NUM 0x10
41#define BD71837_LDO4_VOLTAGE_NUM 0x10
42#define BD71837_LDO5_VOLTAGE_NUM 0x10 48#define BD71837_LDO5_VOLTAGE_NUM 0x10
43#define BD71837_LDO6_VOLTAGE_NUM 0x10
44#define BD71837_LDO7_VOLTAGE_NUM 0x10 49#define BD71837_LDO7_VOLTAGE_NUM 0x10
45 50
51/* BD71847 specific voltage configurations */
52#define BD71847_BUCK3_VOLTAGE_NUM 0x18
53#define BD71847_BUCK4_VOLTAGE_NUM 0x08
54#define BD71847_LDO5_VOLTAGE_NUM 0x20
55
56/* Registers specific to BD71837 */
57enum {
58 BD71837_REG_BUCK3_CTRL = 0x07,
59 BD71837_REG_BUCK4_CTRL = 0x08,
60 BD71837_REG_BUCK3_VOLT_RUN = 0x12,
61 BD71837_REG_BUCK4_VOLT_RUN = 0x13,
62 BD71837_REG_LDO7_VOLT = 0x1E,
63};
64
65/* Registers common for BD71837 and BD71847 */
46enum { 66enum {
47 BD71837_REG_REV = 0x00, 67 BD718XX_REG_REV = 0x00,
48 BD71837_REG_SWRESET = 0x01, 68 BD718XX_REG_SWRESET = 0x01,
49 BD71837_REG_I2C_DEV = 0x02, 69 BD718XX_REG_I2C_DEV = 0x02,
50 BD71837_REG_PWRCTRL0 = 0x03, 70 BD718XX_REG_PWRCTRL0 = 0x03,
51 BD71837_REG_PWRCTRL1 = 0x04, 71 BD718XX_REG_PWRCTRL1 = 0x04,
52 BD71837_REG_BUCK1_CTRL = 0x05, 72 BD718XX_REG_BUCK1_CTRL = 0x05,
53 BD71837_REG_BUCK2_CTRL = 0x06, 73 BD718XX_REG_BUCK2_CTRL = 0x06,
54 BD71837_REG_BUCK3_CTRL = 0x07, 74 BD718XX_REG_1ST_NODVS_BUCK_CTRL = 0x09,
55 BD71837_REG_BUCK4_CTRL = 0x08, 75 BD718XX_REG_2ND_NODVS_BUCK_CTRL = 0x0A,
56 BD71837_REG_BUCK5_CTRL = 0x09, 76 BD718XX_REG_3RD_NODVS_BUCK_CTRL = 0x0B,
57 BD71837_REG_BUCK6_CTRL = 0x0A, 77 BD718XX_REG_4TH_NODVS_BUCK_CTRL = 0x0C,
58 BD71837_REG_BUCK7_CTRL = 0x0B, 78 BD718XX_REG_BUCK1_VOLT_RUN = 0x0D,
59 BD71837_REG_BUCK8_CTRL = 0x0C, 79 BD718XX_REG_BUCK1_VOLT_IDLE = 0x0E,
60 BD71837_REG_BUCK1_VOLT_RUN = 0x0D, 80 BD718XX_REG_BUCK1_VOLT_SUSP = 0x0F,
61 BD71837_REG_BUCK1_VOLT_IDLE = 0x0E, 81 BD718XX_REG_BUCK2_VOLT_RUN = 0x10,
62 BD71837_REG_BUCK1_VOLT_SUSP = 0x0F, 82 BD718XX_REG_BUCK2_VOLT_IDLE = 0x11,
63 BD71837_REG_BUCK2_VOLT_RUN = 0x10, 83 BD718XX_REG_1ST_NODVS_BUCK_VOLT = 0x14,
64 BD71837_REG_BUCK2_VOLT_IDLE = 0x11, 84 BD718XX_REG_2ND_NODVS_BUCK_VOLT = 0x15,
65 BD71837_REG_BUCK3_VOLT_RUN = 0x12, 85 BD718XX_REG_3RD_NODVS_BUCK_VOLT = 0x16,
66 BD71837_REG_BUCK4_VOLT_RUN = 0x13, 86 BD718XX_REG_4TH_NODVS_BUCK_VOLT = 0x17,
67 BD71837_REG_BUCK5_VOLT = 0x14, 87 BD718XX_REG_LDO1_VOLT = 0x18,
68 BD71837_REG_BUCK6_VOLT = 0x15, 88 BD718XX_REG_LDO2_VOLT = 0x19,
69 BD71837_REG_BUCK7_VOLT = 0x16, 89 BD718XX_REG_LDO3_VOLT = 0x1A,
70 BD71837_REG_BUCK8_VOLT = 0x17, 90 BD718XX_REG_LDO4_VOLT = 0x1B,
71 BD71837_REG_LDO1_VOLT = 0x18, 91 BD718XX_REG_LDO5_VOLT = 0x1C,
72 BD71837_REG_LDO2_VOLT = 0x19, 92 BD718XX_REG_LDO6_VOLT = 0x1D,
73 BD71837_REG_LDO3_VOLT = 0x1A, 93 BD718XX_REG_TRANS_COND0 = 0x1F,
74 BD71837_REG_LDO4_VOLT = 0x1B, 94 BD718XX_REG_TRANS_COND1 = 0x20,
75 BD71837_REG_LDO5_VOLT = 0x1C, 95 BD718XX_REG_VRFAULTEN = 0x21,
76 BD71837_REG_LDO6_VOLT = 0x1D, 96 BD718XX_REG_MVRFLTMASK0 = 0x22,
77 BD71837_REG_LDO7_VOLT = 0x1E, 97 BD718XX_REG_MVRFLTMASK1 = 0x23,
78 BD71837_REG_TRANS_COND0 = 0x1F, 98 BD718XX_REG_MVRFLTMASK2 = 0x24,
79 BD71837_REG_TRANS_COND1 = 0x20, 99 BD718XX_REG_RCVCFG = 0x25,
80 BD71837_REG_VRFAULTEN = 0x21, 100 BD718XX_REG_RCVNUM = 0x26,
81 BD71837_REG_MVRFLTMASK0 = 0x22, 101 BD718XX_REG_PWRONCONFIG0 = 0x27,
82 BD71837_REG_MVRFLTMASK1 = 0x23, 102 BD718XX_REG_PWRONCONFIG1 = 0x28,
83 BD71837_REG_MVRFLTMASK2 = 0x24, 103 BD718XX_REG_RESETSRC = 0x29,
84 BD71837_REG_RCVCFG = 0x25, 104 BD718XX_REG_MIRQ = 0x2A,
85 BD71837_REG_RCVNUM = 0x26, 105 BD718XX_REG_IRQ = 0x2B,
86 BD71837_REG_PWRONCONFIG0 = 0x27, 106 BD718XX_REG_IN_MON = 0x2C,
87 BD71837_REG_PWRONCONFIG1 = 0x28, 107 BD718XX_REG_POW_STATE = 0x2D,
88 BD71837_REG_RESETSRC = 0x29, 108 BD718XX_REG_OUT32K = 0x2E,
89 BD71837_REG_MIRQ = 0x2A, 109 BD718XX_REG_REGLOCK = 0x2F,
90 BD71837_REG_IRQ = 0x2B, 110 BD718XX_REG_OTPVER = 0xFF,
91 BD71837_REG_IN_MON = 0x2C, 111 BD718XX_MAX_REGISTER = 0x100,
92 BD71837_REG_POW_STATE = 0x2D,
93 BD71837_REG_OUT32K = 0x2E,
94 BD71837_REG_REGLOCK = 0x2F,
95 BD71837_REG_OTPVER = 0xFF,
96 BD71837_MAX_REGISTER = 0x100,
97}; 112};
98 113
99#define REGLOCK_PWRSEQ 0x1 114#define REGLOCK_PWRSEQ 0x1
100#define REGLOCK_VREG 0x10 115#define REGLOCK_VREG 0x10
101 116
102/* Generic BUCK control masks */ 117/* Generic BUCK control masks */
103#define BD71837_BUCK_SEL 0x02 118#define BD718XX_BUCK_SEL 0x02
104#define BD71837_BUCK_EN 0x01 119#define BD718XX_BUCK_EN 0x01
105#define BD71837_BUCK_RUN_ON 0x04 120#define BD718XX_BUCK_RUN_ON 0x04
106 121
107/* Generic LDO masks */ 122/* Generic LDO masks */
108#define BD71837_LDO_SEL 0x80 123#define BD718XX_LDO_SEL 0x80
109#define BD71837_LDO_EN 0x40 124#define BD718XX_LDO_EN 0x40
110 125
111/* BD71837 BUCK ramp rate CTRL reg bits */ 126/* BD71837 BUCK ramp rate CTRL reg bits */
112#define BUCK_RAMPRATE_MASK 0xC0 127#define BUCK_RAMPRATE_MASK 0xC0
@@ -115,51 +130,64 @@ enum {
115#define BUCK_RAMPRATE_2P50MV 0x2 130#define BUCK_RAMPRATE_2P50MV 0x2
116#define BUCK_RAMPRATE_1P25MV 0x3 131#define BUCK_RAMPRATE_1P25MV 0x3
117 132
118/* BD71837_REG_BUCK1_VOLT_RUN bits */ 133#define DVS_BUCK_RUN_MASK 0x3F
119#define BUCK1_RUN_MASK 0x3F 134#define DVS_BUCK_SUSP_MASK 0x3F
120#define BUCK1_RUN_DEFAULT 0x14 135#define DVS_BUCK_IDLE_MASK 0x3F
121 136
122/* BD71837_REG_BUCK1_VOLT_SUSP bits */ 137#define BD718XX_1ST_NODVS_BUCK_MASK 0x07
123#define BUCK1_SUSP_MASK 0x3F 138#define BD718XX_3RD_NODVS_BUCK_MASK 0x07
124#define BUCK1_SUSP_DEFAULT 0x14 139#define BD718XX_4TH_NODVS_BUCK_MASK 0x3F
125 140
126/* BD71837_REG_BUCK1_VOLT_IDLE bits */ 141#define BD71847_BUCK3_MASK 0x07
127#define BUCK1_IDLE_MASK 0x3F 142#define BD71847_BUCK3_RANGE_MASK 0xC0
128#define BUCK1_IDLE_DEFAULT 0x14 143#define BD71847_BUCK4_MASK 0x03
129 144#define BD71847_BUCK4_RANGE_MASK 0x40
130/* BD71837_REG_BUCK2_VOLT_RUN bits */ 145
131#define BUCK2_RUN_MASK 0x3F 146#define BD71837_BUCK5_MASK 0x07
132#define BUCK2_RUN_DEFAULT 0x1E 147#define BD71837_BUCK5_RANGE_MASK 0x80
133 148#define BD71837_BUCK6_MASK 0x03
134/* BD71837_REG_BUCK2_VOLT_IDLE bits */ 149
135#define BUCK2_IDLE_MASK 0x3F 150#define BD718XX_LDO1_MASK 0x03
136#define BUCK2_IDLE_DEFAULT 0x14 151#define BD718XX_LDO1_RANGE_MASK 0x20
137 152#define BD718XX_LDO2_MASK 0x20
138/* BD71837_REG_BUCK3_VOLT_RUN bits */ 153#define BD718XX_LDO3_MASK 0x0F
139#define BUCK3_RUN_MASK 0x3F 154#define BD718XX_LDO4_MASK 0x0F
140#define BUCK3_RUN_DEFAULT 0x1E 155#define BD718XX_LDO6_MASK 0x0F
141 156
142/* BD71837_REG_BUCK4_VOLT_RUN bits */ 157#define BD71837_LDO5_MASK 0x0F
143#define BUCK4_RUN_MASK 0x3F 158#define BD71847_LDO5_MASK 0x0F
144#define BUCK4_RUN_DEFAULT 0x1E 159#define BD71847_LDO5_RANGE_MASK 0x20
145 160
146/* BD71837_REG_BUCK5_VOLT bits */ 161#define BD71837_LDO7_MASK 0x0F
147#define BUCK5_MASK 0x07 162
148#define BUCK5_DEFAULT 0x02 163/* BD718XX Voltage monitoring masks */
149 164#define BD718XX_BUCK1_VRMON80 0x1
150/* BD71837_REG_BUCK6_VOLT bits */ 165#define BD718XX_BUCK1_VRMON130 0x2
151#define BUCK6_MASK 0x03 166#define BD718XX_BUCK2_VRMON80 0x4
152#define BUCK6_DEFAULT 0x03 167#define BD718XX_BUCK2_VRMON130 0x8
153 168#define BD718XX_1ST_NODVS_BUCK_VRMON80 0x1
154/* BD71837_REG_BUCK7_VOLT bits */ 169#define BD718XX_1ST_NODVS_BUCK_VRMON130 0x2
155#define BUCK7_MASK 0x07 170#define BD718XX_2ND_NODVS_BUCK_VRMON80 0x4
156#define BUCK7_DEFAULT 0x03 171#define BD718XX_2ND_NODVS_BUCK_VRMON130 0x8
157 172#define BD718XX_3RD_NODVS_BUCK_VRMON80 0x10
158/* BD71837_REG_BUCK8_VOLT bits */ 173#define BD718XX_3RD_NODVS_BUCK_VRMON130 0x20
159#define BUCK8_MASK 0x3F 174#define BD718XX_4TH_NODVS_BUCK_VRMON80 0x40
160#define BUCK8_DEFAULT 0x1E 175#define BD718XX_4TH_NODVS_BUCK_VRMON130 0x80
161 176#define BD718XX_LDO1_VRMON80 0x1
162/* BD71837_REG_IRQ bits */ 177#define BD718XX_LDO2_VRMON80 0x2
178#define BD718XX_LDO3_VRMON80 0x4
179#define BD718XX_LDO4_VRMON80 0x8
180#define BD718XX_LDO5_VRMON80 0x10
181#define BD718XX_LDO6_VRMON80 0x20
182
183/* BD71837 specific voltage monitoring masks */
184#define BD71837_BUCK3_VRMON80 0x10
185#define BD71837_BUCK3_VRMON130 0x20
186#define BD71837_BUCK4_VRMON80 0x40
187#define BD71837_BUCK4_VRMON130 0x80
188#define BD71837_LDO7_VRMON80 0x40
189
190/* BD718XX_REG_IRQ bits */
163#define IRQ_SWRST 0x40 191#define IRQ_SWRST 0x40
164#define IRQ_PWRON_S 0x20 192#define IRQ_PWRON_S 0x20
165#define IRQ_PWRON_L 0x10 193#define IRQ_PWRON_L 0x10
@@ -168,52 +196,31 @@ enum {
168#define IRQ_ON_REQ 0x02 196#define IRQ_ON_REQ 0x02
169#define IRQ_STBY_REQ 0x01 197#define IRQ_STBY_REQ 0x01
170 198
171/* BD71837_REG_OUT32K bits */ 199/* BD718XX_REG_OUT32K bits */
172#define BD71837_OUT32K_EN 0x01 200#define BD718XX_OUT32K_EN 0x01
173 201
174/* BD71837 gated clock rate */ 202/* BD7183XX gated clock rate */
175#define BD71837_CLK_RATE 32768 203#define BD718XX_CLK_RATE 32768
176 204
177/* ROHM BD71837 irqs */ 205/* ROHM BD718XX irqs */
178enum { 206enum {
179 BD71837_INT_STBY_REQ, 207 BD718XX_INT_STBY_REQ,
180 BD71837_INT_ON_REQ, 208 BD718XX_INT_ON_REQ,
181 BD71837_INT_WDOG, 209 BD718XX_INT_WDOG,
182 BD71837_INT_PWRBTN, 210 BD718XX_INT_PWRBTN,
183 BD71837_INT_PWRBTN_L, 211 BD718XX_INT_PWRBTN_L,
184 BD71837_INT_PWRBTN_S, 212 BD718XX_INT_PWRBTN_S,
185 BD71837_INT_SWRST 213 BD718XX_INT_SWRST
186}; 214};
187 215
188/* ROHM BD71837 interrupt masks */ 216/* ROHM BD718XX interrupt masks */
189#define BD71837_INT_SWRST_MASK 0x40 217#define BD718XX_INT_SWRST_MASK 0x40
190#define BD71837_INT_PWRBTN_S_MASK 0x20 218#define BD718XX_INT_PWRBTN_S_MASK 0x20
191#define BD71837_INT_PWRBTN_L_MASK 0x10 219#define BD718XX_INT_PWRBTN_L_MASK 0x10
192#define BD71837_INT_PWRBTN_MASK 0x8 220#define BD718XX_INT_PWRBTN_MASK 0x8
193#define BD71837_INT_WDOG_MASK 0x4 221#define BD718XX_INT_WDOG_MASK 0x4
194#define BD71837_INT_ON_REQ_MASK 0x2 222#define BD718XX_INT_ON_REQ_MASK 0x2
195#define BD71837_INT_STBY_REQ_MASK 0x1 223#define BD718XX_INT_STBY_REQ_MASK 0x1
196
197/* BD71837_REG_LDO1_VOLT bits */
198#define LDO1_MASK 0x03
199
200/* BD71837_REG_LDO1_VOLT bits */
201#define LDO2_MASK 0x20
202
203/* BD71837_REG_LDO3_VOLT bits */
204#define LDO3_MASK 0x0F
205
206/* BD71837_REG_LDO4_VOLT bits */
207#define LDO4_MASK 0x0F
208
209/* BD71837_REG_LDO5_VOLT bits */
210#define LDO5_MASK 0x0F
211
212/* BD71837_REG_LDO6_VOLT bits */
213#define LDO6_MASK 0x0F
214
215/* BD71837_REG_LDO7_VOLT bits */
216#define LDO7_MASK 0x0F
217 224
218/* Register write induced reset settings */ 225/* Register write induced reset settings */
219 226
@@ -223,13 +230,13 @@ enum {
223 * write 1 to it we will trigger the action. So always write 0 to it when 230 * write 1 to it we will trigger the action. So always write 0 to it when
224 * changning SWRESET action - no matter what we read from it. 231 * changning SWRESET action - no matter what we read from it.
225 */ 232 */
226#define BD71837_SWRESET_TYPE_MASK 7 233#define BD718XX_SWRESET_TYPE_MASK 7
227#define BD71837_SWRESET_TYPE_DISABLED 0 234#define BD718XX_SWRESET_TYPE_DISABLED 0
228#define BD71837_SWRESET_TYPE_COLD 4 235#define BD718XX_SWRESET_TYPE_COLD 4
229#define BD71837_SWRESET_TYPE_WARM 6 236#define BD718XX_SWRESET_TYPE_WARM 6
230 237
231#define BD71837_SWRESET_RESET_MASK 1 238#define BD718XX_SWRESET_RESET_MASK 1
232#define BD71837_SWRESET_RESET 1 239#define BD718XX_SWRESET_RESET 1
233 240
234/* Poweroff state transition conditions */ 241/* Poweroff state transition conditions */
235 242
@@ -314,10 +321,11 @@ enum {
314 BD718XX_PWRBTN_LONG_PRESS_15S 321 BD718XX_PWRBTN_LONG_PRESS_15S
315}; 322};
316 323
317struct bd71837_pmic; 324struct bd718xx_pmic;
318struct bd71837_clk; 325struct bd718xx_clk;
319 326
320struct bd71837 { 327struct bd718xx {
328 unsigned int chip_type;
321 struct device *dev; 329 struct device *dev;
322 struct regmap *regmap; 330 struct regmap *regmap;
323 unsigned long int id; 331 unsigned long int id;
@@ -325,8 +333,8 @@ struct bd71837 {
325 int chip_irq; 333 int chip_irq;
326 struct regmap_irq_chip_data *irq_data; 334 struct regmap_irq_chip_data *irq_data;
327 335
328 struct bd71837_pmic *pmic; 336 struct bd718xx_pmic *pmic;
329 struct bd71837_clk *clk; 337 struct bd718xx_clk *clk;
330}; 338};
331 339
332#endif /* __LINUX_MFD_BD71837_H__ */ 340#endif /* __LINUX_MFD_BD718XX_H__ */
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 0fd8fbb74763..a9c030192147 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -271,9 +271,16 @@ enum regulator_type {
271 * @ramp_delay: Time to settle down after voltage change (unit: uV/us) 271 * @ramp_delay: Time to settle down after voltage change (unit: uV/us)
272 * @min_dropout_uV: The minimum dropout voltage this regulator can handle 272 * @min_dropout_uV: The minimum dropout voltage this regulator can handle
273 * @linear_ranges: A constant table of possible voltage ranges. 273 * @linear_ranges: A constant table of possible voltage ranges.
274 * @n_linear_ranges: Number of entries in the @linear_ranges table. 274 * @linear_range_selectors: A constant table of voltage range selectors.
275 * If pickable ranges are used each range must
276 * have corresponding selector here.
277 * @n_linear_ranges: Number of entries in the @linear_ranges (and in
278 * linear_range_selectors if used) table(s).
275 * @volt_table: Voltage mapping table (if table based mapping) 279 * @volt_table: Voltage mapping table (if table based mapping)
276 * 280 *
281 * @vsel_range_reg: Register for range selector when using pickable ranges
282 * and regulator_regmap_X_voltage_X_pickable functions.
283 * @vsel_range_mask: Mask for register bitfield used for range selector
277 * @vsel_reg: Register for selector when using regulator_regmap_X_voltage_ 284 * @vsel_reg: Register for selector when using regulator_regmap_X_voltage_
278 * @vsel_mask: Mask for register bitfield used for selector 285 * @vsel_mask: Mask for register bitfield used for selector
279 * @csel_reg: Register for TPS65218 LS3 current regulator 286 * @csel_reg: Register for TPS65218 LS3 current regulator
@@ -338,10 +345,14 @@ struct regulator_desc {
338 int min_dropout_uV; 345 int min_dropout_uV;
339 346
340 const struct regulator_linear_range *linear_ranges; 347 const struct regulator_linear_range *linear_ranges;
348 const unsigned int *linear_range_selectors;
349
341 int n_linear_ranges; 350 int n_linear_ranges;
342 351
343 const unsigned int *volt_table; 352 const unsigned int *volt_table;
344 353
354 unsigned int vsel_range_reg;
355 unsigned int vsel_range_mask;
345 unsigned int vsel_reg; 356 unsigned int vsel_reg;
346 unsigned int vsel_mask; 357 unsigned int vsel_mask;
347 unsigned int csel_reg; 358 unsigned int csel_reg;
@@ -498,18 +509,25 @@ int regulator_mode_to_status(unsigned int);
498 509
499int regulator_list_voltage_linear(struct regulator_dev *rdev, 510int regulator_list_voltage_linear(struct regulator_dev *rdev,
500 unsigned int selector); 511 unsigned int selector);
512int regulator_list_voltage_pickable_linear_range(struct regulator_dev *rdev,
513 unsigned int selector);
501int regulator_list_voltage_linear_range(struct regulator_dev *rdev, 514int regulator_list_voltage_linear_range(struct regulator_dev *rdev,
502 unsigned int selector); 515 unsigned int selector);
503int regulator_list_voltage_table(struct regulator_dev *rdev, 516int regulator_list_voltage_table(struct regulator_dev *rdev,
504 unsigned int selector); 517 unsigned int selector);
505int regulator_map_voltage_linear(struct regulator_dev *rdev, 518int regulator_map_voltage_linear(struct regulator_dev *rdev,
506 int min_uV, int max_uV); 519 int min_uV, int max_uV);
520int regulator_map_voltage_pickable_linear_range(struct regulator_dev *rdev,
521 int min_uV, int max_uV);
507int regulator_map_voltage_linear_range(struct regulator_dev *rdev, 522int regulator_map_voltage_linear_range(struct regulator_dev *rdev,
508 int min_uV, int max_uV); 523 int min_uV, int max_uV);
509int regulator_map_voltage_iterate(struct regulator_dev *rdev, 524int regulator_map_voltage_iterate(struct regulator_dev *rdev,
510 int min_uV, int max_uV); 525 int min_uV, int max_uV);
511int regulator_map_voltage_ascend(struct regulator_dev *rdev, 526int regulator_map_voltage_ascend(struct regulator_dev *rdev,
512 int min_uV, int max_uV); 527 int min_uV, int max_uV);
528int regulator_get_voltage_sel_pickable_regmap(struct regulator_dev *rdev);
529int regulator_set_voltage_sel_pickable_regmap(struct regulator_dev *rdev,
530 unsigned int sel);
513int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev); 531int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev);
514int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel); 532int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel);
515int regulator_is_enabled_regmap(struct regulator_dev *rdev); 533int regulator_is_enabled_regmap(struct regulator_dev *rdev);
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index 3468703d663a..a459a5e973a7 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -48,9 +48,9 @@ struct regulator;
48 * DISABLE_IN_SUSPEND - turn off regulator in suspend states 48 * DISABLE_IN_SUSPEND - turn off regulator in suspend states
49 * ENABLE_IN_SUSPEND - keep regulator on in suspend states 49 * ENABLE_IN_SUSPEND - keep regulator on in suspend states
50 */ 50 */
51#define DO_NOTHING_IN_SUSPEND (-1) 51#define DO_NOTHING_IN_SUSPEND 0
52#define DISABLE_IN_SUSPEND 0 52#define DISABLE_IN_SUSPEND 1
53#define ENABLE_IN_SUSPEND 1 53#define ENABLE_IN_SUSPEND 2
54 54
55/* Regulator active discharge flags */ 55/* Regulator active discharge flags */
56enum regulator_active_discharge { 56enum regulator_active_discharge {