summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/drivers/ata.c24
-rw-r--r--firmware/target/arm/sandisk/ata-c200_e200.c13
2 files changed, 23 insertions, 14 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 67aab8a9ba..1b917686c5 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -1128,12 +1128,18 @@ static int init_and_check(bool hard_reset)
1128 1128
1129int ata_init(void) 1129int ata_init(void)
1130{ 1130{
1131 int rc; 1131 int rc = 0;
1132 bool coldstart = ata_is_coldstart(); 1132 bool coldstart;
1133 /* must be called before ata_device_init() */
1134 1133
1135 spinlock_init(&ata_spinlock IF_COP(, SPINLOCK_TASK_SWITCH)); 1134 if ( !initialized ) {
1135 spinlock_init(&ata_spinlock IF_COP(, SPINLOCK_TASK_SWITCH));
1136 queue_init(&ata_queue, true);
1137 }
1138
1139 spinlock_lock(&ata_spinlock);
1136 1140
1141 /* must be called before ata_device_init() */
1142 coldstart = ata_is_coldstart();
1137 ata_led(false); 1143 ata_led(false);
1138 ata_device_init(); 1144 ata_device_init();
1139 sleeping = false; 1145 sleeping = false;
@@ -1143,6 +1149,9 @@ int ata_init(void)
1143#endif 1149#endif
1144 1150
1145 if ( !initialized ) { 1151 if ( !initialized ) {
1152 /* First call won't have multiple thread contention */
1153 spinlock_unlock(&ata_spinlock);
1154
1146 if (!ide_powered()) /* somebody has switched it off */ 1155 if (!ide_powered()) /* somebody has switched it off */
1147 { 1156 {
1148 ide_power_enable(true); 1157 ide_power_enable(true);
@@ -1202,8 +1211,6 @@ int ata_init(void)
1202 if (rc) 1211 if (rc)
1203 return -60 + rc; 1212 return -60 + rc;
1204 1213
1205 queue_init(&ata_queue, true);
1206
1207 last_disk_activity = current_tick; 1214 last_disk_activity = current_tick;
1208 create_thread(ata_thread, ata_stack, 1215 create_thread(ata_thread, ata_stack,
1209 sizeof(ata_stack), 0, ata_thread_name 1216 sizeof(ata_stack), 0, ata_thread_name
@@ -1214,9 +1221,10 @@ int ata_init(void)
1214 } 1221 }
1215 rc = set_multiple_mode(multisectors); 1222 rc = set_multiple_mode(multisectors);
1216 if (rc) 1223 if (rc)
1217 return -70 + rc; 1224 rc = -70 + rc;
1218 1225
1219 return 0; 1226 spinlock_unlock(&ata_spinlock);
1227 return rc;
1220} 1228}
1221 1229
1222#if (CONFIG_LED == LED_REAL) 1230#if (CONFIG_LED == LED_REAL)
diff --git a/firmware/target/arm/sandisk/ata-c200_e200.c b/firmware/target/arm/sandisk/ata-c200_e200.c
index 5a7577f08d..ef2bad387b 100644
--- a/firmware/target/arm/sandisk/ata-c200_e200.c
+++ b/firmware/target/arm/sandisk/ata-c200_e200.c
@@ -1149,17 +1149,17 @@ int ata_init(void)
1149{ 1149{
1150 int ret = 0; 1150 int ret = 0;
1151 1151
1152 if (!initialized)
1153 spinlock_init(&sd_spin IF_COP(, SPINLOCK_TASK_SWITCH));
1154
1155 spinlock_lock(&sd_spin);
1156
1152 ata_led(false); 1157 ata_led(false);
1153 1158
1154 /* NOTE: This init isn't dual core safe */
1155 if (!initialized) 1159 if (!initialized)
1156 { 1160 {
1157 initialized = true; 1161 initialized = true;
1158 1162
1159 spinlock_init(&sd_spin IF_COP(, SPINLOCK_TASK_SWITCH));
1160
1161 spinlock_lock(&sd_spin);
1162
1163 /* init controller */ 1163 /* init controller */
1164 outl(inl(0x70000088) & ~(0x4), 0x70000088); 1164 outl(inl(0x70000088) & ~(0x4), 0x70000088);
1165 outl(inl(0x7000008c) & ~(0x4), 0x7000008c); 1165 outl(inl(0x7000008c) & ~(0x4), 0x7000008c);
@@ -1213,9 +1213,10 @@ int ata_init(void)
1213 GPIOL_INT_EN |= 0x08; 1213 GPIOL_INT_EN |= 0x08;
1214#endif 1214#endif
1215#endif 1215#endif
1216 spinlock_unlock(&sd_spin);
1217 } 1216 }
1218 1217
1218 spinlock_unlock(&sd_spin);
1219
1219 return ret; 1220 return ret;
1220} 1221}
1221 1222