Deleted Added
full compact
if_fe_pccard.c (150458) if_fe_pccard.c (151638)
1/*-
2 * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
3 *
4 * This software may be used, modified, copied, distributed, and sold, in
5 * both source and binary form provided that the above copyright, these
6 * terms and the following disclaimer are retained. The name of the author
7 * and/or the contributor may not be used to endorse or promote products
8 * derived from this software without specific prior written permission.

--- 8 unchanged lines hidden (view full) ---

17 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
19 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
20 * SUCH DAMAGE.
21 *
22 */
23
24#include <sys/cdefs.h>
1/*-
2 * All Rights Reserved, Copyright (C) Fujitsu Limited 1995
3 *
4 * This software may be used, modified, copied, distributed, and sold, in
5 * both source and binary form provided that the above copyright, these
6 * terms and the following disclaimer are retained. The name of the author
7 * and/or the contributor may not be used to endorse or promote products
8 * derived from this software without specific prior written permission.

--- 8 unchanged lines hidden (view full) ---

17 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
18 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
19 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
20 * SUCH DAMAGE.
21 *
22 */
23
24#include <sys/cdefs.h>
25__FBSDID("$FreeBSD: head/sys/dev/fe/if_fe_pccard.c 150458 2005-09-22 05:52:54Z imp $");
25__FBSDID("$FreeBSD: head/sys/dev/fe/if_fe_pccard.c 151638 2005-10-25 03:49:24Z imp $");
26
27#include <sys/param.h>
28#include <sys/kernel.h>
29#include <sys/socket.h>
30#include <sys/systm.h>
31#include <sys/module.h>
32
33#include <sys/bus.h>

--- 25 unchanged lines hidden (view full) ---

