summaryrefslogtreecommitdiff
path: root/firmware/target/arm/sandisk
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/sandisk')
-rw-r--r--firmware/target/arm/sandisk/adc-c200_e200.c7
-rw-r--r--firmware/target/arm/sandisk/ata-c200_e200.c27
2 files changed, 16 insertions, 18 deletions
diff --git a/firmware/target/arm/sandisk/adc-c200_e200.c b/firmware/target/arm/sandisk/adc-c200_e200.c
index 31321ece37..9dc8f3aabb 100644
--- a/firmware/target/arm/sandisk/adc-c200_e200.c
+++ b/firmware/target/arm/sandisk/adc-c200_e200.c
@@ -21,8 +21,6 @@
21#include "i2c-pp.h" 21#include "i2c-pp.h"
22#include "as3514.h" 22#include "as3514.h"
23 23
24static struct mutex adc_mutex NOCACHEBSS_ATTR;
25
26/* Read 10-bit channel data */ 24/* Read 10-bit channel data */
27unsigned short adc_read(int channel) 25unsigned short adc_read(int channel)
28{ 26{
@@ -30,7 +28,7 @@ unsigned short adc_read(int channel)
30 28
31 if ((unsigned)channel < NUM_ADC_CHANNELS) 29 if ((unsigned)channel < NUM_ADC_CHANNELS)
32 { 30 {
33 spinlock_lock(&adc_mutex); 31 spinlock_lock(&i2c_spin);
34 32
35 /* Select channel */ 33 /* Select channel */
36 if (pp_i2c_send( AS3514_I2C_ADDR, ADC_0, (channel << 4)) >= 0) 34 if (pp_i2c_send( AS3514_I2C_ADDR, ADC_0, (channel << 4)) >= 0)
@@ -44,7 +42,7 @@ unsigned short adc_read(int channel)
44 } 42 }
45 } 43 }
46 44
47 spinlock_unlock(&adc_mutex); 45 spinlock_unlock(&i2c_spin);
48 } 46 }
49 47
50 return data; 48 return data;
@@ -52,5 +50,4 @@ unsigned short adc_read(int channel)
52 50
53void adc_init(void) 51void adc_init(void)
54{ 52{
55 spinlock_init(&adc_mutex);
56} 53}
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 */
163static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x1c0)/sizeof(long)]; 163static long sd_stack [(DEFAULT_STACK_SIZE*2 + 0x1c0)/sizeof(long)];
164static const char sd_thread_name[] = "ata/sd"; 164static const char sd_thread_name[] = "ata/sd";
165static struct mutex sd_mtx; 165static struct spinlock sd_spin NOCACHEBSS_ATTR;
166static struct event_queue sd_queue; 166static 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:
1034static void sd_thread(void) __attribute__((noreturn)); 1034static void sd_thread(void) __attribute__((noreturn));
1035static void sd_thread(void) 1035static 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;