diff options
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c b/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c index a924b82959..403946bfa6 100644 --- a/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c +++ b/firmware/target/arm/s5l8702/ipod6g/storage_ata-ipod6g.c | |||
@@ -33,7 +33,9 @@ | |||
33 | #include "led.h" | 33 | #include "led.h" |
34 | #include "ata_idle_notify.h" | 34 | #include "ata_idle_notify.h" |
35 | #include "disk_cache.h" | 35 | #include "disk_cache.h" |
36 | #ifdef CHECK_ATA_SWAP | ||
36 | #include "splash.h" | 37 | #include "splash.h" |
38 | #endif | ||
37 | 39 | ||
38 | 40 | ||
39 | #ifndef ATA_RETRIES | 41 | #ifndef ATA_RETRIES |
@@ -51,7 +53,9 @@ | |||
51 | static uint8_t ceata_taskfile[16] STORAGE_ALIGN_ATTR; | 53 | static uint8_t ceata_taskfile[16] STORAGE_ALIGN_ATTR; |
52 | static uint16_t ata_identify_data[0x100] STORAGE_ALIGN_ATTR; | 54 | static uint16_t ata_identify_data[0x100] STORAGE_ALIGN_ATTR; |
53 | static bool ceata; | 55 | static bool ceata; |
56 | #ifdef CHECK_ATA_SWAP | ||
54 | static bool ata_swap; | 57 | static bool ata_swap; |
58 | #endif | ||
55 | static bool ata_lba48; | 59 | static bool ata_lba48; |
56 | static bool ata_dma; | 60 | static bool ata_dma; |
57 | static uint64_t ata_total_sectors; | 61 | static uint64_t ata_total_sectors; |
@@ -532,14 +536,18 @@ static int ata_identify(uint16_t* buf) | |||
532 | } | 536 | } |
533 | else | 537 | else |
534 | { | 538 | { |
539 | #ifdef CHECK_ATA_SWAP | ||
535 | uint32_t old = ATA_CFG; | 540 | uint32_t old = ATA_CFG; |
536 | ATA_CFG |= BIT(6); | 541 | ATA_CFG |= BIT(6); |
542 | #endif | ||
537 | PASS_RC(ata_wait_for_not_bsy(10000000), 1, 0); | 543 | PASS_RC(ata_wait_for_not_bsy(10000000), 1, 0); |
538 | ata_write_cbr(&ATA_PIO_DVR, 0); | 544 | ata_write_cbr(&ATA_PIO_DVR, 0); |
539 | ata_write_cbr(&ATA_PIO_CSD, 0xec); | 545 | ata_write_cbr(&ATA_PIO_CSD, 0xec); |
540 | PASS_RC(ata_wait_for_start_of_transfer(10000000), 1, 1); | 546 | PASS_RC(ata_wait_for_start_of_transfer(10000000), 1, 1); |
541 | for (i = 0; i < 0x100; i++) buf[i] = ata_read_cbr(&ATA_PIO_DTR); | 547 | for (i = 0; i < 0x100; i++) buf[i] = ata_read_cbr(&ATA_PIO_DTR); |
548 | #ifdef CHECK_ATA_SWAP | ||
542 | ATA_CFG = old; | 549 | ATA_CFG = old; |
550 | #endif | ||
543 | } | 551 | } |
544 | return 0; | 552 | return 0; |
545 | } | 553 | } |
@@ -628,7 +636,11 @@ static int ata_power_up(void) | |||
628 | sleep(HZ / 5); | 636 | sleep(HZ / 5); |
629 | ATA_PIO_TIME = 0x191f7; | 637 | ATA_PIO_TIME = 0x191f7; |
630 | ATA_PIO_LHR = 0; | 638 | ATA_PIO_LHR = 0; |
639 | #ifdef CHECK_ATA_SWAP | ||
631 | if (!ata_swap) ATA_CFG = BIT(6); | 640 | if (!ata_swap) ATA_CFG = BIT(6); |
641 | #else | ||
642 | ATA_CFG = BIT(6); | ||
643 | #endif | ||
632 | while (!(ATA_PIO_READY & BIT(1))) yield(); | 644 | while (!(ATA_PIO_READY & BIT(1))) yield(); |
633 | PASS_RC(ata_identify(ata_identify_data), 3, 3); | 645 | PASS_RC(ata_identify(ata_identify_data), 3, 3); |
634 | uint32_t piotime = 0x11f3; | 646 | uint32_t piotime = 0x11f3; |
@@ -1184,13 +1196,16 @@ int ata_init(void) | |||
1184 | semaphore_init(&mmc_wakeup, 1, 0); | 1196 | semaphore_init(&mmc_wakeup, 1, 0); |
1185 | semaphore_init(&mmc_comp_wakeup, 1, 0); | 1197 | semaphore_init(&mmc_comp_wakeup, 1, 0); |
1186 | ceata = PDAT(11) & BIT(1); | 1198 | ceata = PDAT(11) & BIT(1); |
1199 | #ifdef CHECK_ATA_SWAP | ||
1187 | ata_swap = false; | 1200 | ata_swap = false; |
1201 | #endif | ||
1188 | ata_powered = false; | 1202 | ata_powered = false; |
1189 | ata_total_sectors = 0; | 1203 | ata_total_sectors = 0; |
1190 | #ifdef ATA_HAVE_BBT | 1204 | #ifdef ATA_HAVE_BBT |
1191 | PASS_RC(ata_bbt_reload(), 0, 0); | 1205 | PASS_RC(ata_bbt_reload(), 0, 0); |
1192 | #endif | 1206 | #endif |
1193 | 1207 | ||
1208 | #ifdef CHECK_ATA_SWAP | ||
1194 | /* HDD data endianness check: | 1209 | /* HDD data endianness check: |
1195 | During the transition period Rockbox needs to detect the HDD data | 1210 | During the transition period Rockbox needs to detect the HDD data |
1196 | endianness automatically and support both. We're now using the correct | 1211 | endianness automatically and support both. We're now using the correct |
@@ -1210,7 +1225,16 @@ int ata_init(void) | |||
1210 | splashf(5000, "Wrong HDD endianness, please update your emCORE version!"); | 1225 | splashf(5000, "Wrong HDD endianness, please update your emCORE version!"); |
1211 | } | 1226 | } |
1212 | } | 1227 | } |
1213 | 1228 | #else | |
1229 | #ifndef ATA_HAVE_BBT | ||
1230 | /* get ata_identify_data */ | ||
1231 | mutex_lock(&ata_mutex); | ||
1232 | int rc = ata_power_up(); | ||
1233 | mutex_unlock(&ata_mutex); | ||
1234 | if (IS_ERR(rc)) return rc; | ||
1235 | #endif | ||
1236 | #endif | ||
1237 | |||
1214 | create_thread(ata_thread, ata_stack, | 1238 | create_thread(ata_thread, ata_stack, |
1215 | sizeof(ata_stack), 0, "ATA idle monitor" | 1239 | sizeof(ata_stack), 0, "ATA idle monitor" |
1216 | IF_PRIO(, PRIORITY_USER_INTERFACE) | 1240 | IF_PRIO(, PRIORITY_USER_INTERFACE) |
@@ -1243,8 +1267,10 @@ static int ata_smart(uint16_t* buf) | |||
1243 | else | 1267 | else |
1244 | { | 1268 | { |
1245 | int i; | 1269 | int i; |
1270 | #ifdef CHECK_ATA_SWAP | ||
1246 | uint32_t old = ATA_CFG; | 1271 | uint32_t old = ATA_CFG; |
1247 | ATA_CFG |= BIT(6); /* 16bit big-endian */ | 1272 | ATA_CFG |= BIT(6); /* 16bit big-endian */ |
1273 | #endif | ||
1248 | PASS_RC(ata_wait_for_not_bsy(10000000), 3, 6); | 1274 | PASS_RC(ata_wait_for_not_bsy(10000000), 3, 6); |
1249 | ata_write_cbr(&ATA_PIO_FED, 0xd0); | 1275 | ata_write_cbr(&ATA_PIO_FED, 0xd0); |
1250 | ata_write_cbr(&ATA_PIO_LMR, 0x4f); | 1276 | ata_write_cbr(&ATA_PIO_LMR, 0x4f); |
@@ -1253,7 +1279,9 @@ static int ata_smart(uint16_t* buf) | |||
1253 | ata_write_cbr(&ATA_PIO_CSD, 0xb0); | 1279 | ata_write_cbr(&ATA_PIO_CSD, 0xb0); |
1254 | PASS_RC(ata_wait_for_start_of_transfer(10000000), 3, 7); | 1280 | PASS_RC(ata_wait_for_start_of_transfer(10000000), 3, 7); |
1255 | for (i = 0; i < 0x100; i++) buf[i] = ata_read_cbr(&ATA_PIO_DTR); | 1281 | for (i = 0; i < 0x100; i++) buf[i] = ata_read_cbr(&ATA_PIO_DTR); |
1282 | #ifdef CHECK_ATA_SWAP | ||
1256 | ATA_CFG = old; | 1283 | ATA_CFG = old; |
1284 | #endif | ||
1257 | } | 1285 | } |
1258 | ata_set_active(); | 1286 | ata_set_active(); |
1259 | return 0; | 1287 | return 0; |