1 /* $NecBSD: tmc18c30_pisa.c,v 1.22 1998/11/26 01:59:21 honda Exp $ */
2 /* $NetBSD$ */
3
4 /*-
5 * [Ported for FreeBSD]
6 * Copyright (c) 2000
7 * Noriaki Mitsunaga, Mitsuru Iwasaki and Takanori Watanabe.
8 * All rights reserved.
9 * [NetBSD for NEC PC-98 series]
10 * Copyright (c) 1996, 1997, 1998
11 * NetBSD/pc98 porting staff. All rights reserved.
12 * Copyright (c) 1996, 1997, 1998
13 * Naofumi HONDA. All rights reserved.
14 * Copyright (c) 1996, 1997, 1998
15 * Kouichi Matsuda. All rights reserved.
16 *
17 * Redistribution and use in source and binary forms, with or without
18 * modification, are permitted provided that the following conditions
19 * are met:
20 * 1. Redistributions of source code must retain the above copyright
21 * notice, this list of conditions and the following disclaimer.
22 * 2. Redistributions in binary form must reproduce the above copyright
23 * notice, this list of conditions and the following disclaimer in the
24 * documentation and/or other materials provided with the distribution.
25 * 3. The name of the author may not be used to endorse or promote products
26 * derived from this software without specific prior written permission.
27 *
28 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
29 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
32 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
39 */
40
41 #include <sys/cdefs.h>
42 __FBSDID("$FreeBSD: releng/11.2/sys/dev/stg/tmc18c30_pccard.c 331722 2018-03-29 02:50:57Z eadler $");
43
44 #include <sys/param.h>
45 #include <sys/errno.h>
46 #include <sys/kernel.h>
47 #include <sys/malloc.h>
48 #include <sys/module.h>
49 #include <sys/systm.h>
50
51 #include <machine/bus.h>
52
53 #include <sys/bus.h>
54
55 #include <dev/pccard/pccardvar.h>
56
57 #include <cam/scsi/scsi_low.h>
58
59 #include <dev/stg/tmc18c30reg.h>
60 #include <dev/stg/tmc18c30var.h>
61 #include <dev/stg/tmc18c30.h>
62
63 #include "pccarddevs.h"
64
65 static const struct pccard_product stg_products[] = {
66 PCMCIA_CARD(FUTUREDOMAIN, SCSI2GO),
67 PCMCIA_CARD(IBM, SCSICARD),
68 PCMCIA_CARD(RATOC, REX5536),
69 PCMCIA_CARD(RATOC, REX5536AM),
70 PCMCIA_CARD(RATOC, REX5536M),
71 { NULL }
72 };
73
74 /*
75 * Additional code for FreeBSD new-bus PC Card frontend
76 */
77 static int
78 stg_pccard_probe(device_t dev)
79 {
80 const struct pccard_product *pp;
81
82 if ((pp = pccard_product_lookup(dev, stg_products,
83 sizeof(stg_products[0]), NULL)) != NULL) {
84 if (pp->pp_name != NULL)
85 device_set_desc(dev, pp->pp_name);
86 return (BUS_PROBE_DEFAULT);
87 }
88 return(EIO);
89 }
90
91 static int
92 stg_pccard_attach(device_t dev)
93 {
94 struct stg_softc *sc = device_get_softc(dev);
95 int error;
96
97 sc->port_rid = 0;
98 sc->irq_rid = 0;
99 error = stg_alloc_resource(dev);
100 if (error) {
101 return(error);
102 }
103
104 if (stg_probe(dev) == 0) {
105 stg_release_resource(dev);
106 return(ENXIO);
107 }
108 error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_CAM | INTR_ENTROPY |
109 INTR_MPSAFE, NULL, stg_intr, sc, &sc->stg_intrhand);
110 if (error) {
111 stg_release_resource(dev);
112 return(error);
113 }
114
115 if (stg_attach(dev) == 0) {
116 stg_release_resource(dev);
117 return(ENXIO);
118 }
119
120 return(0);
121 }
122
123 static device_method_t stg_pccard_methods[] = {
124 /* Device interface */
125 DEVMETHOD(device_probe, stg_pccard_probe),
126 DEVMETHOD(device_attach, stg_pccard_attach),
127 DEVMETHOD(device_detach, stg_detach),
128 { 0, 0 }
129 };
130
131 static driver_t stg_pccard_driver = {
132 "stg",
133 stg_pccard_methods,
134 sizeof(struct stg_softc),
135 };
136
137 DRIVER_MODULE(stg, pccard, stg_pccard_driver, stg_devclass, 0, 0);
138 MODULE_DEPEND(stg, scsi_low, 1, 1, 1);
139 PCCARD_PNP_INFO(stg_products);
Cache object: 7483c1da4f369704d8e35c4e0c3f82ce
|