iPOd Classic: skip emCORE HDD endianness warning for bootloader

Change-Id: I274511cc1061c396a0642e8496d46a3b9c1228d3
This commit is contained in:
Cástor Muñoz 2016-02-05 14:04:45 +01:00
parent 187ce123f1
commit 44ce4eebd6
2 changed files with 33 additions and 1 deletions

View file

@ -196,6 +196,10 @@
#define ATA_HAVE_BBT #define ATA_HAVE_BBT
#define ATA_BBT_PAGES 4096 #define ATA_BBT_PAGES 4096
#ifndef BOOTLOADER
/* TODO: probably this check is no longer needed and might be removed */
#define CHECK_ATA_SWAP
#endif
#define SECTOR_SIZE 4096 #define SECTOR_SIZE 4096

View file

@ -33,7 +33,9 @@
#include "led.h" #include "led.h"
#include "ata_idle_notify.h" #include "ata_idle_notify.h"
#include "disk_cache.h" #include "disk_cache.h"
#ifdef CHECK_ATA_SWAP
#include "splash.h" #include "splash.h"
#endif
#ifndef ATA_RETRIES #ifndef ATA_RETRIES
@ -51,7 +53,9 @@
static uint8_t ceata_taskfile[16] STORAGE_ALIGN_ATTR; static uint8_t ceata_taskfile[16] STORAGE_ALIGN_ATTR;
static uint16_t ata_identify_data[0x100] STORAGE_ALIGN_ATTR; static uint16_t ata_identify_data[0x100] STORAGE_ALIGN_ATTR;
static bool ceata; static bool ceata;
#ifdef CHECK_ATA_SWAP
static bool ata_swap; static bool ata_swap;
#endif
static bool ata_lba48; static bool ata_lba48;
static bool ata_dma; static bool ata_dma;
static uint64_t ata_total_sectors; static uint64_t ata_total_sectors;
@ -532,14 +536,18 @@ static int ata_identify(uint16_t* buf)
} }
else else
{ {
#ifdef CHECK_ATA_SWAP
uint32_t old = ATA_CFG; uint32_t old = ATA_CFG;
ATA_CFG |= BIT(6); ATA_CFG |= BIT(6);
#endif
PASS_RC(ata_wait_for_not_bsy(10000000), 1, 0); PASS_RC(ata_wait_for_not_bsy(10000000), 1, 0);
ata_write_cbr(&ATA_PIO_DVR, 0); ata_write_cbr(&ATA_PIO_DVR, 0);
ata_write_cbr(&ATA_PIO_CSD, 0xec); ata_write_cbr(&ATA_PIO_CSD, 0xec);
PASS_RC(ata_wait_for_start_of_transfer(10000000), 1, 1); PASS_RC(ata_wait_for_start_of_transfer(10000000), 1, 1);
for (i = 0; i < 0x100; i++) buf[i] = ata_read_cbr(&ATA_PIO_DTR); for (i = 0; i < 0x100; i++) buf[i] = ata_read_cbr(&ATA_PIO_DTR);
#ifdef CHECK_ATA_SWAP
ATA_CFG = old; ATA_CFG = old;
#endif
} }
return 0; return 0;
} }
@ -628,7 +636,11 @@ static int ata_power_up(void)
sleep(HZ / 5); sleep(HZ / 5);
ATA_PIO_TIME = 0x191f7; ATA_PIO_TIME = 0x191f7;
ATA_PIO_LHR = 0; ATA_PIO_LHR = 0;
#ifdef CHECK_ATA_SWAP
if (!ata_swap) ATA_CFG = BIT(6); if (!ata_swap) ATA_CFG = BIT(6);
#else
ATA_CFG = BIT(6);
#endif
while (!(ATA_PIO_READY & BIT(1))) yield(); while (!(ATA_PIO_READY & BIT(1))) yield();
PASS_RC(ata_identify(ata_identify_data), 3, 3); PASS_RC(ata_identify(ata_identify_data), 3, 3);
uint32_t piotime = 0x11f3; uint32_t piotime = 0x11f3;
@ -1184,13 +1196,16 @@ int ata_init(void)
semaphore_init(&mmc_wakeup, 1, 0); semaphore_init(&mmc_wakeup, 1, 0);
semaphore_init(&mmc_comp_wakeup, 1, 0); semaphore_init(&mmc_comp_wakeup, 1, 0);
ceata = PDAT(11) & BIT(1); ceata = PDAT(11) & BIT(1);
#ifdef CHECK_ATA_SWAP
ata_swap = false; ata_swap = false;
#endif
ata_powered = false; ata_powered = false;
ata_total_sectors = 0; ata_total_sectors = 0;
#ifdef ATA_HAVE_BBT #ifdef ATA_HAVE_BBT
PASS_RC(ata_bbt_reload(), 0, 0); PASS_RC(ata_bbt_reload(), 0, 0);
#endif #endif
#ifdef CHECK_ATA_SWAP
/* HDD data endianness check: /* HDD data endianness check:
During the transition period Rockbox needs to detect the HDD data During the transition period Rockbox needs to detect the HDD data
endianness automatically and support both. We're now using the correct endianness automatically and support both. We're now using the correct
@ -1210,7 +1225,16 @@ int ata_init(void)
splashf(5000, "Wrong HDD endianness, please update your emCORE version!"); splashf(5000, "Wrong HDD endianness, please update your emCORE version!");
} }
} }
#else
#ifndef ATA_HAVE_BBT
/* get ata_identify_data */
mutex_lock(&ata_mutex);
int rc = ata_power_up();
mutex_unlock(&ata_mutex);
if (IS_ERR(rc)) return rc;
#endif
#endif
create_thread(ata_thread, ata_stack, create_thread(ata_thread, ata_stack,
sizeof(ata_stack), 0, "ATA idle monitor" sizeof(ata_stack), 0, "ATA idle monitor"
IF_PRIO(, PRIORITY_USER_INTERFACE) IF_PRIO(, PRIORITY_USER_INTERFACE)
@ -1243,8 +1267,10 @@ static int ata_smart(uint16_t* buf)
else else
{ {
int i; int i;
#ifdef CHECK_ATA_SWAP
uint32_t old = ATA_CFG; uint32_t old = ATA_CFG;
ATA_CFG |= BIT(6); /* 16bit big-endian */ ATA_CFG |= BIT(6); /* 16bit big-endian */
#endif
PASS_RC(ata_wait_for_not_bsy(10000000), 3, 6); PASS_RC(ata_wait_for_not_bsy(10000000), 3, 6);
ata_write_cbr(&ATA_PIO_FED, 0xd0); ata_write_cbr(&ATA_PIO_FED, 0xd0);
ata_write_cbr(&ATA_PIO_LMR, 0x4f); ata_write_cbr(&ATA_PIO_LMR, 0x4f);
@ -1253,7 +1279,9 @@ static int ata_smart(uint16_t* buf)
ata_write_cbr(&ATA_PIO_CSD, 0xb0); ata_write_cbr(&ATA_PIO_CSD, 0xb0);
PASS_RC(ata_wait_for_start_of_transfer(10000000), 3, 7); PASS_RC(ata_wait_for_start_of_transfer(10000000), 3, 7);
for (i = 0; i < 0x100; i++) buf[i] = ata_read_cbr(&ATA_PIO_DTR); for (i = 0; i < 0x100; i++) buf[i] = ata_read_cbr(&ATA_PIO_DTR);
#ifdef CHECK_ATA_SWAP
ATA_CFG = old; ATA_CFG = old;
#endif
} }
ata_set_active(); ata_set_active();
return 0; return 0;