]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/puc/puc_pccard.c
This commit was generated by cvs2svn to compensate for changes in r155420,
[FreeBSD/FreeBSD.git] / sys / dev / puc / puc_pccard.c
1 /*-
2  * Copyright (c) 2002 Poul-Henning Kamp.  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 unmodified, this list of conditions, and the following
9  *    disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
29
30 #include "opt_puc.h"
31
32 #include <sys/param.h>
33 #include <sys/systm.h>
34 #include <sys/kernel.h>
35 #include <sys/module.h>
36 #include <sys/bus.h>
37 #include <sys/conf.h>
38 #include <sys/malloc.h>
39
40 #include <machine/bus.h>
41 #include <machine/resource.h>
42 #include <sys/rman.h>
43
44 #define PUC_ENTRAILS 1
45 #include <dev/puc/pucvar.h>
46
47 #include <dev/sio/sioreg.h>
48 #include <dev/pccard/pccardvar.h>
49
50 const struct puc_device_description rscom_devices = {
51
52         "ARGOSY SP320 Dual port serial PCMCIA",
53         /* http://www.argosy.com.tw/product/sp320.htm */
54                 {       0,      0,      0,      0       },
55                 {       0,      0,      0,      0       },
56         {
57                 { PUC_PORT_TYPE_COM, 0x0, 0x00, DEFAULT_RCLK, 0x100000 },
58                 { PUC_PORT_TYPE_COM, 0x1, 0x00, DEFAULT_RCLK, 0 },
59         }
60 };
61
62
63 static int
64 puc_pccard_probe(device_t dev)
65 {
66         const char *vendor, *product;
67         int error;
68
69         error = pccard_get_vendor_str(dev, &vendor);
70         if (error)
71                 return(error);
72         error = pccard_get_product_str(dev, &product);
73         if (error)
74                 return(error);
75         if (!strcmp(vendor, "PCMCIA") && !strcmp(product, "RS-COM 2P")) {
76                 device_set_desc(dev, rscom_devices.name);
77                 return (0);
78         }
79
80         return (ENXIO);
81 }
82
83 static int
84 puc_pccard_attach(device_t dev)
85 {
86
87         return (puc_attach(dev, &rscom_devices));
88 }
89
90 static device_method_t puc_pccard_methods[] = {
91     /* Device interface */
92     DEVMETHOD(device_probe,             puc_pccard_probe),
93     DEVMETHOD(device_attach,            puc_pccard_attach),
94
95     DEVMETHOD(bus_alloc_resource,       puc_alloc_resource),
96     DEVMETHOD(bus_release_resource,     puc_release_resource),
97     DEVMETHOD(bus_get_resource,         puc_get_resource),
98     DEVMETHOD(bus_read_ivar,            puc_read_ivar),
99     DEVMETHOD(bus_setup_intr,           puc_setup_intr),
100     DEVMETHOD(bus_teardown_intr,        puc_teardown_intr),
101     DEVMETHOD(bus_print_child,          bus_generic_print_child),
102     DEVMETHOD(bus_driver_added,         bus_generic_driver_added),
103     { 0, 0 }
104 };
105
106 static driver_t puc_pccard_driver = {
107         "puc",
108         puc_pccard_methods,
109         sizeof(struct puc_softc),
110 };
111
112 DRIVER_MODULE(puc, pccard, puc_pccard_driver, puc_devclass, 0, 0);