summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/mc13783-imx31.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/mc13783-imx31.c')
-rw-r--r--firmware/target/arm/imx31/mc13783-imx31.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/firmware/target/arm/imx31/mc13783-imx31.c b/firmware/target/arm/imx31/mc13783-imx31.c
index 1c43b3b6fa..a083614488 100644
--- a/firmware/target/arm/imx31/mc13783-imx31.c
+++ b/firmware/target/arm/imx31/mc13783-imx31.c
@@ -26,10 +26,6 @@
26#include "debug.h" 26#include "debug.h"
27#include "kernel.h" 27#include "kernel.h"
28 28
29#ifdef BOOTLOADER
30#define PMIC_DRIVER_CLOSE
31#endif
32
33extern const struct mc13783_event_list mc13783_event_list; 29extern const struct mc13783_event_list mc13783_event_list;
34extern struct spi_node mc13783_spi; 30extern struct spi_node mc13783_spi;
35 31
@@ -47,10 +43,7 @@ static const unsigned char pmic_intm_regs[2] =
47static const unsigned char pmic_ints_regs[2] = 43static const unsigned char pmic_ints_regs[2] =
48 { MC13783_INTERRUPT_STATUS0, MC13783_INTERRUPT_STATUS1 }; 44 { MC13783_INTERRUPT_STATUS0, MC13783_INTERRUPT_STATUS1 };
49 45
50#ifdef PMIC_DRIVER_CLOSE 46static volatile unsigned int mc13783_thread_id = 0;
51static bool pmic_close = false;
52static unsigned int mc13783_thread_id = 0;
53#endif
54 47
55static void mc13783_interrupt_thread(void) 48static void mc13783_interrupt_thread(void)
56{ 49{
@@ -65,10 +58,8 @@ static void mc13783_interrupt_thread(void)
65 58
66 wakeup_wait(&mc13783_wake, TIMEOUT_BLOCK); 59 wakeup_wait(&mc13783_wake, TIMEOUT_BLOCK);
67 60
68#ifdef PMIC_DRIVER_CLOSE 61 if (mc13783_thread_id == 0)
69 if (pmic_close)
70 break; 62 break;
71#endif
72 63
73 mc13783_read_regset(pmic_ints_regs, pending, 2); 64 mc13783_read_regset(pmic_ints_regs, pending, 2);
74 65
@@ -107,9 +98,7 @@ static void mc13783_interrupt_thread(void)
107 while (++event < event_last); 98 while (++event < event_last);
108 } 99 }
109 100
110#ifdef PMIC_DRIVER_CLOSE
111 gpio_disable_event(MC13783_EVENT_ID); 101 gpio_disable_event(MC13783_EVENT_ID);
112#endif
113} 102}
114 103
115/* GPIO interrupt handler for mc13783 */ 104/* GPIO interrupt handler for mc13783 */
@@ -136,15 +125,12 @@ void mc13783_init(void)
136 125
137 MC13783_GPIO_ISR = (1ul << MC13783_GPIO_LINE); 126 MC13783_GPIO_ISR = (1ul << MC13783_GPIO_LINE);
138 127
139#ifdef PMIC_DRIVER_CLOSE
140 mc13783_thread_id = 128 mc13783_thread_id =
141#endif
142 create_thread(mc13783_interrupt_thread, 129 create_thread(mc13783_interrupt_thread,
143 mc13783_thread_stack, sizeof(mc13783_thread_stack), 0, 130 mc13783_thread_stack, sizeof(mc13783_thread_stack), 0,
144 mc13783_thread_name IF_PRIO(, PRIORITY_REALTIME) IF_COP(, CPU)); 131 mc13783_thread_name IF_PRIO(, PRIORITY_REALTIME) IF_COP(, CPU));
145} 132}
146 133
147#ifdef PMIC_DRIVER_CLOSE
148void mc13783_close(void) 134void mc13783_close(void)
149{ 135{
150 unsigned int thread_id = mc13783_thread_id; 136 unsigned int thread_id = mc13783_thread_id;
@@ -153,12 +139,9 @@ void mc13783_close(void)
153 return; 139 return;
154 140
155 mc13783_thread_id = 0; 141 mc13783_thread_id = 0;
156
157 pmic_close = true;
158 wakeup_signal(&mc13783_wake); 142 wakeup_signal(&mc13783_wake);
159 thread_wait(thread_id); 143 thread_wait(thread_id);
160} 144}
161#endif /* PMIC_DRIVER_CLOSE */
162 145
163bool mc13783_enable_event(enum mc13783_event_ids id) 146bool mc13783_enable_event(enum mc13783_event_ids id)
164{ 147{