1 /*-
2 * Copyright (c) 2002 The NetBSD Foundation, Inc.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Martin Husemann <martin@NetBSD.org>.
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. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the NetBSD
19 * Foundation, Inc. and its contributors.
20 * 4. Neither the name of The NetBSD Foundation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: isic_pcmcia_elsa_mcall.c,v 1.6 2003/12/04 13:57:31 keihan Exp $");
39
40 #include "opt_isicpcmcia.h"
41 #ifdef ISICPCMCIA_ELSA_MCALL
42
43 #include <sys/param.h>
44 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
45 #include <sys/ioccom.h>
46 #else
47 #include <sys/ioctl.h>
48 #endif
49 #include <sys/kernel.h>
50 #include <sys/systm.h>
51 #include <sys/mbuf.h>
52
53 #ifdef __FreeBSD__
54 #include <machine/clock.h>
55 #include <i386/isa/isa_device.h>
56 #else
57 #include <machine/bus.h>
58 #include <sys/device.h>
59 #endif
60
61 #include <sys/socket.h>
62 #include <net/if.h>
63
64 #if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
65 #include <sys/callout.h>
66 #endif
67
68 #ifdef __FreeBSD__
69 #include <machine/i4b_debug.h>
70 #include <machine/i4b_ioctl.h>
71 #else
72 #include <netisdn/i4b_debug.h>
73 #include <netisdn/i4b_ioctl.h>
74
75 #include <dev/pcmcia/pcmciareg.h>
76 #include <dev/pcmcia/pcmciavar.h>
77 #endif
78
79 #include <netisdn/i4b_l2.h>
80 #include <netisdn/i4b_l1l2.h>
81 #include <dev/ic/isic_l1.h>
82 #include <dev/ic/isac.h>
83 #include <dev/ic/hscx.h>
84 #include <dev/ic/ipac.h>
85
86 #include <dev/pcmcia/isic_pcmcia.h>
87
88 #ifndef __FreeBSD__
89 /* PCMCIA support routines */
90 static u_int8_t elsa_mcall_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs));
91 static void elsa_mcall_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data));
92 static void elsa_mcall_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size));
93 static void elsa_mcall_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size));
94 #endif
95
96 /*---------------------------------------------------------------------------*
97 * read fifo routines
98 *---------------------------------------------------------------------------*/
99 #ifdef __FreeBSD__
100 static int PCMCIA_IO_BASE = 0; /* ap: XXX hack */
101 static void
102 elsa_mcall_read_fifo(void *buf, const void *base, size_t len)
103 {
104 }
105 #else
106 static void
107 elsa_mcall_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size)
108 {
109 /*
110 bus_space_tag_t t = sc->sc_maps[0].t;
111 bus_space_handle_t h = sc->sc_maps[0].h;
112 */
113 }
114 #endif
115
116 /*---------------------------------------------------------------------------*
117 * write fifo routines
118 *---------------------------------------------------------------------------*/
119 #ifdef __FreeBSD__
120 static void
121 elsa_mcall_write_fifo(void *base, const void *buf, size_t len)
122 {
123 }
124 #else
125 static void
126 elsa_mcall_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size)
127 {
128 /*
129 bus_space_tag_t t = sc->sc_maps[0].t;
130 bus_space_handle_t h = sc->sc_maps[0].h;
131 */
132 }
133 #endif
134
135 /*---------------------------------------------------------------------------*
136 * write register routines
137 *---------------------------------------------------------------------------*/
138 #ifdef __FreeBSD__
139 static void
140 elsa_mcall_write_reg(u_char *base, u_int offset, u_int v)
141 {
142 }
143 #else
144 static void
145 elsa_mcall_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)
146 {
147 /*
148 bus_space_tag_t t = sc->sc_maps[0].t;
149 bus_space_handle_t h = sc->sc_maps[0].h;
150 */
151 }
152 #endif
153
154 /*---------------------------------------------------------------------------*
155 * read register routines
156 *---------------------------------------------------------------------------*/
157 #ifdef __FreeBSD__
158 static u_char
159 elsa_mcall_read_reg(u_char *base, u_int offset)
160 {
161 return 0;
162 }
163 #else
164 static u_int8_t
165 elsa_mcall_read_reg(struct isic_softc *sc, int what, bus_size_t offs)
166 {
167 /*
168 bus_space_tag_t t = sc->sc_maps[0].t;
169 bus_space_handle_t h = sc->sc_maps[0].h;
170 */
171 return 0;
172 }
173 #endif
174
175 #ifdef __FreeBSD__
176 #else
177
178 /*
179 * XXX - one time only! Some of this has to go into an enable
180 * function, with apropriate counterpart in disable, so a card
181 * could be removed an inserted again.
182 */
183 int
184 isic_attach_elsamcall(struct pcmcia_isic_softc *psc, struct pcmcia_config_entry *cfe, struct pcmcia_attach_args *pa)
185 {
186 struct isic_softc *sc = &psc->sc_isic;
187 bus_space_tag_t t;
188 bus_space_handle_t h;
189
190 /* Validate config info */
191 if (cfe->num_memspace != 0)
192 printf(": unexpected number of memory spaces %d should be 0\n",
193 cfe->num_memspace);
194 if (cfe->num_iospace != 1)
195 printf(": unexpected number of memory spaces %d should be 1\n",
196 cfe->num_iospace);
197
198 /* Allocate pcmcia space */
199 if (pcmcia_io_alloc(pa->pf, 0, cfe->iospace[0].length,
200 cfe->iospace[0].length, &psc->sc_pcioh))
201 printf(": can't allocate i/o space\n");
202
203 /* map them */
204 if (pcmcia_io_map(pa->pf, ((cfe->flags & PCMCIA_CFE_IO16) ?
205 PCMCIA_WIDTH_IO16 : PCMCIA_WIDTH_IO8), 0,
206 cfe->iospace[0].length, &psc->sc_pcioh, &psc->sc_io_window)) {
207 printf(": can't map i/o space\n");
208 return 0;
209 }
210
211 /* Setup bus space maps */
212 sc->sc_num_mappings = 1;
213 MALLOC_MAPS(sc);
214
215 /* Copy our handles/tags to the MI maps */
216 sc->sc_maps[0].t = psc->sc_pcioh.iot;
217 sc->sc_maps[0].h = psc->sc_pcioh.ioh;
218 sc->sc_maps[0].offset = 0;
219 sc->sc_maps[0].size = 0; /* not our mapping */
220
221 t = sc->sc_maps[0].t;
222 h = sc->sc_maps[0].h;
223
224 sc->clearirq = NULL;
225 sc->readreg = elsa_mcall_read_reg;
226 sc->writereg = elsa_mcall_write_reg;
227
228 sc->readfifo = elsa_mcall_read_fifo;
229 sc->writefifo = elsa_mcall_write_fifo;
230
231 /* setup IOM bus type */
232
233 sc->sc_bustyp = BUS_TYPE_IOM2;
234
235 sc->sc_ipac = 1;
236 sc->sc_bfifolen = IPAC_BFIFO_LEN;
237
238 return 1;
239 }
240 #endif
241
242 #endif /* ISICPCMCIA_ELSA_MCALL */
Cache object: f10c89850eec73e7a2f7e06029546959
|