]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/i4b/layer1/i4b_elsa_mcall.c
This commit was generated by cvs2svn to compensate for changes in r56067,
[FreeBSD/FreeBSD.git] / sys / i4b / layer1 / i4b_elsa_mcall.c
1 /*
2  *   Copyright (c) 1998 Martin Husemann. All rights reserved.
3  *
4  *   Redistribution and use in source and binary forms, with or without
5  *   modification, are permitted provided that the following conditions
6  *   are met:
7  *
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.
18  *   
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
29  *   SUCH DAMAGE.
30  *
31  *---------------------------------------------------------------------------
32  *
33  *      ELSA MicroLink MC/all card specific routines
34  *      --------------------------------------------
35  *
36  * $FreeBSD$
37  *
38  *      last edit-date: [Sun Feb 14 10:26:29 1999]
39  *
40  *      -mh     started support for ELSA MC/all
41  *
42  *---------------------------------------------------------------------------*/
43
44 #ifdef __FreeBSD__
45 #include "isic.h"
46 #include "opt_i4b.h"
47 #else
48 #define NISIC   1
49 #endif
50
51 #if NISIC > 0 && defined(ELSA_MCALL)
52
53 #include <sys/param.h>
54 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
55 #include <sys/ioccom.h>
56 #else
57 #include <sys/ioctl.h>
58 #endif
59 #include <sys/kernel.h>
60 #include <sys/systm.h>
61 #include <sys/mbuf.h>
62
63 #ifdef __FreeBSD__
64 #include <machine/clock.h>
65 #include <i386/isa/isa_device.h>
66 #else
67 #include <machine/bus.h>
68 #include <sys/device.h>
69 #endif
70
71 #include <sys/socket.h>
72 #include <net/if.h>
73
74 #ifdef __FreeBSD__
75 #include <machine/i4b_debug.h>
76 #include <machine/i4b_ioctl.h>
77 #else
78 #include <i4b/i4b_debug.h>
79 #include <i4b/i4b_ioctl.h>
80
81 #include <dev/pcmcia/pcmciareg.h>
82 #include <dev/pcmcia/pcmciavar.h>
83 #endif
84
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>
89
90 #include <i4b/layer1/pcmcia_isic.h>
91
92 #ifndef __FreeBSD__
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));
98 #endif
99
100 /*---------------------------------------------------------------------------*
101  *      read fifo routines
102  *---------------------------------------------------------------------------*/
103 #ifdef __FreeBSD__
104 static int PCMCIA_IO_BASE = 0;          /* ap: XXX hack */
105 static void             
106 elsa_mcall_read_fifo(void *buf, const void *base, size_t len)
107 {
108 }
109 #else
110 static void
111 elsa_mcall_read_fifo(struct isic_softc *sc, int what, void *buf, size_t size)
112 {
113         /*
114         bus_space_tag_t t = sc->sc_maps[0].t;
115         bus_space_handle_t h = sc->sc_maps[0].h;
116         */
117 }
118 #endif
119
120 /*---------------------------------------------------------------------------*
121  *      write fifo routines
122  *---------------------------------------------------------------------------*/
123 #ifdef __FreeBSD__
124 static void
125 elsa_mcall_write_fifo(void *base, const void *buf, size_t len)
126 {
127 }
128 #else
129 static void
130 elsa_mcall_write_fifo(struct isic_softc *sc, int what, const void *buf, size_t size)
131 {
132         /*
133         bus_space_tag_t t = sc->sc_maps[0].t;
134         bus_space_handle_t h = sc->sc_maps[0].h;
135         */
136 }
137 #endif
138
139 /*---------------------------------------------------------------------------*
140  *      write register routines
141  *---------------------------------------------------------------------------*/
142 #ifdef __FreeBSD__
143 static void
144 elsa_mcall_write_reg(u_char *base, u_int offset, u_int v)
145 {
146 }
147 #else
148 static void
149 elsa_mcall_write_reg(struct isic_softc *sc, int what, bus_size_t offs, u_int8_t data)
150 {
151         /*
152         bus_space_tag_t t = sc->sc_maps[0].t;
153         bus_space_handle_t h = sc->sc_maps[0].h;
154         */
155 }
156 #endif
157
158 /*---------------------------------------------------------------------------*
159  *      read register routines
160  *---------------------------------------------------------------------------*/
161 #ifdef __FreeBSD__
162 static u_char
163 elsa_mcall_read_reg(u_char *base, u_int offset)
164 {
165         return 0;
166 }
167 #else
168 static u_int8_t
169 elsa_mcall_read_reg(struct isic_softc *sc, int what, bus_size_t offs)
170 {
171         /*
172         bus_space_tag_t t = sc->sc_maps[0].t;
173         bus_space_handle_t h = sc->sc_maps[0].h;
174         */
175         return 0;
176 }
177 #endif
178
179 #ifdef __FreeBSD__
180 #else
181
182 /*
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
187  * and in I4B).
188  */
189 int
190 isic_attach_elsamcall(struct pcmcia_isic_softc *psc, struct pcmcia_config_entry *cfe, struct pcmcia_attach_args *pa)
191 {
192         struct isic_softc *sc = &psc->sc_isic;
193         bus_space_tag_t t;
194         bus_space_handle_t h;
195
196         /* Validate config info */
197         if (cfe->num_memspace != 0)
198                 printf(": unexpected number of memory spaces %d should be 0\n",
199                         cfe->num_memspace);
200         if (cfe->num_iospace != 1)
201                 printf(": unexpected number of memory spaces %d should be 1\n",
202                         cfe->num_iospace);
203
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");
208
209         /* map them */
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");
214                 return 0;
215         }
216
217         /* setup card type */
218         sc->sc_cardtyp = CARD_TYPEP_ELSAMLMCALL;
219
220         /* Setup bus space maps */
221         sc->sc_num_mappings = 1;
222         MALLOC_MAPS(sc);
223
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 */
229
230         t = sc->sc_maps[0].t;
231         h = sc->sc_maps[0].h;
232
233         sc->clearirq = NULL;
234         sc->readreg = elsa_mcall_read_reg;
235         sc->writereg = elsa_mcall_write_reg;
236
237         sc->readfifo = elsa_mcall_read_fifo;
238         sc->writefifo = elsa_mcall_write_fifo;
239
240         /* setup IOM bus type */
241         
242         sc->sc_bustyp = BUS_TYPE_IOM2;
243
244         sc->sc_ipac = 1;
245         sc->sc_bfifolen = IPAC_BFIFO_LEN;
246
247         return 1;
248 }
249 #endif
250
251 #endif /* NISIC > 0 */