1119419Sobrien/*- 285365Simp * Copyright (c) 2001 M. Warner Losh. All rights reserved. 385365Simp * 485365Simp * Redistribution and use in source and binary forms, with or without 585365Simp * modification, are permitted provided that the following conditions 685365Simp * are met: 785365Simp * 1. Redistributions of source code must retain the above copyright 885365Simp * notice, this list of conditions and the following disclaimer. 985365Simp * 2. Redistributions in binary form must reproduce the above copyright 1085365Simp * notice, this list of conditions and the following disclaimer in the 1185365Simp * documentation and/or other materials provided with the distribution. 1285365Simp * 1385365Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1485365Simp * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1585365Simp * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1685365Simp * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 1785365Simp * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 1885365Simp * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 1985365Simp * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2085365Simp * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2185365Simp * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2285365Simp * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2385365Simp */ 2485365Simp 25119419Sobrien#include <sys/cdefs.h> 26119419Sobrien__FBSDID("$FreeBSD: releng/10.3/sys/dev/sio/sio_pci.c 227532 2011-11-15 17:15:09Z eadler $"); 27119419Sobrien 2885365Simp#include <sys/param.h> 2985365Simp#include <sys/systm.h> 3085365Simp#include <sys/bus.h> 3185365Simp#include <sys/conf.h> 3285365Simp#include <sys/kernel.h> 3385365Simp#include <sys/lock.h> 3485365Simp#include <sys/malloc.h> 3585365Simp#include <sys/mutex.h> 3685365Simp#include <sys/module.h> 3785365Simp#include <sys/tty.h> 3885365Simp#include <machine/bus.h> 3985365Simp#include <sys/timepps.h> 4085365Simp 4185365Simp#include <dev/sio/siovar.h> 4285365Simp 43119283Simp#include <dev/pci/pcivar.h> 4485365Simp 4592739Salfredstatic int sio_pci_attach(device_t dev); 4692739Salfredstatic int sio_pci_probe(device_t dev); 4785365Simp 4885365Simpstatic device_method_t sio_pci_methods[] = { 4985365Simp /* Device interface */ 5085365Simp DEVMETHOD(device_probe, sio_pci_probe), 5185365Simp DEVMETHOD(device_attach, sio_pci_attach), 52111014Simp DEVMETHOD(device_detach, siodetach), 5385365Simp 5485365Simp { 0, 0 } 5585365Simp}; 5685365Simp 5785365Simpstatic driver_t sio_pci_driver = { 5885365Simp sio_driver_name, 5985365Simp sio_pci_methods, 6086909Simp 0, 6185365Simp}; 6285365Simp 6385365Simpstruct pci_ids { 6485365Simp u_int32_t type; 6585365Simp const char *desc; 6685365Simp int rid; 6785365Simp}; 6885365Simp 6985365Simpstatic struct pci_ids pci_ids[] = { 7085365Simp { 0x100812b9, "3COM PCI FaxModem", 0x10 }, 7185365Simp { 0x2000131f, "CyberSerial (1-port) 16550", 0x10 }, 7285365Simp { 0x01101407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 }, 7385365Simp { 0x01111407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 }, 7485365Simp { 0x048011c1, "Lucent kermit based PCI Modem", 0x14 }, 7585365Simp { 0x95211415, "Oxford Semiconductor PCI Dual Port Serial", 0x10 }, 7692822Sjhb { 0x7101135e, "SeaLevel Ultra 530.PCI Single Port Serial", 0x18 }, 7785365Simp { 0x0000151f, "SmartLink 5634PCV SurfRider", 0x10 }, 7892401Simp { 0x0103115d, "Xircom Cardbus modem", 0x10 }, 79227532Seadler { 0x432214e4, "Broadcom 802.11b/GPRS CardBus (Serial)", 0x10 }, 80227532Seadler { 0x434414e4, "Broadcom 802.11bg/EDGE/GPRS CardBus (Serial)", 0x10 }, 81110155Sphk { 0x01c0135c, "Quatech SSCLP-200/300", 0x18 82110155Sphk /* 83110155Sphk * NB: You must mount the "SPAD" jumper to correctly detect 84110155Sphk * the FIFO on the UART. Set the options on the jumpers, 85110155Sphk * we do not support the extra registers on the Quatech. 86110155Sphk */ 87110155Sphk }, 8885365Simp { 0x00000000, NULL, 0 } 8985365Simp}; 9085365Simp 9185365Simpstatic int 9285365Simpsio_pci_attach(dev) 9385365Simp device_t dev; 9485365Simp{ 9585365Simp u_int32_t type; 9685365Simp struct pci_ids *id; 9785365Simp 9885365Simp type = pci_get_devid(dev); 9985365Simp id = pci_ids; 10085365Simp while (id->type && id->type != type) 10185365Simp id++; 10285365Simp if (id->desc == NULL) 10385365Simp return (ENXIO); 10489986Sjhay return (sioattach(dev, id->rid, 0UL)); 10585365Simp} 10685365Simp 10785365Simpstatic int 10885365Simpsio_pci_probe(dev) 10985365Simp device_t dev; 11085365Simp{ 11185365Simp u_int32_t type; 11285365Simp struct pci_ids *id; 11385365Simp 11485365Simp type = pci_get_devid(dev); 11585365Simp id = pci_ids; 11685365Simp while (id->type && id->type != type) 11785365Simp id++; 11885365Simp if (id->desc == NULL) 11985365Simp return (ENXIO); 12085365Simp device_set_desc(dev, id->desc); 12190010Snyan#ifdef PC98 12290010Snyan SET_FLAG(dev, SET_IFTYPE(COM_IF_NS16550)); 12390010Snyan#endif 12489986Sjhay return (sioprobe(dev, id->rid, 0UL, 0)); 12585365Simp} 12685365Simp 12785365SimpDRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0); 128