diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2008-05-05 13:00:08 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2008-05-05 13:00:08 +0000 |
commit | 57cbd777889010c39db892fe6e9f844f26eb3ed9 (patch) | |
tree | 8a7c28a0418b0bb8e901fcd4be22228c13dec01b /firmware/target/arm/imx31 | |
parent | c8130b2666e476cfb1a171ba640900a5aed3b37d (diff) | |
download | rockbox-57cbd777889010c39db892fe6e9f844f26eb3ed9.tar.gz rockbox-57cbd777889010c39db892fe6e9f844f26eb3ed9.zip |
Gigabeat S: Do the controller timing settings a more cleanly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17379 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx31')
-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 | |||
79 | }, | 79 | }, |
80 | }; | 80 | }; |
81 | 81 | ||
82 | static bool initialized = false; | 82 | static int pio_mode = 0; /* Setup mode 0 by default */ |
83 | 83 | ||
84 | /* Setup the timing for PIO mode */ | 84 | /* Setup the timing for PIO mode */ |
85 | static void ata_set_pio_mode(int mode) | 85 | void ata_set_pio_timings(int mode) |
86 | { | 86 | { |
87 | const struct ata_pio_timings * const timings = &pio_timings[mode]; | 87 | while (!(ATA_INTERRUPT_PENDING & ATA_CONTROLLER_IDLE)); |
88 | 88 | ||
89 | const struct ata_pio_timings * const timings = &pio_timings[mode]; | ||
89 | /* T = period in nanoseconds */ | 90 | /* T = period in nanoseconds */ |
90 | int T = 1000 * 1000 * 1000 / imx31_clkctl_get_ata_clk(); | 91 | int T = 1000 * 1000 * 1000 / imx31_clkctl_get_ata_clk(); |
91 | 92 | ||
92 | while (!(ATA_INTERRUPT_PENDING & ATA_CONTROLLER_IDLE)); | 93 | pio_mode = mode; |
93 | 94 | ||
94 | ATA_TIME_OFF = 3; | 95 | ATA_TIME_OFF = 3; |
95 | ATA_TIME_ON = 3; | 96 | ATA_TIME_ON = 3; |
@@ -128,40 +129,7 @@ void ata_device_init(void) | |||
128 | { | 129 | { |
129 | ATA_INTF_CONTROL |= ATA_ATA_RST; /* Make sure we're not in reset mode */ | 130 | ATA_INTF_CONTROL |= ATA_ATA_RST; /* Make sure we're not in reset mode */ |
130 | 131 | ||
131 | if (!initialized) | 132 | /* mode may be switched later once identify info is ready in which |
132 | { | 133 | * case the main driver calls back */ |
133 | initialized = true; | 134 | ata_set_pio_timings(pio_mode); |
134 | /* Setup mode 0 by default */ | ||
135 | ata_set_pio_mode(0); | ||
136 | /* mode may be switched later once identify info is ready in which | ||
137 | * case the main driver calls back */ | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | /* identify info will be ready */ | ||
142 | ata_identify_ready(); | ||
143 | } | ||
144 | } | ||
145 | |||
146 | void ata_identify_ready(void) | ||
147 | { | ||
148 | const unsigned short* identify_info = ata_get_identify(); | ||
149 | int mode = 0; | ||
150 | |||
151 | if (identify_info[53] & (1 << 1)) | ||
152 | { | ||
153 | /* Set up advanced timings */ | ||
154 | if (identify_info[64] & (1 << 1)) | ||
155 | mode = 4; /* Mode 0, 1, 2, 3, 4 */ | ||
156 | else if (identify_info[64] & (1 << 0)) | ||
157 | mode = 3; /* Mode 0, 1, 2, 3 */ | ||
158 | else | ||
159 | mode = 2; /* Mode 0, 1, 2 */ | ||
160 | } | ||
161 | |||
162 | /* If mode changed, actually set the timings */ | ||
163 | if (mode != 0) | ||
164 | { | ||
165 | ata_set_pio_mode(mode); | ||
166 | } | ||
167 | } | 135 | } |
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); | |||
68 | void ata_device_init(void); | 68 | void ata_device_init(void); |
69 | bool ata_is_coldstart(void); | 69 | bool ata_is_coldstart(void); |
70 | 70 | ||
71 | #define ATA_NOTIFY_IDENTIFY_READY | 71 | #define ATA_SET_DEVICE_FEATURES |
72 | void ata_identify_ready(void); | 72 | void ata_set_pio_timings(int mode); |
73 | 73 | ||
74 | #endif | 74 | #endif /* ATA_TARGET_H */ |