liblitesata/sata_init: Add SATA Read check (Seems to be required with some disks).
This commit is contained in:
parent
557ebcedfb
commit
3dbe349dd9
|
@ -21,8 +21,9 @@
|
||||||
|
|
||||||
int sata_init(void) {
|
int sata_init(void) {
|
||||||
uint16_t timeout;
|
uint16_t timeout;
|
||||||
|
uint8_t buf[512];
|
||||||
|
|
||||||
for (timeout=10; timeout>0; timeout--) {
|
for (timeout=16; timeout>0; timeout--) {
|
||||||
/* Reset SATA PHY */
|
/* Reset SATA PHY */
|
||||||
sata_phy_enable_write(0);
|
sata_phy_enable_write(0);
|
||||||
busy_wait(1);
|
busy_wait(1);
|
||||||
|
@ -32,10 +33,27 @@ int sata_init(void) {
|
||||||
busy_wait(100);
|
busy_wait(100);
|
||||||
|
|
||||||
/* Check SATA PHY status */
|
/* Check SATA PHY status */
|
||||||
if (sata_phy_status_read() & 0x1)
|
if ((sata_phy_status_read() & 0x1) == 0)
|
||||||
return 1;
|
/* Re-initialize if failing */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Initiate a SATA Read */
|
||||||
|
sata_sector2mem_base_write((uint64_t)(uintptr_t) buf);
|
||||||
|
sata_sector2mem_sector_write(0);
|
||||||
|
sata_sector2mem_start_write(1);
|
||||||
|
|
||||||
|
/* Wait for 10ms */
|
||||||
|
busy_wait(10);
|
||||||
|
|
||||||
|
/* Check SATA Read status */
|
||||||
|
if ((sata_sector2mem_done_read() & 0x1) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* Init succeeded */
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Init failed */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue