diff options
author | Frank Gevaerts <frank@gevaerts.be> | 2008-11-01 16:14:28 +0000 |
---|---|---|
committer | Frank Gevaerts <frank@gevaerts.be> | 2008-11-01 16:14:28 +0000 |
commit | 2f8a0081c64534da23fc0fa9cc685eb7454fd9c9 (patch) | |
tree | 84dbdbd5326cb48f43d2ebd5a4c86e992c1d5288 /firmware/drivers/ata.c | |
parent | 646cac0bde7b11fa7bcb670d1d76eec78e360485 (diff) | |
download | rockbox-2f8a0081c64534da23fc0fa9cc685eb7454fd9c9.tar.gz rockbox-2f8a0081c64534da23fc0fa9cc685eb7454fd9c9.zip |
Apply FS#9500. This adds a storage_*() abstraction to replace ata_*(). To do that, it also introduces sd_*, nand_*, and mmc_*.
This should be a good first step to allow multi-driver targets, like the Elio (ATA/SD), or the D2 (NAND/SD).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18960 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/ata.c')
-rw-r--r-- | firmware/drivers/ata.c | 57 |
1 files changed, 49 insertions, 8 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index b80f615eb3..c2882a5b74 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "string.h" | 32 | #include "string.h" |
33 | #include "ata_idle_notify.h" | 33 | #include "ata_idle_notify.h" |
34 | #include "ata-target.h" | 34 | #include "ata-target.h" |
35 | #include "storage.h" | ||
35 | 36 | ||
36 | #define SECTOR_SIZE (512) | 37 | #define SECTOR_SIZE (512) |
37 | 38 | ||
@@ -148,7 +149,7 @@ static void ata_lock_unlock(struct ata_lock *l) | |||
148 | static struct mutex ata_mtx SHAREDBSS_ATTR; | 149 | static struct mutex ata_mtx SHAREDBSS_ATTR; |
149 | static int ata_device; /* device 0 (master) or 1 (slave) */ | 150 | static int ata_device; /* device 0 (master) or 1 (slave) */ |
150 | 151 | ||
151 | int ata_spinup_time = 0; | 152 | static int spinup_time = 0; |
152 | #if (CONFIG_LED == LED_REAL) | 153 | #if (CONFIG_LED == LED_REAL) |
153 | static bool ata_led_enabled = true; | 154 | static bool ata_led_enabled = true; |
154 | static bool ata_led_on = false; | 155 | static bool ata_led_on = false; |
@@ -166,7 +167,7 @@ static struct event_queue ata_queue; | |||
166 | static bool initialized = false; | 167 | static bool initialized = false; |
167 | 168 | ||
168 | static long last_user_activity = -1; | 169 | static long last_user_activity = -1; |
169 | long last_disk_activity = -1; | 170 | static long last_disk_activity = -1; |
170 | 171 | ||
171 | static unsigned long total_sectors; | 172 | static unsigned long total_sectors; |
172 | static int multisectors; /* number of supported multisectors */ | 173 | static int multisectors; /* number of supported multisectors */ |
@@ -407,7 +408,7 @@ int ata_read_sectors(IF_MV2(int drive,) | |||
407 | } | 408 | } |
408 | 409 | ||
409 | if (spinup) { | 410 | if (spinup) { |
410 | ata_spinup_time = current_tick - spinup_start; | 411 | spinup_time = current_tick - spinup_start; |
411 | spinup = false; | 412 | spinup = false; |
412 | sleeping = false; | 413 | sleeping = false; |
413 | poweroff = false; | 414 | poweroff = false; |
@@ -584,7 +585,7 @@ int ata_write_sectors(IF_MV2(int drive,) | |||
584 | } | 585 | } |
585 | 586 | ||
586 | if (spinup) { | 587 | if (spinup) { |
587 | ata_spinup_time = current_tick - spinup_start; | 588 | spinup_time = current_tick - spinup_start; |
588 | spinup = false; | 589 | spinup = false; |
589 | sleeping = false; | 590 | sleeping = false; |
590 | poweroff = false; | 591 | poweroff = false; |
@@ -873,7 +874,7 @@ void ata_sleepnow(void) | |||
873 | { | 874 | { |
874 | if (!spinup && !sleeping && !ata_mtx.locked && initialized) | 875 | if (!spinup && !sleeping && !ata_mtx.locked && initialized) |
875 | { | 876 | { |
876 | call_ata_idle_notifys(false); | 877 | call_storage_idle_notifys(false); |
877 | ata_perform_sleep(); | 878 | ata_perform_sleep(); |
878 | } | 879 | } |
879 | } | 880 | } |
@@ -908,7 +909,7 @@ static void ata_thread(void) | |||
908 | #ifdef ALLOW_USB_SPINDOWN | 909 | #ifdef ALLOW_USB_SPINDOWN |
909 | if(!usb_mode) | 910 | if(!usb_mode) |
910 | #endif | 911 | #endif |
911 | call_ata_idle_notifys(false); | 912 | call_storage_idle_notifys(false); |
912 | last_seen_mtx_unlock = 0; | 913 | last_seen_mtx_unlock = 0; |
913 | } | 914 | } |
914 | } | 915 | } |
@@ -921,7 +922,7 @@ static void ata_thread(void) | |||
921 | #ifdef ALLOW_USB_SPINDOWN | 922 | #ifdef ALLOW_USB_SPINDOWN |
922 | if(!usb_mode) | 923 | if(!usb_mode) |
923 | #endif | 924 | #endif |
924 | call_ata_idle_notifys(true); | 925 | call_storage_idle_notifys(true); |
925 | ata_perform_sleep(); | 926 | ata_perform_sleep(); |
926 | last_sleep = current_tick; | 927 | last_sleep = current_tick; |
927 | } | 928 | } |
@@ -974,7 +975,7 @@ static void ata_thread(void) | |||
974 | #ifdef ALLOW_USB_SPINDOWN | 975 | #ifdef ALLOW_USB_SPINDOWN |
975 | if(!usb_mode) | 976 | if(!usb_mode) |
976 | #endif | 977 | #endif |
977 | call_ata_idle_notifys(false); | 978 | call_storage_idle_notifys(false); |
978 | last_disk_activity = current_tick - sleep_timeout + (HZ/2); | 979 | last_disk_activity = current_tick - sleep_timeout + (HZ/2); |
979 | break; | 980 | break; |
980 | 981 | ||
@@ -1391,3 +1392,43 @@ void ata_set_led_enabled(bool enabled) | |||
1391 | led(false); | 1392 | led(false); |
1392 | } | 1393 | } |
1393 | #endif | 1394 | #endif |
1395 | |||
1396 | long ata_last_disk_activity(void) | ||
1397 | { | ||
1398 | return last_disk_activity; | ||
1399 | } | ||
1400 | |||
1401 | int ata_spinup_time(void) | ||
1402 | { | ||
1403 | return spinup_time; | ||
1404 | } | ||
1405 | |||
1406 | void ata_get_info(struct storage_info *info) | ||
1407 | { | ||
1408 | unsigned short *src,*dest; | ||
1409 | static char vendor[8]; | ||
1410 | static char product[16]; | ||
1411 | static char revision[4]; | ||
1412 | int i; | ||
1413 | info->sector_size = SECTOR_SIZE; | ||
1414 | info->num_sectors= ((unsigned long)identify_info[61] << 16 | \ | ||
1415 | (unsigned long)identify_info[60]); | ||
1416 | |||
1417 | src = (unsigned short*)&identify_info[27]; | ||
1418 | dest = (unsigned short*)vendor; | ||
1419 | for (i=0;i<4;i++) | ||
1420 | dest[i] = htobe16(src[i]); | ||
1421 | info->vendor=vendor; | ||
1422 | |||
1423 | src = (unsigned short*)&identify_info[31]; | ||
1424 | dest = (unsigned short*)product; | ||
1425 | for (i=0;i<8;i++) | ||
1426 | dest[i] = htobe16(src[i]); | ||
1427 | info->product=product; | ||
1428 | |||
1429 | src = (unsigned short*)&identify_info[23]; | ||
1430 | dest = (unsigned short*)revision; | ||
1431 | for (i=0;i<2;i++) | ||
1432 | dest[i] = htobe16(src[i]); | ||
1433 | info->revision=revision; | ||
1434 | } | ||