FreeBSD/Linux Kernel Cross Reference
sys/i386/isa/bs/bs_isa.c
1 /* $NecBSD: bs_isa.c,v 1.3 1997/10/31 17:43:35 honda Exp $ */
2 /* $NetBSD$ */
3 /*
4 * [NetBSD for NEC PC98 series]
5 * Copyright (c) 1995, 1996 NetBSD/pc98 porting staff.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #include <i386/Cbus/dev/bs/bsif.h>
33
34 static int bs_isa_probe __P((struct device *, void *, void *));
35 static void bs_isa_attach __P((struct device *, struct device *, void *));
36 static void bs_args_copy
37 __P((struct bs_softc *, struct isa_attach_args *, struct bshw *));
38
39 struct cfattach bs_isa_ca = {
40 sizeof(struct bs_softc), bs_isa_probe, bs_isa_attach
41 };
42
43 static void
44 bs_args_copy(bsc, ia, hw)
45 struct bs_softc *bsc;
46 struct isa_attach_args *ia;
47 struct bshw *hw;
48 {
49
50 bsc->sc_hw = hw;
51 bsc->sc_iot = ia->ia_iot;
52 bsc->sc_memt = ia->ia_memt;
53 bsc->sc_dmat = ia->ia_dmat;
54 bsc->sc_delaybah = ia->ia_delaybah; /* should be die */
55 bsc->sc_iobase = ia->ia_iobase;
56 if (ia->ia_maddr != MADDRUNK)
57 bsc->sm_offset = BSHW_SMITFIFO_OFFSET;
58 else
59 bsc->sm_offset = 0;
60
61 bsc->sc_cfgflags = DVCFG_MINOR(ia->ia_cfgflags);
62 strcpy(bsc->sc_dvname, bsc->sc_dev.dv_xname);
63 }
64
65 static int
66 bs_isa_probe(parent, match, aux)
67 struct device *parent;
68 void *match, *aux;
69 {
70 struct bs_softc *bsc = (void *) match;
71 struct isa_attach_args *ia = aux;
72 bus_space_handle_t ioh, memh = NULL;
73 bus_space_tag_t iot, memt;
74 struct bshw *hw;
75 u_int irq, drq;
76 int rv = 0;
77
78 hw = DVCFG_HW(&bshw_hwsel, DVCFG_MAJOR(ia->ia_cfgflags));
79 if (hw == NULL)
80 return rv;
81
82 iot = ia->ia_iot;
83 memt = ia->ia_memt;
84 if (ia->ia_iobase == IOBASEUNK)
85 {
86 printf("%s: iobase not specified. Assume default port(0x%x)\n",
87 bsc->sc_dvname, BSHW_DEFAULT_PORT);
88 ia->ia_iobase = BSHW_DEFAULT_PORT;
89 }
90
91 if (bus_space_map(iot, ia->ia_iobase, BSHW_IOSZ, 0, &ioh))
92 return rv;
93
94 if ((hw->hw_flags & BSHW_SMFIFO) != 0 && (ia->ia_maddr != MADDRUNK))
95 {
96 ia->ia_maddr = (ia->ia_maddr & (~((NBPG * 2) - 1))) + NBPG;
97 ia->ia_msize = NBPG;
98 if (bus_space_map(memt, ia->ia_maddr, NBPG, 0, &memh))
99 {
100 bus_space_unmap(iot, ioh, BSHW_IOSZ);
101 return 0;
102 }
103 }
104 else
105 ia->ia_maddr = MADDRUNK;
106
107 irq = IRQUNK;
108 drq = DRQUNK;
109 bsc->sc_ioh = ioh;
110 bsc->sc_memh = memh;
111 bs_args_copy(bsc, ia, hw);
112 if (bshw_board_probe(bsc, &drq, &irq))
113 goto bad;
114
115 ia->ia_irq = irq;
116 ia->ia_drq = drq;
117 ia->ia_iosize = BSHW_IOSZ;
118 rv = 1;
119
120 bad:
121 bus_space_unmap(iot, bsc->sc_ioh, BSHW_IOSZ);
122 if (ia->ia_maddr != MADDRUNK)
123 bus_space_unmap(memt, bsc->sc_memh, ia->ia_msize);
124 return rv;
125 }
126
127 static void
128 bs_isa_attach(parent, self, aux)
129 struct device *parent, *self;
130 void *aux;
131 {
132 extern struct scsi_adapter pc98texa55bs;
133 extern struct scsi_device bs_dev;
134 struct bs_softc *bsc = (void *) self;
135 struct isa_attach_args *ia = aux;
136 bus_space_tag_t iot, memt;
137 struct bshw *hw;
138 int i;
139
140 printf("\n");
141
142 hw = DVCFG_HW(&bshw_hwsel, DVCFG_MAJOR(ia->ia_cfgflags));
143 iot = ia->ia_iot;
144 memt = ia->ia_memt;
145
146 if (bus_space_map(iot, ia->ia_iobase, BSHW_IOSZ, 0, &bsc->sc_ioh))
147 panic("%s: bus io map failed\n", bsc->sc_dev.dv_xname);
148
149 if (ia->ia_maddr != MADDRUNK &&
150 bus_space_map(memt, ia->ia_maddr, NBPG, 0, &bsc->sc_memh))
151 panic("%s: bus mem map failed\n", bsc->sc_dev.dv_xname);
152
153 if (isa_dmamap_create(NULL, ia->ia_drq, MAXBSIZE, BUS_DMA_NOWAIT))
154 {
155 printf("%s: can't set up ISA DMA map\n", bsc->sc_dev.dv_xname);
156 return;
157 }
158
159 /* system initialize */
160 bs_args_copy(bsc, ia, hw);
161 bs_hostque_init(bsc);
162 for (i = 0; i < NTARGETS; i++)
163 {
164 if (i != bsc->sc_hostid)
165 bs_init_target_info(bsc, i);
166 }
167
168 bs_init_ccbque(BS_MAX_CCB);
169 bsc->sc_hstate = BSC_BOOTUP;
170 bsc->sc_retry = RETRIES;
171 bsc->sc_wc = delaycount * 250;
172 bs_reset_nexus(bsc);
173
174 /* link upper layer */
175 bsc->sc_link.adapter_target = bsc->sc_hostid;
176 bsc->sc_link.openings = XSMAX;
177 bsc->sc_link.max_target = 7;
178 bsc->sc_link.channel = SCSI_CHANNEL_ONLY_ONE;
179 bsc->sc_link.adapter_softc = bsc;
180 bsc->sc_link.adapter = &pc98texa55bs;
181 bsc->sc_link.device = &bs_dev;
182
183 config_found(self, &bsc->sc_link, bsprint);
184
185 bsc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE,
186 IPL_BIO, bsintr, bsc);
187 bs_start_timeout(bsc);
188 }
Cache object: 8f2d95cd2510603e46b1355adbfdadb1
|