summaryrefslogtreecommitdiffstats
path: root/firmware/target/mips/ingenic_x1000/msc-x1000.c
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-06-05 11:58:17 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-06-06 11:06:43 +0000
commit2b23d3ecaf2074ad640f66ff198b6043f3ea9e6e (patch)
tree465de543e13bcada2ffe2ba7346a10d57fdbe0be /firmware/target/mips/ingenic_x1000/msc-x1000.c
parente85bc74b307365e9a7b4adab51d646638db12fbd (diff)
downloadrockbox-2b23d3ecaf.tar.gz
rockbox-2b23d3ecaf.zip
x1000: Allow setting IRQ handlers dynamically
Avoids having to #define the names of GPIO pin interrupt handlers, as they can now be set at runtime instead. Change-Id: Ib5da1bdb475ff7b64280fe7cdd00adab63389152
Diffstat (limited to 'firmware/target/mips/ingenic_x1000/msc-x1000.c')
-rw-r--r--firmware/target/mips/ingenic_x1000/msc-x1000.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/firmware/target/mips/ingenic_x1000/msc-x1000.c b/firmware/target/mips/ingenic_x1000/msc-x1000.c
index 92b3d4206a..27929cced5 100644
--- a/firmware/target/mips/ingenic_x1000/msc-x1000.c
+++ b/firmware/target/mips/ingenic_x1000/msc-x1000.c
@@ -42,7 +42,6 @@
static const msc_config msc_configs[] = {
#ifdef FIIO_M3K
#define MSC_CLOCK_SOURCE X1000_CLK_SCLK_A
-#define msc0_cd_interrupt GPIOB06
{
.msc_nr = 0,
.msc_type = MSC_TYPE_SD,
@@ -67,6 +66,9 @@ static const msc_config* msc_lookup_config(int msc)
static msc_drv msc_drivers[MSC_COUNT];
+static void msc0_cd_interrupt(void);
+static void msc1_cd_interrupt(void);
+
/* ---------------------------------------------------------------------------
* Initialization
*/
@@ -123,6 +125,8 @@ static void msc_init_one(msc_drv* d, int msc)
if(gpio_get_level(d->config->cd_gpio) != d->config->cd_active_level)
d->card_present = 0;
+ system_set_irq_handler(GPIO_TO_IRQ(d->config->cd_gpio),
+ msc == 0 ? msc0_cd_interrupt : msc1_cd_interrupt);
gpio_set_function(d->config->cd_gpio, GPIOF_IRQ_EDGE(1));
gpio_flip_edge_irq(d->config->cd_gpio);
gpio_enable_irq(d->config->cd_gpio);
@@ -647,19 +651,15 @@ void MSC1(void)
msc_interrupt(&msc_drivers[1]);
}
-#ifdef msc0_cd_interrupt
-void msc0_cd_interrupt(void)
+static void msc0_cd_interrupt(void)
{
msc_cd_interrupt(&msc_drivers[0]);
}
-#endif
-#ifdef msc1_cd_interrupt
-void msc1_cd_interrupt(void)
+static void msc1_cd_interrupt(void)
{
msc_cd_interrupt(&msc_drivers[1]);
}
-#endif
/* ---------------------------------------------------------------------------
* SD command helpers