diff options
Diffstat (limited to 'firmware/target/arm')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/ata-imx31.c | 48 | ||||
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/ata-target.h | 6 |
2 files changed, 11 insertions, 43 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/ata-imx31.c b/firmware/target/arm/imx31/gigabeat-s/ata-imx31.c index 965b447651..92cc048d57 100644 --- a/firmware/target/arm/imx31/gigabeat-s/ata-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/ata-imx31.c @@ -79,17 +79,18 @@ static const struct ata_pio_timings }, }; -static bool initialized = false; +static int pio_mode = 0; /* Setup mode 0 by default */ /* Setup the timing for PIO mode */ -static void ata_set_pio_mode(int mode) +void ata_set_pio_timings(int mode) { - const struct ata_pio_timings * const timings = &pio_timings[mode]; + while (!(ATA_INTERRUPT_PENDING & ATA_CONTROLLER_IDLE)); + const struct ata_pio_timings * const timings = &pio_timings[mode]; /* T = period in nanoseconds */ int T = 1000 * 1000 * 1000 / imx31_clkctl_get_ata_clk(); - while (!(ATA_INTERRUPT_PENDING & ATA_CONTROLLER_IDLE)); + pio_mode = mode; ATA_TIME_OFF = 3; ATA_TIME_ON = 3; @@ -128,40 +129,7 @@ void ata_device_init(void) { ATA_INTF_CONTROL |= ATA_ATA_RST; /* Make sure we're not in reset mode */ - if (!initialized) - { - initialized = true; - /* Setup mode 0 by default */ - ata_set_pio_mode(0); - /* mode may be switched later once identify info is ready in which - * case the main driver calls back */ - } - else - { - /* identify info will be ready */ - ata_identify_ready(); - } -} - -void ata_identify_ready(void) -{ - const unsigned short* identify_info = ata_get_identify(); - int mode = 0; - - if (identify_info[53] & (1 << 1)) - { - /* Set up advanced timings */ - if (identify_info[64] & (1 << 1)) - mode = 4; /* Mode 0, 1, 2, 3, 4 */ - else if (identify_info[64] & (1 << 0)) - mode = 3; /* Mode 0, 1, 2, 3 */ - else - mode = 2; /* Mode 0, 1, 2 */ - } - - /* If mode changed, actually set the timings */ - if (mode != 0) - { - ata_set_pio_mode(mode); - } + /* mode may be switched later once identify info is ready in which + * case the main driver calls back */ + ata_set_pio_timings(pio_mode); } diff --git a/firmware/target/arm/imx31/gigabeat-s/ata-target.h b/firmware/target/arm/imx31/gigabeat-s/ata-target.h index 7b61039c7e..6428e9f41f 100644 --- a/firmware/target/arm/imx31/gigabeat-s/ata-target.h +++ b/firmware/target/arm/imx31/gigabeat-s/ata-target.h @@ -68,7 +68,7 @@ void ata_reset(void); void ata_device_init(void); bool ata_is_coldstart(void); -#define ATA_NOTIFY_IDENTIFY_READY -void ata_identify_ready(void); +#define ATA_SET_DEVICE_FEATURES +void ata_set_pio_timings(int mode); -#endif +#endif /* ATA_TARGET_H */ |