diff options
Diffstat (limited to 'firmware/target/arm/sandisk/ata-c200_e200.c')
-rw-r--r-- | firmware/target/arm/sandisk/ata-c200_e200.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/firmware/target/arm/sandisk/ata-c200_e200.c b/firmware/target/arm/sandisk/ata-c200_e200.c index 8e17152e6f..a8e1651280 100644 --- a/firmware/target/arm/sandisk/ata-c200_e200.c +++ b/firmware/target/arm/sandisk/ata-c200_e200.c | |||
@@ -1171,10 +1171,17 @@ int ata_init(void) | |||
1171 | 1171 | ||
1172 | #ifdef HAVE_HOTSWAP | 1172 | #ifdef HAVE_HOTSWAP |
1173 | /* enable card detection port - mask interrupt first */ | 1173 | /* enable card detection port - mask interrupt first */ |
1174 | #ifdef SANSA_E200 | ||
1174 | GPIOA_INT_EN &= ~0x80; | 1175 | GPIOA_INT_EN &= ~0x80; |
1175 | 1176 | ||
1176 | GPIOA_OUTPUT_EN &= ~0x80; | 1177 | GPIOA_OUTPUT_EN &= ~0x80; |
1177 | GPIOA_ENABLE |= 0x80; | 1178 | GPIOA_ENABLE |= 0x80; |
1179 | #elif defined SANSA_C200 | ||
1180 | GPIOL_INT_EN &= ~0x08; | ||
1181 | |||
1182 | GPIOL_OUTPUT_EN &= ~0x08; | ||
1183 | GPIOL_ENABLE |= 0x08; | ||
1184 | #endif | ||
1178 | #endif | 1185 | #endif |
1179 | sd_select_device(0); | 1186 | sd_select_device(0); |
1180 | 1187 | ||
@@ -1188,6 +1195,7 @@ int ata_init(void) | |||
1188 | /* enable interupt for the mSD card */ | 1195 | /* enable interupt for the mSD card */ |
1189 | sleep(HZ/10); | 1196 | sleep(HZ/10); |
1190 | #ifdef HAVE_HOTSWAP | 1197 | #ifdef HAVE_HOTSWAP |
1198 | #ifdef SANSA_E200 | ||
1191 | CPU_INT_EN = HI_MASK; | 1199 | CPU_INT_EN = HI_MASK; |
1192 | CPU_HI_INT_EN = GPIO0_MASK; | 1200 | CPU_HI_INT_EN = GPIO0_MASK; |
1193 | 1201 | ||
@@ -1195,6 +1203,15 @@ int ata_init(void) | |||
1195 | 1203 | ||
1196 | GPIOA_INT_CLR = 0x80; | 1204 | GPIOA_INT_CLR = 0x80; |
1197 | GPIOA_INT_EN |= 0x80; | 1205 | GPIOA_INT_EN |= 0x80; |
1206 | #elif defined SANSA_C200 | ||
1207 | CPU_INT_EN = HI_MASK; | ||
1208 | CPU_HI_INT_EN = GPIO2_MASK; | ||
1209 | |||
1210 | GPIOL_INT_LEV = (GPIOL_INT_LEV & ~0x08) | (~GPIOL_INPUT_VAL & 0x08); | ||
1211 | |||
1212 | GPIOL_INT_CLR = 0x08; | ||
1213 | GPIOL_INT_EN |= 0x08; | ||
1214 | #endif | ||
1198 | #endif | 1215 | #endif |
1199 | spinlock_unlock(&sd_spin); | 1216 | spinlock_unlock(&sd_spin); |
1200 | } | 1217 | } |
@@ -1239,8 +1256,11 @@ tCardInfo *card_get_info_target(int card_no) | |||
1239 | #ifdef HAVE_HOTSWAP | 1256 | #ifdef HAVE_HOTSWAP |
1240 | bool card_detect_target(void) | 1257 | bool card_detect_target(void) |
1241 | { | 1258 | { |
1242 | /* 0x00:inserted, 0x80:not inserted */ | 1259 | #ifdef SANSA_E200 |
1243 | return (GPIOA_INPUT_VAL & 0x80) == 0; | 1260 | return (GPIOA_INPUT_VAL & 0x80) == 0; /* low active */ |
1261 | #elif defined SANSA_C200 | ||
1262 | return (GPIOL_INPUT_VAL & 0x08) != 0; /* high active */ | ||
1263 | #endif | ||
1244 | } | 1264 | } |
1245 | 1265 | ||
1246 | static bool sd1_oneshot_callback(struct timeout *tmo) | 1266 | static bool sd1_oneshot_callback(struct timeout *tmo) |
@@ -1256,6 +1276,7 @@ void microsd_int(void) | |||
1256 | { | 1276 | { |
1257 | static struct timeout sd1_oneshot; | 1277 | static struct timeout sd1_oneshot; |
1258 | 1278 | ||
1279 | #ifdef SANSA_E200 | ||
1259 | int detect = GPIOA_INPUT_VAL & 0x80; | 1280 | int detect = GPIOA_INPUT_VAL & 0x80; |
1260 | 1281 | ||
1261 | GPIOA_INT_LEV = (GPIOA_INT_LEV & ~0x80) | (detect ^ 0x80); | 1282 | GPIOA_INT_LEV = (GPIOA_INT_LEV & ~0x80) | (detect ^ 0x80); |
@@ -1263,5 +1284,15 @@ void microsd_int(void) | |||
1263 | 1284 | ||
1264 | timeout_register(&sd1_oneshot, sd1_oneshot_callback, | 1285 | timeout_register(&sd1_oneshot, sd1_oneshot_callback, |
1265 | detect ? 1 : HZ/2, detect == 0); | 1286 | detect ? 1 : HZ/2, detect == 0); |
1287 | #elif defined SANSA_C200 | ||
1288 | int detect = GPIOL_INPUT_VAL & 0x08; | ||
1289 | |||
1290 | GPIOL_INT_LEV = (GPIOL_INT_LEV & ~0x08) | (detect ^ 0x08); | ||
1291 | GPIOL_INT_CLR = 0x08; | ||
1292 | |||
1293 | timeout_register(&sd1_oneshot, sd1_oneshot_callback, | ||
1294 | detect ? HZ/2 : 1, detect != 0); | ||
1295 | #endif | ||
1296 | |||
1266 | } | 1297 | } |
1267 | #endif /* HAVE_HOTSWAP */ | 1298 | #endif /* HAVE_HOTSWAP */ |