aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-09-05 14:43:30 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-09-05 14:43:30 -0400
commitfe9e31383e9a271a9b404488704e00acd1747ee3 (patch)
tree2d44c657a87b6379705745b46862a92463285a9a
parentb88f55774f20c0c306e0a95d22ca9ab5f08187c7 (diff)
parent00ee929f9efcad925ed4118f8c2e8bceb9fe7373 (diff)
Merge tag 'regulator-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates from Mark Brown: "This is an extremely quiet release for the regulator subsystem, it's all fairly minor fixes and cleanups plus a few new drivers and ddevice ID additions: - Support for MediaTek MT6380, Ricoh RC5T619 and ST Voltage Reference Buffers" * tag 'regulator-v4.14' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (24 commits) regulator: Add support for stm32-vrefbuf regulator: Add STM32 Voltage Reference Buffer regulator: pv88090: Exception handling for out of bounds regulator: da9063: Return an error code on probe failure regulator: rn5t618: add RC5T619 PMIC support regulator: ltc3589: constify i2c_device_id regulator: fan53555: fix I2C device ids regulator: add fixes with MT6397 dt-bindings shouldn't reference driver regulator: add fixes with MT6323 dt-bindings shouldn't reference driver regulator: add fixes with MT6311 dt-bindings shouldn't reference driver regulator: Add document for MediaTek MT6380 regulator regulator: mt6380: Add support for MT6380 regulator: pwm-regulator: Remove unneeded gpiod NULL check regulator: core: fix a possible race in disable_work handling regulator: fan53555: Use of_device_get_match_data() to simplify probe regulator: of: regulator_of_get_init_data() missing of_node_get() regulator: pwm-regulator: fix example syntax regulator: Convert to using %pOF instead of full_name regulator: cpcap: Add OF mode mapping regulator: cpcap: Fix standby mode ...
-rw-r--r--Documentation/devicetree/bindings/regulator/mt6311-regulator.txt2
-rw-r--r--Documentation/devicetree/bindings/regulator/mt6323-regulator.txt2
-rw-r--r--Documentation/devicetree/bindings/regulator/mt6380-regulator.txt89
-rw-r--r--Documentation/devicetree/bindings/regulator/mt6397-regulator.txt2
-rw-r--r--Documentation/devicetree/bindings/regulator/pwm-regulator.txt2
-rw-r--r--Documentation/devicetree/bindings/regulator/st,stm32-vrefbuf.txt20
-rw-r--r--drivers/regulator/Kconfig25
-rw-r--r--drivers/regulator/Makefile2
-rw-r--r--drivers/regulator/axp20x-regulator.c6
-rw-r--r--drivers/regulator/core.c16
-rw-r--r--drivers/regulator/cpcap-regulator.c21
-rw-r--r--drivers/regulator/da9063-regulator.c2
-rw-r--r--drivers/regulator/fan53555.c15
-rw-r--r--drivers/regulator/ltc3589.c2
-rw-r--r--drivers/regulator/max1586.c2
-rw-r--r--drivers/regulator/mt6380-regulator.c352
-rw-r--r--drivers/regulator/of_regulator.c2
-rw-r--r--drivers/regulator/pv88090-regulator.c11
-rw-r--r--drivers/regulator/pv88090-regulator.h8
-rw-r--r--drivers/regulator/pwm-regulator.c6
-rw-r--r--drivers/regulator/qcom_rpm-regulator.c5
-rw-r--r--drivers/regulator/qcom_smd-regulator.c5
-rw-r--r--drivers/regulator/rn5t618-regulator.c35
-rw-r--r--drivers/regulator/s5m8767.c4
-rw-r--r--drivers/regulator/stm32-vrefbuf.c202
-rw-r--r--drivers/reset/reset-socfpga.c4
-rw-r--r--include/linux/mfd/rn5t618.h6
-rw-r--r--include/linux/regulator/mt6380-regulator.h32
28 files changed, 835 insertions, 45 deletions
diff --git a/Documentation/devicetree/bindings/regulator/mt6311-regulator.txt b/Documentation/devicetree/bindings/regulator/mt6311-regulator.txt
index 02649d8b3f5a..84d544d8c1b1 100644
--- a/Documentation/devicetree/bindings/regulator/mt6311-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/mt6311-regulator.txt
@@ -1,4 +1,4 @@
1Mediatek MT6311 Regulator Driver 1Mediatek MT6311 Regulator
2 2
3Required properties: 3Required properties:
4- compatible: "mediatek,mt6311-regulator" 4- compatible: "mediatek,mt6311-regulator"
diff --git a/Documentation/devicetree/bindings/regulator/mt6323-regulator.txt b/Documentation/devicetree/bindings/regulator/mt6323-regulator.txt
index c35d878b0960..a48749db4df3 100644
--- a/Documentation/devicetree/bindings/regulator/mt6323-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/mt6323-regulator.txt
@@ -1,4 +1,4 @@
1Mediatek MT6323 Regulator Driver 1Mediatek MT6323 Regulator
2 2
3All voltage regulators are defined as subnodes of the regulators node. A list 3All voltage regulators are defined as subnodes of the regulators node. A list
4of regulators provided by this controller are defined as subnodes of the 4of regulators provided by this controller are defined as subnodes of the
diff --git a/Documentation/devicetree/bindings/regulator/mt6380-regulator.txt b/Documentation/devicetree/bindings/regulator/mt6380-regulator.txt
new file mode 100644
index 000000000000..0058441f16d2
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/mt6380-regulator.txt
@@ -0,0 +1,89 @@
1MediaTek MT6380 Regulator
2
3All voltage regulators provided by the MT6380 PMIC are described as the
4subnodes of the MT6380 regulators node. Each regulator is named according
5to its regulator type, buck-<name> and ldo-<name>. The definition for each
6of these nodes is defined using the standard binding for regulators at
7Documentation/devicetree/bindings/regulator/regulator.txt.
8
9The valid names for regulators are:
10BUCK:
11 buck-core1, buck-vcore, buck-vrf
12LDO:
13 ldo-vm ,ldo-va , ldo-vphy, ldo-vddr, ldo-vt
14
15Example:
16
17 regulators {
18 compatible = "mediatek,mt6380-regulator";
19
20 mt6380_vcpu_reg: buck-vcore1 {
21 regulator-name = "vcore1";
22 regulator-min-microvolt = < 600000>;
23 regulator-max-microvolt = <1393750>;
24 regulator-ramp-delay = <6250>;
25 regulator-always-on;
26 regulator-boot-on;
27 };
28
29 mt6380_vcore_reg: buck-vcore {
30 regulator-name = "vcore";
31 regulator-min-microvolt = <600000>;
32 regulator-max-microvolt = <1393750>;
33 regulator-ramp-delay = <6250>;
34 };
35
36 mt6380_vrf_reg: buck-vrf {
37 regulator-name = "vrf";
38 regulator-min-microvolt = <1200000>;
39 regulator-max-microvolt = <1575000>;
40 regulator-ramp-delay = <0>;
41 regulator-always-on;
42 regulator-boot-on;
43 };
44
45 mt6380_vm_reg: ldo-vm {
46 regulator-name = "vm";
47 regulator-min-microvolt = <1050000>;
48 regulator-max-microvolt = <1400000>;
49 regulator-ramp-delay = <0>;
50 regulator-always-on;
51 regulator-boot-on;
52 };
53
54 mt6380_va_reg: ldo-va {
55 regulator-name = "va";
56 regulator-min-microvolt = <2200000>;
57 regulator-max-microvolt = <3300000>;
58 regulator-ramp-delay = <0>;
59 regulator-always-on;
60 regulator-boot-on;
61 };
62
63 mt6380_vphy_reg: ldo-vphy {
64 regulator-name = "vphy";
65 regulator-min-microvolt = <1800000>;
66 regulator-max-microvolt = <1800000>;
67 regulator-ramp-delay = <0>;
68 regulator-always-on;
69 regulator-boot-on;
70 };
71
72 mt6380_vddr_reg: ldo-vddr {
73 regulator-name = "vddr";
74 regulator-min-microvolt = <1240000>;
75 regulator-max-microvolt = <1840000>;
76 regulator-ramp-delay = <0>;
77 regulator-always-on;
78 regulator-boot-on;
79 };
80
81 mt6380_vt_reg: ldo-vt {
82 regulator-name = "vt";
83 regulator-min-microvolt = <2200000>;
84 regulator-max-microvolt = <3300000>;
85 regulator-ramp-delay = <0>;
86 regulator-always-on;
87 regulator-boot-on;
88 };
89 };
diff --git a/Documentation/devicetree/bindings/regulator/mt6397-regulator.txt b/Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
index a42b1d6e9863..01141fb00875 100644
--- a/Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/mt6397-regulator.txt
@@ -1,4 +1,4 @@
1Mediatek MT6397 Regulator Driver 1Mediatek MT6397 Regulator
2 2
3Required properties: 3Required properties:
4- compatible: "mediatek,mt6397-regulator" 4- compatible: "mediatek,mt6397-regulator"
diff --git a/Documentation/devicetree/bindings/regulator/pwm-regulator.txt b/Documentation/devicetree/bindings/regulator/pwm-regulator.txt
index bf85aa9ad6a7..3d78d507e29f 100644
--- a/Documentation/devicetree/bindings/regulator/pwm-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/pwm-regulator.txt
@@ -71,7 +71,7 @@ Continuous Voltage With Enable GPIO Example:
71 * Inverted PWM logic, and the duty cycle range is limited 71 * Inverted PWM logic, and the duty cycle range is limited
72 * to 30%-70%. 72 * to 30%-70%.
73 */ 73 */
74 pwm-dutycycle-range <700 300>; /* */ 74 pwm-dutycycle-range = <700 300>; /* */
75 }; 75 };
76 76
77Voltage Table Example: 77Voltage Table Example:
diff --git a/Documentation/devicetree/bindings/regulator/st,stm32-vrefbuf.txt b/Documentation/devicetree/bindings/regulator/st,stm32-vrefbuf.txt
new file mode 100644
index 000000000000..3944ee3e731e
--- /dev/null
+++ b/Documentation/devicetree/bindings/regulator/st,stm32-vrefbuf.txt
@@ -0,0 +1,20 @@
1STM32 VREFBUF - Voltage reference buffer
2
3Some STM32 devices embed a voltage reference buffer which can be used as
4voltage reference for ADCs, DACs and also as voltage reference for external
5components through the dedicated VREF+ pin.
6
7Required properties:
8- compatible: Must be "st,stm32-vrefbuf".
9- reg: Offset and length of VREFBUF register set.
10- clocks: Must contain an entry for peripheral clock.
11
12Example:
13 vrefbuf: regulator@58003C00 {
14 compatible = "st,stm32-vrefbuf";
15 reg = <0x58003C00 0x8>;
16 clocks = <&rcc VREF_CK>;
17 regulator-min-microvolt = <1500000>;
18 regulator-max-microvolt = <2500000>;
19 vdda-supply = <&vdda>;
20 };
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig
index 99b9362331b5..e740a66cb1d6 100644
--- a/drivers/regulator/Kconfig
+++ b/drivers/regulator/Kconfig
@@ -559,6 +559,15 @@ config REGULATOR_MT6323
559 This driver supports the control of different power rails of device 559 This driver supports the control of different power rails of device
560 through regulator interface. 560 through regulator interface.
561 561
562config REGULATOR_MT6380
563 tristate "MediaTek MT6380 PMIC"
564 depends on MTK_PMIC_WRAP
565 help
566 Say y here to select this option to enable the power regulator of
567 MediaTek MT6380 PMIC.
568 This driver supports the control of different power rails of device
569 through regulator interface.
570
562config REGULATOR_MT6397 571config REGULATOR_MT6397
563 tristate "MediaTek MT6397 PMIC" 572 tristate "MediaTek MT6397 PMIC"
564 depends on MFD_MT6397 573 depends on MFD_MT6397
@@ -700,8 +709,8 @@ config REGULATOR_RN5T618
700 tristate "Ricoh RN5T567/618 voltage regulators" 709 tristate "Ricoh RN5T567/618 voltage regulators"
701 depends on MFD_RN5T618 710 depends on MFD_RN5T618
702 help 711 help
703 Say y here to support the regulators found on Ricoh RN5T567 or 712 Say y here to support the regulators found on Ricoh RN5T567,
704 RN5T618 PMIC. 713 RN5T618 or RC5T619 PMIC.
705 714
706config REGULATOR_RT5033 715config REGULATOR_RT5033
707 tristate "Richtek RT5033 Regulators" 716 tristate "Richtek RT5033 Regulators"
@@ -746,6 +755,18 @@ config REGULATOR_SKY81452
746 This driver can also be built as a module. If so, the module 755 This driver can also be built as a module. If so, the module
747 will be called sky81452-regulator. 756 will be called sky81452-regulator.
748 757
758config REGULATOR_STM32_VREFBUF
759 tristate "STMicroelectronics STM32 VREFBUF"
760 depends on ARCH_STM32 || COMPILE_TEST
761 help
762 This driver supports STMicroelectronics STM32 VREFBUF (voltage
763 reference buffer) which can be used as voltage reference for
764 internal ADCs, DACs and also for external components through
765 dedicated Vref+ pin.
766
767 This driver can also be built as a module. If so, the module
768 will be called stm32-vrefbuf.
769
749config REGULATOR_TI_ABB 770config REGULATOR_TI_ABB
750 tristate "TI Adaptive Body Bias on-chip LDO" 771 tristate "TI Adaptive Body Bias on-chip LDO"
751 depends on ARCH_OMAP 772 depends on ARCH_OMAP
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile
index 95b1e86ae692..cbb6e45c77b2 100644
--- a/drivers/regulator/Makefile
+++ b/drivers/regulator/Makefile
@@ -72,6 +72,7 @@ obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o
72obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o 72obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o
73obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o 73obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o
74obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o 74obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o
75obj-$(CONFIG_REGULATOR_MT6380) += mt6380-regulator.o
75obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o 76obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o
76obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o 77obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o
77obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o 78obj-$(CONFIG_REGULATOR_QCOM_SMD_RPM) += qcom_smd-regulator.o
@@ -94,6 +95,7 @@ obj-$(CONFIG_REGULATOR_S2MPA01) += s2mpa01.o
94obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o 95obj-$(CONFIG_REGULATOR_S2MPS11) += s2mps11.o
95obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o 96obj-$(CONFIG_REGULATOR_S5M8767) += s5m8767.o
96obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o 97obj-$(CONFIG_REGULATOR_SKY81452) += sky81452-regulator.o
98obj-$(CONFIG_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
97obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o 99obj-$(CONFIG_REGULATOR_STW481X_VMMC) += stw481x-vmmc.o
98obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o 100obj-$(CONFIG_REGULATOR_TI_ABB) += ti-abb-regulator.o
99obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o 101obj-$(CONFIG_REGULATOR_TPS6105X) += tps6105x-regulator.o
diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c
index e2608fe770b9..f18b36dd57dd 100644
--- a/drivers/regulator/axp20x-regulator.c
+++ b/drivers/regulator/axp20x-regulator.c
@@ -691,6 +691,9 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
691 (regulators == axp809_regulators && i == AXP809_DC1SW)) { 691 (regulators == axp809_regulators && i == AXP809_DC1SW)) {
692 new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc), 692 new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc),
693 GFP_KERNEL); 693 GFP_KERNEL);
694 if (!new_desc)
695 return -ENOMEM;
696
694 *new_desc = regulators[i]; 697 *new_desc = regulators[i];
695 new_desc->supply_name = dcdc1_name; 698 new_desc->supply_name = dcdc1_name;
696 desc = new_desc; 699 desc = new_desc;
@@ -700,6 +703,9 @@ static int axp20x_regulator_probe(struct platform_device *pdev)
700 (regulators == axp809_regulators && i == AXP809_DC5LDO)) { 703 (regulators == axp809_regulators && i == AXP809_DC5LDO)) {
701 new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc), 704 new_desc = devm_kzalloc(&pdev->dev, sizeof(*desc),
702 GFP_KERNEL); 705 GFP_KERNEL);
706 if (!new_desc)
707 return -ENOMEM;
708
703 *new_desc = regulators[i]; 709 *new_desc = regulators[i];
704 new_desc->supply_name = dcdc5_name; 710 new_desc->supply_name = dcdc5_name;
705 desc = new_desc; 711 desc = new_desc;
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index e567fa54980b..b64b7916507f 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -204,8 +204,8 @@ static struct device_node *of_get_regulator(struct device *dev, const char *supp
204 regnode = of_parse_phandle(dev->of_node, prop_name, 0); 204 regnode = of_parse_phandle(dev->of_node, prop_name, 0);
205 205
206 if (!regnode) { 206 if (!regnode) {
207 dev_dbg(dev, "Looking up %s property in node %s failed\n", 207 dev_dbg(dev, "Looking up %s property in node %pOF failed\n",
208 prop_name, dev->of_node->full_name); 208 prop_name, dev->of_node);
209 return NULL; 209 return NULL;
210 } 210 }
211 return regnode; 211 return regnode;
@@ -2396,6 +2396,14 @@ static void regulator_disable_work(struct work_struct *work)
2396 count = rdev->deferred_disables; 2396 count = rdev->deferred_disables;
2397 rdev->deferred_disables = 0; 2397 rdev->deferred_disables = 0;
2398 2398
2399 /*
2400 * Workqueue functions queue the new work instance while the previous
2401 * work instance is being processed. Cancel the queued work instance
2402 * as the work instance under processing does the job of the queued
2403 * work instance.
2404 */
2405 cancel_delayed_work(&rdev->disable_work);
2406
2399 for (i = 0; i < count; i++) { 2407 for (i = 0; i < count; i++) {
2400 ret = _regulator_disable(rdev); 2408 ret = _regulator_disable(rdev);
2401 if (ret != 0) 2409 if (ret != 0)
@@ -2439,10 +2447,10 @@ int regulator_disable_deferred(struct regulator *regulator, int ms)
2439 2447
2440 mutex_lock(&rdev->mutex); 2448 mutex_lock(&rdev->mutex);
2441 rdev->deferred_disables++; 2449 rdev->deferred_disables++;
2450 mod_delayed_work(system_power_efficient_wq, &rdev->disable_work,
2451 msecs_to_jiffies(ms));
2442 mutex_unlock(&rdev->mutex); 2452 mutex_unlock(&rdev->mutex);
2443 2453
2444 queue_delayed_work(system_power_efficient_wq, &rdev->disable_work,
2445 msecs_to_jiffies(ms));
2446 return 0; 2454 return 0;
2447} 2455}
2448EXPORT_SYMBOL_GPL(regulator_disable_deferred); 2456EXPORT_SYMBOL_GPL(regulator_disable_deferred);
diff --git a/drivers/regulator/cpcap-regulator.c b/drivers/regulator/cpcap-regulator.c
index cc98aceed1c1..f541b80f1b54 100644
--- a/drivers/regulator/cpcap-regulator.c
+++ b/drivers/regulator/cpcap-regulator.c
@@ -77,6 +77,8 @@
77#define CPCAP_BIT_VAUDIO_MODE0 BIT(1) 77#define CPCAP_BIT_VAUDIO_MODE0 BIT(1)
78#define CPCAP_BIT_V_AUDIO_EN BIT(0) 78#define CPCAP_BIT_V_AUDIO_EN BIT(0)
79 79
80#define CPCAP_BIT_AUDIO_NORMAL_MODE 0x00
81
80/* 82/*
81 * Off mode configuration bit. Used currently only by SW5 on omap4. There's 83 * Off mode configuration bit. Used currently only by SW5 on omap4. There's
82 * the following comment in Motorola Linux kernel tree for it: 84 * the following comment in Motorola Linux kernel tree for it:
@@ -121,6 +123,7 @@ struct cpcap_regulator {
121 .enable_val = (mode_val), \ 123 .enable_val = (mode_val), \
122 .disable_val = (off_val), \ 124 .disable_val = (off_val), \
123 .ramp_delay = (volt_trans_time), \ 125 .ramp_delay = (volt_trans_time), \
126 .of_map_mode = cpcap_map_mode, \
124 }, \ 127 }, \
125 .assign_reg = (assignment_reg), \ 128 .assign_reg = (assignment_reg), \
126 .assign_mask = (assignment_mask), \ 129 .assign_mask = (assignment_mask), \
@@ -211,13 +214,25 @@ static int cpcap_regulator_disable(struct regulator_dev *rdev)
211 return error; 214 return error;
212} 215}
213 216
217static unsigned int cpcap_map_mode(unsigned int mode)
218{
219 switch (mode) {
220 case CPCAP_BIT_AUDIO_NORMAL_MODE:
221 return REGULATOR_MODE_NORMAL;
222 case CPCAP_BIT_AUDIO_LOW_PWR:
223 return REGULATOR_MODE_STANDBY;
224 default:
225 return -EINVAL;
226 }
227}
228
214static unsigned int cpcap_regulator_get_mode(struct regulator_dev *rdev) 229static unsigned int cpcap_regulator_get_mode(struct regulator_dev *rdev)
215{ 230{
216 int value; 231 int value;
217 232
218 regmap_read(rdev->regmap, rdev->desc->enable_reg, &value); 233 regmap_read(rdev->regmap, rdev->desc->enable_reg, &value);
219 234
220 if (!(value & CPCAP_BIT_AUDIO_LOW_PWR)) 235 if (value & CPCAP_BIT_AUDIO_LOW_PWR)
221 return REGULATOR_MODE_STANDBY; 236 return REGULATOR_MODE_STANDBY;
222 237
223 return REGULATOR_MODE_NORMAL; 238 return REGULATOR_MODE_NORMAL;
@@ -230,10 +245,10 @@ static int cpcap_regulator_set_mode(struct regulator_dev *rdev,
230 245
231 switch (mode) { 246 switch (mode) {
232 case REGULATOR_MODE_NORMAL: 247 case REGULATOR_MODE_NORMAL:
233 value = CPCAP_BIT_AUDIO_LOW_PWR; 248 value = CPCAP_BIT_AUDIO_NORMAL_MODE;
234 break; 249 break;
235 case REGULATOR_MODE_STANDBY: 250 case REGULATOR_MODE_STANDBY:
236 value = 0; 251 value = CPCAP_BIT_AUDIO_LOW_PWR;
237 break; 252 break;
238 default: 253 default:
239 return -EINVAL; 254 return -EINVAL;
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c
index c6af343f54ea..6a8f9cd69f52 100644
--- a/drivers/regulator/da9063-regulator.c
+++ b/drivers/regulator/da9063-regulator.c
@@ -736,7 +736,7 @@ static int da9063_regulator_probe(struct platform_device *pdev)
736 if (IS_ERR(regl_pdata) || regl_pdata->n_regulators == 0) { 736 if (IS_ERR(regl_pdata) || regl_pdata->n_regulators == 0) {
737 dev_err(&pdev->dev, 737 dev_err(&pdev->dev,
738 "No regulators defined for the platform\n"); 738 "No regulators defined for the platform\n");
739 return PTR_ERR(regl_pdata); 739 return -ENODEV;
740 } 740 }
741 741
742 /* Find regulators set for particular device model */ 742 /* Find regulators set for particular device model */
diff --git a/drivers/regulator/fan53555.c b/drivers/regulator/fan53555.c
index 60f431831582..a3bc8037153e 100644
--- a/drivers/regulator/fan53555.c
+++ b/drivers/regulator/fan53555.c
@@ -407,14 +407,8 @@ static int fan53555_regulator_probe(struct i2c_client *client,
407 407
408 di->regulator = pdata->regulator; 408 di->regulator = pdata->regulator;
409 if (client->dev.of_node) { 409 if (client->dev.of_node) {
410 const struct of_device_id *match; 410 di->vendor =
411 411 (unsigned long)of_device_get_match_data(&client->dev);
412 match = of_match_device(of_match_ptr(fan53555_dt_ids),
413 &client->dev);
414 if (!match)
415 return -ENODEV;
416
417 di->vendor = (unsigned long) match->data;
418 } else { 412 } else {
419 /* if no ramp constraint set, get the pdata ramp_delay */ 413 /* if no ramp constraint set, get the pdata ramp_delay */
420 if (!di->regulator->constraints.ramp_delay) { 414 if (!di->regulator->constraints.ramp_delay) {
@@ -476,7 +470,10 @@ static const struct i2c_device_id fan53555_id[] = {
476 .name = "fan53555", 470 .name = "fan53555",
477 .driver_data = FAN53555_VENDOR_FAIRCHILD 471 .driver_data = FAN53555_VENDOR_FAIRCHILD
478 }, { 472 }, {
479 .name = "syr82x", 473 .name = "syr827",
474 .driver_data = FAN53555_VENDOR_SILERGY
475 }, {
476 .name = "syr828",
480 .driver_data = FAN53555_VENDOR_SILERGY 477 .driver_data = FAN53555_VENDOR_SILERGY
481 }, 478 },
482 { }, 479 { },
diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c
index 853a06ad86d6..18d5b01ddcb2 100644
--- a/drivers/regulator/ltc3589.c
+++ b/drivers/regulator/ltc3589.c
@@ -539,7 +539,7 @@ static int ltc3589_probe(struct i2c_client *client,
539 return 0; 539 return 0;
540} 540}
541 541
542static struct i2c_device_id ltc3589_i2c_id[] = { 542static const struct i2c_device_id ltc3589_i2c_id[] = {
543 { "ltc3589", LTC3589 }, 543 { "ltc3589", LTC3589 },
544 { "ltc3589-1", LTC3589_1 }, 544 { "ltc3589-1", LTC3589_1 },
545 { "ltc3589-2", LTC3589_2 }, 545 { "ltc3589-2", LTC3589_2 },
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c
index 6779c2b53674..66bbaa999433 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -169,7 +169,7 @@ static int of_get_max1586_platform_data(struct device *dev,
169 169
170 if (of_property_read_u32(np, "v3-gain", 170 if (of_property_read_u32(np, "v3-gain",
171 &pdata->v3_gain) < 0) { 171 &pdata->v3_gain) < 0) {
172 dev_err(dev, "%s has no 'v3-gain' property\n", np->full_name); 172 dev_err(dev, "%pOF has no 'v3-gain' property\n", np);
173 return -EINVAL; 173 return -EINVAL;
174 } 174 }
175 175
diff --git a/drivers/regulator/mt6380-regulator.c b/drivers/regulator/mt6380-regulator.c
new file mode 100644
index 000000000000..127dd720cbcc
--- /dev/null
+++ b/drivers/regulator/mt6380-regulator.c
@@ -0,0 +1,352 @@
1/*
2 * Copyright (c) 2017 MediaTek Inc.
3 * Author: Chenglin Xu <chenglin.xu@mediatek.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include <linux/module.h>
16#include <linux/of.h>
17#include <linux/platform_device.h>
18#include <linux/regmap.h>
19#include <linux/regulator/driver.h>
20#include <linux/regulator/machine.h>
21#include <linux/regulator/mt6380-regulator.h>
22#include <linux/regulator/of_regulator.h>
23
24/* PMIC Registers */
25#define MT6380_ALDO_CON_0 0x0000
26#define MT6380_BTLDO_CON_0 0x0004
27#define MT6380_COMP_CON_0 0x0008
28#define MT6380_CPUBUCK_CON_0 0x000C
29#define MT6380_CPUBUCK_CON_1 0x0010
30#define MT6380_CPUBUCK_CON_2 0x0014
31#define MT6380_DDRLDO_CON_0 0x0018
32#define MT6380_MLDO_CON_0 0x001C
33#define MT6380_PALDO_CON_0 0x0020
34#define MT6380_PHYLDO_CON_0 0x0024
35#define MT6380_SIDO_CON_0 0x0028
36#define MT6380_SIDO_CON_1 0x002C
37#define MT6380_SIDO_CON_2 0x0030
38#define MT6380_SLDO_CON_0 0x0034
39#define MT6380_TLDO_CON_0 0x0038
40#define MT6380_STARTUP_CON_0 0x003C
41#define MT6380_STARTUP_CON_1 0x0040
42#define MT6380_SMPS_TOP_CON_0 0x0044
43#define MT6380_SMPS_TOP_CON_1 0x0048
44#define MT6380_ANA_CTRL_0 0x0050
45#define MT6380_ANA_CTRL_1 0x0054
46#define MT6380_ANA_CTRL_2 0x0058
47#define MT6380_ANA_CTRL_3 0x005C
48#define MT6380_ANA_CTRL_4 0x0060
49#define MT6380_SPK_CON9 0x0064
50#define MT6380_SPK_CON11 0x0068
51#define MT6380_SPK_CON12 0x006A
52#define MT6380_CLK_CTRL 0x0070
53#define MT6380_PINMUX_CTRL 0x0074
54#define MT6380_IO_CTRL 0x0078
55#define MT6380_SLP_MODE_CTRL_0 0x007C
56#define MT6380_SLP_MODE_CTRL_1 0x0080
57#define MT6380_SLP_MODE_CTRL_2 0x0084
58#define MT6380_SLP_MODE_CTRL_3 0x0088
59#define MT6380_SLP_MODE_CTRL_4 0x008C
60#define MT6380_SLP_MODE_CTRL_5 0x0090
61#define MT6380_SLP_MODE_CTRL_6 0x0094
62#define MT6380_SLP_MODE_CTRL_7 0x0098
63#define MT6380_SLP_MODE_CTRL_8 0x009C
64#define MT6380_FCAL_CTRL_0 0x00A0
65#define MT6380_FCAL_CTRL_1 0x00A4
66#define MT6380_LDO_CTRL_0 0x00A8
67#define MT6380_LDO_CTRL_1 0x00AC
68#define MT6380_LDO_CTRL_2 0x00B0
69#define MT6380_LDO_CTRL_3 0x00B4
70#define MT6380_LDO_CTRL_4 0x00B8
71#define MT6380_DEBUG_CTRL_0 0x00BC
72#define MT6380_EFU_CTRL_0 0x0200
73#define MT6380_EFU_CTRL_1 0x0201
74#define MT6380_EFU_CTRL_2 0x0202
75#define MT6380_EFU_CTRL_3 0x0203
76#define MT6380_EFU_CTRL_4 0x0204
77#define MT6380_EFU_CTRL_5 0x0205
78#define MT6380_EFU_CTRL_6 0x0206
79#define MT6380_EFU_CTRL_7 0x0207
80#define MT6380_EFU_CTRL_8 0x0208
81
82#define MT6380_REGULATOR_MODE_AUTO 0
83#define MT6380_REGULATOR_MODE_FORCE_PWM 1
84
85/*
86 * mt6380 regulators' information
87 *
88 * @desc: standard fields of regulator description
89 * @vselon_reg: Register sections for hardware control mode of bucks
90 * @modeset_reg: Register for controlling the buck/LDO control mode
91 * @modeset_mask: Mask for controlling the buck/LDO control mode
92 */
93struct mt6380_regulator_info {
94 struct regulator_desc desc;
95 u32 vselon_reg;
96 u32 modeset_reg;
97 u32 modeset_mask;
98};
99
100#define MT6380_BUCK(match, vreg, min, max, step, volt_ranges, enreg, \
101 vosel, vosel_mask, enbit, voselon, _modeset_reg, \
102 _modeset_mask) \
103[MT6380_ID_##vreg] = { \
104 .desc = { \
105 .name = #vreg, \
106 .of_match = of_match_ptr(match), \
107 .ops = &mt6380_volt_range_ops, \
108 .type = REGULATOR_VOLTAGE, \
109 .id = MT6380_ID_##vreg, \
110 .owner = THIS_MODULE, \
111 .n_voltages = ((max) - (min)) / (step) + 1, \
112 .linear_ranges = volt_ranges, \
113 .n_linear_ranges = ARRAY_SIZE(volt_ranges), \
114 .vsel_reg = vosel, \
115 .vsel_mask = vosel_mask, \
116 .enable_reg = enreg, \
117 .enable_mask = BIT(enbit), \
118 }, \
119 .vselon_reg = voselon, \
120 .modeset_reg = _modeset_reg, \
121 .modeset_mask = _modeset_mask, \
122}
123
124#define MT6380_LDO(match, vreg, ldo_volt_table, enreg, enbit, vosel, \
125 vosel_mask, _modeset_reg, _modeset_mask) \
126[MT6380_ID_##vreg] = { \
127 .desc = { \
128 .name = #vreg, \
129 .of_match = of_match_ptr(match), \
130 .ops = &mt6380_volt_table_ops, \
131 .type = REGULATOR_VOLTAGE, \
132 .id = MT6380_ID_##vreg, \
133 .owner = THIS_MODULE, \
134 .n_voltages = ARRAY_SIZE(ldo_volt_table), \
135 .volt_table = ldo_volt_table, \
136 .vsel_reg = vosel, \
137 .vsel_mask = vosel_mask, \
138 .enable_reg = enreg, \
139 .enable_mask = BIT(enbit), \
140 }, \
141 .modeset_reg = _modeset_reg, \
142 .modeset_mask = _modeset_mask, \
143}
144
145#define MT6380_REG_FIXED(match, vreg, enreg, enbit, volt, \
146 _modeset_reg, _modeset_mask) \
147[MT6380_ID_##vreg] = { \
148 .desc = { \
149 .name = #vreg, \
150 .of_match = of_match_ptr(match), \
151 .ops = &mt6380_volt_fixed_ops, \
152 .type = REGULATOR_VOLTAGE, \
153 .id = MT6380_ID_##vreg, \
154 .owner = THIS_MODULE, \
155 .n_voltages = 1, \
156 .enable_reg = enreg, \
157 .enable_mask = BIT(enbit), \
158 .min_uV = volt, \
159 }, \
160 .modeset_reg = _modeset_reg, \
161 .modeset_mask = _modeset_mask, \
162}
163
164static const struct regulator_linear_range buck_volt_range1[] = {
165 REGULATOR_LINEAR_RANGE(600000, 0, 0xfe, 6250),
166};
167
168static const struct regulator_linear_range buck_volt_range2[] = {
169 REGULATOR_LINEAR_RANGE(600000, 0, 0xfe, 6250),
170};
171
172static const struct regulator_linear_range buck_volt_range3[] = {
173 REGULATOR_LINEAR_RANGE(1200000, 0, 0x3c, 25000),
174};
175
176static const u32 ldo_volt_table1[] = {
177 1400000, 1350000, 1300000, 1250000, 1200000, 1150000, 1100000, 1050000,
178};
179
180static const u32 ldo_volt_table2[] = {
181 2200000, 3300000,
182};
183
184static const u32 ldo_volt_table3[] = {
185 1240000, 1390000, 1540000, 1840000,
186};
187
188static const u32 ldo_volt_table4[] = {
189 2200000, 3300000,
190};
191
192static int mt6380_regulator_set_mode(struct regulator_dev *rdev,
193 unsigned int mode)
194{
195 int ret, val = 0;
196 struct mt6380_regulator_info *info = rdev_get_drvdata(rdev);
197
198 switch (mode) {
199 case REGULATOR_MODE_NORMAL:
200 val = MT6380_REGULATOR_MODE_AUTO;
201 break;
202 case REGULATOR_MODE_FAST:
203 val = MT6380_REGULATOR_MODE_FORCE_PWM;
204 break;
205 default:
206 return -EINVAL;
207 }
208
209 val <<= ffs(info->modeset_mask) - 1;
210
211 ret = regmap_update_bits(rdev->regmap, info->modeset_reg,
212 info->modeset_mask, val);
213
214 return ret;
215}
216
217static unsigned int mt6380_regulator_get_mode(struct regulator_dev *rdev)
218{
219 unsigned int val;
220 unsigned int mode;
221 int ret;
222 struct mt6380_regulator_info *info = rdev_get_drvdata(rdev);
223
224 ret = regmap_read(rdev->regmap, info->modeset_reg, &val);
225 if (ret < 0)
226 return ret;
227
228 val &= info->modeset_mask;
229 val >>= ffs(info->modeset_mask) - 1;
230
231 switch (val) {
232 case MT6380_REGULATOR_MODE_AUTO:
233 mode = REGULATOR_MODE_NORMAL;
234 break;
235 case MT6380_REGULATOR_MODE_FORCE_PWM:
236 mode = REGULATOR_MODE_FAST;
237 break;
238 default:
239 return -EINVAL;
240 }
241
242 return mode;
243}
244
245static const struct regulator_ops mt6380_volt_range_ops = {
246 .list_voltage = regulator_list_voltage_linear_range,
247 .map_voltage = regulator_map_voltage_linear_range,
248 .set_voltage_sel = regulator_set_voltage_sel_regmap,
249 .get_voltage_sel = regulator_get_voltage_sel_regmap,
250 .set_voltage_time_sel = regulator_set_voltage_time_sel,
251 .enable = regulator_enable_regmap,
252 .disable = regulator_disable_regmap,
253 .is_enabled = regulator_is_enabled_regmap,
254 .set_mode = mt6380_regulator_set_mode,
255 .get_mode = mt6380_regulator_get_mode,
256};
257
258static const struct regulator_ops mt6380_volt_table_ops = {
259 .list_voltage = regulator_list_voltage_table,
260 .map_voltage = regulator_map_voltage_iterate,
261 .set_voltage_sel = regulator_set_voltage_sel_regmap,
262 .get_voltage_sel = regulator_get_voltage_sel_regmap,
263 .set_voltage_time_sel = regulator_set_voltage_time_sel,
264 .enable = regulator_enable_regmap,
265 .disable = regulator_disable_regmap,
266 .is_enabled = regulator_is_enabled_regmap,
267 .set_mode = mt6380_regulator_set_mode,
268 .get_mode = mt6380_regulator_get_mode,
269};
270
271static const struct regulator_ops mt6380_volt_fixed_ops = {
272 .list_voltage = regulator_list_voltage_linear,
273 .enable = regulator_enable_regmap,
274 .disable = regulator_disable_regmap,
275 .is_enabled = regulator_is_enabled_regmap,
276 .set_mode = mt6380_regulator_set_mode,
277 .get_mode = mt6380_regulator_get_mode,
278};
279
280/* The array is indexed by id(MT6380_ID_XXX) */
281static struct mt6380_regulator_info mt6380_regulators[] = {
282 MT6380_BUCK("buck-vcore1", VCPU, 600000, 1393750, 6250,
283 buck_volt_range1, MT6380_ANA_CTRL_3, MT6380_ANA_CTRL_1,
284 0xfe, 3, MT6380_ANA_CTRL_1,
285 MT6380_CPUBUCK_CON_0, 0x8000000),
286 MT6380_BUCK("buck-vcore", VCORE, 600000, 1393750, 6250,
287 buck_volt_range2, MT6380_ANA_CTRL_3, MT6380_ANA_CTRL_2,
288 0xfe, 2, MT6380_ANA_CTRL_2, MT6380_SIDO_CON_0, 0x1000000),
289 MT6380_BUCK("buck-vrf", VRF, 1200000, 1575000, 25000,
290 buck_volt_range3, MT6380_ANA_CTRL_3, MT6380_SIDO_CON_0,
291 0x78, 1, MT6380_SIDO_CON_0, MT6380_SIDO_CON_0, 0x8000),
292 MT6380_LDO("ldo-vm", VMLDO, ldo_volt_table1, MT6380_LDO_CTRL_0,
293 1, MT6380_MLDO_CON_0, 0xE000, MT6380_ANA_CTRL_1, 0x4000000),
294 MT6380_LDO("ldo-va", VALDO, ldo_volt_table2, MT6380_LDO_CTRL_0,
295 2, MT6380_ALDO_CON_0, 0x400, MT6380_ALDO_CON_0, 0x20),
296 MT6380_REG_FIXED("ldo-vphy", VPHYLDO, MT6380_LDO_CTRL_0, 7, 1800000,
297 MT6380_PHYLDO_CON_0, 0x80),
298 MT6380_LDO("ldo-vddr", VDDRLDO, ldo_volt_table3, MT6380_LDO_CTRL_0,
299 8, MT6380_DDRLDO_CON_0, 0x3000, MT6380_DDRLDO_CON_0, 0x80),
300 MT6380_LDO("ldo-vt", VTLDO, ldo_volt_table4, MT6380_LDO_CTRL_0, 3,
301 MT6380_TLDO_CON_0, 0x400, MT6380_TLDO_CON_0, 0x20),
302};
303
304static int mt6380_regulator_probe(struct platform_device *pdev)
305{
306 struct regmap *regmap = dev_get_regmap(pdev->dev.parent, NULL);
307 struct regulator_config config = {};
308 struct regulator_dev *rdev;
309 int i;
310
311 for (i = 0; i < MT6380_MAX_REGULATOR; i++) {
312 config.dev = &pdev->dev;
313 config.driver_data = &mt6380_regulators[i];
314 config.regmap = regmap;
315 rdev = devm_regulator_register(&pdev->dev,
316 &mt6380_regulators[i].desc,
317 &config);
318 if (IS_ERR(rdev)) {
319 dev_err(&pdev->dev, "failed to register %s\n",
320 mt6380_regulators[i].desc.name);
321 return PTR_ERR(rdev);
322 }
323 }
324 return 0;
325}
326
327static const struct platform_device_id mt6380_platform_ids[] = {
328 {"mt6380-regulator", 0},
329 { /* sentinel */ },
330};
331MODULE_DEVICE_TABLE(platform, mt6380_platform_ids);
332
333static const struct of_device_id mt6380_of_match[] = {
334 { .compatible = "mediatek,mt6380-regulator", },
335 { /* sentinel */ },
336};
337MODULE_DEVICE_TABLE(of, mt6380_of_match);
338
339static struct platform_driver mt6380_regulator_driver = {
340 .driver = {
341 .name = "mt6380-regulator",
342 .of_match_table = of_match_ptr(mt6380_of_match),
343 },
344 .probe = mt6380_regulator_probe,
345 .id_table = mt6380_platform_ids,
346};
347
348module_platform_driver(mt6380_regulator_driver);
349
350MODULE_AUTHOR("Chenglin Xu <chenglin.xu@mediatek.com>");
351MODULE_DESCRIPTION("Regulator Driver for MediaTek MT6380 PMIC");
352MODULE_LICENSE("GPL v2");
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index 96bf75458da5..9dd44dd4cdf6 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -333,7 +333,7 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
333 search = of_get_child_by_name(dev->of_node, 333 search = of_get_child_by_name(dev->of_node,
334 desc->regulators_node); 334 desc->regulators_node);
335 else 335 else
336 search = dev->of_node; 336 search = of_node_get(dev->of_node);
337 337
338 if (!search) { 338 if (!search) {
339 dev_dbg(dev, "Failed to find regulator container node '%s'\n", 339 dev_dbg(dev, "Failed to find regulator container node '%s'\n",
diff --git a/drivers/regulator/pv88090-regulator.c b/drivers/regulator/pv88090-regulator.c
index ab51e254d13a..7a0c15957bd0 100644
--- a/drivers/regulator/pv88090-regulator.c
+++ b/drivers/regulator/pv88090-regulator.c
@@ -43,7 +43,7 @@ enum {
43struct pv88090_regulator { 43struct pv88090_regulator {
44 struct regulator_desc desc; 44 struct regulator_desc desc;
45 /* Current limiting */ 45 /* Current limiting */
46 unsigned n_current_limits; 46 unsigned int n_current_limits;
47 const int *current_limits; 47 const int *current_limits;
48 unsigned int limit_mask; 48 unsigned int limit_mask;
49 unsigned int conf; 49 unsigned int conf;
@@ -398,9 +398,14 @@ static int pv88090_i2c_probe(struct i2c_client *i2c,
398 return ret; 398 return ret;
399 399
400 range = (range >> 400 range = (range >>
401 (PV88080_BUCK_VRANGE_GAIN_SHIFT + i - 1)) & 401 (PV88090_BUCK_VRANGE_GAIN_SHIFT + i - 1)) &
402 PV88080_BUCK_VRANGE_GAIN_MASK; 402 PV88090_BUCK_VRANGE_GAIN_MASK;
403 index = ((range << 1) | conf2); 403 index = ((range << 1) | conf2);
404 if (index > PV88090_ID_BUCK3) {
405 dev_err(chip->dev,
406 "Invalid index(%d)\n", index);
407 return -EINVAL;
408 }
404 409
405 pv88090_regulator_info[i].desc.min_uV 410 pv88090_regulator_info[i].desc.min_uV
406 = pv88090_buck_vol[index].min_uV; 411 = pv88090_buck_vol[index].min_uV;
diff --git a/drivers/regulator/pv88090-regulator.h b/drivers/regulator/pv88090-regulator.h
index d7aca8d8266d..62d9029277f4 100644
--- a/drivers/regulator/pv88090-regulator.h
+++ b/drivers/regulator/pv88090-regulator.h
@@ -89,10 +89,10 @@
89#define PV88090_BUCK_VDAC_RANGE_2 0x01 89#define PV88090_BUCK_VDAC_RANGE_2 0x01
90 90
91/* PV88090_REG_BUCK_FOLD_RANGE (addr=0x61) */ 91/* PV88090_REG_BUCK_FOLD_RANGE (addr=0x61) */
92#define PV88080_BUCK_VRANGE_GAIN_SHIFT 3 92#define PV88090_BUCK_VRANGE_GAIN_SHIFT 3
93#define PV88080_BUCK_VRANGE_GAIN_MASK 0x01 93#define PV88090_BUCK_VRANGE_GAIN_MASK 0x01
94 94
95#define PV88080_BUCK_VRANGE_GAIN_1 0x00 95#define PV88090_BUCK_VRANGE_GAIN_1 0x00
96#define PV88080_BUCK_VRANGE_GAIN_2 0x01 96#define PV88090_BUCK_VRANGE_GAIN_2 0x01
97 97
98#endif /* __PV88090_REGISTERS_H__ */ 98#endif /* __PV88090_REGISTERS_H__ */
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c
index 1b88e0e15a70..a2fd140eff81 100644
--- a/drivers/regulator/pwm-regulator.c
+++ b/drivers/regulator/pwm-regulator.c
@@ -122,8 +122,7 @@ static int pwm_regulator_enable(struct regulator_dev *dev)
122{ 122{
123 struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev); 123 struct pwm_regulator_data *drvdata = rdev_get_drvdata(dev);
124 124
125 if (drvdata->enb_gpio) 125 gpiod_set_value_cansleep(drvdata->enb_gpio, 1);
126 gpiod_set_value_cansleep(drvdata->enb_gpio, 1);
127 126
128 return pwm_enable(drvdata->pwm); 127 return pwm_enable(drvdata->pwm);
129} 128}
@@ -134,8 +133,7 @@ static int pwm_regulator_disable(struct regulator_dev *dev)
134 133
135 pwm_disable(drvdata->pwm); 134 pwm_disable(drvdata->pwm);
136 135
137 if (drvdata->enb_gpio) 136 gpiod_set_value_cansleep(drvdata->enb_gpio, 0);
138 gpiod_set_value_cansleep(drvdata->enb_gpio, 0);
139 137
140 return 0; 138 return 0;
141} 139}
diff --git a/drivers/regulator/qcom_rpm-regulator.c b/drivers/regulator/qcom_rpm-regulator.c
index 1b2acc43fea1..88dc0b0f003c 100644
--- a/drivers/regulator/qcom_rpm-regulator.c
+++ b/drivers/regulator/qcom_rpm-regulator.c
@@ -959,6 +959,11 @@ static int rpm_reg_probe(struct platform_device *pdev)
959 } 959 }
960 960
961 match = of_match_device(rpm_of_match, &pdev->dev); 961 match = of_match_device(rpm_of_match, &pdev->dev);
962 if (!match) {
963 dev_err(&pdev->dev, "failed to match device\n");
964 return -ENODEV;
965 }
966
962 for (reg = match->data; reg->name; reg++) { 967 for (reg = match->data; reg->name; reg++) {
963 vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); 968 vreg = devm_kmalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
964 if (!vreg) 969 if (!vreg)
diff --git a/drivers/regulator/qcom_smd-regulator.c b/drivers/regulator/qcom_smd-regulator.c
index f35994a2a5be..940fe1b78411 100644
--- a/drivers/regulator/qcom_smd-regulator.c
+++ b/drivers/regulator/qcom_smd-regulator.c
@@ -570,6 +570,11 @@ static int rpm_reg_probe(struct platform_device *pdev)
570 } 570 }
571 571
572 match = of_match_device(rpm_of_match, &pdev->dev); 572 match = of_match_device(rpm_of_match, &pdev->dev);
573 if (!match) {
574 dev_err(&pdev->dev, "failed to match device\n");
575 return -ENODEV;
576 }
577
573 for (reg = match->data; reg->name; reg++) { 578 for (reg = match->data; reg->name; reg++) {
574 vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL); 579 vreg = devm_kzalloc(&pdev->dev, sizeof(*vreg), GFP_KERNEL);
575 if (!vreg) 580 if (!vreg)
diff --git a/drivers/regulator/rn5t618-regulator.c b/drivers/regulator/rn5t618-regulator.c
index 8d2819e36654..ef2be56460fe 100644
--- a/drivers/regulator/rn5t618-regulator.c
+++ b/drivers/regulator/rn5t618-regulator.c
@@ -79,6 +79,29 @@ static struct regulator_desc rn5t618_regulators[] = {
79 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000), 79 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
80}; 80};
81 81
82static struct regulator_desc rc5t619_regulators[] = {
83 /* DCDC */
84 REG(DCDC1, DC1CTL, BIT(0), DC1DAC, 0xff, 600000, 3500000, 12500),
85 REG(DCDC2, DC2CTL, BIT(0), DC2DAC, 0xff, 600000, 3500000, 12500),
86 REG(DCDC3, DC3CTL, BIT(0), DC3DAC, 0xff, 600000, 3500000, 12500),
87 REG(DCDC4, DC4CTL, BIT(0), DC4DAC, 0xff, 600000, 3500000, 12500),
88 REG(DCDC5, DC5CTL, BIT(0), DC5DAC, 0xff, 600000, 3500000, 12500),
89 /* LDO */
90 REG(LDO1, LDOEN1, BIT(0), LDO1DAC, 0x7f, 900000, 3500000, 25000),
91 REG(LDO2, LDOEN1, BIT(1), LDO2DAC, 0x7f, 900000, 3500000, 25000),
92 REG(LDO3, LDOEN1, BIT(2), LDO3DAC, 0x7f, 900000, 3500000, 25000),
93 REG(LDO4, LDOEN1, BIT(3), LDO4DAC, 0x7f, 900000, 3500000, 25000),
94 REG(LDO5, LDOEN1, BIT(4), LDO5DAC, 0x7f, 600000, 3500000, 25000),
95 REG(LDO6, LDOEN1, BIT(5), LDO6DAC, 0x7f, 600000, 3500000, 25000),
96 REG(LDO7, LDOEN1, BIT(6), LDO7DAC, 0x7f, 900000, 3500000, 25000),
97 REG(LDO8, LDOEN1, BIT(7), LDO8DAC, 0x7f, 900000, 3500000, 25000),
98 REG(LDO9, LDOEN2, BIT(0), LDO9DAC, 0x7f, 900000, 3500000, 25000),
99 REG(LDO10, LDOEN2, BIT(0), LDO10DAC, 0x7f, 900000, 3500000, 25000),
100 /* LDO RTC */
101 REG(LDORTC1, LDOEN2, BIT(4), LDORTCDAC, 0x7f, 1700000, 3500000, 25000),
102 REG(LDORTC2, LDOEN2, BIT(5), LDORTC2DAC, 0x7f, 900000, 3500000, 25000),
103};
104
82static int rn5t618_regulator_probe(struct platform_device *pdev) 105static int rn5t618_regulator_probe(struct platform_device *pdev)
83{ 106{
84 struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent); 107 struct rn5t618 *rn5t618 = dev_get_drvdata(pdev->dev.parent);
@@ -86,13 +109,20 @@ static int rn5t618_regulator_probe(struct platform_device *pdev)
86 struct regulator_dev *rdev; 109 struct regulator_dev *rdev;
87 struct regulator_desc *regulators; 110 struct regulator_desc *regulators;
88 int i; 111 int i;
112 int num_regulators = 0;
89 113
90 switch (rn5t618->variant) { 114 switch (rn5t618->variant) {
91 case RN5T567: 115 case RN5T567:
92 regulators = rn5t567_regulators; 116 regulators = rn5t567_regulators;
117 num_regulators = ARRAY_SIZE(rn5t567_regulators);
93 break; 118 break;
94 case RN5T618: 119 case RN5T618:
95 regulators = rn5t618_regulators; 120 regulators = rn5t618_regulators;
121 num_regulators = ARRAY_SIZE(rn5t618_regulators);
122 break;
123 case RC5T619:
124 regulators = rc5t619_regulators;
125 num_regulators = ARRAY_SIZE(rc5t619_regulators);
96 break; 126 break;
97 default: 127 default:
98 return -EINVAL; 128 return -EINVAL;
@@ -101,10 +131,7 @@ static int rn5t618_regulator_probe(struct platform_device *pdev)
101 config.dev = pdev->dev.parent; 131 config.dev = pdev->dev.parent;
102 config.regmap = rn5t618->regmap; 132 config.regmap = rn5t618->regmap;
103 133
104 for (i = 0; i < RN5T618_REG_NUM; i++) { 134 for (i = 0; i < num_regulators; i++) {
105 if (!regulators[i].name)
106 continue;
107
108 rdev = devm_regulator_register(&pdev->dev, 135 rdev = devm_regulator_register(&pdev->dev,
109 &regulators[i], 136 &regulators[i],
110 &config); 137 &config);
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c
index 383cd7533721..4836947e1521 100644
--- a/drivers/regulator/s5m8767.c
+++ b/drivers/regulator/s5m8767.c
@@ -590,8 +590,8 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
590 if (of_property_read_u32(reg_np, "op_mode", 590 if (of_property_read_u32(reg_np, "op_mode",
591 &rmode->mode)) { 591 &rmode->mode)) {
592 dev_warn(iodev->dev, 592 dev_warn(iodev->dev,
593 "no op_mode property property at %s\n", 593 "no op_mode property property at %pOF\n",
594 reg_np->full_name); 594 reg_np);
595 595
596 rmode->mode = S5M8767_OPMODE_NORMAL_MODE; 596 rmode->mode = S5M8767_OPMODE_NORMAL_MODE;
597 } 597 }
diff --git a/drivers/regulator/stm32-vrefbuf.c b/drivers/regulator/stm32-vrefbuf.c
new file mode 100644
index 000000000000..72c8b3e1022b
--- /dev/null
+++ b/drivers/regulator/stm32-vrefbuf.c
@@ -0,0 +1,202 @@
1/*
2 * Copyright (C) STMicroelectronics 2017
3 *
4 * Author: Fabrice Gasnier <fabrice.gasnier@st.com>
5 *
6 * License terms: GNU General Public License (GPL), version 2
7 */
8
9#include <linux/bitfield.h>
10#include <linux/clk.h>
11#include <linux/io.h>
12#include <linux/iopoll.h>
13#include <linux/module.h>
14#include <linux/of_device.h>
15#include <linux/platform_device.h>
16#include <linux/regulator/driver.h>
17#include <linux/regulator/of_regulator.h>
18
19/* STM32 VREFBUF registers */
20#define STM32_VREFBUF_CSR 0x00
21
22/* STM32 VREFBUF CSR bitfields */
23#define STM32_VRS GENMASK(6, 4)
24#define STM32_VRR BIT(3)
25#define STM32_HIZ BIT(1)
26#define STM32_ENVR BIT(0)
27
28struct stm32_vrefbuf {
29 void __iomem *base;
30 struct clk *clk;
31};
32
33static const unsigned int stm32_vrefbuf_voltages[] = {
34 /* Matches resp. VRS = 000b, 001b, 010b, 011b */
35 2500000, 2048000, 1800000, 1500000,
36};
37
38static int stm32_vrefbuf_enable(struct regulator_dev *rdev)
39{
40 struct stm32_vrefbuf *priv = rdev_get_drvdata(rdev);
41 u32 val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
42 int ret;
43
44 val = (val & ~STM32_HIZ) | STM32_ENVR;
45 writel_relaxed(val, priv->base + STM32_VREFBUF_CSR);
46
47 /*
48 * Vrefbuf startup time depends on external capacitor: wait here for
49 * VRR to be set. That means output has reached expected value.
50 * ~650us sleep should be enough for caps up to 1.5uF. Use 10ms as
51 * arbitrary timeout.
52 */
53 ret = readl_poll_timeout(priv->base + STM32_VREFBUF_CSR, val,
54 !(val & STM32_VRR), 650, 10000);
55 if (ret) {
56 dev_err(&rdev->dev, "stm32 vrefbuf timed out!\n");
57 val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
58 val = (val & ~STM32_ENVR) | STM32_HIZ;
59 writel_relaxed(val, priv->base + STM32_VREFBUF_CSR);
60 }
61
62 return ret;
63}
64
65static int stm32_vrefbuf_disable(struct regulator_dev *rdev)
66{
67 struct stm32_vrefbuf *priv = rdev_get_drvdata(rdev);
68 u32 val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
69
70 val = (val & ~STM32_ENVR) | STM32_HIZ;
71 writel_relaxed(val, priv->base + STM32_VREFBUF_CSR);
72
73 return 0;
74}
75
76static int stm32_vrefbuf_is_enabled(struct regulator_dev *rdev)
77{
78 struct stm32_vrefbuf *priv = rdev_get_drvdata(rdev);
79
80 return readl_relaxed(priv->base + STM32_VREFBUF_CSR) & STM32_ENVR;
81}
82
83static int stm32_vrefbuf_set_voltage_sel(struct regulator_dev *rdev,
84 unsigned sel)
85{
86 struct stm32_vrefbuf *priv = rdev_get_drvdata(rdev);
87 u32 val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
88
89 val = (val & ~STM32_VRS) | FIELD_PREP(STM32_VRS, sel);
90 writel_relaxed(val, priv->base + STM32_VREFBUF_CSR);
91
92 return 0;
93}
94
95static int stm32_vrefbuf_get_voltage_sel(struct regulator_dev *rdev)
96{
97 struct stm32_vrefbuf *priv = rdev_get_drvdata(rdev);
98 u32 val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
99
100 return FIELD_GET(STM32_VRS, val);
101}
102
103static const struct regulator_ops stm32_vrefbuf_volt_ops = {
104 .enable = stm32_vrefbuf_enable,
105 .disable = stm32_vrefbuf_disable,
106 .is_enabled = stm32_vrefbuf_is_enabled,
107 .get_voltage_sel = stm32_vrefbuf_get_voltage_sel,
108 .set_voltage_sel = stm32_vrefbuf_set_voltage_sel,
109 .list_voltage = regulator_list_voltage_table,
110};
111
112static const struct regulator_desc stm32_vrefbuf_regu = {
113 .name = "vref",
114 .supply_name = "vdda",
115 .volt_table = stm32_vrefbuf_voltages,
116 .n_voltages = ARRAY_SIZE(stm32_vrefbuf_voltages),
117 .ops = &stm32_vrefbuf_volt_ops,
118 .type = REGULATOR_VOLTAGE,
119 .owner = THIS_MODULE,
120};
121
122static int stm32_vrefbuf_probe(struct platform_device *pdev)
123{
124 struct resource *res;
125 struct stm32_vrefbuf *priv;
126 struct regulator_config config = { };
127 struct regulator_dev *rdev;
128 int ret;
129
130 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
131 if (!priv)
132 return -ENOMEM;
133
134 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
135 priv->base = devm_ioremap_resource(&pdev->dev, res);
136 if (IS_ERR(priv->base))
137 return PTR_ERR(priv->base);
138
139 priv->clk = devm_clk_get(&pdev->dev, NULL);
140 if (IS_ERR(priv->clk))
141 return PTR_ERR(priv->clk);
142
143 ret = clk_prepare_enable(priv->clk);
144 if (ret) {
145 dev_err(&pdev->dev, "clk prepare failed with error %d\n", ret);
146 return ret;
147 }
148
149 config.dev = &pdev->dev;
150 config.driver_data = priv;
151 config.of_node = pdev->dev.of_node;
152 config.init_data = of_get_regulator_init_data(&pdev->dev,
153 pdev->dev.of_node,
154 &stm32_vrefbuf_regu);
155
156 rdev = regulator_register(&stm32_vrefbuf_regu, &config);
157 if (IS_ERR(rdev)) {
158 ret = PTR_ERR(rdev);
159 dev_err(&pdev->dev, "register failed with error %d\n", ret);
160 goto err_clk_dis;
161 }
162 platform_set_drvdata(pdev, rdev);
163
164 return 0;
165
166err_clk_dis:
167 clk_disable_unprepare(priv->clk);
168
169 return ret;
170}
171
172static int stm32_vrefbuf_remove(struct platform_device *pdev)
173{
174 struct regulator_dev *rdev = platform_get_drvdata(pdev);
175 struct stm32_vrefbuf *priv = rdev_get_drvdata(rdev);
176
177 regulator_unregister(rdev);
178 clk_disable_unprepare(priv->clk);
179
180 return 0;
181};
182
183static const struct of_device_id stm32_vrefbuf_of_match[] = {
184 { .compatible = "st,stm32-vrefbuf", },
185 {},
186};
187MODULE_DEVICE_TABLE(of, stm32_vrefbuf_of_match);
188
189static struct platform_driver stm32_vrefbuf_driver = {
190 .probe = stm32_vrefbuf_probe,
191 .remove = stm32_vrefbuf_remove,
192 .driver = {
193 .name = "stm32-vrefbuf",
194 .of_match_table = of_match_ptr(stm32_vrefbuf_of_match),
195 },
196};
197module_platform_driver(stm32_vrefbuf_driver);
198
199MODULE_LICENSE("GPL v2");
200MODULE_AUTHOR("Fabrice Gasnier <fabrice.gasnier@st.com>");
201MODULE_DESCRIPTION("STMicroelectronics STM32 VREFBUF driver");
202MODULE_ALIAS("platform:stm32-vrefbuf");
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 07224c019892..c60904ff40b8 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -109,8 +109,8 @@ static int socfpga_reset_probe(struct platform_device *pdev)
109 * Do not continue, when we encounter an old DT. 109 * Do not continue, when we encounter an old DT.
110 */ 110 */
111 if (!of_find_property(pdev->dev.of_node, "#reset-cells", NULL)) { 111 if (!of_find_property(pdev->dev.of_node, "#reset-cells", NULL)) {
112 dev_err(&pdev->dev, "%s missing #reset-cells property\n", 112 dev_err(&pdev->dev, "%pOF missing #reset-cells property\n",
113 pdev->dev.of_node->full_name); 113 pdev->dev.of_node);
114 return -EINVAL; 114 return -EINVAL;
115 } 115 }
116 116
diff --git a/include/linux/mfd/rn5t618.h b/include/linux/mfd/rn5t618.h
index e5a6cdeb77db..d61bc58aba8a 100644
--- a/include/linux/mfd/rn5t618.h
+++ b/include/linux/mfd/rn5t618.h
@@ -226,11 +226,17 @@ enum {
226 RN5T618_DCDC2, 226 RN5T618_DCDC2,
227 RN5T618_DCDC3, 227 RN5T618_DCDC3,
228 RN5T618_DCDC4, 228 RN5T618_DCDC4,
229 RN5T618_DCDC5,
229 RN5T618_LDO1, 230 RN5T618_LDO1,
230 RN5T618_LDO2, 231 RN5T618_LDO2,
231 RN5T618_LDO3, 232 RN5T618_LDO3,
232 RN5T618_LDO4, 233 RN5T618_LDO4,
233 RN5T618_LDO5, 234 RN5T618_LDO5,
235 RN5T618_LDO6,
236 RN5T618_LDO7,
237 RN5T618_LDO8,
238 RN5T618_LDO9,
239 RN5T618_LDO10,
234 RN5T618_LDORTC1, 240 RN5T618_LDORTC1,
235 RN5T618_LDORTC2, 241 RN5T618_LDORTC2,
236 RN5T618_REG_NUM, 242 RN5T618_REG_NUM,
diff --git a/include/linux/regulator/mt6380-regulator.h b/include/linux/regulator/mt6380-regulator.h
new file mode 100644
index 000000000000..465182da6315
--- /dev/null
+++ b/include/linux/regulator/mt6380-regulator.h
@@ -0,0 +1,32 @@
1/*
2 * Copyright (c) 2017 MediaTek Inc.
3 * Author: Chenglin Xu <chenglin.xu@mediatek.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#ifndef __LINUX_REGULATOR_mt6380_H
16#define __LINUX_REGULATOR_mt6380_H
17
18enum {
19 MT6380_ID_VCPU = 0,
20 MT6380_ID_VCORE,
21 MT6380_ID_VRF,
22 MT6380_ID_VMLDO,
23 MT6380_ID_VALDO,
24 MT6380_ID_VPHYLDO,
25 MT6380_ID_VDDRLDO,
26 MT6380_ID_VTLDO,
27 MT6380_ID_RG_MAX,
28};
29
30#define MT6380_MAX_REGULATOR MT6380_ID_RG_MAX
31
32#endif /* __LINUX_REGULATOR_mt6380_H */