summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/ata_sd_as3525.c66
1 files changed, 16 insertions, 50 deletions
diff --git a/firmware/target/arm/as3525/ata_sd_as3525.c b/firmware/target/arm/as3525/ata_sd_as3525.c
index b61c49ca37..92dc0b746b 100644
--- a/firmware/target/arm/as3525/ata_sd_as3525.c
+++ b/firmware/target/arm/as3525/ata_sd_as3525.c
@@ -132,7 +132,6 @@ static unsigned char *uncached_buffer = UNCACHED_ADDR(&aligned_buffer[0]);
132static inline void mci_delay(void) { int i = 0xffff; while(i--) ; } 132static inline void mci_delay(void) { int i = 0xffff; while(i--) ; }
133 133
134#ifdef HAVE_HOTSWAP 134#ifdef HAVE_HOTSWAP
135#if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2)
136static int sd1_oneshot_callback(struct timeout *tmo) 135static int sd1_oneshot_callback(struct timeout *tmo)
137{ 136{
138 (void)tmo; 137 (void)tmo;
@@ -152,11 +151,10 @@ static int sd1_oneshot_callback(struct timeout *tmo)
152void INT_GPIOA(void) 151void INT_GPIOA(void)
153{ 152{
154 static struct timeout sd1_oneshot; 153 static struct timeout sd1_oneshot;
155 /* reset irq */ 154 /* acknowledge interrupt */
156 GPIOA_IC = (1<<2); 155 GPIOA_IC = (1<<2);
157 timeout_register(&sd1_oneshot, sd1_oneshot_callback, (3*HZ/10), 0); 156 timeout_register(&sd1_oneshot, sd1_oneshot_callback, (3*HZ/10), 0);
158} 157}
159#endif /* defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2) */
160#endif /* HAVE_HOTSWAP */ 158#endif /* HAVE_HOTSWAP */
161 159
162void INT_NAND(void) 160void INT_NAND(void)
@@ -448,7 +446,6 @@ static void init_pl180_controller(const int drive)
448 VIC_INT_ENABLE |= 446 VIC_INT_ENABLE |=
449 (drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0; 447 (drive == INTERNAL_AS3525) ? INTERRUPT_NAND : INTERRUPT_MCI0;
450 448
451#if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2)
452 /* setup isr for microsd monitoring */ 449 /* setup isr for microsd monitoring */
453 VIC_INT_ENABLE |= (INTERRUPT_GPIOA); 450 VIC_INT_ENABLE |= (INTERRUPT_GPIOA);
454 /* clear previous irq */ 451 /* clear previous irq */
@@ -458,8 +455,6 @@ static void init_pl180_controller(const int drive)
458 /* detect both raising and falling edges */ 455 /* detect both raising and falling edges */
459 GPIOA_IBE |= (1<<2); 456 GPIOA_IBE |= (1<<2);
460 457
461#endif
462
463#else 458#else
464 VIC_INT_ENABLE |= INTERRUPT_NAND; 459 VIC_INT_ENABLE |= INTERRUPT_NAND;
465#endif 460#endif
@@ -519,27 +514,14 @@ int sd_init(void)
519#ifdef HAVE_HOTSWAP 514#ifdef HAVE_HOTSWAP
520bool sd_removable(IF_MD_NONVOID(int drive)) 515bool sd_removable(IF_MD_NONVOID(int drive))
521{ 516{
522#ifndef HAVE_MULTIDRIVE
523 const int drive=0;
524#endif
525 return (drive==1); 517 return (drive==1);
526} 518}
527 519
528bool sd_present(IF_MD_NONVOID(int drive)) 520bool sd_present(IF_MD_NONVOID(int drive))
529{ 521{
530#ifndef HAVE_MULTIDRIVE 522 return (drive == 0) ? true : card_detect_target();
531 const int drive=0;
532#endif
533 if(drive==0)
534 {
535 return true;
536 }
537 else
538 {
539 return card_detect_target();
540 }
541} 523}
542#endif 524#endif /* HAVE_HOTSWAP */
543 525
544static int sd_wait_for_state(const int drive, unsigned int state) 526static int sd_wait_for_state(const int drive, unsigned int state)
545{ 527{
@@ -825,7 +807,7 @@ long sd_last_disk_activity(void)
825 807
826void sd_enable(bool on) 808void sd_enable(bool on)
827{ 809{
828 /* buttonlight AMSes need a bit of special handling for the buttonlight here, 810 /* buttonlight AMSes need a bit of special handling for the buttonlight here
829 * due to the dual mapping of GPIOD and XPD */ 811 * due to the dual mapping of GPIOD and XPD */
830#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE) 812#if defined(HAVE_BUTTON_LIGHT) && defined(HAVE_MULTIDRIVE)
831 extern int buttonlight_is_on; 813 extern int buttonlight_is_on;
@@ -843,8 +825,8 @@ void sd_enable(bool on)
843 GPIOD_DIR &= ~(1<<7); 825 GPIOD_DIR &= ~(1<<7);
844 else 826 else
845 _buttonlight_off(); 827 _buttonlight_off();
846#endif 828#endif /* HAVE_BUTTON_LIGHT */
847#endif 829#endif /* HAVE_MULTIDRIVE */
848 CGU_IDE |= (1<<7) /* AHB interface enable */ | 830 CGU_IDE |= (1<<7) /* AHB interface enable */ |
849 (1<<6) /* interface enable */; 831 (1<<6) /* interface enable */;
850 sd_enabled = true; 832 sd_enabled = true;
@@ -857,9 +839,9 @@ void sd_enable(bool on)
857 CCU_IO &= ~(1<<2); 839 CCU_IO &= ~(1<<2);
858 if (buttonlight_is_on) 840 if (buttonlight_is_on)
859 _buttonlight_on(); 841 _buttonlight_on();
860#endif 842#endif /* HAVE_BUTTON_LIGHT */
861 CGU_PERI &= ~CGU_MCI_CLOCK_ENABLE; 843 CGU_PERI &= ~CGU_MCI_CLOCK_ENABLE;
862#endif 844#endif /* HAVE_MULTIDRIVE */
863 CGU_IDE &= ~((1<<7)|(1<<6)); 845 CGU_IDE &= ~((1<<7)|(1<<6));
864 sd_enabled = false; 846 sd_enabled = false;
865 } 847 }
@@ -872,8 +854,7 @@ tCardInfo *card_get_info_target(int card_no)
872 854
873bool card_detect_target(void) 855bool card_detect_target(void)
874{ 856{
875#if defined(HAVE_HOTSWAP) && \ 857#if defined(HAVE_MULTIDRIVE)
876 (defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2))
877 return !(GPIOA_PIN(2)); 858 return !(GPIOA_PIN(2));
878#else 859#else
879 return false; 860 return false;
@@ -883,36 +864,21 @@ bool card_detect_target(void)
883#ifdef HAVE_HOTSWAP 864#ifdef HAVE_HOTSWAP
884void card_enable_monitoring_target(bool on) 865void card_enable_monitoring_target(bool on)
885{ 866{
886 if (on) 867 if (on) /* enable interrupt */
887 {
888 /* add e200v2/c200v2 here */
889#if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2)
890 /* enable isr*/
891 GPIOA_IE |= (1<<2); 868 GPIOA_IE |= (1<<2);
892#endif 869 else /* disable interrupt */
893 }
894 else
895 {
896#if defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_C200V2)
897 /* edisable isr*/
898 GPIOA_IE &= ~(1<<2); 870 GPIOA_IE &= ~(1<<2);
899#endif
900 }
901} 871}
902#endif 872#endif /* HAVE_HOTSWAP */
903 873
904#endif /* BOOTLOADER */ 874#endif /* !BOOTLOADER */
905 875
906#ifdef CONFIG_STORAGE_MULTI 876#ifdef CONFIG_STORAGE_MULTI
907int sd_num_drives(int first_drive) 877int sd_num_drives(int first_drive)
908{ 878{
909 /* We don't care which logical drive number(s) we have been assigned */ 879 /* We don't care which logical drive number(s) we have been assigned */
910 (void)first_drive; 880 (void)first_drive;
911 881
912#ifdef HAVE_MULTIDRIVE 882 return NUM_DRIVES;
913 return 2;
914#else
915 return 1;
916#endif
917} 883}
918#endif 884#endif /* CONFIG_STORAGE_MULTI */