59static int fe_pccard_probe(device_t);
60static int fe_pccard_attach(device_t);
61static int fe_pccard_detach(device_t);
62
63static const struct fe_pccard_product {
64 struct pccard_product mpp_product;
65 int mpp_flags;
66#define MPP_MBH10302 1
26
27#include <sys/param.h>
28#include <sys/kernel.h>
29#include <sys/socket.h>
30#include <sys/systm.h>
31#include <sys/module.h>
32
33#include <sys/bus.h>

--- 25 unchanged lines hidden (view full) ---

59static int fe_pccard_probe(device_t);
60static int fe_pccard_attach(device_t);
61static int fe_pccard_detach(device_t);
62
63static const struct fe_pccard_product {
64 struct pccard_product mpp_product;
65 int mpp_flags;
66#define MPP_MBH10302 1
67#define MPP_ANYFUNC 2
67} fe_pccard_products[] = {
68 /* These need to be first */
69 { PCMCIA_CARD(FUJITSU2, FMV_J181), MPP_MBH10302 },
70 { PCMCIA_CARD(FUJITSU2, FMV_J182), 0 },
71 { PCMCIA_CARD(FUJITSU2, FMV_J182A), 0 },
72 { PCMCIA_CARD(FUJITSU2, ITCFJ182A), 0 },
73 /* These need to be second */
74 { PCMCIA_CARD(TDK, LAK_CD021BX), 0 },
75 { PCMCIA_CARD(TDK, LAK_CF010), 0 },
76#if 0 /* XXX 86960-based? */
77 { PCMCIA_CARD(TDK, LAK_DFL9610), 0 },
78#endif
79 { PCMCIA_CARD(CONTEC, CNETPC), 0 },
80 { PCMCIA_CARD(FUJITSU, LA501), 0 },
81 { PCMCIA_CARD(FUJITSU, LA10S), 0 },
82 { PCMCIA_CARD(FUJITSU, NE200T), MPP_MBH10302 },/* Sold by Eagle */
83 { PCMCIA_CARD(RATOC, REX_R280), 0 },
68} fe_pccard_products[] = {
69 /* These need to be first */
70 { PCMCIA_CARD(FUJITSU2, FMV_J181), MPP_MBH10302 },
71 { PCMCIA_CARD(FUJITSU2, FMV_J182), 0 },
72 { PCMCIA_CARD(FUJITSU2, FMV_J182A), 0 },
73 { PCMCIA_CARD(FUJITSU2, ITCFJ182A), 0 },
74 /* These need to be second */
75 { PCMCIA_CARD(TDK, LAK_CD021BX), 0 },
76 { PCMCIA_CARD(TDK, LAK_CF010), 0 },
77#if 0 /* XXX 86960-based? */
78 { PCMCIA_CARD(TDK, LAK_DFL9610), 0 },
79#endif
80 { PCMCIA_CARD(CONTEC, CNETPC), 0 },
81 { PCMCIA_CARD(FUJITSU, LA501), 0 },
82 { PCMCIA_CARD(FUJITSU, LA10S), 0 },
83 { PCMCIA_CARD(FUJITSU, NE200T), MPP_MBH10302 },/* Sold by Eagle */
84 { PCMCIA_CARD(RATOC, REX_R280), 0 },
85 { PCMCIA_CARD(XIRCOM, CE), MPP_ANYFUNC },
84 { { NULL } }
85};
86
87static int
88fe_pccard_probe(device_t dev)
89{
86 { { NULL } }
87};
88
89static int
90fe_pccard_probe(device_t dev)
91{
90 const struct pccard_product *pp;
91 int error;
92 uint32_t fcn = PCCARD_FUNCTION_UNSPEC;
92 int error;
93 uint32_t fcn = PCCARD_FUNCTION_UNSPEC;
94 const struct fe_pccard_product *pp;
93
95
94 /* Make sure we're a network function */
95 error = pccard_get_function(dev, &fcn);
96 if (error != 0)
97 return (error);
98 if (fcn != PCCARD_FUNCTION_NETWORK)
99 return (ENXIO);
100
101 if ((pp = pccard_product_lookup(dev,
96 if ((pp = (const struct fe_pccard_product *)pccard_product_lookup(dev,
102 (const struct pccard_product *)fe_pccard_products,
103 sizeof(fe_pccard_products[0]), NULL)) != NULL) {
97 (const struct pccard_product *)fe_pccard_products,
98 sizeof(fe_pccard_products[0]), NULL)) != NULL) {
104 if (pp->pp_name != NULL)
105 device_set_desc(dev, pp->pp_name);
106 return 0;
99 if (pp->mpp_product.pp_name != NULL)
100 device_set_desc(dev, pp->mpp_product.pp_name);
101 if (pp->mpp_flags & MPP_ANYFUNC)
102 return (0);
103 /* Make sure we're a network function */
104 error = pccard_get_function(dev, &fcn);
105 if (error != 0)
106 return (error);
107 if (fcn != PCCARD_FUNCTION_NETWORK)
108 return (ENXIO);
107 }
109 }
108 return EIO;
110 return (ENXIO);
109}
110
111static device_method_t fe_pccard_methods[] = {
112 /* Device interface */
113 DEVMETHOD(device_probe, fe_pccard_probe),
114 DEVMETHOD(device_attach, fe_pccard_attach),
115 DEVMETHOD(device_detach, fe_pccard_detach),
116

--- 126 unchanged lines hidden (view full) ---

243 sc->proto_dlcr7 = FE_D7_BYTSWP_LH | FE_D7_IDENT_NICE;
244
245 /* Setup hooks. We need a special initialization procedure. */
246 sc->init = fe_init_mbh;
247
248 return 0;
249}
250
111}
112
113static device_method_t fe_pccard_methods[] = {
114 /* Device interface */
115 DEVMETHOD(device_probe, fe_pccard_probe),
116 DEVMETHOD(device_attach, fe_pccard_attach),
117 DEVMETHOD(device_detach, fe_pccard_detach),
118

--- 126 unchanged lines hidden (view full) ---

245 sc->proto_dlcr7 = FE_D7_BYTSWP_LH | FE_D7_IDENT_NICE;
246
247 /* Setup hooks. We need a special initialization procedure. */
248 sc->init = fe_init_mbh;
249
250 return 0;
251}
252
253static int
254sn_pccard_xircom_mac(const struct pccard_tuple *tuple, void *argp)
255{
256 uint8_t *enaddr = argp;
257 int i;
258
259#if 1
260 /*
261 * We fail to map the CIS twice, for reasons unknown. We
262 * may fix this in the future by loading the CIS with a sane
263 * CIS from userland.
264 */
265 static uint8_t defaultmac[ETHER_ADDR_LEN] = {
266 0x00, 0x80, 0xc7, 0xed, 0x16, 0x7b};
267
268 /* Copy the MAC ADDR and return success */
269 for (i = 0; i < ETHER_ADDR_LEN; i++)
270 enaddr[i] = defaultmac[i];
271#else
272 /* FUNCE is not after FUNCID, so we gotta go find it */
273 if (tuple->code != 0x22)
274 return (0);
275
276 /* Make sure this is a sane node */
277 if (tuple->length < ETHER_ADDR_LEN + 3)
278 return (0);
279
280 /* Copy the MAC ADDR and return success */
281 for (i = 0; i < ETHER_ADDR_LEN; i++)
282 enaddr[i] = pccard_tuple_read_1(tuple, i + 3);
283#endif
284 return (1);
285}
286
251/*
252 * Probe and initialization for TDK/CONTEC PCMCIA Ethernet interface.
253 * by MASUI Kenji <masui@cs.titech.ac.jp>
254 *
255 * (Contec uses TDK Ethenet chip -- hosokawa)
256 *
257 * This version of fe_probe_tdk has been rewrote to handle
258 * *generic* PC Card implementation of Fujitsu MB8696x family. The

--- 6 unchanged lines hidden (view full) ---

265
266 static struct fe_simple_probe_struct probe_table [] = {
267 { FE_DLCR2, 0x10, 0x00 },
268 { FE_DLCR4, 0x08, 0x00 },
269 /* { FE_DLCR5, 0x80, 0x00 }, Does not work well. */
270 { 0 }
271 };
272
287/*
288 * Probe and initialization for TDK/CONTEC PCMCIA Ethernet interface.
289 * by MASUI Kenji <masui@cs.titech.ac.jp>
290 *
291 * (Contec uses TDK Ethenet chip -- hosokawa)
292 *
293 * This version of fe_probe_tdk has been rewrote to handle
294 * *generic* PC Card implementation of Fujitsu MB8696x family. The

--- 6 unchanged lines hidden (view full) ---

301
302 static struct fe_simple_probe_struct probe_table [] = {
303 { FE_DLCR2, 0x10, 0x00 },
304 { FE_DLCR4, 0x08, 0x00 },
305 /* { FE_DLCR5, 0x80, 0x00 }, Does not work well. */
306 { 0 }
307 };
308
309
273 /* C-NET(PC)C occupies 16 I/O addresses. */
274 if (fe_alloc_port(dev, 16))
275 return ENXIO;
276
277 /* Fill the softc struct with default values. */
278 fe_softc_defaults(sc);
279
280 /*

--- 4 unchanged lines hidden (view full) ---

285
286 /* Determine the card type. */
287 sc->type = FE_TYPE_TDK;
288 sc->typestr = "Generic MB8696x/78Q837x Ethernet (PCMCIA)";
289
290 pccard_get_ether(dev, sc->enaddr);
291
292 /* Make sure we got a valid station address. */
310 /* C-NET(PC)C occupies 16 I/O addresses. */
311 if (fe_alloc_port(dev, 16))
312 return ENXIO;
313
314 /* Fill the softc struct with default values. */
315 fe_softc_defaults(sc);
316
317 /*

--- 4 unchanged lines hidden (view full) ---

322
323 /* Determine the card type. */
324 sc->type = FE_TYPE_TDK;
325 sc->typestr = "Generic MB8696x/78Q837x Ethernet (PCMCIA)";
326
327 pccard_get_ether(dev, sc->enaddr);
328
329 /* Make sure we got a valid station address. */
330 if (!fe_valid_Ether_p(sc->enaddr, 0)) {
331 pccard_cis_scan(dev, sn_pccard_xircom_mac, sc->enaddr);
332 }
333
334 /* Make sure we got a valid station address. */
293 if (!fe_valid_Ether_p(sc->enaddr, 0))
294 return ENXIO;
295
296 return 0;
297}
335 if (!fe_valid_Ether_p(sc->enaddr, 0))
336 return ENXIO;
337
338 return 0;
339}