if_fe_pccard.c (189681) | if_fe_pccard.c (189728) |
---|---|
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 189681 2009-03-11 08:12:28Z imp $"); | 25__FBSDID("$FreeBSD: head/sys/dev/fe/if_fe_pccard.c 189728 2009-03-12 07:18:27Z 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> --- 21 unchanged lines hidden (view full) --- 55/* 56 * PC Card (PCMCIA) specific code. 57 */ 58static int fe_pccard_probe(device_t); 59static int fe_pccard_attach(device_t); 60static int fe_pccard_detach(device_t); 61 62static const struct fe_pccard_product { | 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> --- 21 unchanged lines hidden (view full) --- 55/* 56 * PC Card (PCMCIA) specific code. 57 */ 58static int fe_pccard_probe(device_t); 59static int fe_pccard_attach(device_t); 60static int fe_pccard_detach(device_t); 61 62static const struct fe_pccard_product { |
63 struct pccard_product mpp_product; | 63 struct pccard_product mpp_product; |
64 int mpp_flags; 65#define MPP_MBH10302 1 66#define MPP_ANYFUNC 2 67#define MPP_SKIP_TO_CFE_10 4 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 */ | 64 int mpp_flags; 65#define MPP_MBH10302 1 66#define MPP_ANYFUNC 2 67#define MPP_SKIP_TO_CFE_10 4 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 }, | 75 { PCMCIA_CARD(TDK, LAK_CD021BX), 0 }, 76 { PCMCIA_CARD(TDK, LAK_CF010), 0 }, |
77#if 0 /* XXX 86960-based? */ | 77#if 0 /* XXX 86960-based? */ |
78 { PCMCIA_CARD(TDK, LAK_DFL9610), 0 }, | 78 { PCMCIA_CARD(TDK, LAK_DFL9610), 0 }, |
79#endif | 79#endif |
80 { PCMCIA_CARD(CONTEC, CNETPC), 0 }, | 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(HITACHI, HT_4840), MPP_MBH10302 | MPP_SKIP_TO_CFE_10}, 85 { PCMCIA_CARD(RATOC, REX_R280), 0 }, 86 { PCMCIA_CARD(XIRCOM, CE), MPP_ANYFUNC }, | 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(HITACHI, HT_4840), MPP_MBH10302 | MPP_SKIP_TO_CFE_10}, 85 { PCMCIA_CARD(RATOC, REX_R280), 0 }, 86 { PCMCIA_CARD(XIRCOM, CE), MPP_ANYFUNC }, |
87 { { NULL } } | 87 { { NULL } } |
88}; 89 90static int 91fe_pccard_probe(device_t dev) 92{ 93 int error; 94 uint32_t fcn = PCCARD_FUNCTION_UNSPEC; | 88}; 89 90static int 91fe_pccard_probe(device_t dev) 92{ 93 int error; 94 uint32_t fcn = PCCARD_FUNCTION_UNSPEC; |
95 const struct fe_pccard_product *pp; | 95 const struct fe_pccard_product *pp; |
96 int i; 97 | 96 int i; 97 |
98 if ((pp = (const struct fe_pccard_product *)pccard_product_lookup(dev, 99 (const struct pccard_product *)fe_pccard_products, 100 sizeof(fe_pccard_products[0]), NULL)) != NULL) { | 98 if ((pp = (const struct fe_pccard_product *)pccard_product_lookup(dev, 99 (const struct pccard_product *)fe_pccard_products, 100 sizeof(fe_pccard_products[0]), NULL)) != NULL) { |
101 if (pp->mpp_product.pp_name != NULL) 102 device_set_desc(dev, pp->mpp_product.pp_name); 103 if (pp->mpp_flags & MPP_ANYFUNC) 104 return (0); 105 /* Make sure we're a network function */ 106 error = pccard_get_function(dev, &fcn); 107 if (error != 0) 108 return (error); --- 5 unchanged lines hidden (view full) --- 114 goto good; 115 } 116 device_printf(dev, 117 "Hitachi HT-4840-11 workaround failed\n"); 118 return ENXIO; 119 } 120 good:; 121 return (0); | 101 if (pp->mpp_product.pp_name != NULL) 102 device_set_desc(dev, pp->mpp_product.pp_name); 103 if (pp->mpp_flags & MPP_ANYFUNC) 104 return (0); 105 /* Make sure we're a network function */ 106 error = pccard_get_function(dev, &fcn); 107 if (error != 0) 108 return (error); --- 5 unchanged lines hidden (view full) --- 114 goto good; 115 } 116 device_printf(dev, 117 "Hitachi HT-4840-11 workaround failed\n"); 118 return ENXIO; 119 } 120 good:; 121 return (0); |
122 } 123 return (ENXIO); | 122 } 123 return (ENXIO); |
124} 125 126static device_method_t fe_pccard_methods[] = { | 124} 125 126static device_method_t fe_pccard_methods[] = { |
127 /* Device interface */ 128 DEVMETHOD(device_probe, fe_pccard_probe), 129 DEVMETHOD(device_attach, fe_pccard_attach), 130 DEVMETHOD(device_detach, fe_pccard_detach), | 127 /* Device interface */ 128 DEVMETHOD(device_probe, fe_pccard_probe), 129 DEVMETHOD(device_attach, fe_pccard_attach), 130 DEVMETHOD(device_detach, fe_pccard_detach), |
131 132 { 0, 0 } 133}; 134 135static driver_t fe_pccard_driver = { 136 "fe", 137 fe_pccard_methods, 138 sizeof (struct fe_softc) 139}; 140 141DRIVER_MODULE(fe, pccard, fe_pccard_driver, fe_devclass, 0, 0); 142MODULE_DEPEND(fe, pccard, 1, 1, 1); 143 144static int fe_probe_mbh(device_t, const struct fe_pccard_product *); 145static int fe_probe_tdk(device_t, const struct fe_pccard_product *); | 131 132 { 0, 0 } 133}; 134 135static driver_t fe_pccard_driver = { 136 "fe", 137 fe_pccard_methods, 138 sizeof (struct fe_softc) 139}; 140 141DRIVER_MODULE(fe, pccard, fe_pccard_driver, fe_devclass, 0, 0); 142MODULE_DEPEND(fe, pccard, 1, 1, 1); 143 144static int fe_probe_mbh(device_t, const struct fe_pccard_product *); 145static int fe_probe_tdk(device_t, const struct fe_pccard_product *); |
146/* 147 * Initialize the device - called from Slot manager. 148 */ | 146 |
149static int 150fe_pccard_attach(device_t dev) 151{ 152 struct fe_softc *sc; | 147static int 148fe_pccard_attach(device_t dev) 149{ 150 struct fe_softc *sc; |
153 const struct fe_pccard_product *pp; | 151 const struct fe_pccard_product *pp; |
154 int error; 155 156 /* Prepare for the device probe process. */ 157 sc = device_get_softc(dev); 158 sc->sc_unit = device_get_unit(dev); 159 | 152 int error; 153 154 /* Prepare for the device probe process. */ 155 sc = device_get_softc(dev); 156 sc->sc_unit = device_get_unit(dev); 157 |
160 pp = (const struct fe_pccard_product *) pccard_product_lookup(dev, | 158 pp = (const struct fe_pccard_product *) pccard_product_lookup(dev, |
161 (const struct pccard_product *)fe_pccard_products, | 159 (const struct pccard_product *)fe_pccard_products, |
162 sizeof(fe_pccard_products[0]), NULL); | 160 sizeof(fe_pccard_products[0]), NULL); |
163 if (pp == NULL) 164 return (ENXIO); 165 166 if (pp->mpp_flags & MPP_MBH10302) 167 error = fe_probe_mbh(dev, pp); 168 else 169 error = fe_probe_tdk(dev, pp); 170 if (error != 0) { --- 93 unchanged lines hidden (view full) --- 264 265 /* Setup hooks. We need a special initialization procedure. */ 266 sc->init = fe_init_mbh; 267 268 return 0; 269} 270 271static int | 161 if (pp == NULL) 162 return (ENXIO); 163 164 if (pp->mpp_flags & MPP_MBH10302) 165 error = fe_probe_mbh(dev, pp); 166 else 167 error = fe_probe_tdk(dev, pp); 168 if (error != 0) { --- 93 unchanged lines hidden (view full) --- 262 263 /* Setup hooks. We need a special initialization procedure. */ 264 sc->init = fe_init_mbh; 265 266 return 0; 267} 268 269static int |
272sn_pccard_xircom_mac(const struct pccard_tuple *tuple, void *argp) | 270fe_pccard_xircom_mac(const struct pccard_tuple *tuple, void *argp) |
273{ 274 uint8_t *enaddr = argp; 275 int i; 276 277#if 1 278 /* 279 * We fail to map the CIS twice, for reasons unknown. We 280 * may fix this in the future by loading the CIS with a sane --- 31 unchanged lines hidden (view full) --- 312 * *generic* PC Card implementation of Fujitsu MB8696x family. The 313 * name _tdk is just for a historical reason. :-) 314 */ 315static int 316fe_probe_tdk (device_t dev, const struct fe_pccard_product *pp) 317{ 318 struct fe_softc *sc = device_get_softc(dev); 319 | 271{ 272 uint8_t *enaddr = argp; 273 int i; 274 275#if 1 276 /* 277 * We fail to map the CIS twice, for reasons unknown. We 278 * may fix this in the future by loading the CIS with a sane --- 31 unchanged lines hidden (view full) --- 310 * *generic* PC Card implementation of Fujitsu MB8696x family. The 311 * name _tdk is just for a historical reason. :-) 312 */ 313static int 314fe_probe_tdk (device_t dev, const struct fe_pccard_product *pp) 315{ 316 struct fe_softc *sc = device_get_softc(dev); 317 |
320 static struct fe_simple_probe_struct probe_table [] = { 321 { FE_DLCR2, 0x10, 0x00 }, 322 { FE_DLCR4, 0x08, 0x00 }, 323 /* { FE_DLCR5, 0x80, 0x00 }, Does not work well. */ 324 { 0 } 325 }; | 318 static struct fe_simple_probe_struct probe_table [] = { 319 { FE_DLCR2, 0x10, 0x00 }, 320 { FE_DLCR4, 0x08, 0x00 }, 321/* { FE_DLCR5, 0x80, 0x00 }, Does not work well. */ 322 { 0 } 323 }; |
326 327 | 324 325 |
328 /* C-NET(PC)C occupies 16 I/O addresses. */ | 326 /* C-NET(PC)C occupies 16 I/O addresses. */ |
329 if (fe_alloc_port(dev, 16)) 330 return ENXIO; 331 332 /* Fill the softc struct with default values. */ 333 fe_softc_defaults(sc); 334 | 327 if (fe_alloc_port(dev, 16)) 328 return ENXIO; 329 330 /* Fill the softc struct with default values. */ 331 fe_softc_defaults(sc); 332 |
335 /* 336 * See if C-NET(PC)C is on its address. 337 */ 338 if (!fe_simple_probe(sc, probe_table)) | 333 /* 334 * See if C-NET(PC)C is on its address. 335 */ 336 if (!fe_simple_probe(sc, probe_table)) |
339 return ENXIO; 340 | 337 return ENXIO; 338 |
341 /* Determine the card type. */ | 339 /* Determine the card type. */ |
342 sc->type = FE_TYPE_TDK; | 340 sc->type = FE_TYPE_TDK; |
343 sc->typestr = "Generic MB8696x/78Q837x Ethernet (PCMCIA)"; | 341 sc->typestr = "Generic MB8696x/78Q837x Ethernet (PCMCIA)"; |
344 345 pccard_get_ether(dev, sc->enaddr); 346 | 342 343 pccard_get_ether(dev, sc->enaddr); 344 |
347 /* Make sure we got a valid station address. */ 348 if (!fe_valid_Ether_p(sc->enaddr, 0)) { 349 pccard_cis_scan(dev, sn_pccard_xircom_mac, sc->enaddr); | 345 /* Make sure we got a valid station address. */ 346 if (!fe_valid_Ether_p(sc->enaddr, 0)) { 347 pccard_cis_scan(dev, fe_pccard_xircom_mac, sc->enaddr); |
350 } 351 | 348 } 349 |
352 /* Make sure we got a valid station address. */ 353 if (!fe_valid_Ether_p(sc->enaddr, 0)) | 350 /* Make sure we got a valid station address. */ 351 if (!fe_valid_Ether_p(sc->enaddr, 0)) |
354 return ENXIO; 355 | 352 return ENXIO; 353 |
356 return 0; | 354 return 0; |
357} | 355} |