diff options
-rw-r--r-- | firmware/target/arm/ata-nand-telechips.c | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/firmware/target/arm/ata-nand-telechips.c b/firmware/target/arm/ata-nand-telechips.c index 316780d417..1c135650f1 100644 --- a/firmware/target/arm/ata-nand-telechips.c +++ b/firmware/target/arm/ata-nand-telechips.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include "button.h" | 33 | #include "button.h" |
34 | #include <sprintf.h> | 34 | #include <sprintf.h> |
35 | 35 | ||
36 | #define SECTOR_SIZE 512 | ||
37 | |||
36 | /* #define USE_TCC_LPT */ | 38 | /* #define USE_TCC_LPT */ |
37 | /* #define USE_ECC_CORRECTION */ | 39 | /* #define USE_ECC_CORRECTION */ |
38 | 40 | ||
@@ -41,13 +43,14 @@ int ata_spinup_time = 0; | |||
41 | 43 | ||
42 | long last_disk_activity = -1; | 44 | long last_disk_activity = -1; |
43 | 45 | ||
46 | /* as we aren't actually ata manually fill some fields */ | ||
47 | static unsigned short ata_identify[SECTOR_SIZE/2]; | ||
48 | |||
44 | /** static, private data **/ | 49 | /** static, private data **/ |
45 | static bool initialized = false; | 50 | static bool initialized = false; |
46 | 51 | ||
47 | static struct mutex ata_mtx SHAREDBSS_ATTR; | 52 | static struct mutex ata_mtx SHAREDBSS_ATTR; |
48 | 53 | ||
49 | #define SECTOR_SIZE 512 | ||
50 | |||
51 | #if defined(COWON_D2) || defined(IAUDIO_7) | 54 | #if defined(COWON_D2) || defined(IAUDIO_7) |
52 | #define SEGMENT_ID_BIGENDIAN | 55 | #define SEGMENT_ID_BIGENDIAN |
53 | #define BLOCKS_PER_SEGMENT 4 | 56 | #define BLOCKS_PER_SEGMENT 4 |
@@ -754,6 +757,41 @@ void ata_enable(bool on) | |||
754 | (void)on; | 757 | (void)on; |
755 | } | 758 | } |
756 | 759 | ||
760 | static void fill_identify(void) | ||
761 | { | ||
762 | char buf[80]; | ||
763 | unsigned short *wbuf = (unsigned short *) buf; | ||
764 | unsigned long blocks; | ||
765 | int i; | ||
766 | |||
767 | memset(ata_identify, 0, sizeof(ata_identify)); | ||
768 | |||
769 | /* firmware version */ | ||
770 | memset(buf, ' ', 8); | ||
771 | memcpy(buf, "0.00", 4); | ||
772 | |||
773 | for (i = 0; i < 4; i++) | ||
774 | ata_identify[23 + i] = betoh16(wbuf[i]); | ||
775 | |||
776 | /* model field, need better name? */ | ||
777 | memset(buf, ' ', 80); | ||
778 | memcpy(buf, "TNFL", 4); | ||
779 | |||
780 | for (i = 0; i < 40; i++) | ||
781 | ata_identify[27 + i] = betoh16(wbuf[i]); | ||
782 | |||
783 | /* blocks count */ | ||
784 | blocks = (pages_per_block * blocks_per_bank / SECTOR_SIZE) | ||
785 | * page_size * total_banks; | ||
786 | ata_identify[60] = blocks & 0xffff; | ||
787 | ata_identify[61] = blocks >> 16; | ||
788 | |||
789 | /* TODO: discover where is s/n in TNFL */ | ||
790 | for (i = 10; i < 20; i++) { | ||
791 | ata_identify[i] = 0; | ||
792 | } | ||
793 | } | ||
794 | |||
757 | int ata_init(void) | 795 | int ata_init(void) |
758 | { | 796 | { |
759 | int i, bank, phys_segment; | 797 | int i, bank, phys_segment; |
@@ -871,14 +909,13 @@ int ata_init(void) | |||
871 | } | 909 | } |
872 | #endif | 910 | #endif |
873 | 911 | ||
912 | fill_identify(); | ||
874 | initialized = true; | 913 | initialized = true; |
875 | 914 | ||
876 | return 0; | 915 | return 0; |
877 | } | 916 | } |
878 | 917 | ||
879 | |||
880 | /* TEMP: This will return junk, it's here for compilation only */ | ||
881 | unsigned short* ata_get_identify(void) | 918 | unsigned short* ata_get_identify(void) |
882 | { | 919 | { |
883 | return (unsigned short*)0x21000000; /* Unused DRAM */ | 920 | return ata_identify; |
884 | } | 921 | } |