xref: /freebsd/sys/dev/uart/uart_bus_isa.c (revision 5b23b1b9e72f192791a777b3419ed95538116c14)
1098ca2bdSWarner Losh /*-
281df65c3SYoshihiro Takahashi  * Copyright (c) 2008 TAKAHASHI Yoshihiro
381df65c3SYoshihiro Takahashi  * Copyright (c) 2008 Marcel Moolenaar
481df65c3SYoshihiro Takahashi  * Copyright (c) 2001 M. Warner Losh
581df65c3SYoshihiro Takahashi  * All rights reserved.
627d5dc18SMarcel Moolenaar  *
727d5dc18SMarcel Moolenaar  * Redistribution and use in source and binary forms, with or without
827d5dc18SMarcel Moolenaar  * modification, are permitted provided that the following conditions
927d5dc18SMarcel Moolenaar  * are met:
1027d5dc18SMarcel Moolenaar  * 1. Redistributions of source code must retain the above copyright
1127d5dc18SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer.
1227d5dc18SMarcel Moolenaar  * 2. Redistributions in binary form must reproduce the above copyright
1327d5dc18SMarcel Moolenaar  *    notice, this list of conditions and the following disclaimer in the
1427d5dc18SMarcel Moolenaar  *    documentation and/or other materials provided with the distribution.
1527d5dc18SMarcel Moolenaar  *
1627d5dc18SMarcel Moolenaar  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
1727d5dc18SMarcel Moolenaar  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
1827d5dc18SMarcel Moolenaar  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
1927d5dc18SMarcel Moolenaar  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
2027d5dc18SMarcel Moolenaar  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
2127d5dc18SMarcel Moolenaar  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2227d5dc18SMarcel Moolenaar  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2327d5dc18SMarcel Moolenaar  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2427d5dc18SMarcel Moolenaar  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
2527d5dc18SMarcel Moolenaar  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2627d5dc18SMarcel Moolenaar  */
2727d5dc18SMarcel Moolenaar 
2827d5dc18SMarcel Moolenaar #include <sys/cdefs.h>
2927d5dc18SMarcel Moolenaar __FBSDID("$FreeBSD$");
3027d5dc18SMarcel Moolenaar 
3127d5dc18SMarcel Moolenaar #include <sys/param.h>
3227d5dc18SMarcel Moolenaar #include <sys/systm.h>
3327d5dc18SMarcel Moolenaar #include <sys/bus.h>
3427d5dc18SMarcel Moolenaar #include <sys/conf.h>
3527d5dc18SMarcel Moolenaar #include <sys/kernel.h>
3627d5dc18SMarcel Moolenaar #include <sys/module.h>
3727d5dc18SMarcel Moolenaar #include <machine/bus.h>
3827d5dc18SMarcel Moolenaar #include <sys/rman.h>
3927d5dc18SMarcel Moolenaar #include <machine/resource.h>
4027d5dc18SMarcel Moolenaar 
4127d5dc18SMarcel Moolenaar #include <isa/isavar.h>
4227d5dc18SMarcel Moolenaar 
4327d5dc18SMarcel Moolenaar #include <dev/uart/uart.h>
4427d5dc18SMarcel Moolenaar #include <dev/uart/uart_bus.h>
4527d5dc18SMarcel Moolenaar 
4627d5dc18SMarcel Moolenaar static int uart_isa_probe(device_t dev);
4727d5dc18SMarcel Moolenaar 
4827d5dc18SMarcel Moolenaar static device_method_t uart_isa_methods[] = {
4927d5dc18SMarcel Moolenaar 	/* Device interface */
5027d5dc18SMarcel Moolenaar 	DEVMETHOD(device_probe,		uart_isa_probe),
5127d5dc18SMarcel Moolenaar 	DEVMETHOD(device_attach,	uart_bus_attach),
5227d5dc18SMarcel Moolenaar 	DEVMETHOD(device_detach,	uart_bus_detach),
53*5b23b1b9SAndriy Gapon 	DEVMETHOD(device_resume,	uart_bus_resume),
5427d5dc18SMarcel Moolenaar 	{ 0, 0 }
5527d5dc18SMarcel Moolenaar };
5627d5dc18SMarcel Moolenaar 
5727d5dc18SMarcel Moolenaar static driver_t uart_isa_driver = {
5827d5dc18SMarcel Moolenaar 	uart_driver_name,
5927d5dc18SMarcel Moolenaar 	uart_isa_methods,
6027d5dc18SMarcel Moolenaar 	sizeof(struct uart_softc),
6127d5dc18SMarcel Moolenaar };
6227d5dc18SMarcel Moolenaar 
6327d5dc18SMarcel Moolenaar static struct isa_pnp_id isa_ns8250_ids[] = {
6427d5dc18SMarcel Moolenaar 	{0x0005d041, "Standard PC COM port"},		/* PNP0500 */
6527d5dc18SMarcel Moolenaar 	{0x0105d041, "16550A-compatible COM port"},	/* PNP0501 */
6627d5dc18SMarcel Moolenaar 	{0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */
6727d5dc18SMarcel Moolenaar 	{0x1005d041, "Generic IRDA-compatible device"},	/* PNP0510 */
6827d5dc18SMarcel Moolenaar 	{0x1105d041, "Generic IRDA-compatible device"},	/* PNP0511 */
6927d5dc18SMarcel Moolenaar 	/* Devices that do not have a compatid */
7027d5dc18SMarcel Moolenaar 	{0x12206804, NULL},     /* ACH2012 - 5634BTS 56K Video Ready Modem */
7127d5dc18SMarcel Moolenaar 	{0x7602a904, NULL},	/* AEI0276 - 56K v.90 Fax Modem (LKT) */
7227d5dc18SMarcel Moolenaar 	{0x00007905, NULL},	/* AKY0000 - 56K Plug&Play Modem */
7327d5dc18SMarcel Moolenaar 	{0x21107905, NULL},	/* AKY1021 - 56K Plug&Play Modem */
7427d5dc18SMarcel Moolenaar 	{0x01405407, NULL},	/* AZT4001 - AZT3000 PnP SOUND DEVICE, MODEM */
7527d5dc18SMarcel Moolenaar 	{0x56039008, NULL},	/* BDP0356 - Best Data 56x2 */
7627d5dc18SMarcel Moolenaar 	{0x56159008, NULL},	/* BDP1556 - B.D. Smart One 56SPS,Voice Modem*/
7727d5dc18SMarcel Moolenaar 	{0x36339008, NULL},	/* BDP3336 - Best Data Prods. 336F */
7827d5dc18SMarcel Moolenaar 	{0x0014490a, NULL},	/* BRI1400 - Boca 33.6 PnP */
7927d5dc18SMarcel Moolenaar 	{0x0015490a, NULL},	/* BRI1500 - Internal Fax Data */
8027d5dc18SMarcel Moolenaar 	{0x0034490a, NULL},	/* BRI3400 - Internal ACF Modem */
8127d5dc18SMarcel Moolenaar 	{0x0094490a, NULL},	/* BRI9400 - Boca K56Flex PnP */
8227d5dc18SMarcel Moolenaar 	{0x00b4490a, NULL},	/* BRIB400 - Boca 56k PnP */
839445dd3bSEitan Adler 	{0x0010320d, NULL},     /* CIR1000 - Cirrus Logic V34 */
8427d5dc18SMarcel Moolenaar 	{0x0030320d, NULL},	/* CIR3000 - Cirrus Logic V43 */
8527d5dc18SMarcel Moolenaar 	{0x0100440e, NULL},	/* CRD0001 - Cardinal MVP288IV ? */
8627d5dc18SMarcel Moolenaar 	{0x01308c0e, NULL},	/* CTL3001 - Creative Labs Phoneblaster */
8727d5dc18SMarcel Moolenaar 	{0x36033610, NULL},     /* DAV0336 - DAVICOM 336PNP MODEM */
8827d5dc18SMarcel Moolenaar 	{0x01009416, NULL},	/* ETT0001 - E-Tech Bullet 33k6 PnP */
8927d5dc18SMarcel Moolenaar 	{0x0000aa1a, NULL},	/* FUJ0000 - FUJITSU Modem 33600 PNP/I2 */
9027d5dc18SMarcel Moolenaar 	{0x1200c31e, NULL},	/* GVC0012 - VF1128HV-R9 (win modem?) */
9127d5dc18SMarcel Moolenaar 	{0x0303c31e, NULL},	/* GVC0303 - MaxTech 33.6 PnP D/F/V */
9227d5dc18SMarcel Moolenaar 	{0x0505c31e, NULL},	/* GVC0505 - GVC 56k Faxmodem */
9327d5dc18SMarcel Moolenaar 	{0x0116c31e, NULL},	/* GVC1601 - Rockwell V.34 Plug & Play Modem */
9427d5dc18SMarcel Moolenaar 	{0x0050c31e, NULL},	/* GVC5000 - some GVC modem */
9527d5dc18SMarcel Moolenaar 	{0x3800f91e, NULL},	/* GWY0038 - Telepath with v.90 */
9627d5dc18SMarcel Moolenaar 	{0x9062f91e, NULL},	/* GWY6290 - Telepath with x2 Technology */
9727d5dc18SMarcel Moolenaar 	{0x8100e425, NULL},	/* IOD0081 - I-O DATA DEVICE,INC. IFML-560 */
9827d5dc18SMarcel Moolenaar 	{0x71004d24, NULL},     /* IBM0071 - IBM ThinkPad 240 IrDA controller*/
9927d5dc18SMarcel Moolenaar 	{0x21002534, NULL},	/* MAE0021 - Jetstream Int V.90 56k Voice Series 2*/
10027d5dc18SMarcel Moolenaar 	{0x0000f435, NULL},	/* MOT0000 - Motorola ModemSURFR 33.6 Intern */
10127d5dc18SMarcel Moolenaar 	{0x5015f435, NULL},	/* MOT1550 - Motorola ModemSURFR 56K Modem */
10227d5dc18SMarcel Moolenaar 	{0xf015f435, NULL},	/* MOT15F0 - Motorola VoiceSURFR 56K Modem */
10327d5dc18SMarcel Moolenaar 	{0x6045f435, NULL},	/* MOT4560 - Motorola ? */
10427d5dc18SMarcel Moolenaar 	{0x61e7a338, NULL},	/* NECE761 - 33.6Modem */
10527d5dc18SMarcel Moolenaar 	{0x0160633a, NULL},	/* NSC6001 - National Semi's IrDA Controller*/
10627d5dc18SMarcel Moolenaar  	{0x08804f3f, NULL},	/* OZO8008 - Zoom  (33.6k Modem) */
10727d5dc18SMarcel Moolenaar 	{0x0f804f3f, NULL},	/* OZO800f - Zoom 2812 (56k Modem) */
10827d5dc18SMarcel Moolenaar 	{0x39804f3f, NULL},	/* OZO8039 - Zoom 56k flex */
10927d5dc18SMarcel Moolenaar 	{0x00914f3f, NULL},	/* OZO9100 - Zoom 2919 (K56 Faxmodem) */
11027d5dc18SMarcel Moolenaar 	{0x3024a341, NULL},	/* PMC2430 - Pace 56 Voice Internal Modem */
11127d5dc18SMarcel Moolenaar 	{0x1000eb49, NULL},	/* ROK0010 - Rockwell ? */
11227d5dc18SMarcel Moolenaar 	{0x1200b23d, NULL},     /* RSS0012 - OMRON ME5614ISA */
11327d5dc18SMarcel Moolenaar 	{0x5002734a, NULL},	/* RSS0250 - 5614Jx3(G) Internal Modem */
11427d5dc18SMarcel Moolenaar 	{0x6202734a, NULL},	/* RSS0262 - 5614Jx3[G] V90+K56Flex Modem */
11527d5dc18SMarcel Moolenaar 	{0x1010104d, NULL},	/* SHP1010 - Rockwell 33600bps Modem */
11627d5dc18SMarcel Moolenaar 	{0x10f0a34d, NULL},	/* SMCF010 - SMC IrCC*/
11727d5dc18SMarcel Moolenaar 	{0xc100ad4d, NULL},	/* SMM00C1 - Leopard 56k PnP */
11827d5dc18SMarcel Moolenaar 	{0x9012b04e, NULL},	/* SUP1290 - Supra ? */
11927d5dc18SMarcel Moolenaar 	{0x1013b04e, NULL},	/* SUP1310 - SupraExpress 336i PnP */
12027d5dc18SMarcel Moolenaar 	{0x8013b04e, NULL},	/* SUP1380 - SupraExpress 288i PnP Voice */
12127d5dc18SMarcel Moolenaar 	{0x8113b04e, NULL},	/* SUP1381 - SupraExpress 336i PnP Voice */
12227d5dc18SMarcel Moolenaar 	{0x5016b04e, NULL},	/* SUP1650 - Supra 336i Sp Intl */
12327d5dc18SMarcel Moolenaar 	{0x7016b04e, NULL},	/* SUP1670 - Supra 336i V+ Intl */
12427d5dc18SMarcel Moolenaar 	{0x7420b04e, NULL},	/* SUP2070 - Supra ? */
12527d5dc18SMarcel Moolenaar 	{0x8020b04e, NULL},	/* SUP2080 - Supra ? */
12627d5dc18SMarcel Moolenaar 	{0x8420b04e, NULL},	/* SUP2084 - SupraExpress 56i PnP */
12727d5dc18SMarcel Moolenaar 	{0x7121b04e, NULL},	/* SUP2171 - SupraExpress 56i Sp? */
12827d5dc18SMarcel Moolenaar 	{0x8024b04e, NULL},	/* SUP2480 - Supra ? */
12927d5dc18SMarcel Moolenaar 	{0x01007256, NULL},	/* USR0001 - U.S. Robotics Inc., Sportster W */
13027d5dc18SMarcel Moolenaar 	{0x02007256, NULL},	/* USR0002 - U.S. Robotics Inc. Sportster 33. */
13127d5dc18SMarcel Moolenaar 	{0x04007256, NULL},	/* USR0004 - USR Sportster 14.4k */
13227d5dc18SMarcel Moolenaar 	{0x06007256, NULL},	/* USR0006 - USR Sportster 33.6k */
13327d5dc18SMarcel Moolenaar 	{0x11007256, NULL},	/* USR0011 - USR ? */
13427d5dc18SMarcel Moolenaar 	{0x01017256, NULL},	/* USR0101 - USR ? */
13527d5dc18SMarcel Moolenaar 	{0x30207256, NULL},	/* USR2030 - U.S.Robotics Inc. Sportster 560 */
13627d5dc18SMarcel Moolenaar 	{0x50207256, NULL},	/* USR2050 - U.S.Robotics Inc. Sportster 33. */
13727d5dc18SMarcel Moolenaar 	{0x70207256, NULL},	/* USR2070 - U.S.Robotics Inc. Sportster 560 */
13827d5dc18SMarcel Moolenaar 	{0x30307256, NULL},	/* USR3030 - U.S. Robotics 56K FAX INT */
13927d5dc18SMarcel Moolenaar 	{0x31307256, NULL},	/* USR3031 - U.S. Robotics 56K FAX INT */
14027d5dc18SMarcel Moolenaar 	{0x50307256, NULL},	/* USR3050 - U.S. Robotics 56K FAX INT */
14127d5dc18SMarcel Moolenaar 	{0x70307256, NULL},	/* USR3070 - U.S. Robotics 56K Voice INT */
14227d5dc18SMarcel Moolenaar 	{0x90307256, NULL},	/* USR3090 - USR ? */
14327d5dc18SMarcel Moolenaar 	{0x70917256, NULL},	/* USR9170 - U.S. Robotics 56K FAX INT */
14427d5dc18SMarcel Moolenaar 	{0x90917256, NULL},	/* USR9190 - USR 56k Voice INT */
14527d5dc18SMarcel Moolenaar 	{0x04f0235c, NULL},	/* WACF004 - Wacom Tablet PC Screen*/
14627d5dc18SMarcel Moolenaar 	{0x0300695c, NULL},	/* WCI0003 - Fax/Voice/Modem/Speakphone/Asvd */
14727d5dc18SMarcel Moolenaar 	{0x01a0896a, NULL},	/* ZTIA001 - Zoom Internal V90 Faxmodem */
14827d5dc18SMarcel Moolenaar 	{0x61f7896a, NULL},	/* ZTIF761 - Zoom ComStar 33.6 */
14981df65c3SYoshihiro Takahashi 	/* The following are found in PC98 hardware. */
15081df65c3SYoshihiro Takahashi 	{0x4180a3b8, NULL},     /* NEC8041 - PC-9821CB-B04 */
15181df65c3SYoshihiro Takahashi 	{0x0181a3b8, NULL},     /* NEC8101 - PC-9821CB2-B04 */
15281df65c3SYoshihiro Takahashi 	{0x5181a3b8, NULL},     /* NEC8151 - Internal FAX/Modem for Cx3, Cb3 */
15381df65c3SYoshihiro Takahashi 	{0x9181a3b8, NULL},     /* NEC8191 - PC-9801-120 */
15481df65c3SYoshihiro Takahashi 	{0xe181a3b8, NULL},     /* NEC81E1 - Internal FAX/Modem */
15581df65c3SYoshihiro Takahashi 	{0x1182a3b8, NULL},     /* NEC8211 - PC-9801-123 */
15681df65c3SYoshihiro Takahashi 	{0x3182a3b8, NULL},     /* NEC8231 - Internal FAX/Modem (Voice) */
15781df65c3SYoshihiro Takahashi 	{0x4182a3b8, NULL},     /* NEC8241 - PC-9821NR-B05 */
15881df65c3SYoshihiro Takahashi 	{0x5182a3b8, NULL},     /* NEC8251 - Internel FAX/Modem */
15981df65c3SYoshihiro Takahashi 	{0x7182a3b8, NULL},     /* NEC8271 - PC-9801-125 */
16081df65c3SYoshihiro Takahashi 	{0x11802fbf, NULL},     /* OYO8011 - Internal FAX/Modem (Ring) */
16127d5dc18SMarcel Moolenaar 	{0}
16227d5dc18SMarcel Moolenaar };
16327d5dc18SMarcel Moolenaar 
16427d5dc18SMarcel Moolenaar static int
16527d5dc18SMarcel Moolenaar uart_isa_probe(device_t dev)
16627d5dc18SMarcel Moolenaar {
16727d5dc18SMarcel Moolenaar 	struct uart_softc *sc;
16827d5dc18SMarcel Moolenaar 	device_t parent;
16927d5dc18SMarcel Moolenaar 
17027d5dc18SMarcel Moolenaar 	parent = device_get_parent(dev);
17127d5dc18SMarcel Moolenaar 	sc = device_get_softc(dev);
17227d5dc18SMarcel Moolenaar 
17381df65c3SYoshihiro Takahashi 	/* Check PnP IDs */
17481df65c3SYoshihiro Takahashi 	if (ISA_PNP_PROBE(parent, dev, isa_ns8250_ids) == ENXIO)
1758f0882f5SMarius Strobl 		return (ENXIO);
17681df65c3SYoshihiro Takahashi 
17781df65c3SYoshihiro Takahashi 	/* Probe PnP _and_ non-PnP ns8250 here. */
17881df65c3SYoshihiro Takahashi #ifdef PC98
17981df65c3SYoshihiro Takahashi 	if (isa_get_logicalid(dev))
18081df65c3SYoshihiro Takahashi 		sc->sc_class = &uart_ns8250_class;
18181df65c3SYoshihiro Takahashi 	else
18281df65c3SYoshihiro Takahashi 		sc->sc_class = uart_pc98_getdev(bus_get_resource_start(dev,
18381df65c3SYoshihiro Takahashi 		    SYS_RES_IOPORT, 0));
18481df65c3SYoshihiro Takahashi #else
18581df65c3SYoshihiro Takahashi 	sc->sc_class = &uart_ns8250_class;
18681df65c3SYoshihiro Takahashi #endif
18781df65c3SYoshihiro Takahashi 	return (uart_bus_probe(dev, 0, 0, 0, 0));
18827d5dc18SMarcel Moolenaar }
18927d5dc18SMarcel Moolenaar 
19027d5dc18SMarcel Moolenaar DRIVER_MODULE(uart, isa, uart_isa_driver, uart_devclass, 0, 0);
191