diff options
Diffstat (limited to 'firmware/target/arm/sandisk/ata-c200_e200.c')
-rw-r--r-- | firmware/target/arm/sandisk/ata-c200_e200.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/firmware/target/arm/sandisk/ata-c200_e200.c b/firmware/target/arm/sandisk/ata-c200_e200.c index 14be27e19d..8e17152e6f 100644 --- a/firmware/target/arm/sandisk/ata-c200_e200.c +++ b/firmware/target/arm/sandisk/ata-c200_e200.c | |||
@@ -162,7 +162,7 @@ static struct sd_card_status sd_status[NUM_VOLUMES] = | |||
162 | /* Shoot for around 75% usage */ | 162 | /* Shoot for around 75% usage */ |
163 | static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x1c0)/sizeof(long)]; | 163 | static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x1c0)/sizeof(long)]; |
164 | static const char sd_thread_name[] = "ata/sd"; | 164 | static const char sd_thread_name[] = "ata/sd"; |
165 | static struct mutex sd_mtx; | 165 | static struct spinlock sd_spin NOCACHEBSS_ATTR; |
166 | static struct event_queue sd_queue; | 166 | static struct event_queue sd_queue; |
167 | 167 | ||
168 | /* Posted when card plugged status has changed */ | 168 | /* Posted when card plugged status has changed */ |
@@ -801,7 +801,7 @@ int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int incount, | |||
801 | 801 | ||
802 | /* TODO: Add DMA support. */ | 802 | /* TODO: Add DMA support. */ |
803 | 803 | ||
804 | spinlock_lock(&sd_mtx); | 804 | spinlock_lock(&sd_spin); |
805 | 805 | ||
806 | ata_led(true); | 806 | ata_led(true); |
807 | 807 | ||
@@ -888,7 +888,7 @@ ata_read_retry: | |||
888 | while (1) | 888 | while (1) |
889 | { | 889 | { |
890 | ata_led(false); | 890 | ata_led(false); |
891 | spinlock_unlock(&sd_mtx); | 891 | spinlock_unlock(&sd_spin); |
892 | 892 | ||
893 | return ret; | 893 | return ret; |
894 | 894 | ||
@@ -916,7 +916,7 @@ int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, | |||
916 | const unsigned char *buf, *buf_end; | 916 | const unsigned char *buf, *buf_end; |
917 | int bank; | 917 | int bank; |
918 | 918 | ||
919 | spinlock_lock(&sd_mtx); | 919 | spinlock_lock(&sd_spin); |
920 | 920 | ||
921 | ata_led(true); | 921 | ata_led(true); |
922 | 922 | ||
@@ -1016,7 +1016,7 @@ ata_write_retry: | |||
1016 | while (1) | 1016 | while (1) |
1017 | { | 1017 | { |
1018 | ata_led(false); | 1018 | ata_led(false); |
1019 | spinlock_unlock(&sd_mtx); | 1019 | spinlock_unlock(&sd_spin); |
1020 | 1020 | ||
1021 | return ret; | 1021 | return ret; |
1022 | 1022 | ||
@@ -1034,7 +1034,7 @@ ata_write_error: | |||
1034 | static void sd_thread(void) __attribute__((noreturn)); | 1034 | static void sd_thread(void) __attribute__((noreturn)); |
1035 | static void sd_thread(void) | 1035 | static void sd_thread(void) |
1036 | { | 1036 | { |
1037 | struct event ev; | 1037 | struct queue_event ev; |
1038 | bool idle_notified = false; | 1038 | bool idle_notified = false; |
1039 | 1039 | ||
1040 | while (1) | 1040 | while (1) |
@@ -1050,10 +1050,9 @@ static void sd_thread(void) | |||
1050 | 1050 | ||
1051 | /* Lock to keep us from messing with this variable while an init | 1051 | /* Lock to keep us from messing with this variable while an init |
1052 | may be in progress */ | 1052 | may be in progress */ |
1053 | spinlock_lock(&sd_mtx); | 1053 | spinlock_lock(&sd_spin); |
1054 | card_info[1].initialized = 0; | 1054 | card_info[1].initialized = 0; |
1055 | sd_status[1].retry = 0; | 1055 | sd_status[1].retry = 0; |
1056 | spinlock_unlock(&sd_mtx); | ||
1057 | 1056 | ||
1058 | /* Either unmount because the card was pulled or unmount and | 1057 | /* Either unmount because the card was pulled or unmount and |
1059 | remount if already mounted since multiple messages may be | 1058 | remount if already mounted since multiple messages may be |
@@ -1073,6 +1072,8 @@ static void sd_thread(void) | |||
1073 | 1072 | ||
1074 | if (action != SDA_NONE) | 1073 | if (action != SDA_NONE) |
1075 | queue_broadcast(SYS_FS_CHANGED, 0); | 1074 | queue_broadcast(SYS_FS_CHANGED, 0); |
1075 | |||
1076 | spinlock_unlock(&sd_spin); | ||
1076 | break; | 1077 | break; |
1077 | } /* SD_HOTSWAP */ | 1078 | } /* SD_HOTSWAP */ |
1078 | #endif /* HAVE_HOTSWAP */ | 1079 | #endif /* HAVE_HOTSWAP */ |
@@ -1155,9 +1156,9 @@ int ata_init(void) | |||
1155 | { | 1156 | { |
1156 | initialized = true; | 1157 | initialized = true; |
1157 | 1158 | ||
1158 | spinlock_init(&sd_mtx); | 1159 | spinlock_init(&sd_spin IF_COP(, SPINLOCK_TASK_SWITCH)); |
1159 | 1160 | ||
1160 | spinlock_lock(&sd_mtx); | 1161 | spinlock_lock(&sd_spin); |
1161 | 1162 | ||
1162 | /* init controller */ | 1163 | /* init controller */ |
1163 | outl(inl(0x70000088) & ~(0x4), 0x70000088); | 1164 | outl(inl(0x70000088) & ~(0x4), 0x70000088); |
@@ -1181,8 +1182,8 @@ int ata_init(void) | |||
1181 | ret = currcard->initialized; | 1182 | ret = currcard->initialized; |
1182 | 1183 | ||
1183 | queue_init(&sd_queue, true); | 1184 | queue_init(&sd_queue, true); |
1184 | create_thread(sd_thread, sd_stack, sizeof(sd_stack), | 1185 | create_thread(sd_thread, sd_stack, sizeof(sd_stack), 0, |
1185 | sd_thread_name IF_PRIO(, PRIORITY_SYSTEM) IF_COP(, CPU, false)); | 1186 | sd_thread_name IF_PRIO(, PRIORITY_SYSTEM) IF_COP(, CPU)); |
1186 | 1187 | ||
1187 | /* enable interupt for the mSD card */ | 1188 | /* enable interupt for the mSD card */ |
1188 | sleep(HZ/10); | 1189 | sleep(HZ/10); |
@@ -1195,7 +1196,7 @@ int ata_init(void) | |||
1195 | GPIOA_INT_CLR = 0x80; | 1196 | GPIOA_INT_CLR = 0x80; |
1196 | GPIOA_INT_EN |= 0x80; | 1197 | GPIOA_INT_EN |= 0x80; |
1197 | #endif | 1198 | #endif |
1198 | spinlock_unlock(&sd_mtx); | 1199 | spinlock_unlock(&sd_spin); |
1199 | } | 1200 | } |
1200 | 1201 | ||
1201 | return ret; | 1202 | return ret; |