2 * Copyright (c) 2006 Marcel Moolenaar
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
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.
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.
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
31 * PCI "universal" communications card driver configuration data (used to
32 * match/attach the cards).
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/kernel.h>
39 #include <sys/sysctl.h>
41 #include <machine/resource.h>
42 #include <machine/bus.h>
45 #include <dev/ic/ns16550.h>
47 #include <dev/pci/pcireg.h>
48 #include <dev/pci/pcivar.h>
50 #include <dev/puc/puc_bus.h>
51 #include <dev/puc/puc_cfg.h>
52 #include <dev/puc/puc_bfe.h>
54 static puc_config_f puc_config_advantech;
55 static puc_config_f puc_config_amc;
56 static puc_config_f puc_config_diva;
57 static puc_config_f puc_config_exar;
58 static puc_config_f puc_config_exar_pcie;
59 static puc_config_f puc_config_icbook;
60 static puc_config_f puc_config_moxa;
61 static puc_config_f puc_config_oxford_pci954;
62 static puc_config_f puc_config_oxford_pcie;
63 static puc_config_f puc_config_quatech;
64 static puc_config_f puc_config_syba;
65 static puc_config_f puc_config_siig;
66 static puc_config_f puc_config_sunix;
67 static puc_config_f puc_config_timedia;
68 static puc_config_f puc_config_titan;
70 const struct puc_cfg puc_pci_devices[] = {
71 { 0x0009, 0x7168, 0xffff, 0,
74 PUC_PORT_2S, 0x10, 0, 8,
77 { 0x103c, 0x1048, 0x103c, 0x1049,
78 "HP Diva Serial [GSP] Multiport UART - Tosca Console",
80 PUC_PORT_3S, 0x10, 0, -1,
81 .config_function = puc_config_diva
84 { 0x103c, 0x1048, 0x103c, 0x104a,
85 "HP Diva Serial [GSP] Multiport UART - Tosca Secondary",
87 PUC_PORT_2S, 0x10, 0, -1,
88 .config_function = puc_config_diva
91 { 0x103c, 0x1048, 0x103c, 0x104b,
92 "HP Diva Serial [GSP] Multiport UART - Maestro SP2",
94 PUC_PORT_4S, 0x10, 0, -1,
95 .config_function = puc_config_diva
98 { 0x103c, 0x1048, 0x103c, 0x1223,
99 "HP Diva Serial [GSP] Multiport UART - Superdome Console",
101 PUC_PORT_3S, 0x10, 0, -1,
102 .config_function = puc_config_diva
105 { 0x103c, 0x1048, 0x103c, 0x1226,
106 "HP Diva Serial [GSP] Multiport UART - Keystone SP2",
108 PUC_PORT_3S, 0x10, 0, -1,
109 .config_function = puc_config_diva
112 { 0x103c, 0x1048, 0x103c, 0x1282,
113 "HP Diva Serial [GSP] Multiport UART - Everest SP2",
115 PUC_PORT_3S, 0x10, 0, -1,
116 .config_function = puc_config_diva
119 { 0x10b5, 0x1076, 0x10b5, 0x1076,
122 PUC_PORT_8S, 0x18, 0, 8,
125 { 0x10b5, 0x1077, 0x10b5, 0x1077,
128 PUC_PORT_4S, 0x18, 0, 8,
131 { 0x10b5, 0x1103, 0x10b5, 0x1103,
134 PUC_PORT_2S, 0x18, 4, 0,
138 * Boca Research Turbo Serial 658 (8 serial port) card.
139 * Appears to be the same as Chase Research PLC PCI-FAST8
140 * and Perle PCI-FAST8 Multi-Port serial cards.
142 { 0x10b5, 0x9050, 0x12e0, 0x0021,
143 "Boca Research Turbo Serial 658",
145 PUC_PORT_8S, 0x18, 0, 8,
148 { 0x10b5, 0x9050, 0x12e0, 0x0031,
149 "Boca Research Turbo Serial 654",
151 PUC_PORT_4S, 0x18, 0, 8,
155 * Dolphin Peripherals 4035 (dual serial port) card. PLX 9050, with
156 * a seemingly-lame EEPROM setup that puts the Dolphin IDs
157 * into the subsystem fields, and claims that it's a
158 * network/misc (0x02/0x80) device.
160 { 0x10b5, 0x9050, 0xd84d, 0x6808,
161 "Dolphin Peripherals 4035",
163 PUC_PORT_2S, 0x18, 4, 0,
167 * Dolphin Peripherals 4014 (dual parallel port) card. PLX 9050, with
168 * a seemingly-lame EEPROM setup that puts the Dolphin IDs
169 * into the subsystem fields, and claims that it's a
170 * network/misc (0x02/0x80) device.
172 { 0x10b5, 0x9050, 0xd84d, 0x6810,
173 "Dolphin Peripherals 4014",
175 PUC_PORT_2P, 0x20, 4, 0,
178 { 0x10e8, 0x818e, 0xffff, 0,
179 "Applied Micro Circuits 8 Port UART",
181 PUC_PORT_8S, 0x14, -1, -1,
182 .config_function = puc_config_amc
186 * The following members of the Digi International Neo series are
187 * based on Exar PCI chips, f. e. the 8 port variants on XR17V258IV.
188 * Accordingly, the PCIe versions of these cards incorporate a PLX
192 { 0x114f, 0x00b0, 0xffff, 0,
193 "Digi Neo PCI 4 Port",
195 PUC_PORT_4S, 0x10, 0, -1,
196 .config_function = puc_config_exar
199 { 0x114f, 0x00b1, 0xffff, 0,
200 "Digi Neo PCI 8 Port",
202 PUC_PORT_8S, 0x10, 0, -1,
203 .config_function = puc_config_exar
206 { 0x114f, 0x00f0, 0xffff, 0,
207 "Digi Neo PCIe 8 Port",
209 PUC_PORT_8S, 0x10, 0, -1,
210 .config_function = puc_config_exar
213 { 0x114f, 0x00f1, 0xffff, 0,
214 "Digi Neo PCIe 4 Port",
216 PUC_PORT_4S, 0x10, 0, -1,
217 .config_function = puc_config_exar
220 { 0x114f, 0x00f2, 0xffff, 0,
221 "Digi Neo PCIe 4 Port RJ45",
223 PUC_PORT_4S, 0x10, 0, -1,
224 .config_function = puc_config_exar
227 { 0x114f, 0x00f3, 0xffff, 0,
228 "Digi Neo PCIe 8 Port RJ45",
230 PUC_PORT_8S, 0x10, 0, -1,
231 .config_function = puc_config_exar
234 { 0x11fe, 0x8010, 0xffff, 0,
235 "Comtrol RocketPort 550/8 RJ11 part A",
237 PUC_PORT_4S, 0x10, 0, 8,
240 { 0x11fe, 0x8011, 0xffff, 0,
241 "Comtrol RocketPort 550/8 RJ11 part B",
243 PUC_PORT_4S, 0x10, 0, 8,
246 { 0x11fe, 0x8012, 0xffff, 0,
247 "Comtrol RocketPort 550/8 Octa part A",
249 PUC_PORT_4S, 0x10, 0, 8,
252 { 0x11fe, 0x8013, 0xffff, 0,
253 "Comtrol RocketPort 550/8 Octa part B",
255 PUC_PORT_4S, 0x10, 0, 8,
258 { 0x11fe, 0x8014, 0xffff, 0,
259 "Comtrol RocketPort 550/4 RJ45",
261 PUC_PORT_4S, 0x10, 0, 8,
264 { 0x11fe, 0x8015, 0xffff, 0,
265 "Comtrol RocketPort 550/Quad",
267 PUC_PORT_4S, 0x10, 0, 8,
270 { 0x11fe, 0x8016, 0xffff, 0,
271 "Comtrol RocketPort 550/16 part A",
273 PUC_PORT_4S, 0x10, 0, 8,
276 { 0x11fe, 0x8017, 0xffff, 0,
277 "Comtrol RocketPort 550/16 part B",
279 PUC_PORT_12S, 0x10, 0, 8,
282 { 0x11fe, 0x8018, 0xffff, 0,
283 "Comtrol RocketPort 550/8 part A",
285 PUC_PORT_4S, 0x10, 0, 8,
288 { 0x11fe, 0x8019, 0xffff, 0,
289 "Comtrol RocketPort 550/8 part B",
291 PUC_PORT_4S, 0x10, 0, 8,
295 * IBM SurePOS 300 Series (481033H) serial ports
296 * Details can be found on the IBM RSS websites
299 { 0x1014, 0x0297, 0xffff, 0,
300 "IBM SurePOS 300 Series (481033H) serial ports",
302 PUC_PORT_4S, 0x10, 4, 0
308 * SIIG provides documentation for their boards at:
309 * <URL:http://www.siig.com/downloads.asp>
312 { 0x131f, 0x1010, 0xffff, 0,
313 "SIIG Cyber I/O PCI 16C550 (10x family)",
315 PUC_PORT_1S1P, 0x18, 4, 0,
318 { 0x131f, 0x1011, 0xffff, 0,
319 "SIIG Cyber I/O PCI 16C650 (10x family)",
321 PUC_PORT_1S1P, 0x18, 4, 0,
324 { 0x131f, 0x1012, 0xffff, 0,
325 "SIIG Cyber I/O PCI 16C850 (10x family)",
327 PUC_PORT_1S1P, 0x18, 4, 0,
330 { 0x131f, 0x1021, 0xffff, 0,
331 "SIIG Cyber Parallel Dual PCI (10x family)",
333 PUC_PORT_2P, 0x18, 8, 0,
336 { 0x131f, 0x1030, 0xffff, 0,
337 "SIIG Cyber Serial Dual PCI 16C550 (10x family)",
339 PUC_PORT_2S, 0x18, 4, 0,
342 { 0x131f, 0x1031, 0xffff, 0,
343 "SIIG Cyber Serial Dual PCI 16C650 (10x family)",
345 PUC_PORT_2S, 0x18, 4, 0,
348 { 0x131f, 0x1032, 0xffff, 0,
349 "SIIG Cyber Serial Dual PCI 16C850 (10x family)",
351 PUC_PORT_2S, 0x18, 4, 0,
354 { 0x131f, 0x1034, 0xffff, 0, /* XXX really? */
355 "SIIG Cyber 2S1P PCI 16C550 (10x family)",
357 PUC_PORT_2S1P, 0x18, 4, 0,
360 { 0x131f, 0x1035, 0xffff, 0, /* XXX really? */
361 "SIIG Cyber 2S1P PCI 16C650 (10x family)",
363 PUC_PORT_2S1P, 0x18, 4, 0,
366 { 0x131f, 0x1036, 0xffff, 0, /* XXX really? */
367 "SIIG Cyber 2S1P PCI 16C850 (10x family)",
369 PUC_PORT_2S1P, 0x18, 4, 0,
372 { 0x131f, 0x1050, 0xffff, 0,
373 "SIIG Cyber 4S PCI 16C550 (10x family)",
375 PUC_PORT_4S, 0x18, 4, 0,
378 { 0x131f, 0x1051, 0xffff, 0,
379 "SIIG Cyber 4S PCI 16C650 (10x family)",
381 PUC_PORT_4S, 0x18, 4, 0,
384 { 0x131f, 0x1052, 0xffff, 0,
385 "SIIG Cyber 4S PCI 16C850 (10x family)",
387 PUC_PORT_4S, 0x18, 4, 0,
390 { 0x131f, 0x2010, 0xffff, 0,
391 "SIIG Cyber I/O PCI 16C550 (20x family)",
393 PUC_PORT_1S1P, 0x10, 4, 0,
396 { 0x131f, 0x2011, 0xffff, 0,
397 "SIIG Cyber I/O PCI 16C650 (20x family)",
399 PUC_PORT_1S1P, 0x10, 4, 0,
402 { 0x131f, 0x2012, 0xffff, 0,
403 "SIIG Cyber I/O PCI 16C850 (20x family)",
405 PUC_PORT_1S1P, 0x10, 4, 0,
408 { 0x131f, 0x2021, 0xffff, 0,
409 "SIIG Cyber Parallel Dual PCI (20x family)",
411 PUC_PORT_2P, 0x10, 8, 0,
414 { 0x131f, 0x2030, 0xffff, 0,
415 "SIIG Cyber Serial Dual PCI 16C550 (20x family)",
417 PUC_PORT_2S, 0x10, 4, 0,
420 { 0x131f, 0x2031, 0xffff, 0,
421 "SIIG Cyber Serial Dual PCI 16C650 (20x family)",
423 PUC_PORT_2S, 0x10, 4, 0,
426 { 0x131f, 0x2032, 0xffff, 0,
427 "SIIG Cyber Serial Dual PCI 16C850 (20x family)",
429 PUC_PORT_2S, 0x10, 4, 0,
432 { 0x131f, 0x2040, 0xffff, 0,
433 "SIIG Cyber 2P1S PCI 16C550 (20x family)",
435 PUC_PORT_1S2P, 0x10, -1, 0,
436 .config_function = puc_config_siig
439 { 0x131f, 0x2041, 0xffff, 0,
440 "SIIG Cyber 2P1S PCI 16C650 (20x family)",
442 PUC_PORT_1S2P, 0x10, -1, 0,
443 .config_function = puc_config_siig
446 { 0x131f, 0x2042, 0xffff, 0,
447 "SIIG Cyber 2P1S PCI 16C850 (20x family)",
449 PUC_PORT_1S2P, 0x10, -1, 0,
450 .config_function = puc_config_siig
453 { 0x131f, 0x2050, 0xffff, 0,
454 "SIIG Cyber 4S PCI 16C550 (20x family)",
456 PUC_PORT_4S, 0x10, 4, 0,
459 { 0x131f, 0x2051, 0xffff, 0,
460 "SIIG Cyber 4S PCI 16C650 (20x family)",
462 PUC_PORT_4S, 0x10, 4, 0,
465 { 0x131f, 0x2052, 0xffff, 0,
466 "SIIG Cyber 4S PCI 16C850 (20x family)",
468 PUC_PORT_4S, 0x10, 4, 0,
471 { 0x131f, 0x2060, 0xffff, 0,
472 "SIIG Cyber 2S1P PCI 16C550 (20x family)",
474 PUC_PORT_2S1P, 0x10, 4, 0,
477 { 0x131f, 0x2061, 0xffff, 0,
478 "SIIG Cyber 2S1P PCI 16C650 (20x family)",
480 PUC_PORT_2S1P, 0x10, 4, 0,
483 { 0x131f, 0x2062, 0xffff, 0,
484 "SIIG Cyber 2S1P PCI 16C850 (20x family)",
486 PUC_PORT_2S1P, 0x10, 4, 0,
489 { 0x131f, 0x2081, 0xffff, 0,
490 "SIIG PS8000 8S PCI 16C650 (20x family)",
492 PUC_PORT_8S, 0x10, -1, -1,
493 .config_function = puc_config_siig
496 { 0x135c, 0x0010, 0xffff, 0,
498 -3, /* max 8x clock rate */
499 PUC_PORT_4S, 0x14, 0, 8,
500 .config_function = puc_config_quatech
503 { 0x135c, 0x0020, 0xffff, 0,
505 -1, /* max 2x clock rate */
506 PUC_PORT_2S, 0x14, 0, 8,
507 .config_function = puc_config_quatech
510 { 0x135c, 0x0030, 0xffff, 0,
511 "Quatech DSC-200/300",
512 -1, /* max 2x clock rate */
513 PUC_PORT_2S, 0x14, 0, 8,
514 .config_function = puc_config_quatech
517 { 0x135c, 0x0040, 0xffff, 0,
518 "Quatech QSC-200/300",
519 -3, /* max 8x clock rate */
520 PUC_PORT_4S, 0x14, 0, 8,
521 .config_function = puc_config_quatech
524 { 0x135c, 0x0050, 0xffff, 0,
526 -3, /* max 8x clock rate */
527 PUC_PORT_8S, 0x14, 0, 8,
528 .config_function = puc_config_quatech
531 { 0x135c, 0x0060, 0xffff, 0,
533 -3, /* max 8x clock rate */
534 PUC_PORT_8S, 0x14, 0, 8,
535 .config_function = puc_config_quatech
538 { 0x135c, 0x0170, 0xffff, 0,
540 -1, /* max 2x clock rate */
541 PUC_PORT_4S, 0x18, 0, 8,
542 .config_function = puc_config_quatech
545 { 0x135c, 0x0180, 0xffff, 0,
547 -1, /* max 3x clock rate */
548 PUC_PORT_2S, 0x18, 0, 8,
549 .config_function = puc_config_quatech
552 { 0x135c, 0x01b0, 0xffff, 0,
553 "Quatech DSCLP-200/300",
554 -1, /* max 2x clock rate */
555 PUC_PORT_2S, 0x18, 0, 8,
556 .config_function = puc_config_quatech
559 { 0x135c, 0x01e0, 0xffff, 0,
561 -3, /* max 8x clock rate */
562 PUC_PORT_8S, 0x10, 0, 8,
563 .config_function = puc_config_quatech
566 { 0x1393, 0x1024, 0xffff, 0,
567 "Moxa Technologies, Smartio CP-102E/PCIe",
569 PUC_PORT_2S, 0x14, 0, -1,
570 .config_function = puc_config_moxa
573 { 0x1393, 0x1025, 0xffff, 0,
574 "Moxa Technologies, Smartio CP-102EL/PCIe",
576 PUC_PORT_2S, 0x14, 0, -1,
577 .config_function = puc_config_moxa
580 { 0x1393, 0x1040, 0xffff, 0,
581 "Moxa Technologies, Smartio C104H/PCI",
583 PUC_PORT_4S, 0x18, 0, 8,
586 { 0x1393, 0x1041, 0xffff, 0,
587 "Moxa Technologies, Smartio CP-104UL/PCI",
589 PUC_PORT_4S, 0x18, 0, 8,
592 { 0x1393, 0x1042, 0xffff, 0,
593 "Moxa Technologies, Smartio CP-104JU/PCI",
595 PUC_PORT_4S, 0x18, 0, 8,
598 { 0x1393, 0x1043, 0xffff, 0,
599 "Moxa Technologies, Smartio CP-104EL/PCIe",
601 PUC_PORT_4S, 0x18, 0, 8,
604 { 0x1393, 0x1045, 0xffff, 0,
605 "Moxa Technologies, Smartio CP-104EL-A/PCIe",
607 PUC_PORT_4S, 0x14, 0, -1,
608 .config_function = puc_config_moxa
611 { 0x1393, 0x1120, 0xffff, 0,
612 "Moxa Technologies, CP-112UL",
614 PUC_PORT_2S, 0x18, 0, 8,
617 { 0x1393, 0x1141, 0xffff, 0,
618 "Moxa Technologies, Industio CP-114",
620 PUC_PORT_4S, 0x18, 0, 8,
623 { 0x1393, 0x1144, 0xffff, 0,
624 "Moxa Technologies, Smartio CP-114EL/PCIe",
626 PUC_PORT_4S, 0x14, 0, -1,
627 .config_function = puc_config_moxa
630 { 0x1393, 0x1182, 0xffff, 0,
631 "Moxa Technologies, Smartio CP-118EL-A/PCIe",
633 PUC_PORT_8S, 0x14, 0, -1,
634 .config_function = puc_config_moxa
637 { 0x1393, 0x1680, 0xffff, 0,
638 "Moxa Technologies, C168H/PCI",
640 PUC_PORT_8S, 0x18, 0, 8,
643 { 0x1393, 0x1681, 0xffff, 0,
644 "Moxa Technologies, C168U/PCI",
646 PUC_PORT_8S, 0x18, 0, 8,
649 { 0x1393, 0x1682, 0xffff, 0,
650 "Moxa Technologies, CP-168EL/PCIe",
652 PUC_PORT_8S, 0x18, 0, 8,
655 { 0x1393, 0x1683, 0xffff, 0,
656 "Moxa Technologies, Smartio CP-168EL-A/PCIe",
658 PUC_PORT_8S, 0x14, 0, -1,
659 .config_function = puc_config_moxa
662 { 0x13a8, 0x0152, 0xffff, 0,
665 PUC_PORT_2S, 0x10, 0, -1,
666 .config_function = puc_config_exar
669 { 0x13a8, 0x0154, 0xffff, 0,
672 PUC_PORT_4S, 0x10, 0, -1,
673 .config_function = puc_config_exar
676 { 0x13a8, 0x0158, 0xffff, 0,
679 PUC_PORT_8S, 0x10, 0, -1,
680 .config_function = puc_config_exar
683 { 0x13a8, 0x0258, 0xffff, 0,
686 PUC_PORT_8S, 0x10, 0, -1,
687 .config_function = puc_config_exar
690 /* The XR17V358 uses the 125MHz PCIe clock as its reference clock. */
691 { 0x13a8, 0x0358, 0xffff, 0,
694 PUC_PORT_8S, 0x10, 0, -1,
695 .config_function = puc_config_exar_pcie
699 * The Advantech PCI-1602 Rev. A use the first two ports of an Oxford
700 * Semiconductor OXuPCI954. Note these boards have a hardware bug in
701 * that they drive the RS-422/485 transmitters after power-on until a
702 * driver initalizes the UARTs.
704 { 0x13fe, 0x1600, 0x1602, 0x0002,
705 "Advantech PCI-1602 Rev. A",
707 PUC_PORT_2S, 0x10, 0, 8,
708 .config_function = puc_config_advantech
711 /* Advantech PCI-1602 Rev. B1/PCI-1603 are also based on OXuPCI952. */
712 { 0x13fe, 0xa102, 0x13fe, 0xa102,
713 "Advantech 2-port PCI (PCI-1602 Rev. B1/PCI-1603)",
715 PUC_PORT_2S, 0x10, 4, 0,
716 .config_function = puc_config_advantech
719 { 0x1407, 0x0100, 0xffff, 0,
720 "Lava Computers Dual Serial",
722 PUC_PORT_2S, 0x10, 4, 0,
725 { 0x1407, 0x0101, 0xffff, 0,
726 "Lava Computers Quatro A",
728 PUC_PORT_2S, 0x10, 4, 0,
731 { 0x1407, 0x0102, 0xffff, 0,
732 "Lava Computers Quatro B",
734 PUC_PORT_2S, 0x10, 4, 0,
737 { 0x1407, 0x0120, 0xffff, 0,
738 "Lava Computers Quattro-PCI A",
740 PUC_PORT_2S, 0x10, 4, 0,
743 { 0x1407, 0x0121, 0xffff, 0,
744 "Lava Computers Quattro-PCI B",
746 PUC_PORT_2S, 0x10, 4, 0,
749 { 0x1407, 0x0180, 0xffff, 0,
750 "Lava Computers Octo A",
752 PUC_PORT_4S, 0x10, 4, 0,
755 { 0x1407, 0x0181, 0xffff, 0,
756 "Lava Computers Octo B",
758 PUC_PORT_4S, 0x10, 4, 0,
761 { 0x1409, 0x7268, 0xffff, 0,
764 PUC_PORT_2P, 0x10, 0, 8,
767 { 0x1409, 0x7168, 0xffff, 0,
770 PUC_PORT_NONSTANDARD, 0x10, -1, -1,
771 .config_function = puc_config_timedia
775 * Boards with an Oxford Semiconductor chip.
777 * Oxford Semiconductor provides documentation for their chip at:
778 * <URL:http://www.plxtech.com/products/uart/>
780 * As sold by Kouwell <URL:http://www.kouwell.com/>.
781 * I/O Flex PCI I/O Card Model-223 with 4 serial and 1 parallel ports.
784 0x1415, 0x9501, 0x10fc, 0xc070,
785 "I-O DATA RSA-PCI2/R",
787 PUC_PORT_2S, 0x10, 0, 8,
790 { 0x1415, 0x9501, 0x131f, 0x2050,
791 "SIIG Cyber 4 PCI 16550",
793 PUC_PORT_4S, 0x10, 0, 8,
796 { 0x1415, 0x9501, 0x131f, 0x2051,
797 "SIIG Cyber 4S PCI 16C650 (20x family)",
799 PUC_PORT_4S, 0x10, 0, 8,
802 { 0x1415, 0x9501, 0x131f, 0x2052,
803 "SIIG Quartet Serial 850",
805 PUC_PORT_4S, 0x10, 0, 8,
808 { 0x1415, 0x9501, 0x14db, 0x2150,
809 "Kuroutoshikou SERIAL4P-LPPCI2",
811 PUC_PORT_4S, 0x10, 0, 8,
814 { 0x1415, 0x9501, 0xffff, 0,
815 "Oxford Semiconductor OX16PCI954 UARTs",
817 PUC_PORT_4S, 0x10, 0, 8,
818 .config_function = puc_config_oxford_pci954
821 { 0x1415, 0x950a, 0x131f, 0x2030,
822 "SIIG Cyber 2S PCIe",
824 PUC_PORT_2S, 0x10, 0, 8,
827 { 0x1415, 0x950a, 0x131f, 0x2032,
828 "SIIG Cyber Serial Dual PCI 16C850",
830 PUC_PORT_4S, 0x10, 0, 8,
833 { 0x1415, 0x950a, 0x131f, 0x2061,
834 "SIIG Cyber 2SP1 PCIe",
836 PUC_PORT_2S, 0x10, 0, 8,
839 { 0x1415, 0x950a, 0xffff, 0,
840 "Oxford Semiconductor OX16PCI954 UARTs",
842 PUC_PORT_4S, 0x10, 0, 8,
845 { 0x1415, 0x9511, 0xffff, 0,
846 "Oxford Semiconductor OX9160/OX16PCI954 UARTs (function 1)",
848 PUC_PORT_4S, 0x10, 0, 8,
851 { 0x1415, 0x9521, 0xffff, 0,
852 "Oxford Semiconductor OX16PCI952 UARTs",
854 PUC_PORT_2S, 0x10, 4, 0,
857 { 0x1415, 0x9538, 0xffff, 0,
858 "Oxford Semiconductor OX16PCI958 UARTs",
860 PUC_PORT_8S, 0x18, 0, 8,
864 * Perle boards use Oxford Semiconductor chips, but they store the
865 * Oxford Semiconductor device ID as a subvendor device ID and use
866 * their own device IDs.
869 { 0x155f, 0x0331, 0xffff, 0,
870 "Perle Ultraport4 Express",
872 PUC_PORT_4S, 0x10, 0, 8,
875 { 0x155f, 0xB012, 0xffff, 0,
878 PUC_PORT_2S, 0x10, 0, 8,
881 { 0x155f, 0xB022, 0xffff, 0,
884 PUC_PORT_2S, 0x10, 0, 8,
887 { 0x155f, 0xB004, 0xffff, 0,
890 PUC_PORT_4S, 0x10, 0, 8,
893 { 0x155f, 0xB008, 0xffff, 0,
896 PUC_PORT_8S, 0x10, 0, 8,
901 * Oxford Semiconductor PCI Express Expresso family
903 * Found in many 'native' PCI Express serial boards such as:
905 * eMegatech MP954ER4 (4 port) and MP958ER8 (8 port)
906 * <URL:http://www.emegatech.com.tw/pdrs232pcie.html>
908 * Lindy 51189 (4 port)
909 * <URL:http://www.lindy.com> <URL:http://tinyurl.com/lindy-51189>
911 * StarTech.com PEX4S952 (4 port) and PEX8S952 (8 port)
912 * <URL:http://www.startech.com>
915 { 0x1415, 0xc11b, 0xffff, 0,
916 "Oxford Semiconductor OXPCIe952 1S1P",
918 PUC_PORT_NONSTANDARD, 0x10, 0, -1,
919 .config_function = puc_config_oxford_pcie
922 { 0x1415, 0xc138, 0xffff, 0,
923 "Oxford Semiconductor OXPCIe952 UARTs",
925 PUC_PORT_NONSTANDARD, 0x10, 0, -1,
926 .config_function = puc_config_oxford_pcie
929 { 0x1415, 0xc158, 0xffff, 0,
930 "Oxford Semiconductor OXPCIe952 UARTs",
932 PUC_PORT_NONSTANDARD, 0x10, 0, -1,
933 .config_function = puc_config_oxford_pcie
936 { 0x1415, 0xc15d, 0xffff, 0,
937 "Oxford Semiconductor OXPCIe952 UARTs (function 1)",
939 PUC_PORT_NONSTANDARD, 0x10, 0, -1,
940 .config_function = puc_config_oxford_pcie
943 { 0x1415, 0xc208, 0xffff, 0,
944 "Oxford Semiconductor OXPCIe954 UARTs",
946 PUC_PORT_NONSTANDARD, 0x10, 0, -1,
947 .config_function = puc_config_oxford_pcie
950 { 0x1415, 0xc20d, 0xffff, 0,
951 "Oxford Semiconductor OXPCIe954 UARTs (function 1)",
953 PUC_PORT_NONSTANDARD, 0x10, 0, -1,
954 .config_function = puc_config_oxford_pcie
957 { 0x1415, 0xc308, 0xffff, 0,
958 "Oxford Semiconductor OXPCIe958 UARTs",
960 PUC_PORT_NONSTANDARD, 0x10, 0, -1,
961 .config_function = puc_config_oxford_pcie
964 { 0x1415, 0xc30d, 0xffff, 0,
965 "Oxford Semiconductor OXPCIe958 UARTs (function 1)",
967 PUC_PORT_NONSTANDARD, 0x10, 0, -1,
968 .config_function = puc_config_oxford_pcie
971 { 0x14d2, 0x8010, 0xffff, 0,
974 PUC_PORT_1S, 0x14, 0, 0,
977 { 0x14d2, 0x8020, 0xffff, 0,
980 PUC_PORT_2S, 0x14, 4, 0,
983 { 0x14d2, 0x8028, 0xffff, 0,
986 PUC_PORT_2S, 0x20, 0, 8,
990 * VScom (Titan?) PCI-800L. More modern variant of the
991 * PCI-800. Uses 6 discrete 16550 UARTs, plus another
992 * two of them obviously implemented as macro cells in
993 * the ASIC. This causes the weird port access pattern
994 * below, where two of the IO port ranges each access
995 * one of the ASIC UARTs, and a block of IO addresses
996 * access the external UARTs.
998 { 0x14d2, 0x8080, 0xffff, 0,
999 "Titan VScom PCI-800L",
1001 PUC_PORT_8S, 0x14, -1, -1,
1002 .config_function = puc_config_titan
1006 * VScom PCI-800H. Uses 8 16950 UART, behind a PCI chips that offers
1007 * 4 com port on PCI device 0 and 4 on PCI device 1. PCI device 0 has
1008 * device ID 3 and PCI device 1 device ID 4.
1010 { 0x14d2, 0xa003, 0xffff, 0,
1013 PUC_PORT_4S, 0x10, 0, 8,
1016 { 0x14d2, 0xa004, 0xffff, 0,
1019 PUC_PORT_4S, 0x10, 0, 8,
1022 { 0x14d2, 0xa005, 0xffff, 0,
1025 PUC_PORT_2S, 0x10, 0, 8,
1028 { 0x14d2, 0xe020, 0xffff, 0,
1029 "Titan VScom PCI-200HV2",
1031 PUC_PORT_2S, 0x10, 4, 0,
1034 { 0x14d2, 0xa007, 0xffff, 0,
1035 "Titan VScom PCIex-800H",
1037 PUC_PORT_4S, 0x10, 0, 8,
1040 { 0x14d2, 0xa008, 0xffff, 0,
1041 "Titan VScom PCIex-800H",
1043 PUC_PORT_4S, 0x10, 0, 8,
1046 { 0x14db, 0x2130, 0xffff, 0,
1047 "Avlab Technology, PCI IO 2S",
1049 PUC_PORT_2S, 0x10, 4, 0,
1052 { 0x14db, 0x2150, 0xffff, 0,
1053 "Avlab Low Profile PCI 4 Serial",
1055 PUC_PORT_4S, 0x10, 4, 0,
1058 { 0x14db, 0x2152, 0xffff, 0,
1059 "Avlab Low Profile PCI 4 Serial",
1061 PUC_PORT_4S, 0x10, 4, 0,
1064 { 0x1592, 0x0781, 0xffff, 0,
1065 "Syba Tech Ltd. PCI-4S2P-550-ECP",
1067 PUC_PORT_4S1P, 0x10, 0, -1,
1068 .config_function = puc_config_syba
1071 { 0x1fd4, 0x1999, 0x1fd4, 0x0002,
1072 "Sunix SER5xxxx 2-port serial",
1074 PUC_PORT_2S, 0x10, 0, 8,
1077 { 0x1fd4, 0x1999, 0x1fd4, 0x0004,
1078 "Sunix SER5xxxx 4-port serial",
1080 PUC_PORT_4S, 0x10, 0, 8,
1083 { 0x1fd4, 0x1999, 0x1fd4, 0x0008,
1084 "Sunix SER5xxxx 8-port serial",
1086 PUC_PORT_8S, -1, -1, -1,
1087 .config_function = puc_config_sunix
1090 { 0x1fd4, 0x1999, 0x1fd4, 0x0101,
1091 "Sunix MIO5xxxx 1-port serial and 1284 Printer port",
1093 PUC_PORT_1S1P, -1, -1, -1,
1094 .config_function = puc_config_sunix
1097 { 0x1fd4, 0x1999, 0x1fd4, 0x0102,
1098 "Sunix MIO5xxxx 2-port serial and 1284 Printer port",
1100 PUC_PORT_2S1P, -1, -1, -1,
1101 .config_function = puc_config_sunix
1104 { 0x1fd4, 0x1999, 0x1fd4, 0x0104,
1105 "Sunix MIO5xxxx 4-port serial and 1284 Printer port",
1107 PUC_PORT_4S1P, -1, -1, -1,
1108 .config_function = puc_config_sunix
1111 { 0x5372, 0x6872, 0xffff, 0,
1112 "Feasso PCI FPP-02 2S1P",
1114 PUC_PORT_2S1P, 0x10, 4, 0,
1117 { 0x5372, 0x6873, 0xffff, 0,
1118 "Sun 1040 PCI Quad Serial",
1120 PUC_PORT_4S, 0x10, 4, 0,
1123 { 0x6666, 0x0001, 0xffff, 0,
1124 "Decision Computer Inc, PCCOM 4-port serial",
1126 PUC_PORT_4S, 0x1c, 0, 8,
1129 { 0x6666, 0x0002, 0xffff, 0,
1130 "Decision Computer Inc, PCCOM 8-port serial",
1132 PUC_PORT_8S, 0x1c, 0, 8,
1135 { 0x6666, 0x0004, 0xffff, 0,
1136 "PCCOM dual port RS232/422/485",
1138 PUC_PORT_2S, 0x1c, 0, 8,
1141 { 0x9710, 0x9815, 0xffff, 0,
1142 "NetMos NM9815 Dual 1284 Printer port",
1144 PUC_PORT_2P, 0x10, 8, 0,
1148 * This is more specific than the generic NM9835 entry, and is placed
1149 * here to _prevent_ puc(4) from claiming this single port card.
1151 * uart(4) will claim this device.
1153 { 0x9710, 0x9835, 0x1000, 1,
1154 "NetMos NM9835 based 1-port serial",
1156 PUC_PORT_1S, 0x10, 4, 0,
1159 { 0x9710, 0x9835, 0x1000, 2,
1160 "NetMos NM9835 based 2-port serial",
1162 PUC_PORT_2S, 0x10, 4, 0,
1165 { 0x9710, 0x9835, 0xffff, 0,
1166 "NetMos NM9835 Dual UART and 1284 Printer port",
1168 PUC_PORT_2S1P, 0x10, 4, 0,
1171 { 0x9710, 0x9845, 0x1000, 0x0006,
1172 "NetMos NM9845 6 Port UART",
1174 PUC_PORT_6S, 0x10, 4, 0,
1177 { 0x9710, 0x9845, 0xffff, 0,
1178 "NetMos NM9845 Quad UART and 1284 Printer port",
1180 PUC_PORT_4S1P, 0x10, 4, 0,
1183 { 0x9710, 0x9865, 0xa000, 0x3002,
1184 "NetMos NM9865 Dual UART",
1186 PUC_PORT_2S, 0x10, 4, 0,
1189 { 0x9710, 0x9865, 0xa000, 0x3003,
1190 "NetMos NM9865 Triple UART",
1192 PUC_PORT_3S, 0x10, 4, 0,
1195 { 0x9710, 0x9865, 0xa000, 0x3004,
1196 "NetMos NM9865 Quad UART",
1198 PUC_PORT_4S, 0x10, 4, 0,
1201 { 0x9710, 0x9865, 0xa000, 0x3011,
1202 "NetMos NM9865 Single UART and 1284 Printer port",
1204 PUC_PORT_1S1P, 0x10, 4, 0,
1207 { 0x9710, 0x9865, 0xa000, 0x3012,
1208 "NetMos NM9865 Dual UART and 1284 Printer port",
1210 PUC_PORT_2S1P, 0x10, 4, 0,
1213 { 0x9710, 0x9865, 0xa000, 0x3020,
1214 "NetMos NM9865 Dual 1284 Printer port",
1216 PUC_PORT_2P, 0x10, 4, 0,
1219 { 0xb00c, 0x021c, 0xffff, 0,
1220 "IC Book Labs Gunboat x4 Lite",
1222 PUC_PORT_4S, 0x10, 0, 8,
1223 .config_function = puc_config_icbook
1226 { 0xb00c, 0x031c, 0xffff, 0,
1227 "IC Book Labs Gunboat x4 Pro",
1229 PUC_PORT_4S, 0x10, 0, 8,
1230 .config_function = puc_config_icbook
1233 { 0xb00c, 0x041c, 0xffff, 0,
1234 "IC Book Labs Ironclad x8 Lite",
1236 PUC_PORT_8S, 0x10, 0, 8,
1237 .config_function = puc_config_icbook
1240 { 0xb00c, 0x051c, 0xffff, 0,
1241 "IC Book Labs Ironclad x8 Pro",
1243 PUC_PORT_8S, 0x10, 0, 8,
1244 .config_function = puc_config_icbook
1247 { 0xb00c, 0x081c, 0xffff, 0,
1248 "IC Book Labs Dreadnought x16 Pro",
1250 PUC_PORT_16S, 0x10, 0, 8,
1251 .config_function = puc_config_icbook
1254 { 0xb00c, 0x091c, 0xffff, 0,
1255 "IC Book Labs Dreadnought x16 Lite",
1257 PUC_PORT_16S, 0x10, 0, 8,
1258 .config_function = puc_config_icbook
1261 { 0xb00c, 0x0a1c, 0xffff, 0,
1262 "IC Book Labs Gunboat x2 Low Profile",
1264 PUC_PORT_2S, 0x10, 0, 8,
1267 { 0xb00c, 0x0b1c, 0xffff, 0,
1268 "IC Book Labs Gunboat x4 Low Profile",
1270 PUC_PORT_4S, 0x10, 0, 8,
1271 .config_function = puc_config_icbook
1274 { 0xffff, 0, 0xffff, 0, NULL, 0 }
1278 puc_config_advantech(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
1279 intptr_t *res __unused)
1281 const struct puc_cfg *cfg;
1282 struct resource *cres;
1283 struct puc_bar *bar;
1286 int base, crtype, fixed, high, i, oxpcie;
1287 uint8_t acr, func, mask;
1289 if (cmd != PUC_CFG_SETUP)
1292 base = fixed = oxpcie = 0;
1293 crtype = SYS_RES_IOPORT;
1299 switch (cfg->subvendor) {
1301 switch (cfg->device) {
1315 cdev = pci_find_dbsf(pci_get_domain(dev), pci_get_bus(dev),
1316 pci_get_slot(dev), func);
1318 device_printf(dev, "could not find config function\n");
1323 cres = bus_alloc_resource_any(cdev, crtype, &i, RF_ACTIVE);
1325 device_printf(dev, "could not allocate config resource\n");
1330 mask = bus_read_1(cres, off);
1331 if (pci_get_function(dev) == 1)
1336 for (i = 0; i < sc->sc_nports; ++i) {
1337 device_printf(dev, "port %d: ", i);
1338 bar = puc_get_bar(sc, cfg->rid + i * cfg->d_rid);
1340 printf("could not get BAR\n");
1345 if ((mask & (1 << (base + i))) == 0) {
1349 acr = (high == 1 ? 0x18 : 0x10);
1350 printf("RS-422/RS-485, active-%s auto-DTR\n",
1351 high == 1 ? "high" : "low");
1355 bus_write_1(bar->b_res, REG_SPR, REG_ACR);
1356 bus_write_1(bar->b_res, REG_ICR, acr);
1359 bus_release_resource(cdev, crtype, rman_get_rid(cres), cres);
1364 puc_config_amc(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd, int port,
1369 case PUC_CFG_GET_OFS:
1370 *res = 8 * (port & 1);
1372 case PUC_CFG_GET_RID:
1373 *res = 0x14 + (port >> 1) * 4;
1382 puc_config_diva(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
1385 const struct puc_cfg *cfg = sc->sc_cfg;
1387 if (cmd == PUC_CFG_GET_OFS) {
1388 if (cfg->subdevice == 0x1282) /* Everest SP */
1390 else if (cfg->subdevice == 0x104b) /* Maestro SP2 */
1391 port = (port == 3) ? 4 : port;
1392 *res = port * 8 + ((port > 2) ? 0x18 : 0);
1399 puc_config_exar(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd,
1400 int port, intptr_t *res)
1403 if (cmd == PUC_CFG_GET_OFS) {
1404 *res = port * 0x200;
1411 puc_config_exar_pcie(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd,
1412 int port, intptr_t *res)
1415 if (cmd == PUC_CFG_GET_OFS) {
1416 *res = port * 0x400;
1423 puc_config_icbook(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd,
1424 int port __unused, intptr_t *res)
1427 if (cmd == PUC_CFG_GET_ILR) {
1428 *res = PUC_ILR_DIGI;
1435 puc_config_moxa(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
1438 const struct puc_cfg *cfg = sc->sc_cfg;
1440 if (cmd == PUC_CFG_GET_OFS) {
1441 if (port == 3 && (cfg->device == 0x1045 ||
1442 cfg->device == 0x1144))
1444 *res = port * 0x200;
1452 puc_config_quatech(struct puc_softc *sc, enum puc_cfg_cmd cmd,
1453 int port __unused, intptr_t *res)
1455 const struct puc_cfg *cfg = sc->sc_cfg;
1456 struct puc_bar *bar;
1462 * Check if the scratchpad register is enabled or if the
1463 * interrupt status and options registers are active.
1465 bar = puc_get_bar(sc, cfg->rid);
1468 bus_write_1(bar->b_res, REG_LCR, LCR_DLAB);
1469 bus_write_1(bar->b_res, REG_SPR, 0);
1470 v0 = bus_read_1(bar->b_res, REG_SPR);
1471 bus_write_1(bar->b_res, REG_SPR, 0x80 + -cfg->clock);
1472 v1 = bus_read_1(bar->b_res, REG_SPR);
1473 bus_write_1(bar->b_res, REG_LCR, 0);
1474 sc->sc_cfg_data = (v0 << 8) | v1;
1475 if (v0 == 0 && v1 == 0x80 + -cfg->clock) {
1477 * The SPR register echoed the two values written
1478 * by us. This means that the SPAD jumper is set.
1480 device_printf(sc->sc_dev, "warning: extra features "
1481 "not usable -- SPAD compatibility enabled\n");
1486 * The first value doesn't match. This can only mean
1487 * that the SPAD jumper is not set and that a non-
1488 * standard fixed clock multiplier jumper is set.
1491 device_printf(sc->sc_dev, "fixed clock rate "
1492 "multiplier of %d\n", 1 << v0);
1493 if (v0 < -cfg->clock)
1494 device_printf(sc->sc_dev, "warning: "
1495 "suboptimal fixed clock rate multiplier "
1500 * The first value matched, but the second didn't. We know
1501 * that the SPAD jumper is not set. We also know that the
1502 * clock rate multiplier is software controlled *and* that
1503 * we just programmed it to the maximum allowed.
1506 device_printf(sc->sc_dev, "clock rate multiplier of "
1507 "%d selected\n", 1 << -cfg->clock);
1509 case PUC_CFG_GET_CLOCK:
1510 v0 = (sc->sc_cfg_data >> 8) & 0xff;
1511 v1 = sc->sc_cfg_data & 0xff;
1512 if (v0 == 0 && v1 == 0x80 + -cfg->clock) {
1514 * XXX With the SPAD jumper applied, there's no
1515 * easy way of knowing if there's also a clock
1516 * rate multiplier jumper installed. Let's hope
1519 *res = DEFAULT_RCLK;
1520 } else if (v0 == 0) {
1522 * No clock rate multiplier jumper installed,
1523 * so we programmed the board with the maximum
1524 * multiplier allowed as given to us in the
1525 * clock field of the config record (negated).
1527 *res = DEFAULT_RCLK << -cfg->clock;
1529 *res = DEFAULT_RCLK << v0;
1531 case PUC_CFG_GET_ILR:
1532 v0 = (sc->sc_cfg_data >> 8) & 0xff;
1533 v1 = sc->sc_cfg_data & 0xff;
1534 *res = (v0 == 0 && v1 == 0x80 + -cfg->clock) ?
1535 PUC_ILR_NONE : PUC_ILR_QUATECH;
1544 puc_config_syba(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
1547 static int base[] = { 0x251, 0x3f0, 0 };
1548 const struct puc_cfg *cfg = sc->sc_cfg;
1549 struct puc_bar *bar;
1555 bar = puc_get_bar(sc, cfg->rid);
1559 /* configure both W83877TFs */
1560 bus_write_1(bar->b_res, 0x250, 0x89);
1561 bus_write_1(bar->b_res, 0x3f0, 0x87);
1562 bus_write_1(bar->b_res, 0x3f0, 0x87);
1564 while (base[idx] != 0) {
1566 bus_write_1(bar->b_res, efir, 0x09);
1567 v = bus_read_1(bar->b_res, efir + 1);
1568 if ((v & 0x0f) != 0x0c)
1570 bus_write_1(bar->b_res, efir, 0x16);
1571 v = bus_read_1(bar->b_res, efir + 1);
1572 bus_write_1(bar->b_res, efir, 0x16);
1573 bus_write_1(bar->b_res, efir + 1, v | 0x04);
1574 bus_write_1(bar->b_res, efir, 0x16);
1575 bus_write_1(bar->b_res, efir + 1, v & ~0x04);
1576 ofs = base[idx] & 0x300;
1577 bus_write_1(bar->b_res, efir, 0x23);
1578 bus_write_1(bar->b_res, efir + 1, (ofs + 0x78) >> 2);
1579 bus_write_1(bar->b_res, efir, 0x24);
1580 bus_write_1(bar->b_res, efir + 1, (ofs + 0xf8) >> 2);
1581 bus_write_1(bar->b_res, efir, 0x25);
1582 bus_write_1(bar->b_res, efir + 1, (ofs + 0xe8) >> 2);
1583 bus_write_1(bar->b_res, efir, 0x17);
1584 bus_write_1(bar->b_res, efir + 1, 0x03);
1585 bus_write_1(bar->b_res, efir, 0x28);
1586 bus_write_1(bar->b_res, efir + 1, 0x43);
1589 bus_write_1(bar->b_res, 0x250, 0xaa);
1590 bus_write_1(bar->b_res, 0x3f0, 0xaa);
1592 case PUC_CFG_GET_OFS:
1618 puc_config_siig(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
1621 const struct puc_cfg *cfg = sc->sc_cfg;
1624 case PUC_CFG_GET_OFS:
1625 if (cfg->ports == PUC_PORT_8S) {
1626 *res = (port > 4) ? 8 * (port - 4) : 0;
1630 case PUC_CFG_GET_RID:
1631 if (cfg->ports == PUC_PORT_8S) {
1632 *res = 0x10 + ((port > 4) ? 0x10 : 4 * port);
1635 if (cfg->ports == PUC_PORT_2S1P) {
1637 case 0: *res = 0x10; return (0);
1638 case 1: *res = 0x14; return (0);
1639 case 2: *res = 0x1c; return (0);
1650 puc_config_timedia(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
1653 static const uint16_t dual[] = {
1654 0x0002, 0x4036, 0x4037, 0x4038, 0x4078, 0x4079, 0x4085,
1655 0x4088, 0x4089, 0x5037, 0x5078, 0x5079, 0x5085, 0x6079,
1656 0x7079, 0x8079, 0x8137, 0x8138, 0x8237, 0x8238, 0x9079,
1657 0x9137, 0x9138, 0x9237, 0x9238, 0xA079, 0xB079, 0xC079,
1660 static const uint16_t quad[] = {
1661 0x4055, 0x4056, 0x4095, 0x4096, 0x5056, 0x8156, 0x8157,
1662 0x8256, 0x8257, 0x9056, 0x9156, 0x9157, 0x9158, 0x9159,
1663 0x9256, 0x9257, 0xA056, 0xA157, 0xA158, 0xA159, 0xB056,
1666 static const uint16_t octa[] = {
1667 0x4065, 0x4066, 0x5065, 0x5066, 0x8166, 0x9066, 0x9166,
1668 0x9167, 0x9168, 0xA066, 0xA167, 0xA168, 0
1670 static const struct {
1672 const uint16_t *ids;
1679 static char desc[64];
1684 case PUC_CFG_GET_CLOCK:
1686 *res = DEFAULT_RCLK * 8;
1688 *res = DEFAULT_RCLK;
1690 case PUC_CFG_GET_DESC:
1691 snprintf(desc, sizeof(desc),
1692 "Timedia technology %d Port Serial", (int)sc->sc_cfg_data);
1693 *res = (intptr_t)desc;
1695 case PUC_CFG_GET_NPORTS:
1696 subdev = pci_get_subdevice(sc->sc_dev);
1698 while (subdevs[dev].ports != 0) {
1700 while (subdevs[dev].ids[id] != 0) {
1701 if (subdev == subdevs[dev].ids[id]) {
1702 sc->sc_cfg_data = subdevs[dev].ports;
1703 *res = sc->sc_cfg_data;
1711 case PUC_CFG_GET_OFS:
1712 *res = (port == 1 || port == 3) ? 8 : 0;
1714 case PUC_CFG_GET_RID:
1715 *res = 0x10 + ((port > 3) ? port - 2 : port >> 1) * 4;
1717 case PUC_CFG_GET_TYPE:
1718 *res = PUC_TYPE_SERIAL;
1727 puc_config_oxford_pci954(struct puc_softc *sc, enum puc_cfg_cmd cmd,
1728 int port __unused, intptr_t *res)
1732 case PUC_CFG_GET_CLOCK:
1734 * OXu16PCI954 use a 14.7456 MHz clock by default while
1735 * OX16PCI954 and OXm16PCI954 employ a 1.8432 MHz one.
1737 if (pci_get_revid(sc->sc_dev) == 1)
1738 *res = DEFAULT_RCLK * 8;
1740 *res = DEFAULT_RCLK;
1749 puc_config_oxford_pcie(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
1752 const struct puc_cfg *cfg = sc->sc_cfg;
1754 struct puc_bar *bar;
1759 device_printf(sc->sc_dev, "%d UARTs detected\n",
1762 /* Set UARTs to enhanced mode */
1763 bar = puc_get_bar(sc, cfg->rid);
1766 for (idx = 0; idx < sc->sc_nports; idx++) {
1767 value = bus_read_1(bar->b_res, 0x1000 + (idx << 9) +
1769 bus_write_1(bar->b_res, 0x1000 + (idx << 9) + 0x92,
1773 case PUC_CFG_GET_LEN:
1776 case PUC_CFG_GET_NPORTS:
1778 * Check if we are being called from puc_bfe_attach()
1779 * or puc_bfe_probe(). If puc_bfe_probe(), we cannot
1780 * puc_get_bar(), so we return a value of 16. This has
1781 * cosmetic side-effects at worst; in PUC_CFG_GET_DESC,
1782 * sc->sc_cfg_data will not contain the true number of
1783 * ports in PUC_CFG_GET_DESC, but we are not implementing
1784 * that call for this device family anyway.
1786 * The check is for initialization of sc->sc_bar[idx],
1787 * which is only done in puc_bfe_attach().
1791 if (sc->sc_bar[idx++].b_rid != -1) {
1792 sc->sc_cfg_data = 16;
1793 *res = sc->sc_cfg_data;
1796 } while (idx < PUC_PCI_BARS);
1798 bar = puc_get_bar(sc, cfg->rid);
1802 value = bus_read_1(bar->b_res, 0x04);
1806 sc->sc_cfg_data = value;
1807 *res = sc->sc_cfg_data;
1809 case PUC_CFG_GET_OFS:
1810 *res = 0x1000 + (port << 9);
1812 case PUC_CFG_GET_TYPE:
1813 *res = PUC_TYPE_SERIAL;
1822 puc_config_sunix(struct puc_softc *sc, enum puc_cfg_cmd cmd, int port,
1828 case PUC_CFG_GET_OFS:
1829 error = puc_config(sc, PUC_CFG_GET_TYPE, port, res);
1832 *res = (*res == PUC_TYPE_SERIAL) ? (port & 3) * 8 : 0;
1834 case PUC_CFG_GET_RID:
1835 error = puc_config(sc, PUC_CFG_GET_TYPE, port, res);
1838 *res = (*res == PUC_TYPE_SERIAL && port <= 3) ? 0x10 : 0x14;
1847 puc_config_titan(struct puc_softc *sc __unused, enum puc_cfg_cmd cmd,
1848 int port, intptr_t *res)
1852 case PUC_CFG_GET_OFS:
1853 *res = (port < 3) ? 0 : (port - 2) << 3;
1855 case PUC_CFG_GET_RID:
1856 *res = 0x14 + ((port >= 2) ? 0x0c : port << 2);