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