From 028c5e35eee43efc3c922ffc0db067fc61cf27cb Mon Sep 17 00:00:00 2001 From: Jonas Wielicki Date: Tue, 17 Apr 2012 18:35:50 +0200 Subject: [PATCH] Add identify() call to reset procedures This change is motivated by the ATA specs, section 9.2 Software reset protocol (quote): A host should issue an IDENTIFY DEVICE and/or IDENTIFY PACKET DEVICE command after the software reset protocol has completed to determine the current status of features implemented by the device(s). This indeed fixes a local issue with an SSD in an iriver h320. No other tests were carried out. Change-Id: I191444aec3e55f6890020f601c715d0022d09fb6 Reviewed-on: http://gerrit.rockbox.org/218 Reviewed-by: Bertrik Sikken Reviewed-by: Linus Nielsen Feltzing Reviewed-by: Peter D'Hoye Tested-by: Peter D'Hoye Reviewed-by: Marcin Bukat --- firmware/drivers/ata.c | 62 ++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 8dfc8d965d..ec04ac1426 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -1016,6 +1016,35 @@ static int STORAGE_INIT_ATTR ata_hard_reset(void) return ret; } +// not putting this into STORAGE_INIT_ATTR, as ATA spec recommends to +// re-read identify_info after soft reset. So we'll do that. +static int identify(void) +{ + int i; + + ATA_OUT8(ATA_SELECT, ata_device); + + if(!wait_for_rdy()) { + DEBUGF("identify() - not RDY\n"); + return -1; + } + ATA_OUT8(ATA_COMMAND, CMD_IDENTIFY); + + if (!wait_for_start_of_transfer()) + { + DEBUGF("identify() - CMD failed\n"); + return -2; + } + + for (i=0; i