Deleted Added
full compact
if_sn_pccard.c (119227) if_sn_pccard.c (119419)
1/*
1/*-
2 * Copyright (c) 1999 M. Warner Losh <imp@village.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2 * Copyright (c) 1999 M. Warner Losh <imp@village.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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 *
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 * $FreeBSD: head/sys/dev/sn/if_sn_pccard.c 119227 2003-08-21 17:27:49Z imp $
26 */
24 */
27
28/*
29 * Modifications for Megahertz X-Jack Ethernet Card (XJ-10BT)
30 *
31 * Copyright (c) 1996 by Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org>
32 * BSD-nomads, Tokyo, Japan.
33 */
34
25/*
26 * Modifications for Megahertz X-Jack Ethernet Card (XJ-10BT)
27 *
28 * Copyright (c) 1996 by Tatsumi Hosokawa <hosokawa@jp.FreeBSD.org>
29 * BSD-nomads, Tokyo, Japan.
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/dev/sn/if_sn_pccard.c 119419 2003-08-24 18:03:45Z obrien $");
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/socket.h>
39
40#include <sys/module.h>
41#include <sys/bus.h>
42
43#include <machine/bus.h>
44#include <machine/resource.h>
45
46#include <net/ethernet.h>
47#include <net/if.h>
48#include <net/if_arp.h>
49
50#include <dev/sn/if_snvar.h>
51#include <dev/pccard/pccardvar.h>
52#include <dev/pccard/pccarddevs.h>
53
54#include "card_if.h"
55
56static const struct pccard_product sn_pccard_products[] = {
57 PCMCIA_CARD(DSPSI, XJACK, 0),
58 PCMCIA_CARD(NEWMEDIA, BASICS, 0),
59#if 0
60 PCMCIA_CARD(SMC, 8020BT, 0),
61#endif
62 { NULL }
63};
64
65static int
66sn_pccard_match(device_t dev)
67{
68 const struct pccard_product *pp;
69
70 if ((pp = pccard_product_lookup(dev, sn_pccard_products,
71 sizeof(sn_pccard_products[0]), NULL)) != NULL) {
72 if (pp->pp_name != NULL)
73 device_set_desc(dev, pp->pp_name);
74 return 0;
75 }
76 return EIO;
77}
78
79static int
80sn_pccard_probe(device_t dev)
81{
82 int err;
83
84 err = sn_probe(dev, 1);
85 return (err);
86}
87
88static int
89sn_pccard_attach(device_t dev)
90{
91 struct sn_softc *sc = device_get_softc(dev);
92 int i;
93 u_char sum;
94 u_char ether_addr[ETHER_ADDR_LEN];
95
96 sc->pccard_enaddr = 0;
97 pccard_get_ether(dev, ether_addr);
98 for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
99 sum |= ether_addr[i];
100 if (sum) {
101 sc->pccard_enaddr = 1;
102 bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
103 }
104 return (sn_attach(dev));
105}
106
107static device_method_t sn_pccard_methods[] = {
108 /* Device interface */
109 DEVMETHOD(device_probe, pccard_compat_probe),
110 DEVMETHOD(device_attach, pccard_compat_attach),
111 DEVMETHOD(device_detach, sn_detach),
112
113 /* Card interface */
114 DEVMETHOD(card_compat_match, sn_pccard_match),
115 DEVMETHOD(card_compat_probe, sn_pccard_probe),
116 DEVMETHOD(card_compat_attach, sn_pccard_attach),
117
118 { 0, 0 }
119};
120
121static driver_t sn_pccard_driver = {
122 "sn",
123 sn_pccard_methods,
124 sizeof(struct sn_softc),
125};
126
127extern devclass_t sn_devclass;
128
129DRIVER_MODULE(sn, pccard, sn_pccard_driver, sn_devclass, 0, 0);
130MODULE_DEPEND(sn, pccard, 1, 1, 1);
131MODULE_DEPEND(sn, ether, 1, 1, 1);
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/socket.h>
39
40#include <sys/module.h>
41#include <sys/bus.h>
42
43#include <machine/bus.h>
44#include <machine/resource.h>
45
46#include <net/ethernet.h>
47#include <net/if.h>
48#include <net/if_arp.h>
49
50#include <dev/sn/if_snvar.h>
51#include <dev/pccard/pccardvar.h>
52#include <dev/pccard/pccarddevs.h>
53
54#include "card_if.h"
55
56static const struct pccard_product sn_pccard_products[] = {
57 PCMCIA_CARD(DSPSI, XJACK, 0),
58 PCMCIA_CARD(NEWMEDIA, BASICS, 0),
59#if 0
60 PCMCIA_CARD(SMC, 8020BT, 0),
61#endif
62 { NULL }
63};
64
65static int
66sn_pccard_match(device_t dev)
67{
68 const struct pccard_product *pp;
69
70 if ((pp = pccard_product_lookup(dev, sn_pccard_products,
71 sizeof(sn_pccard_products[0]), NULL)) != NULL) {
72 if (pp->pp_name != NULL)
73 device_set_desc(dev, pp->pp_name);
74 return 0;
75 }
76 return EIO;
77}
78
79static int
80sn_pccard_probe(device_t dev)
81{
82 int err;
83
84 err = sn_probe(dev, 1);
85 return (err);
86}
87
88static int
89sn_pccard_attach(device_t dev)
90{
91 struct sn_softc *sc = device_get_softc(dev);
92 int i;
93 u_char sum;
94 u_char ether_addr[ETHER_ADDR_LEN];
95
96 sc->pccard_enaddr = 0;
97 pccard_get_ether(dev, ether_addr);
98 for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
99 sum |= ether_addr[i];
100 if (sum) {
101 sc->pccard_enaddr = 1;
102 bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
103 }
104 return (sn_attach(dev));
105}
106
107static device_method_t sn_pccard_methods[] = {
108 /* Device interface */
109 DEVMETHOD(device_probe, pccard_compat_probe),
110 DEVMETHOD(device_attach, pccard_compat_attach),
111 DEVMETHOD(device_detach, sn_detach),
112
113 /* Card interface */
114 DEVMETHOD(card_compat_match, sn_pccard_match),
115 DEVMETHOD(card_compat_probe, sn_pccard_probe),
116 DEVMETHOD(card_compat_attach, sn_pccard_attach),
117
118 { 0, 0 }
119};
120
121static driver_t sn_pccard_driver = {
122 "sn",
123 sn_pccard_methods,
124 sizeof(struct sn_softc),
125};
126
127extern devclass_t sn_devclass;
128
129DRIVER_MODULE(sn, pccard, sn_pccard_driver, sn_devclass, 0, 0);
130MODULE_DEPEND(sn, pccard, 1, 1, 1);
131MODULE_DEPEND(sn, ether, 1, 1, 1);