summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/drivers/ata.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index e8fd4469cd..63bfc92e92 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -62,7 +62,8 @@
62#define CMD_SECURITY_FREEZE_LOCK 0xF5 62#define CMD_SECURITY_FREEZE_LOCK 0xF5
63 63
64static struct mutex ata_mtx; 64static struct mutex ata_mtx;
65static char device; /* device 0 (master) or 1 (slave) */ 65char ata_device; /* device 0 (master) or 1 (slave) */
66int ata_io_address; /* 0x300 or 0x200, only valid on recorder */
66 67
67static volatile unsigned char* ata_control; 68static volatile unsigned char* ata_control;
68 69
@@ -126,7 +127,7 @@ int ata_read_sectors(unsigned long start,
126 ATA_SECTOR = start & 0xff; 127 ATA_SECTOR = start & 0xff;
127 ATA_LCYL = (start >> 8) & 0xff; 128 ATA_LCYL = (start >> 8) & 0xff;
128 ATA_HCYL = (start >> 16) & 0xff; 129 ATA_HCYL = (start >> 16) & 0xff;
129 ATA_SELECT = ((start >> 24) & 0xf) | SELECT_LBA | device; 130 ATA_SELECT = ((start >> 24) & 0xf) | SELECT_LBA | ata_device;
130 ATA_COMMAND = CMD_READ_SECTORS; 131 ATA_COMMAND = CMD_READ_SECTORS;
131 132
132 for (i=0; i<count; i++) { 133 for (i=0; i<count; i++) {
@@ -177,7 +178,7 @@ int ata_write_sectors(unsigned long start,
177 ATA_SECTOR = start & 0xff; 178 ATA_SECTOR = start & 0xff;
178 ATA_LCYL = (start >> 8) & 0xff; 179 ATA_LCYL = (start >> 8) & 0xff;
179 ATA_HCYL = (start >> 16) & 0xff; 180 ATA_HCYL = (start >> 16) & 0xff;
180 ATA_SELECT = ((start >> 24) & 0xf) | SELECT_LBA | device; 181 ATA_SELECT = ((start >> 24) & 0xf) | SELECT_LBA | ata_device;
181 ATA_COMMAND = CMD_WRITE_SECTORS; 182 ATA_COMMAND = CMD_WRITE_SECTORS;
182 183
183 for (i=0; i<count; i++) { 184 for (i=0; i<count; i++) {
@@ -299,7 +300,7 @@ int ata_soft_reset(void)
299 300
300 mutex_lock(&ata_mtx); 301 mutex_lock(&ata_mtx);
301 302
302 ATA_SELECT = SELECT_LBA | device; 303 ATA_SELECT = SELECT_LBA | ata_device;
303 ATA_CONTROL = CONTROL_nIEN|CONTROL_SRST; 304 ATA_CONTROL = CONTROL_nIEN|CONTROL_SRST;
304 sleep(HZ/20000); /* >= 5us */ 305 sleep(HZ/20000); /* >= 5us */
305 306
@@ -325,14 +326,14 @@ static int master_slave_detect(void)
325 /* master? */ 326 /* master? */
326 ATA_SELECT = 0; 327 ATA_SELECT = 0;
327 if ( ATA_STATUS & STATUS_RDY ) { 328 if ( ATA_STATUS & STATUS_RDY ) {
328 device = 0; 329 ata_device = 0;
329 DEBUGF("Found master harddisk\n"); 330 DEBUGF("Found master harddisk\n");
330 } 331 }
331 else { 332 else {
332 /* slave? */ 333 /* slave? */
333 ATA_SELECT = SELECT_DEVICE1; 334 ATA_SELECT = SELECT_DEVICE1;
334 if ( ATA_STATUS & STATUS_RDY ) { 335 if ( ATA_STATUS & STATUS_RDY ) {
335 device = SELECT_DEVICE1; 336 ata_device = SELECT_DEVICE1;
336 DEBUGF("Found slave harddisk\n"); 337 DEBUGF("Found slave harddisk\n");
337 } 338 }
338 else 339 else
@@ -360,12 +361,14 @@ static int io_address_detect(void)
360 if(tmp == ((*ATA_CONTROL2) & 0xf9)) 361 if(tmp == ((*ATA_CONTROL2) & 0xf9))
361 { 362 {
362 DEBUGF("CONTROL is at 0x306\n"); 363 DEBUGF("CONTROL is at 0x306\n");
364 ata_io_address = 0x300; /* For debug purposes only */
363 old_recorder = true; 365 old_recorder = true;
364 ata_control = ATA_CONTROL2; 366 ata_control = ATA_CONTROL2;
365 } 367 }
366 else 368 else
367 { 369 {
368 DEBUGF("CONTROL is at 0x206\n"); 370 DEBUGF("CONTROL is at 0x206\n");
371 ata_io_address = 0x200; /* For debug purposes only */
369 old_recorder = false; 372 old_recorder = false;
370 ata_control = ATA_CONTROL1; 373 ata_control = ATA_CONTROL1;
371 } 374 }