puc_pccard.c revision 160030
1102714Sphk/*- 2102714Sphk * Copyright (c) 2002 Poul-Henning Kamp. All rights reserved. 3102714Sphk * 4102714Sphk * Redistribution and use in source and binary forms, with or without 5102714Sphk * modification, are permitted provided that the following conditions 6102714Sphk * are met: 7102714Sphk * 1. Redistributions of source code must retain the above copyright 8102714Sphk * notice unmodified, this list of conditions, and the following 9102714Sphk * disclaimer. 10102714Sphk * 2. Redistributions in binary form must reproduce the above copyright 11102714Sphk * notice, this list of conditions and the following disclaimer in the 12102714Sphk * documentation and/or other materials provided with the distribution. 13102714Sphk * 14102714Sphk * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15102714Sphk * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16102714Sphk * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17102714Sphk * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18102714Sphk * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19102714Sphk * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20102714Sphk * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21102714Sphk * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22102714Sphk * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23102714Sphk * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24102714Sphk * 25102714Sphk */ 26102714Sphk 27119418Sobrien#include <sys/cdefs.h> 28119418Sobrien__FBSDID("$FreeBSD: head/sys/dev/puc/puc_pccard.c 160030 2006-06-29 16:27:19Z obrien $"); 29119418Sobrien 30102714Sphk#include <sys/param.h> 31102714Sphk#include <sys/systm.h> 32102714Sphk#include <sys/kernel.h> 33129879Sphk#include <sys/module.h> 34102714Sphk#include <sys/bus.h> 35102714Sphk#include <sys/conf.h> 36102714Sphk#include <sys/malloc.h> 37102714Sphk 38102714Sphk#include <machine/bus.h> 39102714Sphk#include <machine/resource.h> 40102714Sphk#include <sys/rman.h> 41102714Sphk 42102714Sphk#include <dev/pccard/pccardvar.h> 43102714Sphk 44160030Sobrien#include <dev/puc/puc_cfg.h> 45158124Smarcel#include <dev/puc/puc_bfe.h> 46102714Sphk 47158124Smarcel/* http://www.argosy.com.tw/product/sp320.htm */ 48158124Smarcelconst struct puc_cfg puc_pccard_rscom = { 49158124Smarcel 0, 0, 0, 0, 50102897Sphk "ARGOSY SP320 Dual port serial PCMCIA", 51158124Smarcel DEFAULT_RCLK, 52158124Smarcel PUC_PORT_2S, 0, 1, 0, 53102714Sphk}; 54102714Sphk 55102714Sphkstatic int 56102714Sphkpuc_pccard_probe(device_t dev) 57102714Sphk{ 58121604Simp const char *vendor, *product; 59102714Sphk int error; 60102714Sphk 61102714Sphk error = pccard_get_vendor_str(dev, &vendor); 62102714Sphk if (error) 63102714Sphk return(error); 64102714Sphk error = pccard_get_product_str(dev, &product); 65102714Sphk if (error) 66102714Sphk return(error); 67158124Smarcel if (!strcmp(vendor, "PCMCIA") && !strcmp(product, "RS-COM 2P")) 68158124Smarcel return (puc_bfe_probe(dev, &puc_pccard_rscom)); 69102714Sphk 70102714Sphk return (ENXIO); 71102714Sphk} 72102714Sphk 73102714Sphkstatic device_method_t puc_pccard_methods[] = { 74102714Sphk /* Device interface */ 75102714Sphk DEVMETHOD(device_probe, puc_pccard_probe), 76158124Smarcel DEVMETHOD(device_attach, puc_bfe_attach), 77158124Smarcel DEVMETHOD(device_detach, puc_bfe_detach), 78102714Sphk 79158124Smarcel DEVMETHOD(bus_alloc_resource, puc_bus_alloc_resource), 80158124Smarcel DEVMETHOD(bus_release_resource, puc_bus_release_resource), 81158124Smarcel DEVMETHOD(bus_get_resource, puc_bus_get_resource), 82158124Smarcel DEVMETHOD(bus_read_ivar, puc_bus_read_ivar), 83158124Smarcel DEVMETHOD(bus_setup_intr, puc_bus_setup_intr), 84158124Smarcel DEVMETHOD(bus_teardown_intr, puc_bus_teardown_intr), 85102714Sphk DEVMETHOD(bus_print_child, bus_generic_print_child), 86102714Sphk DEVMETHOD(bus_driver_added, bus_generic_driver_added), 87102714Sphk { 0, 0 } 88102714Sphk}; 89102714Sphk 90102714Sphkstatic driver_t puc_pccard_driver = { 91158124Smarcel puc_driver_name, 92102714Sphk puc_pccard_methods, 93102714Sphk sizeof(struct puc_softc), 94102714Sphk}; 95102714Sphk 96102714SphkDRIVER_MODULE(puc, pccard, puc_pccard_driver, puc_devclass, 0, 0); 97