summaryrefslogtreecommitdiff
path: root/firmware/drivers/ata.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/ata.c')
-rw-r--r--firmware/drivers/ata.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 0ed0877034..725d33e4a0 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -69,6 +69,7 @@
69#define CMD_STANDBY 0xE2 69#define CMD_STANDBY 0xE2
70#define CMD_IDENTIFY 0xEC 70#define CMD_IDENTIFY 0xEC
71#define CMD_SLEEP 0xE6 71#define CMD_SLEEP 0xE6
72#define CMD_SET_FEATURES 0xEF
72#define CMD_SECURITY_FREEZE_LOCK 0xF5 73#define CMD_SECURITY_FREEZE_LOCK 0xF5
73 74
74#define Q_SLEEP 0 75#define Q_SLEEP 0
@@ -773,6 +774,44 @@ static int set_multiple_mode(int sectors)
773 return 0; 774 return 0;
774} 775}
775 776
777static int set_features(void)
778{
779 struct {
780 unsigned char id_word;
781 unsigned char id_bit;
782 unsigned char subcommand;
783 unsigned char parameter;
784 } features[] = {
785 { 83, 3, 0x05, 1 }, /* power management: lowest power */
786 { 83, 9, 0x42, 0x80 }, /* acoustic management: lowest noise */
787 { 82, 6, 0xaa, 0 }, /* enable read look-ahead */
788 { 0, 0, 0, 0 } /* <end of list> */
789 };
790 int i;
791
792 ATA_SELECT = ata_device;
793
794 if (!wait_for_rdy()) {
795 DEBUGF("set_features() - not RDY\n");
796 return -1;
797 }
798
799 for (i=0; features[i].id_word; i++) {
800 if (identify_info[features[i].id_word] & (1 << features[i].id_bit)) {
801 ATA_FEATURE = features[i].subcommand;
802 ATA_NSECTOR = features[i].parameter;
803 ATA_COMMAND = CMD_SET_FEATURES;
804
805 if (!wait_for_rdy()) {
806 DEBUGF("set_features() - CMD failed\n");
807 return -2 - i;
808 }
809 }
810 }
811
812 return 0;
813}
814
776unsigned short* ata_get_identify(void) 815unsigned short* ata_get_identify(void)
777{ 816{
778 return identify_info; 817 return identify_info;
@@ -842,6 +881,10 @@ int ata_init(void)
842 multisectors = identify_info[47] & 0xff; 881 multisectors = identify_info[47] & 0xff;
843 DEBUGF("ata: %d sectors per ata request\n",multisectors); 882 DEBUGF("ata: %d sectors per ata request\n",multisectors);
844 883
884 rc = set_features();
885 if (rc)
886 return -60 + rc;
887
845 queue_init(&ata_queue); 888 queue_init(&ata_queue);
846 889
847 last_disk_activity = current_tick; 890 last_disk_activity = current_tick;
@@ -851,7 +894,7 @@ int ata_init(void)
851 } 894 }
852 rc = set_multiple_mode(multisectors); 895 rc = set_multiple_mode(multisectors);
853 if (rc) 896 if (rc)
854 return -60 + rc; 897 return -70 + rc;
855 898
856 return 0; 899 return 0;
857} 900}