diff options
Diffstat (limited to 'firmware/drivers')
-rw-r--r-- | firmware/drivers/ata.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 35dff56f6c..309a155eb6 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -161,7 +161,9 @@ static bool ata_led_on = false; | |||
161 | #endif | 161 | #endif |
162 | static bool spinup = false; | 162 | static bool spinup = false; |
163 | static bool sleeping = true; | 163 | static bool sleeping = true; |
164 | #ifdef HAVE_ATA_POWER_OFF | ||
164 | static bool poweroff = false; | 165 | static bool poweroff = false; |
166 | #endif | ||
165 | static long sleep_timeout = 5*HZ; | 167 | static long sleep_timeout = 5*HZ; |
166 | #ifdef HAVE_LBA48 | 168 | #ifdef HAVE_LBA48 |
167 | static bool lba48 = false; /* set for 48 bit addressing */ | 169 | static bool lba48 = false; /* set for 48 bit addressing */ |
@@ -195,7 +197,9 @@ static int phys_sector_mult = 1; | |||
195 | static int dma_mode = 0; | 197 | static int dma_mode = 0; |
196 | #endif | 198 | #endif |
197 | 199 | ||
200 | #ifdef HAVE_ATA_POWER_OFF | ||
198 | static int ata_power_on(void); | 201 | static int ata_power_on(void); |
202 | #endif | ||
199 | static int perform_soft_reset(void); | 203 | static int perform_soft_reset(void); |
200 | static int set_multiple_mode(int sectors); | 204 | static int set_multiple_mode(int sectors); |
201 | static int set_features(void); | 205 | static int set_features(void); |
@@ -367,13 +371,16 @@ static int ata_transfer_sectors(unsigned long start, | |||
367 | if ( sleeping ) { | 371 | if ( sleeping ) { |
368 | sleeping = false; /* set this now since it'll be on */ | 372 | sleeping = false; /* set this now since it'll be on */ |
369 | spinup = true; | 373 | spinup = true; |
374 | #ifdef HAVE_ATA_POWER_OFF | ||
370 | if (poweroff) { | 375 | if (poweroff) { |
371 | if (ata_power_on()) { | 376 | if (ata_power_on()) { |
372 | ret = -2; | 377 | ret = -2; |
373 | goto error; | 378 | goto error; |
374 | } | 379 | } |
375 | } | 380 | } |
376 | else { | 381 | else |
382 | #endif | ||
383 | { | ||
377 | if (perform_soft_reset()) { | 384 | if (perform_soft_reset()) { |
378 | ret = -2; | 385 | ret = -2; |
379 | goto error; | 386 | goto error; |
@@ -462,7 +469,9 @@ static int ata_transfer_sectors(unsigned long start, | |||
462 | if (spinup) { | 469 | if (spinup) { |
463 | spinup_time = current_tick - spinup_start; | 470 | spinup_time = current_tick - spinup_start; |
464 | spinup = false; | 471 | spinup = false; |
472 | #ifdef HAVE_ATA_POWER_OFF | ||
465 | poweroff = false; | 473 | poweroff = false; |
474 | #endif | ||
466 | } | 475 | } |
467 | } | 476 | } |
468 | else | 477 | else |
@@ -491,7 +500,9 @@ static int ata_transfer_sectors(unsigned long start, | |||
491 | if (spinup) { | 500 | if (spinup) { |
492 | spinup_time = current_tick - spinup_start; | 501 | spinup_time = current_tick - spinup_start; |
493 | spinup = false; | 502 | spinup = false; |
503 | #ifdef HAVE_ATA_POWER_OFF | ||
494 | poweroff = false; | 504 | poweroff = false; |
505 | #endif | ||
495 | } | 506 | } |
496 | 507 | ||
497 | /* read the status register exactly once per loop */ | 508 | /* read the status register exactly once per loop */ |
@@ -934,11 +945,14 @@ static void ata_thread(void) | |||
934 | ata_led(true); | 945 | ata_led(true); |
935 | sleeping = false; /* set this now since it'll be on */ | 946 | sleeping = false; /* set this now since it'll be on */ |
936 | 947 | ||
948 | #ifdef HAVE_ATA_POWER_OFF | ||
937 | if (poweroff) { | 949 | if (poweroff) { |
938 | ata_power_on(); | 950 | ata_power_on(); |
939 | poweroff = false; | 951 | poweroff = false; |
940 | } | 952 | } |
941 | else { | 953 | else |
954 | #endif | ||
955 | { | ||
942 | perform_soft_reset(); | 956 | perform_soft_reset(); |
943 | } | 957 | } |
944 | 958 | ||
@@ -980,7 +994,11 @@ static void ata_thread(void) | |||
980 | } | 994 | } |
981 | 995 | ||
982 | /* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */ | 996 | /* Hardware reset protocol as specified in chapter 9.1, ATA spec draft v5 */ |
997 | #ifdef HAVE_ATA_POWER_OFF | ||
983 | static int ata_hard_reset(void) | 998 | static int ata_hard_reset(void) |
999 | #else | ||
1000 | static int STORAGE_INIT_ATTR ata_hard_reset(void) | ||
1001 | #endif | ||
984 | { | 1002 | { |
985 | int ret; | 1003 | int ret; |
986 | 1004 | ||
@@ -1056,6 +1074,7 @@ int ata_soft_reset(void) | |||
1056 | return ret; | 1074 | return ret; |
1057 | } | 1075 | } |
1058 | 1076 | ||
1077 | #ifdef HAVE_ATA_POWER_OFF | ||
1059 | static int ata_power_on(void) | 1078 | static int ata_power_on(void) |
1060 | { | 1079 | { |
1061 | int rc; | 1080 | int rc; |
@@ -1085,6 +1104,7 @@ static int ata_power_on(void) | |||
1085 | 1104 | ||
1086 | return 0; | 1105 | return 0; |
1087 | } | 1106 | } |
1107 | #endif | ||
1088 | 1108 | ||
1089 | static int STORAGE_INIT_ATTR master_slave_detect(void) | 1109 | static int STORAGE_INIT_ATTR master_slave_detect(void) |
1090 | { | 1110 | { |