xref: /freebsd/sys/dev/ata/ata-pci.h (revision f0a75d274af375d15b97b830966b99a02b7db911)
1 /*-
2  * Copyright (c) 2003 - 2007 S�ren Schmidt <sos@FreeBSD.org>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer,
10  *    without modification, immediately at the beginning of the file.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28 
29 /* structure holding chipset config info */
30 struct ata_chip_id {
31     u_int32_t           chipid;
32     u_int8_t            chiprev;
33     int                 cfg1;
34     int                 cfg2;
35     u_int8_t            max_dma;
36     char                *text;
37 };
38 
39 /* structure describing a PCI ATA controller */
40 struct ata_pci_controller {
41     device_t            dev;
42     int                 r_type1;
43     int                 r_rid1;
44     struct resource     *r_res1;
45     int                 r_type2;
46     int                 r_rid2;
47     struct resource     *r_res2;
48     struct resource     *r_irq;
49     void                *handle;
50     struct ata_chip_id  *chip;
51     int                 channels;
52     int                 (*chipinit)(device_t);
53     int                 (*allocate)(device_t);
54     int                 (*locking)(device_t, int);
55     void                (*reset)(device_t);
56     void                (*dmainit)(device_t);
57     void                (*setmode)(device_t, int);
58     struct {
59     void                (*function)(void *);
60     void                *argument;
61     } interrupt[8];     /* XXX SOS max ch# for now */
62 };
63 
64 /* structure for SATA connection update hotplug/hotswap support */
65 struct ata_connect_task {
66     struct task task;
67     device_t    dev;
68     int         action;
69 #define ATA_C_ATTACH    1
70 #define ATA_C_DETACH    2
71 };
72 
73 /* defines for known chipset PCI id's */
74 #define ATA_ACARD_ID            0x1191
75 #define ATA_ATP850              0x00021191
76 #define ATA_ATP850A             0x00041191
77 #define ATA_ATP850R             0x00051191
78 #define ATA_ATP860A             0x00061191
79 #define ATA_ATP860R             0x00071191
80 #define ATA_ATP865A             0x00081191
81 #define ATA_ATP865R             0x00091191
82 
83 #define ATA_AMD_ID              0x1022
84 #define ATA_AMD755              0x74011022
85 #define ATA_AMD756              0x74091022
86 #define ATA_AMD766              0x74111022
87 #define ATA_AMD768              0x74411022
88 #define ATA_AMD8111             0x74691022
89 
90 #define ATA_ACER_LABS_ID        0x10b9
91 #define ATA_ALI_1533            0x153310b9
92 #define ATA_ALI_5229            0x522910b9
93 #define ATA_ALI_5281            0x528110b9
94 #define ATA_ALI_5287            0x528710b9
95 #define ATA_ALI_5288            0x528810b9
96 #define ATA_ALI_5289            0x528910b9
97 
98 #define ATA_ATI_ID              0x1002
99 #define ATA_ATI_IXP200          0x43491002
100 #define ATA_ATI_IXP300          0x43691002
101 #define ATA_ATI_IXP400          0x43761002
102 #define ATA_ATI_IXP300_S1       0x436e1002
103 #define ATA_ATI_IXP400_S1       0x43791002
104 #define ATA_ATI_IXP400_S2       0x437a1002
105 
106 #define ATA_CENATEK_ID          0x16ca
107 #define ATA_CENATEK_ROCKET      0x000116ca
108 
109 #define ATA_CYRIX_ID            0x1078
110 #define ATA_CYRIX_5530          0x01021078
111 
112 #define ATA_CYPRESS_ID          0x1080
113 #define ATA_CYPRESS_82C693      0xc6931080
114 
115 #define ATA_DEC_21150           0x00221011
116 #define ATA_DEC_21150_1         0x00231011
117 
118 #define ATA_HIGHPOINT_ID        0x1103
119 #define ATA_HPT366              0x00041103
120 #define ATA_HPT372              0x00051103
121 #define ATA_HPT302              0x00061103
122 #define ATA_HPT371              0x00071103
123 #define ATA_HPT374              0x00081103
124 
125 #define ATA_INTEL_ID            0x8086
126 #define ATA_I960RM              0x09628086
127 #define ATA_I82371FB            0x12308086
128 #define ATA_I82371SB            0x70108086
129 #define ATA_I82371AB            0x71118086
130 #define ATA_I82443MX            0x71998086
131 #define ATA_I82451NX            0x84ca8086
132 #define ATA_I82372FB            0x76018086
133 #define ATA_I82801AB            0x24218086
134 #define ATA_I82801AA            0x24118086
135 #define ATA_I82801BA            0x244a8086
136 #define ATA_I82801BA_1          0x244b8086
137 #define ATA_I82801CA            0x248a8086
138 #define ATA_I82801CA_1          0x248b8086
139 #define ATA_I82801DB            0x24cb8086
140 #define ATA_I82801DB_1          0x24ca8086
141 #define ATA_I82801EB            0x24db8086
142 #define ATA_I82801EB_S1         0x24d18086
143 #define ATA_I82801EB_R1         0x24df8086
144 #define ATA_I6300ESB            0x25a28086
145 #define ATA_I6300ESB_S1         0x25a38086
146 #define ATA_I6300ESB_R1         0x25b08086
147 #define ATA_I63XXESB2           0x269e8086
148 #define ATA_I63XXESB2_S1        0x26808086
149 #define ATA_I63XXESB2_S2        0x26818086
150 #define ATA_I63XXESB2_R1        0x26828086
151 #define ATA_I63XXESB2_R2        0x26838086
152 #define ATA_I82801FB            0x266f8086
153 #define ATA_I82801FB_S1         0x26518086
154 #define ATA_I82801FB_R1         0x26528086
155 #define ATA_I82801FBM           0x26538086
156 #define ATA_I82801GB            0x27df8086
157 #define ATA_I82801GB_S1         0x27c08086
158 #define ATA_I82801GB_AH         0x27c18086
159 #define ATA_I82801GB_R1         0x27c38086
160 #define ATA_I82801GBM_S1        0x27c48086
161 #define ATA_I82801GBM_AH        0x27c58086
162 #define ATA_I82801GBM_R1        0x27c68086
163 #define ATA_I82801HB_S1         0x28208086
164 #define ATA_I82801HB_AH6        0x28218086
165 #define ATA_I82801HB_R1         0x28228086
166 #define ATA_I82801HB_AH4        0x28248086
167 #define ATA_I82801HB_S2         0x28258086
168 #define ATA_I82801HBM_S1        0x28298086
169 #define ATA_I82801HBM_S2        0x282a8086
170 #define ATA_I31244              0x32008086
171 
172 #define ATA_ITE_ID              0x1283
173 #define ATA_IT8211F             0x82111283
174 #define ATA_IT8212F             0x82121283
175 
176 #define ATA_JMICRON_ID          0x197b
177 #define ATA_JMB360              0x2360197b
178 #define ATA_JMB361              0x2361197b
179 #define ATA_JMB363              0x2363197b
180 #define ATA_JMB365              0x2365197b
181 #define ATA_JMB366              0x2366197b
182 #define ATA_JMB368              0x2368197b
183 
184 #define ATA_MARVELL_ID          0x11ab
185 #define ATA_M88SX5040           0x504011ab
186 #define ATA_M88SX5041           0x504111ab
187 #define ATA_M88SX5080           0x508011ab
188 #define ATA_M88SX5081           0x508111ab
189 #define ATA_M88SX6041           0x604111ab
190 #define ATA_M88SX6081           0x608111ab
191 #define ATA_M88SX6101           0x610111ab
192 #define ATA_M88SX6145           0x614511ab
193 
194 #define ATA_MICRON_ID           0x1042
195 #define ATA_MICRON_RZ1000       0x10001042
196 #define ATA_MICRON_RZ1001       0x10011042
197 
198 #define ATA_NATIONAL_ID         0x100b
199 #define ATA_SC1100              0x0502100b
200 
201 #define ATA_NETCELL_ID          0x169c
202 #define ATA_NETCELL_SR          0x0044169c
203 
204 #define ATA_NVIDIA_ID           0x10de
205 #define ATA_NFORCE1             0x01bc10de
206 #define ATA_NFORCE2             0x006510de
207 #define ATA_NFORCE2_PRO         0x008510de
208 #define ATA_NFORCE2_PRO_S1      0x008e10de
209 #define ATA_NFORCE3             0x00d510de
210 #define ATA_NFORCE3_PRO         0x00e510de
211 #define ATA_NFORCE3_PRO_S1      0x00e310de
212 #define ATA_NFORCE3_PRO_S2      0x00ee10de
213 #define ATA_NFORCE_MCP04        0x003510de
214 #define ATA_NFORCE_MCP04_S1     0x003610de
215 #define ATA_NFORCE_MCP04_S2     0x003e10de
216 #define ATA_NFORCE_CK804        0x005310de
217 #define ATA_NFORCE_CK804_S1     0x005410de
218 #define ATA_NFORCE_CK804_S2     0x005510de
219 #define ATA_NFORCE_MCP51        0x026510de
220 #define ATA_NFORCE_MCP51_S1     0x026610de
221 #define ATA_NFORCE_MCP51_S2     0x026710de
222 #define ATA_NFORCE_MCP55        0x036e10de
223 #define ATA_NFORCE_MCP55_S1     0x037e10de
224 #define ATA_NFORCE_MCP55_S2     0x037f10de
225 
226 #define ATA_PROMISE_ID          0x105a
227 #define ATA_PDC20246            0x4d33105a
228 #define ATA_PDC20262            0x4d38105a
229 #define ATA_PDC20263            0x0d38105a
230 #define ATA_PDC20265            0x0d30105a
231 #define ATA_PDC20267            0x4d30105a
232 #define ATA_PDC20268            0x4d68105a
233 #define ATA_PDC20269            0x4d69105a
234 #define ATA_PDC20270            0x6268105a
235 #define ATA_PDC20271            0x6269105a
236 #define ATA_PDC20275            0x1275105a
237 #define ATA_PDC20276            0x5275105a
238 #define ATA_PDC20277            0x7275105a
239 #define ATA_PDC20318            0x3318105a
240 #define ATA_PDC20319            0x3319105a
241 #define ATA_PDC20371            0x3371105a
242 #define ATA_PDC20375            0x3375105a
243 #define ATA_PDC20376            0x3376105a
244 #define ATA_PDC20377            0x3377105a
245 #define ATA_PDC20378            0x3373105a
246 #define ATA_PDC20379            0x3372105a
247 #define ATA_PDC20571            0x3571105a
248 #define ATA_PDC20575            0x3d75105a
249 #define ATA_PDC20579            0x3574105a
250 #define ATA_PDC20771            0x3570105a
251 #define ATA_PDC40518            0x3d18105a
252 #define ATA_PDC40519            0x3519105a
253 #define ATA_PDC40718            0x3d17105a
254 #define ATA_PDC40719            0x3515105a
255 #define ATA_PDC40775            0x3d73105a
256 #define ATA_PDC40779            0x3577105a
257 #define ATA_PDC20617            0x6617105a
258 #define ATA_PDC20618            0x6626105a
259 #define ATA_PDC20619            0x6629105a
260 #define ATA_PDC20620            0x6620105a
261 #define ATA_PDC20621            0x6621105a
262 #define ATA_PDC20622            0x6622105a
263 #define ATA_PDC20624            0x6624105a
264 #define ATA_PDC81518            0x8002105a
265 
266 #define ATA_SERVERWORKS_ID      0x1166
267 #define ATA_ROSB4_ISA           0x02001166
268 #define ATA_ROSB4               0x02111166
269 #define ATA_CSB5                0x02121166
270 #define ATA_CSB6                0x02131166
271 #define ATA_CSB6_1              0x02171166
272 #define ATA_HT1000              0x02141166
273 #define ATA_HT1000_S1           0x024b1166
274 #define ATA_HT1000_S2           0x024a1166
275 #define ATA_K2			0x02401166
276 #define ATA_FRODO4		0x02411166
277 #define ATA_FRODO8		0x02421166
278 
279 #define ATA_SILICON_IMAGE_ID    0x1095
280 #define ATA_SII3114             0x31141095
281 #define ATA_SII3512             0x35121095
282 #define ATA_SII3112             0x31121095
283 #define ATA_SII3112_1           0x02401095
284 #define ATA_SII3124		0x31241095
285 #define ATA_SII3132		0x31321095
286 #define ATA_SII0680             0x06801095
287 #define ATA_CMD646              0x06461095
288 #define ATA_CMD648              0x06481095
289 #define ATA_CMD649              0x06491095
290 
291 #define ATA_SIS_ID              0x1039
292 #define ATA_SISSOUTH            0x00081039
293 #define ATA_SIS5511             0x55111039
294 #define ATA_SIS5513             0x55131039
295 #define ATA_SIS5517             0x55171039
296 #define ATA_SIS5518             0x55181039
297 #define ATA_SIS5571             0x55711039
298 #define ATA_SIS5591             0x55911039
299 #define ATA_SIS5596             0x55961039
300 #define ATA_SIS5597             0x55971039
301 #define ATA_SIS5598             0x55981039
302 #define ATA_SIS5600             0x56001039
303 #define ATA_SIS530              0x05301039
304 #define ATA_SIS540              0x05401039
305 #define ATA_SIS550              0x05501039
306 #define ATA_SIS620              0x06201039
307 #define ATA_SIS630              0x06301039
308 #define ATA_SIS635              0x06351039
309 #define ATA_SIS633              0x06331039
310 #define ATA_SIS640              0x06401039
311 #define ATA_SIS645              0x06451039
312 #define ATA_SIS646              0x06461039
313 #define ATA_SIS648              0x06481039
314 #define ATA_SIS650              0x06501039
315 #define ATA_SIS651              0x06511039
316 #define ATA_SIS652              0x06521039
317 #define ATA_SIS655              0x06551039
318 #define ATA_SIS658              0x06581039
319 #define ATA_SIS661              0x06611039
320 #define ATA_SIS730              0x07301039
321 #define ATA_SIS733              0x07331039
322 #define ATA_SIS735              0x07351039
323 #define ATA_SIS740              0x07401039
324 #define ATA_SIS745              0x07451039
325 #define ATA_SIS746              0x07461039
326 #define ATA_SIS748              0x07481039
327 #define ATA_SIS750              0x07501039
328 #define ATA_SIS751              0x07511039
329 #define ATA_SIS752              0x07521039
330 #define ATA_SIS755              0x07551039
331 #define ATA_SIS961              0x09611039
332 #define ATA_SIS962              0x09621039
333 #define ATA_SIS963              0x09631039
334 #define ATA_SIS964              0x09641039
335 #define ATA_SIS965              0x09651039
336 #define ATA_SIS180              0x01801039
337 #define ATA_SIS181              0x01811039
338 #define ATA_SIS182              0x01821039
339 
340 #define ATA_VIA_ID              0x1106
341 #define ATA_VIA82C571           0x05711106
342 #define ATA_VIA82C586           0x05861106
343 #define ATA_VIA82C596           0x05961106
344 #define ATA_VIA82C686           0x06861106
345 #define ATA_VIA8231             0x82311106
346 #define ATA_VIA8233             0x30741106
347 #define ATA_VIA8233A            0x31471106
348 #define ATA_VIA8233C            0x31091106
349 #define ATA_VIA8235             0x31771106
350 #define ATA_VIA8237             0x32271106
351 #define ATA_VIA8237A            0x05911106
352 #define ATA_VIA8251             0x33491106
353 #define ATA_VIA8361             0x31121106
354 #define ATA_VIA8363             0x03051106
355 #define ATA_VIA8371             0x03911106
356 #define ATA_VIA8662             0x31021106
357 #define ATA_VIA6410             0x31641106
358 #define ATA_VIA6420             0x31491106
359 #define ATA_VIA6421             0x32491106
360 
361 /* chipset setup related defines */
362 #define AHCI            1
363 #define ATPOLD          1
364 
365 #define ALIOLD          0x01
366 #define ALINEW          0x02
367 #define ALISATA         0x04
368 
369 #define HPT366          0
370 #define HPT370          1
371 #define HPT372          2
372 #define HPT374          3
373 #define HPTOLD          0x01
374 
375 #define MV50XX          50
376 #define MV60XX          60
377 #define MV61XX          61
378 
379 #define PROLD           0
380 #define PRNEW           1
381 #define PRTX            2
382 #define PRMIO           3
383 #define PRTX4           0x01
384 #define PRSX4X          0x02
385 #define PRSX6K          0x04
386 #define PRPATA          0x08
387 #define PRCMBO          0x10
388 #define PRCMBO2         0x20
389 #define PRSATA          0x40
390 #define PRSATA2         0x80
391 
392 #define SWKS33          0
393 #define SWKS66          1
394 #define SWKS100         2
395 #define SWKSMIO         3
396 
397 #define SIIMEMIO        1
398 #define SIIPRBIO        2
399 #define SIIINTR         0x01
400 #define SIISETCLK       0x02
401 #define SIIBUG          0x04
402 #define SII4CH          0x08
403 
404 #define SIS_SOUTH       1
405 #define SISSATA         2
406 #define SIS133NEW       3
407 #define SIS133OLD       4
408 #define SIS100NEW       5
409 #define SIS100OLD       6
410 #define SIS66           7
411 #define SIS33           8
412 
413 #define VIA33           0
414 #define VIA66           1
415 #define VIA100          2
416 #define VIA133          3
417 #define AMDNVIDIA       4
418 
419 #define AMDCABLE        0x0001
420 #define AMDBUG          0x0002
421 #define NVIDIA          0x0004
422 #define NV4             0x0010
423 #define NVQ             0x0020
424 #define VIACLK          0x0100
425 #define VIABUG          0x0200
426 #define VIABAR          0x0400
427 #define VIAAHCI         0x0800
428 
429 
430 /* global prototypes ata-pci.c */
431 int ata_pci_probe(device_t dev);
432 int ata_pci_attach(device_t dev);
433 int ata_pci_detach(device_t dev);
434 struct resource * ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, u_long start, u_long end, u_long count, u_int flags);
435 int ata_pci_release_resource(device_t dev, device_t child, int type, int rid, struct resource *r);
436 int ata_pci_setup_intr(device_t dev, device_t child, struct resource *irq, int flags, driver_filter_t *filter, driver_intr_t *function, void *argument, void **cookiep);
437  int ata_pci_teardown_intr(device_t dev, device_t child, struct resource *irq, void *cookie);
438 int ata_pci_allocate(device_t dev);
439 void ata_pci_hw(device_t dev);
440 int ata_pci_status(device_t dev);
441 void ata_pci_dmainit(device_t);
442 
443 
444 /* global prototypes ata-chipset.c */
445 int ata_generic_ident(device_t);
446 int ata_acard_ident(device_t);
447 int ata_ali_ident(device_t);
448 int ata_amd_ident(device_t);
449 int ata_ati_ident(device_t);
450 int ata_cyrix_ident(device_t);
451 int ata_cypress_ident(device_t);
452 int ata_highpoint_ident(device_t);
453 int ata_intel_ident(device_t);
454 int ata_ite_ident(device_t);
455 int ata_jmicron_ident(device_t);
456 int ata_marvell_ident(device_t);
457 int ata_national_ident(device_t);
458 int ata_nvidia_ident(device_t);
459 int ata_netcell_ident(device_t);
460 int ata_promise_ident(device_t);
461 int ata_serverworks_ident(device_t);
462 int ata_sii_ident(device_t);
463 int ata_sis_ident(device_t);
464 int ata_via_ident(device_t);
465 int ata_legacy(device_t);
466 
467 /* global prototypes ata-dma.c */
468 void ata_dmainit(device_t);
469