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.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 3c79c1be8f..a5fb78d6bd 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -71,13 +71,20 @@
71#define SET_REG(reg,val) reg = ((val) << 8) 71#define SET_REG(reg,val) reg = ((val) << 8)
72#define SET_16BITREG(reg,val) reg = (val) 72#define SET_16BITREG(reg,val) reg = (val)
73 73
74#elif CONFIG_CPU == PP5020 74#elif (CONFIG_CPU == PP5002) || (CONFIG_CPU == PP5020)
75 75
76/* don't use sh7034 assembler routines */ 76/* don't use sh7034 assembler routines */
77#define PREFER_C_READING 77#define PREFER_C_READING
78#define PREFER_C_WRITING 78#define PREFER_C_WRITING
79 79
80#if (CONFIG_CPU == PP5002)
81#define ATA_IOBASE 0xc00031e0
82#define ATA_CONTROL (*((volatile unsigned char*)(0xc00033f8)))
83#elif (CONFIG_CPU == PP5020)
80#define ATA_IOBASE 0xc30001e0 84#define ATA_IOBASE 0xc30001e0
85#define ATA_CONTROL (*((volatile unsigned char*)(0xc30003f8)))
86#endif
87
81#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE))) 88#define ATA_DATA (*((volatile unsigned short*)(ATA_IOBASE)))
82#define ATA_ERROR (*((volatile unsigned char*)(ATA_IOBASE + 0x04))) 89#define ATA_ERROR (*((volatile unsigned char*)(ATA_IOBASE + 0x04)))
83#define ATA_NSECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x08))) 90#define ATA_NSECTOR (*((volatile unsigned char*)(ATA_IOBASE + 0x08)))
@@ -86,7 +93,6 @@
86#define ATA_HCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x14))) 93#define ATA_HCYL (*((volatile unsigned char*)(ATA_IOBASE + 0x14)))
87#define ATA_SELECT (*((volatile unsigned char*)(ATA_IOBASE + 0x18))) 94#define ATA_SELECT (*((volatile unsigned char*)(ATA_IOBASE + 0x18)))
88#define ATA_COMMAND (*((volatile unsigned char*)(ATA_IOBASE + 0x1c))) 95#define ATA_COMMAND (*((volatile unsigned char*)(ATA_IOBASE + 0x1c)))
89#define ATA_CONTROL (*((volatile unsigned char*)(0xc30003f8)))
90 96
91#define STATUS_BSY 0x80 97#define STATUS_BSY 0x80
92#define STATUS_RDY 0x40 98#define STATUS_RDY 0x40
@@ -928,6 +934,11 @@ extern void ata_flush(void)
928 934
929static int check_registers(void) 935static int check_registers(void)
930{ 936{
937#if (CONFIG_CPU == PP5002)
938 /* This fails on the PP5002, but the ATA driver still works. This
939 needs more investigation. */
940 return 0;
941#else
931 int i; 942 int i;
932 if ( ATA_STATUS & STATUS_BSY ) 943 if ( ATA_STATUS & STATUS_BSY )
933 return -1; 944 return -1;
@@ -939,13 +950,14 @@ static int check_registers(void)
939 SET_REG(ATA_HCYL, WRITE_PATTERN4); 950 SET_REG(ATA_HCYL, WRITE_PATTERN4);
940 951
941 if ((ATA_NSECTOR == READ_PATTERN1) && 952 if ((ATA_NSECTOR == READ_PATTERN1) &&
942 (ATA_SECTOR == READ_PATTERN2) && 953 (ATA_SECTOR == READ_PATTERN2) &&
943 (ATA_LCYL == READ_PATTERN3) && 954 (ATA_LCYL == READ_PATTERN3) &&
944 (ATA_HCYL == READ_PATTERN4)) 955 (ATA_HCYL == READ_PATTERN4))
945 return 0; 956 return 0;
946 } 957 }
947 958
948 return -2; 959 return -2;
960#endif
949} 961}
950 962
951static int freeze_lock(void) 963static int freeze_lock(void)
@@ -1254,7 +1266,7 @@ void ata_enable(bool on)
1254 (void)on; 1266 (void)on;
1255#elif CONFIG_CPU == TCC730 1267#elif CONFIG_CPU == TCC730
1256 1268
1257#elif CONFIG_CPU == PP5020 1269#elif (CONFIG_CPU == PP5002) || (CONFIG_CPU == PP5020)
1258 /* TODO: Implement ata_enable() */ 1270 /* TODO: Implement ata_enable() */
1259 (void)on; 1271 (void)on;
1260#endif 1272#endif
@@ -1410,7 +1422,7 @@ int ata_init(void)
1410#elif defined(IAUDIO_X5) 1422#elif defined(IAUDIO_X5)
1411 /* X5 TODO */ 1423 /* X5 TODO */
1412 bool coldstart = true; 1424 bool coldstart = true;
1413#elif CONFIG_CPU == PP5020 1425#elif (CONFIG_CPU == PP5002) || (CONFIG_CPU == PP5020)
1414 bool coldstart = false; 1426 bool coldstart = false;
1415 /* TODO: Implement coldstart variable */ 1427 /* TODO: Implement coldstart variable */
1416#else 1428#else
@@ -1440,6 +1452,13 @@ int ata_init(void)
1440 or_l(0x00080000, &GPIO_FUNCTION); 1452 or_l(0x00080000, &GPIO_FUNCTION);
1441 1453
1442 /* FYI: The IDECONFIGx registers are set by set_cpu_frequency() */ 1454 /* FYI: The IDECONFIGx registers are set by set_cpu_frequency() */
1455#elif CONFIG_CPU == PP5002
1456 /* From ipod-ide.c:ipod_ide_register() */
1457 outl(inl(0xc0003024) | (1 << 7), 0xc0003024);
1458 outl(inl(0xc0003024) & ~(1<<2), 0xc0003024);
1459
1460 outl(0x10, 0xc0003000);
1461 outl(0x80002150, 0xc0003004);
1443#elif CONFIG_CPU == PP5020 1462#elif CONFIG_CPU == PP5020
1444 /* From ipod-ide.c:ipod_ide_register() */ 1463 /* From ipod-ide.c:ipod_ide_register() */
1445 outl(inl(0xc3000028) | (1 << 5), 0xc3000028); 1464 outl(inl(0xc3000028) | (1 << 5), 0xc3000028);