1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm831x-core.c -- Device access for Wolfson WM831x PMICs
5 * Copyright 2009 Wolfson Microelectronics PLC.
7 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
10 #include <linux/kernel.h>
11 #include <linux/init.h>
12 #include <linux/export.h>
13 #include <linux/bcd.h>
14 #include <linux/delay.h>
15 #include <linux/mfd/core.h>
16 #include <linux/slab.h>
17 #include <linux/err.h>
19 #include <linux/of_device.h>
21 #include <linux/mfd/wm831x/core.h>
22 #include <linux/mfd/wm831x/pdata.h>
23 #include <linux/mfd/wm831x/irq.h>
24 #include <linux/mfd/wm831x/auxadc.h>
25 #include <linux/mfd/wm831x/otp.h>
26 #include <linux/mfd/wm831x/pmu.h>
27 #include <linux/mfd/wm831x/regulator.h>
29 /* Current settings - values are 2*2^(reg_val/4) microamps. These are
30 * exported since they are used by multiple drivers.
32 const unsigned int wm831x_isinkv_values
[WM831X_ISINK_MAX_ISEL
+ 1] = {
90 EXPORT_SYMBOL_GPL(wm831x_isinkv_values
);
92 static int wm831x_reg_locked(struct wm831x
*wm831x
, unsigned short reg
)
99 case WM831X_DC4_CONTROL
:
100 case WM831X_ON_PIN_CONTROL
:
101 case WM831X_BACKUP_CHARGER_CONTROL
:
102 case WM831X_CHARGER_CONTROL_1
:
103 case WM831X_CHARGER_CONTROL_2
:
112 * wm831x_reg_unlock: Unlock user keyed registers
114 * The WM831x has a user key preventing writes to particularly
115 * critical registers. This function locks those registers,
116 * allowing writes to them.
118 void wm831x_reg_lock(struct wm831x
*wm831x
)
122 ret
= wm831x_reg_write(wm831x
, WM831X_SECURITY_KEY
, 0);
124 dev_vdbg(wm831x
->dev
, "Registers locked\n");
126 mutex_lock(&wm831x
->io_lock
);
127 WARN_ON(wm831x
->locked
);
129 mutex_unlock(&wm831x
->io_lock
);
131 dev_err(wm831x
->dev
, "Failed to lock registers: %d\n", ret
);
135 EXPORT_SYMBOL_GPL(wm831x_reg_lock
);
138 * wm831x_reg_unlock: Unlock user keyed registers
140 * The WM831x has a user key preventing writes to particularly
141 * critical registers. This function locks those registers,
142 * preventing spurious writes.
144 int wm831x_reg_unlock(struct wm831x
*wm831x
)
148 /* 0x9716 is the value required to unlock the registers */
149 ret
= wm831x_reg_write(wm831x
, WM831X_SECURITY_KEY
, 0x9716);
151 dev_vdbg(wm831x
->dev
, "Registers unlocked\n");
153 mutex_lock(&wm831x
->io_lock
);
154 WARN_ON(!wm831x
->locked
);
156 mutex_unlock(&wm831x
->io_lock
);
161 EXPORT_SYMBOL_GPL(wm831x_reg_unlock
);
163 static bool wm831x_reg_readable(struct device
*dev
, unsigned int reg
)
166 case WM831X_RESET_ID
:
167 case WM831X_REVISION
:
168 case WM831X_PARENT_ID
:
169 case WM831X_SYSVDD_CONTROL
:
170 case WM831X_THERMAL_MONITORING
:
171 case WM831X_POWER_STATE
:
172 case WM831X_WATCHDOG
:
173 case WM831X_ON_PIN_CONTROL
:
174 case WM831X_RESET_CONTROL
:
175 case WM831X_CONTROL_INTERFACE
:
176 case WM831X_SECURITY_KEY
:
177 case WM831X_SOFTWARE_SCRATCH
:
178 case WM831X_OTP_CONTROL
:
179 case WM831X_GPIO_LEVEL
:
180 case WM831X_SYSTEM_STATUS
:
181 case WM831X_ON_SOURCE
:
182 case WM831X_OFF_SOURCE
:
183 case WM831X_SYSTEM_INTERRUPTS
:
184 case WM831X_INTERRUPT_STATUS_1
:
185 case WM831X_INTERRUPT_STATUS_2
:
186 case WM831X_INTERRUPT_STATUS_3
:
187 case WM831X_INTERRUPT_STATUS_4
:
188 case WM831X_INTERRUPT_STATUS_5
:
189 case WM831X_IRQ_CONFIG
:
190 case WM831X_SYSTEM_INTERRUPTS_MASK
:
191 case WM831X_INTERRUPT_STATUS_1_MASK
:
192 case WM831X_INTERRUPT_STATUS_2_MASK
:
193 case WM831X_INTERRUPT_STATUS_3_MASK
:
194 case WM831X_INTERRUPT_STATUS_4_MASK
:
195 case WM831X_INTERRUPT_STATUS_5_MASK
:
196 case WM831X_RTC_WRITE_COUNTER
:
197 case WM831X_RTC_TIME_1
:
198 case WM831X_RTC_TIME_2
:
199 case WM831X_RTC_ALARM_1
:
200 case WM831X_RTC_ALARM_2
:
201 case WM831X_RTC_CONTROL
:
202 case WM831X_RTC_TRIM
:
203 case WM831X_TOUCH_CONTROL_1
:
204 case WM831X_TOUCH_CONTROL_2
:
205 case WM831X_TOUCH_DATA_X
:
206 case WM831X_TOUCH_DATA_Y
:
207 case WM831X_TOUCH_DATA_Z
:
208 case WM831X_AUXADC_DATA
:
209 case WM831X_AUXADC_CONTROL
:
210 case WM831X_AUXADC_SOURCE
:
211 case WM831X_COMPARATOR_CONTROL
:
212 case WM831X_COMPARATOR_1
:
213 case WM831X_COMPARATOR_2
:
214 case WM831X_COMPARATOR_3
:
215 case WM831X_COMPARATOR_4
:
216 case WM831X_GPIO1_CONTROL
:
217 case WM831X_GPIO2_CONTROL
:
218 case WM831X_GPIO3_CONTROL
:
219 case WM831X_GPIO4_CONTROL
:
220 case WM831X_GPIO5_CONTROL
:
221 case WM831X_GPIO6_CONTROL
:
222 case WM831X_GPIO7_CONTROL
:
223 case WM831X_GPIO8_CONTROL
:
224 case WM831X_GPIO9_CONTROL
:
225 case WM831X_GPIO10_CONTROL
:
226 case WM831X_GPIO11_CONTROL
:
227 case WM831X_GPIO12_CONTROL
:
228 case WM831X_GPIO13_CONTROL
:
229 case WM831X_GPIO14_CONTROL
:
230 case WM831X_GPIO15_CONTROL
:
231 case WM831X_GPIO16_CONTROL
:
232 case WM831X_CHARGER_CONTROL_1
:
233 case WM831X_CHARGER_CONTROL_2
:
234 case WM831X_CHARGER_STATUS
:
235 case WM831X_BACKUP_CHARGER_CONTROL
:
236 case WM831X_STATUS_LED_1
:
237 case WM831X_STATUS_LED_2
:
238 case WM831X_CURRENT_SINK_1
:
239 case WM831X_CURRENT_SINK_2
:
240 case WM831X_DCDC_ENABLE
:
241 case WM831X_LDO_ENABLE
:
242 case WM831X_DCDC_STATUS
:
243 case WM831X_LDO_STATUS
:
244 case WM831X_DCDC_UV_STATUS
:
245 case WM831X_LDO_UV_STATUS
:
246 case WM831X_DC1_CONTROL_1
:
247 case WM831X_DC1_CONTROL_2
:
248 case WM831X_DC1_ON_CONFIG
:
249 case WM831X_DC1_SLEEP_CONTROL
:
250 case WM831X_DC1_DVS_CONTROL
:
251 case WM831X_DC2_CONTROL_1
:
252 case WM831X_DC2_CONTROL_2
:
253 case WM831X_DC2_ON_CONFIG
:
254 case WM831X_DC2_SLEEP_CONTROL
:
255 case WM831X_DC2_DVS_CONTROL
:
256 case WM831X_DC3_CONTROL_1
:
257 case WM831X_DC3_CONTROL_2
:
258 case WM831X_DC3_ON_CONFIG
:
259 case WM831X_DC3_SLEEP_CONTROL
:
260 case WM831X_DC4_CONTROL
:
261 case WM831X_DC4_SLEEP_CONTROL
:
262 case WM831X_EPE1_CONTROL
:
263 case WM831X_EPE2_CONTROL
:
264 case WM831X_LDO1_CONTROL
:
265 case WM831X_LDO1_ON_CONTROL
:
266 case WM831X_LDO1_SLEEP_CONTROL
:
267 case WM831X_LDO2_CONTROL
:
268 case WM831X_LDO2_ON_CONTROL
:
269 case WM831X_LDO2_SLEEP_CONTROL
:
270 case WM831X_LDO3_CONTROL
:
271 case WM831X_LDO3_ON_CONTROL
:
272 case WM831X_LDO3_SLEEP_CONTROL
:
273 case WM831X_LDO4_CONTROL
:
274 case WM831X_LDO4_ON_CONTROL
:
275 case WM831X_LDO4_SLEEP_CONTROL
:
276 case WM831X_LDO5_CONTROL
:
277 case WM831X_LDO5_ON_CONTROL
:
278 case WM831X_LDO5_SLEEP_CONTROL
:
279 case WM831X_LDO6_CONTROL
:
280 case WM831X_LDO6_ON_CONTROL
:
281 case WM831X_LDO6_SLEEP_CONTROL
:
282 case WM831X_LDO7_CONTROL
:
283 case WM831X_LDO7_ON_CONTROL
:
284 case WM831X_LDO7_SLEEP_CONTROL
:
285 case WM831X_LDO8_CONTROL
:
286 case WM831X_LDO8_ON_CONTROL
:
287 case WM831X_LDO8_SLEEP_CONTROL
:
288 case WM831X_LDO9_CONTROL
:
289 case WM831X_LDO9_ON_CONTROL
:
290 case WM831X_LDO9_SLEEP_CONTROL
:
291 case WM831X_LDO10_CONTROL
:
292 case WM831X_LDO10_ON_CONTROL
:
293 case WM831X_LDO10_SLEEP_CONTROL
:
294 case WM831X_LDO11_ON_CONTROL
:
295 case WM831X_LDO11_SLEEP_CONTROL
:
296 case WM831X_POWER_GOOD_SOURCE_1
:
297 case WM831X_POWER_GOOD_SOURCE_2
:
298 case WM831X_CLOCK_CONTROL_1
:
299 case WM831X_CLOCK_CONTROL_2
:
300 case WM831X_FLL_CONTROL_1
:
301 case WM831X_FLL_CONTROL_2
:
302 case WM831X_FLL_CONTROL_3
:
303 case WM831X_FLL_CONTROL_4
:
304 case WM831X_FLL_CONTROL_5
:
305 case WM831X_UNIQUE_ID_1
:
306 case WM831X_UNIQUE_ID_2
:
307 case WM831X_UNIQUE_ID_3
:
308 case WM831X_UNIQUE_ID_4
:
309 case WM831X_UNIQUE_ID_5
:
310 case WM831X_UNIQUE_ID_6
:
311 case WM831X_UNIQUE_ID_7
:
312 case WM831X_UNIQUE_ID_8
:
313 case WM831X_FACTORY_OTP_ID
:
314 case WM831X_FACTORY_OTP_1
:
315 case WM831X_FACTORY_OTP_2
:
316 case WM831X_FACTORY_OTP_3
:
317 case WM831X_FACTORY_OTP_4
:
318 case WM831X_FACTORY_OTP_5
:
319 case WM831X_CUSTOMER_OTP_ID
:
320 case WM831X_DC1_OTP_CONTROL
:
321 case WM831X_DC2_OTP_CONTROL
:
322 case WM831X_DC3_OTP_CONTROL
:
323 case WM831X_LDO1_2_OTP_CONTROL
:
324 case WM831X_LDO3_4_OTP_CONTROL
:
325 case WM831X_LDO5_6_OTP_CONTROL
:
326 case WM831X_LDO7_8_OTP_CONTROL
:
327 case WM831X_LDO9_10_OTP_CONTROL
:
328 case WM831X_LDO11_EPE_CONTROL
:
329 case WM831X_GPIO1_OTP_CONTROL
:
330 case WM831X_GPIO2_OTP_CONTROL
:
331 case WM831X_GPIO3_OTP_CONTROL
:
332 case WM831X_GPIO4_OTP_CONTROL
:
333 case WM831X_GPIO5_OTP_CONTROL
:
334 case WM831X_GPIO6_OTP_CONTROL
:
335 case WM831X_DBE_CHECK_DATA
:
342 static bool wm831x_reg_writeable(struct device
*dev
, unsigned int reg
)
344 struct wm831x
*wm831x
= dev_get_drvdata(dev
);
346 if (wm831x_reg_locked(wm831x
, reg
))
350 case WM831X_SYSVDD_CONTROL
:
351 case WM831X_THERMAL_MONITORING
:
352 case WM831X_POWER_STATE
:
353 case WM831X_WATCHDOG
:
354 case WM831X_ON_PIN_CONTROL
:
355 case WM831X_RESET_CONTROL
:
356 case WM831X_CONTROL_INTERFACE
:
357 case WM831X_SECURITY_KEY
:
358 case WM831X_SOFTWARE_SCRATCH
:
359 case WM831X_OTP_CONTROL
:
360 case WM831X_GPIO_LEVEL
:
361 case WM831X_INTERRUPT_STATUS_1
:
362 case WM831X_INTERRUPT_STATUS_2
:
363 case WM831X_INTERRUPT_STATUS_3
:
364 case WM831X_INTERRUPT_STATUS_4
:
365 case WM831X_INTERRUPT_STATUS_5
:
366 case WM831X_IRQ_CONFIG
:
367 case WM831X_SYSTEM_INTERRUPTS_MASK
:
368 case WM831X_INTERRUPT_STATUS_1_MASK
:
369 case WM831X_INTERRUPT_STATUS_2_MASK
:
370 case WM831X_INTERRUPT_STATUS_3_MASK
:
371 case WM831X_INTERRUPT_STATUS_4_MASK
:
372 case WM831X_INTERRUPT_STATUS_5_MASK
:
373 case WM831X_RTC_TIME_1
:
374 case WM831X_RTC_TIME_2
:
375 case WM831X_RTC_ALARM_1
:
376 case WM831X_RTC_ALARM_2
:
377 case WM831X_RTC_CONTROL
:
378 case WM831X_RTC_TRIM
:
379 case WM831X_TOUCH_CONTROL_1
:
380 case WM831X_TOUCH_CONTROL_2
:
381 case WM831X_AUXADC_CONTROL
:
382 case WM831X_AUXADC_SOURCE
:
383 case WM831X_COMPARATOR_CONTROL
:
384 case WM831X_COMPARATOR_1
:
385 case WM831X_COMPARATOR_2
:
386 case WM831X_COMPARATOR_3
:
387 case WM831X_COMPARATOR_4
:
388 case WM831X_GPIO1_CONTROL
:
389 case WM831X_GPIO2_CONTROL
:
390 case WM831X_GPIO3_CONTROL
:
391 case WM831X_GPIO4_CONTROL
:
392 case WM831X_GPIO5_CONTROL
:
393 case WM831X_GPIO6_CONTROL
:
394 case WM831X_GPIO7_CONTROL
:
395 case WM831X_GPIO8_CONTROL
:
396 case WM831X_GPIO9_CONTROL
:
397 case WM831X_GPIO10_CONTROL
:
398 case WM831X_GPIO11_CONTROL
:
399 case WM831X_GPIO12_CONTROL
:
400 case WM831X_GPIO13_CONTROL
:
401 case WM831X_GPIO14_CONTROL
:
402 case WM831X_GPIO15_CONTROL
:
403 case WM831X_GPIO16_CONTROL
:
404 case WM831X_CHARGER_CONTROL_1
:
405 case WM831X_CHARGER_CONTROL_2
:
406 case WM831X_CHARGER_STATUS
:
407 case WM831X_BACKUP_CHARGER_CONTROL
:
408 case WM831X_STATUS_LED_1
:
409 case WM831X_STATUS_LED_2
:
410 case WM831X_CURRENT_SINK_1
:
411 case WM831X_CURRENT_SINK_2
:
412 case WM831X_DCDC_ENABLE
:
413 case WM831X_LDO_ENABLE
:
414 case WM831X_DC1_CONTROL_1
:
415 case WM831X_DC1_CONTROL_2
:
416 case WM831X_DC1_ON_CONFIG
:
417 case WM831X_DC1_SLEEP_CONTROL
:
418 case WM831X_DC1_DVS_CONTROL
:
419 case WM831X_DC2_CONTROL_1
:
420 case WM831X_DC2_CONTROL_2
:
421 case WM831X_DC2_ON_CONFIG
:
422 case WM831X_DC2_SLEEP_CONTROL
:
423 case WM831X_DC2_DVS_CONTROL
:
424 case WM831X_DC3_CONTROL_1
:
425 case WM831X_DC3_CONTROL_2
:
426 case WM831X_DC3_ON_CONFIG
:
427 case WM831X_DC3_SLEEP_CONTROL
:
428 case WM831X_DC4_CONTROL
:
429 case WM831X_DC4_SLEEP_CONTROL
:
430 case WM831X_EPE1_CONTROL
:
431 case WM831X_EPE2_CONTROL
:
432 case WM831X_LDO1_CONTROL
:
433 case WM831X_LDO1_ON_CONTROL
:
434 case WM831X_LDO1_SLEEP_CONTROL
:
435 case WM831X_LDO2_CONTROL
:
436 case WM831X_LDO2_ON_CONTROL
:
437 case WM831X_LDO2_SLEEP_CONTROL
:
438 case WM831X_LDO3_CONTROL
:
439 case WM831X_LDO3_ON_CONTROL
:
440 case WM831X_LDO3_SLEEP_CONTROL
:
441 case WM831X_LDO4_CONTROL
:
442 case WM831X_LDO4_ON_CONTROL
:
443 case WM831X_LDO4_SLEEP_CONTROL
:
444 case WM831X_LDO5_CONTROL
:
445 case WM831X_LDO5_ON_CONTROL
:
446 case WM831X_LDO5_SLEEP_CONTROL
:
447 case WM831X_LDO6_CONTROL
:
448 case WM831X_LDO6_ON_CONTROL
:
449 case WM831X_LDO6_SLEEP_CONTROL
:
450 case WM831X_LDO7_CONTROL
:
451 case WM831X_LDO7_ON_CONTROL
:
452 case WM831X_LDO7_SLEEP_CONTROL
:
453 case WM831X_LDO8_CONTROL
:
454 case WM831X_LDO8_ON_CONTROL
:
455 case WM831X_LDO8_SLEEP_CONTROL
:
456 case WM831X_LDO9_CONTROL
:
457 case WM831X_LDO9_ON_CONTROL
:
458 case WM831X_LDO9_SLEEP_CONTROL
:
459 case WM831X_LDO10_CONTROL
:
460 case WM831X_LDO10_ON_CONTROL
:
461 case WM831X_LDO10_SLEEP_CONTROL
:
462 case WM831X_LDO11_ON_CONTROL
:
463 case WM831X_LDO11_SLEEP_CONTROL
:
464 case WM831X_POWER_GOOD_SOURCE_1
:
465 case WM831X_POWER_GOOD_SOURCE_2
:
466 case WM831X_CLOCK_CONTROL_1
:
467 case WM831X_CLOCK_CONTROL_2
:
468 case WM831X_FLL_CONTROL_1
:
469 case WM831X_FLL_CONTROL_2
:
470 case WM831X_FLL_CONTROL_3
:
471 case WM831X_FLL_CONTROL_4
:
472 case WM831X_FLL_CONTROL_5
:
479 static bool wm831x_reg_volatile(struct device
*dev
, unsigned int reg
)
482 case WM831X_SYSTEM_STATUS
:
483 case WM831X_ON_SOURCE
:
484 case WM831X_OFF_SOURCE
:
485 case WM831X_GPIO_LEVEL
:
486 case WM831X_SYSTEM_INTERRUPTS
:
487 case WM831X_INTERRUPT_STATUS_1
:
488 case WM831X_INTERRUPT_STATUS_2
:
489 case WM831X_INTERRUPT_STATUS_3
:
490 case WM831X_INTERRUPT_STATUS_4
:
491 case WM831X_INTERRUPT_STATUS_5
:
492 case WM831X_RTC_TIME_1
:
493 case WM831X_RTC_TIME_2
:
494 case WM831X_TOUCH_DATA_X
:
495 case WM831X_TOUCH_DATA_Y
:
496 case WM831X_TOUCH_DATA_Z
:
497 case WM831X_AUXADC_DATA
:
498 case WM831X_CHARGER_STATUS
:
499 case WM831X_DCDC_STATUS
:
500 case WM831X_LDO_STATUS
:
501 case WM831X_DCDC_UV_STATUS
:
502 case WM831X_LDO_UV_STATUS
:
510 * wm831x_reg_read: Read a single WM831x register.
512 * @wm831x: Device to read from.
513 * @reg: Register to read.
515 int wm831x_reg_read(struct wm831x
*wm831x
, unsigned short reg
)
520 ret
= regmap_read(wm831x
->regmap
, reg
, &val
);
527 EXPORT_SYMBOL_GPL(wm831x_reg_read
);
530 * wm831x_bulk_read: Read multiple WM831x registers
532 * @wm831x: Device to read from
533 * @reg: First register
534 * @count: Number of registers
535 * @buf: Buffer to fill.
537 int wm831x_bulk_read(struct wm831x
*wm831x
, unsigned short reg
,
540 return regmap_bulk_read(wm831x
->regmap
, reg
, buf
, count
);
542 EXPORT_SYMBOL_GPL(wm831x_bulk_read
);
544 static int wm831x_write(struct wm831x
*wm831x
, unsigned short reg
,
545 int bytes
, void *src
)
553 for (i
= 0; i
< bytes
/ 2; i
++) {
554 if (wm831x_reg_locked(wm831x
, reg
))
557 dev_vdbg(wm831x
->dev
, "Write %04x to R%d(0x%x)\n",
558 buf
[i
], reg
+ i
, reg
+ i
);
559 ret
= regmap_write(wm831x
->regmap
, reg
+ i
, buf
[i
]);
568 * wm831x_reg_write: Write a single WM831x register.
570 * @wm831x: Device to write to.
571 * @reg: Register to write to.
572 * @val: Value to write.
574 int wm831x_reg_write(struct wm831x
*wm831x
, unsigned short reg
,
579 mutex_lock(&wm831x
->io_lock
);
581 ret
= wm831x_write(wm831x
, reg
, 2, &val
);
583 mutex_unlock(&wm831x
->io_lock
);
587 EXPORT_SYMBOL_GPL(wm831x_reg_write
);
590 * wm831x_set_bits: Set the value of a bitfield in a WM831x register
592 * @wm831x: Device to write to.
593 * @reg: Register to write to.
594 * @mask: Mask of bits to set.
595 * @val: Value to set (unshifted)
597 int wm831x_set_bits(struct wm831x
*wm831x
, unsigned short reg
,
598 unsigned short mask
, unsigned short val
)
602 mutex_lock(&wm831x
->io_lock
);
604 if (!wm831x_reg_locked(wm831x
, reg
))
605 ret
= regmap_update_bits(wm831x
->regmap
, reg
, mask
, val
);
609 mutex_unlock(&wm831x
->io_lock
);
613 EXPORT_SYMBOL_GPL(wm831x_set_bits
);
615 static struct resource wm831x_dcdc1_resources
[] = {
617 .start
= WM831X_DC1_CONTROL_1
,
618 .end
= WM831X_DC1_DVS_CONTROL
,
619 .flags
= IORESOURCE_REG
,
623 .start
= WM831X_IRQ_UV_DC1
,
624 .end
= WM831X_IRQ_UV_DC1
,
625 .flags
= IORESOURCE_IRQ
,
629 .start
= WM831X_IRQ_HC_DC1
,
630 .end
= WM831X_IRQ_HC_DC1
,
631 .flags
= IORESOURCE_IRQ
,
636 static struct resource wm831x_dcdc2_resources
[] = {
638 .start
= WM831X_DC2_CONTROL_1
,
639 .end
= WM831X_DC2_DVS_CONTROL
,
640 .flags
= IORESOURCE_REG
,
644 .start
= WM831X_IRQ_UV_DC2
,
645 .end
= WM831X_IRQ_UV_DC2
,
646 .flags
= IORESOURCE_IRQ
,
650 .start
= WM831X_IRQ_HC_DC2
,
651 .end
= WM831X_IRQ_HC_DC2
,
652 .flags
= IORESOURCE_IRQ
,
656 static struct resource wm831x_dcdc3_resources
[] = {
658 .start
= WM831X_DC3_CONTROL_1
,
659 .end
= WM831X_DC3_SLEEP_CONTROL
,
660 .flags
= IORESOURCE_REG
,
664 .start
= WM831X_IRQ_UV_DC3
,
665 .end
= WM831X_IRQ_UV_DC3
,
666 .flags
= IORESOURCE_IRQ
,
670 static struct resource wm831x_dcdc4_resources
[] = {
672 .start
= WM831X_DC4_CONTROL
,
673 .end
= WM831X_DC4_SLEEP_CONTROL
,
674 .flags
= IORESOURCE_REG
,
678 .start
= WM831X_IRQ_UV_DC4
,
679 .end
= WM831X_IRQ_UV_DC4
,
680 .flags
= IORESOURCE_IRQ
,
684 static struct resource wm8320_dcdc4_buck_resources
[] = {
686 .start
= WM831X_DC4_CONTROL
,
687 .end
= WM832X_DC4_SLEEP_CONTROL
,
688 .flags
= IORESOURCE_REG
,
692 .start
= WM831X_IRQ_UV_DC4
,
693 .end
= WM831X_IRQ_UV_DC4
,
694 .flags
= IORESOURCE_IRQ
,
698 static struct resource wm831x_gpio_resources
[] = {
700 .start
= WM831X_IRQ_GPIO_1
,
701 .end
= WM831X_IRQ_GPIO_16
,
702 .flags
= IORESOURCE_IRQ
,
706 static struct resource wm831x_isink1_resources
[] = {
708 .start
= WM831X_CURRENT_SINK_1
,
709 .end
= WM831X_CURRENT_SINK_1
,
710 .flags
= IORESOURCE_REG
,
713 .start
= WM831X_IRQ_CS1
,
714 .end
= WM831X_IRQ_CS1
,
715 .flags
= IORESOURCE_IRQ
,
719 static struct resource wm831x_isink2_resources
[] = {
721 .start
= WM831X_CURRENT_SINK_2
,
722 .end
= WM831X_CURRENT_SINK_2
,
723 .flags
= IORESOURCE_REG
,
726 .start
= WM831X_IRQ_CS2
,
727 .end
= WM831X_IRQ_CS2
,
728 .flags
= IORESOURCE_IRQ
,
732 static struct resource wm831x_ldo1_resources
[] = {
734 .start
= WM831X_LDO1_CONTROL
,
735 .end
= WM831X_LDO1_SLEEP_CONTROL
,
736 .flags
= IORESOURCE_REG
,
740 .start
= WM831X_IRQ_UV_LDO1
,
741 .end
= WM831X_IRQ_UV_LDO1
,
742 .flags
= IORESOURCE_IRQ
,
746 static struct resource wm831x_ldo2_resources
[] = {
748 .start
= WM831X_LDO2_CONTROL
,
749 .end
= WM831X_LDO2_SLEEP_CONTROL
,
750 .flags
= IORESOURCE_REG
,
754 .start
= WM831X_IRQ_UV_LDO2
,
755 .end
= WM831X_IRQ_UV_LDO2
,
756 .flags
= IORESOURCE_IRQ
,
760 static struct resource wm831x_ldo3_resources
[] = {
762 .start
= WM831X_LDO3_CONTROL
,
763 .end
= WM831X_LDO3_SLEEP_CONTROL
,
764 .flags
= IORESOURCE_REG
,
768 .start
= WM831X_IRQ_UV_LDO3
,
769 .end
= WM831X_IRQ_UV_LDO3
,
770 .flags
= IORESOURCE_IRQ
,
774 static struct resource wm831x_ldo4_resources
[] = {
776 .start
= WM831X_LDO4_CONTROL
,
777 .end
= WM831X_LDO4_SLEEP_CONTROL
,
778 .flags
= IORESOURCE_REG
,
782 .start
= WM831X_IRQ_UV_LDO4
,
783 .end
= WM831X_IRQ_UV_LDO4
,
784 .flags
= IORESOURCE_IRQ
,
788 static struct resource wm831x_ldo5_resources
[] = {
790 .start
= WM831X_LDO5_CONTROL
,
791 .end
= WM831X_LDO5_SLEEP_CONTROL
,
792 .flags
= IORESOURCE_REG
,
796 .start
= WM831X_IRQ_UV_LDO5
,
797 .end
= WM831X_IRQ_UV_LDO5
,
798 .flags
= IORESOURCE_IRQ
,
802 static struct resource wm831x_ldo6_resources
[] = {
804 .start
= WM831X_LDO6_CONTROL
,
805 .end
= WM831X_LDO6_SLEEP_CONTROL
,
806 .flags
= IORESOURCE_REG
,
810 .start
= WM831X_IRQ_UV_LDO6
,
811 .end
= WM831X_IRQ_UV_LDO6
,
812 .flags
= IORESOURCE_IRQ
,
816 static struct resource wm831x_ldo7_resources
[] = {
818 .start
= WM831X_LDO7_CONTROL
,
819 .end
= WM831X_LDO7_SLEEP_CONTROL
,
820 .flags
= IORESOURCE_REG
,
824 .start
= WM831X_IRQ_UV_LDO7
,
825 .end
= WM831X_IRQ_UV_LDO7
,
826 .flags
= IORESOURCE_IRQ
,
830 static struct resource wm831x_ldo8_resources
[] = {
832 .start
= WM831X_LDO8_CONTROL
,
833 .end
= WM831X_LDO8_SLEEP_CONTROL
,
834 .flags
= IORESOURCE_REG
,
838 .start
= WM831X_IRQ_UV_LDO8
,
839 .end
= WM831X_IRQ_UV_LDO8
,
840 .flags
= IORESOURCE_IRQ
,
844 static struct resource wm831x_ldo9_resources
[] = {
846 .start
= WM831X_LDO9_CONTROL
,
847 .end
= WM831X_LDO9_SLEEP_CONTROL
,
848 .flags
= IORESOURCE_REG
,
852 .start
= WM831X_IRQ_UV_LDO9
,
853 .end
= WM831X_IRQ_UV_LDO9
,
854 .flags
= IORESOURCE_IRQ
,
858 static struct resource wm831x_ldo10_resources
[] = {
860 .start
= WM831X_LDO10_CONTROL
,
861 .end
= WM831X_LDO10_SLEEP_CONTROL
,
862 .flags
= IORESOURCE_REG
,
866 .start
= WM831X_IRQ_UV_LDO10
,
867 .end
= WM831X_IRQ_UV_LDO10
,
868 .flags
= IORESOURCE_IRQ
,
872 static struct resource wm831x_ldo11_resources
[] = {
874 .start
= WM831X_LDO11_ON_CONTROL
,
875 .end
= WM831X_LDO11_SLEEP_CONTROL
,
876 .flags
= IORESOURCE_REG
,
880 static struct resource wm831x_on_resources
[] = {
882 .start
= WM831X_IRQ_ON
,
883 .end
= WM831X_IRQ_ON
,
884 .flags
= IORESOURCE_IRQ
,
889 static struct resource wm831x_power_resources
[] = {
892 .start
= WM831X_IRQ_PPM_SYSLO
,
893 .end
= WM831X_IRQ_PPM_SYSLO
,
894 .flags
= IORESOURCE_IRQ
,
898 .start
= WM831X_IRQ_PPM_PWR_SRC
,
899 .end
= WM831X_IRQ_PPM_PWR_SRC
,
900 .flags
= IORESOURCE_IRQ
,
904 .start
= WM831X_IRQ_PPM_USB_CURR
,
905 .end
= WM831X_IRQ_PPM_USB_CURR
,
906 .flags
= IORESOURCE_IRQ
,
910 .start
= WM831X_IRQ_CHG_BATT_HOT
,
911 .end
= WM831X_IRQ_CHG_BATT_HOT
,
912 .flags
= IORESOURCE_IRQ
,
916 .start
= WM831X_IRQ_CHG_BATT_COLD
,
917 .end
= WM831X_IRQ_CHG_BATT_COLD
,
918 .flags
= IORESOURCE_IRQ
,
922 .start
= WM831X_IRQ_CHG_BATT_FAIL
,
923 .end
= WM831X_IRQ_CHG_BATT_FAIL
,
924 .flags
= IORESOURCE_IRQ
,
928 .start
= WM831X_IRQ_CHG_OV
,
929 .end
= WM831X_IRQ_CHG_OV
,
930 .flags
= IORESOURCE_IRQ
,
934 .start
= WM831X_IRQ_CHG_END
,
935 .end
= WM831X_IRQ_CHG_END
,
936 .flags
= IORESOURCE_IRQ
,
940 .start
= WM831X_IRQ_CHG_TO
,
941 .end
= WM831X_IRQ_CHG_TO
,
942 .flags
= IORESOURCE_IRQ
,
946 .start
= WM831X_IRQ_CHG_MODE
,
947 .end
= WM831X_IRQ_CHG_MODE
,
948 .flags
= IORESOURCE_IRQ
,
952 .start
= WM831X_IRQ_CHG_START
,
953 .end
= WM831X_IRQ_CHG_START
,
954 .flags
= IORESOURCE_IRQ
,
958 static struct resource wm831x_rtc_resources
[] = {
961 .start
= WM831X_IRQ_RTC_PER
,
962 .end
= WM831X_IRQ_RTC_PER
,
963 .flags
= IORESOURCE_IRQ
,
967 .start
= WM831X_IRQ_RTC_ALM
,
968 .end
= WM831X_IRQ_RTC_ALM
,
969 .flags
= IORESOURCE_IRQ
,
973 static struct resource wm831x_status1_resources
[] = {
975 .start
= WM831X_STATUS_LED_1
,
976 .end
= WM831X_STATUS_LED_1
,
977 .flags
= IORESOURCE_REG
,
981 static struct resource wm831x_status2_resources
[] = {
983 .start
= WM831X_STATUS_LED_2
,
984 .end
= WM831X_STATUS_LED_2
,
985 .flags
= IORESOURCE_REG
,
989 static struct resource wm831x_touch_resources
[] = {
992 .start
= WM831X_IRQ_TCHPD
,
993 .end
= WM831X_IRQ_TCHPD
,
994 .flags
= IORESOURCE_IRQ
,
998 .start
= WM831X_IRQ_TCHDATA
,
999 .end
= WM831X_IRQ_TCHDATA
,
1000 .flags
= IORESOURCE_IRQ
,
1004 static struct resource wm831x_wdt_resources
[] = {
1006 .start
= WM831X_IRQ_WDOG_TO
,
1007 .end
= WM831X_IRQ_WDOG_TO
,
1008 .flags
= IORESOURCE_IRQ
,
1012 static const struct mfd_cell wm8310_devs
[] = {
1014 .name
= "wm831x-backup",
1017 .name
= "wm831x-buckv",
1019 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1020 .resources
= wm831x_dcdc1_resources
,
1023 .name
= "wm831x-buckv",
1025 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1026 .resources
= wm831x_dcdc2_resources
,
1029 .name
= "wm831x-buckp",
1031 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1032 .resources
= wm831x_dcdc3_resources
,
1035 .name
= "wm831x-boostp",
1037 .num_resources
= ARRAY_SIZE(wm831x_dcdc4_resources
),
1038 .resources
= wm831x_dcdc4_resources
,
1041 .name
= "wm831x-clk",
1044 .name
= "wm831x-epe",
1048 .name
= "wm831x-epe",
1052 .name
= "wm831x-gpio",
1053 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1054 .resources
= wm831x_gpio_resources
,
1057 .name
= "wm831x-hwmon",
1060 .name
= "wm831x-isink",
1062 .num_resources
= ARRAY_SIZE(wm831x_isink1_resources
),
1063 .resources
= wm831x_isink1_resources
,
1066 .name
= "wm831x-isink",
1068 .num_resources
= ARRAY_SIZE(wm831x_isink2_resources
),
1069 .resources
= wm831x_isink2_resources
,
1072 .name
= "wm831x-ldo",
1074 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1075 .resources
= wm831x_ldo1_resources
,
1078 .name
= "wm831x-ldo",
1080 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1081 .resources
= wm831x_ldo2_resources
,
1084 .name
= "wm831x-ldo",
1086 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1087 .resources
= wm831x_ldo3_resources
,
1090 .name
= "wm831x-ldo",
1092 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1093 .resources
= wm831x_ldo4_resources
,
1096 .name
= "wm831x-ldo",
1098 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1099 .resources
= wm831x_ldo5_resources
,
1102 .name
= "wm831x-ldo",
1104 .num_resources
= ARRAY_SIZE(wm831x_ldo6_resources
),
1105 .resources
= wm831x_ldo6_resources
,
1108 .name
= "wm831x-aldo",
1110 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1111 .resources
= wm831x_ldo7_resources
,
1114 .name
= "wm831x-aldo",
1116 .num_resources
= ARRAY_SIZE(wm831x_ldo8_resources
),
1117 .resources
= wm831x_ldo8_resources
,
1120 .name
= "wm831x-aldo",
1122 .num_resources
= ARRAY_SIZE(wm831x_ldo9_resources
),
1123 .resources
= wm831x_ldo9_resources
,
1126 .name
= "wm831x-aldo",
1128 .num_resources
= ARRAY_SIZE(wm831x_ldo10_resources
),
1129 .resources
= wm831x_ldo10_resources
,
1132 .name
= "wm831x-alive-ldo",
1134 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1135 .resources
= wm831x_ldo11_resources
,
1138 .name
= "wm831x-on",
1139 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1140 .resources
= wm831x_on_resources
,
1143 .name
= "wm831x-power",
1144 .num_resources
= ARRAY_SIZE(wm831x_power_resources
),
1145 .resources
= wm831x_power_resources
,
1148 .name
= "wm831x-status",
1150 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1151 .resources
= wm831x_status1_resources
,
1154 .name
= "wm831x-status",
1156 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1157 .resources
= wm831x_status2_resources
,
1160 .name
= "wm831x-watchdog",
1161 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1162 .resources
= wm831x_wdt_resources
,
1166 static const struct mfd_cell wm8311_devs
[] = {
1168 .name
= "wm831x-backup",
1171 .name
= "wm831x-buckv",
1173 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1174 .resources
= wm831x_dcdc1_resources
,
1177 .name
= "wm831x-buckv",
1179 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1180 .resources
= wm831x_dcdc2_resources
,
1183 .name
= "wm831x-buckp",
1185 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1186 .resources
= wm831x_dcdc3_resources
,
1189 .name
= "wm831x-boostp",
1191 .num_resources
= ARRAY_SIZE(wm831x_dcdc4_resources
),
1192 .resources
= wm831x_dcdc4_resources
,
1195 .name
= "wm831x-clk",
1198 .name
= "wm831x-epe",
1202 .name
= "wm831x-epe",
1206 .name
= "wm831x-gpio",
1207 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1208 .resources
= wm831x_gpio_resources
,
1211 .name
= "wm831x-hwmon",
1214 .name
= "wm831x-isink",
1216 .num_resources
= ARRAY_SIZE(wm831x_isink1_resources
),
1217 .resources
= wm831x_isink1_resources
,
1220 .name
= "wm831x-isink",
1222 .num_resources
= ARRAY_SIZE(wm831x_isink2_resources
),
1223 .resources
= wm831x_isink2_resources
,
1226 .name
= "wm831x-ldo",
1228 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1229 .resources
= wm831x_ldo1_resources
,
1232 .name
= "wm831x-ldo",
1234 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1235 .resources
= wm831x_ldo2_resources
,
1238 .name
= "wm831x-ldo",
1240 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1241 .resources
= wm831x_ldo3_resources
,
1244 .name
= "wm831x-ldo",
1246 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1247 .resources
= wm831x_ldo4_resources
,
1250 .name
= "wm831x-ldo",
1252 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1253 .resources
= wm831x_ldo5_resources
,
1256 .name
= "wm831x-aldo",
1258 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1259 .resources
= wm831x_ldo7_resources
,
1262 .name
= "wm831x-alive-ldo",
1264 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1265 .resources
= wm831x_ldo11_resources
,
1268 .name
= "wm831x-on",
1269 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1270 .resources
= wm831x_on_resources
,
1273 .name
= "wm831x-power",
1274 .num_resources
= ARRAY_SIZE(wm831x_power_resources
),
1275 .resources
= wm831x_power_resources
,
1278 .name
= "wm831x-status",
1280 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1281 .resources
= wm831x_status1_resources
,
1284 .name
= "wm831x-status",
1286 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1287 .resources
= wm831x_status2_resources
,
1290 .name
= "wm831x-watchdog",
1291 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1292 .resources
= wm831x_wdt_resources
,
1296 static const struct mfd_cell wm8312_devs
[] = {
1298 .name
= "wm831x-backup",
1301 .name
= "wm831x-buckv",
1303 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1304 .resources
= wm831x_dcdc1_resources
,
1307 .name
= "wm831x-buckv",
1309 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1310 .resources
= wm831x_dcdc2_resources
,
1313 .name
= "wm831x-buckp",
1315 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1316 .resources
= wm831x_dcdc3_resources
,
1319 .name
= "wm831x-boostp",
1321 .num_resources
= ARRAY_SIZE(wm831x_dcdc4_resources
),
1322 .resources
= wm831x_dcdc4_resources
,
1325 .name
= "wm831x-clk",
1328 .name
= "wm831x-epe",
1332 .name
= "wm831x-epe",
1336 .name
= "wm831x-gpio",
1337 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1338 .resources
= wm831x_gpio_resources
,
1341 .name
= "wm831x-hwmon",
1344 .name
= "wm831x-isink",
1346 .num_resources
= ARRAY_SIZE(wm831x_isink1_resources
),
1347 .resources
= wm831x_isink1_resources
,
1350 .name
= "wm831x-isink",
1352 .num_resources
= ARRAY_SIZE(wm831x_isink2_resources
),
1353 .resources
= wm831x_isink2_resources
,
1356 .name
= "wm831x-ldo",
1358 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1359 .resources
= wm831x_ldo1_resources
,
1362 .name
= "wm831x-ldo",
1364 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1365 .resources
= wm831x_ldo2_resources
,
1368 .name
= "wm831x-ldo",
1370 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1371 .resources
= wm831x_ldo3_resources
,
1374 .name
= "wm831x-ldo",
1376 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1377 .resources
= wm831x_ldo4_resources
,
1380 .name
= "wm831x-ldo",
1382 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1383 .resources
= wm831x_ldo5_resources
,
1386 .name
= "wm831x-ldo",
1388 .num_resources
= ARRAY_SIZE(wm831x_ldo6_resources
),
1389 .resources
= wm831x_ldo6_resources
,
1392 .name
= "wm831x-aldo",
1394 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1395 .resources
= wm831x_ldo7_resources
,
1398 .name
= "wm831x-aldo",
1400 .num_resources
= ARRAY_SIZE(wm831x_ldo8_resources
),
1401 .resources
= wm831x_ldo8_resources
,
1404 .name
= "wm831x-aldo",
1406 .num_resources
= ARRAY_SIZE(wm831x_ldo9_resources
),
1407 .resources
= wm831x_ldo9_resources
,
1410 .name
= "wm831x-aldo",
1412 .num_resources
= ARRAY_SIZE(wm831x_ldo10_resources
),
1413 .resources
= wm831x_ldo10_resources
,
1416 .name
= "wm831x-alive-ldo",
1418 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1419 .resources
= wm831x_ldo11_resources
,
1422 .name
= "wm831x-on",
1423 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1424 .resources
= wm831x_on_resources
,
1427 .name
= "wm831x-power",
1428 .num_resources
= ARRAY_SIZE(wm831x_power_resources
),
1429 .resources
= wm831x_power_resources
,
1432 .name
= "wm831x-status",
1434 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1435 .resources
= wm831x_status1_resources
,
1438 .name
= "wm831x-status",
1440 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1441 .resources
= wm831x_status2_resources
,
1444 .name
= "wm831x-watchdog",
1445 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1446 .resources
= wm831x_wdt_resources
,
1450 static const struct mfd_cell wm8320_devs
[] = {
1452 .name
= "wm831x-backup",
1455 .name
= "wm831x-buckv",
1457 .num_resources
= ARRAY_SIZE(wm831x_dcdc1_resources
),
1458 .resources
= wm831x_dcdc1_resources
,
1461 .name
= "wm831x-buckv",
1463 .num_resources
= ARRAY_SIZE(wm831x_dcdc2_resources
),
1464 .resources
= wm831x_dcdc2_resources
,
1467 .name
= "wm831x-buckp",
1469 .num_resources
= ARRAY_SIZE(wm831x_dcdc3_resources
),
1470 .resources
= wm831x_dcdc3_resources
,
1473 .name
= "wm831x-buckp",
1475 .num_resources
= ARRAY_SIZE(wm8320_dcdc4_buck_resources
),
1476 .resources
= wm8320_dcdc4_buck_resources
,
1479 .name
= "wm831x-clk",
1482 .name
= "wm831x-gpio",
1483 .num_resources
= ARRAY_SIZE(wm831x_gpio_resources
),
1484 .resources
= wm831x_gpio_resources
,
1487 .name
= "wm831x-hwmon",
1490 .name
= "wm831x-ldo",
1492 .num_resources
= ARRAY_SIZE(wm831x_ldo1_resources
),
1493 .resources
= wm831x_ldo1_resources
,
1496 .name
= "wm831x-ldo",
1498 .num_resources
= ARRAY_SIZE(wm831x_ldo2_resources
),
1499 .resources
= wm831x_ldo2_resources
,
1502 .name
= "wm831x-ldo",
1504 .num_resources
= ARRAY_SIZE(wm831x_ldo3_resources
),
1505 .resources
= wm831x_ldo3_resources
,
1508 .name
= "wm831x-ldo",
1510 .num_resources
= ARRAY_SIZE(wm831x_ldo4_resources
),
1511 .resources
= wm831x_ldo4_resources
,
1514 .name
= "wm831x-ldo",
1516 .num_resources
= ARRAY_SIZE(wm831x_ldo5_resources
),
1517 .resources
= wm831x_ldo5_resources
,
1520 .name
= "wm831x-ldo",
1522 .num_resources
= ARRAY_SIZE(wm831x_ldo6_resources
),
1523 .resources
= wm831x_ldo6_resources
,
1526 .name
= "wm831x-aldo",
1528 .num_resources
= ARRAY_SIZE(wm831x_ldo7_resources
),
1529 .resources
= wm831x_ldo7_resources
,
1532 .name
= "wm831x-aldo",
1534 .num_resources
= ARRAY_SIZE(wm831x_ldo8_resources
),
1535 .resources
= wm831x_ldo8_resources
,
1538 .name
= "wm831x-aldo",
1540 .num_resources
= ARRAY_SIZE(wm831x_ldo9_resources
),
1541 .resources
= wm831x_ldo9_resources
,
1544 .name
= "wm831x-aldo",
1546 .num_resources
= ARRAY_SIZE(wm831x_ldo10_resources
),
1547 .resources
= wm831x_ldo10_resources
,
1550 .name
= "wm831x-alive-ldo",
1552 .num_resources
= ARRAY_SIZE(wm831x_ldo11_resources
),
1553 .resources
= wm831x_ldo11_resources
,
1556 .name
= "wm831x-on",
1557 .num_resources
= ARRAY_SIZE(wm831x_on_resources
),
1558 .resources
= wm831x_on_resources
,
1561 .name
= "wm831x-status",
1563 .num_resources
= ARRAY_SIZE(wm831x_status1_resources
),
1564 .resources
= wm831x_status1_resources
,
1567 .name
= "wm831x-status",
1569 .num_resources
= ARRAY_SIZE(wm831x_status2_resources
),
1570 .resources
= wm831x_status2_resources
,
1573 .name
= "wm831x-watchdog",
1574 .num_resources
= ARRAY_SIZE(wm831x_wdt_resources
),
1575 .resources
= wm831x_wdt_resources
,
1579 static const struct mfd_cell touch_devs
[] = {
1581 .name
= "wm831x-touch",
1582 .num_resources
= ARRAY_SIZE(wm831x_touch_resources
),
1583 .resources
= wm831x_touch_resources
,
1587 static const struct mfd_cell rtc_devs
[] = {
1589 .name
= "wm831x-rtc",
1590 .num_resources
= ARRAY_SIZE(wm831x_rtc_resources
),
1591 .resources
= wm831x_rtc_resources
,
1595 static const struct mfd_cell backlight_devs
[] = {
1597 .name
= "wm831x-backlight",
1601 struct regmap_config wm831x_regmap_config
= {
1605 .cache_type
= REGCACHE_RBTREE
,
1607 .max_register
= WM831X_DBE_CHECK_DATA
,
1608 .readable_reg
= wm831x_reg_readable
,
1609 .writeable_reg
= wm831x_reg_writeable
,
1610 .volatile_reg
= wm831x_reg_volatile
,
1612 EXPORT_SYMBOL_GPL(wm831x_regmap_config
);
1614 const struct of_device_id wm831x_of_match
[] = {
1615 { .compatible
= "wlf,wm8310", .data
= (void *)WM8310
},
1616 { .compatible
= "wlf,wm8311", .data
= (void *)WM8311
},
1617 { .compatible
= "wlf,wm8312", .data
= (void *)WM8312
},
1618 { .compatible
= "wlf,wm8320", .data
= (void *)WM8320
},
1619 { .compatible
= "wlf,wm8321", .data
= (void *)WM8321
},
1620 { .compatible
= "wlf,wm8325", .data
= (void *)WM8325
},
1621 { .compatible
= "wlf,wm8326", .data
= (void *)WM8326
},
1624 EXPORT_SYMBOL_GPL(wm831x_of_match
);
1627 * Instantiate the generic non-control parts of the device.
1629 int wm831x_device_init(struct wm831x
*wm831x
, int irq
)
1631 struct wm831x_pdata
*pdata
= &wm831x
->pdata
;
1632 int rev
, wm831x_num
;
1633 enum wm831x_parent parent
;
1636 mutex_init(&wm831x
->io_lock
);
1637 mutex_init(&wm831x
->key_lock
);
1638 dev_set_drvdata(wm831x
->dev
, wm831x
);
1640 wm831x
->soft_shutdown
= pdata
->soft_shutdown
;
1642 ret
= wm831x_reg_read(wm831x
, WM831X_PARENT_ID
);
1644 dev_err(wm831x
->dev
, "Failed to read parent ID: %d\n", ret
);
1652 dev_err(wm831x
->dev
, "Device is not a WM831x: ID %x\n", ret
);
1657 ret
= wm831x_reg_read(wm831x
, WM831X_REVISION
);
1659 dev_err(wm831x
->dev
, "Failed to read revision: %d\n", ret
);
1662 rev
= (ret
& WM831X_PARENT_REV_MASK
) >> WM831X_PARENT_REV_SHIFT
;
1664 ret
= wm831x_reg_read(wm831x
, WM831X_RESET_ID
);
1666 dev_err(wm831x
->dev
, "Failed to read device ID: %d\n", ret
);
1670 /* Some engineering samples do not have the ID set, rely on
1671 * the device being registered correctly.
1674 dev_info(wm831x
->dev
, "Device is an engineering sample\n");
1681 wm831x
->num_gpio
= 16;
1682 wm831x
->charger_irq_wake
= 1;
1684 wm831x
->has_gpio_ena
= 1;
1685 wm831x
->has_cs_sts
= 1;
1688 dev_info(wm831x
->dev
, "WM8310 revision %c\n", 'A' + rev
);
1693 wm831x
->num_gpio
= 16;
1694 wm831x
->charger_irq_wake
= 1;
1696 wm831x
->has_gpio_ena
= 1;
1697 wm831x
->has_cs_sts
= 1;
1700 dev_info(wm831x
->dev
, "WM8311 revision %c\n", 'A' + rev
);
1705 wm831x
->num_gpio
= 16;
1706 wm831x
->charger_irq_wake
= 1;
1708 wm831x
->has_gpio_ena
= 1;
1709 wm831x
->has_cs_sts
= 1;
1712 dev_info(wm831x
->dev
, "WM8312 revision %c\n", 'A' + rev
);
1717 wm831x
->num_gpio
= 12;
1718 dev_info(wm831x
->dev
, "WM8320 revision %c\n", 'A' + rev
);
1723 wm831x
->num_gpio
= 12;
1724 dev_info(wm831x
->dev
, "WM8321 revision %c\n", 'A' + rev
);
1729 wm831x
->num_gpio
= 12;
1730 dev_info(wm831x
->dev
, "WM8325 revision %c\n", 'A' + rev
);
1735 wm831x
->num_gpio
= 12;
1736 dev_info(wm831x
->dev
, "WM8326 revision %c\n", 'A' + rev
);
1740 dev_err(wm831x
->dev
, "Unknown WM831x device %04x\n", ret
);
1745 /* This will need revisiting in future but is OK for all
1748 if (parent
!= wm831x
->type
)
1749 dev_warn(wm831x
->dev
, "Device was registered as a WM%x\n",
1752 /* Bootstrap the user key */
1753 ret
= wm831x_reg_read(wm831x
, WM831X_SECURITY_KEY
);
1755 dev_err(wm831x
->dev
, "Failed to read security key: %d\n", ret
);
1759 dev_warn(wm831x
->dev
, "Security key had non-zero value %x\n",
1761 wm831x_reg_write(wm831x
, WM831X_SECURITY_KEY
, 0);
1765 if (pdata
->pre_init
) {
1766 ret
= pdata
->pre_init(wm831x
);
1768 dev_err(wm831x
->dev
, "pre_init() failed: %d\n", ret
);
1773 for (i
= 0; i
< ARRAY_SIZE(pdata
->gpio_defaults
); i
++) {
1774 if (!pdata
->gpio_defaults
[i
])
1777 wm831x_reg_write(wm831x
,
1778 WM831X_GPIO1_CONTROL
+ i
,
1779 pdata
->gpio_defaults
[i
] & 0xffff);
1782 /* Multiply by 10 as we have many subdevices of the same type */
1783 if (pdata
->wm831x_num
)
1784 wm831x_num
= pdata
->wm831x_num
* 10;
1788 ret
= wm831x_irq_init(wm831x
, irq
);
1792 wm831x_auxadc_init(wm831x
);
1794 /* The core device is up, instantiate the subdevices. */
1797 ret
= mfd_add_devices(wm831x
->dev
, wm831x_num
,
1798 wm8310_devs
, ARRAY_SIZE(wm8310_devs
),
1803 ret
= mfd_add_devices(wm831x
->dev
, wm831x_num
,
1804 wm8311_devs
, ARRAY_SIZE(wm8311_devs
),
1806 if (!pdata
->disable_touch
)
1807 mfd_add_devices(wm831x
->dev
, wm831x_num
,
1808 touch_devs
, ARRAY_SIZE(touch_devs
),
1813 ret
= mfd_add_devices(wm831x
->dev
, wm831x_num
,
1814 wm8312_devs
, ARRAY_SIZE(wm8312_devs
),
1816 if (!pdata
->disable_touch
)
1817 mfd_add_devices(wm831x
->dev
, wm831x_num
,
1818 touch_devs
, ARRAY_SIZE(touch_devs
),
1826 ret
= mfd_add_devices(wm831x
->dev
, wm831x_num
,
1827 wm8320_devs
, ARRAY_SIZE(wm8320_devs
),
1832 /* If this happens the bus probe function is buggy */
1837 dev_err(wm831x
->dev
, "Failed to add children\n");
1841 /* The RTC can only be used if the 32.768kHz crystal is
1842 * enabled; this can't be controlled by software at runtime.
1844 ret
= wm831x_reg_read(wm831x
, WM831X_CLOCK_CONTROL_2
);
1846 dev_err(wm831x
->dev
, "Failed to read clock status: %d\n", ret
);
1850 if (ret
& WM831X_XTAL_ENA
) {
1851 ret
= mfd_add_devices(wm831x
->dev
, wm831x_num
,
1852 rtc_devs
, ARRAY_SIZE(rtc_devs
),
1855 dev_err(wm831x
->dev
, "Failed to add RTC: %d\n", ret
);
1859 dev_info(wm831x
->dev
, "32.768kHz clock disabled, no RTC\n");
1862 if (pdata
->backlight
) {
1863 /* Treat errors as non-critical */
1864 ret
= mfd_add_devices(wm831x
->dev
, wm831x_num
, backlight_devs
,
1865 ARRAY_SIZE(backlight_devs
), NULL
,
1868 dev_err(wm831x
->dev
, "Failed to add backlight: %d\n",
1872 wm831x_otp_init(wm831x
);
1874 if (pdata
->post_init
) {
1875 ret
= pdata
->post_init(wm831x
);
1877 dev_err(wm831x
->dev
, "post_init() failed: %d\n", ret
);
1885 wm831x_irq_exit(wm831x
);
1887 mfd_remove_devices(wm831x
->dev
);
1891 int wm831x_device_suspend(struct wm831x
*wm831x
)
1895 /* If the charger IRQs are a wake source then make sure we ack
1896 * them even if they're not actively being used (eg, no power
1897 * driver or no IRQ line wired up) then acknowledge the
1898 * interrupts otherwise suspend won't last very long.
1900 if (wm831x
->charger_irq_wake
) {
1901 reg
= wm831x_reg_read(wm831x
, WM831X_INTERRUPT_STATUS_2_MASK
);
1903 mask
= WM831X_CHG_BATT_HOT_EINT
|
1904 WM831X_CHG_BATT_COLD_EINT
|
1905 WM831X_CHG_BATT_FAIL_EINT
|
1906 WM831X_CHG_OV_EINT
| WM831X_CHG_END_EINT
|
1907 WM831X_CHG_TO_EINT
| WM831X_CHG_MODE_EINT
|
1908 WM831X_CHG_START_EINT
;
1910 /* If any of the interrupts are masked read the statuses */
1912 reg
= wm831x_reg_read(wm831x
,
1913 WM831X_INTERRUPT_STATUS_2
);
1916 dev_info(wm831x
->dev
,
1917 "Acknowledging masked charger IRQs: %x\n",
1919 wm831x_reg_write(wm831x
, WM831X_INTERRUPT_STATUS_2
,
1927 void wm831x_device_shutdown(struct wm831x
*wm831x
)
1929 if (wm831x
->soft_shutdown
) {
1930 dev_info(wm831x
->dev
, "Initiating shutdown...\n");
1931 wm831x_set_bits(wm831x
, WM831X_POWER_STATE
, WM831X_CHIP_ON
, 0);
1934 EXPORT_SYMBOL_GPL(wm831x_device_shutdown
);