uart_bus_pci.c revision 119815
1255376Sdes/* 2255376Sdes * Copyright (c) 2001 M. Warner Losh. All rights reserved. 3271947Sdes * 491100Sdes * Redistribution and use in source and binary forms, with or without 591100Sdes * modification, are permitted provided that the following conditions 691100Sdes * are met: 791100Sdes * 1. Redistributions of source code must retain the above copyright 891100Sdes * notice, this list of conditions and the following disclaimer. 991100Sdes * 2. Redistributions in binary form must reproduce the above copyright 1091100Sdes * notice, this list of conditions and the following disclaimer in the 1191100Sdes * documentation and/or other materials provided with the distribution. 12108794Sdes * 1391100Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1491100Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15117610Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1691100Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1791100Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1891100Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19236109Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2091100Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2191100Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2291100Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2391100Sdes */ 2491100Sdes 2591100Sdes#include <sys/cdefs.h> 26236109Sdes__FBSDID("$FreeBSD: head/sys/dev/uart/uart_bus_pci.c 119815 2003-09-06 23:13:47Z marcel $"); 2791100Sdes 2891100Sdes#include <sys/param.h> 2991100Sdes#include <sys/systm.h> 3091100Sdes#include <sys/bus.h> 3191100Sdes#include <sys/conf.h> 3291100Sdes#include <sys/kernel.h> 3391100Sdes#include <sys/module.h> 3491100Sdes#include <machine/bus.h> 3591100Sdes#include <sys/rman.h> 3691100Sdes#include <machine/resource.h> 3791100Sdes 3891100Sdes#include <dev/pci/pcivar.h> 3991100Sdes 4091100Sdes#include <dev/uart/uart.h> 4191100Sdes#include <dev/uart/uart_bus.h> 4291100Sdes 4391100Sdesstatic int uart_pci_probe(device_t dev); 4491100Sdes 4591100Sdesstatic device_method_t uart_pci_methods[] = { 4691100Sdes /* Device interface */ 4791100Sdes DEVMETHOD(device_probe, uart_pci_probe), 4891100Sdes DEVMETHOD(device_attach, uart_bus_attach), 4991100Sdes DEVMETHOD(device_detach, uart_bus_detach), 5091100Sdes { 0, 0 } 5191100Sdes}; 5291100Sdes 5391100Sdesstatic driver_t uart_pci_driver = { 5491100Sdes uart_driver_name, 5591100Sdes uart_pci_methods, 5691100Sdes sizeof(struct uart_softc), 5791100Sdes}; 5891100Sdes 5991100Sdesstruct pci_id { 6091100Sdes uint32_t type; 6191100Sdes const char *desc; 6291100Sdes int rid; 6391100Sdes}; 6491100Sdes 65236109Sdesstatic struct pci_id pci_ns8250_ids[] = { 66236109Sdes { 0x100812b9, "3COM PCI FaxModem", 0x10 }, 67236109Sdes { 0x2000131f, "CyberSerial (1-port) 16550", 0x10 }, 68117610Sdes { 0x01101407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 }, 69236109Sdes { 0x01111407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 }, 70147466Sdes { 0x048011c1, "Lucent kermit based PCI Modem", 0x14 }, 71117610Sdes { 0x95211415, "Oxford Semiconductor PCI Dual Port Serial", 0x10 }, 7291100Sdes { 0x7101135e, "SeaLevel Ultra 530.PCI Single Port Serial", 0x18 }, 7391100Sdes { 0x0000151f, "SmartLink 5634PCV SurfRider", 0x10 }, 74255376Sdes { 0x0103115d, "Xircom Cardbus modem", 0x10 }, 75255376Sdes { 0x98459710, "Netmos Nm9845 PCI Bridge with Dual UART", 0x10 }, 76255376Sdes { 0x01c0135c, "Quatech SSCLP-200/300", 0x18 77 /* 78 * NB: You must mount the "SPAD" jumper to correctly detect 79 * the FIFO on the UART. Set the options on the jumpers, 80 * we do not support the extra registers on the Quatech. 81 */ 82 }, 83 { 0x00000000, NULL, 0 } 84}; 85 86static struct pci_id * 87uart_pci_match(uint32_t type, struct pci_id *id) 88{ 89 90 while (id->type && id->type != type) 91 id++; 92 return ((id->type) ? id : NULL); 93} 94 95static int 96uart_pci_probe(device_t dev) 97{ 98 struct uart_softc *sc; 99 struct pci_id *id; 100 101 sc = device_get_softc(dev); 102 103 id = uart_pci_match(pci_get_devid(dev), pci_ns8250_ids); 104 if (id != NULL) { 105 sc->sc_class = &uart_ns8250_class; 106 goto match; 107 } 108 /* Add checks for non-ns8250 IDs here. */ 109 return (ENXIO); 110 111 match: 112 if (id->desc) 113 device_set_desc(dev, id->desc); 114 return (uart_bus_probe(dev, 0, 0, id->rid)); 115} 116 117DRIVER_MODULE(uart, pci, uart_pci_driver, uart_devclass, 0, 0); 118DRIVER_MODULE(uart, cardbus, uart_pci_driver, uart_devclass, 0, 0); 119