27 /* |
27 /* |
28 * Register values. |
28 * Register values. |
29 */ |
29 */ |
30 #define WM8350_RESET_ID 0x00 |
30 #define WM8350_RESET_ID 0x00 |
31 #define WM8350_ID 0x01 |
31 #define WM8350_ID 0x01 |
|
32 #define WM8350_REVISION 0x02 |
32 #define WM8350_SYSTEM_CONTROL_1 0x03 |
33 #define WM8350_SYSTEM_CONTROL_1 0x03 |
33 #define WM8350_SYSTEM_CONTROL_2 0x04 |
34 #define WM8350_SYSTEM_CONTROL_2 0x04 |
34 #define WM8350_SYSTEM_HIBERNATE 0x05 |
35 #define WM8350_SYSTEM_HIBERNATE 0x05 |
35 #define WM8350_INTERFACE_CONTROL 0x06 |
36 #define WM8350_INTERFACE_CONTROL 0x06 |
36 #define WM8350_POWER_MGMT_1 0x08 |
37 #define WM8350_POWER_MGMT_1 0x08 |
55 #define WM8350_POWER_UP_INT_STATUS_MASK 0x23 |
56 #define WM8350_POWER_UP_INT_STATUS_MASK 0x23 |
56 #define WM8350_UNDER_VOLTAGE_INT_STATUS_MASK 0x24 |
57 #define WM8350_UNDER_VOLTAGE_INT_STATUS_MASK 0x24 |
57 #define WM8350_OVER_CURRENT_INT_STATUS_MASK 0x25 |
58 #define WM8350_OVER_CURRENT_INT_STATUS_MASK 0x25 |
58 #define WM8350_GPIO_INT_STATUS_MASK 0x26 |
59 #define WM8350_GPIO_INT_STATUS_MASK 0x26 |
59 #define WM8350_COMPARATOR_INT_STATUS_MASK 0x27 |
60 #define WM8350_COMPARATOR_INT_STATUS_MASK 0x27 |
|
61 #define WM8350_CHARGER_OVERRIDES 0xE2 |
|
62 #define WM8350_MISC_OVERRIDES 0xE3 |
|
63 #define WM8350_COMPARATOR_OVERRIDES 0xE7 |
|
64 #define WM8350_STATE_MACHINE_STATUS 0xE9 |
60 |
65 |
61 #define WM8350_MAX_REGISTER 0xFF |
66 #define WM8350_MAX_REGISTER 0xFF |
62 |
67 |
63 /* |
68 /* |
64 * Field Definitions. |
69 * Field Definitions. |
73 * R1 (0x01) - ID |
78 * R1 (0x01) - ID |
74 */ |
79 */ |
75 #define WM8350_CHIP_REV_MASK 0x7000 |
80 #define WM8350_CHIP_REV_MASK 0x7000 |
76 #define WM8350_CONF_STS_MASK 0x0C00 |
81 #define WM8350_CONF_STS_MASK 0x0C00 |
77 #define WM8350_CUST_ID_MASK 0x00FF |
82 #define WM8350_CUST_ID_MASK 0x00FF |
|
83 |
|
84 /* |
|
85 * R2 (0x02) - Revision |
|
86 */ |
|
87 #define WM8350_MASK_REV_MASK 0x00FF |
78 |
88 |
79 /* |
89 /* |
80 * R3 (0x03) - System Control 1 |
90 * R3 (0x03) - System Control 1 |
81 */ |
91 */ |
82 #define WM8350_CHIP_ON 0x8000 |
92 #define WM8350_CHIP_ON 0x8000 |
521 #define WM8350_DC4_STS 0x0008 |
531 #define WM8350_DC4_STS 0x0008 |
522 #define WM8350_DC3_STS 0x0004 |
532 #define WM8350_DC3_STS 0x0004 |
523 #define WM8350_DC2_STS 0x0002 |
533 #define WM8350_DC2_STS 0x0002 |
524 #define WM8350_DC1_STS 0x0001 |
534 #define WM8350_DC1_STS 0x0001 |
525 |
535 |
|
536 /* |
|
537 * R226 (0xE2) - Charger status |
|
538 */ |
|
539 #define WM8350_CHG_BATT_HOT_OVRDE 0x8000 |
|
540 #define WM8350_CHG_BATT_COLD_OVRDE 0x4000 |
|
541 |
|
542 /* |
|
543 * R227 (0xE3) - Misc Overrides |
|
544 */ |
|
545 #define WM8350_USB_LIMIT_OVRDE 0x0400 |
|
546 |
|
547 /* |
|
548 * R227 (0xE7) - Comparator Overrides |
|
549 */ |
|
550 #define WM8350_USB_FB_OVRDE 0x8000 |
|
551 #define WM8350_WALL_FB_OVRDE 0x4000 |
|
552 #define WM8350_BATT_FB_OVRDE 0x2000 |
|
553 |
|
554 |
|
555 /* |
|
556 * R233 (0xE9) - State Machinine Status |
|
557 */ |
|
558 #define WM8350_USB_SM_MASK 0x0700 |
|
559 #define WM8350_USB_SM_SHIFT 8 |
|
560 |
|
561 #define WM8350_USB_SM_100_SLV 1 |
|
562 #define WM8350_USB_SM_500_SLV 5 |
|
563 #define WM8350_USB_SM_STDBY_SLV 7 |
|
564 |
526 /* WM8350 wake up conditions */ |
565 /* WM8350 wake up conditions */ |
527 #define WM8350_IRQ_WKUP_OFF_STATE 43 |
566 #define WM8350_IRQ_WKUP_OFF_STATE 43 |
528 #define WM8350_IRQ_WKUP_HIB_STATE 44 |
567 #define WM8350_IRQ_WKUP_HIB_STATE 44 |
529 #define WM8350_IRQ_WKUP_CONV_FAULT 45 |
568 #define WM8350_IRQ_WKUP_CONV_FAULT 45 |
530 #define WM8350_IRQ_WKUP_WDOG_RST 46 |
569 #define WM8350_IRQ_WKUP_WDOG_RST 46 |
534 |
573 |
535 /* wm8350 chip revisions */ |
574 /* wm8350 chip revisions */ |
536 #define WM8350_REV_E 0x4 |
575 #define WM8350_REV_E 0x4 |
537 #define WM8350_REV_F 0x5 |
576 #define WM8350_REV_F 0x5 |
538 #define WM8350_REV_G 0x6 |
577 #define WM8350_REV_G 0x6 |
|
578 #define WM8350_REV_H 0x7 |
539 |
579 |
540 #define WM8350_NUM_IRQ 63 |
580 #define WM8350_NUM_IRQ 63 |
541 |
581 |
542 struct wm8350_reg_access { |
582 struct wm8350_reg_access { |
543 u16 readable; /* Mask of readable bits */ |
583 u16 readable; /* Mask of readable bits */ |
547 extern const struct wm8350_reg_access wm8350_reg_io_map[]; |
587 extern const struct wm8350_reg_access wm8350_reg_io_map[]; |
548 extern const u16 wm8350_mode0_defaults[]; |
588 extern const u16 wm8350_mode0_defaults[]; |
549 extern const u16 wm8350_mode1_defaults[]; |
589 extern const u16 wm8350_mode1_defaults[]; |
550 extern const u16 wm8350_mode2_defaults[]; |
590 extern const u16 wm8350_mode2_defaults[]; |
551 extern const u16 wm8350_mode3_defaults[]; |
591 extern const u16 wm8350_mode3_defaults[]; |
|
592 extern const u16 wm8351_mode0_defaults[]; |
|
593 extern const u16 wm8351_mode1_defaults[]; |
|
594 extern const u16 wm8351_mode2_defaults[]; |
|
595 extern const u16 wm8351_mode3_defaults[]; |
|
596 extern const u16 wm8352_mode0_defaults[]; |
|
597 extern const u16 wm8352_mode1_defaults[]; |
|
598 extern const u16 wm8352_mode2_defaults[]; |
|
599 extern const u16 wm8352_mode3_defaults[]; |
552 |
600 |
553 struct wm8350; |
601 struct wm8350; |
554 |
602 |
555 struct wm8350_irq { |
603 struct wm8350_irq { |
556 void (*handler) (struct wm8350 *, int, void *); |
604 void (*handler) (struct wm8350 *, int, void *); |
557 void *data; |
605 void *data; |
558 }; |
606 }; |
559 |
607 |
560 struct wm8350 { |
608 struct wm8350 { |
561 int rev; /* chip revision */ |
|
562 |
|
563 struct device *dev; |
609 struct device *dev; |
564 |
610 |
565 /* device IO */ |
611 /* device IO */ |
566 union { |
612 union { |
567 struct i2c_client *i2c_client; |
613 struct i2c_client *i2c_client; |
570 int (*read_dev)(struct wm8350 *wm8350, char reg, int size, void *dest); |
616 int (*read_dev)(struct wm8350 *wm8350, char reg, int size, void *dest); |
571 int (*write_dev)(struct wm8350 *wm8350, char reg, int size, |
617 int (*write_dev)(struct wm8350 *wm8350, char reg, int size, |
572 void *src); |
618 void *src); |
573 u16 *reg_cache; |
619 u16 *reg_cache; |
574 |
620 |
|
621 struct mutex auxadc_mutex; |
|
622 |
575 /* Interrupt handling */ |
623 /* Interrupt handling */ |
576 struct work_struct irq_work; |
624 struct work_struct irq_work; |
577 struct mutex irq_mutex; /* IRQ table mutex */ |
625 struct mutex irq_mutex; /* IRQ table mutex */ |
578 struct wm8350_irq irq[WM8350_NUM_IRQ]; |
626 struct wm8350_irq irq[WM8350_NUM_IRQ]; |
579 int chip_irq; |
627 int chip_irq; |