2 * Copyright (c) 1998 Martin Husemann. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following 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 * 3. Neither the name of the author nor the names of any co-contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 * 4. Altered versions must be plainly marked as such, and must not be
17 * misrepresented as being the original software and/or documentation.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 *---------------------------------------------------------------------------
33 * ELSA MicroLink MC/all card specific routines
34 * --------------------------------------------
38 * last edit-date: [Sun Feb 14 10:26:29 1999]
40 * -mh started support for ELSA MC/all
42 *---------------------------------------------------------------------------*/
51 #if NISIC > 0 && defined(ELSA_MCALL)
53 #include <sys/param.h>
54 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
55 #include <sys/ioccom.h>
57 #include <sys/ioctl.h>
59 #include <sys/kernel.h>
60 #include <sys/systm.h>
64 #include <machine/clock.h>
65 #include <i386/isa/isa_device.h>
67 #include <machine/bus.h>
68 #include <sys/device.h>
71 #include <sys/socket.h>
75 #include <machine/i4b_debug.h>
76 #include <machine/i4b_ioctl.h>
78 #include <i4b/i4b_debug.h>
79 #include <i4b/i4b_ioctl.h>
81 #include <dev/pcmcia/pcmciareg.h>
82 #include <dev/pcmcia/pcmciavar.h>
85 #include <i4b/layer1/i4b_l1.h>
86 #include <i4b/layer1/i4b_isac.h>
87 #include <i4b/layer1/i4b_hscx.h>
88 #include <i4b/layer1/i4b_ipac.h>
90 #include <i4b/layer1/pcmcia_isic.h>
93 /* PCMCIA support routines */
94 static u_int8_t elsa_mcall_read_reg __P((struct isic_softc *sc, int what, bus_size_t offs));
95 static void elsa_mcall_write_reg __P((struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data));
96 static void elsa_mcall_read_fifo __P((struct isic_softc *sc, int what, void *buf, size_t size));
97 static void elsa_mcall_write_fifo __P((struct isic_softc *sc, int what, const void *data, size_t size));
100 /*---------------------------------------------------------------------------*
102 *---------------------------------------------------------------------------*/
104 static int PCMCIA_IO_BASE = 0; /* ap: XXX hack */
106 elsa_mcall_read_fifo(void *buf, const void *base, size_t len)
111 elsa_mcall_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size)
114 bus_space_tag_t t = sc->sc_maps[0].t;
115 bus_space_handle_t h = sc->sc_maps[0].h;
120 /*---------------------------------------------------------------------------*
121 * write fifo routines
122 *---------------------------------------------------------------------------*/
125 elsa_mcall_write_fifo(void *base, const void *buf, size_t len)
130 elsa_mcall_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size)
133 bus_space_tag_t t = sc->sc_maps[0].t;
134 bus_space_handle_t h = sc->sc_maps[0].h;
139 /*---------------------------------------------------------------------------*
140 * write register routines
141 *---------------------------------------------------------------------------*/
144 elsa_mcall_write_reg(u_char *base, u_int offset, u_int v)
149 elsa_mcall_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)
152 bus_space_tag_t t = sc->sc_maps[0].t;
153 bus_space_handle_t h = sc->sc_maps[0].h;
158 /*---------------------------------------------------------------------------*
159 * read register routines
160 *---------------------------------------------------------------------------*/
163 elsa_mcall_read_reg(u_char *base, u_int offset)
169 elsa_mcall_read_reg(struct isic_softc *sc, int what, bus_size_t offs)
172 bus_space_tag_t t = sc->sc_maps[0].t;
173 bus_space_handle_t h = sc->sc_maps[0].h;
183 * XXX - one time only! Some of this has to go into an enable
184 * function, with apropriate counterpart in disable, so a card
185 * could be removed an inserted again. But never mind for now,
186 * this won't work anyway for several reasons (both in NetBSD
190 isic_attach_elsamcall(struct pcmcia_isic_softc *psc, struct pcmcia_config_entry *cfe, struct pcmcia_attach_args *pa)
192 struct isic_softc *sc = &psc->sc_isic;
194 bus_space_handle_t h;
196 /* Validate config info */
197 if (cfe->num_memspace != 0)
198 printf(": unexpected number of memory spaces %d should be 0\n",
200 if (cfe->num_iospace != 1)
201 printf(": unexpected number of memory spaces %d should be 1\n",
204 /* Allocate pcmcia space */
205 if (pcmcia_io_alloc(pa->pf, 0, cfe->iospace[0].length,
206 cfe->iospace[0].length, &psc->sc_pcioh))
207 printf(": can't allocate i/o space\n");
210 if (pcmcia_io_map(pa->pf, ((cfe->flags & PCMCIA_CFE_IO16) ?
211 PCMCIA_WIDTH_IO16 : PCMCIA_WIDTH_IO8), 0,
212 cfe->iospace[0].length, &psc->sc_pcioh, &psc->sc_io_window)) {
213 printf(": can't map i/o space\n");
217 /* setup card type */
218 sc->sc_cardtyp = CARD_TYPEP_ELSAMLMCALL;
220 /* Setup bus space maps */
221 sc->sc_num_mappings = 1;
224 /* Copy our handles/tags to the MI maps */
225 sc->sc_maps[0].t = psc->sc_pcioh.iot;
226 sc->sc_maps[0].h = psc->sc_pcioh.ioh;
227 sc->sc_maps[0].offset = 0;
228 sc->sc_maps[0].size = 0; /* not our mapping */
230 t = sc->sc_maps[0].t;
231 h = sc->sc_maps[0].h;
234 sc->readreg = elsa_mcall_read_reg;
235 sc->writereg = elsa_mcall_write_reg;
237 sc->readfifo = elsa_mcall_read_fifo;
238 sc->writefifo = elsa_mcall_write_fifo;
240 /* setup IOM bus type */
242 sc->sc_bustyp = BUS_TYPE_IOM2;
245 sc->sc_bfifolen = IPAC_BFIFO_LEN;
251 #endif /* NISIC > 0 */