uart_bus_pci.c revision 158078
188800Skbyanc/*- 219192Sphk * Copyright (c) 2006 Marcel Moolenaar 319192Sphk * Copyright (c) 2001 M. Warner Losh 4219511Sbrucec * All rights reserved. 519192Sphk * 619192Sphk * Redistribution and use in source and binary forms, with or without 719192Sphk * modification, are permitted provided that the following conditions 819192Sphk * are met: 919192Sphk * 1. Redistributions of source code must retain the above copyright 1019192Sphk * notice, this list of conditions and the following disclaimer. 1119192Sphk * 2. Redistributions in binary form must reproduce the above copyright 1219192Sphk * notice, this list of conditions and the following disclaimer in the 1319192Sphk * documentation and/or other materials provided with the distribution. 1419192Sphk * 1519192Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 16219511Sbrucec * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1719192Sphk * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1819192Sphk * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1919192Sphk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2019192Sphk * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21219511Sbrucec * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22219511Sbrucec * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23219511Sbrucec * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2488800Skbyanc * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25219511Sbrucec */ 2619192Sphk 2719192Sphk#include <sys/cdefs.h> 28219511Sbrucec__FBSDID("$FreeBSD: head/sys/dev/uart/uart_bus_pci.c 158078 2006-04-27 17:08:30Z marcel $"); 2919192Sphk 30219511Sbrucec#include <sys/param.h> 3119192Sphk#include <sys/systm.h> 3219192Sphk#include <sys/bus.h> 3319192Sphk#include <sys/conf.h> 34219511Sbrucec#include <sys/kernel.h> 3519192Sphk#include <sys/module.h> 3688800Skbyanc#include <machine/bus.h> 3719192Sphk#include <sys/rman.h> 3888800Skbyanc#include <machine/resource.h> 3988800Skbyanc 4088800Skbyanc#include <dev/pci/pcivar.h> 4188800Skbyanc 4288800Skbyanc#include <dev/uart/uart.h> 43219511Sbrucec#include <dev/uart/uart_bus.h> 4488800Skbyanc 4519192Sphk#define DEFAULT_RCLK 1843200 4619192Sphk 4719192Sphkstatic int uart_pci_probe(device_t dev); 48219511Sbrucec 49219511Sbrucecstatic device_method_t uart_pci_methods[] = { 5019192Sphk /* Device interface */ 5119192Sphk DEVMETHOD(device_probe, uart_pci_probe), 52219511Sbrucec DEVMETHOD(device_attach, uart_bus_attach), 5319192Sphk DEVMETHOD(device_detach, uart_bus_detach), 5419192Sphk { 0, 0 } 55219511Sbrucec}; 56219511Sbrucec 5719192Sphkstatic driver_t uart_pci_driver = { 5819192Sphk uart_driver_name, 59 uart_pci_methods, 60 sizeof(struct uart_softc), 61}; 62 63struct pci_id { 64 uint16_t vendor; 65 uint16_t device; 66 uint16_t subven; 67 uint16_t subdev; 68 const char *desc; 69 int rid; 70 int rclk; 71}; 72 73static struct pci_id pci_ns8250_ids[] = { 74{ 0x1028, 0x0008, 0xffff, 0, "Dell Remote Access Card III", 0x14, 75 128 * DEFAULT_RCLK }, 76{ 0x1028, 0x0012, 0xffff, 0, "Dell RAC 4 Daughter Card Virtual UART", 0x14, 77 128 * DEFAULT_RCLK }, 78{ 0x1033, 0x0074, 0x1033, 0x8014, "NEC RCV56ACF 56k Voice Modem", 0x10 }, 79{ 0x1033, 0x007d, 0x1033, 0x8012, "NEC RS232C", 0x10 }, 80{ 0x103c, 0x1048, 0x103c, 0x1227, "HP Diva Serial [GSP] UART - Powerbar SP2", 81 0x10 }, 82{ 0x103c, 0x1290, 0xffff, 0, "HP Auxiliary Diva Serial Port", 0x18 }, 83{ 0x11c1, 0x0480, 0xffff, 0, "Agere Systems Venus Modem (V90, 56KFlex)", 0x14 }, 84{ 0x115d, 0x0103, 0xffff, 0, "Xircom Cardbus Ethernet + 56k Modem", 0x10 }, 85{ 0x12b9, 0x1008, 0xffff, 0, "3Com 56K FaxModem Model 5610", 0x10 }, 86{ 0x131f, 0x1000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x18 }, 87{ 0x131f, 0x1001, 0xffff, 0, "Siig CyberSerial (1-port) 16650", 0x18 }, 88{ 0x131f, 0x1002, 0xffff, 0, "Siig CyberSerial (1-port) 16850", 0x18 }, 89{ 0x131f, 0x2000, 0xffff, 0, "Siig CyberSerial (1-port) 16550", 0x10 }, 90{ 0x131f, 0x2001, 0xffff, 0, "Siig CyberSerial (1-port) 16650", 0x10 }, 91{ 0x131f, 0x2002, 0xffff, 0, "Siig CyberSerial (1-port) 16850", 0x10 }, 92{ 0x135c, 0x0190, 0xffff, 0, "Quatech SSCLP-100", 0x18 }, 93{ 0x135c, 0x01c0, 0xffff, 0, "Quatech SSCLP-200/300", 0x18 }, 94{ 0x135e, 0x7101, 0xffff, 0, "Sealevel Systems Single Port RS-232/422/485/530", 95 0x18 }, 96{ 0x1407, 0x0110, 0xffff, 0, "Lava Computer mfg DSerial-PCI Port A", 0x10 }, 97{ 0x1407, 0x0111, 0xffff, 0, "Lava Computer mfg DSerial-PCI Port B", 0x10 }, 98{ 0x1409, 0x7168, 0x1409, 0x4025, "Timedia Technology Serial Port", 0x10, 99 8 * DEFAULT_RCLK }, 100{ 0x1409, 0x7168, 0x1409, 0x4027, "Timedia Technology Serial Port", 0x10, 101 8 * DEFAULT_RCLK }, 102{ 0x1409, 0x7168, 0x1409, 0x4028, "Timedia Technology Serial Port", 0x10, 103 8 * DEFAULT_RCLK }, 104{ 0x1409, 0x7168, 0x1409, 0x5025, "Timedia Technology Serial Port", 0x10, 105 8 * DEFAULT_RCLK }, 106{ 0x1409, 0x7168, 0x1409, 0x5027, "Timedia Technology Serial Port", 0x10, 107 8 * DEFAULT_RCLK }, 108{ 0x1415, 0x950b, 0xffff, 0, "Oxford Semiconductor OXCB950 Cardbus 16950 UART", 109 0x10, 16384000 }, 110{ 0x151f, 0x0000, 0xffff, 0, "TOPIC Semiconductor TP560 56k modem", 0x10 }, 111{ 0xdeaf, 0x9051, 0xffff, 0, "Middle Digital PC Weasel Serial Port", 0x10 }, 112{ 0xffff, 0, 0xffff, 0, NULL, 0, 0} 113}; 114 115static struct pci_id * 116uart_pci_match(device_t dev, struct pci_id *id) 117{ 118 uint16_t device, subdev, subven, vendor; 119 120 vendor = pci_get_vendor(dev); 121 device = pci_get_device(dev); 122 while (id->vendor != 0xffff && 123 (id->vendor != vendor || id->device != device)) 124 id++; 125 if (id->vendor == 0xffff) 126 return (NULL); 127 if (id->subven == 0xffff) 128 return (id); 129 subven = pci_get_subvendor(dev); 130 subdev = pci_get_subdevice(dev); 131 while (id->vendor == vendor && id->device == device && 132 (id->subven != subven || id->subdev != subdev)) 133 id++; 134 return ((id->vendor == vendor && id->device == device) ? id : NULL); 135} 136 137static int 138uart_pci_probe(device_t dev) 139{ 140 struct uart_softc *sc; 141 struct pci_id *id; 142 143 sc = device_get_softc(dev); 144 145 id = uart_pci_match(dev, pci_ns8250_ids); 146 if (id != NULL) { 147 sc->sc_class = &uart_ns8250_class; 148 goto match; 149 } 150 /* Add checks for non-ns8250 IDs here. */ 151 return (ENXIO); 152 153 match: 154 if (id->desc) 155 device_set_desc(dev, id->desc); 156 return (uart_bus_probe(dev, 0, id->rclk, id->rid, 0)); 157} 158 159DRIVER_MODULE(uart, pci, uart_pci_driver, uart_devclass, 0, 0); 160DRIVER_MODULE(uart, cardbus, uart_pci_driver, uart_devclass, 0, 0); 161