1139749Simp/*-
2182159Snyan * Copyright (c) 2008 TAKAHASHI Yoshihiro
3182159Snyan * Copyright (c) 2008 Marcel Moolenaar
4182159Snyan * Copyright (c) 2001 M. Warner Losh
5182159Snyan * All rights reserved.
6119815Smarcel *
7119815Smarcel * Redistribution and use in source and binary forms, with or without
8119815Smarcel * modification, are permitted provided that the following conditions
9119815Smarcel * are met:
10119815Smarcel * 1. Redistributions of source code must retain the above copyright
11119815Smarcel *    notice, this list of conditions and the following disclaimer.
12119815Smarcel * 2. Redistributions in binary form must reproduce the above copyright
13119815Smarcel *    notice, this list of conditions and the following disclaimer in the
14119815Smarcel *    documentation and/or other materials provided with the distribution.
15119815Smarcel *
16119815Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17119815Smarcel * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18119815Smarcel * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19119815Smarcel * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20119815Smarcel * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21119815Smarcel * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22119815Smarcel * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23119815Smarcel * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24119815Smarcel * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25119815Smarcel * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26119815Smarcel */
27119815Smarcel
28119815Smarcel#include <sys/cdefs.h>
29119815Smarcel__FBSDID("$FreeBSD$");
30119815Smarcel
31119815Smarcel#include <sys/param.h>
32119815Smarcel#include <sys/systm.h>
33119815Smarcel#include <sys/bus.h>
34119815Smarcel#include <sys/conf.h>
35119815Smarcel#include <sys/kernel.h>
36119815Smarcel#include <sys/module.h>
37119815Smarcel#include <machine/bus.h>
38119815Smarcel#include <sys/rman.h>
39119815Smarcel#include <machine/resource.h>
40119815Smarcel
41119815Smarcel#include <isa/isavar.h>
42119815Smarcel
43119815Smarcel#include <dev/uart/uart.h>
44119815Smarcel#include <dev/uart/uart_bus.h>
45119815Smarcel
46119815Smarcelstatic int uart_isa_probe(device_t dev);
47119815Smarcel
48119815Smarcelstatic device_method_t uart_isa_methods[] = {
49119815Smarcel	/* Device interface */
50119815Smarcel	DEVMETHOD(device_probe,		uart_isa_probe),
51119815Smarcel	DEVMETHOD(device_attach,	uart_bus_attach),
52119815Smarcel	DEVMETHOD(device_detach,	uart_bus_detach),
53247887Savg	DEVMETHOD(device_resume,	uart_bus_resume),
54119815Smarcel	{ 0, 0 }
55119815Smarcel};
56119815Smarcel
57119815Smarcelstatic driver_t uart_isa_driver = {
58119815Smarcel	uart_driver_name,
59119815Smarcel	uart_isa_methods,
60119815Smarcel	sizeof(struct uart_softc),
61119815Smarcel};
62119815Smarcel
63119815Smarcelstatic struct isa_pnp_id isa_ns8250_ids[] = {
64119815Smarcel	{0x0005d041, "Standard PC COM port"},		/* PNP0500 */
65119815Smarcel	{0x0105d041, "16550A-compatible COM port"},	/* PNP0501 */
66119815Smarcel	{0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */
67119815Smarcel	{0x1005d041, "Generic IRDA-compatible device"},	/* PNP0510 */
68119815Smarcel	{0x1105d041, "Generic IRDA-compatible device"},	/* PNP0511 */
69119815Smarcel	/* Devices that do not have a compatid */
70119815Smarcel	{0x12206804, NULL},     /* ACH2012 - 5634BTS 56K Video Ready Modem */
71119815Smarcel	{0x7602a904, NULL},	/* AEI0276 - 56K v.90 Fax Modem (LKT) */
72119815Smarcel	{0x00007905, NULL},	/* AKY0000 - 56K Plug&Play Modem */
73119815Smarcel	{0x21107905, NULL},	/* AKY1021 - 56K Plug&Play Modem */
74119815Smarcel	{0x01405407, NULL},	/* AZT4001 - AZT3000 PnP SOUND DEVICE, MODEM */
75119815Smarcel	{0x56039008, NULL},	/* BDP0356 - Best Data 56x2 */
76119815Smarcel	{0x56159008, NULL},	/* BDP1556 - B.D. Smart One 56SPS,Voice Modem*/
77119815Smarcel	{0x36339008, NULL},	/* BDP3336 - Best Data Prods. 336F */
78119815Smarcel	{0x0014490a, NULL},	/* BRI1400 - Boca 33.6 PnP */
79119815Smarcel	{0x0015490a, NULL},	/* BRI1500 - Internal Fax Data */
80119815Smarcel	{0x0034490a, NULL},	/* BRI3400 - Internal ACF Modem */
81119815Smarcel	{0x0094490a, NULL},	/* BRI9400 - Boca K56Flex PnP */
82119815Smarcel	{0x00b4490a, NULL},	/* BRIB400 - Boca 56k PnP */
83243356Seadler	{0x0010320d, NULL},     /* CIR1000 - Cirrus Logic V34 */
84119815Smarcel	{0x0030320d, NULL},	/* CIR3000 - Cirrus Logic V43 */
85119815Smarcel	{0x0100440e, NULL},	/* CRD0001 - Cardinal MVP288IV ? */
86119815Smarcel	{0x01308c0e, NULL},	/* CTL3001 - Creative Labs Phoneblaster */
87119815Smarcel	{0x36033610, NULL},     /* DAV0336 - DAVICOM 336PNP MODEM */
88119815Smarcel	{0x01009416, NULL},	/* ETT0001 - E-Tech Bullet 33k6 PnP */
89119815Smarcel	{0x0000aa1a, NULL},	/* FUJ0000 - FUJITSU Modem 33600 PNP/I2 */
90119815Smarcel	{0x1200c31e, NULL},	/* GVC0012 - VF1128HV-R9 (win modem?) */
91119815Smarcel	{0x0303c31e, NULL},	/* GVC0303 - MaxTech 33.6 PnP D/F/V */
92119815Smarcel	{0x0505c31e, NULL},	/* GVC0505 - GVC 56k Faxmodem */
93119815Smarcel	{0x0116c31e, NULL},	/* GVC1601 - Rockwell V.34 Plug & Play Modem */
94119815Smarcel	{0x0050c31e, NULL},	/* GVC5000 - some GVC modem */
95119815Smarcel	{0x3800f91e, NULL},	/* GWY0038 - Telepath with v.90 */
96119815Smarcel	{0x9062f91e, NULL},	/* GWY6290 - Telepath with x2 Technology */
97119815Smarcel	{0x8100e425, NULL},	/* IOD0081 - I-O DATA DEVICE,INC. IFML-560 */
98119815Smarcel	{0x71004d24, NULL},     /* IBM0071 - IBM ThinkPad 240 IrDA controller*/
99119815Smarcel	{0x21002534, NULL},	/* MAE0021 - Jetstream Int V.90 56k Voice Series 2*/
100119815Smarcel	{0x0000f435, NULL},	/* MOT0000 - Motorola ModemSURFR 33.6 Intern */
101119815Smarcel	{0x5015f435, NULL},	/* MOT1550 - Motorola ModemSURFR 56K Modem */
102119815Smarcel	{0xf015f435, NULL},	/* MOT15F0 - Motorola VoiceSURFR 56K Modem */
103119815Smarcel	{0x6045f435, NULL},	/* MOT4560 - Motorola ? */
104119815Smarcel	{0x61e7a338, NULL},	/* NECE761 - 33.6Modem */
105119815Smarcel	{0x0160633a, NULL},	/* NSC6001 - National Semi's IrDA Controller*/
106119815Smarcel 	{0x08804f3f, NULL},	/* OZO8008 - Zoom  (33.6k Modem) */
107119815Smarcel	{0x0f804f3f, NULL},	/* OZO800f - Zoom 2812 (56k Modem) */
108119815Smarcel	{0x39804f3f, NULL},	/* OZO8039 - Zoom 56k flex */
109119815Smarcel	{0x00914f3f, NULL},	/* OZO9100 - Zoom 2919 (K56 Faxmodem) */
110119815Smarcel	{0x3024a341, NULL},	/* PMC2430 - Pace 56 Voice Internal Modem */
111119815Smarcel	{0x1000eb49, NULL},	/* ROK0010 - Rockwell ? */
112119815Smarcel	{0x1200b23d, NULL},     /* RSS0012 - OMRON ME5614ISA */
113119815Smarcel	{0x5002734a, NULL},	/* RSS0250 - 5614Jx3(G) Internal Modem */
114119815Smarcel	{0x6202734a, NULL},	/* RSS0262 - 5614Jx3[G] V90+K56Flex Modem */
115119815Smarcel	{0x1010104d, NULL},	/* SHP1010 - Rockwell 33600bps Modem */
116119815Smarcel	{0x10f0a34d, NULL},	/* SMCF010 - SMC IrCC*/
117119815Smarcel	{0xc100ad4d, NULL},	/* SMM00C1 - Leopard 56k PnP */
118119815Smarcel	{0x9012b04e, NULL},	/* SUP1290 - Supra ? */
119119815Smarcel	{0x1013b04e, NULL},	/* SUP1310 - SupraExpress 336i PnP */
120119815Smarcel	{0x8013b04e, NULL},	/* SUP1380 - SupraExpress 288i PnP Voice */
121119815Smarcel	{0x8113b04e, NULL},	/* SUP1381 - SupraExpress 336i PnP Voice */
122119815Smarcel	{0x5016b04e, NULL},	/* SUP1650 - Supra 336i Sp Intl */
123119815Smarcel	{0x7016b04e, NULL},	/* SUP1670 - Supra 336i V+ Intl */
124119815Smarcel	{0x7420b04e, NULL},	/* SUP2070 - Supra ? */
125119815Smarcel	{0x8020b04e, NULL},	/* SUP2080 - Supra ? */
126119815Smarcel	{0x8420b04e, NULL},	/* SUP2084 - SupraExpress 56i PnP */
127119815Smarcel	{0x7121b04e, NULL},	/* SUP2171 - SupraExpress 56i Sp? */
128119815Smarcel	{0x8024b04e, NULL},	/* SUP2480 - Supra ? */
129119815Smarcel	{0x01007256, NULL},	/* USR0001 - U.S. Robotics Inc., Sportster W */
130119815Smarcel	{0x02007256, NULL},	/* USR0002 - U.S. Robotics Inc. Sportster 33. */
131119815Smarcel	{0x04007256, NULL},	/* USR0004 - USR Sportster 14.4k */
132119815Smarcel	{0x06007256, NULL},	/* USR0006 - USR Sportster 33.6k */
133119815Smarcel	{0x11007256, NULL},	/* USR0011 - USR ? */
134119815Smarcel	{0x01017256, NULL},	/* USR0101 - USR ? */
135119815Smarcel	{0x30207256, NULL},	/* USR2030 - U.S.Robotics Inc. Sportster 560 */
136119815Smarcel	{0x50207256, NULL},	/* USR2050 - U.S.Robotics Inc. Sportster 33. */
137119815Smarcel	{0x70207256, NULL},	/* USR2070 - U.S.Robotics Inc. Sportster 560 */
138119815Smarcel	{0x30307256, NULL},	/* USR3030 - U.S. Robotics 56K FAX INT */
139119815Smarcel	{0x31307256, NULL},	/* USR3031 - U.S. Robotics 56K FAX INT */
140119815Smarcel	{0x50307256, NULL},	/* USR3050 - U.S. Robotics 56K FAX INT */
141119815Smarcel	{0x70307256, NULL},	/* USR3070 - U.S. Robotics 56K Voice INT */
142119815Smarcel	{0x90307256, NULL},	/* USR3090 - USR ? */
143119815Smarcel	{0x70917256, NULL},	/* USR9170 - U.S. Robotics 56K FAX INT */
144119815Smarcel	{0x90917256, NULL},	/* USR9190 - USR 56k Voice INT */
145119815Smarcel	{0x04f0235c, NULL},	/* WACF004 - Wacom Tablet PC Screen*/
146119815Smarcel	{0x0300695c, NULL},	/* WCI0003 - Fax/Voice/Modem/Speakphone/Asvd */
147119815Smarcel	{0x01a0896a, NULL},	/* ZTIA001 - Zoom Internal V90 Faxmodem */
148119815Smarcel	{0x61f7896a, NULL},	/* ZTIF761 - Zoom ComStar 33.6 */
149182159Snyan	/* The following are found in PC98 hardware. */
150182159Snyan	{0x4180a3b8, NULL},     /* NEC8041 - PC-9821CB-B04 */
151182159Snyan	{0x0181a3b8, NULL},     /* NEC8101 - PC-9821CB2-B04 */
152182159Snyan	{0x5181a3b8, NULL},     /* NEC8151 - Internal FAX/Modem for Cx3, Cb3 */
153182159Snyan	{0x9181a3b8, NULL},     /* NEC8191 - PC-9801-120 */
154182159Snyan	{0xe181a3b8, NULL},     /* NEC81E1 - Internal FAX/Modem */
155182159Snyan	{0x1182a3b8, NULL},     /* NEC8211 - PC-9801-123 */
156182159Snyan	{0x3182a3b8, NULL},     /* NEC8231 - Internal FAX/Modem (Voice) */
157182159Snyan	{0x4182a3b8, NULL},     /* NEC8241 - PC-9821NR-B05 */
158182159Snyan	{0x5182a3b8, NULL},     /* NEC8251 - Internel FAX/Modem */
159182159Snyan	{0x7182a3b8, NULL},     /* NEC8271 - PC-9801-125 */
160182159Snyan	{0x11802fbf, NULL},     /* OYO8011 - Internal FAX/Modem (Ring) */
161119815Smarcel	{0}
162119815Smarcel};
163119815Smarcel
164119815Smarcelstatic int
165119815Smarceluart_isa_probe(device_t dev)
166119815Smarcel{
167119815Smarcel	struct uart_softc *sc;
168119815Smarcel	device_t parent;
169119815Smarcel
170119815Smarcel	parent = device_get_parent(dev);
171119815Smarcel	sc = device_get_softc(dev);
172119815Smarcel
173182159Snyan	/* Check PnP IDs */
174182159Snyan	if (ISA_PNP_PROBE(parent, dev, isa_ns8250_ids) == ENXIO)
175182159Snyan		return (ENXIO);
176182159Snyan
177134312Smarius	/* Probe PnP _and_ non-PnP ns8250 here. */
178182159Snyan#ifdef PC98
179182159Snyan	if (isa_get_logicalid(dev))
180119815Smarcel		sc->sc_class = &uart_ns8250_class;
181182159Snyan	else
182182159Snyan		sc->sc_class = uart_pc98_getdev(bus_get_resource_start(dev,
183182159Snyan		    SYS_RES_IOPORT, 0));
184182159Snyan#else
185182159Snyan	sc->sc_class = &uart_ns8250_class;
186182159Snyan#endif
187182159Snyan	return (uart_bus_probe(dev, 0, 0, 0, 0));
188119815Smarcel}
189119815Smarcel
190119815SmarcelDRIVER_MODULE(uart, isa, uart_isa_driver, uart_devclass, 0, 0);
191