uart_bus_pci.c revision 158064
1/*- 2 * Copyright (c) 2001 M. Warner Losh. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25#include <sys/cdefs.h> 26__FBSDID("$FreeBSD: head/sys/dev/uart/uart_bus_pci.c 158064 2006-04-27 03:17:39Z marcel $"); 27 28#include <sys/param.h> 29#include <sys/systm.h> 30#include <sys/bus.h> 31#include <sys/conf.h> 32#include <sys/kernel.h> 33#include <sys/module.h> 34#include <machine/bus.h> 35#include <sys/rman.h> 36#include <machine/resource.h> 37 38#include <dev/pci/pcivar.h> 39 40#include <dev/uart/uart.h> 41#include <dev/uart/uart_bus.h> 42 43#define DEFAULT_RCLK 1843200 44 45static int uart_pci_probe(device_t dev); 46 47static device_method_t uart_pci_methods[] = { 48 /* Device interface */ 49 DEVMETHOD(device_probe, uart_pci_probe), 50 DEVMETHOD(device_attach, uart_bus_attach), 51 DEVMETHOD(device_detach, uart_bus_detach), 52 { 0, 0 } 53}; 54 55static driver_t uart_pci_driver = { 56 uart_driver_name, 57 uart_pci_methods, 58 sizeof(struct uart_softc), 59}; 60 61struct pci_id { 62 uint16_t vendor; 63 uint16_t device; 64 uint16_t subven; 65 uint16_t subdev; 66 const char *desc; 67 int rid; 68 int rclk; 69}; 70 71static struct pci_id pci_ns8250_ids[] = { 72{ 0x1028, 0x0008, 0xffff, 0, "Dell Remote Access Card III", 0x14, 128 * DEFAULT_RCLK }, 73{ 0x1028, 0x0012, 0xffff, 0, "Dell Remote Access Card 4 Daughter Card Virtual UART", 0x14, 128 * DEFAULT_RCLK }, 74{ 0x1033, 0x0074, 0x1033, 0x8014, "NEC RCV56ACF 56k Voice Modem", 0x10 }, 75{ 0x1033, 0x007d, 0x1033, 0x8012, "NEC RS232C", 0x10 }, 76{ 0x103c, 0x1048, 0x103c, 0x1227, "HP Diva Serial [GSP] Multiport UART - Powerbar SP2", 0x10, DEFAULT_RCLK }, 77{ 0x103c, 0x1290, 0xffff, 0, "HP Auxiliary Diva Serial Port", 0x18, DEFAULT_RCLK }, 78{ 0x11c1, 0x0480, 0xffff, 0, "Agere Systems Venus Modem (V90, 56KFlex)", 0x14 }, 79{ 0x115d, 0x0103, 0xffff, 0, "Xircom Cardbus Ethernet + 56k Modem", 0x10 }, 80{ 0x12b9, 0x1008, 0xffff, 0, "3Com 56K FaxModem Model 5610", 0x10 }, 81{ 0x131f, 0x1000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x18 }, 82{ 0x131f, 0x1001, 0xffff, 0, "Siig CyberSerial (1-port) 16650", 0x18 }, 83{ 0x131f, 0x1002, 0xffff, 0, "Siig CyberSerial (1-port) 16850", 0x18 }, 84{ 0x131f, 0x2000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x10 }, 85{ 0x131f, 0x2001, 0xffff, 0, "Siig CyberSerial (1-port) 16650", 0x10 }, 86{ 0x131f, 0x2002, 0xffff, 0, "Siig CyberSerial (1-port) 16850", 0x10 }, 87{ 0x135c, 0x0190, 0xffff, 0, "Quatech SSCLP-100", 0x18 }, 88{ 0x135c, 0x01c0, 0xffff, 0, "Quatech SSCLP-200/300", 0x18 }, 89{ 0x135e, 0x7101, 0xffff, 0, "Sealevel Systems Single Port RS-232/422/485/530", 0x18 }, 90{ 0x1407, 0x0110, 0xffff, 0, "Lava Computer mfg DSerial-PCI Port A", 0x10 }, 91{ 0x1407, 0x0111, 0xffff, 0, "Lava Computer mfg DSerial-PCI Port B", 0x10 }, 92{ 0x1415, 0x950b, 0xffff, 0, "Oxford Semiconductor OXCB950 Cardbus 16950 UART", 0x10, 16384000 }, 93{ 0x151f, 0x0000, 0xffff, 0, "TOPIC Semiconductor TP560 Data/Fax/Voice 56k modem", 0x10 }, 94{ 0xdeaf, 0x9051, 0xffff, 0, "Middle Digital PC Weasel Serial Port", 0x10 }, 95{ 0xffff, 0, 0xffff, 0, NULL, 0, 0} 96}; 97 98static struct pci_id * 99uart_pci_match(device_t dev, struct pci_id *id) 100{ 101 uint16_t device, subdev, subven, vendor; 102 103 vendor = pci_get_vendor(dev); 104 device = pci_get_device(dev); 105 while (id->vendor != 0xffff && 106 (id->vendor != vendor || id->device != device)) 107 id++; 108 if (id->vendor == 0xffff) 109 return (NULL); 110 if (id->subven == 0xffff) 111 return (id); 112 subven = pci_get_subvendor(dev); 113 subdev = pci_get_subdevice(dev); 114 while (id->vendor == vendor && id->device == device && 115 (id->subven != subven || id->subdev != subdev)) 116 id++; 117 return ((id->vendor == vendor && id->device == device) ? id : NULL); 118} 119 120static int 121uart_pci_probe(device_t dev) 122{ 123 struct uart_softc *sc; 124 struct pci_id *id; 125 126 sc = device_get_softc(dev); 127 128 id = uart_pci_match(dev, pci_ns8250_ids); 129 if (id != NULL) { 130 sc->sc_class = &uart_ns8250_class; 131 goto match; 132 } 133 /* Add checks for non-ns8250 IDs here. */ 134 return (ENXIO); 135 136 match: 137 if (id->desc) 138 device_set_desc(dev, id->desc); 139 return (uart_bus_probe(dev, 0, id->rclk, id->rid, 0)); 140} 141 142DRIVER_MODULE(uart, pci, uart_pci_driver, uart_devclass, 0, 0); 143DRIVER_MODULE(uart, cardbus, uart_pci_driver, uart_devclass, 0, 0); 144