summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2013-06-16 19:32:21 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2013-06-17 00:29:24 +0200
commit8f351d6e212e3b726a9d9020ed8a4119bb68e77e (patch)
treed4ab979baf0c6e56b90a3df5c2ace9cfb924cc47
parent918a06a12ad633a29634f3249990ba04ce9fb00b (diff)
downloadrockbox-8f351d6e212e3b726a9d9020ed8a4119bb68e77e.tar.gz
rockbox-8f351d6e212e3b726a9d9020ed8a4119bb68e77e.tar.bz2
rockbox-8f351d6e212e3b726a9d9020ed8a4119bb68e77e.zip
imx233: enhance pinctrl irq with user pointer
Change-Id: I191704299487598a853af4df5aebbbf8a7134a34
-rw-r--r--firmware/target/arm/imx233/creative-zenxfi3/button-zenxfi3.c7
-rw-r--r--firmware/target/arm/imx233/pinctrl-imx233.c13
-rw-r--r--firmware/target/arm/imx233/pinctrl-imx233.h8
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/button-fuzeplus.c7
-rw-r--r--firmware/target/arm/imx233/sansa-fuzeplus/fmradio-i2c-fuzeplus.c9
-rw-r--r--firmware/target/arm/imx233/ssp-imx233.c31
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)];
static const char mpr121_thread_name[] = "mpr121";
static struct event_queue mpr121_queue;
-static void mpr121_irq_cb(int bank, int pin)
+static void mpr121_irq_cb(int bank, int pin, intptr_t user)
{
(void) bank;
(void) pin;
+ (void) user;
/* the callback will not be fired until interrupt is enabled back so
* the queue will not overflow or contain multiple MPR121_INTERRUPT events */
queue_post(&mpr121_queue, MPR121_INTERRUPT, 0);
@@ -107,7 +108,7 @@ static void mpr121_thread(void)
if(status & 0x80) touchpad_btns |= BUTTON_PLAY;
}
/* enable interrupt */
- imx233_pinctrl_setup_irq(0, 18, true, true, false, &mpr121_irq_cb);
+ imx233_pinctrl_setup_irq(0, 18, true, true, false, &mpr121_irq_cb, 0);
}
}
@@ -125,7 +126,7 @@ void button_init_device(void)
imx233_pinctrl_acquire(0, 18, "mpr121 int");
imx233_pinctrl_set_function(0, 18, PINCTRL_FUNCTION_GPIO);
imx233_pinctrl_enable_gpio(0, 18, false);
- imx233_pinctrl_setup_irq(0, 18, true, true, false, &mpr121_irq_cb);
+ imx233_pinctrl_setup_irq(0, 18, true, true, false, &mpr121_irq_cb, 0);
/* hold button */
imx233_pinctrl_acquire(0, 4, "hold");
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)
#endif
static pin_irq_cb_t pin_cb[3][32]; /* 3 banks, 32 pins/bank */
+static intptr_t pin_cb_user[3][32];
static void INT_GPIO(int bank)
{
@@ -71,9 +72,12 @@ static void INT_GPIO(int bank)
if(fire & (1 << pin))
{
pin_irq_cb_t cb = pin_cb[bank][pin];
- imx233_pinctrl_setup_irq(bank, pin, false, false, false, NULL);
+ intptr_t arg = pin_cb_user[bank][pin];
+ /* WARNING: this call will modify pin_cb and pin_cb_user, that's
+ * why we copy the data before ! */
+ imx233_pinctrl_setup_irq(bank, pin, false, false, false, NULL, 0);
if(cb)
- cb(bank, pin);
+ cb(bank, pin, arg);
}
}
@@ -92,13 +96,14 @@ void INT_GPIO2(void)
INT_GPIO(2);
}
-void imx233_pinctrl_setup_irq(int bank, int pin, bool enable_int,
- bool level, bool polarity, pin_irq_cb_t cb)
+void imx233_pinctrl_setup_irq(unsigned bank, unsigned pin, bool enable_int,
+ bool level, bool polarity, pin_irq_cb_t cb, intptr_t user)
{
HW_PINCTRL_PIN2IRQn_CLR(bank) = 1 << pin;
HW_PINCTRL_IRQENn_CLR(bank) = 1 << pin;
HW_PINCTRL_IRQSTATn_CLR(bank) = 1 << pin;
pin_cb[bank][pin] = cb;
+ pin_cb_user[bank][pin] = user;
if(enable_int)
{
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);
#define imx233_pinctrl_blame(...) NULL
#endif
-typedef void (*pin_irq_cb_t)(int bank, int pin);
+typedef void (*pin_irq_cb_t)(int bank, int pin, intptr_t user);
static inline void imx233_pinctrl_init(void)
{
@@ -69,7 +69,7 @@ static inline void imx233_pinctrl_set_drive(unsigned bank, unsigned pin, unsigne
static inline void imx233_pinctrl_enable_gpio(unsigned bank, unsigned pin, bool enable)
{
- if(enable)
+ if(enable)
HW_PINCTRL_DOEn_SET(bank) = 1 << pin;
else
HW_PINCTRL_DOEn_CLR(bank) = 1 << pin;
@@ -128,7 +128,7 @@ static inline void imx233_pinctrl_enable_pullup_mask(unsigned bank, uint32_t pin
/** On irq, the pin irq interrupt is disable and then cb is called;
* the setup_pin_irq function needs to be called again to enable it again */
-void imx233_pinctrl_setup_irq(int bank, int pin, bool enable_int,
- bool level, bool polarity, pin_irq_cb_t cb);
+void imx233_pinctrl_setup_irq(unsigned bank, unsigned pin, bool enable_int,
+ bool level, bool polarity, pin_irq_cb_t cb, intptr_t user);
#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)
return touchpad_btns;
}
-static void rmi_attn_cb(int bank, int pin)
+static void rmi_attn_cb(int bank, int pin, intptr_t user)
{
(void) bank;
(void) pin;
+ (void) user;
/* the callback will not be fired until interrupt is enabled back so
* the queue will not overflow or contain multiple RMI_INTERRUPT events */
queue_post(&rmi_queue, RMI_INTERRUPT, 0);
@@ -271,7 +272,7 @@ static void rmi_thread(void)
touchpad_btns = 0;
/* enable interrupt */
- imx233_pinctrl_setup_irq(0, 27, true, true, false, &rmi_attn_cb);
+ imx233_pinctrl_setup_irq(0, 27, true, true, false, &rmi_attn_cb, 0);
}
}
@@ -328,7 +329,7 @@ void button_init_device(void)
imx233_pinctrl_acquire(0, 27, "touchpad int");
imx233_pinctrl_set_function(0, 27, PINCTRL_FUNCTION_GPIO);
imx233_pinctrl_enable_gpio(0, 27, false);
- imx233_pinctrl_setup_irq(0, 27, true, true, false, &rmi_attn_cb);
+ imx233_pinctrl_setup_irq(0, 27, true, true, false, &rmi_attn_cb, 0);
/* Volume down */
imx233_pinctrl_acquire(1, 30, "volume down");
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;
static uint32_t rds_stack[DEFAULT_STACK_SIZE / sizeof(uint32_t)];
/* RDS GPIO interrupt handler */
-static void stc_rds_callback(int bank, int pin)
+static void stc_rds_callback(int bank, int pin, intptr_t user)
{
(void) bank;
(void) pin;
+ (void) user;
semaphore_release(&rds_sema);
}
@@ -132,7 +133,7 @@ static void NORETURN_ATTR rds_thread(void)
if(si4700_rds_read_raw(rds_data) && rds_process(rds_data))
si4700_rds_set_event();
/* renable callback */
- imx233_pinctrl_setup_irq(2, 27, true, true, false, &stc_rds_callback);
+ imx233_pinctrl_setup_irq(2, 27, true, true, false, &stc_rds_callback, 0);
}
}
@@ -145,11 +146,11 @@ void si4700_rds_powerup(bool on)
imx233_pinctrl_set_function(2, 27, PINCTRL_FUNCTION_GPIO);
imx233_pinctrl_enable_gpio(2, 27, false);
/* pin is set to 0 when an RDS packet has arrived */
- imx233_pinctrl_setup_irq(2, 27, true, true, false, &stc_rds_callback);
+ imx233_pinctrl_setup_irq(2, 27, true, true, false, &stc_rds_callback, 0);
}
else
{
- imx233_pinctrl_setup_irq(2, 27, false, false, false, NULL);
+ imx233_pinctrl_setup_irq(2, 27, false, false, false, NULL, 0);
imx233_pinctrl_release(2, 27, "tuner stc/rds");
}
}
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)
SSP_CLRn(SSP_CMD0, ssp, CONT_CLKING_EN);
}
-static int ssp_detect_oneshot_callback(int ssp)
+static int ssp_detect_oneshot_callback(struct timeout *tmo)
{
+ int ssp = tmo->data;
ASSERT_SSP(ssp)
if(ssp_detect_cb[ssp - 1])
ssp_detect_cb[ssp - 1](ssp);
@@ -344,26 +345,13 @@ static int ssp_detect_oneshot_callback(int ssp)
return 0;
}
-static int ssp1_detect_oneshot_callback(struct timeout *tmo)
-{
- (void) tmo;
- return ssp_detect_oneshot_callback(1);
-}
-
-static int ssp2_detect_oneshot_callback(struct timeout *tmo)
-{
- (void) tmo;
- return ssp_detect_oneshot_callback(2);
-}
+static struct timeout ssp_detect_oneshot[2];
-static void detect_irq(int bank, int pin)
+static void detect_irq(int bank, int pin, intptr_t ssp)
{
- static struct timeout ssp1_detect_oneshot;
- static struct timeout ssp2_detect_oneshot;
- if(bank == 2 && pin == 1)
- timeout_register(&ssp1_detect_oneshot, ssp1_detect_oneshot_callback, (3*HZ/10), 0);
- else if(bank == 0 && pin == 19)
- timeout_register(&ssp2_detect_oneshot, ssp2_detect_oneshot_callback, (3*HZ/10), 0);
+ (void) bank;
+ (void) pin;
+ timeout_register(&ssp_detect_oneshot[ssp - 1], ssp_detect_oneshot_callback, (3*HZ/10), ssp);
}
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,
imx233_pinctrl_enable_gpio(bank, pin, false);
}
if(first_time && imx233_ssp_sdmmc_detect(ssp))
- detect_irq(bank, pin);
- imx233_pinctrl_setup_irq(bank, pin, enable, true, !imx233_ssp_sdmmc_detect_raw(ssp), detect_irq);
+ detect_irq(bank, pin, ssp);
+ imx233_pinctrl_setup_irq(bank, pin, enable,
+ true, !imx233_ssp_sdmmc_detect_raw(ssp), detect_irq, ssp);
}
bool imx233_ssp_sdmmc_is_detect_inverted(int ssp)