summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Gjenero <dreamlayers@rockbox.org>2011-11-27 17:40:57 +0000
committerBoris Gjenero <dreamlayers@rockbox.org>2011-11-27 17:40:57 +0000
commite5a7388fc71c551e00e9abc6b2e25402acf8829b (patch)
treee9bb9c81262df31b294260da8b293745354c8dbe
parent2154cbf70665b812553335f49174c673a95e7503 (diff)
downloadrockbox-e5a7388fc71c551e00e9abc6b2e25402acf8829b.tar.gz
rockbox-e5a7388fc71c551e00e9abc6b2e25402acf8829b.zip
If Rockbox never turns off ATA power, don't compile code for turning it back on. Note that ATA power may still need to be turned on when starting, so that code in ata_init() always remains.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31079 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/drivers/ata.c24
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
162static bool spinup = false; 162static bool spinup = false;
163static bool sleeping = true; 163static bool sleeping = true;
164#ifdef HAVE_ATA_POWER_OFF
164static bool poweroff = false; 165static bool poweroff = false;
166#endif
165static long sleep_timeout = 5*HZ; 167static long sleep_timeout = 5*HZ;
166#ifdef HAVE_LBA48 168#ifdef HAVE_LBA48
167static bool lba48 = false; /* set for 48 bit addressing */ 169static bool lba48 = false; /* set for 48 bit addressing */
@@ -195,7 +197,9 @@ static int phys_sector_mult = 1;
195static int dma_mode = 0; 197static int dma_mode = 0;
196#endif 198#endif
197 199
200#ifdef HAVE_ATA_POWER_OFF
198static int ata_power_on(void); 201static int ata_power_on(void);
202#endif
199static int perform_soft_reset(void); 203static int perform_soft_reset(void);
200static int set_multiple_mode(int sectors); 204static int set_multiple_mode(int sectors);
201static int set_features(void); 205static 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
983static int ata_hard_reset(void) 998static int ata_hard_reset(void)
999#else
1000static 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
1059static int ata_power_on(void) 1078static 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
1089static int STORAGE_INIT_ATTR master_slave_detect(void) 1109static int STORAGE_INIT_ATTR master_slave_detect(void)
1090{ 1110{