aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 14:52:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 14:52:16 -0400
commitb51c4354dffd32b3472c5a3da7ce864c7be82601 (patch)
tree84efef7ea859085da102b2446c91ea8dd9a9b82b
parentffd776bf564f1308fb94634b032df296ce3134a3 (diff)
parent36fd679f45a25a7c634b3dbec35a2d7fdb832a65 (diff)
Merge tag 'regulator-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates from Mark Brown: "A very small set of updates for the regulator API this time around, there's a few bug fixes and also: - Conversion of the regulator API to use GPIO descriptors rather than numbers from Linus Walleij. - New drivers for Marvell 88PG86x and Qualcomm PM8998 and PMI8998" * tag 'regulator-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: regulator: qcom: smd: Add pm8998 and pmi8998 regulators regulator: core: Add missing blank line between functions regulator: qcom_smd: Drop regulator/{machine,of_regulator} includes regulator: giving regulator controlling gpios a non-empty label when used through the devicetree. regulator: gpio: Fix some error handling paths in 'gpio_regulator_probe()' regulator: 88pg86x: new i2c dual regulator chip regulator: 88pg86x: add DT bindings document regulator: da9211: Pass descriptors instead of GPIO numbers regulator: da9055: Pass descriptor instead of GPIO number regulator: core: Support passing an initialized GPIO enable descriptor regulator: dt: regulator-name is required property regulator: of: Add a missing 'of_node_put()' in an error handling path of 'of_regulator_match()'
-rw-r--r--Documentation/devicetree/bindings/regulator/88pg86x.txt22
-rw-r--r--Documentation/devicetree/bindings/regulator/fixed-regulator.txt1
-rw-r--r--Documentation/devicetree/bindings/regulator/gpio-regulator.txt2
-rw-r--r--Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.txt48
-rw-r--r--drivers/regulator/88pg86x.c114
-rw-r--r--drivers/regulator/Kconfig9
-rw-r--r--drivers/regulator/Makefile1
-rw-r--r--drivers/regulator/core.c26
-rw-r--r--drivers/regulator/da9055-regulator.c4
-rw-r--r--drivers/regulator/da9211-regulator.c23
-rw-r--r--drivers/regulator/gpio-regulator.c17
-rw-r--r--drivers/regulator/of_regulator.c1
-rw-r--r--drivers/regulator/qcom_smd-regulator.c123
-rw-r--r--include/linux/mfd/da9055/pdata.h5
-rw-r--r--include/linux/regulator/da9211.h4
-rw-r--r--include/linux/regulator/driver.h3
-rw-r--r--include/linux/soc/qcom/smd-rpm.h1
17 files changed, 367 insertions, 37 deletions
diff --git a/Documentation/devicetree/bindings/regulator/88pg86x.txt b/Documentation/devicetree/bindings/regulator/88pg86x.txt
new file mode 100644
index 000000000000..13b7f49a2ea8
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/88pg86x.txt
@@ -0,0 +1,22 @@
1Marvell 88PG867/88PG868 voltage regulators
2
3Required properties:
4- compatible: one of "marvell,88pg867", "marvell,88pg868";
5- reg: I2C slave address.
6
7Optional subnodes for regulators: "buck1", "buck2", using common regulator
8bindings given in <Documentation/devicetree/bindings/regulator/regulator.txt>.
9
10Example:
11
12 pg868@19 {
13 compatible = "marvell,88pg868";
14 reg = <0x19>;
15
16 vcpu: buck1 {
17 regulator-boot-on;
18 regulator-always-on;
19 regulator-min-microvolt = <1000000>;
20 regulator-max-microvolt = <1350000>;
21 };
22 };
diff --git a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
index 4fae41d54798..0c2a6c8a1536 100644
--- a/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/fixed-regulator.txt
@@ -2,6 +2,7 @@ Fixed Voltage regulators
2 2
3Required properties: 3Required properties:
4- compatible: Must be "regulator-fixed"; 4- compatible: Must be "regulator-fixed";
5- regulator-name: Defined in regulator.txt as optional, but required here.
5 6
6Optional properties: 7Optional properties:
7- gpio: gpio to use for enable control 8- gpio: gpio to use for enable control
diff --git a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
index dd1ed789728e..1f496159e2bb 100644
--- a/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/gpio-regulator.txt
@@ -2,6 +2,8 @@ GPIO controlled regulators
2 2
3Required properties: 3Required properties:
4- compatible : Must be "regulator-gpio". 4- compatible : Must be "regulator-gpio".
5- regulator-name : Defined in regulator.txt as optional, but required
6 here.
5- states : Selection of available voltages and GPIO configs. 7- states : Selection of available voltages and GPIO configs.
6 if there are no states, then use a fixed regulator 8 if there are no states, then use a fixed regulator
7 9
diff --git a/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.txt b/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.txt
index 4e3dfb5b5f16..58a1d97972f5 100644
--- a/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/qcom,smd-rpm-regulator.txt
@@ -23,7 +23,9 @@ Regulator nodes are identified by their compatible:
23 "qcom,rpm-pm8916-regulators" 23 "qcom,rpm-pm8916-regulators"
24 "qcom,rpm-pm8941-regulators" 24 "qcom,rpm-pm8941-regulators"
25 "qcom,rpm-pm8994-regulators" 25 "qcom,rpm-pm8994-regulators"
26 "qcom,rpm-pm8998-regulators"
26 "qcom,rpm-pma8084-regulators" 27 "qcom,rpm-pma8084-regulators"
28 "qcom,rpm-pmi8998-regulators"
27 29
28- vdd_s1-supply: 30- vdd_s1-supply:
29- vdd_s2-supply: 31- vdd_s2-supply:
@@ -131,6 +133,38 @@ Regulator nodes are identified by their compatible:
131- vdd_s10-supply: 133- vdd_s10-supply:
132- vdd_s11-supply: 134- vdd_s11-supply:
133- vdd_s12-supply: 135- vdd_s12-supply:
136- vdd_s13-supply:
137- vdd_l1_l27-supply:
138- vdd_l20_l24-supply:
139- vdd_l26-supply:
140- vdd_l2_l8_l17-supply:
141- vdd_l3_l11-supply:
142- vdd_l4_l5-supply:
143- vdd_l6-supply:
144- vdd_l7_l12_l14_l15-supply:
145- vdd_l9-supply:
146- vdd_l10_l23_l25-supply:
147- vdd_l13_l19_l21-supply:
148- vdd_l16_l28-supply:
149- vdd_l18_l22-supply:
150- vdd_lvs1_lvs2-supply:
151 Usage: optional (pmi8998 only)
152 Value type: <phandle>
153 Definition: reference to regulator supplying the input pin, as
154 described in the data sheet
155
156- vdd_s1-supply:
157- vdd_s2-supply:
158- vdd_s3-supply:
159- vdd_s4-supply:
160- vdd_s5-supply:
161- vdd_s6-supply:
162- vdd_s7-supply:
163- vdd_s8-supply:
164- vdd_s9-supply:
165- vdd_s10-supply:
166- vdd_s11-supply:
167- vdd_s12-supply:
134- vdd_l1_l11-supply: 168- vdd_l1_l11-supply:
135- vdd_l2_l3_l4_l27-supply: 169- vdd_l2_l3_l4_l27-supply:
136- vdd_l5_l7-supply: 170- vdd_l5_l7-supply:
@@ -148,6 +182,12 @@ Regulator nodes are identified by their compatible:
148 Definition: reference to regulator supplying the input pin, as 182 Definition: reference to regulator supplying the input pin, as
149 described in the data sheet 183 described in the data sheet
150 184
185- vdd_bob-supply:
186 Usage: optional (pmi8998 only)
187 Value type: <phandle>
188 Definition: reference to regulator supplying the input pin, as
189 described in the data sheet
190
151The regulator node houses sub-nodes for each regulator within the device. Each 191The regulator node houses sub-nodes for each regulator within the device. Each
152sub-node is identified using the node's name, with valid values listed for each 192sub-node is identified using the node's name, with valid values listed for each
153of the pmics below. 193of the pmics below.
@@ -169,11 +209,19 @@ pm8994:
169 l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20, 209 l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20,
170 l21, l22, l23, l24, l25, l26, l27, l28, l29, l30, l31, l32, lvs1, lvs2 210 l21, l22, l23, l24, l25, l26, l27, l28, l29, l30, l31, l32, lvs1, lvs2
171 211
212pm8998:
213 s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, l1, l2, l3, l4,
214 l5, l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19,
215 l20, l21, l22, l23, l24, l25, l26, l27, l28, lvs1, lvs2
216
172pma8084: 217pma8084:
173 s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, l1, l2, l3, l4, l5, 218 s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, l1, l2, l3, l4, l5,
174 l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20, 219 l6, l7, l8, l9, l10, l11, l12, l13, l14, l15, l16, l17, l18, l19, l20,
175 l21, l22, l23, l24, l25, l26, l27, lvs1, lvs2, lvs3, lvs4, 5vs1 220 l21, l22, l23, l24, l25, l26, l27, lvs1, lvs2, lvs3, lvs4, 5vs1
176 221
222pmi8998:
223 bob
224
177The content of each sub-node is defined by the standard binding for regulators - 225The content of each sub-node is defined by the standard binding for regulators -
178see regulator.txt. 226see regulator.txt.
179 227
diff --git a/drivers/regulator/88pg86x.c b/drivers/regulator/88pg86x.c
new file mode 100644
index 000000000000..d5ef55c81185
--- /dev/null
+++ b/drivers/regulator/88pg86x.c
@@ -0,0 +1,114 @@
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/module.h>
3#include <linux/i2c.h>
4#include <linux/of.h>
5#include <linux/regulator/driver.h>
6#include <linux/regmap.h>
7
8static const struct regulator_ops pg86x_ops = {
9 .set_voltage_sel = regulator_set_voltage_sel_regmap,
10 .get_voltage_sel = regulator_get_voltage_sel_regmap,
11 .list_voltage = regulator_list_voltage_linear_range,
12};
13
14static const struct regulator_linear_range pg86x_buck1_ranges[] = {
15 REGULATOR_LINEAR_RANGE( 0, 0, 10, 0),
16 REGULATOR_LINEAR_RANGE(1000000, 11, 34, 25000),
17 REGULATOR_LINEAR_RANGE(1600000, 35, 47, 50000),
18};
19
20static const struct regulator_linear_range pg86x_buck2_ranges[] = {
21 REGULATOR_LINEAR_RANGE( 0, 0, 15, 0),
22 REGULATOR_LINEAR_RANGE(1000000, 16, 39, 25000),
23 REGULATOR_LINEAR_RANGE(1600000, 40, 52, 50000),
24};
25
26static const struct regulator_desc pg86x_regulators[] = {
27 {
28 .id = 0,
29 .type = REGULATOR_VOLTAGE,
30 .name = "buck1",
31 .of_match = of_match_ptr("buck1"),
32 .n_voltages = 11 + 24 + 13,
33 .linear_ranges = pg86x_buck1_ranges,
34 .n_linear_ranges = 3,
35 .vsel_reg = 0x24,
36 .vsel_mask = 0xff,
37 .ops = &pg86x_ops,
38 .owner = THIS_MODULE
39 },
40 {
41 .id = 1,
42 .type = REGULATOR_VOLTAGE,
43 .name = "buck2",
44 .of_match = of_match_ptr("buck2"),
45 .n_voltages = 16 + 24 + 13,
46 .linear_ranges = pg86x_buck2_ranges,
47 .n_linear_ranges = 3,
48 .vsel_reg = 0x13,
49 .vsel_mask = 0xff,
50 .ops = &pg86x_ops,
51 .owner = THIS_MODULE
52 },
53};
54
55static const struct regmap_config pg86x_regmap = {
56 .reg_bits = 8,
57 .val_bits = 8,
58};
59
60static int pg86x_i2c_probe(struct i2c_client *i2c)
61{
62 int id, ret;
63 struct regulator_config config = {.dev = &i2c->dev};
64 struct regmap *regmap = devm_regmap_init_i2c(i2c, &pg86x_regmap);
65
66 if (IS_ERR(regmap)) {
67 ret = PTR_ERR(regmap);
68 dev_err(&i2c->dev, "regmap init failed: %d\n", ret);
69 return ret;
70 }
71
72 for (id = 0; id < ARRAY_SIZE(pg86x_regulators); id++) {
73 struct regulator_dev *rdev;
74 rdev = devm_regulator_register(&i2c->dev,
75 &pg86x_regulators[id],
76 &config);
77 if (IS_ERR(rdev)) {
78 ret = PTR_ERR(rdev);
79 dev_err(&i2c->dev, "failed to register %s: %d\n",
80 pg86x_regulators[id].name, ret);
81 return ret;
82 }
83 }
84 return 0;
85}
86
87static const struct of_device_id pg86x_dt_ids [] = {
88 { .compatible = "marvell,88pg867" },
89 { .compatible = "marvell,88pg868" },
90 { }
91};
92MODULE_DEVICE_TABLE(of, pg86x_dt_ids);
93
94static const struct i2c_device_id pg86x_i2c_id[] = {
95 { "88pg867", },
96 { "88pg868", },
97 { }
98};
99MODULE_DEVICE_TABLE(i2c, pg86x_i2c_id);
100
101static struct i2c_driver pg86x_regulator_driver = {
102 .driver = {
103 .name = "88pg86x",
104 .of_match_table = of_match_ptr(pg86x_dt_ids),
105 },
106 .probe_new = pg86x_i2c_probe,
107 .id_table = pg86x_i2c_id,
108};
109
110module_i2c_driver(pg86x_regulator_driver);
111
112MODULE_DESCRIPTION("Marvell 88PG86X voltage regulator");
113MODULE_AUTHOR("Alexander Monakov <amonakov@gmail.com>");
114MODULE_LICENSE("GPL");
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index b27417ca188a..097f61784a7d 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -54,6 +54,15 @@ config REGULATOR_USERSPACE_CONSUMER
54 54
55 If unsure, say no. 55 If unsure, say no.
56 56
57config REGULATOR_88PG86X
58 tristate "Marvell 88PG86X voltage regulators"
59 depends on I2C
60 select REGMAP_I2C
61 help
62 This driver supports Marvell 88PG867 and 88PG868 voltage regulators.
63 They provide two I2C-controlled DC/DC step-down converters with
64 sleep mode and separate enable pins.
65
57config REGULATOR_88PM800 66config REGULATOR_88PM800
58 tristate "Marvell 88PM800 Power regulators" 67 tristate "Marvell 88PM800 Power regulators"
59 depends on MFD_88PM800 68 depends on MFD_88PM800
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 19fea09ba10a..590674fbecd7 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
10obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o 10obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
11obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o 11obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o
12 12
13obj-$(CONFIG_REGULATOR_88PG86X) += 88pg86x.o
13obj-$(CONFIG_REGULATOR_88PM800) += 88pm800.o 14obj-$(CONFIG_REGULATOR_88PM800) += 88pm800.o
14obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o 15obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o
15obj-$(CONFIG_REGULATOR_CPCAP) += cpcap-regulator.o 16obj-$(CONFIG_REGULATOR_CPCAP) += cpcap-regulator.o
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 1fc0c0811da4..d4803460a557 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1937,7 +1937,10 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev,
1937 struct gpio_desc *gpiod; 1937 struct gpio_desc *gpiod;
1938 int ret; 1938 int ret;
1939 1939
1940 gpiod = gpio_to_desc(config->ena_gpio); 1940 if (config->ena_gpiod)
1941 gpiod = config->ena_gpiod;
1942 else
1943 gpiod = gpio_to_desc(config->ena_gpio);
1941 1944
1942 list_for_each_entry(pin, &regulator_ena_gpio_list, list) { 1945 list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
1943 if (pin->gpiod == gpiod) { 1946 if (pin->gpiod == gpiod) {
@@ -1947,15 +1950,18 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev,
1947 } 1950 }
1948 } 1951 }
1949 1952
1950 ret = gpio_request_one(config->ena_gpio, 1953 if (!config->ena_gpiod) {
1951 GPIOF_DIR_OUT | config->ena_gpio_flags, 1954 ret = gpio_request_one(config->ena_gpio,
1952 rdev_get_name(rdev)); 1955 GPIOF_DIR_OUT | config->ena_gpio_flags,
1953 if (ret) 1956 rdev_get_name(rdev));
1954 return ret; 1957 if (ret)
1958 return ret;
1959 }
1955 1960
1956 pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL); 1961 pin = kzalloc(sizeof(struct regulator_enable_gpio), GFP_KERNEL);
1957 if (pin == NULL) { 1962 if (pin == NULL) {
1958 gpio_free(config->ena_gpio); 1963 if (!config->ena_gpiod)
1964 gpio_free(config->ena_gpio);
1959 return -ENOMEM; 1965 return -ENOMEM;
1960 } 1966 }
1961 1967
@@ -4154,8 +4160,9 @@ regulator_register(const struct regulator_desc *regulator_desc,
4154 goto clean; 4160 goto clean;
4155 } 4161 }
4156 4162
4157 if ((config->ena_gpio || config->ena_gpio_initialized) && 4163 if (config->ena_gpiod ||
4158 gpio_is_valid(config->ena_gpio)) { 4164 ((config->ena_gpio || config->ena_gpio_initialized) &&
4165 gpio_is_valid(config->ena_gpio))) {
4159 mutex_lock(&regulator_list_mutex); 4166 mutex_lock(&regulator_list_mutex);
4160 ret = regulator_ena_gpio_request(rdev, config); 4167 ret = regulator_ena_gpio_request(rdev, config);
4161 mutex_unlock(&regulator_list_mutex); 4168 mutex_unlock(&regulator_list_mutex);
@@ -4301,6 +4308,7 @@ static int regulator_suspend_late(struct device *dev)
4301 return class_for_each_device(&regulator_class, NULL, &state, 4308 return class_for_each_device(&regulator_class, NULL, &state,
4302 _regulator_suspend_late); 4309 _regulator_suspend_late);
4303} 4310}
4311
4304static int _regulator_resume_early(struct device *dev, void *data) 4312static int _regulator_resume_early(struct device *dev, void *data)
4305{ 4313{
4306 int ret = 0; 4314 int ret = 0;
diff --git a/drivers/regulator/da9055-regulator.c b/drivers/regulator/da9055-regulator.c
index d029c941a1e1..f40c3b8644ae 100644
--- a/drivers/regulator/da9055-regulator.c
+++ b/drivers/regulator/da9055-regulator.c
@@ -16,6 +16,7 @@
16#include <linux/init.h> 16#include <linux/init.h>
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/gpio.h> 18#include <linux/gpio.h>
19#include <linux/gpio/consumer.h>
19#include <linux/platform_device.h> 20#include <linux/platform_device.h>
20#include <linux/regulator/driver.h> 21#include <linux/regulator/driver.h>
21#include <linux/regulator/machine.h> 22#include <linux/regulator/machine.h>
@@ -455,8 +456,7 @@ static int da9055_gpio_init(struct da9055_regulator *regulator,
455 char name[18]; 456 char name[18];
456 int gpio_mux = pdata->gpio_ren[id]; 457 int gpio_mux = pdata->gpio_ren[id];
457 458
458 config->ena_gpio = pdata->ena_gpio[id]; 459 config->ena_gpiod = pdata->ena_gpiods[id];
459 config->ena_gpio_flags = GPIOF_OUT_INIT_HIGH;
460 config->ena_gpio_invert = 1; 460 config->ena_gpio_invert = 1;
461 461
462 /* 462 /*
diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c
index 9b8f47617724..6c122b3df5d0 100644
--- a/drivers/regulator/da9211-regulator.c
+++ b/drivers/regulator/da9211-regulator.c
@@ -15,7 +15,6 @@
15 */ 15 */
16 16
17#include <linux/err.h> 17#include <linux/err.h>
18#include <linux/gpio.h>
19#include <linux/i2c.h> 18#include <linux/i2c.h>
20#include <linux/module.h> 19#include <linux/module.h>
21#include <linux/init.h> 20#include <linux/init.h>
@@ -25,7 +24,7 @@
25#include <linux/regmap.h> 24#include <linux/regmap.h>
26#include <linux/irq.h> 25#include <linux/irq.h>
27#include <linux/interrupt.h> 26#include <linux/interrupt.h>
28#include <linux/of_gpio.h> 27#include <linux/gpio/consumer.h>
29#include <linux/regulator/of_regulator.h> 28#include <linux/regulator/of_regulator.h>
30#include <linux/regulator/da9211.h> 29#include <linux/regulator/da9211.h>
31#include "da9211-regulator.h" 30#include "da9211-regulator.h"
@@ -294,9 +293,12 @@ static struct da9211_pdata *da9211_parse_regulators_dt(
294 293
295 pdata->init_data[n] = da9211_matches[i].init_data; 294 pdata->init_data[n] = da9211_matches[i].init_data;
296 pdata->reg_node[n] = da9211_matches[i].of_node; 295 pdata->reg_node[n] = da9211_matches[i].of_node;
297 pdata->gpio_ren[n] = 296 pdata->gpiod_ren[n] = devm_gpiod_get_from_of_node(dev,
298 of_get_named_gpio(da9211_matches[i].of_node, 297 da9211_matches[i].of_node,
299 "enable-gpios", 0); 298 "enable",
299 0,
300 GPIOD_OUT_HIGH,
301 "da9211-enable");
300 n++; 302 n++;
301 } 303 }
302 304
@@ -382,13 +384,10 @@ static int da9211_regulator_init(struct da9211 *chip)
382 config.regmap = chip->regmap; 384 config.regmap = chip->regmap;
383 config.of_node = chip->pdata->reg_node[i]; 385 config.of_node = chip->pdata->reg_node[i];
384 386
385 if (gpio_is_valid(chip->pdata->gpio_ren[i])) { 387 if (chip->pdata->gpiod_ren[i])
386 config.ena_gpio = chip->pdata->gpio_ren[i]; 388 config.ena_gpiod = chip->pdata->gpiod_ren[i];
387 config.ena_gpio_initialized = true; 389 else
388 } else { 390 config.ena_gpiod = NULL;
389 config.ena_gpio = -EINVAL;
390 config.ena_gpio_initialized = false;
391 }
392 391
393 chip->rdev[i] = devm_regulator_register(chip->dev, 392 chip->rdev[i] = devm_regulator_register(chip->dev,
394 &da9211_regulators[i], &config); 393 &da9211_regulators[i], &config);
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c
index 0fce06acfaec..a86b8997bb54 100644
--- a/drivers/regulator/gpio-regulator.c
+++ b/drivers/regulator/gpio-regulator.c
@@ -196,6 +196,7 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
196 break; 196 break;
197 } 197 }
198 config->gpios[i].gpio = gpio; 198 config->gpios[i].gpio = gpio;
199 config->gpios[i].label = config->supply_name;
199 if (proplen > 0) { 200 if (proplen > 0) {
200 of_property_read_u32_index(np, "gpios-states", 201 of_property_read_u32_index(np, "gpios-states",
201 i, &ret); 202 i, &ret);
@@ -271,8 +272,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
271 drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL); 272 drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
272 if (drvdata->desc.name == NULL) { 273 if (drvdata->desc.name == NULL) {
273 dev_err(&pdev->dev, "Failed to allocate supply name\n"); 274 dev_err(&pdev->dev, "Failed to allocate supply name\n");
274 ret = -ENOMEM; 275 return -ENOMEM;
275 goto err;
276 } 276 }
277 277
278 if (config->nr_gpios != 0) { 278 if (config->nr_gpios != 0) {
@@ -292,7 +292,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
292 dev_err(&pdev->dev, 292 dev_err(&pdev->dev,
293 "Could not obtain regulator setting GPIOs: %d\n", 293 "Could not obtain regulator setting GPIOs: %d\n",
294 ret); 294 ret);
295 goto err_memstate; 295 goto err_memgpio;
296 } 296 }
297 } 297 }
298 298
@@ -303,7 +303,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
303 if (drvdata->states == NULL) { 303 if (drvdata->states == NULL) {
304 dev_err(&pdev->dev, "Failed to allocate state data\n"); 304 dev_err(&pdev->dev, "Failed to allocate state data\n");
305 ret = -ENOMEM; 305 ret = -ENOMEM;
306 goto err_memgpio; 306 goto err_stategpio;
307 } 307 }
308 drvdata->nr_states = config->nr_states; 308 drvdata->nr_states = config->nr_states;
309 309
@@ -324,7 +324,7 @@ static int gpio_regulator_probe(struct platform_device *pdev)
324 default: 324 default:
325 dev_err(&pdev->dev, "No regulator type set\n"); 325 dev_err(&pdev->dev, "No regulator type set\n");
326 ret = -EINVAL; 326 ret = -EINVAL;
327 goto err_memgpio; 327 goto err_memstate;
328 } 328 }
329 329
330 /* build initial state from gpio init data. */ 330 /* build initial state from gpio init data. */
@@ -361,22 +361,21 @@ static int gpio_regulator_probe(struct platform_device *pdev)
361 if (IS_ERR(drvdata->dev)) { 361 if (IS_ERR(drvdata->dev)) {
362 ret = PTR_ERR(drvdata->dev); 362 ret = PTR_ERR(drvdata->dev);
363 dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); 363 dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret);
364 goto err_stategpio; 364 goto err_memstate;
365 } 365 }
366 366
367 platform_set_drvdata(pdev, drvdata); 367 platform_set_drvdata(pdev, drvdata);
368 368
369 return 0; 369 return 0;
370 370
371err_stategpio:
372 gpio_free_array(drvdata->gpios, drvdata->nr_gpios);
373err_memstate: 371err_memstate:
374 kfree(drvdata->states); 372 kfree(drvdata->states);
373err_stategpio:
374 gpio_free_array(drvdata->gpios, drvdata->nr_gpios);
375err_memgpio: 375err_memgpio:
376 kfree(drvdata->gpios); 376 kfree(drvdata->gpios);
377err_name: 377err_name:
378 kfree(drvdata->desc.name); 378 kfree(drvdata->desc.name);
379err:
380 return ret; 379 return ret;
381} 380}
382 381
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 092ed6efb3ec..f47264fa1940 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -321,6 +321,7 @@ int of_regulator_match(struct device *dev, struct device_node *node,
321 dev_err(dev, 321 dev_err(dev,
322 "failed to parse DT for regulator %s\n", 322 "failed to parse DT for regulator %s\n",
323 child->name); 323 child->name);
324 of_node_put(child);
324 return -EINVAL; 325 return -EINVAL;
325 } 326 }
326 match->of_node = of_node_get(child); 327 match->of_node = of_node_get(child);
diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c
index 940fe1b78411..fe2fb36803e0 100644
--- a/drivers/regulator/qcom_smd-regulator.c
+++ b/drivers/regulator/qcom_smd-regulator.c
@@ -17,8 +17,6 @@
17#include <linux/of_device.h> 17#include <linux/of_device.h>
18#include <linux/platform_device.h> 18#include <linux/platform_device.h>
19#include <linux/regulator/driver.h> 19#include <linux/regulator/driver.h>
20#include <linux/regulator/machine.h>
21#include <linux/regulator/of_regulator.h>
22#include <linux/soc/qcom/smd-rpm.h> 20#include <linux/soc/qcom/smd-rpm.h>
23 21
24struct qcom_rpm_reg { 22struct qcom_rpm_reg {
@@ -165,6 +163,15 @@ static const struct regulator_ops rpm_switch_ops = {
165 .is_enabled = rpm_reg_is_enabled, 163 .is_enabled = rpm_reg_is_enabled,
166}; 164};
167 165
166static const struct regulator_ops rpm_bob_ops = {
167 .enable = rpm_reg_enable,
168 .disable = rpm_reg_disable,
169 .is_enabled = rpm_reg_is_enabled,
170
171 .get_voltage = rpm_reg_get_voltage,
172 .set_voltage = rpm_reg_set_voltage,
173};
174
168static const struct regulator_desc pma8084_hfsmps = { 175static const struct regulator_desc pma8084_hfsmps = {
169 .linear_ranges = (struct regulator_linear_range[]) { 176 .linear_ranges = (struct regulator_linear_range[]) {
170 REGULATOR_LINEAR_RANGE(375000, 0, 95, 12500), 177 REGULATOR_LINEAR_RANGE(375000, 0, 95, 12500),
@@ -355,6 +362,64 @@ static const struct regulator_desc pm8994_lnldo = {
355 .ops = &rpm_smps_ldo_ops_fixed, 362 .ops = &rpm_smps_ldo_ops_fixed,
356}; 363};
357 364
365static const struct regulator_desc pm8998_ftsmps = {
366 .linear_ranges = (struct regulator_linear_range[]) {
367 REGULATOR_LINEAR_RANGE(320000, 0, 258, 4000),
368 },
369 .n_linear_ranges = 1,
370 .n_voltages = 259,
371 .ops = &rpm_smps_ldo_ops,
372};
373
374static const struct regulator_desc pm8998_hfsmps = {
375 .linear_ranges = (struct regulator_linear_range[]) {
376 REGULATOR_LINEAR_RANGE(320000, 0, 215, 8000),
377 },
378 .n_linear_ranges = 1,
379 .n_voltages = 216,
380 .ops = &rpm_smps_ldo_ops,
381};
382
383static const struct regulator_desc pm8998_nldo = {
384 .linear_ranges = (struct regulator_linear_range[]) {
385 REGULATOR_LINEAR_RANGE(312000, 0, 127, 8000),
386 },
387 .n_linear_ranges = 1,
388 .n_voltages = 128,
389 .ops = &rpm_smps_ldo_ops,
390};
391
392static const struct regulator_desc pm8998_pldo = {
393 .linear_ranges = (struct regulator_linear_range[]) {
394 REGULATOR_LINEAR_RANGE(1664000, 0, 255, 8000),
395 },
396 .n_linear_ranges = 1,
397 .n_voltages = 256,
398 .ops = &rpm_smps_ldo_ops,
399};
400
401static const struct regulator_desc pm8998_pldo_lv = {
402 .linear_ranges = (struct regulator_linear_range[]) {
403 REGULATOR_LINEAR_RANGE(1256000, 0, 127, 8000),
404 },
405 .n_linear_ranges = 1,
406 .n_voltages = 128,
407 .ops = &rpm_smps_ldo_ops,
408};
409
410static const struct regulator_desc pm8998_switch = {
411 .ops = &rpm_switch_ops,
412};
413
414static const struct regulator_desc pmi8998_bob = {
415 .linear_ranges = (struct regulator_linear_range[]) {
416 REGULATOR_LINEAR_RANGE(1824000, 0, 83, 32000),
417 },
418 .n_linear_ranges = 1,
419 .n_voltages = 84,
420 .ops = &rpm_bob_ops,
421};
422
358struct rpm_regulator_data { 423struct rpm_regulator_data {
359 const char *name; 424 const char *name;
360 u32 type; 425 u32 type;
@@ -544,12 +609,66 @@ static const struct rpm_regulator_data rpm_pm8994_regulators[] = {
544 {} 609 {}
545}; 610};
546 611
612static const struct rpm_regulator_data rpm_pm8998_regulators[] = {
613 { "s1", QCOM_SMD_RPM_SMPA, 1, &pm8998_ftsmps, "vdd_s1" },
614 { "s2", QCOM_SMD_RPM_SMPA, 2, &pm8998_ftsmps, "vdd_s2" },
615 { "s3", QCOM_SMD_RPM_SMPA, 3, &pm8998_hfsmps, "vdd_s3" },
616 { "s4", QCOM_SMD_RPM_SMPA, 4, &pm8998_hfsmps, "vdd_s4" },
617 { "s5", QCOM_SMD_RPM_SMPA, 5, &pm8998_hfsmps, "vdd_s5" },
618 { "s6", QCOM_SMD_RPM_SMPA, 6, &pm8998_ftsmps, "vdd_s6" },
619 { "s7", QCOM_SMD_RPM_SMPA, 7, &pm8998_ftsmps, "vdd_s7" },
620 { "s8", QCOM_SMD_RPM_SMPA, 8, &pm8998_ftsmps, "vdd_s8" },
621 { "s9", QCOM_SMD_RPM_SMPA, 9, &pm8998_ftsmps, "vdd_s9" },
622 { "s10", QCOM_SMD_RPM_SMPA, 10, &pm8998_ftsmps, "vdd_s10" },
623 { "s11", QCOM_SMD_RPM_SMPA, 11, &pm8998_ftsmps, "vdd_s11" },
624 { "s12", QCOM_SMD_RPM_SMPA, 12, &pm8998_ftsmps, "vdd_s12" },
625 { "s13", QCOM_SMD_RPM_SMPA, 13, &pm8998_ftsmps, "vdd_s13" },
626 { "l1", QCOM_SMD_RPM_LDOA, 1, &pm8998_nldo, "vdd_l1_l27" },
627 { "l2", QCOM_SMD_RPM_LDOA, 2, &pm8998_nldo, "vdd_l2_l8_l17" },
628 { "l3", QCOM_SMD_RPM_LDOA, 3, &pm8998_nldo, "vdd_l3_l11" },
629 { "l4", QCOM_SMD_RPM_LDOA, 4, &pm8998_nldo, "vdd_l4_l5" },
630 { "l5", QCOM_SMD_RPM_LDOA, 5, &pm8998_nldo, "vdd_l4_l5" },
631 { "l6", QCOM_SMD_RPM_LDOA, 6, &pm8998_pldo, "vdd_l6" },
632 { "l7", QCOM_SMD_RPM_LDOA, 7, &pm8998_pldo_lv, "vdd_l7_l12_l14_l15" },
633 { "l8", QCOM_SMD_RPM_LDOA, 8, &pm8998_nldo, "vdd_l2_l8_l17" },
634 { "l9", QCOM_SMD_RPM_LDOA, 9, &pm8998_pldo, "vdd_l9" },
635 { "l10", QCOM_SMD_RPM_LDOA, 10, &pm8998_pldo, "vdd_l10_l23_l25" },
636 { "l11", QCOM_SMD_RPM_LDOA, 11, &pm8998_nldo, "vdd_l3_l11" },
637 { "l12", QCOM_SMD_RPM_LDOA, 12, &pm8998_pldo_lv, "vdd_l7_l12_l14_l15" },
638 { "l13", QCOM_SMD_RPM_LDOA, 13, &pm8998_pldo, "vdd_l13_l19_l21" },
639 { "l14", QCOM_SMD_RPM_LDOA, 14, &pm8998_pldo_lv, "vdd_l7_l12_l14_l15" },
640 { "l15", QCOM_SMD_RPM_LDOA, 15, &pm8998_pldo_lv, "vdd_l7_l12_l14_l15" },
641 { "l16", QCOM_SMD_RPM_LDOA, 16, &pm8998_pldo, "vdd_l16_l28" },
642 { "l17", QCOM_SMD_RPM_LDOA, 17, &pm8998_nldo, "vdd_l2_l8_l17" },
643 { "l18", QCOM_SMD_RPM_LDOA, 18, &pm8998_pldo, "vdd_l18_l22" },
644 { "l19", QCOM_SMD_RPM_LDOA, 19, &pm8998_pldo, "vdd_l13_l19_l21" },
645 { "l20", QCOM_SMD_RPM_LDOA, 20, &pm8998_pldo, "vdd_l20_l24" },
646 { "l21", QCOM_SMD_RPM_LDOA, 21, &pm8998_pldo, "vdd_l13_l19_l21" },
647 { "l22", QCOM_SMD_RPM_LDOA, 22, &pm8998_pldo, "vdd_l18_l22" },
648 { "l23", QCOM_SMD_RPM_LDOA, 23, &pm8998_pldo, "vdd_l10_l23_l25" },
649 { "l24", QCOM_SMD_RPM_LDOA, 24, &pm8998_pldo, "vdd_l20_l24" },
650 { "l25", QCOM_SMD_RPM_LDOA, 25, &pm8998_pldo, "vdd_l10_l23_l25" },
651 { "l26", QCOM_SMD_RPM_LDOA, 26, &pm8998_nldo, "vdd_l26" },
652 { "l27", QCOM_SMD_RPM_LDOA, 27, &pm8998_nldo, "vdd_l1_l27" },
653 { "l28", QCOM_SMD_RPM_LDOA, 28, &pm8998_pldo, "vdd_l16_l28" },
654 { "lvs1", QCOM_SMD_RPM_VSA, 1, &pm8998_switch, "vdd_lvs1_lvs2" },
655 { "lvs2", QCOM_SMD_RPM_VSA, 2, &pm8998_switch, "vdd_lvs1_lvs2" },
656 {}
657};
658
659static const struct rpm_regulator_data rpm_pmi8998_regulators[] = {
660 { "bob", QCOM_SMD_RPM_BOBB, 1, &pmi8998_bob, "vdd_bob" },
661 {}
662};
663
547static const struct of_device_id rpm_of_match[] = { 664static const struct of_device_id rpm_of_match[] = {
548 { .compatible = "qcom,rpm-pm8841-regulators", .data = &rpm_pm8841_regulators }, 665 { .compatible = "qcom,rpm-pm8841-regulators", .data = &rpm_pm8841_regulators },
549 { .compatible = "qcom,rpm-pm8916-regulators", .data = &rpm_pm8916_regulators }, 666 { .compatible = "qcom,rpm-pm8916-regulators", .data = &rpm_pm8916_regulators },
550 { .compatible = "qcom,rpm-pm8941-regulators", .data = &rpm_pm8941_regulators }, 667 { .compatible = "qcom,rpm-pm8941-regulators", .data = &rpm_pm8941_regulators },
551 { .compatible = "qcom,rpm-pm8994-regulators", .data = &rpm_pm8994_regulators }, 668 { .compatible = "qcom,rpm-pm8994-regulators", .data = &rpm_pm8994_regulators },
669 { .compatible = "qcom,rpm-pm8998-regulators", .data = &rpm_pm8998_regulators },
552 { .compatible = "qcom,rpm-pma8084-regulators", .data = &rpm_pma8084_regulators }, 670 { .compatible = "qcom,rpm-pma8084-regulators", .data = &rpm_pma8084_regulators },
671 { .compatible = "qcom,rpm-pmi8998-regulators", .data = &rpm_pmi8998_regulators },
553 {} 672 {}
554}; 673};
555MODULE_DEVICE_TABLE(of, rpm_of_match); 674MODULE_DEVICE_TABLE(of, rpm_of_match);
diff --git a/include/linux/mfd/da9055/pdata.h b/include/linux/mfd/da9055/pdata.h
index 04e092be4b07..1a94fa2ac309 100644
--- a/include/linux/mfd/da9055/pdata.h
+++ b/include/linux/mfd/da9055/pdata.h
@@ -12,6 +12,7 @@
12#define DA9055_MAX_REGULATORS 8 12#define DA9055_MAX_REGULATORS 8
13 13
14struct da9055; 14struct da9055;
15struct gpio_desc;
15 16
16enum gpio_select { 17enum gpio_select {
17 NO_GPIO = 0, 18 NO_GPIO = 0,
@@ -47,7 +48,7 @@ struct da9055_pdata {
47 * controls the regulator set A/B, 0 if not available. 48 * controls the regulator set A/B, 0 if not available.
48 */ 49 */
49 enum gpio_select *reg_rsel; 50 enum gpio_select *reg_rsel;
50 /* GPIOs to enable regulator, 0 if not available */ 51 /* GPIO descriptors to enable regulator, NULL if not available */
51 int *ena_gpio; 52 struct gpio_desc **ena_gpiods;
52}; 53};
53#endif /* __DA9055_PDATA_H */ 54#endif /* __DA9055_PDATA_H */
diff --git a/include/linux/regulator/da9211.h b/include/linux/regulator/da9211.h
index f2fd2d3bf58f..d1f2073e4d5f 100644
--- a/include/linux/regulator/da9211.h
+++ b/include/linux/regulator/da9211.h
@@ -21,6 +21,8 @@
21 21
22#define DA9211_MAX_REGULATORS 2 22#define DA9211_MAX_REGULATORS 2
23 23
24struct gpio_desc;
25
24enum da9211_chip_id { 26enum da9211_chip_id {
25 DA9211, 27 DA9211,
26 DA9212, 28 DA9212,
@@ -39,7 +41,7 @@ struct da9211_pdata {
39 * 2 : 2 phase 2 buck 41 * 2 : 2 phase 2 buck
40 */ 42 */
41 int num_buck; 43 int num_buck;
42 int gpio_ren[DA9211_MAX_REGULATORS]; 44 struct gpio_desc *gpiod_ren[DA9211_MAX_REGULATORS];
43 struct device_node *reg_node[DA9211_MAX_REGULATORS]; 45 struct device_node *reg_node[DA9211_MAX_REGULATORS];
44 struct regulator_init_data *init_data[DA9211_MAX_REGULATORS]; 46 struct regulator_init_data *init_data[DA9211_MAX_REGULATORS];
45}; 47};
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 4c00486b7a78..4fc96cb8e5d7 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -19,6 +19,7 @@
19#include <linux/notifier.h> 19#include <linux/notifier.h>
20#include <linux/regulator/consumer.h> 20#include <linux/regulator/consumer.h>
21 21
22struct gpio_desc;
22struct regmap; 23struct regmap;
23struct regulator_dev; 24struct regulator_dev;
24struct regulator_config; 25struct regulator_config;
@@ -387,6 +388,7 @@ struct regulator_desc {
387 * initialized, meaning that >= 0 is a valid gpio 388 * initialized, meaning that >= 0 is a valid gpio
388 * identifier and < 0 is a non existent gpio. 389 * identifier and < 0 is a non existent gpio.
389 * @ena_gpio: GPIO controlling regulator enable. 390 * @ena_gpio: GPIO controlling regulator enable.
391 * @ena_gpiod: GPIO descriptor controlling regulator enable.
390 * @ena_gpio_invert: Sense for GPIO enable control. 392 * @ena_gpio_invert: Sense for GPIO enable control.
391 * @ena_gpio_flags: Flags to use when calling gpio_request_one() 393 * @ena_gpio_flags: Flags to use when calling gpio_request_one()
392 */ 394 */
@@ -399,6 +401,7 @@ struct regulator_config {
399 401
400 bool ena_gpio_initialized; 402 bool ena_gpio_initialized;
401 int ena_gpio; 403 int ena_gpio;
404 struct gpio_desc *ena_gpiod;
402 unsigned int ena_gpio_invert:1; 405 unsigned int ena_gpio_invert:1;
403 unsigned int ena_gpio_flags; 406 unsigned int ena_gpio_flags;
404}; 407};
diff --git a/include/linux/soc/qcom/smd-rpm.h b/include/linux/soc/qcom/smd-rpm.h
index 9f5c6e53f3a5..9e4fdd861a51 100644
--- a/include/linux/soc/qcom/smd-rpm.h
+++ b/include/linux/soc/qcom/smd-rpm.h
@@ -10,6 +10,7 @@ struct qcom_smd_rpm;
10/* 10/*
11 * Constants used for addressing resources in the RPM. 11 * Constants used for addressing resources in the RPM.
12 */ 12 */
13#define QCOM_SMD_RPM_BOBB 0x62626f62
13#define QCOM_SMD_RPM_BOOST 0x61747362 14#define QCOM_SMD_RPM_BOOST 0x61747362
14#define QCOM_SMD_RPM_BUS_CLK 0x316b6c63 15#define QCOM_SMD_RPM_BUS_CLK 0x316b6c63
15#define QCOM_SMD_RPM_BUS_MASTER 0x73616d62 16#define QCOM_SMD_RPM_BUS_MASTER 0x73616d62