summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-05-05 13:00:08 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-05-05 13:00:08 +0000
commit57cbd777889010c39db892fe6e9f844f26eb3ed9 (patch)
tree8a7c28a0418b0bb8e901fcd4be22228c13dec01b
parentc8130b2666e476cfb1a171ba640900a5aed3b37d (diff)
downloadrockbox-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
-rw-r--r--firmware/drivers/ata.c8
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/ata-imx31.c48
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/ata-target.h6
3 files changed, 15 insertions, 47 deletions
diff --git a/firmware/drivers/ata.c b/firmware/drivers/ata.c
index e949f38a9d..1dd05133fe 100644
--- a/firmware/drivers/ata.c
+++ b/firmware/drivers/ata.c
@@ -1090,10 +1090,6 @@ static int identify(void)
1090#endif 1090#endif
1091 } 1091 }
1092 1092
1093#ifdef ATA_NOTIFY_IDENTIFY_READY
1094 ata_identify_ready();
1095#endif
1096
1097 return 0; 1093 return 0;
1098} 1094}
1099 1095
@@ -1172,6 +1168,10 @@ static int set_features(void)
1172 } 1168 }
1173 } 1169 }
1174 1170
1171#ifdef ATA_SET_DEVICE_FEATURES
1172 ata_set_pio_timings(pio_mode);
1173#endif
1174
1175 return 0; 1175 return 0;
1176} 1176}
1177 1177
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
82static bool initialized = false; 82static 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 */
85static void ata_set_pio_mode(int mode) 85void 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
146void 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);
68void ata_device_init(void); 68void ata_device_init(void);
69bool ata_is_coldstart(void); 69bool ata_is_coldstart(void);
70 70
71#define ATA_NOTIFY_IDENTIFY_READY 71#define ATA_SET_DEVICE_FEATURES
72void ata_identify_ready(void); 72void ata_set_pio_timings(int mode);
73 73
74#endif 74#endif /* ATA_TARGET_H */