diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-25 16:19:10 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-25 16:19:10 -0500 |
commit | 15333539a9b3022656f815f643a77f6b054b335f (patch) | |
tree | 2c5eabbd1ba12a0bd33e8f10c32847f88567d681 | |
parent | bb1b64908f5a346b0654f02999e1a022a7e0c07d (diff) | |
parent | 07b19808486054f356dbf3495a277f51af062b35 (diff) |
Merge tag 'regulator-v3.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
Pull regulator updates from Mark Brown:
"A respin of the merges in the previous pull request with one extra
fix.
A quiet release for the regulator API, quite a large number of small
improvements all over but other than the addition of new drivers for
the AS3722 and MAX14577 there is nothing of substantial non-local
impact"
* tag 'regulator-v3.14-2' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator: (47 commits)
regulator: pfuze100-regulator: Improve dev_info() message
regulator: pfuze100-regulator: Fix some checkpatch complaints
regulator: twl: Fix checkpatch issue
regulator: core: Fix checkpatch issue
regulator: anatop-regulator: Remove unneeded memset()
regulator: s5m8767: Update LDO index in s5m8767-regulator.txt
regulator: as3722: set enable time for SD0/1/6
regulator: as3722: detect SD0 low-voltage mode
regulator: tps62360: Fix up a pointer-integer size mismatch warning
regulator: anatop-regulator: Remove unneeded kstrdup()
regulator: act8865: Fix build error when !OF
regulator: act8865: register all regulators regardless of how many are used
regulator: wm831x-dcdc: Remove unneeded 'err' label
regulator: anatop-regulator: Add MODULE_ALIAS()
regulator: act8865: fix incorrect devm_kzalloc for act8865
regulator: act8865: Remove set_suspend_[en|dis]able implementation
regulator: act8865: Remove unneeded regulator_unregister() calls
regulator: s2mps11: Clean up redundant code
regulator: tps65910: Simplify setting enable_mask for regulators
regulator: act8865: add device tree binding doc
...
36 files changed, 1017 insertions, 460 deletions
diff --git a/Documentation/devicetree/bindings/mfd/tps65910.txt b/Documentation/devicetree/bindings/mfd/tps65910.txt index 2e3304888ffc..b4bd98af1cc7 100644 --- a/Documentation/devicetree/bindings/mfd/tps65910.txt +++ b/Documentation/devicetree/bindings/mfd/tps65910.txt | |||
@@ -21,7 +21,7 @@ Required properties: | |||
21 | 21 | ||
22 | The valid regulator-compatible values are: | 22 | The valid regulator-compatible values are: |
23 | tps65910: vrtc, vio, vdd1, vdd2, vdd3, vdig1, vdig2, vpll, vdac, vaux1, | 23 | tps65910: vrtc, vio, vdd1, vdd2, vdd3, vdig1, vdig2, vpll, vdac, vaux1, |
24 | vaux2, vaux33, vmmc | 24 | vaux2, vaux33, vmmc, vbb |
25 | tps65911: vrtc, vio, vdd1, vdd3, vddctrl, ldo1, ldo2, ldo3, ldo4, ldo5, | 25 | tps65911: vrtc, vio, vdd1, vdd3, vddctrl, ldo1, ldo2, ldo3, ldo4, ldo5, |
26 | ldo6, ldo7, ldo8 | 26 | ldo6, ldo7, ldo8 |
27 | 27 | ||
@@ -38,7 +38,7 @@ Required properties: | |||
38 | vcc4-supply: VAUX1 and VAUX2 input. | 38 | vcc4-supply: VAUX1 and VAUX2 input. |
39 | vcc5-supply: VPLL and VDAC input. | 39 | vcc5-supply: VPLL and VDAC input. |
40 | vcc6-supply: VDIG1 and VDIG2 input. | 40 | vcc6-supply: VDIG1 and VDIG2 input. |
41 | vcc7-supply: VRTC input. | 41 | vcc7-supply: VRTC and VBB input. |
42 | vccio-supply: VIO input. | 42 | vccio-supply: VIO input. |
43 | tps65911: | 43 | tps65911: |
44 | vcc1-supply: VDD1 input. | 44 | vcc1-supply: VDD1 input. |
diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt new file mode 100644 index 000000000000..bef1fbb647ca --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt | |||
@@ -0,0 +1,60 @@ | |||
1 | ACT8865 regulator | ||
2 | ------------------- | ||
3 | |||
4 | Required properties: | ||
5 | - compatible: "active-semi,act8865" | ||
6 | - reg: I2C slave address | ||
7 | |||
8 | Any standard regulator properties can be used to configure the single regulator. | ||
9 | |||
10 | The valid names for regulators are: | ||
11 | DCDC_REG1, DCDC_REG2, DCDC_REG3, LDO_REG1, LDO_REG2, LDO_REG3, LDO_REG4. | ||
12 | |||
13 | Example: | ||
14 | -------- | ||
15 | |||
16 | i2c1: i2c@f0018000 { | ||
17 | pmic: act8865@5b { | ||
18 | compatible = "active-semi,act8865"; | ||
19 | reg = <0x5b>; | ||
20 | status = "disabled"; | ||
21 | |||
22 | regulators { | ||
23 | vcc_1v8_reg: DCDC_REG1 { | ||
24 | regulator-name = "VCC_1V8"; | ||
25 | regulator-min-microvolt = <1800000>; | ||
26 | regulator-max-microvolt = <1800000>; | ||
27 | regulator-always-on; | ||
28 | }; | ||
29 | |||
30 | vcc_1v2_reg: DCDC_REG2 { | ||
31 | regulator-name = "VCC_1V2"; | ||
32 | regulator-min-microvolt = <1100000>; | ||
33 | regulator-max-microvolt = <1300000>; | ||
34 | regulator-suspend-mem-microvolt = <1150000>; | ||
35 | regulator-suspend-standby-microvolt = <1150000>; | ||
36 | regulator-always-on; | ||
37 | }; | ||
38 | |||
39 | vcc_3v3_reg: DCDC_REG3 { | ||
40 | regulator-name = "VCC_3V3"; | ||
41 | regulator-min-microvolt = <3300000>; | ||
42 | regulator-max-microvolt = <3300000>; | ||
43 | regulator-always-on; | ||
44 | }; | ||
45 | |||
46 | vddana_reg: LDO_REG1 { | ||
47 | regulator-name = "VDDANA"; | ||
48 | regulator-min-microvolt = <3300000>; | ||
49 | regulator-max-microvolt = <3300000>; | ||
50 | regulator-always-on; | ||
51 | }; | ||
52 | |||
53 | vddfuse_reg: LDO_REG2 { | ||
54 | regulator-name = "FUSE_2V5"; | ||
55 | regulator-min-microvolt = <2500000>; | ||
56 | regulator-max-microvolt = <2500000>; | ||
57 | }; | ||
58 | }; | ||
59 | }; | ||
60 | }; | ||
diff --git a/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt index d1660a90fc06..fc6b38f035bd 100644 --- a/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt +++ b/Documentation/devicetree/bindings/regulator/s5m8767-regulator.txt | |||
@@ -83,7 +83,7 @@ as per the datasheet of s5m8767. | |||
83 | 83 | ||
84 | - LDOn | 84 | - LDOn |
85 | - valid values for n are 1 to 28 | 85 | - valid values for n are 1 to 28 |
86 | - Example: LDO0, LD01, LDO28 | 86 | - Example: LDO1, LD02, LDO28 |
87 | - BUCKn | 87 | - BUCKn |
88 | - valid values for n are 1 to 9. | 88 | - valid values for n are 1 to 9. |
89 | - Example: BUCK1, BUCK2, BUCK9 | 89 | - Example: BUCK1, BUCK2, BUCK9 |
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 5780ffcd79af..3f900cd51bf0 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt | |||
@@ -3,6 +3,7 @@ Device tree binding vendor prefix registry. Keep list in alphabetical order. | |||
3 | This isn't an exhaustive list, but you should add new prefixes to it before | 3 | This isn't an exhaustive list, but you should add new prefixes to it before |
4 | using them to avoid name-space collisions. | 4 | using them to avoid name-space collisions. |
5 | 5 | ||
6 | active-semi Active-Semi International Inc | ||
6 | ad Avionic Design GmbH | 7 | ad Avionic Design GmbH |
7 | adi Analog Devices, Inc. | 8 | adi Analog Devices, Inc. |
8 | aeroflexgaisler Aeroflex Gaisler AB | 9 | aeroflexgaisler Aeroflex Gaisler AB |
diff --git a/drivers/mfd/pcf50633-core.c b/drivers/mfd/pcf50633-core.c index 6841d6805fd6..41ab5e34d2ac 100644 --- a/drivers/mfd/pcf50633-core.c +++ b/drivers/mfd/pcf50633-core.c | |||
@@ -245,7 +245,7 @@ static int pcf50633_probe(struct i2c_client *client, | |||
245 | for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { | 245 | for (i = 0; i < PCF50633_NUM_REGULATORS; i++) { |
246 | struct platform_device *pdev; | 246 | struct platform_device *pdev; |
247 | 247 | ||
248 | pdev = platform_device_alloc("pcf50633-regltr", i); | 248 | pdev = platform_device_alloc("pcf50633-regulator", i); |
249 | if (!pdev) { | 249 | if (!pdev) { |
250 | dev_err(pcf->dev, "Cannot create regulator %d\n", i); | 250 | dev_err(pcf->dev, "Cannot create regulator %d\n", i); |
251 | continue; | 251 | continue; |
diff --git a/drivers/mfd/sec-core.c b/drivers/mfd/sec-core.c index e4671088f075..a139798b8065 100644 --- a/drivers/mfd/sec-core.c +++ b/drivers/mfd/sec-core.c | |||
@@ -81,36 +81,6 @@ static struct of_device_id sec_dt_match[] = { | |||
81 | }; | 81 | }; |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest) | ||
85 | { | ||
86 | return regmap_read(sec_pmic->regmap_pmic, reg, dest); | ||
87 | } | ||
88 | EXPORT_SYMBOL_GPL(sec_reg_read); | ||
89 | |||
90 | int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf) | ||
91 | { | ||
92 | return regmap_bulk_read(sec_pmic->regmap_pmic, reg, buf, count); | ||
93 | } | ||
94 | EXPORT_SYMBOL_GPL(sec_bulk_read); | ||
95 | |||
96 | int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value) | ||
97 | { | ||
98 | return regmap_write(sec_pmic->regmap_pmic, reg, value); | ||
99 | } | ||
100 | EXPORT_SYMBOL_GPL(sec_reg_write); | ||
101 | |||
102 | int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf) | ||
103 | { | ||
104 | return regmap_raw_write(sec_pmic->regmap_pmic, reg, buf, count); | ||
105 | } | ||
106 | EXPORT_SYMBOL_GPL(sec_bulk_write); | ||
107 | |||
108 | int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask) | ||
109 | { | ||
110 | return regmap_update_bits(sec_pmic->regmap_pmic, reg, mask, val); | ||
111 | } | ||
112 | EXPORT_SYMBOL_GPL(sec_reg_update); | ||
113 | |||
114 | static bool s2mps11_volatile(struct device *dev, unsigned int reg) | 84 | static bool s2mps11_volatile(struct device *dev, unsigned int reg) |
115 | { | 85 | { |
116 | switch (reg) { | 86 | switch (reg) { |
diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index db9ae6fa2404..6a7932822e37 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig | |||
@@ -70,6 +70,14 @@ config REGULATOR_88PM8607 | |||
70 | help | 70 | help |
71 | This driver supports 88PM8607 voltage regulator chips. | 71 | This driver supports 88PM8607 voltage regulator chips. |
72 | 72 | ||
73 | config REGULATOR_ACT8865 | ||
74 | tristate "Active-semi act8865 voltage regulator" | ||
75 | depends on I2C | ||
76 | select REGMAP_I2C | ||
77 | help | ||
78 | This driver controls a active-semi act8865 voltage output | ||
79 | regulator via I2C bus. | ||
80 | |||
73 | config REGULATOR_AD5398 | 81 | config REGULATOR_AD5398 |
74 | tristate "Analog Devices AD5398/AD5821 regulators" | 82 | tristate "Analog Devices AD5398/AD5821 regulators" |
75 | depends on I2C | 83 | depends on I2C |
@@ -249,6 +257,13 @@ config REGULATOR_LP8788 | |||
249 | help | 257 | help |
250 | This driver supports LP8788 voltage regulator chip. | 258 | This driver supports LP8788 voltage regulator chip. |
251 | 259 | ||
260 | config REGULATOR_MAX14577 | ||
261 | tristate "Maxim 14577 regulator" | ||
262 | depends on MFD_MAX14577 | ||
263 | help | ||
264 | This driver controls a Maxim 14577 regulator via I2C bus. | ||
265 | The regulators include safeout LDO and current regulator 'CHARGER'. | ||
266 | |||
252 | config REGULATOR_MAX1586 | 267 | config REGULATOR_MAX1586 |
253 | tristate "Maxim 1586/1587 voltage regulator" | 268 | tristate "Maxim 1586/1587 voltage regulator" |
254 | depends on I2C | 269 | depends on I2C |
@@ -384,7 +399,7 @@ config REGULATOR_PCF50633 | |||
384 | on PCF50633 | 399 | on PCF50633 |
385 | 400 | ||
386 | config REGULATOR_PFUZE100 | 401 | config REGULATOR_PFUZE100 |
387 | tristate "Support regulators on Freescale PFUZE100 PMIC" | 402 | tristate "Freescale PFUZE100 regulator driver" |
388 | depends on I2C | 403 | depends on I2C |
389 | select REGMAP_I2C | 404 | select REGMAP_I2C |
390 | help | 405 | help |
diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index 01c597ea1744..979f9ddcf259 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile | |||
@@ -14,6 +14,7 @@ obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o | |||
14 | obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o | 14 | obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o |
15 | obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o | 15 | obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o |
16 | obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o | 16 | obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o |
17 | obj-$(CONFIG_REGULATOR_ACT8865) += act8865-regulator.o | ||
17 | obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o | 18 | obj-$(CONFIG_REGULATOR_AD5398) += ad5398.o |
18 | obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o | 19 | obj-$(CONFIG_REGULATOR_ANATOP) += anatop-regulator.o |
19 | obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o | 20 | obj-$(CONFIG_REGULATOR_ARIZONA) += arizona-micsupp.o arizona-ldo1.o |
@@ -35,6 +36,7 @@ obj-$(CONFIG_REGULATOR_LP872X) += lp872x.o | |||
35 | obj-$(CONFIG_REGULATOR_LP8788) += lp8788-buck.o | 36 | obj-$(CONFIG_REGULATOR_LP8788) += lp8788-buck.o |
36 | obj-$(CONFIG_REGULATOR_LP8788) += lp8788-ldo.o | 37 | obj-$(CONFIG_REGULATOR_LP8788) += lp8788-ldo.o |
37 | obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o | 38 | obj-$(CONFIG_REGULATOR_LP8755) += lp8755.o |
39 | obj-$(CONFIG_REGULATOR_MAX14577) += max14577.o | ||
38 | obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o | 40 | obj-$(CONFIG_REGULATOR_MAX1586) += max1586.o |
39 | obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o | 41 | obj-$(CONFIG_REGULATOR_MAX8649) += max8649.o |
40 | obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o | 42 | obj-$(CONFIG_REGULATOR_MAX8660) += max8660.o |
diff --git a/drivers/regulator/ab8500.c b/drivers/regulator/ab8500.c index 603f192e84f1..c625468c7f2c 100644 --- a/drivers/regulator/ab8500.c +++ b/drivers/regulator/ab8500.c | |||
@@ -2998,37 +2998,6 @@ static void abx500_get_regulator_info(struct ab8500 *ab8500) | |||
2998 | } | 2998 | } |
2999 | } | 2999 | } |
3000 | 3000 | ||
3001 | static int ab8500_regulator_init_registers(struct platform_device *pdev, | ||
3002 | int id, int mask, int value) | ||
3003 | { | ||
3004 | struct ab8500_reg_init *reg_init = abx500_regulator.init; | ||
3005 | int err; | ||
3006 | |||
3007 | BUG_ON(value & ~mask); | ||
3008 | BUG_ON(mask & ~reg_init[id].mask); | ||
3009 | |||
3010 | /* initialize register */ | ||
3011 | err = abx500_mask_and_set_register_interruptible( | ||
3012 | &pdev->dev, | ||
3013 | reg_init[id].bank, | ||
3014 | reg_init[id].addr, | ||
3015 | mask, value); | ||
3016 | if (err < 0) { | ||
3017 | dev_err(&pdev->dev, | ||
3018 | "Failed to initialize 0x%02x, 0x%02x.\n", | ||
3019 | reg_init[id].bank, | ||
3020 | reg_init[id].addr); | ||
3021 | return err; | ||
3022 | } | ||
3023 | dev_vdbg(&pdev->dev, | ||
3024 | " init: 0x%02x, 0x%02x, 0x%02x, 0x%02x\n", | ||
3025 | reg_init[id].bank, | ||
3026 | reg_init[id].addr, | ||
3027 | mask, value); | ||
3028 | |||
3029 | return 0; | ||
3030 | } | ||
3031 | |||
3032 | static int ab8500_regulator_register(struct platform_device *pdev, | 3001 | static int ab8500_regulator_register(struct platform_device *pdev, |
3033 | struct regulator_init_data *init_data, | 3002 | struct regulator_init_data *init_data, |
3034 | int id, struct device_node *np) | 3003 | int id, struct device_node *np) |
@@ -3036,7 +3005,6 @@ static int ab8500_regulator_register(struct platform_device *pdev, | |||
3036 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); | 3005 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); |
3037 | struct ab8500_regulator_info *info = NULL; | 3006 | struct ab8500_regulator_info *info = NULL; |
3038 | struct regulator_config config = { }; | 3007 | struct regulator_config config = { }; |
3039 | int err; | ||
3040 | 3008 | ||
3041 | /* assign per-regulator data */ | 3009 | /* assign per-regulator data */ |
3042 | info = &abx500_regulator.info[id]; | 3010 | info = &abx500_regulator.info[id]; |
@@ -3058,17 +3026,12 @@ static int ab8500_regulator_register(struct platform_device *pdev, | |||
3058 | } | 3026 | } |
3059 | 3027 | ||
3060 | /* register regulator with framework */ | 3028 | /* register regulator with framework */ |
3061 | info->regulator = regulator_register(&info->desc, &config); | 3029 | info->regulator = devm_regulator_register(&pdev->dev, &info->desc, |
3030 | &config); | ||
3062 | if (IS_ERR(info->regulator)) { | 3031 | if (IS_ERR(info->regulator)) { |
3063 | err = PTR_ERR(info->regulator); | ||
3064 | dev_err(&pdev->dev, "failed to register regulator %s\n", | 3032 | dev_err(&pdev->dev, "failed to register regulator %s\n", |
3065 | info->desc.name); | 3033 | info->desc.name); |
3066 | /* when we fail, un-register all earlier regulators */ | 3034 | return PTR_ERR(info->regulator); |
3067 | while (--id >= 0) { | ||
3068 | info = &abx500_regulator.info[id]; | ||
3069 | regulator_unregister(info->regulator); | ||
3070 | } | ||
3071 | return err; | ||
3072 | } | 3035 | } |
3073 | 3036 | ||
3074 | return 0; | 3037 | return 0; |
@@ -3095,9 +3058,7 @@ static int ab8500_regulator_probe(struct platform_device *pdev) | |||
3095 | { | 3058 | { |
3096 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); | 3059 | struct ab8500 *ab8500 = dev_get_drvdata(pdev->dev.parent); |
3097 | struct device_node *np = pdev->dev.of_node; | 3060 | struct device_node *np = pdev->dev.of_node; |
3098 | struct ab8500_platform_data *ppdata; | 3061 | int err; |
3099 | struct ab8500_regulator_platform_data *pdata; | ||
3100 | int i, err; | ||
3101 | 3062 | ||
3102 | if (!ab8500) { | 3063 | if (!ab8500) { |
3103 | dev_err(&pdev->dev, "null mfd parent\n"); | 3064 | dev_err(&pdev->dev, "null mfd parent\n"); |
@@ -3106,83 +3067,20 @@ static int ab8500_regulator_probe(struct platform_device *pdev) | |||
3106 | 3067 | ||
3107 | abx500_get_regulator_info(ab8500); | 3068 | abx500_get_regulator_info(ab8500); |
3108 | 3069 | ||
3109 | if (np) { | 3070 | err = of_regulator_match(&pdev->dev, np, |
3110 | err = of_regulator_match(&pdev->dev, np, | 3071 | abx500_regulator.match, |
3111 | abx500_regulator.match, | 3072 | abx500_regulator.match_size); |
3112 | abx500_regulator.match_size); | 3073 | if (err < 0) { |
3113 | if (err < 0) { | 3074 | dev_err(&pdev->dev, |
3114 | dev_err(&pdev->dev, | 3075 | "Error parsing regulator init data: %d\n", err); |
3115 | "Error parsing regulator init data: %d\n", err); | ||
3116 | return err; | ||
3117 | } | ||
3118 | |||
3119 | err = ab8500_regulator_of_probe(pdev, np); | ||
3120 | return err; | ||
3121 | } | ||
3122 | |||
3123 | ppdata = dev_get_platdata(ab8500->dev); | ||
3124 | if (!ppdata) { | ||
3125 | dev_err(&pdev->dev, "null parent pdata\n"); | ||
3126 | return -EINVAL; | ||
3127 | } | ||
3128 | |||
3129 | pdata = ppdata->regulator; | ||
3130 | if (!pdata) { | ||
3131 | dev_err(&pdev->dev, "null pdata\n"); | ||
3132 | return -EINVAL; | ||
3133 | } | ||
3134 | |||
3135 | /* make sure the platform data has the correct size */ | ||
3136 | if (pdata->num_regulator != abx500_regulator.info_size) { | ||
3137 | dev_err(&pdev->dev, "Configuration error: size mismatch.\n"); | ||
3138 | return -EINVAL; | ||
3139 | } | ||
3140 | |||
3141 | /* initialize debug (initial state is recorded with this call) */ | ||
3142 | err = ab8500_regulator_debug_init(pdev); | ||
3143 | if (err) | ||
3144 | return err; | 3076 | return err; |
3145 | |||
3146 | /* initialize registers */ | ||
3147 | for (i = 0; i < pdata->num_reg_init; i++) { | ||
3148 | int id, mask, value; | ||
3149 | |||
3150 | id = pdata->reg_init[i].id; | ||
3151 | mask = pdata->reg_init[i].mask; | ||
3152 | value = pdata->reg_init[i].value; | ||
3153 | |||
3154 | /* check for configuration errors */ | ||
3155 | BUG_ON(id >= abx500_regulator.init_size); | ||
3156 | |||
3157 | err = ab8500_regulator_init_registers(pdev, id, mask, value); | ||
3158 | if (err < 0) | ||
3159 | return err; | ||
3160 | } | 3077 | } |
3161 | 3078 | return ab8500_regulator_of_probe(pdev, np); | |
3162 | /* register all regulators */ | ||
3163 | for (i = 0; i < abx500_regulator.info_size; i++) { | ||
3164 | err = ab8500_regulator_register(pdev, &pdata->regulator[i], | ||
3165 | i, NULL); | ||
3166 | if (err < 0) | ||
3167 | return err; | ||
3168 | } | ||
3169 | |||
3170 | return 0; | ||
3171 | } | 3079 | } |
3172 | 3080 | ||
3173 | static int ab8500_regulator_remove(struct platform_device *pdev) | 3081 | static int ab8500_regulator_remove(struct platform_device *pdev) |
3174 | { | 3082 | { |
3175 | int i, err; | 3083 | int err; |
3176 | |||
3177 | for (i = 0; i < abx500_regulator.info_size; i++) { | ||
3178 | struct ab8500_regulator_info *info = NULL; | ||
3179 | info = &abx500_regulator.info[i]; | ||
3180 | |||
3181 | dev_vdbg(rdev_get_dev(info->regulator), | ||
3182 | "%s-remove\n", info->desc.name); | ||
3183 | |||
3184 | regulator_unregister(info->regulator); | ||
3185 | } | ||
3186 | 3084 | ||
3187 | /* remove regulator debug */ | 3085 | /* remove regulator debug */ |
3188 | err = ab8500_regulator_debug_exit(pdev); | 3086 | err = ab8500_regulator_debug_exit(pdev); |
diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c new file mode 100644 index 000000000000..084cc0819a52 --- /dev/null +++ b/drivers/regulator/act8865-regulator.c | |||
@@ -0,0 +1,349 @@ | |||
1 | /* | ||
2 | * act8865-regulator.c - Voltage regulation for the active-semi ACT8865 | ||
3 | * http://www.active-semi.com/sheets/ACT8865_Datasheet.pdf | ||
4 | * | ||
5 | * Copyright (C) 2013 Atmel Corporation | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/init.h> | ||
20 | #include <linux/i2c.h> | ||
21 | #include <linux/err.h> | ||
22 | #include <linux/platform_device.h> | ||
23 | #include <linux/regulator/driver.h> | ||
24 | #include <linux/regulator/act8865.h> | ||
25 | #include <linux/of.h> | ||
26 | #include <linux/of_device.h> | ||
27 | #include <linux/regulator/of_regulator.h> | ||
28 | #include <linux/regmap.h> | ||
29 | |||
30 | /* | ||
31 | * ACT8865 Global Register Map. | ||
32 | */ | ||
33 | #define ACT8865_SYS_MODE 0x00 | ||
34 | #define ACT8865_SYS_CTRL 0x01 | ||
35 | #define ACT8865_DCDC1_VSET1 0x20 | ||
36 | #define ACT8865_DCDC1_VSET2 0x21 | ||
37 | #define ACT8865_DCDC1_CTRL 0x22 | ||
38 | #define ACT8865_DCDC2_VSET1 0x30 | ||
39 | #define ACT8865_DCDC2_VSET2 0x31 | ||
40 | #define ACT8865_DCDC2_CTRL 0x32 | ||
41 | #define ACT8865_DCDC3_VSET1 0x40 | ||
42 | #define ACT8865_DCDC3_VSET2 0x41 | ||
43 | #define ACT8865_DCDC3_CTRL 0x42 | ||
44 | #define ACT8865_LDO1_VSET 0x50 | ||
45 | #define ACT8865_LDO1_CTRL 0x51 | ||
46 | #define ACT8865_LDO2_VSET 0x54 | ||
47 | #define ACT8865_LDO2_CTRL 0x55 | ||
48 | #define ACT8865_LDO3_VSET 0x60 | ||
49 | #define ACT8865_LDO3_CTRL 0x61 | ||
50 | #define ACT8865_LDO4_VSET 0x64 | ||
51 | #define ACT8865_LDO4_CTRL 0x65 | ||
52 | |||
53 | /* | ||
54 | * Field Definitions. | ||
55 | */ | ||
56 | #define ACT8865_ENA 0x80 /* ON - [7] */ | ||
57 | #define ACT8865_VSEL_MASK 0x3F /* VSET - [5:0] */ | ||
58 | |||
59 | /* | ||
60 | * ACT8865 voltage number | ||
61 | */ | ||
62 | #define ACT8865_VOLTAGE_NUM 64 | ||
63 | |||
64 | struct act8865 { | ||
65 | struct regulator_dev *rdev[ACT8865_REG_NUM]; | ||
66 | struct regmap *regmap; | ||
67 | }; | ||
68 | |||
69 | static const struct regmap_config act8865_regmap_config = { | ||
70 | .reg_bits = 8, | ||
71 | .val_bits = 8, | ||
72 | }; | ||
73 | |||
74 | static const struct regulator_linear_range act8865_volatge_ranges[] = { | ||
75 | REGULATOR_LINEAR_RANGE(600000, 0, 23, 25000), | ||
76 | REGULATOR_LINEAR_RANGE(1200000, 24, 47, 50000), | ||
77 | REGULATOR_LINEAR_RANGE(2400000, 48, 63, 100000), | ||
78 | }; | ||
79 | |||
80 | static struct regulator_ops act8865_ops = { | ||
81 | .list_voltage = regulator_list_voltage_linear_range, | ||
82 | .map_voltage = regulator_map_voltage_linear_range, | ||
83 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
84 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
85 | .enable = regulator_enable_regmap, | ||
86 | .disable = regulator_disable_regmap, | ||
87 | .is_enabled = regulator_is_enabled_regmap, | ||
88 | }; | ||
89 | |||
90 | static const struct regulator_desc act8865_reg[] = { | ||
91 | { | ||
92 | .name = "DCDC_REG1", | ||
93 | .id = ACT8865_ID_DCDC1, | ||
94 | .ops = &act8865_ops, | ||
95 | .type = REGULATOR_VOLTAGE, | ||
96 | .n_voltages = ACT8865_VOLTAGE_NUM, | ||
97 | .linear_ranges = act8865_volatge_ranges, | ||
98 | .n_linear_ranges = ARRAY_SIZE(act8865_volatge_ranges), | ||
99 | .vsel_reg = ACT8865_DCDC1_VSET1, | ||
100 | .vsel_mask = ACT8865_VSEL_MASK, | ||
101 | .enable_reg = ACT8865_DCDC1_CTRL, | ||
102 | .enable_mask = ACT8865_ENA, | ||
103 | .owner = THIS_MODULE, | ||
104 | }, | ||
105 | { | ||
106 | .name = "DCDC_REG2", | ||
107 | .id = ACT8865_ID_DCDC2, | ||
108 | .ops = &act8865_ops, | ||
109 | .type = REGULATOR_VOLTAGE, | ||
110 | .n_voltages = ACT8865_VOLTAGE_NUM, | ||
111 | .linear_ranges = act8865_volatge_ranges, | ||
112 | .n_linear_ranges = ARRAY_SIZE(act8865_volatge_ranges), | ||
113 | .vsel_reg = ACT8865_DCDC2_VSET1, | ||
114 | .vsel_mask = ACT8865_VSEL_MASK, | ||
115 | .enable_reg = ACT8865_DCDC2_CTRL, | ||
116 | .enable_mask = ACT8865_ENA, | ||
117 | .owner = THIS_MODULE, | ||
118 | }, | ||
119 | { | ||
120 | .name = "DCDC_REG3", | ||
121 | .id = ACT8865_ID_DCDC3, | ||
122 | .ops = &act8865_ops, | ||
123 | .type = REGULATOR_VOLTAGE, | ||
124 | .n_voltages = ACT8865_VOLTAGE_NUM, | ||
125 | .linear_ranges = act8865_volatge_ranges, | ||
126 | .n_linear_ranges = ARRAY_SIZE(act8865_volatge_ranges), | ||
127 | .vsel_reg = ACT8865_DCDC3_VSET1, | ||
128 | .vsel_mask = ACT8865_VSEL_MASK, | ||
129 | .enable_reg = ACT8865_DCDC3_CTRL, | ||
130 | .enable_mask = ACT8865_ENA, | ||
131 | .owner = THIS_MODULE, | ||
132 | }, | ||
133 | { | ||
134 | .name = "LDO_REG1", | ||
135 | .id = ACT8865_ID_LDO1, | ||
136 | .ops = &act8865_ops, | ||
137 | .type = REGULATOR_VOLTAGE, | ||
138 | .n_voltages = ACT8865_VOLTAGE_NUM, | ||
139 | .linear_ranges = act8865_volatge_ranges, | ||
140 | .n_linear_ranges = ARRAY_SIZE(act8865_volatge_ranges), | ||
141 | .vsel_reg = ACT8865_LDO1_VSET, | ||
142 | .vsel_mask = ACT8865_VSEL_MASK, | ||
143 | .enable_reg = ACT8865_LDO1_CTRL, | ||
144 | .enable_mask = ACT8865_ENA, | ||
145 | .owner = THIS_MODULE, | ||
146 | }, | ||
147 | { | ||
148 | .name = "LDO_REG2", | ||
149 | .id = ACT8865_ID_LDO2, | ||
150 | .ops = &act8865_ops, | ||
151 | .type = REGULATOR_VOLTAGE, | ||
152 | .n_voltages = ACT8865_VOLTAGE_NUM, | ||
153 | .linear_ranges = act8865_volatge_ranges, | ||
154 | .n_linear_ranges = ARRAY_SIZE(act8865_volatge_ranges), | ||
155 | .vsel_reg = ACT8865_LDO2_VSET, | ||
156 | .vsel_mask = ACT8865_VSEL_MASK, | ||
157 | .enable_reg = ACT8865_LDO2_CTRL, | ||
158 | .enable_mask = ACT8865_ENA, | ||
159 | .owner = THIS_MODULE, | ||
160 | }, | ||
161 | { | ||
162 | .name = "LDO_REG3", | ||
163 | .id = ACT8865_ID_LDO3, | ||
164 | .ops = &act8865_ops, | ||
165 | .type = REGULATOR_VOLTAGE, | ||
166 | .n_voltages = ACT8865_VOLTAGE_NUM, | ||
167 | .linear_ranges = act8865_volatge_ranges, | ||
168 | .n_linear_ranges = ARRAY_SIZE(act8865_volatge_ranges), | ||
169 | .vsel_reg = ACT8865_LDO3_VSET, | ||
170 | .vsel_mask = ACT8865_VSEL_MASK, | ||
171 | .enable_reg = ACT8865_LDO3_CTRL, | ||
172 | .enable_mask = ACT8865_ENA, | ||
173 | .owner = THIS_MODULE, | ||
174 | }, | ||
175 | { | ||
176 | .name = "LDO_REG4", | ||
177 | .id = ACT8865_ID_LDO4, | ||
178 | .ops = &act8865_ops, | ||
179 | .type = REGULATOR_VOLTAGE, | ||
180 | .n_voltages = ACT8865_VOLTAGE_NUM, | ||
181 | .linear_ranges = act8865_volatge_ranges, | ||
182 | .n_linear_ranges = ARRAY_SIZE(act8865_volatge_ranges), | ||
183 | .vsel_reg = ACT8865_LDO4_VSET, | ||
184 | .vsel_mask = ACT8865_VSEL_MASK, | ||
185 | .enable_reg = ACT8865_LDO4_CTRL, | ||
186 | .enable_mask = ACT8865_ENA, | ||
187 | .owner = THIS_MODULE, | ||
188 | }, | ||
189 | }; | ||
190 | |||
191 | #ifdef CONFIG_OF | ||
192 | static const struct of_device_id act8865_dt_ids[] = { | ||
193 | { .compatible = "active-semi,act8865" }, | ||
194 | { } | ||
195 | }; | ||
196 | MODULE_DEVICE_TABLE(of, act8865_dt_ids); | ||
197 | |||
198 | static struct of_regulator_match act8865_matches[] = { | ||
199 | [ACT8865_ID_DCDC1] = { .name = "DCDC_REG1"}, | ||
200 | [ACT8865_ID_DCDC2] = { .name = "DCDC_REG2"}, | ||
201 | [ACT8865_ID_DCDC3] = { .name = "DCDC_REG3"}, | ||
202 | [ACT8865_ID_LDO1] = { .name = "LDO_REG1"}, | ||
203 | [ACT8865_ID_LDO2] = { .name = "LDO_REG2"}, | ||
204 | [ACT8865_ID_LDO3] = { .name = "LDO_REG3"}, | ||
205 | [ACT8865_ID_LDO4] = { .name = "LDO_REG4"}, | ||
206 | }; | ||
207 | |||
208 | static int act8865_pdata_from_dt(struct device *dev, | ||
209 | struct device_node **of_node, | ||
210 | struct act8865_platform_data *pdata) | ||
211 | { | ||
212 | int matched, i; | ||
213 | struct device_node *np; | ||
214 | struct act8865_regulator_data *regulator; | ||
215 | |||
216 | np = of_find_node_by_name(dev->of_node, "regulators"); | ||
217 | if (!np) { | ||
218 | dev_err(dev, "missing 'regulators' subnode in DT\n"); | ||
219 | return -EINVAL; | ||
220 | } | ||
221 | |||
222 | matched = of_regulator_match(dev, np, | ||
223 | act8865_matches, ARRAY_SIZE(act8865_matches)); | ||
224 | if (matched <= 0) | ||
225 | return matched; | ||
226 | |||
227 | pdata->regulators = devm_kzalloc(dev, | ||
228 | sizeof(struct act8865_regulator_data) * | ||
229 | ARRAY_SIZE(act8865_matches), GFP_KERNEL); | ||
230 | if (!pdata->regulators) { | ||
231 | dev_err(dev, "%s: failed to allocate act8865 registor\n", | ||
232 | __func__); | ||
233 | return -ENOMEM; | ||
234 | } | ||
235 | |||
236 | pdata->num_regulators = matched; | ||
237 | regulator = pdata->regulators; | ||
238 | |||
239 | for (i = 0; i < ARRAY_SIZE(act8865_matches); i++) { | ||
240 | regulator->id = i; | ||
241 | regulator->name = act8865_matches[i].name; | ||
242 | regulator->platform_data = act8865_matches[i].init_data; | ||
243 | of_node[i] = act8865_matches[i].of_node; | ||
244 | regulator++; | ||
245 | } | ||
246 | |||
247 | return 0; | ||
248 | } | ||
249 | #else | ||
250 | static inline int act8865_pdata_from_dt(struct device *dev, | ||
251 | struct device_node **of_node, | ||
252 | struct act8865_platform_data *pdata) | ||
253 | { | ||
254 | return 0; | ||
255 | } | ||
256 | #endif | ||
257 | |||
258 | static int act8865_pmic_probe(struct i2c_client *client, | ||
259 | const struct i2c_device_id *i2c_id) | ||
260 | { | ||
261 | struct regulator_dev **rdev; | ||
262 | struct device *dev = &client->dev; | ||
263 | struct act8865_platform_data *pdata = dev_get_platdata(dev); | ||
264 | struct regulator_config config = { }; | ||
265 | struct act8865 *act8865; | ||
266 | struct device_node *of_node[ACT8865_REG_NUM]; | ||
267 | int i, id; | ||
268 | int ret = -EINVAL; | ||
269 | int error; | ||
270 | |||
271 | if (dev->of_node && !pdata) { | ||
272 | const struct of_device_id *id; | ||
273 | struct act8865_platform_data pdata_of; | ||
274 | |||
275 | id = of_match_device(of_match_ptr(act8865_dt_ids), dev); | ||
276 | if (!id) | ||
277 | return -ENODEV; | ||
278 | |||
279 | ret = act8865_pdata_from_dt(dev, of_node, &pdata_of); | ||
280 | if (ret < 0) | ||
281 | return ret; | ||
282 | |||
283 | pdata = &pdata_of; | ||
284 | } | ||
285 | |||
286 | if (pdata->num_regulators > ACT8865_REG_NUM) { | ||
287 | dev_err(dev, "Too many regulators found!\n"); | ||
288 | return -EINVAL; | ||
289 | } | ||
290 | |||
291 | act8865 = devm_kzalloc(dev, sizeof(struct act8865), GFP_KERNEL); | ||
292 | if (!act8865) | ||
293 | return -ENOMEM; | ||
294 | |||
295 | rdev = act8865->rdev; | ||
296 | |||
297 | act8865->regmap = devm_regmap_init_i2c(client, &act8865_regmap_config); | ||
298 | if (IS_ERR(act8865->regmap)) { | ||
299 | error = PTR_ERR(act8865->regmap); | ||
300 | dev_err(&client->dev, "Failed to allocate register map: %d\n", | ||
301 | error); | ||
302 | return error; | ||
303 | } | ||
304 | |||
305 | /* Finally register devices */ | ||
306 | for (i = 0; i < ACT8865_REG_NUM; i++) { | ||
307 | |||
308 | id = pdata->regulators[i].id; | ||
309 | |||
310 | config.dev = dev; | ||
311 | config.init_data = pdata->regulators[i].platform_data; | ||
312 | config.of_node = of_node[i]; | ||
313 | config.driver_data = act8865; | ||
314 | config.regmap = act8865->regmap; | ||
315 | |||
316 | rdev[i] = devm_regulator_register(&client->dev, | ||
317 | &act8865_reg[i], &config); | ||
318 | if (IS_ERR(rdev[i])) { | ||
319 | dev_err(dev, "failed to register %s\n", | ||
320 | act8865_reg[id].name); | ||
321 | return PTR_ERR(rdev[i]); | ||
322 | } | ||
323 | } | ||
324 | |||
325 | i2c_set_clientdata(client, act8865); | ||
326 | |||
327 | return 0; | ||
328 | } | ||
329 | |||
330 | static const struct i2c_device_id act8865_ids[] = { | ||
331 | { "act8865", 0 }, | ||
332 | { }, | ||
333 | }; | ||
334 | MODULE_DEVICE_TABLE(i2c, act8865_ids); | ||
335 | |||
336 | static struct i2c_driver act8865_pmic_driver = { | ||
337 | .driver = { | ||
338 | .name = "act8865", | ||
339 | .owner = THIS_MODULE, | ||
340 | }, | ||
341 | .probe = act8865_pmic_probe, | ||
342 | .id_table = act8865_ids, | ||
343 | }; | ||
344 | |||
345 | module_i2c_driver(act8865_pmic_driver); | ||
346 | |||
347 | MODULE_DESCRIPTION("active-semi act8865 voltage regulator driver"); | ||
348 | MODULE_AUTHOR("Wenyou Yang <wenyou.yang@atmel.com>"); | ||
349 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/regulator/anatop-regulator.c b/drivers/regulator/anatop-regulator.c index c734d0980826..862e63e451d0 100644 --- a/drivers/regulator/anatop-regulator.c +++ b/drivers/regulator/anatop-regulator.c | |||
@@ -122,10 +122,8 @@ static int anatop_regulator_probe(struct platform_device *pdev) | |||
122 | if (!sreg) | 122 | if (!sreg) |
123 | return -ENOMEM; | 123 | return -ENOMEM; |
124 | sreg->initdata = initdata; | 124 | sreg->initdata = initdata; |
125 | sreg->name = kstrdup(of_get_property(np, "regulator-name", NULL), | 125 | sreg->name = of_get_property(np, "regulator-name", NULL); |
126 | GFP_KERNEL); | ||
127 | rdesc = &sreg->rdesc; | 126 | rdesc = &sreg->rdesc; |
128 | memset(rdesc, 0, sizeof(*rdesc)); | ||
129 | rdesc->name = sreg->name; | 127 | rdesc->name = sreg->name; |
130 | rdesc->ops = &anatop_rops; | 128 | rdesc->ops = &anatop_rops; |
131 | rdesc->type = REGULATOR_VOLTAGE; | 129 | rdesc->type = REGULATOR_VOLTAGE; |
@@ -143,37 +141,37 @@ static int anatop_regulator_probe(struct platform_device *pdev) | |||
143 | &sreg->control_reg); | 141 | &sreg->control_reg); |
144 | if (ret) { | 142 | if (ret) { |
145 | dev_err(dev, "no anatop-reg-offset property set\n"); | 143 | dev_err(dev, "no anatop-reg-offset property set\n"); |
146 | goto anatop_probe_end; | 144 | return ret; |
147 | } | 145 | } |
148 | ret = of_property_read_u32(np, "anatop-vol-bit-width", | 146 | ret = of_property_read_u32(np, "anatop-vol-bit-width", |
149 | &sreg->vol_bit_width); | 147 | &sreg->vol_bit_width); |
150 | if (ret) { | 148 | if (ret) { |
151 | dev_err(dev, "no anatop-vol-bit-width property set\n"); | 149 | dev_err(dev, "no anatop-vol-bit-width property set\n"); |
152 | goto anatop_probe_end; | 150 | return ret; |
153 | } | 151 | } |
154 | ret = of_property_read_u32(np, "anatop-vol-bit-shift", | 152 | ret = of_property_read_u32(np, "anatop-vol-bit-shift", |
155 | &sreg->vol_bit_shift); | 153 | &sreg->vol_bit_shift); |
156 | if (ret) { | 154 | if (ret) { |
157 | dev_err(dev, "no anatop-vol-bit-shift property set\n"); | 155 | dev_err(dev, "no anatop-vol-bit-shift property set\n"); |
158 | goto anatop_probe_end; | 156 | return ret; |
159 | } | 157 | } |
160 | ret = of_property_read_u32(np, "anatop-min-bit-val", | 158 | ret = of_property_read_u32(np, "anatop-min-bit-val", |
161 | &sreg->min_bit_val); | 159 | &sreg->min_bit_val); |
162 | if (ret) { | 160 | if (ret) { |
163 | dev_err(dev, "no anatop-min-bit-val property set\n"); | 161 | dev_err(dev, "no anatop-min-bit-val property set\n"); |
164 | goto anatop_probe_end; | 162 | return ret; |
165 | } | 163 | } |
166 | ret = of_property_read_u32(np, "anatop-min-voltage", | 164 | ret = of_property_read_u32(np, "anatop-min-voltage", |
167 | &sreg->min_voltage); | 165 | &sreg->min_voltage); |
168 | if (ret) { | 166 | if (ret) { |
169 | dev_err(dev, "no anatop-min-voltage property set\n"); | 167 | dev_err(dev, "no anatop-min-voltage property set\n"); |
170 | goto anatop_probe_end; | 168 | return ret; |
171 | } | 169 | } |
172 | ret = of_property_read_u32(np, "anatop-max-voltage", | 170 | ret = of_property_read_u32(np, "anatop-max-voltage", |
173 | &sreg->max_voltage); | 171 | &sreg->max_voltage); |
174 | if (ret) { | 172 | if (ret) { |
175 | dev_err(dev, "no anatop-max-voltage property set\n"); | 173 | dev_err(dev, "no anatop-max-voltage property set\n"); |
176 | goto anatop_probe_end; | 174 | return ret; |
177 | } | 175 | } |
178 | 176 | ||
179 | /* read LDO ramp up setting, only for core reg */ | 177 | /* read LDO ramp up setting, only for core reg */ |
@@ -204,27 +202,11 @@ static int anatop_regulator_probe(struct platform_device *pdev) | |||
204 | if (IS_ERR(rdev)) { | 202 | if (IS_ERR(rdev)) { |
205 | dev_err(dev, "failed to register %s\n", | 203 | dev_err(dev, "failed to register %s\n", |
206 | rdesc->name); | 204 | rdesc->name); |
207 | ret = PTR_ERR(rdev); | 205 | return PTR_ERR(rdev); |
208 | goto anatop_probe_end; | ||
209 | } | 206 | } |
210 | 207 | ||
211 | platform_set_drvdata(pdev, rdev); | 208 | platform_set_drvdata(pdev, rdev); |
212 | 209 | ||
213 | anatop_probe_end: | ||
214 | if (ret) | ||
215 | kfree(sreg->name); | ||
216 | |||
217 | return ret; | ||
218 | } | ||
219 | |||
220 | static int anatop_regulator_remove(struct platform_device *pdev) | ||
221 | { | ||
222 | struct regulator_dev *rdev = platform_get_drvdata(pdev); | ||
223 | struct anatop_regulator *sreg = rdev_get_drvdata(rdev); | ||
224 | const char *name = sreg->name; | ||
225 | |||
226 | kfree(name); | ||
227 | |||
228 | return 0; | 210 | return 0; |
229 | } | 211 | } |
230 | 212 | ||
@@ -240,7 +222,6 @@ static struct platform_driver anatop_regulator_driver = { | |||
240 | .of_match_table = of_anatop_regulator_match_tbl, | 222 | .of_match_table = of_anatop_regulator_match_tbl, |
241 | }, | 223 | }, |
242 | .probe = anatop_regulator_probe, | 224 | .probe = anatop_regulator_probe, |
243 | .remove = anatop_regulator_remove, | ||
244 | }; | 225 | }; |
245 | 226 | ||
246 | static int __init anatop_regulator_init(void) | 227 | static int __init anatop_regulator_init(void) |
@@ -259,3 +240,4 @@ MODULE_AUTHOR("Nancy Chen <Nancy.Chen@freescale.com>"); | |||
259 | MODULE_AUTHOR("Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>"); | 240 | MODULE_AUTHOR("Ying-Chun Liu (PaulLiu) <paul.liu@linaro.org>"); |
260 | MODULE_DESCRIPTION("ANATOP Regulator driver"); | 241 | MODULE_DESCRIPTION("ANATOP Regulator driver"); |
261 | MODULE_LICENSE("GPL v2"); | 242 | MODULE_LICENSE("GPL v2"); |
243 | MODULE_ALIAS("platform:anatop_regulator"); | ||
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c index fd3154d86901..034ece707083 100644 --- a/drivers/regulator/arizona-micsupp.c +++ b/drivers/regulator/arizona-micsupp.c | |||
@@ -28,8 +28,6 @@ | |||
28 | #include <linux/mfd/arizona/pdata.h> | 28 | #include <linux/mfd/arizona/pdata.h> |
29 | #include <linux/mfd/arizona/registers.h> | 29 | #include <linux/mfd/arizona/registers.h> |
30 | 30 | ||
31 | #define ARIZONA_MICSUPP_MAX_SELECTOR 0x1f | ||
32 | |||
33 | struct arizona_micsupp { | 31 | struct arizona_micsupp { |
34 | struct regulator_dev *regulator; | 32 | struct regulator_dev *regulator; |
35 | struct arizona *arizona; | 33 | struct arizona *arizona; |
@@ -40,42 +38,6 @@ struct arizona_micsupp { | |||
40 | struct work_struct check_cp_work; | 38 | struct work_struct check_cp_work; |
41 | }; | 39 | }; |
42 | 40 | ||
43 | static int arizona_micsupp_list_voltage(struct regulator_dev *rdev, | ||
44 | unsigned int selector) | ||
45 | { | ||
46 | if (selector > ARIZONA_MICSUPP_MAX_SELECTOR) | ||
47 | return -EINVAL; | ||
48 | |||
49 | if (selector == ARIZONA_MICSUPP_MAX_SELECTOR) | ||
50 | return 3300000; | ||
51 | else | ||
52 | return (selector * 50000) + 1700000; | ||
53 | } | ||
54 | |||
55 | static int arizona_micsupp_map_voltage(struct regulator_dev *rdev, | ||
56 | int min_uV, int max_uV) | ||
57 | { | ||
58 | unsigned int voltage; | ||
59 | int selector; | ||
60 | |||
61 | if (min_uV < 1700000) | ||
62 | min_uV = 1700000; | ||
63 | |||
64 | if (min_uV > 3200000) | ||
65 | selector = ARIZONA_MICSUPP_MAX_SELECTOR; | ||
66 | else | ||
67 | selector = DIV_ROUND_UP(min_uV - 1700000, 50000); | ||
68 | |||
69 | if (selector < 0) | ||
70 | return -EINVAL; | ||
71 | |||
72 | voltage = arizona_micsupp_list_voltage(rdev, selector); | ||
73 | if (voltage < min_uV || voltage > max_uV) | ||
74 | return -EINVAL; | ||
75 | |||
76 | return selector; | ||
77 | } | ||
78 | |||
79 | static void arizona_micsupp_check_cp(struct work_struct *work) | 41 | static void arizona_micsupp_check_cp(struct work_struct *work) |
80 | { | 42 | { |
81 | struct arizona_micsupp *micsupp = | 43 | struct arizona_micsupp *micsupp = |
@@ -145,8 +107,8 @@ static struct regulator_ops arizona_micsupp_ops = { | |||
145 | .disable = arizona_micsupp_disable, | 107 | .disable = arizona_micsupp_disable, |
146 | .is_enabled = regulator_is_enabled_regmap, | 108 | .is_enabled = regulator_is_enabled_regmap, |
147 | 109 | ||
148 | .list_voltage = arizona_micsupp_list_voltage, | 110 | .list_voltage = regulator_list_voltage_linear_range, |
149 | .map_voltage = arizona_micsupp_map_voltage, | 111 | .map_voltage = regulator_map_voltage_linear_range, |
150 | 112 | ||
151 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | 113 | .get_voltage_sel = regulator_get_voltage_sel_regmap, |
152 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | 114 | .set_voltage_sel = regulator_set_voltage_sel_regmap, |
@@ -155,11 +117,16 @@ static struct regulator_ops arizona_micsupp_ops = { | |||
155 | .set_bypass = arizona_micsupp_set_bypass, | 117 | .set_bypass = arizona_micsupp_set_bypass, |
156 | }; | 118 | }; |
157 | 119 | ||
120 | static const struct regulator_linear_range arizona_micsupp_ranges[] = { | ||
121 | REGULATOR_LINEAR_RANGE(1700000, 0, 0x1e, 50000), | ||
122 | REGULATOR_LINEAR_RANGE(3300000, 0x1f, 0x1f, 0), | ||
123 | }; | ||
124 | |||
158 | static const struct regulator_desc arizona_micsupp = { | 125 | static const struct regulator_desc arizona_micsupp = { |
159 | .name = "MICVDD", | 126 | .name = "MICVDD", |
160 | .supply_name = "CPVDD", | 127 | .supply_name = "CPVDD", |
161 | .type = REGULATOR_VOLTAGE, | 128 | .type = REGULATOR_VOLTAGE, |
162 | .n_voltages = ARIZONA_MICSUPP_MAX_SELECTOR + 1, | 129 | .n_voltages = 32, |
163 | .ops = &arizona_micsupp_ops, | 130 | .ops = &arizona_micsupp_ops, |
164 | 131 | ||
165 | .vsel_reg = ARIZONA_LDO2_CONTROL_1, | 132 | .vsel_reg = ARIZONA_LDO2_CONTROL_1, |
@@ -169,6 +136,9 @@ static const struct regulator_desc arizona_micsupp = { | |||
169 | .bypass_reg = ARIZONA_MIC_CHARGE_PUMP_1, | 136 | .bypass_reg = ARIZONA_MIC_CHARGE_PUMP_1, |
170 | .bypass_mask = ARIZONA_CPMIC_BYPASS, | 137 | .bypass_mask = ARIZONA_CPMIC_BYPASS, |
171 | 138 | ||
139 | .linear_ranges = arizona_micsupp_ranges, | ||
140 | .n_linear_ranges = ARRAY_SIZE(arizona_micsupp_ranges), | ||
141 | |||
172 | .enable_time = 3000, | 142 | .enable_time = 3000, |
173 | 143 | ||
174 | .owner = THIS_MODULE, | 144 | .owner = THIS_MODULE, |
diff --git a/drivers/regulator/as3722-regulator.c b/drivers/regulator/as3722-regulator.c index b9f1d24c6812..8b17d786cb71 100644 --- a/drivers/regulator/as3722-regulator.c +++ b/drivers/regulator/as3722-regulator.c | |||
@@ -99,7 +99,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { | |||
99 | .sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK, | 99 | .sleep_ctrl_mask = AS3722_SD0_EXT_ENABLE_MASK, |
100 | .control_reg = AS3722_SD0_CONTROL_REG, | 100 | .control_reg = AS3722_SD0_CONTROL_REG, |
101 | .mode_mask = AS3722_SD0_MODE_FAST, | 101 | .mode_mask = AS3722_SD0_MODE_FAST, |
102 | .n_voltages = AS3722_SD0_VSEL_MAX + 1, | ||
103 | }, | 102 | }, |
104 | { | 103 | { |
105 | .regulator_id = AS3722_REGULATOR_ID_SD1, | 104 | .regulator_id = AS3722_REGULATOR_ID_SD1, |
@@ -112,7 +111,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { | |||
112 | .sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK, | 111 | .sleep_ctrl_mask = AS3722_SD1_EXT_ENABLE_MASK, |
113 | .control_reg = AS3722_SD1_CONTROL_REG, | 112 | .control_reg = AS3722_SD1_CONTROL_REG, |
114 | .mode_mask = AS3722_SD1_MODE_FAST, | 113 | .mode_mask = AS3722_SD1_MODE_FAST, |
115 | .n_voltages = AS3722_SD0_VSEL_MAX + 1, | ||
116 | }, | 114 | }, |
117 | { | 115 | { |
118 | .regulator_id = AS3722_REGULATOR_ID_SD2, | 116 | .regulator_id = AS3722_REGULATOR_ID_SD2, |
@@ -181,7 +179,6 @@ static const struct as3722_register_mapping as3722_reg_lookup[] = { | |||
181 | .sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK, | 179 | .sleep_ctrl_mask = AS3722_SD6_EXT_ENABLE_MASK, |
182 | .control_reg = AS3722_SD6_CONTROL_REG, | 180 | .control_reg = AS3722_SD6_CONTROL_REG, |
183 | .mode_mask = AS3722_SD6_MODE_FAST, | 181 | .mode_mask = AS3722_SD6_MODE_FAST, |
184 | .n_voltages = AS3722_SD0_VSEL_MAX + 1, | ||
185 | }, | 182 | }, |
186 | { | 183 | { |
187 | .regulator_id = AS3722_REGULATOR_ID_LDO0, | 184 | .regulator_id = AS3722_REGULATOR_ID_LDO0, |
@@ -595,6 +592,22 @@ static int as3722_sd016_set_current_limit(struct regulator_dev *rdev, | |||
595 | return as3722_update_bits(as3722, reg, mask, val); | 592 | return as3722_update_bits(as3722, reg, mask, val); |
596 | } | 593 | } |
597 | 594 | ||
595 | static bool as3722_sd0_is_low_voltage(struct as3722_regulators *as3722_regs) | ||
596 | { | ||
597 | int err; | ||
598 | unsigned val; | ||
599 | |||
600 | err = as3722_read(as3722_regs->as3722, AS3722_FUSE7_REG, &val); | ||
601 | if (err < 0) { | ||
602 | dev_err(as3722_regs->dev, "Reg 0x%02x read failed: %d\n", | ||
603 | AS3722_FUSE7_REG, err); | ||
604 | return false; | ||
605 | } | ||
606 | if (val & AS3722_FUSE7_SD0_LOW_VOLTAGE) | ||
607 | return true; | ||
608 | return false; | ||
609 | } | ||
610 | |||
598 | static const struct regulator_linear_range as3722_sd2345_ranges[] = { | 611 | static const struct regulator_linear_range as3722_sd2345_ranges[] = { |
599 | REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500), | 612 | REGULATOR_LINEAR_RANGE(612500, 0x01, 0x40, 12500), |
600 | REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), | 613 | REGULATOR_LINEAR_RANGE(1425000, 0x41, 0x70, 25000), |
@@ -820,9 +833,19 @@ static int as3722_regulator_probe(struct platform_device *pdev) | |||
820 | ops = &as3722_sd016_extcntrl_ops; | 833 | ops = &as3722_sd016_extcntrl_ops; |
821 | else | 834 | else |
822 | ops = &as3722_sd016_ops; | 835 | ops = &as3722_sd016_ops; |
823 | as3722_regs->desc[id].min_uV = 610000; | 836 | if (id == AS3722_REGULATOR_ID_SD0 && |
837 | as3722_sd0_is_low_voltage(as3722_regs)) { | ||
838 | as3722_regs->desc[id].n_voltages = | ||
839 | AS3722_SD0_VSEL_LOW_VOL_MAX + 1; | ||
840 | as3722_regs->desc[id].min_uV = 410000; | ||
841 | } else { | ||
842 | as3722_regs->desc[id].n_voltages = | ||
843 | AS3722_SD0_VSEL_MAX + 1, | ||
844 | as3722_regs->desc[id].min_uV = 610000; | ||
845 | } | ||
824 | as3722_regs->desc[id].uV_step = 10000; | 846 | as3722_regs->desc[id].uV_step = 10000; |
825 | as3722_regs->desc[id].linear_min_sel = 1; | 847 | as3722_regs->desc[id].linear_min_sel = 1; |
848 | as3722_regs->desc[id].enable_time = 600; | ||
826 | break; | 849 | break; |
827 | case AS3722_REGULATOR_ID_SD2: | 850 | case AS3722_REGULATOR_ID_SD2: |
828 | case AS3722_REGULATOR_ID_SD3: | 851 | case AS3722_REGULATOR_ID_SD3: |
@@ -842,9 +865,6 @@ static int as3722_regulator_probe(struct platform_device *pdev) | |||
842 | ops = &as3722_ldo_extcntrl_ops; | 865 | ops = &as3722_ldo_extcntrl_ops; |
843 | else | 866 | else |
844 | ops = &as3722_ldo_ops; | 867 | ops = &as3722_ldo_ops; |
845 | as3722_regs->desc[id].min_uV = 825000; | ||
846 | as3722_regs->desc[id].uV_step = 25000; | ||
847 | as3722_regs->desc[id].linear_min_sel = 1; | ||
848 | as3722_regs->desc[id].enable_time = 500; | 868 | as3722_regs->desc[id].enable_time = 500; |
849 | as3722_regs->desc[id].linear_ranges = as3722_ldo_ranges; | 869 | as3722_regs->desc[id].linear_ranges = as3722_ldo_ranges; |
850 | as3722_regs->desc[id].n_linear_ranges = | 870 | as3722_regs->desc[id].n_linear_ranges = |
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d85f31385b24..b38a6b669e8c 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c | |||
@@ -1334,9 +1334,8 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, | |||
1334 | * If we have return value from dev_lookup fail, we do not expect to | 1334 | * If we have return value from dev_lookup fail, we do not expect to |
1335 | * succeed, so, quit with appropriate error value | 1335 | * succeed, so, quit with appropriate error value |
1336 | */ | 1336 | */ |
1337 | if (ret && ret != -ENODEV) { | 1337 | if (ret && ret != -ENODEV) |
1338 | goto out; | 1338 | goto out; |
1339 | } | ||
1340 | 1339 | ||
1341 | if (!devname) | 1340 | if (!devname) |
1342 | devname = "deviceless"; | 1341 | devname = "deviceless"; |
@@ -1351,7 +1350,8 @@ static struct regulator *_regulator_get(struct device *dev, const char *id, | |||
1351 | 1350 | ||
1352 | rdev = dummy_regulator_rdev; | 1351 | rdev = dummy_regulator_rdev; |
1353 | goto found; | 1352 | goto found; |
1354 | } else { | 1353 | /* Don't log an error when called from regulator_get_optional() */ |
1354 | } else if (!have_full_constraints() || exclusive) { | ||
1355 | dev_err(dev, "dummy supplies not allowed\n"); | 1355 | dev_err(dev, "dummy supplies not allowed\n"); |
1356 | } | 1356 | } |
1357 | 1357 | ||
@@ -2244,7 +2244,7 @@ int regulator_is_supported_voltage(struct regulator *regulator, | |||
2244 | if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { | 2244 | if (!(rdev->constraints->valid_ops_mask & REGULATOR_CHANGE_VOLTAGE)) { |
2245 | ret = regulator_get_voltage(regulator); | 2245 | ret = regulator_get_voltage(regulator); |
2246 | if (ret >= 0) | 2246 | if (ret >= 0) |
2247 | return (min_uV <= ret && ret <= max_uV); | 2247 | return min_uV <= ret && ret <= max_uV; |
2248 | else | 2248 | else |
2249 | return ret; | 2249 | return ret; |
2250 | } | 2250 | } |
@@ -2416,7 +2416,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) | |||
2416 | ret = regulator_check_voltage(rdev, &min_uV, &max_uV); | 2416 | ret = regulator_check_voltage(rdev, &min_uV, &max_uV); |
2417 | if (ret < 0) | 2417 | if (ret < 0) |
2418 | goto out; | 2418 | goto out; |
2419 | 2419 | ||
2420 | /* restore original values in case of error */ | 2420 | /* restore original values in case of error */ |
2421 | old_min_uV = regulator->min_uV; | 2421 | old_min_uV = regulator->min_uV; |
2422 | old_max_uV = regulator->max_uV; | 2422 | old_max_uV = regulator->max_uV; |
@@ -2430,7 +2430,7 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) | |||
2430 | ret = _regulator_do_set_voltage(rdev, min_uV, max_uV); | 2430 | ret = _regulator_do_set_voltage(rdev, min_uV, max_uV); |
2431 | if (ret < 0) | 2431 | if (ret < 0) |
2432 | goto out2; | 2432 | goto out2; |
2433 | 2433 | ||
2434 | out: | 2434 | out: |
2435 | mutex_unlock(&rdev->mutex); | 2435 | mutex_unlock(&rdev->mutex); |
2436 | return ret; | 2436 | return ret; |
@@ -3835,9 +3835,8 @@ static int __init regulator_init_complete(void) | |||
3835 | * goes wrong. */ | 3835 | * goes wrong. */ |
3836 | rdev_info(rdev, "disabling\n"); | 3836 | rdev_info(rdev, "disabling\n"); |
3837 | ret = ops->disable(rdev); | 3837 | ret = ops->disable(rdev); |
3838 | if (ret != 0) { | 3838 | if (ret != 0) |
3839 | rdev_err(rdev, "couldn't disable: %d\n", ret); | 3839 | rdev_err(rdev, "couldn't disable: %d\n", ret); |
3840 | } | ||
3841 | } else { | 3840 | } else { |
3842 | /* The intention is that in future we will | 3841 | /* The intention is that in future we will |
3843 | * assume that full constraints are provided | 3842 | * assume that full constraints are provided |
diff --git a/drivers/regulator/db8500-prcmu.c b/drivers/regulator/db8500-prcmu.c index a53c11a529d5..846acf240e48 100644 --- a/drivers/regulator/db8500-prcmu.c +++ b/drivers/regulator/db8500-prcmu.c | |||
@@ -431,17 +431,11 @@ static int db8500_regulator_register(struct platform_device *pdev, | |||
431 | config.of_node = np; | 431 | config.of_node = np; |
432 | 432 | ||
433 | /* register with the regulator framework */ | 433 | /* register with the regulator framework */ |
434 | info->rdev = regulator_register(&info->desc, &config); | 434 | info->rdev = devm_regulator_register(&pdev->dev, &info->desc, &config); |
435 | if (IS_ERR(info->rdev)) { | 435 | if (IS_ERR(info->rdev)) { |
436 | err = PTR_ERR(info->rdev); | 436 | err = PTR_ERR(info->rdev); |
437 | dev_err(&pdev->dev, "failed to register %s: err %i\n", | 437 | dev_err(&pdev->dev, "failed to register %s: err %i\n", |
438 | info->desc.name, err); | 438 | info->desc.name, err); |
439 | |||
440 | /* if failing, unregister all earlier regulators */ | ||
441 | while (--id >= 0) { | ||
442 | info = &dbx500_regulator_info[id]; | ||
443 | regulator_unregister(info->rdev); | ||
444 | } | ||
445 | return err; | 439 | return err; |
446 | } | 440 | } |
447 | 441 | ||
@@ -530,20 +524,8 @@ static int db8500_regulator_probe(struct platform_device *pdev) | |||
530 | 524 | ||
531 | static int db8500_regulator_remove(struct platform_device *pdev) | 525 | static int db8500_regulator_remove(struct platform_device *pdev) |
532 | { | 526 | { |
533 | int i; | ||
534 | |||
535 | ux500_regulator_debug_exit(); | 527 | ux500_regulator_debug_exit(); |
536 | 528 | ||
537 | for (i = 0; i < ARRAY_SIZE(dbx500_regulator_info); i++) { | ||
538 | struct dbx500_regulator_info *info; | ||
539 | info = &dbx500_regulator_info[i]; | ||
540 | |||
541 | dev_vdbg(rdev_get_dev(info->rdev), | ||
542 | "regulator-%s-remove\n", info->desc.name); | ||
543 | |||
544 | regulator_unregister(info->rdev); | ||
545 | } | ||
546 | |||
547 | return 0; | 529 | return 0; |
548 | } | 530 | } |
549 | 531 | ||
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index 234960dc9607..c0a1d00b78c9 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
@@ -203,17 +203,18 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np) | |||
203 | } | 203 | } |
204 | config->nr_states = i; | 204 | config->nr_states = i; |
205 | 205 | ||
206 | config->type = REGULATOR_VOLTAGE; | ||
206 | ret = of_property_read_string(np, "regulator-type", ®type); | 207 | ret = of_property_read_string(np, "regulator-type", ®type); |
207 | if (ret < 0) { | 208 | if (ret >= 0) { |
208 | dev_err(dev, "Missing 'regulator-type' property\n"); | 209 | if (!strncmp("voltage", regtype, 7)) |
209 | return ERR_PTR(-EINVAL); | 210 | config->type = REGULATOR_VOLTAGE; |
211 | else if (!strncmp("current", regtype, 7)) | ||
212 | config->type = REGULATOR_CURRENT; | ||
213 | else | ||
214 | dev_warn(dev, "Unknown regulator-type '%s'\n", | ||
215 | regtype); | ||
210 | } | 216 | } |
211 | 217 | ||
212 | if (!strncmp("voltage", regtype, 7)) | ||
213 | config->type = REGULATOR_VOLTAGE; | ||
214 | else if (!strncmp("current", regtype, 7)) | ||
215 | config->type = REGULATOR_CURRENT; | ||
216 | |||
217 | return config; | 218 | return config; |
218 | } | 219 | } |
219 | 220 | ||
diff --git a/drivers/regulator/lp3971.c b/drivers/regulator/lp3971.c index 947c05ffe0ab..3b1102b75071 100644 --- a/drivers/regulator/lp3971.c +++ b/drivers/regulator/lp3971.c | |||
@@ -25,8 +25,6 @@ struct lp3971 { | |||
25 | struct device *dev; | 25 | struct device *dev; |
26 | struct mutex io_lock; | 26 | struct mutex io_lock; |
27 | struct i2c_client *i2c; | 27 | struct i2c_client *i2c; |
28 | int num_regulators; | ||
29 | struct regulator_dev **rdev; | ||
30 | }; | 28 | }; |
31 | 29 | ||
32 | static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg); | 30 | static u8 lp3971_reg_read(struct lp3971 *lp3971, u8 reg); |
@@ -383,42 +381,27 @@ static int setup_regulators(struct lp3971 *lp3971, | |||
383 | { | 381 | { |
384 | int i, err; | 382 | int i, err; |
385 | 383 | ||
386 | lp3971->num_regulators = pdata->num_regulators; | ||
387 | lp3971->rdev = kcalloc(pdata->num_regulators, | ||
388 | sizeof(struct regulator_dev *), GFP_KERNEL); | ||
389 | if (!lp3971->rdev) { | ||
390 | err = -ENOMEM; | ||
391 | goto err_nomem; | ||
392 | } | ||
393 | |||
394 | /* Instantiate the regulators */ | 384 | /* Instantiate the regulators */ |
395 | for (i = 0; i < pdata->num_regulators; i++) { | 385 | for (i = 0; i < pdata->num_regulators; i++) { |
396 | struct regulator_config config = { }; | 386 | struct regulator_config config = { }; |
397 | struct lp3971_regulator_subdev *reg = &pdata->regulators[i]; | 387 | struct lp3971_regulator_subdev *reg = &pdata->regulators[i]; |
388 | struct regulator_dev *rdev; | ||
398 | 389 | ||
399 | config.dev = lp3971->dev; | 390 | config.dev = lp3971->dev; |
400 | config.init_data = reg->initdata; | 391 | config.init_data = reg->initdata; |
401 | config.driver_data = lp3971; | 392 | config.driver_data = lp3971; |
402 | 393 | ||
403 | lp3971->rdev[i] = regulator_register(®ulators[reg->id], | 394 | rdev = devm_regulator_register(lp3971->dev, |
404 | &config); | 395 | ®ulators[reg->id], &config); |
405 | if (IS_ERR(lp3971->rdev[i])) { | 396 | if (IS_ERR(rdev)) { |
406 | err = PTR_ERR(lp3971->rdev[i]); | 397 | err = PTR_ERR(rdev); |
407 | dev_err(lp3971->dev, "regulator init failed: %d\n", | 398 | dev_err(lp3971->dev, "regulator init failed: %d\n", |
408 | err); | 399 | err); |
409 | goto error; | 400 | return err; |
410 | } | 401 | } |
411 | } | 402 | } |
412 | 403 | ||
413 | return 0; | 404 | return 0; |
414 | |||
415 | error: | ||
416 | while (--i >= 0) | ||
417 | regulator_unregister(lp3971->rdev[i]); | ||
418 | kfree(lp3971->rdev); | ||
419 | lp3971->rdev = NULL; | ||
420 | err_nomem: | ||
421 | return err; | ||
422 | } | 405 | } |
423 | 406 | ||
424 | static int lp3971_i2c_probe(struct i2c_client *i2c, | 407 | static int lp3971_i2c_probe(struct i2c_client *i2c, |
@@ -460,19 +443,6 @@ static int lp3971_i2c_probe(struct i2c_client *i2c, | |||
460 | return 0; | 443 | return 0; |
461 | } | 444 | } |
462 | 445 | ||
463 | static int lp3971_i2c_remove(struct i2c_client *i2c) | ||
464 | { | ||
465 | struct lp3971 *lp3971 = i2c_get_clientdata(i2c); | ||
466 | int i; | ||
467 | |||
468 | for (i = 0; i < lp3971->num_regulators; i++) | ||
469 | regulator_unregister(lp3971->rdev[i]); | ||
470 | |||
471 | kfree(lp3971->rdev); | ||
472 | |||
473 | return 0; | ||
474 | } | ||
475 | |||
476 | static const struct i2c_device_id lp3971_i2c_id[] = { | 446 | static const struct i2c_device_id lp3971_i2c_id[] = { |
477 | { "lp3971", 0 }, | 447 | { "lp3971", 0 }, |
478 | { } | 448 | { } |
@@ -485,7 +455,6 @@ static struct i2c_driver lp3971_i2c_driver = { | |||
485 | .owner = THIS_MODULE, | 455 | .owner = THIS_MODULE, |
486 | }, | 456 | }, |
487 | .probe = lp3971_i2c_probe, | 457 | .probe = lp3971_i2c_probe, |
488 | .remove = lp3971_i2c_remove, | ||
489 | .id_table = lp3971_i2c_id, | 458 | .id_table = lp3971_i2c_id, |
490 | }; | 459 | }; |
491 | 460 | ||
diff --git a/drivers/regulator/lp3972.c b/drivers/regulator/lp3972.c index 093e6f44ff8a..aea485afcc1a 100644 --- a/drivers/regulator/lp3972.c +++ b/drivers/regulator/lp3972.c | |||
@@ -22,8 +22,6 @@ struct lp3972 { | |||
22 | struct device *dev; | 22 | struct device *dev; |
23 | struct mutex io_lock; | 23 | struct mutex io_lock; |
24 | struct i2c_client *i2c; | 24 | struct i2c_client *i2c; |
25 | int num_regulators; | ||
26 | struct regulator_dev **rdev; | ||
27 | }; | 25 | }; |
28 | 26 | ||
29 | /* LP3972 Control Registers */ | 27 | /* LP3972 Control Registers */ |
@@ -478,41 +476,27 @@ static int setup_regulators(struct lp3972 *lp3972, | |||
478 | { | 476 | { |
479 | int i, err; | 477 | int i, err; |
480 | 478 | ||
481 | lp3972->num_regulators = pdata->num_regulators; | ||
482 | lp3972->rdev = kcalloc(pdata->num_regulators, | ||
483 | sizeof(struct regulator_dev *), GFP_KERNEL); | ||
484 | if (!lp3972->rdev) { | ||
485 | err = -ENOMEM; | ||
486 | goto err_nomem; | ||
487 | } | ||
488 | |||
489 | /* Instantiate the regulators */ | 479 | /* Instantiate the regulators */ |
490 | for (i = 0; i < pdata->num_regulators; i++) { | 480 | for (i = 0; i < pdata->num_regulators; i++) { |
491 | struct lp3972_regulator_subdev *reg = &pdata->regulators[i]; | 481 | struct lp3972_regulator_subdev *reg = &pdata->regulators[i]; |
492 | struct regulator_config config = { }; | 482 | struct regulator_config config = { }; |
483 | struct regulator_dev *rdev; | ||
493 | 484 | ||
494 | config.dev = lp3972->dev; | 485 | config.dev = lp3972->dev; |
495 | config.init_data = reg->initdata; | 486 | config.init_data = reg->initdata; |
496 | config.driver_data = lp3972; | 487 | config.driver_data = lp3972; |
497 | 488 | ||
498 | lp3972->rdev[i] = regulator_register(®ulators[reg->id], | 489 | rdev = devm_regulator_register(lp3972->dev, |
499 | &config); | 490 | ®ulators[reg->id], &config); |
500 | if (IS_ERR(lp3972->rdev[i])) { | 491 | if (IS_ERR(rdev)) { |
501 | err = PTR_ERR(lp3972->rdev[i]); | 492 | err = PTR_ERR(rdev); |
502 | dev_err(lp3972->dev, "regulator init failed: %d\n", | 493 | dev_err(lp3972->dev, "regulator init failed: %d\n", |
503 | err); | 494 | err); |
504 | goto error; | 495 | return err; |
505 | } | 496 | } |
506 | } | 497 | } |
507 | 498 | ||
508 | return 0; | 499 | return 0; |
509 | error: | ||
510 | while (--i >= 0) | ||
511 | regulator_unregister(lp3972->rdev[i]); | ||
512 | kfree(lp3972->rdev); | ||
513 | lp3972->rdev = NULL; | ||
514 | err_nomem: | ||
515 | return err; | ||
516 | } | 500 | } |
517 | 501 | ||
518 | static int lp3972_i2c_probe(struct i2c_client *i2c, | 502 | static int lp3972_i2c_probe(struct i2c_client *i2c, |
@@ -557,18 +541,6 @@ static int lp3972_i2c_probe(struct i2c_client *i2c, | |||
557 | return 0; | 541 | return 0; |
558 | } | 542 | } |
559 | 543 | ||
560 | static int lp3972_i2c_remove(struct i2c_client *i2c) | ||
561 | { | ||
562 | struct lp3972 *lp3972 = i2c_get_clientdata(i2c); | ||
563 | int i; | ||
564 | |||
565 | for (i = 0; i < lp3972->num_regulators; i++) | ||
566 | regulator_unregister(lp3972->rdev[i]); | ||
567 | kfree(lp3972->rdev); | ||
568 | |||
569 | return 0; | ||
570 | } | ||
571 | |||
572 | static const struct i2c_device_id lp3972_i2c_id[] = { | 544 | static const struct i2c_device_id lp3972_i2c_id[] = { |
573 | { "lp3972", 0 }, | 545 | { "lp3972", 0 }, |
574 | { } | 546 | { } |
@@ -581,7 +553,6 @@ static struct i2c_driver lp3972_i2c_driver = { | |||
581 | .owner = THIS_MODULE, | 553 | .owner = THIS_MODULE, |
582 | }, | 554 | }, |
583 | .probe = lp3972_i2c_probe, | 555 | .probe = lp3972_i2c_probe, |
584 | .remove = lp3972_i2c_remove, | ||
585 | .id_table = lp3972_i2c_id, | 556 | .id_table = lp3972_i2c_id, |
586 | }; | 557 | }; |
587 | 558 | ||
diff --git a/drivers/regulator/max14577.c b/drivers/regulator/max14577.c new file mode 100644 index 000000000000..b1078ba3f393 --- /dev/null +++ b/drivers/regulator/max14577.c | |||
@@ -0,0 +1,273 @@ | |||
1 | /* | ||
2 | * max14577.c - Regulator driver for the Maxim 14577 | ||
3 | * | ||
4 | * Copyright (C) 2013 Samsung Electronics | ||
5 | * Krzysztof Kozlowski <k.kozlowski@samsung.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as published by | ||
9 | * the Free Software Foundation; either version 2 of the License, or | ||
10 | * (at your option) any later version. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, | ||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | */ | ||
17 | |||
18 | #include <linux/module.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | #include <linux/regulator/driver.h> | ||
21 | #include <linux/mfd/max14577.h> | ||
22 | #include <linux/mfd/max14577-private.h> | ||
23 | #include <linux/regulator/of_regulator.h> | ||
24 | |||
25 | struct max14577_regulator { | ||
26 | struct device *dev; | ||
27 | struct max14577 *max14577; | ||
28 | struct regulator_dev **regulators; | ||
29 | }; | ||
30 | |||
31 | static int max14577_reg_is_enabled(struct regulator_dev *rdev) | ||
32 | { | ||
33 | int rid = rdev_get_id(rdev); | ||
34 | struct regmap *rmap = rdev->regmap; | ||
35 | u8 reg_data; | ||
36 | |||
37 | switch (rid) { | ||
38 | case MAX14577_CHARGER: | ||
39 | max14577_read_reg(rmap, MAX14577_CHG_REG_CHG_CTRL2, ®_data); | ||
40 | if ((reg_data & CHGCTRL2_MBCHOSTEN_MASK) == 0) | ||
41 | return 0; | ||
42 | max14577_read_reg(rmap, MAX14577_CHG_REG_STATUS3, ®_data); | ||
43 | if ((reg_data & STATUS3_CGMBC_MASK) == 0) | ||
44 | return 0; | ||
45 | /* MBCHOSTEN and CGMBC are on */ | ||
46 | return 1; | ||
47 | default: | ||
48 | return -EINVAL; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | static int max14577_reg_get_current_limit(struct regulator_dev *rdev) | ||
53 | { | ||
54 | u8 reg_data; | ||
55 | struct regmap *rmap = rdev->regmap; | ||
56 | |||
57 | if (rdev_get_id(rdev) != MAX14577_CHARGER) | ||
58 | return -EINVAL; | ||
59 | |||
60 | max14577_read_reg(rmap, MAX14577_CHG_REG_CHG_CTRL4, ®_data); | ||
61 | |||
62 | if ((reg_data & CHGCTRL4_MBCICHWRCL_MASK) == 0) | ||
63 | return MAX14577_REGULATOR_CURRENT_LIMIT_MIN; | ||
64 | |||
65 | reg_data = ((reg_data & CHGCTRL4_MBCICHWRCH_MASK) >> | ||
66 | CHGCTRL4_MBCICHWRCH_SHIFT); | ||
67 | return MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START + | ||
68 | reg_data * MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP; | ||
69 | } | ||
70 | |||
71 | static int max14577_reg_set_current_limit(struct regulator_dev *rdev, | ||
72 | int min_uA, int max_uA) | ||
73 | { | ||
74 | int i, current_bits = 0xf; | ||
75 | u8 reg_data; | ||
76 | |||
77 | if (rdev_get_id(rdev) != MAX14577_CHARGER) | ||
78 | return -EINVAL; | ||
79 | |||
80 | if (min_uA > MAX14577_REGULATOR_CURRENT_LIMIT_MAX || | ||
81 | max_uA < MAX14577_REGULATOR_CURRENT_LIMIT_MIN) | ||
82 | return -EINVAL; | ||
83 | |||
84 | if (max_uA < MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START) { | ||
85 | /* Less than 200 mA, so set 90mA (turn only Low Bit off) */ | ||
86 | u8 reg_data = 0x0 << CHGCTRL4_MBCICHWRCL_SHIFT; | ||
87 | return max14577_update_reg(rdev->regmap, | ||
88 | MAX14577_CHG_REG_CHG_CTRL4, | ||
89 | CHGCTRL4_MBCICHWRCL_MASK, reg_data); | ||
90 | } | ||
91 | |||
92 | /* max_uA is in range: <LIMIT_HIGH_START, inifinite>, so search for | ||
93 | * valid current starting from LIMIT_MAX. */ | ||
94 | for (i = MAX14577_REGULATOR_CURRENT_LIMIT_MAX; | ||
95 | i >= MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START; | ||
96 | i -= MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP) { | ||
97 | if (i <= max_uA) | ||
98 | break; | ||
99 | current_bits--; | ||
100 | } | ||
101 | BUG_ON(current_bits < 0); /* Cannot happen */ | ||
102 | /* Turn Low Bit on (use range 200mA-950 mA) */ | ||
103 | reg_data = 0x1 << CHGCTRL4_MBCICHWRCL_SHIFT; | ||
104 | /* and set proper High Bits */ | ||
105 | reg_data |= current_bits << CHGCTRL4_MBCICHWRCH_SHIFT; | ||
106 | |||
107 | return max14577_update_reg(rdev->regmap, MAX14577_CHG_REG_CHG_CTRL4, | ||
108 | CHGCTRL4_MBCICHWRCL_MASK | CHGCTRL4_MBCICHWRCH_MASK, | ||
109 | reg_data); | ||
110 | } | ||
111 | |||
112 | static struct regulator_ops max14577_safeout_ops = { | ||
113 | .is_enabled = regulator_is_enabled_regmap, | ||
114 | .enable = regulator_enable_regmap, | ||
115 | .disable = regulator_disable_regmap, | ||
116 | .list_voltage = regulator_list_voltage_linear, | ||
117 | }; | ||
118 | |||
119 | static struct regulator_ops max14577_charger_ops = { | ||
120 | .is_enabled = max14577_reg_is_enabled, | ||
121 | .enable = regulator_enable_regmap, | ||
122 | .disable = regulator_disable_regmap, | ||
123 | .get_current_limit = max14577_reg_get_current_limit, | ||
124 | .set_current_limit = max14577_reg_set_current_limit, | ||
125 | }; | ||
126 | |||
127 | static const struct regulator_desc supported_regulators[] = { | ||
128 | [MAX14577_SAFEOUT] = { | ||
129 | .name = "SAFEOUT", | ||
130 | .id = MAX14577_SAFEOUT, | ||
131 | .ops = &max14577_safeout_ops, | ||
132 | .type = REGULATOR_VOLTAGE, | ||
133 | .owner = THIS_MODULE, | ||
134 | .n_voltages = 1, | ||
135 | .min_uV = MAX14577_REGULATOR_SAFEOUT_VOLTAGE, | ||
136 | .enable_reg = MAX14577_REG_CONTROL2, | ||
137 | .enable_mask = CTRL2_SFOUTORD_MASK, | ||
138 | }, | ||
139 | [MAX14577_CHARGER] = { | ||
140 | .name = "CHARGER", | ||
141 | .id = MAX14577_CHARGER, | ||
142 | .ops = &max14577_charger_ops, | ||
143 | .type = REGULATOR_CURRENT, | ||
144 | .owner = THIS_MODULE, | ||
145 | .enable_reg = MAX14577_CHG_REG_CHG_CTRL2, | ||
146 | .enable_mask = CHGCTRL2_MBCHOSTEN_MASK, | ||
147 | }, | ||
148 | }; | ||
149 | |||
150 | #ifdef CONFIG_OF | ||
151 | static struct of_regulator_match max14577_regulator_matches[] = { | ||
152 | { .name = "SAFEOUT", }, | ||
153 | { .name = "CHARGER", }, | ||
154 | }; | ||
155 | |||
156 | static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) | ||
157 | { | ||
158 | int ret; | ||
159 | struct device_node *np; | ||
160 | |||
161 | np = of_get_child_by_name(pdev->dev.parent->of_node, "regulators"); | ||
162 | if (!np) { | ||
163 | dev_err(&pdev->dev, "Failed to get child OF node for regulators\n"); | ||
164 | return -EINVAL; | ||
165 | } | ||
166 | |||
167 | ret = of_regulator_match(&pdev->dev, np, max14577_regulator_matches, | ||
168 | MAX14577_REG_MAX); | ||
169 | if (ret < 0) { | ||
170 | dev_err(&pdev->dev, "Error parsing regulator init data: %d\n", ret); | ||
171 | return ret; | ||
172 | } | ||
173 | |||
174 | return 0; | ||
175 | } | ||
176 | |||
177 | static inline struct regulator_init_data *match_init_data(int index) | ||
178 | { | ||
179 | return max14577_regulator_matches[index].init_data; | ||
180 | } | ||
181 | |||
182 | static inline struct device_node *match_of_node(int index) | ||
183 | { | ||
184 | return max14577_regulator_matches[index].of_node; | ||
185 | } | ||
186 | #else /* CONFIG_OF */ | ||
187 | static int max14577_regulator_dt_parse_pdata(struct platform_device *pdev) | ||
188 | { | ||
189 | return 0; | ||
190 | } | ||
191 | static inline struct regulator_init_data *match_init_data(int index) | ||
192 | { | ||
193 | return NULL; | ||
194 | } | ||
195 | |||
196 | static inline struct device_node *match_of_node(int index) | ||
197 | { | ||
198 | return NULL; | ||
199 | } | ||
200 | #endif /* CONFIG_OF */ | ||
201 | |||
202 | |||
203 | static int max14577_regulator_probe(struct platform_device *pdev) | ||
204 | { | ||
205 | struct max14577 *max14577 = dev_get_drvdata(pdev->dev.parent); | ||
206 | struct max14577_platform_data *pdata = dev_get_platdata(max14577->dev); | ||
207 | int i, ret; | ||
208 | struct regulator_config config = {}; | ||
209 | |||
210 | ret = max14577_regulator_dt_parse_pdata(pdev); | ||
211 | if (ret) | ||
212 | return ret; | ||
213 | |||
214 | config.dev = &pdev->dev; | ||
215 | config.regmap = max14577->regmap; | ||
216 | |||
217 | for (i = 0; i < ARRAY_SIZE(supported_regulators); i++) { | ||
218 | struct regulator_dev *regulator; | ||
219 | /* | ||
220 | * Index of supported_regulators[] is also the id and must | ||
221 | * match index of pdata->regulators[]. | ||
222 | */ | ||
223 | if (pdata && pdata->regulators) { | ||
224 | config.init_data = pdata->regulators[i].initdata; | ||
225 | config.of_node = pdata->regulators[i].of_node; | ||
226 | } else { | ||
227 | config.init_data = match_init_data(i); | ||
228 | config.of_node = match_of_node(i); | ||
229 | } | ||
230 | |||
231 | regulator = devm_regulator_register(&pdev->dev, | ||
232 | &supported_regulators[i], &config); | ||
233 | if (IS_ERR(regulator)) { | ||
234 | ret = PTR_ERR(regulator); | ||
235 | dev_err(&pdev->dev, | ||
236 | "Regulator init failed for ID %d with error: %d\n", | ||
237 | i, ret); | ||
238 | return ret; | ||
239 | } | ||
240 | } | ||
241 | |||
242 | return ret; | ||
243 | } | ||
244 | |||
245 | static struct platform_driver max14577_regulator_driver = { | ||
246 | .driver = { | ||
247 | .owner = THIS_MODULE, | ||
248 | .name = "max14577-regulator", | ||
249 | }, | ||
250 | .probe = max14577_regulator_probe, | ||
251 | }; | ||
252 | |||
253 | static int __init max14577_regulator_init(void) | ||
254 | { | ||
255 | BUILD_BUG_ON(MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_START + | ||
256 | MAX14577_REGULATOR_CURRENT_LIMIT_HIGH_STEP * 0xf != | ||
257 | MAX14577_REGULATOR_CURRENT_LIMIT_MAX); | ||
258 | BUILD_BUG_ON(ARRAY_SIZE(supported_regulators) != MAX14577_REG_MAX); | ||
259 | |||
260 | return platform_driver_register(&max14577_regulator_driver); | ||
261 | } | ||
262 | subsys_initcall(max14577_regulator_init); | ||
263 | |||
264 | static void __exit max14577_regulator_exit(void) | ||
265 | { | ||
266 | platform_driver_unregister(&max14577_regulator_driver); | ||
267 | } | ||
268 | module_exit(max14577_regulator_exit); | ||
269 | |||
270 | MODULE_AUTHOR("Krzysztof Kozlowski <k.kozlowski@samsung.com>"); | ||
271 | MODULE_DESCRIPTION("MAXIM 14577 regulator driver"); | ||
272 | MODULE_LICENSE("GPL"); | ||
273 | MODULE_ALIAS("platform:max14577-regulator"); | ||
diff --git a/drivers/regulator/max77693.c b/drivers/regulator/max77693.c index feb20bf4ccab..5fb899f461d0 100644 --- a/drivers/regulator/max77693.c +++ b/drivers/regulator/max77693.c | |||
@@ -138,6 +138,7 @@ static struct regulator_ops max77693_charger_ops = { | |||
138 | .n_voltages = 4, \ | 138 | .n_voltages = 4, \ |
139 | .ops = &max77693_safeout_ops, \ | 139 | .ops = &max77693_safeout_ops, \ |
140 | .type = REGULATOR_VOLTAGE, \ | 140 | .type = REGULATOR_VOLTAGE, \ |
141 | .owner = THIS_MODULE, \ | ||
141 | .volt_table = max77693_safeout_table, \ | 142 | .volt_table = max77693_safeout_table, \ |
142 | .vsel_reg = MAX77693_CHG_REG_SAFEOUT_CTRL, \ | 143 | .vsel_reg = MAX77693_CHG_REG_SAFEOUT_CTRL, \ |
143 | .vsel_mask = SAFEOUT_CTRL_SAFEOUT##_num##_MASK, \ | 144 | .vsel_mask = SAFEOUT_CTRL_SAFEOUT##_num##_MASK, \ |
diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c index 96c9f80d9550..f374fa57220f 100644 --- a/drivers/regulator/mc13892-regulator.c +++ b/drivers/regulator/mc13892-regulator.c | |||
@@ -274,25 +274,25 @@ static struct mc13xxx_regulator mc13892_regulators[] = { | |||
274 | MC13892_SW_DEFINE(SW4, SWITCHERS3, SWITCHERS3, mc13892_sw), | 274 | MC13892_SW_DEFINE(SW4, SWITCHERS3, SWITCHERS3, mc13892_sw), |
275 | MC13892_FIXED_DEFINE(SWBST, SWITCHERS5, mc13892_swbst), | 275 | MC13892_FIXED_DEFINE(SWBST, SWITCHERS5, mc13892_swbst), |
276 | MC13892_FIXED_DEFINE(VIOHI, REGULATORMODE0, mc13892_viohi), | 276 | MC13892_FIXED_DEFINE(VIOHI, REGULATORMODE0, mc13892_viohi), |
277 | MC13892_DEFINE_REGU(VPLL, REGULATORMODE0, REGULATORSETTING0, \ | 277 | MC13892_DEFINE_REGU(VPLL, REGULATORMODE0, REGULATORSETTING0, |
278 | mc13892_vpll), | 278 | mc13892_vpll), |
279 | MC13892_DEFINE_REGU(VDIG, REGULATORMODE0, REGULATORSETTING0, \ | 279 | MC13892_DEFINE_REGU(VDIG, REGULATORMODE0, REGULATORSETTING0, |
280 | mc13892_vdig), | 280 | mc13892_vdig), |
281 | MC13892_DEFINE_REGU(VSD, REGULATORMODE1, REGULATORSETTING1, \ | 281 | MC13892_DEFINE_REGU(VSD, REGULATORMODE1, REGULATORSETTING1, |
282 | mc13892_vsd), | 282 | mc13892_vsd), |
283 | MC13892_DEFINE_REGU(VUSB2, REGULATORMODE0, REGULATORSETTING0, \ | 283 | MC13892_DEFINE_REGU(VUSB2, REGULATORMODE0, REGULATORSETTING0, |
284 | mc13892_vusb2), | 284 | mc13892_vusb2), |
285 | MC13892_DEFINE_REGU(VVIDEO, REGULATORMODE1, REGULATORSETTING1, \ | 285 | MC13892_DEFINE_REGU(VVIDEO, REGULATORMODE1, REGULATORSETTING1, |
286 | mc13892_vvideo), | 286 | mc13892_vvideo), |
287 | MC13892_DEFINE_REGU(VAUDIO, REGULATORMODE1, REGULATORSETTING1, \ | 287 | MC13892_DEFINE_REGU(VAUDIO, REGULATORMODE1, REGULATORSETTING1, |
288 | mc13892_vaudio), | 288 | mc13892_vaudio), |
289 | MC13892_DEFINE_REGU(VCAM, REGULATORMODE1, REGULATORSETTING0, \ | 289 | MC13892_DEFINE_REGU(VCAM, REGULATORMODE1, REGULATORSETTING0, |
290 | mc13892_vcam), | 290 | mc13892_vcam), |
291 | MC13892_DEFINE_REGU(VGEN1, REGULATORMODE0, REGULATORSETTING0, \ | 291 | MC13892_DEFINE_REGU(VGEN1, REGULATORMODE0, REGULATORSETTING0, |
292 | mc13892_vgen1), | 292 | mc13892_vgen1), |
293 | MC13892_DEFINE_REGU(VGEN2, REGULATORMODE0, REGULATORSETTING0, \ | 293 | MC13892_DEFINE_REGU(VGEN2, REGULATORMODE0, REGULATORSETTING0, |
294 | mc13892_vgen2), | 294 | mc13892_vgen2), |
295 | MC13892_DEFINE_REGU(VGEN3, REGULATORMODE1, REGULATORSETTING0, \ | 295 | MC13892_DEFINE_REGU(VGEN3, REGULATORMODE1, REGULATORSETTING0, |
296 | mc13892_vgen3), | 296 | mc13892_vgen3), |
297 | MC13892_FIXED_DEFINE(VUSB, USB1, mc13892_vusb), | 297 | MC13892_FIXED_DEFINE(VUSB, USB1, mc13892_vusb), |
298 | MC13892_GPO_DEFINE(GPO1, POWERMISC, mc13892_gpo), | 298 | MC13892_GPO_DEFINE(GPO1, POWERMISC, mc13892_gpo), |
@@ -476,8 +476,8 @@ static int mc13892_sw_regulator_set_voltage_sel(struct regulator_dev *rdev, | |||
476 | } | 476 | } |
477 | 477 | ||
478 | mc13xxx_lock(priv->mc13xxx); | 478 | mc13xxx_lock(priv->mc13xxx); |
479 | ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13892_regulators[id].vsel_reg, mask, | 479 | ret = mc13xxx_reg_rmw(priv->mc13xxx, mc13892_regulators[id].vsel_reg, |
480 | reg_value); | 480 | mask, reg_value); |
481 | mc13xxx_unlock(priv->mc13xxx); | 481 | mc13xxx_unlock(priv->mc13xxx); |
482 | 482 | ||
483 | return ret; | 483 | return ret; |
diff --git a/drivers/regulator/pcf50633-regulator.c b/drivers/regulator/pcf50633-regulator.c index d7da1c15a6da..134f90ec9ca1 100644 --- a/drivers/regulator/pcf50633-regulator.c +++ b/drivers/regulator/pcf50633-regulator.c | |||
@@ -105,7 +105,7 @@ static int pcf50633_regulator_probe(struct platform_device *pdev) | |||
105 | 105 | ||
106 | static struct platform_driver pcf50633_regulator_driver = { | 106 | static struct platform_driver pcf50633_regulator_driver = { |
107 | .driver = { | 107 | .driver = { |
108 | .name = "pcf50633-regltr", | 108 | .name = "pcf50633-regulator", |
109 | }, | 109 | }, |
110 | .probe = pcf50633_regulator_probe, | 110 | .probe = pcf50633_regulator_probe, |
111 | }; | 111 | }; |
diff --git a/drivers/regulator/pfuze100-regulator.c b/drivers/regulator/pfuze100-regulator.c index 8b5e4c712a01..ab174f20ca11 100644 --- a/drivers/regulator/pfuze100-regulator.c +++ b/drivers/regulator/pfuze100-regulator.c | |||
@@ -309,21 +309,24 @@ static int pfuze_identify(struct pfuze_chip *pfuze_chip) | |||
309 | return ret; | 309 | return ret; |
310 | 310 | ||
311 | switch (value & 0x0f) { | 311 | switch (value & 0x0f) { |
312 | /* Freescale misprogrammed 1-3% of parts prior to week 8 of 2013 as ID=8 */ | 312 | /* |
313 | case 0x8: | 313 | * Freescale misprogrammed 1-3% of parts prior to week 8 of 2013 |
314 | dev_info(pfuze_chip->dev, "Assuming misprogrammed ID=0x8"); | 314 | * as ID=8 |
315 | case 0x0: | 315 | */ |
316 | break; | 316 | case 0x8: |
317 | default: | 317 | dev_info(pfuze_chip->dev, "Assuming misprogrammed ID=0x8"); |
318 | dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value); | 318 | case 0x0: |
319 | return -ENODEV; | 319 | break; |
320 | default: | ||
321 | dev_warn(pfuze_chip->dev, "Illegal ID: %x\n", value); | ||
322 | return -ENODEV; | ||
320 | } | 323 | } |
321 | 324 | ||
322 | ret = regmap_read(pfuze_chip->regmap, PFUZE100_REVID, &value); | 325 | ret = regmap_read(pfuze_chip->regmap, PFUZE100_REVID, &value); |
323 | if (ret) | 326 | if (ret) |
324 | return ret; | 327 | return ret; |
325 | dev_info(pfuze_chip->dev, | 328 | dev_info(pfuze_chip->dev, |
326 | "Full lay: %x, Metal lay: %x\n", | 329 | "Full layer: %x, Metal layer: %x\n", |
327 | (value & 0xf0) >> 4, value & 0x0f); | 330 | (value & 0xf0) >> 4, value & 0x0f); |
328 | 331 | ||
329 | ret = regmap_read(pfuze_chip->regmap, PFUZE100_FABID, &value); | 332 | ret = regmap_read(pfuze_chip->regmap, PFUZE100_FABID, &value); |
@@ -408,31 +411,18 @@ static int pfuze100_regulator_probe(struct i2c_client *client, | |||
408 | config.driver_data = pfuze_chip; | 411 | config.driver_data = pfuze_chip; |
409 | config.of_node = match_of_node(i); | 412 | config.of_node = match_of_node(i); |
410 | 413 | ||
411 | pfuze_chip->regulators[i] = regulator_register(desc, &config); | 414 | pfuze_chip->regulators[i] = |
415 | devm_regulator_register(&client->dev, desc, &config); | ||
412 | if (IS_ERR(pfuze_chip->regulators[i])) { | 416 | if (IS_ERR(pfuze_chip->regulators[i])) { |
413 | dev_err(&client->dev, "register regulator%s failed\n", | 417 | dev_err(&client->dev, "register regulator%s failed\n", |
414 | pfuze100_regulators[i].desc.name); | 418 | pfuze100_regulators[i].desc.name); |
415 | ret = PTR_ERR(pfuze_chip->regulators[i]); | 419 | return PTR_ERR(pfuze_chip->regulators[i]); |
416 | while (--i >= 0) | ||
417 | regulator_unregister(pfuze_chip->regulators[i]); | ||
418 | return ret; | ||
419 | } | 420 | } |
420 | } | 421 | } |
421 | 422 | ||
422 | return 0; | 423 | return 0; |
423 | } | 424 | } |
424 | 425 | ||
425 | static int pfuze100_regulator_remove(struct i2c_client *client) | ||
426 | { | ||
427 | int i; | ||
428 | struct pfuze_chip *pfuze_chip = i2c_get_clientdata(client); | ||
429 | |||
430 | for (i = 0; i < PFUZE100_MAX_REGULATOR; i++) | ||
431 | regulator_unregister(pfuze_chip->regulators[i]); | ||
432 | |||
433 | return 0; | ||
434 | } | ||
435 | |||
436 | static struct i2c_driver pfuze_driver = { | 426 | static struct i2c_driver pfuze_driver = { |
437 | .id_table = pfuze_device_id, | 427 | .id_table = pfuze_device_id, |
438 | .driver = { | 428 | .driver = { |
@@ -441,7 +431,6 @@ static struct i2c_driver pfuze_driver = { | |||
441 | .of_match_table = pfuze_dt_ids, | 431 | .of_match_table = pfuze_dt_ids, |
442 | }, | 432 | }, |
443 | .probe = pfuze100_regulator_probe, | 433 | .probe = pfuze100_regulator_probe, |
444 | .remove = pfuze100_regulator_remove, | ||
445 | }; | 434 | }; |
446 | module_i2c_driver(pfuze_driver); | 435 | module_i2c_driver(pfuze_driver); |
447 | 436 | ||
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 9e61922d8230..d9e557990577 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
@@ -70,8 +70,6 @@ static int s2mps11_regulator_set_voltage_time_sel(struct regulator_dev *rdev, | |||
70 | ramp_delay = s2mps11->ramp_delay2; | 70 | ramp_delay = s2mps11->ramp_delay2; |
71 | break; | 71 | break; |
72 | case S2MPS11_BUCK3: | 72 | case S2MPS11_BUCK3: |
73 | ramp_delay = s2mps11->ramp_delay34; | ||
74 | break; | ||
75 | case S2MPS11_BUCK4: | 73 | case S2MPS11_BUCK4: |
76 | ramp_delay = s2mps11->ramp_delay34; | 74 | ramp_delay = s2mps11->ramp_delay34; |
77 | break; | 75 | break; |
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index aeb40aad0ae7..d7164bb75d3e 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/mfd/samsung/core.h> | 23 | #include <linux/mfd/samsung/core.h> |
24 | #include <linux/mfd/samsung/s5m8767.h> | 24 | #include <linux/mfd/samsung/s5m8767.h> |
25 | #include <linux/regulator/of_regulator.h> | 25 | #include <linux/regulator/of_regulator.h> |
26 | #include <linux/regmap.h> | ||
26 | 27 | ||
27 | #define S5M8767_OPMODE_NORMAL_MODE 0x1 | 28 | #define S5M8767_OPMODE_NORMAL_MODE 0x1 |
28 | 29 | ||
@@ -120,8 +121,8 @@ static const struct sec_voltage_desc *reg_voltage_map[] = { | |||
120 | [S5M8767_BUCK4] = &buck_voltage_val2, | 121 | [S5M8767_BUCK4] = &buck_voltage_val2, |
121 | [S5M8767_BUCK5] = &buck_voltage_val1, | 122 | [S5M8767_BUCK5] = &buck_voltage_val1, |
122 | [S5M8767_BUCK6] = &buck_voltage_val1, | 123 | [S5M8767_BUCK6] = &buck_voltage_val1, |
123 | [S5M8767_BUCK7] = NULL, | 124 | [S5M8767_BUCK7] = &buck_voltage_val3, |
124 | [S5M8767_BUCK8] = NULL, | 125 | [S5M8767_BUCK8] = &buck_voltage_val3, |
125 | [S5M8767_BUCK9] = &buck_voltage_val3, | 126 | [S5M8767_BUCK9] = &buck_voltage_val3, |
126 | }; | 127 | }; |
127 | 128 | ||
@@ -217,7 +218,7 @@ static int s5m8767_reg_is_enabled(struct regulator_dev *rdev) | |||
217 | { | 218 | { |
218 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); | 219 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); |
219 | int ret, reg; | 220 | int ret, reg; |
220 | int mask = 0xc0, enable_ctrl; | 221 | int enable_ctrl; |
221 | unsigned int val; | 222 | unsigned int val; |
222 | 223 | ||
223 | ret = s5m8767_get_register(rdev, ®, &enable_ctrl); | 224 | ret = s5m8767_get_register(rdev, ®, &enable_ctrl); |
@@ -226,37 +227,38 @@ static int s5m8767_reg_is_enabled(struct regulator_dev *rdev) | |||
226 | else if (ret) | 227 | else if (ret) |
227 | return ret; | 228 | return ret; |
228 | 229 | ||
229 | ret = sec_reg_read(s5m8767->iodev, reg, &val); | 230 | ret = regmap_read(s5m8767->iodev->regmap_pmic, reg, &val); |
230 | if (ret) | 231 | if (ret) |
231 | return ret; | 232 | return ret; |
232 | 233 | ||
233 | return (val & mask) == enable_ctrl; | 234 | return (val & S5M8767_ENCTRL_MASK) == enable_ctrl; |
234 | } | 235 | } |
235 | 236 | ||
236 | static int s5m8767_reg_enable(struct regulator_dev *rdev) | 237 | static int s5m8767_reg_enable(struct regulator_dev *rdev) |
237 | { | 238 | { |
238 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); | 239 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); |
239 | int ret, reg; | 240 | int ret, reg; |
240 | int mask = 0xc0, enable_ctrl; | 241 | int enable_ctrl; |
241 | 242 | ||
242 | ret = s5m8767_get_register(rdev, ®, &enable_ctrl); | 243 | ret = s5m8767_get_register(rdev, ®, &enable_ctrl); |
243 | if (ret) | 244 | if (ret) |
244 | return ret; | 245 | return ret; |
245 | 246 | ||
246 | return sec_reg_update(s5m8767->iodev, reg, enable_ctrl, mask); | 247 | return regmap_update_bits(s5m8767->iodev->regmap_pmic, reg, |
248 | S5M8767_ENCTRL_MASK, enable_ctrl); | ||
247 | } | 249 | } |
248 | 250 | ||
249 | static int s5m8767_reg_disable(struct regulator_dev *rdev) | 251 | static int s5m8767_reg_disable(struct regulator_dev *rdev) |
250 | { | 252 | { |
251 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); | 253 | struct s5m8767_info *s5m8767 = rdev_get_drvdata(rdev); |
252 | int ret, reg; | 254 | int ret, reg, enable_ctrl; |
253 | int mask = 0xc0, enable_ctrl; | ||
254 | 255 | ||
255 | ret = s5m8767_get_register(rdev, ®, &enable_ctrl); | 256 | ret = s5m8767_get_register(rdev, ®, &enable_ctrl); |
256 | if (ret) | 257 | if (ret) |
257 | return ret; | 258 | return ret; |
258 | 259 | ||
259 | return sec_reg_update(s5m8767->iodev, reg, ~mask, mask); | 260 | return regmap_update_bits(s5m8767->iodev->regmap_pmic, reg, |
261 | S5M8767_ENCTRL_MASK, ~S5M8767_ENCTRL_MASK); | ||
260 | } | 262 | } |
261 | 263 | ||
262 | static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767) | 264 | static int s5m8767_get_vsel_reg(int reg_id, struct s5m8767_info *s5m8767) |
@@ -417,9 +419,12 @@ static struct regulator_ops s5m8767_ops = { | |||
417 | }; | 419 | }; |
418 | 420 | ||
419 | static struct regulator_ops s5m8767_buck78_ops = { | 421 | static struct regulator_ops s5m8767_buck78_ops = { |
422 | .list_voltage = regulator_list_voltage_linear, | ||
420 | .is_enabled = s5m8767_reg_is_enabled, | 423 | .is_enabled = s5m8767_reg_is_enabled, |
421 | .enable = s5m8767_reg_enable, | 424 | .enable = s5m8767_reg_enable, |
422 | .disable = s5m8767_reg_disable, | 425 | .disable = s5m8767_reg_disable, |
426 | .get_voltage_sel = regulator_get_voltage_sel_regmap, | ||
427 | .set_voltage_sel = regulator_set_voltage_sel_regmap, | ||
423 | }; | 428 | }; |
424 | 429 | ||
425 | #define s5m8767_regulator_desc(_name) { \ | 430 | #define s5m8767_regulator_desc(_name) { \ |
@@ -745,17 +750,20 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
745 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, | 750 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, |
746 | pdata->buck2_init); | 751 | pdata->buck2_init); |
747 | 752 | ||
748 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS2, buck_init); | 753 | regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK2DVS2, |
754 | buck_init); | ||
749 | 755 | ||
750 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, | 756 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, |
751 | pdata->buck3_init); | 757 | pdata->buck3_init); |
752 | 758 | ||
753 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS2, buck_init); | 759 | regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK3DVS2, |
760 | buck_init); | ||
754 | 761 | ||
755 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, | 762 | buck_init = s5m8767_convert_voltage_to_sel(&buck_voltage_val2, |
756 | pdata->buck4_init); | 763 | pdata->buck4_init); |
757 | 764 | ||
758 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS2, buck_init); | 765 | regmap_write(s5m8767->iodev->regmap_pmic, S5M8767_REG_BUCK4DVS2, |
766 | buck_init); | ||
759 | 767 | ||
760 | for (i = 0; i < 8; i++) { | 768 | for (i = 0; i < 8; i++) { |
761 | if (s5m8767->buck2_gpiodvs) { | 769 | if (s5m8767->buck2_gpiodvs) { |
@@ -837,71 +845,76 @@ static int s5m8767_pmic_probe(struct platform_device *pdev) | |||
837 | 845 | ||
838 | if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || | 846 | if (pdata->buck2_gpiodvs || pdata->buck3_gpiodvs || |
839 | pdata->buck4_gpiodvs) { | 847 | pdata->buck4_gpiodvs) { |
840 | sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK2CTRL, | 848 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
841 | (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1), | 849 | S5M8767_REG_BUCK2CTRL, 1 << 1, |
842 | 1 << 1); | 850 | (pdata->buck2_gpiodvs) ? (1 << 1) : (0 << 1)); |
843 | sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK3CTRL, | 851 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
844 | (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1), | 852 | S5M8767_REG_BUCK3CTRL, 1 << 1, |
845 | 1 << 1); | 853 | (pdata->buck3_gpiodvs) ? (1 << 1) : (0 << 1)); |
846 | sec_reg_update(s5m8767->iodev, S5M8767_REG_BUCK4CTRL, | 854 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
847 | (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1), | 855 | S5M8767_REG_BUCK4CTRL, 1 << 1, |
848 | 1 << 1); | 856 | (pdata->buck4_gpiodvs) ? (1 << 1) : (0 << 1)); |
849 | } | 857 | } |
850 | 858 | ||
851 | /* Initialize GPIO DVS registers */ | 859 | /* Initialize GPIO DVS registers */ |
852 | for (i = 0; i < 8; i++) { | 860 | for (i = 0; i < 8; i++) { |
853 | if (s5m8767->buck2_gpiodvs) { | 861 | if (s5m8767->buck2_gpiodvs) { |
854 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK2DVS1 + i, | 862 | regmap_write(s5m8767->iodev->regmap_pmic, |
855 | s5m8767->buck2_vol[i]); | 863 | S5M8767_REG_BUCK2DVS1 + i, |
864 | s5m8767->buck2_vol[i]); | ||
856 | } | 865 | } |
857 | 866 | ||
858 | if (s5m8767->buck3_gpiodvs) { | 867 | if (s5m8767->buck3_gpiodvs) { |
859 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK3DVS1 + i, | 868 | regmap_write(s5m8767->iodev->regmap_pmic, |
860 | s5m8767->buck3_vol[i]); | 869 | S5M8767_REG_BUCK3DVS1 + i, |
870 | s5m8767->buck3_vol[i]); | ||
861 | } | 871 | } |
862 | 872 | ||
863 | if (s5m8767->buck4_gpiodvs) { | 873 | if (s5m8767->buck4_gpiodvs) { |
864 | sec_reg_write(s5m8767->iodev, S5M8767_REG_BUCK4DVS1 + i, | 874 | regmap_write(s5m8767->iodev->regmap_pmic, |
865 | s5m8767->buck4_vol[i]); | 875 | S5M8767_REG_BUCK4DVS1 + i, |
876 | s5m8767->buck4_vol[i]); | ||
866 | } | 877 | } |
867 | } | 878 | } |
868 | 879 | ||
869 | if (s5m8767->buck2_ramp) | 880 | if (s5m8767->buck2_ramp) |
870 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x08, 0x08); | 881 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
882 | S5M8767_REG_DVSRAMP, 0x08, 0x08); | ||
871 | 883 | ||
872 | if (s5m8767->buck3_ramp) | 884 | if (s5m8767->buck3_ramp) |
873 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x04, 0x04); | 885 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
886 | S5M8767_REG_DVSRAMP, 0x04, 0x04); | ||
874 | 887 | ||
875 | if (s5m8767->buck4_ramp) | 888 | if (s5m8767->buck4_ramp) |
876 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, 0x02, 0x02); | 889 | regmap_update_bits(s5m8767->iodev->regmap_pmic, |
890 | S5M8767_REG_DVSRAMP, 0x02, 0x02); | ||
877 | 891 | ||
878 | if (s5m8767->buck2_ramp || s5m8767->buck3_ramp | 892 | if (s5m8767->buck2_ramp || s5m8767->buck3_ramp |
879 | || s5m8767->buck4_ramp) { | 893 | || s5m8767->buck4_ramp) { |
894 | unsigned int val; | ||
880 | switch (s5m8767->ramp_delay) { | 895 | switch (s5m8767->ramp_delay) { |
881 | case 5: | 896 | case 5: |
882 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, | 897 | val = S5M8767_DVS_BUCK_RAMP_5; |
883 | 0x40, 0xf0); | ||
884 | break; | 898 | break; |
885 | case 10: | 899 | case 10: |
886 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, | 900 | val = S5M8767_DVS_BUCK_RAMP_10; |
887 | 0x90, 0xf0); | ||
888 | break; | 901 | break; |
889 | case 25: | 902 | case 25: |
890 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, | 903 | val = S5M8767_DVS_BUCK_RAMP_25; |
891 | 0xd0, 0xf0); | ||
892 | break; | 904 | break; |
893 | case 50: | 905 | case 50: |
894 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, | 906 | val = S5M8767_DVS_BUCK_RAMP_50; |
895 | 0xe0, 0xf0); | ||
896 | break; | 907 | break; |
897 | case 100: | 908 | case 100: |
898 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, | 909 | val = S5M8767_DVS_BUCK_RAMP_100; |
899 | 0xf0, 0xf0); | ||
900 | break; | 910 | break; |
901 | default: | 911 | default: |
902 | sec_reg_update(s5m8767->iodev, S5M8767_REG_DVSRAMP, | 912 | val = S5M8767_DVS_BUCK_RAMP_10; |
903 | 0x90, 0xf0); | ||
904 | } | 913 | } |
914 | regmap_update_bits(s5m8767->iodev->regmap_pmic, | ||
915 | S5M8767_REG_DVSRAMP, | ||
916 | S5M8767_DVS_BUCK_RAMP_MASK, | ||
917 | val << S5M8767_DVS_BUCK_RAMP_SHIFT); | ||
905 | } | 918 | } |
906 | 919 | ||
907 | for (i = 0; i < pdata->num_regulators; i++) { | 920 | for (i = 0; i < pdata->num_regulators; i++) { |
diff --git a/drivers/regulator/stw481x-vmmc.c b/drivers/regulator/stw481x-vmmc.c index f78857bd6a15..a7e152696a02 100644 --- a/drivers/regulator/stw481x-vmmc.c +++ b/drivers/regulator/stw481x-vmmc.c | |||
@@ -74,7 +74,8 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) | |||
74 | config.init_data = of_get_regulator_init_data(&pdev->dev, | 74 | config.init_data = of_get_regulator_init_data(&pdev->dev, |
75 | pdev->dev.of_node); | 75 | pdev->dev.of_node); |
76 | 76 | ||
77 | stw481x->vmmc_regulator = regulator_register(&vmmc_regulator, &config); | 77 | stw481x->vmmc_regulator = devm_regulator_register(&pdev->dev, |
78 | &vmmc_regulator, &config); | ||
78 | if (IS_ERR(stw481x->vmmc_regulator)) { | 79 | if (IS_ERR(stw481x->vmmc_regulator)) { |
79 | dev_err(&pdev->dev, | 80 | dev_err(&pdev->dev, |
80 | "error initializing STw481x VMMC regulator\n"); | 81 | "error initializing STw481x VMMC regulator\n"); |
@@ -85,14 +86,6 @@ static int stw481x_vmmc_regulator_probe(struct platform_device *pdev) | |||
85 | return 0; | 86 | return 0; |
86 | } | 87 | } |
87 | 88 | ||
88 | static int stw481x_vmmc_regulator_remove(struct platform_device *pdev) | ||
89 | { | ||
90 | struct stw481x *stw481x = dev_get_platdata(&pdev->dev); | ||
91 | |||
92 | regulator_unregister(stw481x->vmmc_regulator); | ||
93 | return 0; | ||
94 | } | ||
95 | |||
96 | static const struct of_device_id stw481x_vmmc_match[] = { | 89 | static const struct of_device_id stw481x_vmmc_match[] = { |
97 | { .compatible = "st,stw481x-vmmc", }, | 90 | { .compatible = "st,stw481x-vmmc", }, |
98 | {}, | 91 | {}, |
@@ -105,7 +98,6 @@ static struct platform_driver stw481x_vmmc_regulator_driver = { | |||
105 | .of_match_table = stw481x_vmmc_match, | 98 | .of_match_table = stw481x_vmmc_match, |
106 | }, | 99 | }, |
107 | .probe = stw481x_vmmc_regulator_probe, | 100 | .probe = stw481x_vmmc_regulator_probe, |
108 | .remove = stw481x_vmmc_regulator_remove, | ||
109 | }; | 101 | }; |
110 | 102 | ||
111 | module_platform_driver(stw481x_vmmc_regulator_driver); | 103 | module_platform_driver(stw481x_vmmc_regulator_driver); |
diff --git a/drivers/regulator/tps51632-regulator.c b/drivers/regulator/tps51632-regulator.c index b0a3f0917a27..b3764f594ee9 100644 --- a/drivers/regulator/tps51632-regulator.c +++ b/drivers/regulator/tps51632-regulator.c | |||
@@ -70,16 +70,16 @@ | |||
70 | #define TPS51632_POWER_STATE_SINGLE_PHASE_CCM 0x1 | 70 | #define TPS51632_POWER_STATE_SINGLE_PHASE_CCM 0x1 |
71 | #define TPS51632_POWER_STATE_SINGLE_PHASE_DCM 0x2 | 71 | #define TPS51632_POWER_STATE_SINGLE_PHASE_DCM 0x2 |
72 | 72 | ||
73 | #define TPS51632_MIN_VOLATGE 500000 | 73 | #define TPS51632_MIN_VOLTAGE 500000 |
74 | #define TPS51632_MAX_VOLATGE 1520000 | 74 | #define TPS51632_MAX_VOLTAGE 1520000 |
75 | #define TPS51632_VOLATGE_STEP_10mV 10000 | 75 | #define TPS51632_VOLTAGE_STEP_10mV 10000 |
76 | #define TPS51632_VOLATGE_STEP_20mV 20000 | 76 | #define TPS51632_VOLTAGE_STEP_20mV 20000 |
77 | #define TPS51632_MAX_VSEL 0x7F | 77 | #define TPS51632_MAX_VSEL 0x7F |
78 | #define TPS51632_MIN_VSEL 0x19 | 78 | #define TPS51632_MIN_VSEL 0x19 |
79 | #define TPS51632_DEFAULT_RAMP_DELAY 6000 | 79 | #define TPS51632_DEFAULT_RAMP_DELAY 6000 |
80 | #define TPS51632_VOLT_VSEL(uV) \ | 80 | #define TPS51632_VOLT_VSEL(uV) \ |
81 | (DIV_ROUND_UP(uV - TPS51632_MIN_VOLATGE, \ | 81 | (DIV_ROUND_UP(uV - TPS51632_MIN_VOLTAGE, \ |
82 | TPS51632_VOLATGE_STEP_10mV) + \ | 82 | TPS51632_VOLTAGE_STEP_10mV) + \ |
83 | TPS51632_MIN_VSEL) | 83 | TPS51632_MIN_VSEL) |
84 | 84 | ||
85 | /* TPS51632 chip information */ | 85 | /* TPS51632 chip information */ |
@@ -243,9 +243,9 @@ static struct tps51632_regulator_platform_data * | |||
243 | pdata->dvfs_step_20mV = of_property_read_bool(np, "ti,dvfs-step-20mV"); | 243 | pdata->dvfs_step_20mV = of_property_read_bool(np, "ti,dvfs-step-20mV"); |
244 | 244 | ||
245 | pdata->base_voltage_uV = pdata->reg_init_data->constraints.min_uV ? : | 245 | pdata->base_voltage_uV = pdata->reg_init_data->constraints.min_uV ? : |
246 | TPS51632_MIN_VOLATGE; | 246 | TPS51632_MIN_VOLTAGE; |
247 | pdata->max_voltage_uV = pdata->reg_init_data->constraints.max_uV ? : | 247 | pdata->max_voltage_uV = pdata->reg_init_data->constraints.max_uV ? : |
248 | TPS51632_MAX_VOLATGE; | 248 | TPS51632_MAX_VOLTAGE; |
249 | return pdata; | 249 | return pdata; |
250 | } | 250 | } |
251 | #else | 251 | #else |
@@ -284,15 +284,15 @@ static int tps51632_probe(struct i2c_client *client, | |||
284 | } | 284 | } |
285 | 285 | ||
286 | if (pdata->enable_pwm_dvfs) { | 286 | if (pdata->enable_pwm_dvfs) { |
287 | if ((pdata->base_voltage_uV < TPS51632_MIN_VOLATGE) || | 287 | if ((pdata->base_voltage_uV < TPS51632_MIN_VOLTAGE) || |
288 | (pdata->base_voltage_uV > TPS51632_MAX_VOLATGE)) { | 288 | (pdata->base_voltage_uV > TPS51632_MAX_VOLTAGE)) { |
289 | dev_err(&client->dev, "Invalid base_voltage_uV setting\n"); | 289 | dev_err(&client->dev, "Invalid base_voltage_uV setting\n"); |
290 | return -EINVAL; | 290 | return -EINVAL; |
291 | } | 291 | } |
292 | 292 | ||
293 | if ((pdata->max_voltage_uV) && | 293 | if ((pdata->max_voltage_uV) && |
294 | ((pdata->max_voltage_uV < TPS51632_MIN_VOLATGE) || | 294 | ((pdata->max_voltage_uV < TPS51632_MIN_VOLTAGE) || |
295 | (pdata->max_voltage_uV > TPS51632_MAX_VOLATGE))) { | 295 | (pdata->max_voltage_uV > TPS51632_MAX_VOLTAGE))) { |
296 | dev_err(&client->dev, "Invalid max_voltage_uV setting\n"); | 296 | dev_err(&client->dev, "Invalid max_voltage_uV setting\n"); |
297 | return -EINVAL; | 297 | return -EINVAL; |
298 | } | 298 | } |
@@ -305,11 +305,11 @@ static int tps51632_probe(struct i2c_client *client, | |||
305 | } | 305 | } |
306 | 306 | ||
307 | tps->dev = &client->dev; | 307 | tps->dev = &client->dev; |
308 | tps->desc.name = id->name; | 308 | tps->desc.name = client->name; |
309 | tps->desc.id = 0; | 309 | tps->desc.id = 0; |
310 | tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; | 310 | tps->desc.ramp_delay = TPS51632_DEFAULT_RAMP_DELAY; |
311 | tps->desc.min_uV = TPS51632_MIN_VOLATGE; | 311 | tps->desc.min_uV = TPS51632_MIN_VOLTAGE; |
312 | tps->desc.uV_step = TPS51632_VOLATGE_STEP_10mV; | 312 | tps->desc.uV_step = TPS51632_VOLTAGE_STEP_10mV; |
313 | tps->desc.linear_min_sel = TPS51632_MIN_VSEL; | 313 | tps->desc.linear_min_sel = TPS51632_MIN_VSEL; |
314 | tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; | 314 | tps->desc.n_voltages = TPS51632_MAX_VSEL + 1; |
315 | tps->desc.ops = &tps51632_dcdc_ops; | 315 | tps->desc.ops = &tps51632_dcdc_ops; |
diff --git a/drivers/regulator/tps62360-regulator.c b/drivers/regulator/tps62360-regulator.c index c2c0185a2dcd..c3fa15a299b1 100644 --- a/drivers/regulator/tps62360-regulator.c +++ b/drivers/regulator/tps62360-regulator.c | |||
@@ -360,7 +360,7 @@ static int tps62360_probe(struct i2c_client *client, | |||
360 | dev_err(&client->dev, "Error: No device match found\n"); | 360 | dev_err(&client->dev, "Error: No device match found\n"); |
361 | return -ENODEV; | 361 | return -ENODEV; |
362 | } | 362 | } |
363 | chip_id = (int)match->data; | 363 | chip_id = (int)(long)match->data; |
364 | if (!pdata) | 364 | if (!pdata) |
365 | pdata = of_get_tps62360_platform_data(&client->dev); | 365 | pdata = of_get_tps62360_platform_data(&client->dev); |
366 | } else if (id) { | 366 | } else if (id) { |
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index a00132e31ec7..f50dd847eebc 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
@@ -88,6 +88,11 @@ static const unsigned int VMMC_VSEL_table[] = { | |||
88 | 1800000, 2800000, 3000000, 3300000, | 88 | 1800000, 2800000, 3000000, 3300000, |
89 | }; | 89 | }; |
90 | 90 | ||
91 | /* supported BBCH voltages in microvolts */ | ||
92 | static const unsigned int VBB_VSEL_table[] = { | ||
93 | 3000000, 2520000, 3150000, 5000000, | ||
94 | }; | ||
95 | |||
91 | struct tps_info { | 96 | struct tps_info { |
92 | const char *name; | 97 | const char *name; |
93 | const char *vin_name; | 98 | const char *vin_name; |
@@ -183,6 +188,12 @@ static struct tps_info tps65910_regs[] = { | |||
183 | .voltage_table = VMMC_VSEL_table, | 188 | .voltage_table = VMMC_VSEL_table, |
184 | .enable_time_us = 100, | 189 | .enable_time_us = 100, |
185 | }, | 190 | }, |
191 | { | ||
192 | .name = "vbb", | ||
193 | .vin_name = "vcc7", | ||
194 | .n_voltages = ARRAY_SIZE(VBB_VSEL_table), | ||
195 | .voltage_table = VBB_VSEL_table, | ||
196 | }, | ||
186 | }; | 197 | }; |
187 | 198 | ||
188 | static struct tps_info tps65911_regs[] = { | 199 | static struct tps_info tps65911_regs[] = { |
@@ -339,6 +350,8 @@ static int tps65910_get_ctrl_register(int id) | |||
339 | return TPS65910_VAUX33; | 350 | return TPS65910_VAUX33; |
340 | case TPS65910_REG_VMMC: | 351 | case TPS65910_REG_VMMC: |
341 | return TPS65910_VMMC; | 352 | return TPS65910_VMMC; |
353 | case TPS65910_REG_VBB: | ||
354 | return TPS65910_BBCH; | ||
342 | default: | 355 | default: |
343 | return -EINVAL; | 356 | return -EINVAL; |
344 | } | 357 | } |
@@ -528,6 +541,10 @@ static int tps65910_get_voltage_sel(struct regulator_dev *dev) | |||
528 | value &= LDO_SEL_MASK; | 541 | value &= LDO_SEL_MASK; |
529 | value >>= LDO_SEL_SHIFT; | 542 | value >>= LDO_SEL_SHIFT; |
530 | break; | 543 | break; |
544 | case TPS65910_REG_VBB: | ||
545 | value &= BBCH_BBSEL_MASK; | ||
546 | value >>= BBCH_BBSEL_SHIFT; | ||
547 | break; | ||
531 | default: | 548 | default: |
532 | return -EINVAL; | 549 | return -EINVAL; |
533 | } | 550 | } |
@@ -638,6 +655,9 @@ static int tps65910_set_voltage_sel(struct regulator_dev *dev, | |||
638 | case TPS65910_REG_VMMC: | 655 | case TPS65910_REG_VMMC: |
639 | return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, | 656 | return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, |
640 | selector << LDO_SEL_SHIFT); | 657 | selector << LDO_SEL_SHIFT); |
658 | case TPS65910_REG_VBB: | ||
659 | return tps65910_reg_update_bits(pmic->mfd, reg, BBCH_BBSEL_MASK, | ||
660 | selector << BBCH_BBSEL_SHIFT); | ||
641 | } | 661 | } |
642 | 662 | ||
643 | return -EINVAL; | 663 | return -EINVAL; |
@@ -669,6 +689,9 @@ static int tps65911_set_voltage_sel(struct regulator_dev *dev, | |||
669 | case TPS65910_REG_VIO: | 689 | case TPS65910_REG_VIO: |
670 | return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, | 690 | return tps65910_reg_update_bits(pmic->mfd, reg, LDO_SEL_MASK, |
671 | selector << LDO_SEL_SHIFT); | 691 | selector << LDO_SEL_SHIFT); |
692 | case TPS65910_REG_VBB: | ||
693 | return tps65910_reg_update_bits(pmic->mfd, reg, BBCH_BBSEL_MASK, | ||
694 | selector << BBCH_BBSEL_SHIFT); | ||
672 | } | 695 | } |
673 | 696 | ||
674 | return -EINVAL; | 697 | return -EINVAL; |
@@ -762,6 +785,18 @@ static struct regulator_ops tps65910_ops_vdd3 = { | |||
762 | .map_voltage = regulator_map_voltage_ascend, | 785 | .map_voltage = regulator_map_voltage_ascend, |
763 | }; | 786 | }; |
764 | 787 | ||
788 | static struct regulator_ops tps65910_ops_vbb = { | ||
789 | .is_enabled = regulator_is_enabled_regmap, | ||
790 | .enable = regulator_enable_regmap, | ||
791 | .disable = regulator_disable_regmap, | ||
792 | .set_mode = tps65910_set_mode, | ||
793 | .get_mode = tps65910_get_mode, | ||
794 | .get_voltage_sel = tps65910_get_voltage_sel, | ||
795 | .set_voltage_sel = tps65910_set_voltage_sel, | ||
796 | .list_voltage = regulator_list_voltage_table, | ||
797 | .map_voltage = regulator_map_voltage_iterate, | ||
798 | }; | ||
799 | |||
765 | static struct regulator_ops tps65910_ops = { | 800 | static struct regulator_ops tps65910_ops = { |
766 | .is_enabled = regulator_is_enabled_regmap, | 801 | .is_enabled = regulator_is_enabled_regmap, |
767 | .enable = regulator_enable_regmap, | 802 | .enable = regulator_enable_regmap, |
@@ -944,6 +979,7 @@ static struct of_regulator_match tps65910_matches[] = { | |||
944 | { .name = "vaux2", .driver_data = (void *) &tps65910_regs[10] }, | 979 | { .name = "vaux2", .driver_data = (void *) &tps65910_regs[10] }, |
945 | { .name = "vaux33", .driver_data = (void *) &tps65910_regs[11] }, | 980 | { .name = "vaux33", .driver_data = (void *) &tps65910_regs[11] }, |
946 | { .name = "vmmc", .driver_data = (void *) &tps65910_regs[12] }, | 981 | { .name = "vmmc", .driver_data = (void *) &tps65910_regs[12] }, |
982 | { .name = "vbb", .driver_data = (void *) &tps65910_regs[13] }, | ||
947 | }; | 983 | }; |
948 | 984 | ||
949 | static struct of_regulator_match tps65911_matches[] = { | 985 | static struct of_regulator_match tps65911_matches[] = { |
@@ -1145,6 +1181,10 @@ static int tps65910_probe(struct platform_device *pdev) | |||
1145 | pmic->desc[i].ops = &tps65910_ops_dcdc; | 1181 | pmic->desc[i].ops = &tps65910_ops_dcdc; |
1146 | pmic->desc[i].ramp_delay = 5000; | 1182 | pmic->desc[i].ramp_delay = 5000; |
1147 | } | 1183 | } |
1184 | } else if (i == TPS65910_REG_VBB && | ||
1185 | tps65910_chip_id(tps65910) == TPS65910) { | ||
1186 | pmic->desc[i].ops = &tps65910_ops_vbb; | ||
1187 | pmic->desc[i].volt_table = info->voltage_table; | ||
1148 | } else { | 1188 | } else { |
1149 | if (tps65910_chip_id(tps65910) == TPS65910) { | 1189 | if (tps65910_chip_id(tps65910) == TPS65910) { |
1150 | pmic->desc[i].ops = &tps65910_ops; | 1190 | pmic->desc[i].ops = &tps65910_ops; |
diff --git a/drivers/regulator/twl-regulator.c b/drivers/regulator/twl-regulator.c index 8ebd785485c7..fed28abef419 100644 --- a/drivers/regulator/twl-regulator.c +++ b/drivers/regulator/twl-regulator.c | |||
@@ -58,7 +58,7 @@ struct twlreg_info { | |||
58 | struct regulator_desc desc; | 58 | struct regulator_desc desc; |
59 | 59 | ||
60 | /* chip specific features */ | 60 | /* chip specific features */ |
61 | unsigned long features; | 61 | unsigned long features; |
62 | 62 | ||
63 | /* | 63 | /* |
64 | * optional override functions for voltage set/get | 64 | * optional override functions for voltage set/get |
@@ -1128,7 +1128,7 @@ static int twlreg_probe(struct platform_device *pdev) | |||
1128 | if (!initdata) | 1128 | if (!initdata) |
1129 | return -EINVAL; | 1129 | return -EINVAL; |
1130 | 1130 | ||
1131 | info = kmemdup(template, sizeof (*info), GFP_KERNEL); | 1131 | info = kmemdup(template, sizeof(*info), GFP_KERNEL); |
1132 | if (!info) | 1132 | if (!info) |
1133 | return -ENOMEM; | 1133 | return -ENOMEM; |
1134 | 1134 | ||
diff --git a/drivers/regulator/wm831x-dcdc.c b/drivers/regulator/wm831x-dcdc.c index 6823e6f2b88a..04cf9c16ef23 100644 --- a/drivers/regulator/wm831x-dcdc.c +++ b/drivers/regulator/wm831x-dcdc.c | |||
@@ -762,8 +762,7 @@ static int wm831x_boostp_probe(struct platform_device *pdev) | |||
762 | res = platform_get_resource(pdev, IORESOURCE_REG, 0); | 762 | res = platform_get_resource(pdev, IORESOURCE_REG, 0); |
763 | if (res == NULL) { | 763 | if (res == NULL) { |
764 | dev_err(&pdev->dev, "No REG resource\n"); | 764 | dev_err(&pdev->dev, "No REG resource\n"); |
765 | ret = -EINVAL; | 765 | return -EINVAL; |
766 | goto err; | ||
767 | } | 766 | } |
768 | dcdc->base = res->start; | 767 | dcdc->base = res->start; |
769 | 768 | ||
@@ -788,7 +787,7 @@ static int wm831x_boostp_probe(struct platform_device *pdev) | |||
788 | ret = PTR_ERR(dcdc->regulator); | 787 | ret = PTR_ERR(dcdc->regulator); |
789 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", | 788 | dev_err(wm831x->dev, "Failed to register DCDC%d: %d\n", |
790 | id + 1, ret); | 789 | id + 1, ret); |
791 | goto err; | 790 | return ret; |
792 | } | 791 | } |
793 | 792 | ||
794 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); | 793 | irq = wm831x_irq(wm831x, platform_get_irq_byname(pdev, "UV")); |
@@ -799,15 +798,12 @@ static int wm831x_boostp_probe(struct platform_device *pdev) | |||
799 | if (ret != 0) { | 798 | if (ret != 0) { |
800 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", | 799 | dev_err(&pdev->dev, "Failed to request UV IRQ %d: %d\n", |
801 | irq, ret); | 800 | irq, ret); |
802 | goto err; | 801 | return ret; |
803 | } | 802 | } |
804 | 803 | ||
805 | platform_set_drvdata(pdev, dcdc); | 804 | platform_set_drvdata(pdev, dcdc); |
806 | 805 | ||
807 | return 0; | 806 | return 0; |
808 | |||
809 | err: | ||
810 | return ret; | ||
811 | } | 807 | } |
812 | 808 | ||
813 | static struct platform_driver wm831x_boostp_driver = { | 809 | static struct platform_driver wm831x_boostp_driver = { |
diff --git a/include/linux/mfd/as3722.h b/include/linux/mfd/as3722.h index f654a7a42260..8d43e9f2a842 100644 --- a/include/linux/mfd/as3722.h +++ b/include/linux/mfd/as3722.h | |||
@@ -151,6 +151,7 @@ | |||
151 | #define AS3722_ASIC_ID1_REG 0x90 | 151 | #define AS3722_ASIC_ID1_REG 0x90 |
152 | #define AS3722_ASIC_ID2_REG 0x91 | 152 | #define AS3722_ASIC_ID2_REG 0x91 |
153 | #define AS3722_LOCK_REG 0x9E | 153 | #define AS3722_LOCK_REG 0x9E |
154 | #define AS3722_FUSE7_REG 0xA7 | ||
154 | #define AS3722_MAX_REGISTER 0xF4 | 155 | #define AS3722_MAX_REGISTER 0xF4 |
155 | 156 | ||
156 | #define AS3722_SD0_EXT_ENABLE_MASK 0x03 | 157 | #define AS3722_SD0_EXT_ENABLE_MASK 0x03 |
@@ -224,6 +225,7 @@ | |||
224 | #define AS3722_SD_VSEL_MASK 0x7F | 225 | #define AS3722_SD_VSEL_MASK 0x7F |
225 | #define AS3722_SD0_VSEL_MIN 0x01 | 226 | #define AS3722_SD0_VSEL_MIN 0x01 |
226 | #define AS3722_SD0_VSEL_MAX 0x5A | 227 | #define AS3722_SD0_VSEL_MAX 0x5A |
228 | #define AS3722_SD0_VSEL_LOW_VOL_MAX 0x6E | ||
227 | #define AS3722_SD2_VSEL_MIN 0x01 | 229 | #define AS3722_SD2_VSEL_MIN 0x01 |
228 | #define AS3722_SD2_VSEL_MAX 0x7F | 230 | #define AS3722_SD2_VSEL_MAX 0x7F |
229 | 231 | ||
@@ -342,6 +344,8 @@ | |||
342 | #define AS3722_EXT_CONTROL_ENABLE2 0x2 | 344 | #define AS3722_EXT_CONTROL_ENABLE2 0x2 |
343 | #define AS3722_EXT_CONTROL_ENABLE3 0x3 | 345 | #define AS3722_EXT_CONTROL_ENABLE3 0x3 |
344 | 346 | ||
347 | #define AS3722_FUSE7_SD0_LOW_VOLTAGE BIT(4) | ||
348 | |||
345 | /* Interrupt IDs */ | 349 | /* Interrupt IDs */ |
346 | enum as3722_irq { | 350 | enum as3722_irq { |
347 | AS3722_IRQ_LID, | 351 | AS3722_IRQ_LID, |
diff --git a/include/linux/mfd/samsung/core.h b/include/linux/mfd/samsung/core.h index cab2dd279076..41c9bde410c5 100644 --- a/include/linux/mfd/samsung/core.h +++ b/include/linux/mfd/samsung/core.h | |||
@@ -59,12 +59,6 @@ int sec_irq_init(struct sec_pmic_dev *sec_pmic); | |||
59 | void sec_irq_exit(struct sec_pmic_dev *sec_pmic); | 59 | void sec_irq_exit(struct sec_pmic_dev *sec_pmic); |
60 | int sec_irq_resume(struct sec_pmic_dev *sec_pmic); | 60 | int sec_irq_resume(struct sec_pmic_dev *sec_pmic); |
61 | 61 | ||
62 | extern int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest); | ||
63 | extern int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf); | ||
64 | extern int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value); | ||
65 | extern int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf); | ||
66 | extern int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask); | ||
67 | |||
68 | struct sec_platform_data { | 62 | struct sec_platform_data { |
69 | struct sec_regulator_data *regulators; | 63 | struct sec_regulator_data *regulators; |
70 | struct sec_opmode_data *opmode; | 64 | struct sec_opmode_data *opmode; |
diff --git a/include/linux/mfd/samsung/s5m8767.h b/include/linux/mfd/samsung/s5m8767.h index 306a95fc558c..2ab0b0f03641 100644 --- a/include/linux/mfd/samsung/s5m8767.h +++ b/include/linux/mfd/samsung/s5m8767.h | |||
@@ -183,6 +183,22 @@ enum s5m8767_regulators { | |||
183 | S5M8767_REG_MAX, | 183 | S5M8767_REG_MAX, |
184 | }; | 184 | }; |
185 | 185 | ||
186 | #define S5M8767_ENCTRL_SHIFT 6 | 186 | #define S5M8767_ENCTRL_SHIFT 6 |
187 | #define S5M8767_ENCTRL_MASK (0x3 << S5M8767_ENCTRL_SHIFT) | ||
188 | |||
189 | /* | ||
190 | * Values for BUCK_RAMP field in DVS_RAMP register, matching raw values | ||
191 | * in mV/us. | ||
192 | */ | ||
193 | enum s5m8767_dvs_buck_ramp_values { | ||
194 | S5M8767_DVS_BUCK_RAMP_5 = 0x4, | ||
195 | S5M8767_DVS_BUCK_RAMP_10 = 0x9, | ||
196 | S5M8767_DVS_BUCK_RAMP_12_5 = 0xb, | ||
197 | S5M8767_DVS_BUCK_RAMP_25 = 0xd, | ||
198 | S5M8767_DVS_BUCK_RAMP_50 = 0xe, | ||
199 | S5M8767_DVS_BUCK_RAMP_100 = 0xf, | ||
200 | }; | ||
201 | #define S5M8767_DVS_BUCK_RAMP_SHIFT 4 | ||
202 | #define S5M8767_DVS_BUCK_RAMP_MASK (0xf << S5M8767_DVS_BUCK_RAMP_SHIFT) | ||
187 | 203 | ||
188 | #endif /* __LINUX_MFD_S5M8767_H */ | 204 | #endif /* __LINUX_MFD_S5M8767_H */ |
diff --git a/include/linux/mfd/tps65910.h b/include/linux/mfd/tps65910.h index 20e433e551e3..16c2335c2856 100644 --- a/include/linux/mfd/tps65910.h +++ b/include/linux/mfd/tps65910.h | |||
@@ -358,8 +358,6 @@ | |||
358 | /*Register BBCH (0x80) register.RegisterDescription */ | 358 | /*Register BBCH (0x80) register.RegisterDescription */ |
359 | #define BBCH_BBSEL_MASK 0x06 | 359 | #define BBCH_BBSEL_MASK 0x06 |
360 | #define BBCH_BBSEL_SHIFT 1 | 360 | #define BBCH_BBSEL_SHIFT 1 |
361 | #define BBCH_BBCHEN_MASK 0x01 | ||
362 | #define BBCH_BBCHEN_SHIFT 0 | ||
363 | 361 | ||
364 | 362 | ||
365 | /*Register DCDCCTRL (0x80) register.RegisterDescription */ | 363 | /*Register DCDCCTRL (0x80) register.RegisterDescription */ |
@@ -833,6 +831,7 @@ | |||
833 | #define TPS65910_REG_VAUX2 10 | 831 | #define TPS65910_REG_VAUX2 10 |
834 | #define TPS65910_REG_VAUX33 11 | 832 | #define TPS65910_REG_VAUX33 11 |
835 | #define TPS65910_REG_VMMC 12 | 833 | #define TPS65910_REG_VMMC 12 |
834 | #define TPS65910_REG_VBB 13 | ||
836 | 835 | ||
837 | #define TPS65911_REG_VDDCTRL 4 | 836 | #define TPS65911_REG_VDDCTRL 4 |
838 | #define TPS65911_REG_LDO1 5 | 837 | #define TPS65911_REG_LDO1 5 |
@@ -845,7 +844,7 @@ | |||
845 | #define TPS65911_REG_LDO8 12 | 844 | #define TPS65911_REG_LDO8 12 |
846 | 845 | ||
847 | /* Max number of TPS65910/11 regulators */ | 846 | /* Max number of TPS65910/11 regulators */ |
848 | #define TPS65910_NUM_REGS 13 | 847 | #define TPS65910_NUM_REGS 14 |
849 | 848 | ||
850 | /* External sleep controls through EN1/EN2/EN3/SLEEP inputs */ | 849 | /* External sleep controls through EN1/EN2/EN3/SLEEP inputs */ |
851 | #define TPS65910_SLEEP_CONTROL_EXT_INPUT_EN1 0x1 | 850 | #define TPS65910_SLEEP_CONTROL_EXT_INPUT_EN1 0x1 |
diff --git a/include/linux/regulator/act8865.h b/include/linux/regulator/act8865.h new file mode 100644 index 000000000000..49206c1b4905 --- /dev/null +++ b/include/linux/regulator/act8865.h | |||
@@ -0,0 +1,53 @@ | |||
1 | /* | ||
2 | * act8865.h -- Voltage regulation for the active-semi act8865 | ||
3 | * | ||
4 | * Copyright (C) 2013 Atmel Corporation. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; version 2 of the License. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | */ | ||
15 | |||
16 | #ifndef __LINUX_REGULATOR_ACT8865_H | ||
17 | #define __LINUX_REGULATOR_ACT8865_H | ||
18 | |||
19 | #include <linux/regulator/machine.h> | ||
20 | |||
21 | enum { | ||
22 | ACT8865_ID_DCDC1, | ||
23 | ACT8865_ID_DCDC2, | ||
24 | ACT8865_ID_DCDC3, | ||
25 | ACT8865_ID_LDO1, | ||
26 | ACT8865_ID_LDO2, | ||
27 | ACT8865_ID_LDO3, | ||
28 | ACT8865_ID_LDO4, | ||
29 | ACT8865_REG_NUM, | ||
30 | }; | ||
31 | |||
32 | /** | ||
33 | * act8865_regulator_data - regulator data | ||
34 | * @id: regulator id | ||
35 | * @name: regulator name | ||
36 | * @platform_data: regulator init data | ||
37 | */ | ||
38 | struct act8865_regulator_data { | ||
39 | int id; | ||
40 | const char *name; | ||
41 | struct regulator_init_data *platform_data; | ||
42 | }; | ||
43 | |||
44 | /** | ||
45 | * act8865_platform_data - platform data for act8865 | ||
46 | * @num_regulators: number of regulators used | ||
47 | * @regulators: pointer to regulators used | ||
48 | */ | ||
49 | struct act8865_platform_data { | ||
50 | int num_regulators; | ||
51 | struct act8865_regulator_data *regulators; | ||
52 | }; | ||
53 | #endif | ||