summaryrefslogtreecommitdiff
path: root/firmware/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers')
-rw-r--r--firmware/drivers/ata.c37
1 files changed, 8 insertions, 29 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 80123fadb7..01a8fa360b 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -28,6 +28,7 @@
28#include "usb.h" 28#include "usb.h"
29#include "power.h" 29#include "power.h"
30#include "string.h" 30#include "string.h"
31#include "hwcompat.h"
31 32
32#define SECTOR_SIZE 512 33#define SECTOR_SIZE 512
33#define ATA_DATA (*((volatile unsigned short*)0x06104100)) 34#define ATA_DATA (*((volatile unsigned short*)0x06104100))
@@ -697,42 +698,20 @@ static int master_slave_detect(void)
697} 698}
698 699
699static int io_address_detect(void) 700static int io_address_detect(void)
700{ 701{ /* now, use the HW mask instead of probing */
701 unsigned char tmp = ATA_STATUS & 0xf9; /* Mask the IDX and CORR bits */ 702 if (read_hw_mask() & ATA_ADDRESS_200)
702 unsigned char dummy;
703
704 /* We compare the STATUS register with the ALT_STATUS register, which
705 is located at the same address as CONTROL. If they are the same, we
706 assume that we have the correct address.
707
708 We can't read the ATA_STATUS directly, since the read data will stay
709 on the data bus if the following read does not assert the Chip Select
710 to the ATA controller. We read a register that we know exists to make
711 sure that the data on the bus isn't identical to the STATUS register
712 contents. */
713 ATA_SECTOR = 0;
714 dummy = ATA_SECTOR;
715 if(tmp == ((*ATA_CONTROL2) & 0xf9))
716 {
717 DEBUGF("CONTROL is at 0x306\n");
718 ata_io_address = 0x300; /* For debug purposes only */
719 old_recorder = true;
720 ata_control = ATA_CONTROL2;
721 }
722 else
723 { 703 {
724 DEBUGF("CONTROL is at 0x206\n");
725 ata_io_address = 0x200; /* For debug purposes only */ 704 ata_io_address = 0x200; /* For debug purposes only */
726 old_recorder = false; 705 old_recorder = false;
727 ata_control = ATA_CONTROL1; 706 ata_control = ATA_CONTROL1;
728 } 707 }
729 708 else
730 /* Let's check again, to be sure */
731 if(tmp != (ATA_ALT_STATUS & 0xf9))
732 { 709 {
733 DEBUGF("ATA I/O address detection failed\n"); 710 ata_io_address = 0x300; /* For debug purposes only */
734 return -1; 711 old_recorder = true;
712 ata_control = ATA_CONTROL2;
735 } 713 }
714
736 return 0; 715 return 0;
737} 716}
738 717