diff options
author | Keerthy <j-keerthy@ti.com> | 2014-06-18 05:58:55 -0400 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2014-06-23 07:30:56 -0400 |
commit | 1c113d83bb041ba544ea5054cf84ada93152b0d1 (patch) | |
tree | 3b6a480f3ee7f48debc0e6c3de9c1b2402b6ff01 /drivers/mfd/palmas.c | |
parent | 027d7c2a26ad637f14c72f401dd8da0bb6df20c8 (diff) |
mfd: palmas: Add tps65917 support
Add tps65917 PMIC support. tps65917 is a subset of palmas PMIC.
Some of the register definitions and the interrupt mappings
are different.
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Keerthy <j-keerthy@ti.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/mfd/palmas.c')
-rw-r--r-- | drivers/mfd/palmas.c | 179 |
1 files changed, 172 insertions, 7 deletions
diff --git a/drivers/mfd/palmas.c b/drivers/mfd/palmas.c index d280d789e55a..6e1786187dd8 100644 --- a/drivers/mfd/palmas.c +++ b/drivers/mfd/palmas.c | |||
@@ -92,6 +92,133 @@ static const struct regmap_config palmas_regmap_config[PALMAS_NUM_CLIENTS] = { | |||
92 | }, | 92 | }, |
93 | }; | 93 | }; |
94 | 94 | ||
95 | static const struct regmap_irq tps65917_irqs[] = { | ||
96 | /* INT1 IRQs */ | ||
97 | [TPS65917_RESERVED1] = { | ||
98 | .mask = TPS65917_RESERVED, | ||
99 | }, | ||
100 | [TPS65917_PWRON_IRQ] = { | ||
101 | .mask = TPS65917_INT1_STATUS_PWRON, | ||
102 | }, | ||
103 | [TPS65917_LONG_PRESS_KEY_IRQ] = { | ||
104 | .mask = TPS65917_INT1_STATUS_LONG_PRESS_KEY, | ||
105 | }, | ||
106 | [TPS65917_RESERVED2] = { | ||
107 | .mask = TPS65917_RESERVED, | ||
108 | }, | ||
109 | [TPS65917_PWRDOWN_IRQ] = { | ||
110 | .mask = TPS65917_INT1_STATUS_PWRDOWN, | ||
111 | }, | ||
112 | [TPS65917_HOTDIE_IRQ] = { | ||
113 | .mask = TPS65917_INT1_STATUS_HOTDIE, | ||
114 | }, | ||
115 | [TPS65917_VSYS_MON_IRQ] = { | ||
116 | .mask = TPS65917_INT1_STATUS_VSYS_MON, | ||
117 | }, | ||
118 | [TPS65917_RESERVED3] = { | ||
119 | .mask = TPS65917_RESERVED, | ||
120 | }, | ||
121 | /* INT2 IRQs*/ | ||
122 | [TPS65917_RESERVED4] = { | ||
123 | .mask = TPS65917_RESERVED, | ||
124 | .reg_offset = 1, | ||
125 | }, | ||
126 | [TPS65917_OTP_ERROR_IRQ] = { | ||
127 | .mask = TPS65917_INT2_STATUS_OTP_ERROR, | ||
128 | .reg_offset = 1, | ||
129 | }, | ||
130 | [TPS65917_WDT_IRQ] = { | ||
131 | .mask = TPS65917_INT2_STATUS_WDT, | ||
132 | .reg_offset = 1, | ||
133 | }, | ||
134 | [TPS65917_RESERVED5] = { | ||
135 | .mask = TPS65917_RESERVED, | ||
136 | .reg_offset = 1, | ||
137 | }, | ||
138 | [TPS65917_RESET_IN_IRQ] = { | ||
139 | .mask = TPS65917_INT2_STATUS_RESET_IN, | ||
140 | .reg_offset = 1, | ||
141 | }, | ||
142 | [TPS65917_FSD_IRQ] = { | ||
143 | .mask = TPS65917_INT2_STATUS_FSD, | ||
144 | .reg_offset = 1, | ||
145 | }, | ||
146 | [TPS65917_SHORT_IRQ] = { | ||
147 | .mask = TPS65917_INT2_STATUS_SHORT, | ||
148 | .reg_offset = 1, | ||
149 | }, | ||
150 | [TPS65917_RESERVED6] = { | ||
151 | .mask = TPS65917_RESERVED, | ||
152 | .reg_offset = 1, | ||
153 | }, | ||
154 | /* INT3 IRQs */ | ||
155 | [TPS65917_GPADC_AUTO_0_IRQ] = { | ||
156 | .mask = TPS65917_INT3_STATUS_GPADC_AUTO_0, | ||
157 | .reg_offset = 2, | ||
158 | }, | ||
159 | [TPS65917_GPADC_AUTO_1_IRQ] = { | ||
160 | .mask = TPS65917_INT3_STATUS_GPADC_AUTO_1, | ||
161 | .reg_offset = 2, | ||
162 | }, | ||
163 | [TPS65917_GPADC_EOC_SW_IRQ] = { | ||
164 | .mask = TPS65917_INT3_STATUS_GPADC_EOC_SW, | ||
165 | .reg_offset = 2, | ||
166 | }, | ||
167 | [TPS65917_RESREVED6] = { | ||
168 | .mask = TPS65917_RESERVED6, | ||
169 | .reg_offset = 2, | ||
170 | }, | ||
171 | [TPS65917_RESERVED7] = { | ||
172 | .mask = TPS65917_RESERVED, | ||
173 | .reg_offset = 2, | ||
174 | }, | ||
175 | [TPS65917_RESERVED8] = { | ||
176 | .mask = TPS65917_RESERVED, | ||
177 | .reg_offset = 2, | ||
178 | }, | ||
179 | [TPS65917_RESERVED9] = { | ||
180 | .mask = TPS65917_RESERVED, | ||
181 | .reg_offset = 2, | ||
182 | }, | ||
183 | [TPS65917_VBUS_IRQ] = { | ||
184 | .mask = TPS65917_INT3_STATUS_VBUS, | ||
185 | .reg_offset = 2, | ||
186 | }, | ||
187 | /* INT4 IRQs */ | ||
188 | [TPS65917_GPIO_0_IRQ] = { | ||
189 | .mask = TPS65917_INT4_STATUS_GPIO_0, | ||
190 | .reg_offset = 3, | ||
191 | }, | ||
192 | [TPS65917_GPIO_1_IRQ] = { | ||
193 | .mask = TPS65917_INT4_STATUS_GPIO_1, | ||
194 | .reg_offset = 3, | ||
195 | }, | ||
196 | [TPS65917_GPIO_2_IRQ] = { | ||
197 | .mask = TPS65917_INT4_STATUS_GPIO_2, | ||
198 | .reg_offset = 3, | ||
199 | }, | ||
200 | [TPS65917_GPIO_3_IRQ] = { | ||
201 | .mask = TPS65917_INT4_STATUS_GPIO_3, | ||
202 | .reg_offset = 3, | ||
203 | }, | ||
204 | [TPS65917_GPIO_4_IRQ] = { | ||
205 | .mask = TPS65917_INT4_STATUS_GPIO_4, | ||
206 | .reg_offset = 3, | ||
207 | }, | ||
208 | [TPS65917_GPIO_5_IRQ] = { | ||
209 | .mask = TPS65917_INT4_STATUS_GPIO_5, | ||
210 | .reg_offset = 3, | ||
211 | }, | ||
212 | [TPS65917_GPIO_6_IRQ] = { | ||
213 | .mask = TPS65917_INT4_STATUS_GPIO_6, | ||
214 | .reg_offset = 3, | ||
215 | }, | ||
216 | [TPS65917_RESERVED10] = { | ||
217 | .mask = TPS65917_RESERVED10, | ||
218 | .reg_offset = 3, | ||
219 | }, | ||
220 | }; | ||
221 | |||
95 | static const struct regmap_irq palmas_irqs[] = { | 222 | static const struct regmap_irq palmas_irqs[] = { |
96 | /* INT1 IRQs */ | 223 | /* INT1 IRQs */ |
97 | [PALMAS_CHARG_DET_N_VBUS_OVV_IRQ] = { | 224 | [PALMAS_CHARG_DET_N_VBUS_OVV_IRQ] = { |
@@ -232,6 +359,19 @@ static struct regmap_irq_chip palmas_irq_chip = { | |||
232 | PALMAS_INT1_MASK), | 359 | PALMAS_INT1_MASK), |
233 | }; | 360 | }; |
234 | 361 | ||
362 | static struct regmap_irq_chip tps65917_irq_chip = { | ||
363 | .name = "tps65917", | ||
364 | .irqs = tps65917_irqs, | ||
365 | .num_irqs = ARRAY_SIZE(tps65917_irqs), | ||
366 | |||
367 | .num_regs = 4, | ||
368 | .irq_reg_stride = 5, | ||
369 | .status_base = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, | ||
370 | PALMAS_INT1_STATUS), | ||
371 | .mask_base = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, | ||
372 | PALMAS_INT1_MASK), | ||
373 | }; | ||
374 | |||
235 | int palmas_ext_control_req_config(struct palmas *palmas, | 375 | int palmas_ext_control_req_config(struct palmas *palmas, |
236 | enum palmas_external_requestor_id id, int ext_ctrl, bool enable) | 376 | enum palmas_external_requestor_id id, int ext_ctrl, bool enable) |
237 | { | 377 | { |
@@ -357,14 +497,38 @@ static void palmas_power_off(void) | |||
357 | static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST; | 497 | static unsigned int palmas_features = PALMAS_PMIC_FEATURE_SMPS10_BOOST; |
358 | static unsigned int tps659038_features; | 498 | static unsigned int tps659038_features; |
359 | 499 | ||
500 | struct palmas_driver_data { | ||
501 | unsigned int *features; | ||
502 | struct regmap_irq_chip *irq_chip; | ||
503 | }; | ||
504 | |||
505 | static struct palmas_driver_data palmas_data = { | ||
506 | .features = &palmas_features, | ||
507 | .irq_chip = &palmas_irq_chip, | ||
508 | }; | ||
509 | |||
510 | static struct palmas_driver_data tps659038_data = { | ||
511 | .features = &tps659038_features, | ||
512 | .irq_chip = &palmas_irq_chip, | ||
513 | }; | ||
514 | |||
515 | static struct palmas_driver_data tps65917_data = { | ||
516 | .features = &tps659038_features, | ||
517 | .irq_chip = &tps65917_irq_chip, | ||
518 | }; | ||
519 | |||
360 | static const struct of_device_id of_palmas_match_tbl[] = { | 520 | static const struct of_device_id of_palmas_match_tbl[] = { |
361 | { | 521 | { |
362 | .compatible = "ti,palmas", | 522 | .compatible = "ti,palmas", |
363 | .data = &palmas_features, | 523 | .data = &palmas_data, |
364 | }, | 524 | }, |
365 | { | 525 | { |
366 | .compatible = "ti,tps659038", | 526 | .compatible = "ti,tps659038", |
367 | .data = &tps659038_features, | 527 | .data = &tps659038_data, |
528 | }, | ||
529 | { | ||
530 | .compatible = "ti,tps65917", | ||
531 | .data = &tps65917_data, | ||
368 | }, | 532 | }, |
369 | { }, | 533 | { }, |
370 | }; | 534 | }; |
@@ -375,9 +539,10 @@ static int palmas_i2c_probe(struct i2c_client *i2c, | |||
375 | { | 539 | { |
376 | struct palmas *palmas; | 540 | struct palmas *palmas; |
377 | struct palmas_platform_data *pdata; | 541 | struct palmas_platform_data *pdata; |
542 | struct palmas_driver_data *driver_data; | ||
378 | struct device_node *node = i2c->dev.of_node; | 543 | struct device_node *node = i2c->dev.of_node; |
379 | int ret = 0, i; | 544 | int ret = 0, i; |
380 | unsigned int reg, addr, *features; | 545 | unsigned int reg, addr; |
381 | int slave; | 546 | int slave; |
382 | const struct of_device_id *match; | 547 | const struct of_device_id *match; |
383 | 548 | ||
@@ -408,8 +573,8 @@ static int palmas_i2c_probe(struct i2c_client *i2c, | |||
408 | if (!match) | 573 | if (!match) |
409 | return -ENODATA; | 574 | return -ENODATA; |
410 | 575 | ||
411 | features = (unsigned int *)match->data; | 576 | driver_data = (struct palmas_driver_data *)match->data; |
412 | palmas->features = *features; | 577 | palmas->features = *driver_data->features; |
413 | 578 | ||
414 | for (i = 0; i < PALMAS_NUM_CLIENTS; i++) { | 579 | for (i = 0; i < PALMAS_NUM_CLIENTS; i++) { |
415 | if (i == 0) | 580 | if (i == 0) |
@@ -463,8 +628,8 @@ static int palmas_i2c_probe(struct i2c_client *i2c, | |||
463 | regmap_write(palmas->regmap[slave], addr, reg); | 628 | regmap_write(palmas->regmap[slave], addr, reg); |
464 | 629 | ||
465 | ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq, | 630 | ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq, |
466 | IRQF_ONESHOT | pdata->irq_flags, 0, &palmas_irq_chip, | 631 | IRQF_ONESHOT | pdata->irq_flags, 0, |
467 | &palmas->irq_data); | 632 | driver_data->irq_chip, &palmas->irq_data); |
468 | if (ret < 0) | 633 | if (ret < 0) |
469 | goto err_i2c; | 634 | goto err_i2c; |
470 | 635 | ||