From 28fd4b7228620f915dd837d401abaab8c353e89c Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Tue, 19 Dec 2006 09:27:41 +0000 Subject: Archos: Moved the ata_address_detect() code into ata_device_init(), removing the associated #ifdef and some public #defines. Saves a tiny bit of code as well. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11812 a1c6a512-1295-4272-9138-f99709370657 --- firmware/drivers/ata.c | 8 +++----- firmware/target/sh/archos/ata-archos.c | 28 ++++++++++++++-------------- firmware/target/sh/archos/ata-target.h | 3 --- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c index 5e69b36f2d..800bd1a31a 100644 --- a/firmware/drivers/ata.c +++ b/firmware/drivers/ata.c @@ -909,6 +909,7 @@ int ata_init(void) { int rc; bool coldstart = ata_is_coldstart(); + /* must be called before ata_device_init() */ mutex_init(&ata_mtx); @@ -924,13 +925,10 @@ int ata_init(void) sleep(HZ); /* allow voltage to build up */ } -#ifdef ATA_ADDRESS_DETECT - ata_address_detect(); -#endif /* first try, hard reset at cold start only */ - rc = init_and_check(coldstart); + rc = init_and_check(coldstart); - if (rc) + if (rc) { /* failed? -> second try, always with hard reset */ DEBUGF("ata: init failed, retrying...\n"); rc = init_and_check(true); diff --git a/firmware/target/sh/archos/ata-archos.c b/firmware/target/sh/archos/ata-archos.c index 73e56b8d84..c685700fa3 100755 --- a/firmware/target/sh/archos/ata-archos.c +++ b/firmware/target/sh/archos/ata-archos.c @@ -25,6 +25,9 @@ #include "ata-target.h" #include "hwcompat.h" +#define ATA_CONTROL1 ((volatile unsigned char*)0x06200206) +#define ATA_CONTROL2 ((volatile unsigned char*)0x06200306) + volatile unsigned char* ata_control; int ata_io_address; /* 0x300 or 0x200 */ @@ -39,20 +42,6 @@ void ata_reset(void) sleep(1); /* > 2ms */ } -void ata_address_detect(void) -{ - if (read_hw_mask() & ATA_ADDRESS_200) - { - ata_io_address = 0x200; /* For debug purposes only */ - ata_control = ATA_CONTROL1; - } - else - { - ata_io_address = 0x300; /* For debug purposes only */ - ata_control = ATA_CONTROL2; - } -} - void ata_enable(bool on) { if(on) @@ -68,6 +57,17 @@ void ata_device_init(void) or_b(0x02, &PAIORH); /* output for ATA reset */ or_b(0x02, &PADRH); /* release ATA reset */ PACR2 &= 0xBFFF; /* GPIO function for PA7 (IDE enable) */ + + if (read_hw_mask() & ATA_ADDRESS_200) + { + ata_io_address = 0x200; /* For debug purposes only */ + ata_control = ATA_CONTROL1; + } + else + { + ata_io_address = 0x300; /* For debug purposes only */ + ata_control = ATA_CONTROL2; + } } bool ata_is_coldstart(void) diff --git a/firmware/target/sh/archos/ata-target.h b/firmware/target/sh/archos/ata-target.h index ddffb34f5a..ae9329387d 100755 --- a/firmware/target/sh/archos/ata-target.h +++ b/firmware/target/sh/archos/ata-target.h @@ -22,14 +22,11 @@ /* asm optimised read & write loops */ #define ATA_OPTIMIZED_READING #define ATA_OPTIMIZED_WRITING -#define ATA_ADDRESS_DETECT /* need address detection */ #define SWAP_WORDS #define ATA_IOBASE 0x06100100 #define ATA_DATA (*((volatile unsigned short*)0x06104100)) -#define ATA_CONTROL1 ((volatile unsigned char*)0x06200206) -#define ATA_CONTROL2 ((volatile unsigned char*)0x06200306) #define ATA_CONTROL (*ata_control) #define ATA_ERROR (*((volatile unsigned char*)ATA_IOBASE + 1)) -- cgit v1.2.3