diff options
29 files changed, 510 insertions, 65 deletions
diff --git a/Documentation/devicetree/bindings/regulator/mt6311-regulator.txt b/Documentation/devicetree/bindings/regulator/mt6311-regulator.txt new file mode 100644 index 000000000000..02649d8b3f5a --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/mt6311-regulator.txt | |||
@@ -0,0 +1,35 @@ | |||
1 | Mediatek MT6311 Regulator Driver | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: "mediatek,mt6311-regulator" | ||
5 | - reg: I2C slave address, usually 0x6b. | ||
6 | - regulators: List of regulators provided by this controller. It is named | ||
7 | to VDVFS and VBIASN. | ||
8 | The definition for each of these nodes is defined using the standard binding | ||
9 | for regulators at Documentation/devicetree/bindings/regulator/regulator.txt. | ||
10 | |||
11 | The valid names for regulators are: | ||
12 | BUCK: | ||
13 | VDVFS | ||
14 | LDO: | ||
15 | VBIASN | ||
16 | |||
17 | Example: | ||
18 | mt6311: pmic@6b { | ||
19 | compatible = "mediatek,mt6311-regulator"; | ||
20 | reg = <0x6b>; | ||
21 | |||
22 | regulators { | ||
23 | mt6311_vcpu_reg: VDVFS { | ||
24 | regulator-name = "VDVFS"; | ||
25 | regulator-min-microvolt = < 600000>; | ||
26 | regulator-max-microvolt = <1400000>; | ||
27 | regulator-ramp-delay = <10000>; | ||
28 | }; | ||
29 | mt6311_ldo_reg: VBIASN { | ||
30 | regulator-name = "VBIASN"; | ||
31 | regulator-min-microvolt = <200000>; | ||
32 | regulator-max-microvolt = <800000>; | ||
33 | }; | ||
34 | }; | ||
35 | }; | ||
diff --git a/Documentation/devicetree/bindings/regulator/pwm-regulator.txt b/Documentation/devicetree/bindings/regulator/pwm-regulator.txt index ce91f61feb12..ed936f0f34f2 100644 --- a/Documentation/devicetree/bindings/regulator/pwm-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/pwm-regulator.txt | |||
@@ -1,27 +1,68 @@ | |||
1 | pwm regulator bindings | 1 | Bindings for the Generic PWM Regulator |
2 | ====================================== | ||
3 | |||
4 | Currently supports 2 modes of operation: | ||
5 | |||
6 | Voltage Table: When in this mode, a voltage table (See below) of | ||
7 | predefined voltage <=> duty-cycle values must be | ||
8 | provided via DT. Limitations are that the regulator can | ||
9 | only operate at the voltages supplied in the table. | ||
10 | Intermediary duty-cycle values which would normally | ||
11 | allow finer grained voltage selection are ignored and | ||
12 | rendered useless. Although more control is given to | ||
13 | the user if the assumptions made in continuous-voltage | ||
14 | mode do not reign true. | ||
15 | |||
16 | Continuous Voltage: This mode uses the regulator's maximum and minimum | ||
17 | supplied voltages specified in the | ||
18 | regulator-{min,max}-microvolt properties to calculate | ||
19 | appropriate duty-cycle values. This allows for a much | ||
20 | more fine grained solution when compared with | ||
21 | voltage-table mode above. This solution does make an | ||
22 | assumption that a %50 duty-cycle value will cause the | ||
23 | regulator voltage to run at half way between the | ||
24 | supplied max_uV and min_uV values. | ||
2 | 25 | ||
3 | Required properties: | 26 | Required properties: |
4 | - compatible: Should be "pwm-regulator" | 27 | -------------------- |
5 | - pwms: OF device-tree PWM specification (see PWM binding pwm.txt) | 28 | - compatible: Should be "pwm-regulator" |
6 | - voltage-table: voltage and duty table, include 2 members in each set of | 29 | |
7 | brackets, first one is voltage(unit: uv), the next is duty(unit: percent) | 30 | - pwms: PWM specification (See: ../pwm/pwm.txt) |
31 | |||
32 | Only required for Voltage Table Mode: | ||
33 | - voltage-table: Voltage and Duty-Cycle table consisting of 2 cells | ||
34 | First cell is voltage in microvolts (uV) | ||
35 | Second cell is duty-cycle in percent (%) | ||
36 | |||
37 | NB: To be clear, if voltage-table is provided, then the device will be used | ||
38 | in Voltage Table Mode. If no voltage-table is provided, then the device will | ||
39 | be used in Continuous Voltage Mode. | ||
8 | 40 | ||
9 | Any property defined as part of the core regulator binding defined in | 41 | Any property defined as part of the core regulator binding can also be used. |
10 | regulator.txt can also be used. | 42 | (See: ../regulator/regulator.txt) |
11 | 43 | ||
12 | Example: | 44 | Continuous Voltage Example: |
13 | pwm_regulator { | 45 | pwm_regulator { |
14 | compatible = "pwm-regulator; | 46 | compatible = "pwm-regulator; |
15 | pwms = <&pwm1 0 8448 0>; | 47 | pwms = <&pwm1 0 8448 0>; |
48 | regulator-min-microvolt = <1016000>; | ||
49 | regulator-max-microvolt = <1114000>; | ||
50 | regulator-name = "vdd_logic"; | ||
51 | }; | ||
16 | 52 | ||
53 | Voltage Table Example: | ||
54 | pwm_regulator { | ||
55 | compatible = "pwm-regulator; | ||
56 | pwms = <&pwm1 0 8448 0>; | ||
57 | regulator-min-microvolt = <1016000>; | ||
58 | regulator-max-microvolt = <1114000>; | ||
59 | regulator-name = "vdd_logic"; | ||
60 | |||
61 | /* Voltage Duty-Cycle */ | ||
17 | voltage-table = <1114000 0>, | 62 | voltage-table = <1114000 0>, |
18 | <1095000 10>, | 63 | <1095000 10>, |
19 | <1076000 20>, | 64 | <1076000 20>, |
20 | <1056000 30>, | 65 | <1056000 30>, |
21 | <1036000 40>, | 66 | <1036000 40>, |
22 | <1016000 50>; | 67 | <1016000 50>; |
23 | |||
24 | regulator-min-microvolt = <1016000>; | ||
25 | regulator-max-microvolt = <1114000>; | ||
26 | regulator-name = "vdd_logic"; | ||
27 | }; | 68 | }; |
diff --git a/Documentation/devicetree/bindings/regulator/regulator.txt b/Documentation/devicetree/bindings/regulator/regulator.txt index db88feb28c03..24bd422cecd5 100644 --- a/Documentation/devicetree/bindings/regulator/regulator.txt +++ b/Documentation/devicetree/bindings/regulator/regulator.txt | |||
@@ -42,6 +42,7 @@ Optional properties: | |||
42 | - regulator-system-load: Load in uA present on regulator that is not captured by | 42 | - regulator-system-load: Load in uA present on regulator that is not captured by |
43 | any consumer request. | 43 | any consumer request. |
44 | - regulator-pull-down: Enable pull down resistor when the regulator is disabled. | 44 | - regulator-pull-down: Enable pull down resistor when the regulator is disabled. |
45 | - regulator-over-current-protection: Enable over current protection. | ||
45 | 46 | ||
46 | Deprecated properties: | 47 | Deprecated properties: |
47 | - regulator-compatible: If a regulator chip contains multiple | 48 | - regulator-compatible: If a regulator chip contains multiple |
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index a7b81f0185b5..f3cdf7a4e487 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -443,6 +443,15 @@ config REGULATOR_MC13892 | |||
443 | Say y here to support the regulators found on the Freescale MC13892 | 443 | Say y here to support the regulators found on the Freescale MC13892 |
444 | PMIC. | 444 | PMIC. |
445 | 445 | ||
446 | config REGULATOR_MT6311 | ||
447 | tristate "MediaTek MT6311 PMIC" | ||
448 | depends on I2C | ||
449 | help | ||
450 | Say y here to select this option to enable the power regulator of | ||
451 | MediaTek MT6311 PMIC. | ||
452 | This driver supports the control of different power rails of device | ||
453 | through regulator interface. | ||
454 | |||
446 | config REGULATOR_MT6397 | 455 | config REGULATOR_MT6397 |
447 | tristate "MediaTek MT6397 PMIC" | 456 | tristate "MediaTek MT6397 PMIC" |
448 | depends on MFD_MT6397 | 457 | depends on MFD_MT6397 |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 6429e629dcb6..8bc702910320 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
@@ -59,6 +59,7 @@ obj-$(CONFIG_REGULATOR_MAX77802) += max77802.o | |||
59 | obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o | 59 | obj-$(CONFIG_REGULATOR_MC13783) += mc13783-regulator.o |
60 | obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o | 60 | obj-$(CONFIG_REGULATOR_MC13892) += mc13892-regulator.o |
61 | obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o | 61 | obj-$(CONFIG_REGULATOR_MC13XXX_CORE) += mc13xxx-regulator-core.o |
62 | obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o | ||
62 | obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o | 63 | obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o |
63 | obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o | 64 | obj-$(CONFIG_REGULATOR_QCOM_RPM) += qcom_rpm-regulator.o |
64 | obj-$(CONFIG_REGULATOR_QCOM_SPMI) += qcom_spmi-regulator.o | 65 | obj-$(CONFIG_REGULATOR_QCOM_SPMI) += qcom_spmi-regulator.o |
diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c index 2ff73d72ca34..896db168e4bd 100644 --- a/drivers/regulator/act8865-regulator.c +++ b/drivers/regulator/act8865-regulator.c | |||
@@ -530,7 +530,6 @@ MODULE_DEVICE_TABLE(i2c, act8865_ids); | |||
530 | static struct i2c_driver act8865_pmic_driver = { | 530 | static struct i2c_driver act8865_pmic_driver = { |
531 | .driver = { | 531 | .driver = { |
532 | .name = "act8865", | 532 | .name = "act8865", |
533 | .owner = THIS_MODULE, | ||
534 | }, | 533 | }, |
535 | .probe = act8865_pmic_probe, | 534 | .probe = act8865_pmic_probe, |
536 | .id_table = act8865_ids, | 535 | .id_table = act8865_ids, |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 4315476540c4..de9f272a0faf 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1091,6 +1091,15 @@ static int set_machine_constraints(struct regulator_dev *rdev, | |||
1091 | } | 1091 | } |
1092 | } | 1092 | } |
1093 | 1093 | ||
1094 | if (rdev->constraints->over_current_protection | ||
1095 | && ops->set_over_current_protection) { | ||
1096 | ret = ops->set_over_current_protection(rdev); | ||
1097 | if (ret < 0) { | ||
1098 | rdev_err(rdev, "failed to set over current protection\n"); | ||
1099 | goto out; | ||
1100 | } | ||
1101 | } | ||
1102 | |||
1094 | print_constraints(rdev); | 1103 | print_constraints(rdev); |
1095 | return 0; | 1104 | return 0; |
1096 | out: | 1105 | out: |
diff --git a/drivers/regulator/da9210-regulator.c b/drivers/regulator/da9210-regulator.c index 8e39f7457bc3..b3517830edb6 100644 --- a/drivers/regulator/da9210-regulator.c +++ b/drivers/regulator/da9210-regulator.c | |||
@@ -259,7 +259,6 @@ MODULE_DEVICE_TABLE(i2c, da9210_i2c_id); | |||
259 | static struct i2c_driver da9210_regulator_driver = { | 259 | static struct i2c_driver da9210_regulator_driver = { |
260 | .driver = { | 260 | .driver = { |
261 | .name = "da9210", | 261 | .name = "da9210", |
262 | .owner = THIS_MODULE, | ||
263 | }, | 262 | }, |
264 | .probe = da9210_i2c_probe, | 263 | .probe = da9210_i2c_probe, |
265 | .id_table = da9210_i2c_id, | 264 | .id_table = da9210_i2c_id, |
diff --git a/drivers/regulator/da9211-regulator.c b/drivers/regulator/da9211-regulator.c index 0858100d2d03..04ef65b7eb3d 100644 --- a/drivers/regulator/da9211-regulator.c +++ b/drivers/regulator/da9211-regulator.c | |||
@@ -512,7 +512,6 @@ MODULE_DEVICE_TABLE(of, da9211_dt_ids); | |||
512 | static struct i2c_driver da9211_regulator_driver = { | 512 | static struct i2c_driver da9211_regulator_driver = { |
513 | .driver = { | 513 | .driver = { |
514 | .name = "da9211", | 514 | .name = "da9211", |
515 | .owner = THIS_MODULE, | ||
516 | .of_match_table = of_match_ptr(da9211_dt_ids), | 515 | .of_match_table = of_match_ptr(da9211_dt_ids), |
517 | }, | 516 | }, |
518 | .probe = da9211_i2c_probe, | 517 | .probe = da9211_i2c_probe, |
diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c index 6e5da95fa025..4abd8e9c81e5 100644 --- a/drivers/regulator/isl6271a-regulator.c +++ b/drivers/regulator/isl6271a-regulator.c | |||
@@ -156,7 +156,6 @@ MODULE_DEVICE_TABLE(i2c, isl6271a_id); | |||
156 | static struct i2c_driver isl6271a_i2c_driver = { | 156 | static struct i2c_driver isl6271a_i2c_driver = { |
157 | .driver = { | 157 | .driver = { |
158 | .name = "isl6271a", | 158 | .name = "isl6271a", |
159 | .owner = THIS_MODULE, | ||
160 | }, | 159 | }, |
161 | .probe = isl6271a_probe, | 160 | .probe = isl6271a_probe, |
162 | .id_table = isl6271a_id, | 161 | .id_table = isl6271a_id, |
diff --git a/drivers/regulator/isl9305.c b/drivers/regulator/isl9305.c index e02e9a9dddbd..257c1943e753 100644 --- a/drivers/regulator/isl9305.c +++ b/drivers/regulator/isl9305.c | |||
@@ -196,7 +196,6 @@ MODULE_DEVICE_TABLE(i2c, isl9305_i2c_id); | |||
196 | static struct i2c_driver isl9305_regulator_driver = { | 196 | static struct i2c_driver isl9305_regulator_driver = { |
197 | .driver = { | 197 | .driver = { |
198 | .name = "isl9305", | 198 | .name = "isl9305", |
199 | .owner = THIS_MODULE, | ||
200 | .of_match_table = of_match_ptr(isl9305_dt_ids), | 199 | .of_match_table = of_match_ptr(isl9305_dt_ids), |
201 | }, | 200 | }, |
202 | .probe = isl9305_i2c_probe, | 201 | .probe = isl9305_i2c_probe, |
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 66fd2330dca0..15c25c622edf 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
@@ -452,7 +452,6 @@ MODULE_DEVICE_TABLE(i2c, lp3971_i2c_id); | |||
452 | static struct i2c_driver lp3971_i2c_driver = { | 452 | static struct i2c_driver lp3971_i2c_driver = { |
453 | .driver = { | 453 | .driver = { |
454 | .name = "LP3971", | 454 | .name = "LP3971", |
455 | .owner = THIS_MODULE, | ||
456 | }, | 455 | }, |
457 | .probe = lp3971_i2c_probe, | 456 | .probe = lp3971_i2c_probe, |
458 | .id_table = lp3971_i2c_id, | 457 | .id_table = lp3971_i2c_id, |
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c index aea485afcc1a..3a7e96e2c7b3 100644 --- a/drivers/regulator/lp3972.c +++ b/drivers/regulator/lp3972.c | |||
@@ -550,7 +550,6 @@ MODULE_DEVICE_TABLE(i2c, lp3972_i2c_id); | |||
550 | static struct i2c_driver lp3972_i2c_driver = { | 550 | static struct i2c_driver lp3972_i2c_driver = { |
551 | .driver = { | 551 | .driver = { |
552 | .name = "lp3972", | 552 | .name = "lp3972", |
553 | .owner = THIS_MODULE, | ||
554 | }, | 553 | }, |
555 | .probe = lp3972_i2c_probe, | 554 | .probe = lp3972_i2c_probe, |
556 | .id_table = lp3972_i2c_id, | 555 | .id_table = lp3972_i2c_id, |
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c index 8702e7384af7..e5af07208f9d 100644 --- a/drivers/regulator/lp872x.c +++ b/drivers/regulator/lp872x.c | |||
@@ -961,7 +961,6 @@ MODULE_DEVICE_TABLE(i2c, lp872x_ids); | |||
961 | static struct i2c_driver lp872x_driver = { | 961 | static struct i2c_driver lp872x_driver = { |
962 | .driver = { | 962 | .driver = { |
963 | .name = "lp872x", | 963 | .name = "lp872x", |
964 | .owner = THIS_MODULE, | ||
965 | .of_match_table = of_match_ptr(lp872x_dt_ids), | 964 | .of_match_table = of_match_ptr(lp872x_dt_ids), |
966 | }, | 965 | }, |
967 | .probe = lp872x_probe, | 966 | .probe = lp872x_probe, |
diff --git a/drivers/regulator/ltc3589.c b/drivers/regulator/ltc3589.c index cc22ac66c8fd..972c386b2690 100644 --- a/drivers/regulator/ltc3589.c +++ b/drivers/regulator/ltc3589.c | |||
@@ -542,7 +542,6 @@ MODULE_DEVICE_TABLE(i2c, ltc3589_i2c_id); | |||
542 | static struct i2c_driver ltc3589_driver = { | 542 | static struct i2c_driver ltc3589_driver = { |
543 | .driver = { | 543 | .driver = { |
544 | .name = DRIVER_NAME, | 544 | .name = DRIVER_NAME, |
545 | .owner = THIS_MODULE, | ||
546 | }, | 545 | }, |
547 | .probe = ltc3589_probe, | 546 | .probe = ltc3589_probe, |
548 | .id_table = ltc3589_i2c_id, | 547 | .id_table = ltc3589_i2c_id, |
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index d2a8c64cae42..2c1228d5796a 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
@@ -304,7 +304,6 @@ static struct i2c_driver max1586_pmic_driver = { | |||
304 | .probe = max1586_pmic_probe, | 304 | .probe = max1586_pmic_probe, |
305 | .driver = { | 305 | .driver = { |
306 | .name = "max1586", | 306 | .name = "max1586", |
307 | .owner = THIS_MODULE, | ||
308 | .of_match_table = of_match_ptr(max1586_of_match), | 307 | .of_match_table = of_match_ptr(max1586_of_match), |
309 | }, | 308 | }, |
310 | .id_table = max1586_id, | 309 | .id_table = max1586_id, |
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index 4071d74fa828..b87f62dd484e 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c | |||
@@ -518,7 +518,6 @@ static struct i2c_driver max8660_driver = { | |||
518 | .probe = max8660_probe, | 518 | .probe = max8660_probe, |
519 | .driver = { | 519 | .driver = { |
520 | .name = "max8660", | 520 | .name = "max8660", |
521 | .owner = THIS_MODULE, | ||
522 | }, | 521 | }, |
523 | .id_table = max8660_id, | 522 | .id_table = max8660_id, |
524 | }; | 523 | }; |
diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c index 8857cc02d9a8..5b75b7c2e3ea 100644 --- a/drivers/regulator/max8973-regulator.c +++ b/drivers/regulator/max8973-regulator.c | |||
@@ -732,7 +732,6 @@ static struct i2c_driver max8973_i2c_driver = { | |||
732 | .driver = { | 732 | .driver = { |
733 | .name = "max8973", | 733 | .name = "max8973", |
734 | .of_match_table = of_max8973_match_tbl, | 734 | .of_match_table = of_max8973_match_tbl, |
735 | .owner = THIS_MODULE, | ||
736 | }, | 735 | }, |
737 | .probe = max8973_probe, | 736 | .probe = max8973_probe, |
738 | .id_table = max8973_id, | 737 | .id_table = max8973_id, |
diff --git a/drivers/regulator/mt6311-regulator.c b/drivers/regulator/mt6311-regulator.c new file mode 100644 index 000000000000..02c4e5feca8e --- /dev/null +++ b/drivers/regulator/mt6311-regulator.c | |||
@@ -0,0 +1,179 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2015 MediaTek Inc. | ||
3 | * Author: Henry Chen <henryc.chen@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/err.h> | ||
16 | #include <linux/gpio.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/init.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/regmap.h> | ||
22 | #include <linux/regulator/driver.h> | ||
23 | #include <linux/regulator/machine.h> | ||
24 | #include <linux/regulator/of_regulator.h> | ||
25 | #include <linux/regulator/mt6311.h> | ||
26 | #include <linux/slab.h> | ||
27 | #include "mt6311-regulator.h" | ||
28 | |||
29 | static const struct regmap_config mt6311_regmap_config = { | ||
30 | .reg_bits = 8, | ||
31 | .val_bits = 8, | ||
32 | .max_register = MT6311_FQMTR_CON4, | ||
33 | }; | ||
34 | |||
35 | /* Default limits measured in millivolts and milliamps */ | ||
36 | #define MT6311_MIN_UV 600000 | ||
37 | #define MT6311_MAX_UV 1393750 | ||
38 | #define MT6311_STEP_UV 6250 | ||
39 | |||
40 | static const struct regulator_linear_range buck_volt_range[] = { | ||
41 | REGULATOR_LINEAR_RANGE(MT6311_MIN_UV, 0, 0x7f, MT6311_STEP_UV), | ||
42 | }; | ||
43 | |||
44 | static const struct regulator_ops mt6311_buck_ops = { | ||
45 | .list_voltage = regulator_list_voltage_linear_range, | ||
46 | .map_voltage = regulator_map_voltage_linear_range, | ||
47 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
48 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
49 | .set_voltage_time_sel = regulator_set_voltage_time_sel, | ||
50 | .enable = regulator_enable_regmap, | ||
51 | .disable = regulator_disable_regmap, | ||
52 | .is_enabled = regulator_is_enabled_regmap, | ||
53 | }; | ||
54 | |||
55 | static const struct regulator_ops mt6311_ldo_ops = { | ||
56 | .enable = regulator_enable_regmap, | ||
57 | .disable = regulator_disable_regmap, | ||
58 | .is_enabled = regulator_is_enabled_regmap, | ||
59 | }; | ||
60 | |||
61 | #define MT6311_BUCK(_id) \ | ||
62 | {\ | ||
63 | .name = #_id,\ | ||
64 | .ops = &mt6311_buck_ops,\ | ||
65 | .of_match = of_match_ptr(#_id),\ | ||
66 | .regulators_node = of_match_ptr("regulators"),\ | ||
67 | .type = REGULATOR_VOLTAGE,\ | ||
68 | .id = MT6311_ID_##_id,\ | ||
69 | .n_voltages = (MT6311_MAX_UV - MT6311_MIN_UV) / MT6311_STEP_UV + 1,\ | ||
70 | .min_uV = MT6311_MIN_UV,\ | ||
71 | .uV_step = MT6311_STEP_UV,\ | ||
72 | .owner = THIS_MODULE,\ | ||
73 | .linear_ranges = buck_volt_range, \ | ||
74 | .n_linear_ranges = ARRAY_SIZE(buck_volt_range), \ | ||
75 | .enable_reg = MT6311_VDVFS11_CON9,\ | ||
76 | .enable_mask = MT6311_PMIC_VDVFS11_EN_MASK,\ | ||
77 | .vsel_reg = MT6311_VDVFS11_CON12,\ | ||
78 | .vsel_mask = MT6311_PMIC_VDVFS11_VOSEL_MASK,\ | ||
79 | } | ||
80 | |||
81 | #define MT6311_LDO(_id) \ | ||
82 | {\ | ||
83 | .name = #_id,\ | ||
84 | .ops = &mt6311_ldo_ops,\ | ||
85 | .of_match = of_match_ptr(#_id),\ | ||
86 | .regulators_node = of_match_ptr("regulators"),\ | ||
87 | .type = REGULATOR_VOLTAGE,\ | ||
88 | .id = MT6311_ID_##_id,\ | ||
89 | .owner = THIS_MODULE,\ | ||
90 | .enable_reg = MT6311_LDO_CON3,\ | ||
91 | .enable_mask = MT6311_PMIC_RG_VBIASN_EN_MASK,\ | ||
92 | } | ||
93 | |||
94 | static const struct regulator_desc mt6311_regulators[] = { | ||
95 | MT6311_BUCK(VDVFS), | ||
96 | MT6311_LDO(VBIASN), | ||
97 | }; | ||
98 | |||
99 | /* | ||
100 | * I2C driver interface functions | ||
101 | */ | ||
102 | static int mt6311_i2c_probe(struct i2c_client *i2c, | ||
103 | const struct i2c_device_id *id) | ||
104 | { | ||
105 | struct regulator_config config = { }; | ||
106 | struct regulator_dev *rdev; | ||
107 | struct regmap *regmap; | ||
108 | int i, ret; | ||
109 | unsigned int data; | ||
110 | |||
111 | regmap = devm_regmap_init_i2c(i2c, &mt6311_regmap_config); | ||
112 | if (IS_ERR(regmap)) { | ||
113 | ret = PTR_ERR(regmap); | ||
114 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", | ||
115 | ret); | ||
116 | return ret; | ||
117 | } | ||
118 | |||
119 | ret = regmap_read(regmap, MT6311_SWCID, &data); | ||
120 | if (ret < 0) { | ||
121 | dev_err(&i2c->dev, "Failed to read DEVICE_ID reg: %d\n", ret); | ||
122 | return ret; | ||
123 | } | ||
124 | |||
125 | switch (data) { | ||
126 | case MT6311_E1_CID_CODE: | ||
127 | case MT6311_E2_CID_CODE: | ||
128 | case MT6311_E3_CID_CODE: | ||
129 | break; | ||
130 | default: | ||
131 | dev_err(&i2c->dev, "Unsupported device id = 0x%x.\n", data); | ||
132 | return -ENODEV; | ||
133 | } | ||
134 | |||
135 | for (i = 0; i < MT6311_MAX_REGULATORS; i++) { | ||
136 | config.dev = &i2c->dev; | ||
137 | config.regmap = regmap; | ||
138 | |||
139 | rdev = devm_regulator_register(&i2c->dev, | ||
140 | &mt6311_regulators[i], &config); | ||
141 | if (IS_ERR(rdev)) { | ||
142 | dev_err(&i2c->dev, | ||
143 | "Failed to register MT6311 regulator\n"); | ||
144 | return PTR_ERR(rdev); | ||
145 | } | ||
146 | } | ||
147 | |||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static const struct i2c_device_id mt6311_i2c_id[] = { | ||
152 | {"mt6311", 0}, | ||
153 | {}, | ||
154 | }; | ||
155 | MODULE_DEVICE_TABLE(i2c, mt6311_i2c_id); | ||
156 | |||
157 | #ifdef CONFIG_OF | ||
158 | static const struct of_device_id mt6311_dt_ids[] = { | ||
159 | { .compatible = "mediatek,mt6311-regulator", | ||
160 | .data = &mt6311_i2c_id[0] }, | ||
161 | {}, | ||
162 | }; | ||
163 | MODULE_DEVICE_TABLE(of, mt6311_dt_ids); | ||
164 | #endif | ||
165 | |||
166 | static struct i2c_driver mt6311_regulator_driver = { | ||
167 | .driver = { | ||
168 | .name = "mt6311", | ||
169 | .of_match_table = of_match_ptr(mt6311_dt_ids), | ||
170 | }, | ||
171 | .probe = mt6311_i2c_probe, | ||
172 | .id_table = mt6311_i2c_id, | ||
173 | }; | ||
174 | |||
175 | module_i2c_driver(mt6311_regulator_driver); | ||
176 | |||
177 | MODULE_AUTHOR("Henry Chen <henryc.chen@mediatek.com>"); | ||
178 | MODULE_DESCRIPTION("Regulator device driver for Mediatek MT6311"); | ||
179 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/regulator/mt6311-regulator.h b/drivers/regulator/mt6311-regulator.h new file mode 100644 index 000000000000..5218db46a798 --- /dev/null +++ b/drivers/regulator/mt6311-regulator.h | |||
@@ -0,0 +1,65 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2015 MediaTek Inc. | ||
3 | * Author: Henry Chen <henryc.chen@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 __MT6311_REGULATOR_H__ | ||
16 | #define __MT6311_REGULATOR_H__ | ||
17 | |||
18 | #define MT6311_SWCID 0x01 | ||
19 | |||
20 | #define MT6311_TOP_INT_CON 0x18 | ||
21 | #define MT6311_TOP_INT_MON 0x19 | ||
22 | |||
23 | #define MT6311_VDVFS11_CON0 0x87 | ||
24 | #define MT6311_VDVFS11_CON7 0x88 | ||
25 | #define MT6311_VDVFS11_CON8 0x89 | ||
26 | #define MT6311_VDVFS11_CON9 0x8A | ||
27 | #define MT6311_VDVFS11_CON10 0x8B | ||
28 | #define MT6311_VDVFS11_CON11 0x8C | ||
29 | #define MT6311_VDVFS11_CON12 0x8D | ||
30 | #define MT6311_VDVFS11_CON13 0x8E | ||
31 | #define MT6311_VDVFS11_CON14 0x8F | ||
32 | #define MT6311_VDVFS11_CON15 0x90 | ||
33 | #define MT6311_VDVFS11_CON16 0x91 | ||
34 | #define MT6311_VDVFS11_CON17 0x92 | ||
35 | #define MT6311_VDVFS11_CON18 0x93 | ||
36 | #define MT6311_VDVFS11_CON19 0x94 | ||
37 | |||
38 | #define MT6311_LDO_CON0 0xCC | ||
39 | #define MT6311_LDO_OCFB0 0xCD | ||
40 | #define MT6311_LDO_CON2 0xCE | ||
41 | #define MT6311_LDO_CON3 0xCF | ||
42 | #define MT6311_LDO_CON4 0xD0 | ||
43 | #define MT6311_FQMTR_CON0 0xD1 | ||
44 | #define MT6311_FQMTR_CON1 0xD2 | ||
45 | #define MT6311_FQMTR_CON2 0xD3 | ||
46 | #define MT6311_FQMTR_CON3 0xD4 | ||
47 | #define MT6311_FQMTR_CON4 0xD5 | ||
48 | |||
49 | #define MT6311_PMIC_RG_INT_POL_MASK 0x1 | ||
50 | #define MT6311_PMIC_RG_INT_EN_MASK 0x2 | ||
51 | #define MT6311_PMIC_RG_BUCK_OC_INT_STATUS_MASK 0x10 | ||
52 | |||
53 | #define MT6311_PMIC_VDVFS11_EN_CTRL_MASK 0x1 | ||
54 | #define MT6311_PMIC_VDVFS11_VOSEL_CTRL_MASK 0x2 | ||
55 | #define MT6311_PMIC_VDVFS11_EN_SEL_MASK 0x3 | ||
56 | #define MT6311_PMIC_VDVFS11_VOSEL_SEL_MASK 0xc | ||
57 | #define MT6311_PMIC_VDVFS11_EN_MASK 0x1 | ||
58 | #define MT6311_PMIC_VDVFS11_VOSEL_MASK 0x7F | ||
59 | #define MT6311_PMIC_VDVFS11_VOSEL_ON_MASK 0x7F | ||
60 | #define MT6311_PMIC_VDVFS11_VOSEL_SLEEP_MASK 0x7F | ||
61 | #define MT6311_PMIC_NI_VDVFS11_VOSEL_MASK 0x7F | ||
62 | |||
63 | #define MT6311_PMIC_RG_VBIASN_EN_MASK 0x1 | ||
64 | |||
65 | #endif | ||
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index b1c485b24ab2..250700c853bf 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c | |||
@@ -107,6 +107,9 @@ static void of_get_regulation_constraints(struct device_node *np, | |||
107 | if (!of_property_read_u32(np, "regulator-system-load", &pval)) | 107 | if (!of_property_read_u32(np, "regulator-system-load", &pval)) |
108 | constraints->system_load = pval; | 108 | constraints->system_load = pval; |
109 | 109 | ||
110 | constraints->over_current_protection = of_property_read_bool(np, | ||
111 | "regulator-over-current-protection"); | ||
112 | |||
110 | for (i = 0; i < ARRAY_SIZE(regulator_states); i++) { | 113 | for (i = 0; i < ARRAY_SIZE(regulator_states); i++) { |
111 | switch (i) { | 114 | switch (i) { |
112 | case PM_SUSPEND_MEM: | 115 | case PM_SUSPEND_MEM: |
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c index 8cc8d1877c44..2a44e5dd9c2a 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c | |||
@@ -643,7 +643,6 @@ static struct i2c_driver pfuze_driver = { | |||
643 | .id_table = pfuze_device_id, | 643 | .id_table = pfuze_device_id, |
644 | .driver = { | 644 | .driver = { |
645 | .name = "pfuze100-regulator", | 645 | .name = "pfuze100-regulator", |
646 | .owner = THIS_MODULE, | ||
647 | .of_match_table = pfuze_dt_ids, | 646 | .of_match_table = pfuze_dt_ids, |
648 | }, | 647 | }, |
649 | .probe = pfuze100_regulator_probe, | 648 | .probe = pfuze100_regulator_probe, |
@@ -653,4 +652,3 @@ module_i2c_driver(pfuze_driver); | |||
653 | MODULE_AUTHOR("Robin Gong <b38343@freescale.com>"); | 652 | MODULE_AUTHOR("Robin Gong <b38343@freescale.com>"); |
654 | MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/PFUZE200 PMIC"); | 653 | MODULE_DESCRIPTION("Regulator Driver for Freescale PFUZE100/PFUZE200 PMIC"); |
655 | MODULE_LICENSE("GPL v2"); | 654 | MODULE_LICENSE("GPL v2"); |
656 | MODULE_ALIAS("i2c:pfuze100-regulator"); | ||
diff --git a/drivers/regulator/pwm-regulator.c b/drivers/regulator/pwm-regulator.c index ffa96124a5e7..fc3166dfcbfa 100644 --- a/drivers/regulator/pwm-regulator.c +++ b/drivers/regulator/pwm-regulator.c | |||
@@ -10,6 +10,7 @@ | |||
10 | * published by the Free Software Foundation. | 10 | * published by the Free Software Foundation. |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/delay.h> | ||
13 | #include <linux/module.h> | 14 | #include <linux/module.h> |
14 | #include <linux/init.h> | 15 | #include <linux/init.h> |
15 | #include <linux/err.h> | 16 | #include <linux/err.h> |
@@ -21,9 +22,15 @@ | |||
21 | #include <linux/pwm.h> | 22 | #include <linux/pwm.h> |
22 | 23 | ||
23 | struct pwm_regulator_data { | 24 | struct pwm_regulator_data { |
24 | struct pwm_voltages *duty_cycle_table; | 25 | /* Shared */ |
25 | struct pwm_device *pwm; | 26 | struct pwm_device *pwm; |
27 | |||
28 | /* Voltage table */ | ||
29 | struct pwm_voltages *duty_cycle_table; | ||
26 | int state; | 30 | int state; |
31 | |||
32 | /* Continuous voltage */ | ||
33 | int volt_uV; | ||
27 | }; | 34 | }; |
28 | 35 | ||
29 | struct pwm_voltages { | 36 | struct pwm_voltages { |
@@ -31,6 +38,9 @@ struct pwm_voltages { | |||
31 | unsigned int dutycycle; | 38 | unsigned int dutycycle; |
32 | }; | 39 | }; |
33 | 40 | ||
41 | /** | ||
42 | * Voltage table call-backs | ||
43 | */ | ||
34 | static int pwm_regulator_get_voltage_sel(struct regulator_dev *rdev) | 44 | static int pwm_regulator_get_voltage_sel(struct regulator_dev *rdev) |
35 | { | 45 | { |
36 | struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); | 46 | struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); |
@@ -79,29 +89,129 @@ static int pwm_regulator_list_voltage(struct regulator_dev *rdev, | |||
79 | return drvdata->duty_cycle_table[selector].uV; | 89 | return drvdata->duty_cycle_table[selector].uV; |
80 | } | 90 | } |
81 | 91 | ||
82 | static struct regulator_ops pwm_regulator_voltage_ops = { | 92 | /** |
93 | * Continuous voltage call-backs | ||
94 | */ | ||
95 | static int pwm_voltage_to_duty_cycle_percentage(struct regulator_dev *rdev, int req_uV) | ||
96 | { | ||
97 | int min_uV = rdev->constraints->min_uV; | ||
98 | int max_uV = rdev->constraints->max_uV; | ||
99 | int diff = max_uV - min_uV; | ||
100 | |||
101 | return 100 - (((req_uV * 100) - (min_uV * 100)) / diff); | ||
102 | } | ||
103 | |||
104 | static int pwm_regulator_get_voltage(struct regulator_dev *rdev) | ||
105 | { | ||
106 | struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); | ||
107 | |||
108 | return drvdata->volt_uV; | ||
109 | } | ||
110 | |||
111 | static int pwm_regulator_set_voltage(struct regulator_dev *rdev, | ||
112 | int min_uV, int max_uV, | ||
113 | unsigned *selector) | ||
114 | { | ||
115 | struct pwm_regulator_data *drvdata = rdev_get_drvdata(rdev); | ||
116 | unsigned int ramp_delay = rdev->constraints->ramp_delay; | ||
117 | unsigned int period = pwm_get_period(drvdata->pwm); | ||
118 | int duty_cycle; | ||
119 | int ret; | ||
120 | |||
121 | duty_cycle = pwm_voltage_to_duty_cycle_percentage(rdev, min_uV); | ||
122 | |||
123 | ret = pwm_config(drvdata->pwm, (period / 100) * duty_cycle, period); | ||
124 | if (ret) { | ||
125 | dev_err(&rdev->dev, "Failed to configure PWM\n"); | ||
126 | return ret; | ||
127 | } | ||
128 | |||
129 | ret = pwm_enable(drvdata->pwm); | ||
130 | if (ret) { | ||
131 | dev_err(&rdev->dev, "Failed to enable PWM\n"); | ||
132 | return ret; | ||
133 | } | ||
134 | drvdata->volt_uV = min_uV; | ||
135 | |||
136 | /* Delay required by PWM regulator to settle to the new voltage */ | ||
137 | usleep_range(ramp_delay, ramp_delay + 1000); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | static struct regulator_ops pwm_regulator_voltage_table_ops = { | ||
83 | .set_voltage_sel = pwm_regulator_set_voltage_sel, | 143 | .set_voltage_sel = pwm_regulator_set_voltage_sel, |
84 | .get_voltage_sel = pwm_regulator_get_voltage_sel, | 144 | .get_voltage_sel = pwm_regulator_get_voltage_sel, |
85 | .list_voltage = pwm_regulator_list_voltage, | 145 | .list_voltage = pwm_regulator_list_voltage, |
86 | .map_voltage = regulator_map_voltage_iterate, | 146 | .map_voltage = regulator_map_voltage_iterate, |
87 | }; | 147 | }; |
88 | 148 | ||
149 | static struct regulator_ops pwm_regulator_voltage_continuous_ops = { | ||
150 | .get_voltage = pwm_regulator_get_voltage, | ||
151 | .set_voltage = pwm_regulator_set_voltage, | ||
152 | }; | ||
153 | |||
89 | static struct regulator_desc pwm_regulator_desc = { | 154 | static struct regulator_desc pwm_regulator_desc = { |
90 | .name = "pwm-regulator", | 155 | .name = "pwm-regulator", |
91 | .ops = &pwm_regulator_voltage_ops, | ||
92 | .type = REGULATOR_VOLTAGE, | 156 | .type = REGULATOR_VOLTAGE, |
93 | .owner = THIS_MODULE, | 157 | .owner = THIS_MODULE, |
94 | .supply_name = "pwm", | 158 | .supply_name = "pwm", |
95 | }; | 159 | }; |
96 | 160 | ||
161 | static int pwm_regulator_init_table(struct platform_device *pdev, | ||
162 | struct pwm_regulator_data *drvdata) | ||
163 | { | ||
164 | struct device_node *np = pdev->dev.of_node; | ||
165 | struct pwm_voltages *duty_cycle_table; | ||
166 | unsigned int length = 0; | ||
167 | int ret; | ||
168 | |||
169 | of_find_property(np, "voltage-table", &length); | ||
170 | |||
171 | if ((length < sizeof(*duty_cycle_table)) || | ||
172 | (length % sizeof(*duty_cycle_table))) { | ||
173 | dev_err(&pdev->dev, | ||
174 | "voltage-table length(%d) is invalid\n", | ||
175 | length); | ||
176 | return -EINVAL; | ||
177 | } | ||
178 | |||
179 | duty_cycle_table = devm_kzalloc(&pdev->dev, length, GFP_KERNEL); | ||
180 | if (!duty_cycle_table) | ||
181 | return -ENOMEM; | ||
182 | |||
183 | ret = of_property_read_u32_array(np, "voltage-table", | ||
184 | (u32 *)duty_cycle_table, | ||
185 | length / sizeof(u32)); | ||
186 | if (ret) { | ||
187 | dev_err(&pdev->dev, "Failed to read voltage-table\n"); | ||
188 | return ret; | ||
189 | } | ||
190 | |||
191 | drvdata->duty_cycle_table = duty_cycle_table; | ||
192 | pwm_regulator_desc.ops = &pwm_regulator_voltage_table_ops; | ||
193 | pwm_regulator_desc.n_voltages = length / sizeof(*duty_cycle_table); | ||
194 | |||
195 | return 0; | ||
196 | } | ||
197 | |||
198 | static int pwm_regulator_init_continuous(struct platform_device *pdev, | ||
199 | struct pwm_regulator_data *drvdata) | ||
200 | { | ||
201 | pwm_regulator_desc.ops = &pwm_regulator_voltage_continuous_ops; | ||
202 | pwm_regulator_desc.continuous_voltage_range = true; | ||
203 | |||
204 | return 0; | ||
205 | } | ||
206 | |||
97 | static int pwm_regulator_probe(struct platform_device *pdev) | 207 | static int pwm_regulator_probe(struct platform_device *pdev) |
98 | { | 208 | { |
209 | const struct regulator_init_data *init_data; | ||
99 | struct pwm_regulator_data *drvdata; | 210 | struct pwm_regulator_data *drvdata; |
100 | struct property *prop; | ||
101 | struct regulator_dev *regulator; | 211 | struct regulator_dev *regulator; |
102 | struct regulator_config config = { }; | 212 | struct regulator_config config = { }; |
103 | struct device_node *np = pdev->dev.of_node; | 213 | struct device_node *np = pdev->dev.of_node; |
104 | int length, ret; | 214 | int ret; |
105 | 215 | ||
106 | if (!np) { | 216 | if (!np) { |
107 | dev_err(&pdev->dev, "Device Tree node missing\n"); | 217 | dev_err(&pdev->dev, "Device Tree node missing\n"); |
@@ -112,44 +222,22 @@ static int pwm_regulator_probe(struct platform_device *pdev) | |||
112 | if (!drvdata) | 222 | if (!drvdata) |
113 | return -ENOMEM; | 223 | return -ENOMEM; |
114 | 224 | ||
115 | /* determine the number of voltage-table */ | 225 | if (of_find_property(np, "voltage-table", NULL)) |
116 | prop = of_find_property(np, "voltage-table", &length); | 226 | ret = pwm_regulator_init_table(pdev, drvdata); |
117 | if (!prop) { | 227 | else |
118 | dev_err(&pdev->dev, "No voltage-table\n"); | 228 | ret = pwm_regulator_init_continuous(pdev, drvdata); |
119 | return -EINVAL; | 229 | if (ret) |
120 | } | ||
121 | |||
122 | if ((length < sizeof(*drvdata->duty_cycle_table)) || | ||
123 | (length % sizeof(*drvdata->duty_cycle_table))) { | ||
124 | dev_err(&pdev->dev, "voltage-table length(%d) is invalid\n", | ||
125 | length); | ||
126 | return -EINVAL; | ||
127 | } | ||
128 | |||
129 | pwm_regulator_desc.n_voltages = length / sizeof(*drvdata->duty_cycle_table); | ||
130 | |||
131 | drvdata->duty_cycle_table = devm_kzalloc(&pdev->dev, | ||
132 | length, GFP_KERNEL); | ||
133 | if (!drvdata->duty_cycle_table) | ||
134 | return -ENOMEM; | ||
135 | |||
136 | /* read voltage table from DT property */ | ||
137 | ret = of_property_read_u32_array(np, "voltage-table", | ||
138 | (u32 *)drvdata->duty_cycle_table, | ||
139 | length / sizeof(u32)); | ||
140 | if (ret < 0) { | ||
141 | dev_err(&pdev->dev, "read voltage-table failed\n"); | ||
142 | return ret; | 230 | return ret; |
143 | } | ||
144 | 231 | ||
145 | config.init_data = of_get_regulator_init_data(&pdev->dev, np, | 232 | init_data = of_get_regulator_init_data(&pdev->dev, np, |
146 | &pwm_regulator_desc); | 233 | &pwm_regulator_desc); |
147 | if (!config.init_data) | 234 | if (!init_data) |
148 | return -ENOMEM; | 235 | return -ENOMEM; |
149 | 236 | ||
150 | config.of_node = np; | 237 | config.of_node = np; |
151 | config.dev = &pdev->dev; | 238 | config.dev = &pdev->dev; |
152 | config.driver_data = drvdata; | 239 | config.driver_data = drvdata; |
240 | config.init_data = init_data; | ||
153 | 241 | ||
154 | drvdata->pwm = devm_pwm_get(&pdev->dev, NULL); | 242 | drvdata->pwm = devm_pwm_get(&pdev->dev, NULL); |
155 | if (IS_ERR(drvdata->pwm)) { | 243 | if (IS_ERR(drvdata->pwm)) { |
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index c213e37eb69e..572816e30095 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c | |||
@@ -362,7 +362,6 @@ MODULE_DEVICE_TABLE(i2c, tps51632_id); | |||
362 | static struct i2c_driver tps51632_i2c_driver = { | 362 | static struct i2c_driver tps51632_i2c_driver = { |
363 | .driver = { | 363 | .driver = { |
364 | .name = "tps51632", | 364 | .name = "tps51632", |
365 | .owner = THIS_MODULE, | ||
366 | .of_match_table = of_match_ptr(tps51632_of_match), | 365 | .of_match_table = of_match_ptr(tps51632_of_match), |
367 | }, | 366 | }, |
368 | .probe = tps51632_probe, | 367 | .probe = tps51632_probe, |
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index a1fd626c6c96..f6a6d36a6533 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c | |||
@@ -515,7 +515,6 @@ MODULE_DEVICE_TABLE(i2c, tps62360_id); | |||
515 | static struct i2c_driver tps62360_i2c_driver = { | 515 | static struct i2c_driver tps62360_i2c_driver = { |
516 | .driver = { | 516 | .driver = { |
517 | .name = "tps62360", | 517 | .name = "tps62360", |
518 | .owner = THIS_MODULE, | ||
519 | .of_match_table = of_match_ptr(tps62360_of_match), | 518 | .of_match_table = of_match_ptr(tps62360_of_match), |
520 | }, | 519 | }, |
521 | .probe = tps62360_probe, | 520 | .probe = tps62360_probe, |
diff --git a/drivers/regulator/tps65023-regulator.c b/drivers/regulator/tps65023-regulator.c index b941e564b3f3..5cc19b44974a 100644 --- a/drivers/regulator/tps65023-regulator.c +++ b/drivers/regulator/tps65023-regulator.c | |||
@@ -410,7 +410,6 @@ MODULE_DEVICE_TABLE(i2c, tps_65023_id); | |||
410 | static struct i2c_driver tps_65023_i2c_driver = { | 410 | static struct i2c_driver tps_65023_i2c_driver = { |
411 | .driver = { | 411 | .driver = { |
412 | .name = "tps65023", | 412 | .name = "tps65023", |
413 | .owner = THIS_MODULE, | ||
414 | }, | 413 | }, |
415 | .probe = tps_65023_probe, | 414 | .probe = tps_65023_probe, |
416 | .id_table = tps_65023_id, | 415 | .id_table = tps_65023_id, |
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index 4db9fbe4889d..45932228cbf5 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
@@ -148,6 +148,7 @@ struct regulator_ops { | |||
148 | int (*get_current_limit) (struct regulator_dev *); | 148 | int (*get_current_limit) (struct regulator_dev *); |
149 | 149 | ||
150 | int (*set_input_current_limit) (struct regulator_dev *, int lim_uA); | 150 | int (*set_input_current_limit) (struct regulator_dev *, int lim_uA); |
151 | int (*set_over_current_protection) (struct regulator_dev *); | ||
151 | 152 | ||
152 | /* enable/disable regulator */ | 153 | /* enable/disable regulator */ |
153 | int (*enable) (struct regulator_dev *); | 154 | int (*enable) (struct regulator_dev *); |
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index b11be1260129..a1067d0b3991 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h | |||
@@ -147,6 +147,7 @@ struct regulation_constraints { | |||
147 | unsigned ramp_disable:1; /* disable ramp delay */ | 147 | unsigned ramp_disable:1; /* disable ramp delay */ |
148 | unsigned soft_start:1; /* ramp voltage slowly */ | 148 | unsigned soft_start:1; /* ramp voltage slowly */ |
149 | unsigned pull_down:1; /* pull down resistor when regulator off */ | 149 | unsigned pull_down:1; /* pull down resistor when regulator off */ |
150 | unsigned over_current_protection:1; /* auto disable on over current */ | ||
150 | }; | 151 | }; |
151 | 152 | ||
152 | /** | 153 | /** |
diff --git a/include/linux/regulator/mt6311.h b/include/linux/regulator/mt6311.h new file mode 100644 index 000000000000..8473259395b6 --- /dev/null +++ b/include/linux/regulator/mt6311.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2015 MediaTek Inc. | ||
3 | * Author: Henry Chen <henryc.chen@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_MT6311_H | ||
16 | #define __LINUX_REGULATOR_MT6311_H | ||
17 | |||
18 | #define MT6311_MAX_REGULATORS 2 | ||
19 | |||
20 | enum { | ||
21 | MT6311_ID_VDVFS = 0, | ||
22 | MT6311_ID_VBIASN, | ||
23 | }; | ||
24 | |||
25 | #define MT6311_E1_CID_CODE 0x10 | ||
26 | #define MT6311_E2_CID_CODE 0x20 | ||
27 | #define MT6311_E3_CID_CODE 0x30 | ||
28 | |||
29 | #endif /* __LINUX_REGULATOR_MT6311_H */ | ||