summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2006-12-19 09:27:41 +0000
committerJens Arnold <amiconn@rockbox.org>2006-12-19 09:27:41 +0000
commit28fd4b7228620f915dd837d401abaab8c353e89c (patch)
tree4780a2f9148990e67980a3267cc0ed53acd778a2
parent3bceded79373a43ee75487a5bd037723c92e089b (diff)
downloadrockbox-28fd4b7228620f915dd837d401abaab8c353e89c.zip
rockbox-28fd4b7228620f915dd837d401abaab8c353e89c.tar.gz
rockbox-28fd4b7228620f915dd837d401abaab8c353e89c.tar.bz2
rockbox-28fd4b7228620f915dd837d401abaab8c353e89c.tar.xz
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
-rw-r--r--firmware/drivers/ata.c8
-rwxr-xr-xfirmware/target/sh/archos/ata-archos.c28
-rwxr-xr-xfirmware/target/sh/archos/ata-target.h3
3 files changed, 17 insertions, 22 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index 5e69b36..800bd1a 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 73e56b8..c685700 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 ddffb34..ae93293 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))