diff options
6 files changed, 36 insertions, 39 deletions
diff --git a/firmware/target/arm/imx233/creative-zenxfi3/button-zenxfi3.c b/firmware/target/arm/imx233/creative-zenxfi3/button-zenxfi3.c index 7f981b5d68..c3f1908511 100644 --- a/firmware/target/arm/imx233/creative-zenxfi3/button-zenxfi3.c +++ b/firmware/target/arm/imx233/creative-zenxfi3/button-zenxfi3.c | |||
@@ -66,10 +66,11 @@ static long mpr121_stack[DEFAULT_STACK_SIZE/sizeof(long)]; | |||
66 | static const char mpr121_thread_name[] = "mpr121"; | 66 | static const char mpr121_thread_name[] = "mpr121"; |
67 | static struct event_queue mpr121_queue; | 67 | static struct event_queue mpr121_queue; |
68 | 68 | ||
69 | static void mpr121_irq_cb(int bank, int pin) | 69 | static void mpr121_irq_cb(int bank, int pin, intptr_t user) |
70 | { | 70 | { |
71 | (void) bank; | 71 | (void) bank; |
72 | (void) pin; | 72 | (void) pin; |
73 | (void) user; | ||
73 | /* the callback will not be fired until interrupt is enabled back so | 74 | /* the callback will not be fired until interrupt is enabled back so |
74 | * the queue will not overflow or contain multiple MPR121_INTERRUPT events */ | 75 | * the queue will not overflow or contain multiple MPR121_INTERRUPT events */ |
75 | queue_post(&mpr121_queue, MPR121_INTERRUPT, 0); | 76 | queue_post(&mpr121_queue, MPR121_INTERRUPT, 0); |
@@ -107,7 +108,7 @@ static void mpr121_thread(void) | |||
107 | if(status & 0x80) touchpad_btns |= BUTTON_PLAY; | 108 | if(status & 0x80) touchpad_btns |= BUTTON_PLAY; |
108 | } | 109 | } |
109 | /* enable interrupt */ | 110 | /* enable interrupt */ |
110 | imx233_pinctrl_setup_irq(0, 18, true, true, false, &mpr121_irq_cb); | 111 | imx233_pinctrl_setup_irq(0, 18, true, true, false, &mpr121_irq_cb, 0); |
111 | } | 112 | } |
112 | } | 113 | } |
113 | 114 | ||
@@ -125,7 +126,7 @@ void button_init_device(void) | |||
125 | imx233_pinctrl_acquire(0, 18, "mpr121 int"); | 126 | imx233_pinctrl_acquire(0, 18, "mpr121 int"); |
126 | imx233_pinctrl_set_function(0, 18, PINCTRL_FUNCTION_GPIO); | 127 | imx233_pinctrl_set_function(0, 18, PINCTRL_FUNCTION_GPIO); |
127 | imx233_pinctrl_enable_gpio(0, 18, false); | 128 | imx233_pinctrl_enable_gpio(0, 18, false); |
128 | imx233_pinctrl_setup_irq(0, 18, true, true, false, &mpr121_irq_cb); | 129 | imx233_pinctrl_setup_irq(0, 18, true, true, false, &mpr121_irq_cb, 0); |
129 | /* hold button */ | 130 | /* hold button */ |
130 | imx233_pinctrl_acquire(0, 4, "hold"); | 131 | imx233_pinctrl_acquire(0, 4, "hold"); |
131 | imx233_pinctrl_set_function(0, 4, PINCTRL_FUNCTION_GPIO); | 132 | imx233_pinctrl_set_function(0, 4, PINCTRL_FUNCTION_GPIO); |
diff --git a/firmware/target/arm/imx233/pinctrl-imx233.c b/firmware/target/arm/imx233/pinctrl-imx233.c index 5dc25031b1..ab59532543 100644 --- a/firmware/target/arm/imx233/pinctrl-imx233.c +++ b/firmware/target/arm/imx233/pinctrl-imx233.c | |||
@@ -63,6 +63,7 @@ const char *imx233_pinctrl_blame(unsigned bank, unsigned pin) | |||
63 | #endif | 63 | #endif |
64 | 64 | ||
65 | static pin_irq_cb_t pin_cb[3][32]; /* 3 banks, 32 pins/bank */ | 65 | static pin_irq_cb_t pin_cb[3][32]; /* 3 banks, 32 pins/bank */ |
66 | static intptr_t pin_cb_user[3][32]; | ||
66 | 67 | ||
67 | static void INT_GPIO(int bank) | 68 | static void INT_GPIO(int bank) |
68 | { | 69 | { |
@@ -71,9 +72,12 @@ static void INT_GPIO(int bank) | |||
71 | if(fire & (1 << pin)) | 72 | if(fire & (1 << pin)) |
72 | { | 73 | { |
73 | pin_irq_cb_t cb = pin_cb[bank][pin]; | 74 | pin_irq_cb_t cb = pin_cb[bank][pin]; |
74 | imx233_pinctrl_setup_irq(bank, pin, false, false, false, NULL); | 75 | intptr_t arg = pin_cb_user[bank][pin]; |
76 | /* WARNING: this call will modify pin_cb and pin_cb_user, that's | ||
77 | * why we copy the data before ! */ | ||
78 | imx233_pinctrl_setup_irq(bank, pin, false, false, false, NULL, 0); | ||
75 | if(cb) | 79 | if(cb) |
76 | cb(bank, pin); | 80 | cb(bank, pin, arg); |
77 | } | 81 | } |
78 | } | 82 | } |
79 | 83 | ||
@@ -92,13 +96,14 @@ void INT_GPIO2(void) | |||
92 | INT_GPIO(2); | 96 | INT_GPIO(2); |
93 | } | 97 | } |
94 | 98 | ||
95 | void imx233_pinctrl_setup_irq(int bank, int pin, bool enable_int, | 99 | void imx233_pinctrl_setup_irq(unsigned bank, unsigned pin, bool enable_int, |
96 | bool level, bool polarity, pin_irq_cb_t cb) | 100 | bool level, bool polarity, pin_irq_cb_t cb, intptr_t user) |
97 | { | 101 | { |
98 | HW_PINCTRL_PIN2IRQn_CLR(bank) = 1 << pin; | 102 | HW_PINCTRL_PIN2IRQn_CLR(bank) = 1 << pin; |
99 | HW_PINCTRL_IRQENn_CLR(bank) = 1 << pin; | 103 | HW_PINCTRL_IRQENn_CLR(bank) = 1 << pin; |
100 | HW_PINCTRL_IRQSTATn_CLR(bank) = 1 << pin; | 104 | HW_PINCTRL_IRQSTATn_CLR(bank) = 1 << pin; |
101 | pin_cb[bank][pin] = cb; | 105 | pin_cb[bank][pin] = cb; |
106 | pin_cb_user[bank][pin] = user; | ||
102 | if(enable_int) | 107 | if(enable_int) |
103 | { | 108 | { |
104 | if(level) | 109 | if(level) |
diff --git a/firmware/target/arm/imx233/pinctrl-imx233.h b/firmware/target/arm/imx233/pinctrl-imx233.h index c731490e38..88d08430ad 100644 --- a/firmware/target/arm/imx233/pinctrl-imx233.h +++ b/firmware/target/arm/imx233/pinctrl-imx233.h | |||
@@ -54,7 +54,7 @@ const char *imx233_pinctrl_blame(unsigned bank, unsigned pin); | |||
54 | #define imx233_pinctrl_blame(...) NULL | 54 | #define imx233_pinctrl_blame(...) NULL |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | typedef void (*pin_irq_cb_t)(int bank, int pin); | 57 | typedef void (*pin_irq_cb_t)(int bank, int pin, intptr_t user); |
58 | 58 | ||
59 | static inline void imx233_pinctrl_init(void) | 59 | static inline void imx233_pinctrl_init(void) |
60 | { | 60 | { |
@@ -69,7 +69,7 @@ static inline void imx233_pinctrl_set_drive(unsigned bank, unsigned pin, unsigne | |||
69 | 69 | ||
70 | static inline void imx233_pinctrl_enable_gpio(unsigned bank, unsigned pin, bool enable) | 70 | static inline void imx233_pinctrl_enable_gpio(unsigned bank, unsigned pin, bool enable) |
71 | { | 71 | { |
72 | if(enable) | 72 | if(enable) |
73 | HW_PINCTRL_DOEn_SET(bank) = 1 << pin; | 73 | HW_PINCTRL_DOEn_SET(bank) = 1 << pin; |
74 | else | 74 | else |
75 | HW_PINCTRL_DOEn_CLR(bank) = 1 << pin; | 75 | HW_PINCTRL_DOEn_CLR(bank) = 1 << pin; |
@@ -128,7 +128,7 @@ static inline void imx233_pinctrl_enable_pullup_mask(unsigned bank, uint32_t pin | |||
128 | 128 | ||
129 | /** On irq, the pin irq interrupt is disable and then cb is called; | 129 | /** On irq, the pin irq interrupt is disable and then cb is called; |
130 | * the setup_pin_irq function needs to be called again to enable it again */ | 130 | * the setup_pin_irq function needs to be called again to enable it again */ |
131 | void imx233_pinctrl_setup_irq(int bank, int pin, bool enable_int, | 131 | void imx233_pinctrl_setup_irq(unsigned bank, unsigned pin, bool enable_int, |
132 | bool level, bool polarity, pin_irq_cb_t cb); | 132 | bool level, bool polarity, pin_irq_cb_t cb, intptr_t user); |
133 | 133 | ||
134 | #endif /* __PINCTRL_IMX233_H__ */ | 134 | #endif /* __PINCTRL_IMX233_H__ */ |
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c index 6373038d2e..612ec39fb9 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c | |||
@@ -222,10 +222,11 @@ static int touchpad_read_device(void) | |||
222 | return touchpad_btns; | 222 | return touchpad_btns; |
223 | } | 223 | } |
224 | 224 | ||
225 | static void rmi_attn_cb(int bank, int pin) | 225 | static void rmi_attn_cb(int bank, int pin, intptr_t user) |
226 | { | 226 | { |
227 | (void) bank; | 227 | (void) bank; |
228 | (void) pin; | 228 | (void) pin; |
229 | (void) user; | ||
229 | /* the callback will not be fired until interrupt is enabled back so | 230 | /* the callback will not be fired until interrupt is enabled back so |
230 | * the queue will not overflow or contain multiple RMI_INTERRUPT events */ | 231 | * the queue will not overflow or contain multiple RMI_INTERRUPT events */ |
231 | queue_post(&rmi_queue, RMI_INTERRUPT, 0); | 232 | queue_post(&rmi_queue, RMI_INTERRUPT, 0); |
@@ -271,7 +272,7 @@ static void rmi_thread(void) | |||
271 | touchpad_btns = 0; | 272 | touchpad_btns = 0; |
272 | 273 | ||
273 | /* enable interrupt */ | 274 | /* enable interrupt */ |
274 | imx233_pinctrl_setup_irq(0, 27, true, true, false, &rmi_attn_cb); | 275 | imx233_pinctrl_setup_irq(0, 27, true, true, false, &rmi_attn_cb, 0); |
275 | } | 276 | } |
276 | } | 277 | } |
277 | 278 | ||
@@ -328,7 +329,7 @@ void button_init_device(void) | |||
328 | imx233_pinctrl_acquire(0, 27, "touchpad int"); | 329 | imx233_pinctrl_acquire(0, 27, "touchpad int"); |
329 | imx233_pinctrl_set_function(0, 27, PINCTRL_FUNCTION_GPIO); | 330 | imx233_pinctrl_set_function(0, 27, PINCTRL_FUNCTION_GPIO); |
330 | imx233_pinctrl_enable_gpio(0, 27, false); | 331 | imx233_pinctrl_enable_gpio(0, 27, false); |
331 | imx233_pinctrl_setup_irq(0, 27, true, true, false, &rmi_attn_cb); | 332 | imx233_pinctrl_setup_irq(0, 27, true, true, false, &rmi_attn_cb, 0); |
332 | /* Volume down */ | 333 | /* Volume down */ |
333 | imx233_pinctrl_acquire(1, 30, "volume down"); | 334 | imx233_pinctrl_acquire(1, 30, "volume down"); |
334 | imx233_pinctrl_set_function(1, 30, PINCTRL_FUNCTION_GPIO); | 335 | imx233_pinctrl_set_function(1, 30, PINCTRL_FUNCTION_GPIO); |
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c index 80c9d9149a..ba62ebf59c 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c | |||
@@ -113,10 +113,11 @@ static struct semaphore rds_sema; | |||
113 | static uint32_t rds_stack[DEFAULT_STACK_SIZE / sizeof(uint32_t)]; | 113 | static uint32_t rds_stack[DEFAULT_STACK_SIZE / sizeof(uint32_t)]; |
114 | 114 | ||
115 | /* RDS GPIO interrupt handler */ | 115 | /* RDS GPIO interrupt handler */ |
116 | static void stc_rds_callback(int bank, int pin) | 116 | static void stc_rds_callback(int bank, int pin, intptr_t user) |
117 | { | 117 | { |
118 | (void) bank; | 118 | (void) bank; |
119 | (void) pin; | 119 | (void) pin; |
120 | (void) user; | ||
120 | 121 | ||
121 | semaphore_release(&rds_sema); | 122 | semaphore_release(&rds_sema); |
122 | } | 123 | } |
@@ -132,7 +133,7 @@ static void NORETURN_ATTR rds_thread(void) | |||
132 | if(si4700_rds_read_raw(rds_data) && rds_process(rds_data)) | 133 | if(si4700_rds_read_raw(rds_data) && rds_process(rds_data)) |
133 | si4700_rds_set_event(); | 134 | si4700_rds_set_event(); |
134 | /* renable callback */ | 135 | /* renable callback */ |
135 | imx233_pinctrl_setup_irq(2, 27, true, true, false, &stc_rds_callback); | 136 | imx233_pinctrl_setup_irq(2, 27, true, true, false, &stc_rds_callback, 0); |
136 | } | 137 | } |
137 | } | 138 | } |
138 | 139 | ||
@@ -145,11 +146,11 @@ void si4700_rds_powerup(bool on) | |||
145 | imx233_pinctrl_set_function(2, 27, PINCTRL_FUNCTION_GPIO); | 146 | imx233_pinctrl_set_function(2, 27, PINCTRL_FUNCTION_GPIO); |
146 | imx233_pinctrl_enable_gpio(2, 27, false); | 147 | imx233_pinctrl_enable_gpio(2, 27, false); |
147 | /* pin is set to 0 when an RDS packet has arrived */ | 148 | /* pin is set to 0 when an RDS packet has arrived */ |
148 | imx233_pinctrl_setup_irq(2, 27, true, true, false, &stc_rds_callback); | 149 | imx233_pinctrl_setup_irq(2, 27, true, true, false, &stc_rds_callback, 0); |
149 | } | 150 | } |
150 | else | 151 | else |
151 | { | 152 | { |
152 | imx233_pinctrl_setup_irq(2, 27, false, false, false, NULL); | 153 | imx233_pinctrl_setup_irq(2, 27, false, false, false, NULL, 0); |
153 | imx233_pinctrl_release(2, 27, "tuner stc/rds"); | 154 | imx233_pinctrl_release(2, 27, "tuner stc/rds"); |
154 | } | 155 | } |
155 | } | 156 | } |
diff --git a/firmware/target/arm/imx233/ssp-imx233.c b/firmware/target/arm/imx233/ssp-imx233.c index a3f4083aeb..d83cea7bc0 100644 --- a/firmware/target/arm/imx233/ssp-imx233.c +++ b/firmware/target/arm/imx233/ssp-imx233.c | |||
@@ -335,8 +335,9 @@ void imx233_ssp_sd_mmc_power_up_sequence(int ssp) | |||
335 | SSP_CLRn(SSP_CMD0, ssp, CONT_CLKING_EN); | 335 | SSP_CLRn(SSP_CMD0, ssp, CONT_CLKING_EN); |
336 | } | 336 | } |
337 | 337 | ||
338 | static int ssp_detect_oneshot_callback(int ssp) | 338 | static int ssp_detect_oneshot_callback(struct timeout *tmo) |
339 | { | 339 | { |
340 | int ssp = tmo->data; | ||
340 | ASSERT_SSP(ssp) | 341 | ASSERT_SSP(ssp) |
341 | if(ssp_detect_cb[ssp - 1]) | 342 | if(ssp_detect_cb[ssp - 1]) |
342 | ssp_detect_cb[ssp - 1](ssp); | 343 | ssp_detect_cb[ssp - 1](ssp); |
@@ -344,26 +345,13 @@ static int ssp_detect_oneshot_callback(int ssp) | |||
344 | return 0; | 345 | return 0; |
345 | } | 346 | } |
346 | 347 | ||
347 | static int ssp1_detect_oneshot_callback(struct timeout *tmo) | 348 | static struct timeout ssp_detect_oneshot[2]; |
348 | { | ||
349 | (void) tmo; | ||
350 | return ssp_detect_oneshot_callback(1); | ||
351 | } | ||
352 | |||
353 | static int ssp2_detect_oneshot_callback(struct timeout *tmo) | ||
354 | { | ||
355 | (void) tmo; | ||
356 | return ssp_detect_oneshot_callback(2); | ||
357 | } | ||
358 | 349 | ||
359 | static void detect_irq(int bank, int pin) | 350 | static void detect_irq(int bank, int pin, intptr_t ssp) |
360 | { | 351 | { |
361 | static struct timeout ssp1_detect_oneshot; | 352 | (void) bank; |
362 | static struct timeout ssp2_detect_oneshot; | 353 | (void) pin; |
363 | if(bank == 2 && pin == 1) | 354 | timeout_register(&ssp_detect_oneshot[ssp - 1], ssp_detect_oneshot_callback, (3*HZ/10), ssp); |
364 | timeout_register(&ssp1_detect_oneshot, ssp1_detect_oneshot_callback, (3*HZ/10), 0); | ||
365 | else if(bank == 0 && pin == 19) | ||
366 | timeout_register(&ssp2_detect_oneshot, ssp2_detect_oneshot_callback, (3*HZ/10), 0); | ||
367 | } | 355 | } |
368 | 356 | ||
369 | void imx233_ssp_sdmmc_setup_detect(int ssp, bool enable, ssp_detect_cb_t fn, | 357 | void imx233_ssp_sdmmc_setup_detect(int ssp, bool enable, ssp_detect_cb_t fn, |
@@ -381,8 +369,9 @@ void imx233_ssp_sdmmc_setup_detect(int ssp, bool enable, ssp_detect_cb_t fn, | |||
381 | imx233_pinctrl_enable_gpio(bank, pin, false); | 369 | imx233_pinctrl_enable_gpio(bank, pin, false); |
382 | } | 370 | } |
383 | if(first_time && imx233_ssp_sdmmc_detect(ssp)) | 371 | if(first_time && imx233_ssp_sdmmc_detect(ssp)) |
384 | detect_irq(bank, pin); | 372 | detect_irq(bank, pin, ssp); |
385 | imx233_pinctrl_setup_irq(bank, pin, enable, true, !imx233_ssp_sdmmc_detect_raw(ssp), detect_irq); | 373 | imx233_pinctrl_setup_irq(bank, pin, enable, |
374 | true, !imx233_ssp_sdmmc_detect_raw(ssp), detect_irq, ssp); | ||
386 | } | 375 | } |
387 | 376 | ||
388 | bool imx233_ssp_sdmmc_is_detect_inverted(int ssp) | 377 | bool imx233_ssp_sdmmc_is_detect_inverted(int ssp) |