aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com>2015-02-27 12:04:04 -0500
committerMark Brown <broonie@kernel.org>2015-03-06 14:43:28 -0500
commitdf3a950e4e7386027fc174566aa5c24781297be8 (patch)
treece30a71ac46f22349eeb5d7153fd0da3718aa06a
parentc517d838eb7d07bbe9507871fab3931deccff539 (diff)
regulator: act8865: Add act8600 support
This patch adds act8600 support to the act8865 driver. VBUS and USB charger supported by this chip can be added later Tested on MIPS Creator CI20 Signed-off-by: Zubair Lutfullah Kakakhel <Zubair.Kakakhel@imgtec.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/regulator/act8865-regulator.txt5
-rw-r--r--drivers/regulator/act8865-regulator.c120
-rw-r--r--include/linux/regulator/act8865.h14
3 files changed, 137 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
index dad6358074ac..e170df2357df 100644
--- a/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
+++ b/Documentation/devicetree/bindings/regulator/act8865-regulator.txt
@@ -2,7 +2,7 @@ ACT88xx regulators
2------------------- 2-------------------
3 3
4Required properties: 4Required properties:
5- compatible: "active-semi,act8846" or "active-semi,act8865" 5- compatible: "active-semi,act8846" or "active-semi,act8865" or "active-semi,act8600"
6- reg: I2C slave address 6- reg: I2C slave address
7 7
8Optional properties: 8Optional properties:
@@ -16,6 +16,9 @@ The valid names for regulators are:
16 REG1, REG2, REG3, REG4, REG5, REG6, REG7, REG8, REG9, REG10, REG11, REG12 16 REG1, REG2, REG3, REG4, REG5, REG6, REG7, REG8, REG9, REG10, REG11, REG12
17 - for act8865: 17 - for act8865:
18 DCDC_REG1, DCDC_REG2, DCDC_REG3, LDO_REG1, LDO_REG2, LDO_REG3, LDO_REG4. 18 DCDC_REG1, DCDC_REG2, DCDC_REG3, LDO_REG1, LDO_REG2, LDO_REG3, LDO_REG4.
19 - for act8600:
20 DCDC_REG1, DCDC_REG2, DCDC_REG3, SUDCDC_REG4, LDO_REG5, LDO_REG6, LDO_REG7,
21 LDO_REG8, LDO_REG9, LDO_REG10,
19 22
20Example: 23Example:
21-------- 24--------
diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c
index 9eec453b745d..3781f6e289d8 100644
--- a/drivers/regulator/act8865-regulator.c
+++ b/drivers/regulator/act8865-regulator.c
@@ -29,6 +29,35 @@
29#include <linux/regmap.h> 29#include <linux/regmap.h>
30 30
31/* 31/*
32 * ACT8600 Global Register Map.
33 */
34#define ACT8600_SYS_MODE 0x00
35#define ACT8600_SYS_CTRL 0x01
36#define ACT8600_DCDC1_VSET 0x10
37#define ACT8600_DCDC1_CTRL 0x12
38#define ACT8600_DCDC2_VSET 0x20
39#define ACT8600_DCDC2_CTRL 0x22
40#define ACT8600_DCDC3_VSET 0x30
41#define ACT8600_DCDC3_CTRL 0x32
42#define ACT8600_SUDCDC4_VSET 0x40
43#define ACT8600_SUDCDC4_CTRL 0x41
44#define ACT8600_LDO5_VSET 0x50
45#define ACT8600_LDO5_CTRL 0x51
46#define ACT8600_LDO6_VSET 0x60
47#define ACT8600_LDO6_CTRL 0x61
48#define ACT8600_LDO7_VSET 0x70
49#define ACT8600_LDO7_CTRL 0x71
50#define ACT8600_LDO8_VSET 0x80
51#define ACT8600_LDO8_CTRL 0x81
52#define ACT8600_LDO910_CTRL 0x91
53#define ACT8600_APCH0 0xA1
54#define ACT8600_APCH1 0xA8
55#define ACT8600_APCH2 0xA9
56#define ACT8600_APCH_STAT 0xAA
57#define ACT8600_OTG0 0xB0
58#define ACT8600_OTG1 0xB2
59
60/*
32 * ACT8846 Global Register Map. 61 * ACT8846 Global Register Map.
33 */ 62 */
34#define ACT8846_SYS0 0x00 63#define ACT8846_SYS0 0x00
@@ -94,10 +123,15 @@
94#define ACT8865_ENA 0x80 /* ON - [7] */ 123#define ACT8865_ENA 0x80 /* ON - [7] */
95#define ACT8865_VSEL_MASK 0x3F /* VSET - [5:0] */ 124#define ACT8865_VSEL_MASK 0x3F /* VSET - [5:0] */
96 125
126
127#define ACT8600_LDO10_ENA 0x40 /* ON - [6] */
128#define ACT8600_SUDCDC_VSEL_MASK 0xFF /* SUDCDC VSET - [7:0] */
129
97/* 130/*
98 * ACT8865 voltage number 131 * ACT8865 voltage number
99 */ 132 */
100#define ACT8865_VOLTAGE_NUM 64 133#define ACT8865_VOLTAGE_NUM 64
134#define ACT8600_SUDCDC_VOLTAGE_NUM 255
101 135
102struct act8865 { 136struct act8865 {
103 struct regmap *regmap; 137 struct regmap *regmap;
@@ -116,6 +150,13 @@ static const struct regulator_linear_range act8865_voltage_ranges[] = {
116 REGULATOR_LINEAR_RANGE(2400000, 48, 63, 100000), 150 REGULATOR_LINEAR_RANGE(2400000, 48, 63, 100000),
117}; 151};
118 152
153static const struct regulator_linear_range act8600_sudcdc_voltage_ranges[] = {
154 REGULATOR_LINEAR_RANGE(3000000, 0, 63, 0),
155 REGULATOR_LINEAR_RANGE(3000000, 64, 159, 100000),
156 REGULATOR_LINEAR_RANGE(12600000, 160, 191, 200000),
157 REGULATOR_LINEAR_RANGE(19000000, 191, 255, 400000),
158};
159
119static struct regulator_ops act8865_ops = { 160static struct regulator_ops act8865_ops = {
120 .list_voltage = regulator_list_voltage_linear_range, 161 .list_voltage = regulator_list_voltage_linear_range,
121 .map_voltage = regulator_map_voltage_linear_range, 162 .map_voltage = regulator_map_voltage_linear_range,
@@ -126,6 +167,12 @@ static struct regulator_ops act8865_ops = {
126 .is_enabled = regulator_is_enabled_regmap, 167 .is_enabled = regulator_is_enabled_regmap,
127}; 168};
128 169
170static struct regulator_ops act8865_ldo_ops = {
171 .enable = regulator_enable_regmap,
172 .disable = regulator_disable_regmap,
173 .is_enabled = regulator_is_enabled_regmap,
174};
175
129#define ACT88xx_REG(_name, _family, _id, _vsel_reg) \ 176#define ACT88xx_REG(_name, _family, _id, _vsel_reg) \
130 [_family##_ID_##_id] = { \ 177 [_family##_ID_##_id] = { \
131 .name = _name, \ 178 .name = _name, \
@@ -142,6 +189,52 @@ static struct regulator_ops act8865_ops = {
142 .owner = THIS_MODULE, \ 189 .owner = THIS_MODULE, \
143 } 190 }
144 191
192static const struct regulator_desc act8600_regulators[] = {
193 ACT88xx_REG("DCDC1", ACT8600, DCDC1, VSET),
194 ACT88xx_REG("DCDC2", ACT8600, DCDC2, VSET),
195 ACT88xx_REG("DCDC3", ACT8600, DCDC3, VSET),
196 {
197 .name = "SUDCDC_REG4",
198 .id = ACT8600_ID_SUDCDC4,
199 .ops = &act8865_ops,
200 .type = REGULATOR_VOLTAGE,
201 .n_voltages = ACT8600_SUDCDC_VOLTAGE_NUM,
202 .linear_ranges = act8600_sudcdc_voltage_ranges,
203 .n_linear_ranges = ARRAY_SIZE(act8600_sudcdc_voltage_ranges),
204 .vsel_reg = ACT8600_SUDCDC4_VSET,
205 .vsel_mask = ACT8600_SUDCDC_VSEL_MASK,
206 .enable_reg = ACT8600_SUDCDC4_CTRL,
207 .enable_mask = ACT8865_ENA,
208 .owner = THIS_MODULE,
209 },
210 ACT88xx_REG("LDO5", ACT8600, LDO5, VSET),
211 ACT88xx_REG("LDO6", ACT8600, LDO6, VSET),
212 ACT88xx_REG("LDO7", ACT8600, LDO7, VSET),
213 ACT88xx_REG("LDO8", ACT8600, LDO8, VSET),
214 {
215 .name = "LDO_REG9",
216 .id = ACT8600_ID_LDO9,
217 .ops = &act8865_ldo_ops,
218 .type = REGULATOR_VOLTAGE,
219 .n_voltages = 1,
220 .fixed_uV = 1800000,
221 .enable_reg = ACT8600_LDO910_CTRL,
222 .enable_mask = ACT8865_ENA,
223 .owner = THIS_MODULE,
224 },
225 {
226 .name = "LDO_REG10",
227 .id = ACT8600_ID_LDO10,
228 .ops = &act8865_ldo_ops,
229 .type = REGULATOR_VOLTAGE,
230 .n_voltages = 1,
231 .fixed_uV = 1200000,
232 .enable_reg = ACT8600_LDO910_CTRL,
233 .enable_mask = ACT8600_LDO10_ENA,
234 .owner = THIS_MODULE,
235 },
236};
237
145static const struct regulator_desc act8846_regulators[] = { 238static const struct regulator_desc act8846_regulators[] = {
146 ACT88xx_REG("REG1", ACT8846, REG1, VSET), 239 ACT88xx_REG("REG1", ACT8846, REG1, VSET),
147 ACT88xx_REG("REG2", ACT8846, REG2, VSET0), 240 ACT88xx_REG("REG2", ACT8846, REG2, VSET0),
@@ -169,6 +262,7 @@ static const struct regulator_desc act8865_regulators[] = {
169 262
170#ifdef CONFIG_OF 263#ifdef CONFIG_OF
171static const struct of_device_id act8865_dt_ids[] = { 264static const struct of_device_id act8865_dt_ids[] = {
265 { .compatible = "active-semi,act8600", .data = (void *)ACT8600 },
172 { .compatible = "active-semi,act8846", .data = (void *)ACT8846 }, 266 { .compatible = "active-semi,act8846", .data = (void *)ACT8846 },
173 { .compatible = "active-semi,act8865", .data = (void *)ACT8865 }, 267 { .compatible = "active-semi,act8865", .data = (void *)ACT8865 },
174 { } 268 { }
@@ -200,6 +294,19 @@ static struct of_regulator_match act8865_matches[] = {
200 [ACT8865_ID_LDO4] = { .name = "LDO_REG4"}, 294 [ACT8865_ID_LDO4] = { .name = "LDO_REG4"},
201}; 295};
202 296
297static struct of_regulator_match act8600_matches[] = {
298 [ACT8600_ID_DCDC1] = { .name = "DCDC_REG1"},
299 [ACT8600_ID_DCDC2] = { .name = "DCDC_REG2"},
300 [ACT8600_ID_DCDC3] = { .name = "DCDC_REG3"},
301 [ACT8600_ID_SUDCDC4] = { .name = "SUDCDC_REG4"},
302 [ACT8600_ID_LDO5] = { .name = "LDO_REG5"},
303 [ACT8600_ID_LDO6] = { .name = "LDO_REG6"},
304 [ACT8600_ID_LDO7] = { .name = "LDO_REG7"},
305 [ACT8600_ID_LDO8] = { .name = "LDO_REG8"},
306 [ACT8600_ID_LDO9] = { .name = "LDO_REG9"},
307 [ACT8600_ID_LDO10] = { .name = "LDO_REG10"},
308};
309
203static int act8865_pdata_from_dt(struct device *dev, 310static int act8865_pdata_from_dt(struct device *dev,
204 struct device_node **of_node, 311 struct device_node **of_node,
205 struct act8865_platform_data *pdata, 312 struct act8865_platform_data *pdata,
@@ -217,6 +324,10 @@ static int act8865_pdata_from_dt(struct device *dev,
217 } 324 }
218 325
219 switch (type) { 326 switch (type) {
327 case ACT8600:
328 matches = act8600_matches;
329 num_matches = ARRAY_SIZE(act8600_matches);
330 break;
220 case ACT8846: 331 case ACT8846:
221 matches = act8846_matches; 332 matches = act8846_matches;
222 num_matches = ARRAY_SIZE(act8846_matches); 333 num_matches = ARRAY_SIZE(act8846_matches);
@@ -317,6 +428,12 @@ static int act8865_pmic_probe(struct i2c_client *client,
317 } 428 }
318 429
319 switch (type) { 430 switch (type) {
431 case ACT8600:
432 regulators = act8600_regulators;
433 num_regulators = ARRAY_SIZE(act8600_regulators);
434 off_reg = -1;
435 off_mask = -1;
436 break;
320 case ACT8846: 437 case ACT8846:
321 regulators = act8846_regulators; 438 regulators = act8846_regulators;
322 num_regulators = ARRAY_SIZE(act8846_regulators); 439 num_regulators = ARRAY_SIZE(act8846_regulators);
@@ -366,7 +483,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
366 } 483 }
367 484
368 if (of_device_is_system_power_controller(dev->of_node)) { 485 if (of_device_is_system_power_controller(dev->of_node)) {
369 if (!pm_power_off) { 486 if (!pm_power_off && (off_reg > 0)) {
370 act8865_i2c_client = client; 487 act8865_i2c_client = client;
371 act8865->off_reg = off_reg; 488 act8865->off_reg = off_reg;
372 act8865->off_mask = off_mask; 489 act8865->off_mask = off_mask;
@@ -402,6 +519,7 @@ static int act8865_pmic_probe(struct i2c_client *client,
402} 519}
403 520
404static const struct i2c_device_id act8865_ids[] = { 521static const struct i2c_device_id act8865_ids[] = {
522 { .name = "act8600", .driver_data = ACT8600 },
405 { .name = "act8846", .driver_data = ACT8846 }, 523 { .name = "act8846", .driver_data = ACT8846 },
406 { .name = "act8865", .driver_data = ACT8865 }, 524 { .name = "act8865", .driver_data = ACT8865 },
407 { }, 525 { },
diff --git a/include/linux/regulator/act8865.h b/include/linux/regulator/act8865.h
index b6c4909b33af..15fa8f2d35c9 100644
--- a/include/linux/regulator/act8865.h
+++ b/include/linux/regulator/act8865.h
@@ -19,6 +19,19 @@
19#include <linux/regulator/machine.h> 19#include <linux/regulator/machine.h>
20 20
21enum { 21enum {
22 ACT8600_ID_DCDC1,
23 ACT8600_ID_DCDC2,
24 ACT8600_ID_DCDC3,
25 ACT8600_ID_SUDCDC4,
26 ACT8600_ID_LDO5,
27 ACT8600_ID_LDO6,
28 ACT8600_ID_LDO7,
29 ACT8600_ID_LDO8,
30 ACT8600_ID_LDO9,
31 ACT8600_ID_LDO10,
32};
33
34enum {
22 ACT8865_ID_DCDC1, 35 ACT8865_ID_DCDC1,
23 ACT8865_ID_DCDC2, 36 ACT8865_ID_DCDC2,
24 ACT8865_ID_DCDC3, 37 ACT8865_ID_DCDC3,
@@ -46,6 +59,7 @@ enum {
46}; 59};
47 60
48enum { 61enum {
62 ACT8600,
49 ACT8865, 63 ACT8865,
50 ACT8846, 64 ACT8846,
51}; 65};