diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2007-03-08 18:28:52 -0500 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-04-28 14:15:58 -0400 |
commit | fcc2f69a6fad1543b466db9c35aa5a2f364eb3d4 (patch) | |
tree | b479a3852fbce5a659c408dea68eec29df8b04d7 /drivers/ata/pata_hpt37x.c | |
parent | ec04b075843d12b5115267415d0426b48e672136 (diff) |
pata_hpt37x: Updates from drivers/ide work
Drag pata_hpt37x kicking and screaming in the direction of
drivers/ide/pci/hpt366.c and all the work that Sergei has been doing
there. Plenty left to be done but this is a good snapshot for folks to
work on and to review
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/ata/pata_hpt37x.c')
-rw-r--r-- | drivers/ata/pata_hpt37x.c | 358 |
1 files changed, 146 insertions, 212 deletions
diff --git a/drivers/ata/pata_hpt37x.c b/drivers/ata/pata_hpt37x.c index f331eeeafa0f..12f387f37771 100644 --- a/drivers/ata/pata_hpt37x.c +++ b/drivers/ata/pata_hpt37x.c | |||
@@ -8,6 +8,7 @@ | |||
8 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> | 8 | * Copyright (C) 1999-2003 Andre Hedrick <andre@linux-ide.org> |
9 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. | 9 | * Portions Copyright (C) 2001 Sun Microsystems, Inc. |
10 | * Portions Copyright (C) 2003 Red Hat Inc | 10 | * Portions Copyright (C) 2003 Red Hat Inc |
11 | * Portions Copyright (C) 2005-2006 MontaVista Software, Inc. | ||
11 | * | 12 | * |
12 | * TODO | 13 | * TODO |
13 | * PLL mode | 14 | * PLL mode |
@@ -25,7 +26,7 @@ | |||
25 | #include <linux/libata.h> | 26 | #include <linux/libata.h> |
26 | 27 | ||
27 | #define DRV_NAME "pata_hpt37x" | 28 | #define DRV_NAME "pata_hpt37x" |
28 | #define DRV_VERSION "0.6.0" | 29 | #define DRV_VERSION "0.6.4" |
29 | 30 | ||
30 | struct hpt_clock { | 31 | struct hpt_clock { |
31 | u8 xfer_speed; | 32 | u8 xfer_speed; |
@@ -61,201 +62,75 @@ struct hpt_chip { | |||
61 | * 31 FIFO enable. | 62 | * 31 FIFO enable. |
62 | */ | 63 | */ |
63 | 64 | ||
64 | /* from highpoint documentation. these are old values */ | 65 | static struct hpt_clock hpt37x_timings_33[] = { |
65 | static const struct hpt_clock hpt370_timings_33[] = { | 66 | { XFER_UDMA_6, 0x12446231 }, /* 0x12646231 ?? */ |
66 | /* { XFER_UDMA_5, 0x1A85F442, 0x16454e31 }, */ | 67 | { XFER_UDMA_5, 0x12446231 }, |
67 | { XFER_UDMA_5, 0x16454e31 }, | 68 | { XFER_UDMA_4, 0x12446231 }, |
68 | { XFER_UDMA_4, 0x16454e31 }, | 69 | { XFER_UDMA_3, 0x126c6231 }, |
69 | { XFER_UDMA_3, 0x166d4e31 }, | 70 | { XFER_UDMA_2, 0x12486231 }, |
70 | { XFER_UDMA_2, 0x16494e31 }, | 71 | { XFER_UDMA_1, 0x124c6233 }, |
71 | { XFER_UDMA_1, 0x164d4e31 }, | 72 | { XFER_UDMA_0, 0x12506297 }, |
72 | { XFER_UDMA_0, 0x16514e31 }, | 73 | |
73 | 74 | { XFER_MW_DMA_2, 0x22406c31 }, | |
74 | { XFER_MW_DMA_2, 0x26514e21 }, | 75 | { XFER_MW_DMA_1, 0x22406c33 }, |
75 | { XFER_MW_DMA_1, 0x26514e33 }, | 76 | { XFER_MW_DMA_0, 0x22406c97 }, |
76 | { XFER_MW_DMA_0, 0x26514e97 }, | 77 | |
77 | 78 | { XFER_PIO_4, 0x06414e31 }, | |
78 | { XFER_PIO_4, 0x06514e21 }, | 79 | { XFER_PIO_3, 0x06414e42 }, |
79 | { XFER_PIO_3, 0x06514e22 }, | 80 | { XFER_PIO_2, 0x06414e53 }, |
80 | { XFER_PIO_2, 0x06514e33 }, | 81 | { XFER_PIO_1, 0x06814e93 }, |
81 | { XFER_PIO_1, 0x06914e43 }, | 82 | { XFER_PIO_0, 0x06814ea7 } |
82 | { XFER_PIO_0, 0x06914e57 }, | ||
83 | { 0, 0x06514e57 } | ||
84 | }; | 83 | }; |
85 | 84 | ||
86 | static const struct hpt_clock hpt370_timings_66[] = { | 85 | static struct hpt_clock hpt37x_timings_50[] = { |
87 | { XFER_UDMA_5, 0x14846231 }, | 86 | { XFER_UDMA_6, 0x12848242 }, |
88 | { XFER_UDMA_4, 0x14886231 }, | 87 | { XFER_UDMA_5, 0x12848242 }, |
89 | { XFER_UDMA_3, 0x148c6231 }, | 88 | { XFER_UDMA_4, 0x12ac8242 }, |
90 | { XFER_UDMA_2, 0x148c6231 }, | 89 | { XFER_UDMA_3, 0x128c8242 }, |
91 | { XFER_UDMA_1, 0x14906231 }, | 90 | { XFER_UDMA_2, 0x120c8242 }, |
92 | { XFER_UDMA_0, 0x14986231 }, | 91 | { XFER_UDMA_1, 0x12148254 }, |
93 | 92 | { XFER_UDMA_0, 0x121882ea }, | |
94 | { XFER_MW_DMA_2, 0x26514e21 }, | 93 | |
95 | { XFER_MW_DMA_1, 0x26514e33 }, | 94 | { XFER_MW_DMA_2, 0x22808242 }, |
96 | { XFER_MW_DMA_0, 0x26514e97 }, | 95 | { XFER_MW_DMA_1, 0x22808254 }, |
97 | 96 | { XFER_MW_DMA_0, 0x228082ea }, | |
98 | { XFER_PIO_4, 0x06514e21 }, | 97 | |
99 | { XFER_PIO_3, 0x06514e22 }, | 98 | { XFER_PIO_4, 0x0a81f442 }, |
100 | { XFER_PIO_2, 0x06514e33 }, | 99 | { XFER_PIO_3, 0x0a81f443 }, |
101 | { XFER_PIO_1, 0x06914e43 }, | 100 | { XFER_PIO_2, 0x0a81f454 }, |
102 | { XFER_PIO_0, 0x06914e57 }, | 101 | { XFER_PIO_1, 0x0ac1f465 }, |
103 | { 0, 0x06514e57 } | 102 | { XFER_PIO_0, 0x0ac1f48a } |
104 | }; | 103 | }; |
105 | 104 | ||
106 | /* these are the current (4 sep 2001) timings from highpoint */ | 105 | static struct hpt_clock hpt37x_timings_66[] = { |
107 | static const struct hpt_clock hpt370a_timings_33[] = { | 106 | { XFER_UDMA_6, 0x1c869c62 }, |
108 | { XFER_UDMA_5, 0x12446231 }, | 107 | { XFER_UDMA_5, 0x1cae9c62 }, /* 0x1c8a9c62 */ |
109 | { XFER_UDMA_4, 0x12446231 }, | 108 | { XFER_UDMA_4, 0x1c8a9c62 }, |
110 | { XFER_UDMA_3, 0x126c6231 }, | 109 | { XFER_UDMA_3, 0x1c8e9c62 }, |
111 | { XFER_UDMA_2, 0x12486231 }, | 110 | { XFER_UDMA_2, 0x1c929c62 }, |
112 | { XFER_UDMA_1, 0x124c6233 }, | 111 | { XFER_UDMA_1, 0x1c9a9c62 }, |
113 | { XFER_UDMA_0, 0x12506297 }, | 112 | { XFER_UDMA_0, 0x1c829c62 }, |
114 | 113 | ||
115 | { XFER_MW_DMA_2, 0x22406c31 }, | 114 | { XFER_MW_DMA_2, 0x2c829c62 }, |
116 | { XFER_MW_DMA_1, 0x22406c33 }, | 115 | { XFER_MW_DMA_1, 0x2c829c66 }, |
117 | { XFER_MW_DMA_0, 0x22406c97 }, | 116 | { XFER_MW_DMA_0, 0x2c829d2e }, |
118 | 117 | ||
119 | { XFER_PIO_4, 0x06414e31 }, | 118 | { XFER_PIO_4, 0x0c829c62 }, |
120 | { XFER_PIO_3, 0x06414e42 }, | 119 | { XFER_PIO_3, 0x0c829c84 }, |
121 | { XFER_PIO_2, 0x06414e53 }, | 120 | { XFER_PIO_2, 0x0c829ca6 }, |
122 | { XFER_PIO_1, 0x06814e93 }, | 121 | { XFER_PIO_1, 0x0d029d26 }, |
123 | { XFER_PIO_0, 0x06814ea7 }, | 122 | { XFER_PIO_0, 0x0d029d5e } |
124 | { 0, 0x06814ea7 } | ||
125 | }; | 123 | }; |
126 | 124 | ||
127 | /* 2x 33MHz timings */ | ||
128 | static const struct hpt_clock hpt370a_timings_66[] = { | ||
129 | { XFER_UDMA_5, 0x1488e673 }, | ||
130 | { XFER_UDMA_4, 0x1488e673 }, | ||
131 | { XFER_UDMA_3, 0x1498e673 }, | ||
132 | { XFER_UDMA_2, 0x1490e673 }, | ||
133 | { XFER_UDMA_1, 0x1498e677 }, | ||
134 | { XFER_UDMA_0, 0x14a0e73f }, | ||
135 | |||
136 | { XFER_MW_DMA_2, 0x2480fa73 }, | ||
137 | { XFER_MW_DMA_1, 0x2480fa77 }, | ||
138 | { XFER_MW_DMA_0, 0x2480fb3f }, | ||
139 | |||
140 | { XFER_PIO_4, 0x0c82be73 }, | ||
141 | { XFER_PIO_3, 0x0c82be95 }, | ||
142 | { XFER_PIO_2, 0x0c82beb7 }, | ||
143 | { XFER_PIO_1, 0x0d02bf37 }, | ||
144 | { XFER_PIO_0, 0x0d02bf5f }, | ||
145 | { 0, 0x0d02bf5f } | ||
146 | }; | ||
147 | |||
148 | static const struct hpt_clock hpt370a_timings_50[] = { | ||
149 | { XFER_UDMA_5, 0x12848242 }, | ||
150 | { XFER_UDMA_4, 0x12ac8242 }, | ||
151 | { XFER_UDMA_3, 0x128c8242 }, | ||
152 | { XFER_UDMA_2, 0x120c8242 }, | ||
153 | { XFER_UDMA_1, 0x12148254 }, | ||
154 | { XFER_UDMA_0, 0x121882ea }, | ||
155 | |||
156 | { XFER_MW_DMA_2, 0x22808242 }, | ||
157 | { XFER_MW_DMA_1, 0x22808254 }, | ||
158 | { XFER_MW_DMA_0, 0x228082ea }, | ||
159 | |||
160 | { XFER_PIO_4, 0x0a81f442 }, | ||
161 | { XFER_PIO_3, 0x0a81f443 }, | ||
162 | { XFER_PIO_2, 0x0a81f454 }, | ||
163 | { XFER_PIO_1, 0x0ac1f465 }, | ||
164 | { XFER_PIO_0, 0x0ac1f48a }, | ||
165 | { 0, 0x0ac1f48a } | ||
166 | }; | ||
167 | |||
168 | static const struct hpt_clock hpt372_timings_33[] = { | ||
169 | { XFER_UDMA_6, 0x1c81dc62 }, | ||
170 | { XFER_UDMA_5, 0x1c6ddc62 }, | ||
171 | { XFER_UDMA_4, 0x1c8ddc62 }, | ||
172 | { XFER_UDMA_3, 0x1c8edc62 }, /* checkme */ | ||
173 | { XFER_UDMA_2, 0x1c91dc62 }, | ||
174 | { XFER_UDMA_1, 0x1c9adc62 }, /* checkme */ | ||
175 | { XFER_UDMA_0, 0x1c82dc62 }, /* checkme */ | ||
176 | |||
177 | { XFER_MW_DMA_2, 0x2c829262 }, | ||
178 | { XFER_MW_DMA_1, 0x2c829266 }, /* checkme */ | ||
179 | { XFER_MW_DMA_0, 0x2c82922e }, /* checkme */ | ||
180 | |||
181 | { XFER_PIO_4, 0x0c829c62 }, | ||
182 | { XFER_PIO_3, 0x0c829c84 }, | ||
183 | { XFER_PIO_2, 0x0c829ca6 }, | ||
184 | { XFER_PIO_1, 0x0d029d26 }, | ||
185 | { XFER_PIO_0, 0x0d029d5e }, | ||
186 | { 0, 0x0d029d5e } | ||
187 | }; | ||
188 | |||
189 | static const struct hpt_clock hpt372_timings_50[] = { | ||
190 | { XFER_UDMA_5, 0x12848242 }, | ||
191 | { XFER_UDMA_4, 0x12ac8242 }, | ||
192 | { XFER_UDMA_3, 0x128c8242 }, | ||
193 | { XFER_UDMA_2, 0x120c8242 }, | ||
194 | { XFER_UDMA_1, 0x12148254 }, | ||
195 | { XFER_UDMA_0, 0x121882ea }, | ||
196 | |||
197 | { XFER_MW_DMA_2, 0x22808242 }, | ||
198 | { XFER_MW_DMA_1, 0x22808254 }, | ||
199 | { XFER_MW_DMA_0, 0x228082ea }, | ||
200 | |||
201 | { XFER_PIO_4, 0x0a81f442 }, | ||
202 | { XFER_PIO_3, 0x0a81f443 }, | ||
203 | { XFER_PIO_2, 0x0a81f454 }, | ||
204 | { XFER_PIO_1, 0x0ac1f465 }, | ||
205 | { XFER_PIO_0, 0x0ac1f48a }, | ||
206 | { 0, 0x0a81f443 } | ||
207 | }; | ||
208 | |||
209 | static const struct hpt_clock hpt372_timings_66[] = { | ||
210 | { XFER_UDMA_6, 0x1c869c62 }, | ||
211 | { XFER_UDMA_5, 0x1cae9c62 }, | ||
212 | { XFER_UDMA_4, 0x1c8a9c62 }, | ||
213 | { XFER_UDMA_3, 0x1c8e9c62 }, | ||
214 | { XFER_UDMA_2, 0x1c929c62 }, | ||
215 | { XFER_UDMA_1, 0x1c9a9c62 }, | ||
216 | { XFER_UDMA_0, 0x1c829c62 }, | ||
217 | |||
218 | { XFER_MW_DMA_2, 0x2c829c62 }, | ||
219 | { XFER_MW_DMA_1, 0x2c829c66 }, | ||
220 | { XFER_MW_DMA_0, 0x2c829d2e }, | ||
221 | |||
222 | { XFER_PIO_4, 0x0c829c62 }, | ||
223 | { XFER_PIO_3, 0x0c829c84 }, | ||
224 | { XFER_PIO_2, 0x0c829ca6 }, | ||
225 | { XFER_PIO_1, 0x0d029d26 }, | ||
226 | { XFER_PIO_0, 0x0d029d5e }, | ||
227 | { 0, 0x0d029d26 } | ||
228 | }; | ||
229 | |||
230 | static const struct hpt_clock hpt374_timings_33[] = { | ||
231 | { XFER_UDMA_6, 0x12808242 }, | ||
232 | { XFER_UDMA_5, 0x12848242 }, | ||
233 | { XFER_UDMA_4, 0x12ac8242 }, | ||
234 | { XFER_UDMA_3, 0x128c8242 }, | ||
235 | { XFER_UDMA_2, 0x120c8242 }, | ||
236 | { XFER_UDMA_1, 0x12148254 }, | ||
237 | { XFER_UDMA_0, 0x121882ea }, | ||
238 | |||
239 | { XFER_MW_DMA_2, 0x22808242 }, | ||
240 | { XFER_MW_DMA_1, 0x22808254 }, | ||
241 | { XFER_MW_DMA_0, 0x228082ea }, | ||
242 | |||
243 | { XFER_PIO_4, 0x0a81f442 }, | ||
244 | { XFER_PIO_3, 0x0a81f443 }, | ||
245 | { XFER_PIO_2, 0x0a81f454 }, | ||
246 | { XFER_PIO_1, 0x0ac1f465 }, | ||
247 | { XFER_PIO_0, 0x0ac1f48a }, | ||
248 | { 0, 0x06814e93 } | ||
249 | }; | ||
250 | 125 | ||
251 | static const struct hpt_chip hpt370 = { | 126 | static const struct hpt_chip hpt370 = { |
252 | "HPT370", | 127 | "HPT370", |
253 | 48, | 128 | 48, |
254 | { | 129 | { |
255 | hpt370_timings_33, | 130 | hpt37x_timings_33, |
256 | NULL, | 131 | NULL, |
257 | NULL, | 132 | NULL, |
258 | hpt370_timings_66 | 133 | hpt37x_timings_66 |
259 | } | 134 | } |
260 | }; | 135 | }; |
261 | 136 | ||
@@ -263,10 +138,10 @@ static const struct hpt_chip hpt370a = { | |||
263 | "HPT370A", | 138 | "HPT370A", |
264 | 48, | 139 | 48, |
265 | { | 140 | { |
266 | hpt370a_timings_33, | 141 | hpt37x_timings_33, |
267 | NULL, | 142 | NULL, |
268 | hpt370a_timings_50, | 143 | hpt37x_timings_50, |
269 | hpt370a_timings_66 | 144 | hpt37x_timings_66 |
270 | } | 145 | } |
271 | }; | 146 | }; |
272 | 147 | ||
@@ -274,10 +149,10 @@ static const struct hpt_chip hpt372 = { | |||
274 | "HPT372", | 149 | "HPT372", |
275 | 55, | 150 | 55, |
276 | { | 151 | { |
277 | hpt372_timings_33, | 152 | hpt37x_timings_33, |
278 | NULL, | 153 | NULL, |
279 | hpt372_timings_50, | 154 | hpt37x_timings_50, |
280 | hpt372_timings_66 | 155 | hpt37x_timings_66 |
281 | } | 156 | } |
282 | }; | 157 | }; |
283 | 158 | ||
@@ -285,10 +160,10 @@ static const struct hpt_chip hpt302 = { | |||
285 | "HPT302", | 160 | "HPT302", |
286 | 66, | 161 | 66, |
287 | { | 162 | { |
288 | hpt372_timings_33, | 163 | hpt37x_timings_33, |
289 | NULL, | 164 | NULL, |
290 | hpt372_timings_50, | 165 | hpt37x_timings_50, |
291 | hpt372_timings_66 | 166 | hpt37x_timings_66 |
292 | } | 167 | } |
293 | }; | 168 | }; |
294 | 169 | ||
@@ -296,10 +171,10 @@ static const struct hpt_chip hpt371 = { | |||
296 | "HPT371", | 171 | "HPT371", |
297 | 66, | 172 | 66, |
298 | { | 173 | { |
299 | hpt372_timings_33, | 174 | hpt37x_timings_33, |
300 | NULL, | 175 | NULL, |
301 | hpt372_timings_50, | 176 | hpt37x_timings_50, |
302 | hpt372_timings_66 | 177 | hpt37x_timings_66 |
303 | } | 178 | } |
304 | }; | 179 | }; |
305 | 180 | ||
@@ -307,10 +182,10 @@ static const struct hpt_chip hpt372a = { | |||
307 | "HPT372A", | 182 | "HPT372A", |
308 | 66, | 183 | 66, |
309 | { | 184 | { |
310 | hpt372_timings_33, | 185 | hpt37x_timings_33, |
311 | NULL, | 186 | NULL, |
312 | hpt372_timings_50, | 187 | hpt37x_timings_50, |
313 | hpt372_timings_66 | 188 | hpt37x_timings_66 |
314 | } | 189 | } |
315 | }; | 190 | }; |
316 | 191 | ||
@@ -318,7 +193,7 @@ static const struct hpt_chip hpt374 = { | |||
318 | "HPT374", | 193 | "HPT374", |
319 | 48, | 194 | 48, |
320 | { | 195 | { |
321 | hpt374_timings_33, | 196 | hpt37x_timings_33, |
322 | NULL, | 197 | NULL, |
323 | NULL, | 198 | NULL, |
324 | NULL | 199 | NULL |
@@ -462,8 +337,7 @@ static int hpt37x_pre_reset(struct ata_port *ap) | |||
462 | ap->cbl = ATA_CBL_PATA80; | 337 | ap->cbl = ATA_CBL_PATA80; |
463 | 338 | ||
464 | /* Reset the state machine */ | 339 | /* Reset the state machine */ |
465 | pci_write_config_byte(pdev, 0x50, 0x37); | 340 | pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); |
466 | pci_write_config_byte(pdev, 0x54, 0x37); | ||
467 | udelay(100); | 341 | udelay(100); |
468 | 342 | ||
469 | return ata_std_prereset(ap); | 343 | return ata_std_prereset(ap); |
@@ -513,8 +387,7 @@ static int hpt374_pre_reset(struct ata_port *ap) | |||
513 | ap->cbl = ATA_CBL_PATA80; | 387 | ap->cbl = ATA_CBL_PATA80; |
514 | 388 | ||
515 | /* Reset the state machine */ | 389 | /* Reset the state machine */ |
516 | pci_write_config_byte(pdev, 0x50, 0x37); | 390 | pci_write_config_byte(pdev, 0x50 + 4 * ap->port_no, 0x37); |
517 | pci_write_config_byte(pdev, 0x54, 0x37); | ||
518 | udelay(100); | 391 | udelay(100); |
519 | 392 | ||
520 | return ata_std_prereset(ap); | 393 | return ata_std_prereset(ap); |
@@ -1032,6 +905,24 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1032 | .udma_mask = 0x3f, | 905 | .udma_mask = 0x3f, |
1033 | .port_ops = &hpt370a_port_ops | 906 | .port_ops = &hpt370a_port_ops |
1034 | }; | 907 | }; |
908 | /* HPT370 - UDMA100 */ | ||
909 | static struct ata_port_info info_hpt370_33 = { | ||
910 | .sht = &hpt37x_sht, | ||
911 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | ||
912 | .pio_mask = 0x1f, | ||
913 | .mwdma_mask = 0x07, | ||
914 | .udma_mask = 0x0f, | ||
915 | .port_ops = &hpt370_port_ops | ||
916 | }; | ||
917 | /* HPT370A - UDMA100 */ | ||
918 | static struct ata_port_info info_hpt370a_33 = { | ||
919 | .sht = &hpt37x_sht, | ||
920 | .flags = ATA_FLAG_SLAVE_POSS|ATA_FLAG_SRST, | ||
921 | .pio_mask = 0x1f, | ||
922 | .mwdma_mask = 0x07, | ||
923 | .udma_mask = 0x0f, | ||
924 | .port_ops = &hpt370a_port_ops | ||
925 | }; | ||
1035 | /* HPT371, 372 and friends - UDMA133 */ | 926 | /* HPT371, 372 and friends - UDMA133 */ |
1036 | static struct ata_port_info info_hpt372 = { | 927 | static struct ata_port_info info_hpt372 = { |
1037 | .sht = &hpt37x_sht, | 928 | .sht = &hpt37x_sht, |
@@ -1067,7 +958,11 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1067 | 958 | ||
1068 | u8 irqmask; | 959 | u8 irqmask; |
1069 | u32 class_rev; | 960 | u32 class_rev; |
961 | u8 mcr1; | ||
1070 | u32 freq; | 962 | u32 freq; |
963 | int prefer_dpll = 1; | ||
964 | |||
965 | unsigned long iobase = pci_resource_start(dev, 4); | ||
1071 | 966 | ||
1072 | const struct hpt_chip *chip_table; | 967 | const struct hpt_chip *chip_table; |
1073 | int clock_slot; | 968 | int clock_slot; |
@@ -1088,10 +983,12 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1088 | case 3: | 983 | case 3: |
1089 | port = &info_hpt370; | 984 | port = &info_hpt370; |
1090 | chip_table = &hpt370; | 985 | chip_table = &hpt370; |
986 | prefer_dpll = 0; | ||
1091 | break; | 987 | break; |
1092 | case 4: | 988 | case 4: |
1093 | port = &info_hpt370a; | 989 | port = &info_hpt370a; |
1094 | chip_table = &hpt370a; | 990 | chip_table = &hpt370a; |
991 | prefer_dpll = 0; | ||
1095 | break; | 992 | break; |
1096 | case 5: | 993 | case 5: |
1097 | port = &info_hpt372; | 994 | port = &info_hpt372; |
@@ -1119,8 +1016,16 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1119 | chip_table = &hpt302; | 1016 | chip_table = &hpt302; |
1120 | break; | 1017 | break; |
1121 | case PCI_DEVICE_ID_TTI_HPT371: | 1018 | case PCI_DEVICE_ID_TTI_HPT371: |
1019 | if (class_rev > 1) | ||
1020 | return -ENODEV; | ||
1122 | port = &info_hpt372; | 1021 | port = &info_hpt372; |
1123 | chip_table = &hpt371; | 1022 | chip_table = &hpt371; |
1023 | /* Single channel device, paster is not present | ||
1024 | but the NIOS (or us for non x86) must mark it | ||
1025 | absent */ | ||
1026 | pci_read_config_byte(dev, 0x50, &mcr1); | ||
1027 | mcr1 &= ~0x04; | ||
1028 | pci_write_config_byte(dev, 0x50, mcr1); | ||
1124 | break; | 1029 | break; |
1125 | case PCI_DEVICE_ID_TTI_HPT374: | 1030 | case PCI_DEVICE_ID_TTI_HPT374: |
1126 | chip_table = &hpt374; | 1031 | chip_table = &hpt374; |
@@ -1150,8 +1055,18 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1150 | */ | 1055 | */ |
1151 | 1056 | ||
1152 | pci_write_config_byte(dev, 0x5b, 0x23); | 1057 | pci_write_config_byte(dev, 0x5b, 0x23); |
1058 | |||
1059 | /* | ||
1060 | * HighPoint does this for HPT372A. | ||
1061 | * NOTE: This register is only writeable via I/O space. | ||
1062 | */ | ||
1063 | if (chip_table == &hpt372a) | ||
1064 | outb(0x0e, iobase + 0x9c); | ||
1153 | 1065 | ||
1154 | pci_read_config_dword(dev, 0x70, &freq); | 1066 | /* Some devices do not let this value be accessed via PCI space |
1067 | according to the old driver */ | ||
1068 | |||
1069 | freq = inl(iobase + 0x90); | ||
1155 | if ((freq >> 12) != 0xABCDE) { | 1070 | if ((freq >> 12) != 0xABCDE) { |
1156 | int i; | 1071 | int i; |
1157 | u8 sr; | 1072 | u8 sr; |
@@ -1162,7 +1077,7 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1162 | /* This is the process the HPT371 BIOS is reported to use */ | 1077 | /* This is the process the HPT371 BIOS is reported to use */ |
1163 | for(i = 0; i < 128; i++) { | 1078 | for(i = 0; i < 128; i++) { |
1164 | pci_read_config_byte(dev, 0x78, &sr); | 1079 | pci_read_config_byte(dev, 0x78, &sr); |
1165 | total += sr; | 1080 | total += sr & 0x1FF; |
1166 | udelay(15); | 1081 | udelay(15); |
1167 | } | 1082 | } |
1168 | freq = total / 128; | 1083 | freq = total / 128; |
@@ -1173,15 +1088,27 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1173 | * Turn the frequency check into a band and then find a timing | 1088 | * Turn the frequency check into a band and then find a timing |
1174 | * table to match it. | 1089 | * table to match it. |
1175 | */ | 1090 | */ |
1176 | 1091 | ||
1177 | clock_slot = hpt37x_clock_slot(freq, chip_table->base); | 1092 | clock_slot = hpt37x_clock_slot(freq, chip_table->base); |
1178 | if (chip_table->clocks[clock_slot] == NULL) { | 1093 | if (chip_table->clocks[clock_slot] == NULL || prefer_dpll) { |
1179 | /* | 1094 | /* |
1180 | * We need to try PLL mode instead | 1095 | * We need to try PLL mode instead |
1096 | * | ||
1097 | * For non UDMA133 capable devices we should | ||
1098 | * use a 50MHz DPLL by choice | ||
1181 | */ | 1099 | */ |
1182 | unsigned int f_low = (MHz[clock_slot] * chip_table->base) / 192; | 1100 | unsigned int f_low, f_high; |
1183 | unsigned int f_high = f_low + 2; | ||
1184 | int adjust; | 1101 | int adjust; |
1102 | |||
1103 | clock_slot = 2; | ||
1104 | if (port->udma_mask & 0xE0) | ||
1105 | clock_slot = 3; | ||
1106 | |||
1107 | f_low = (MHz[clock_slot] * chip_table->base) / 192; | ||
1108 | f_high = f_low + 2; | ||
1109 | |||
1110 | /* Select the DPLL clock. */ | ||
1111 | pci_write_config_byte(dev, 0x5b, 0x21); | ||
1185 | 1112 | ||
1186 | for(adjust = 0; adjust < 8; adjust++) { | 1113 | for(adjust = 0; adjust < 8; adjust++) { |
1187 | if (hpt37x_calibrate_dpll(dev)) | 1114 | if (hpt37x_calibrate_dpll(dev)) |
@@ -1197,15 +1124,17 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1197 | printk(KERN_WARNING "hpt37x: DPLL did not stabilize.\n"); | 1124 | printk(KERN_WARNING "hpt37x: DPLL did not stabilize.\n"); |
1198 | return -ENODEV; | 1125 | return -ENODEV; |
1199 | } | 1126 | } |
1200 | /* Check if this works for all cases */ | 1127 | if (clock_slot == 3) |
1201 | port->private_data = (void *)hpt370_timings_66; | 1128 | port->private_data = (void *)hpt37x_timings_66; |
1129 | else | ||
1130 | port->private_data = (void *)hpt37x_timings_50; | ||
1202 | 1131 | ||
1203 | printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); | 1132 | printk(KERN_INFO "hpt37x: Bus clock %dMHz, using DPLL.\n", MHz[clock_slot]); |
1204 | } else { | 1133 | } else { |
1205 | port->private_data = (void *)chip_table->clocks[clock_slot]; | 1134 | port->private_data = (void *)chip_table->clocks[clock_slot]; |
1206 | /* | 1135 | /* |
1207 | * Perform a final fixup. The 371 and 372 clock determines | 1136 | * Perform a final fixup. The 371 and 372 clock determines |
1208 | * if UDMA133 is available. | 1137 | * if UDMA133 is available. (FIXME: should we use DPLL then ?) |
1209 | */ | 1138 | */ |
1210 | 1139 | ||
1211 | if (clock_slot == 2 && chip_table == &hpt372) { /* 50Mhz */ | 1140 | if (clock_slot == 2 && chip_table == &hpt372) { /* 50Mhz */ |
@@ -1214,8 +1143,13 @@ static int hpt37x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
1214 | port = &info_hpt372_50; | 1143 | port = &info_hpt372_50; |
1215 | else BUG(); | 1144 | else BUG(); |
1216 | } | 1145 | } |
1146 | if (clock_slot < 2 && port == &info_hpt370) | ||
1147 | port = &info_hpt370_33; | ||
1148 | if (clock_slot < 2 && port == &info_hpt370a) | ||
1149 | port = &info_hpt370a_33; | ||
1217 | printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); | 1150 | printk(KERN_INFO "hpt37x: %s: Bus clock %dMHz.\n", chip_table->name, MHz[clock_slot]); |
1218 | } | 1151 | } |
1152 | |||
1219 | port_info[0] = port_info[1] = port; | 1153 | port_info[0] = port_info[1] = port; |
1220 | /* Now kick off ATA set up */ | 1154 | /* Now kick off ATA set up */ |
1221 | return ata_pci_init_one(dev, port_info, 2); | 1155 | return ata_pci_init_one(dev, port_info, 2); |