diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-06-05 11:58:17 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-06-06 11:06:43 +0000 |
commit | 2b23d3ecaf2074ad640f66ff198b6043f3ea9e6e (patch) | |
tree | 465de543e13bcada2ffe2ba7346a10d57fdbe0be /firmware/target/mips/ingenic_x1000/msc-x1000.c | |
parent | e85bc74b307365e9a7b4adab51d646638db12fbd (diff) | |
download | rockbox-2b23d3ecaf2074ad640f66ff198b6043f3ea9e6e.tar.gz rockbox-2b23d3ecaf2074ad640f66ff198b6043f3ea9e6e.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.c | 14 |
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 @@ | |||
42 | static const msc_config msc_configs[] = { | 42 | static const msc_config msc_configs[] = { |
43 | #ifdef FIIO_M3K | 43 | #ifdef FIIO_M3K |
44 | #define MSC_CLOCK_SOURCE X1000_CLK_SCLK_A | 44 | #define MSC_CLOCK_SOURCE X1000_CLK_SCLK_A |
45 | #define msc0_cd_interrupt GPIOB06 | ||
46 | { | 45 | { |
47 | .msc_nr = 0, | 46 | .msc_nr = 0, |
48 | .msc_type = MSC_TYPE_SD, | 47 | .msc_type = MSC_TYPE_SD, |
@@ -67,6 +66,9 @@ static const msc_config* msc_lookup_config(int msc) | |||
67 | 66 | ||
68 | static msc_drv msc_drivers[MSC_COUNT]; | 67 | static msc_drv msc_drivers[MSC_COUNT]; |
69 | 68 | ||
69 | static void msc0_cd_interrupt(void); | ||
70 | static void msc1_cd_interrupt(void); | ||
71 | |||
70 | /* --------------------------------------------------------------------------- | 72 | /* --------------------------------------------------------------------------- |
71 | * Initialization | 73 | * Initialization |
72 | */ | 74 | */ |
@@ -123,6 +125,8 @@ static void msc_init_one(msc_drv* d, int msc) | |||
123 | if(gpio_get_level(d->config->cd_gpio) != d->config->cd_active_level) | 125 | if(gpio_get_level(d->config->cd_gpio) != d->config->cd_active_level) |
124 | d->card_present = 0; | 126 | d->card_present = 0; |
125 | 127 | ||
128 | system_set_irq_handler(GPIO_TO_IRQ(d->config->cd_gpio), | ||
129 | msc == 0 ? msc0_cd_interrupt : msc1_cd_interrupt); | ||
126 | gpio_set_function(d->config->cd_gpio, GPIOF_IRQ_EDGE(1)); | 130 | gpio_set_function(d->config->cd_gpio, GPIOF_IRQ_EDGE(1)); |
127 | gpio_flip_edge_irq(d->config->cd_gpio); | 131 | gpio_flip_edge_irq(d->config->cd_gpio); |
128 | gpio_enable_irq(d->config->cd_gpio); | 132 | gpio_enable_irq(d->config->cd_gpio); |
@@ -647,19 +651,15 @@ void MSC1(void) | |||
647 | msc_interrupt(&msc_drivers[1]); | 651 | msc_interrupt(&msc_drivers[1]); |
648 | } | 652 | } |
649 | 653 | ||
650 | #ifdef msc0_cd_interrupt | 654 | static void msc0_cd_interrupt(void) |
651 | void msc0_cd_interrupt(void) | ||
652 | { | 655 | { |
653 | msc_cd_interrupt(&msc_drivers[0]); | 656 | msc_cd_interrupt(&msc_drivers[0]); |
654 | } | 657 | } |
655 | #endif | ||
656 | 658 | ||
657 | #ifdef msc1_cd_interrupt | 659 | static void msc1_cd_interrupt(void) |
658 | void msc1_cd_interrupt(void) | ||
659 | { | 660 | { |
660 | msc_cd_interrupt(&msc_drivers[1]); | 661 | msc_cd_interrupt(&msc_drivers[1]); |
661 | } | 662 | } |
662 | #endif | ||
663 | 663 | ||
664 | /* --------------------------------------------------------------------------- | 664 | /* --------------------------------------------------------------------------- |
665 | * SD command helpers | 665 | * SD command helpers |