diff options
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c b/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c index fdb214a33d..d62df92ac5 100644 --- a/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/mc13783-imx31.c | |||
@@ -26,6 +26,7 @@ | |||
26 | 26 | ||
27 | #include "power-imx31.h" | 27 | #include "power-imx31.h" |
28 | #include "button-target.h" | 28 | #include "button-target.h" |
29 | #include "adc-target.h" | ||
29 | 30 | ||
30 | /* This is all based on communicating with the MC13783 PMU which is on | 31 | /* This is all based on communicating with the MC13783 PMU which is on |
31 | * CSPI2 with the chip select at 0. The LCD controller resides on | 32 | * CSPI2 with the chip select at 0. The LCD controller resides on |
@@ -64,17 +65,21 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void) | |||
64 | 65 | ||
65 | gpio_enable_event(MC13783_GPIO_NUM, MC13783_EVENT_ID); | 66 | gpio_enable_event(MC13783_GPIO_NUM, MC13783_EVENT_ID); |
66 | 67 | ||
67 | /* Check initial states */ | 68 | /* Check initial states for events with a sense bit */ |
68 | value = mc13783_read(MC13783_INTERRUPT_SENSE0); | 69 | value = mc13783_read(MC13783_INTERRUPT_SENSE0); |
69 | set_charger_inserted(value & MC13783_CHGDET); | 70 | set_charger_inserted(value & MC13783_CHGDET); |
70 | 71 | ||
71 | value = mc13783_read(MC13783_INTERRUPT_SENSE1); | 72 | value = mc13783_read(MC13783_INTERRUPT_SENSE1); |
72 | button_power_set_state((value & MC13783_ON1B) == 0); | 73 | button_power_set_state((value & MC13783_ONOFD1) == 0); |
73 | set_headphones_inserted((value & MC13783_ON2B) == 0); | 74 | set_headphones_inserted((value & MC13783_ONOFD2) == 0); |
74 | 75 | ||
75 | /* Enable desired PMIC interrupts */ | 76 | pending[0] = pending[1] = 0xffffff; |
77 | mc13783_write_regset(status_regs, pending, 2); | ||
78 | |||
79 | /* Enable desired PMIC interrupts - some are unmasked in the drivers that | ||
80 | * handle a specific task */ | ||
76 | mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_CHGDET); | 81 | mc13783_clear(MC13783_INTERRUPT_MASK0, MC13783_CHGDET); |
77 | mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_ON1B | MC13783_ON2B); | 82 | mc13783_clear(MC13783_INTERRUPT_MASK1, MC13783_ONOFD1 | MC13783_ONOFD2); |
78 | 83 | ||
79 | while (1) | 84 | while (1) |
80 | { | 85 | { |
@@ -83,10 +88,16 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void) | |||
83 | mc13783_read_regset(status_regs, pending, 2); | 88 | mc13783_read_regset(status_regs, pending, 2); |
84 | mc13783_write_regset(status_regs, pending, 2); | 89 | mc13783_write_regset(status_regs, pending, 2); |
85 | 90 | ||
86 | |||
87 | if (pending[0]) | 91 | if (pending[0]) |
88 | { | 92 | { |
89 | /* Handle ...PENDING0 */ | 93 | /* Handle ...PENDING0 */ |
94 | |||
95 | /* Handle interrupts without a sense bit */ | ||
96 | if (pending[0] & MC13783_ADCDONE) | ||
97 | adc_done(); | ||
98 | |||
99 | /* Handle interrupts that have a sense bit that needs to | ||
100 | * be checked */ | ||
90 | if (pending[0] & MC13783_CHGDET) | 101 | if (pending[0] & MC13783_CHGDET) |
91 | { | 102 | { |
92 | value = mc13783_read(MC13783_INTERRUPT_SENSE0); | 103 | value = mc13783_read(MC13783_INTERRUPT_SENSE0); |
@@ -96,19 +107,24 @@ static __attribute__((noreturn)) void mc13783_interrupt_thread(void) | |||
96 | } | 107 | } |
97 | } | 108 | } |
98 | 109 | ||
99 | |||
100 | if (pending[1]) | 110 | if (pending[1]) |
101 | { | 111 | { |
102 | /* Handle ...PENDING1 */ | 112 | /* Handle ...PENDING1 */ |
103 | if (pending[1] & (MC13783_ON1B | MC13783_ON2B)) | 113 | |
114 | /* Handle interrupts without a sense bit */ | ||
115 | /* ... */ | ||
116 | |||
117 | /* Handle interrupts that have a sense bit that needs to | ||
118 | * be checked */ | ||
119 | if (pending[1] & (MC13783_ONOFD1 | MC13783_ONOFD2)) | ||
104 | { | 120 | { |
105 | value = mc13783_read(MC13783_INTERRUPT_SENSE1); | 121 | value = mc13783_read(MC13783_INTERRUPT_SENSE1); |
106 | 122 | ||
107 | if (pending[1] & MC13783_ON1B) | 123 | if (pending[1] & MC13783_ONOFD1) |
108 | button_power_set_state((value & MC13783_ON1B) == 0); | 124 | button_power_set_state((value & MC13783_ONOFD1) == 0); |
109 | 125 | ||
110 | if (pending[1] & MC13783_ON2B) | 126 | if (pending[1] & MC13783_ONOFD2) |
111 | set_headphones_inserted((value & MC13783_ON2B) == 0); | 127 | set_headphones_inserted((value & MC13783_ONOFD2) == 0); |
112 | } | 128 | } |
113 | } | 129 | } |
114 | } | 130 | } |