if_ep_pccard.c (106937) | if_ep_pccard.c (112822) |
---|---|
1/* 2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> 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 --- 13 unchanged lines hidden (view full) --- 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * | 1/* 2 * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> 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 --- 13 unchanged lines hidden (view full) --- 22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * |
30 * $FreeBSD: head/sys/dev/ep/if_ep_pccard.c 106937 2002-11-14 23:54:55Z sam $ | 30 * $FreeBSD: head/sys/dev/ep/if_ep_pccard.c 112822 2003-03-29 21:44:46Z mdodd $ |
31 */ 32 33/* 34 * Pccard support for 3C589 by: 35 * HAMADA Naoki 36 * nao@tom-yam.or.jp 37 */ 38 --- 27 unchanged lines hidden (view full) --- 66 * Initialize the device - called from Slot manager. 67 */ 68static int 69ep_pccard_probe(device_t dev) 70{ 71 struct ep_softc * sc = device_get_softc(dev); 72 struct ep_board * epb = &sc->epb; 73 const char * desc; | 31 */ 32 33/* 34 * Pccard support for 3C589 by: 35 * HAMADA Naoki 36 * nao@tom-yam.or.jp 37 */ 38 --- 27 unchanged lines hidden (view full) --- 66 * Initialize the device - called from Slot manager. 67 */ 68static int 69ep_pccard_probe(device_t dev) 70{ 71 struct ep_softc * sc = device_get_softc(dev); 72 struct ep_board * epb = &sc->epb; 73 const char * desc; |
74 u_int16_t result; |
|
74 int error; 75 76 error = ep_alloc(dev); 77 if (error) 78 return error; 79 80 /* 81 * XXX - Certain (newer?) 3Com cards need epb->cmd_off == 82 * 2. Sadly, you need to have a correct cmd_off in order to 83 * identify the card. So we have to hit it with both and 84 * cross our virtual fingers. There's got to be a better way 85 * to do this. jyoung@accessus.net 09/11/1999 86 */ 87 88 epb->cmd_off = 0; | 75 int error; 76 77 error = ep_alloc(dev); 78 if (error) 79 return error; 80 81 /* 82 * XXX - Certain (newer?) 3Com cards need epb->cmd_off == 83 * 2. Sadly, you need to have a correct cmd_off in order to 84 * identify the card. So we have to hit it with both and 85 * cross our virtual fingers. There's got to be a better way 86 * to do this. jyoung@accessus.net 09/11/1999 87 */ 88 89 epb->cmd_off = 0; |
89 epb->prod_id = get_e(sc, EEPROM_PROD_ID); | 90 91 error = get_e(sc, EEPROM_PROD_ID, &result); /* XXX check return */ 92 epb->prod_id = result; 93 |
90 if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) { 91 if (bootverbose) 92 device_printf(dev, "Pass 1 of 2 detection " 93 "failed (nonfatal) id 0x%x\n", epb->prod_id); 94 epb->cmd_off = 2; | 94 if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) { 95 if (bootverbose) 96 device_printf(dev, "Pass 1 of 2 detection " 97 "failed (nonfatal) id 0x%x\n", epb->prod_id); 98 epb->cmd_off = 2; |
95 epb->prod_id = get_e(sc, EEPROM_PROD_ID); | 99 error = get_e(sc, EEPROM_PROD_ID, &result); /* XXX check return */ 100 epb->prod_id = result; |
96 if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) { 97 device_printf(dev, "Unit failed to come ready or " 98 "product ID unknown! (id 0x%x)\n", epb->prod_id); 99 ep_free(dev); 100 return (ENXIO); 101 } 102 } 103 device_set_desc(dev, desc); 104 105 /* 106 * For some reason the 3c574 needs this. 107 */ | 101 if ((desc = ep_pccard_identify(epb->prod_id)) == NULL) { 102 device_printf(dev, "Unit failed to come ready or " 103 "product ID unknown! (id 0x%x)\n", epb->prod_id); 104 ep_free(dev); 105 return (ENXIO); 106 } 107 } 108 device_set_desc(dev, desc); 109 110 /* 111 * For some reason the 3c574 needs this. 112 */ |
108 ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr); | 113 error = ep_get_macaddr(sc, (u_char *)&sc->arpcom.ac_enaddr); |
109 110 ep_free(dev); 111 return (0); 112} 113 114static const char * 115ep_pccard_identify(u_short id) 116{ --- 37 unchanged lines hidden (view full) --- 154 } 155 return (0); 156} 157 158static int 159ep_pccard_attach(device_t dev) 160{ 161 struct ep_softc * sc = device_get_softc(dev); | 114 115 ep_free(dev); 116 return (0); 117} 118 119static const char * 120ep_pccard_identify(u_short id) 121{ --- 37 unchanged lines hidden (view full) --- 159 } 160 return (0); 161} 162 163static int 164ep_pccard_attach(device_t dev) 165{ 166 struct ep_softc * sc = device_get_softc(dev); |
167 u_int16_t result; |
|
162 int error = 0; 163 164 if ((error = ep_alloc(dev))) { 165 device_printf(dev, "ep_alloc() failed! (%d)\n", error); 166 goto bad; 167 } 168 169 sc->epb.cmd_off = 0; | 168 int error = 0; 169 170 if ((error = ep_alloc(dev))) { 171 device_printf(dev, "ep_alloc() failed! (%d)\n", error); 172 goto bad; 173 } 174 175 sc->epb.cmd_off = 0; |
170 sc->epb.prod_id = get_e(sc, EEPROM_PROD_ID); | 176 177 error = get_e(sc, EEPROM_PROD_ID, &result); /* XXX check return */ 178 sc->epb.prod_id = result; 179 |
171 if (!ep_pccard_card_attach(&sc->epb)) { 172 sc->epb.cmd_off = 2; | 180 if (!ep_pccard_card_attach(&sc->epb)) { 181 sc->epb.cmd_off = 2; |
173 sc->epb.prod_id = get_e(sc, EEPROM_PROD_ID); 174 sc->epb.res_cfg = get_e(sc, EEPROM_RESOURCE_CFG); | 182 error = get_e(sc, EEPROM_PROD_ID, &result); 183 sc->epb.prod_id = result; 184 error = get_e(sc, EEPROM_RESOURCE_CFG, &result); 185 sc->epb.res_cfg = result; |
175 if (!ep_pccard_card_attach(&sc->epb)) { 176 device_printf(dev, 177 "Probe found ID, attach failed so ignore card!\n"); 178 error = ENXIO; 179 goto bad; 180 } 181 } 182 | 186 if (!ep_pccard_card_attach(&sc->epb)) { 187 device_printf(dev, 188 "Probe found ID, attach failed so ignore card!\n"); 189 error = ENXIO; 190 goto bad; 191 } 192 } 193 |
194 error = get_e(sc, EEPROM_ADDR_CFG, &result); 195 |
|
183 /* ROM size = 0, ROM base = 0 */ 184 /* For now, ignore AUTO SELECT feature of 3C589B and later. */ | 196 /* ROM size = 0, ROM base = 0 */ 197 /* For now, ignore AUTO SELECT feature of 3C589B and later. */ |
185 outw(BASE + EP_W0_ADDRESS_CFG, get_e(sc, EEPROM_ADDR_CFG) & 0xc000); | 198 outw(BASE + EP_W0_ADDRESS_CFG, result & 0xc000); |
186 187 /* Fake IRQ must be 3 */ 188 outw(BASE + EP_W0_RESOURCE_CFG, (sc->epb.res_cfg & 0x0fff) | 0x3000); 189 190 outw(BASE + EP_W0_PRODUCT_ID, sc->epb.prod_id); 191 192 if (sc->epb.mii_trans) { 193 /* --- 96 unchanged lines hidden --- | 199 200 /* Fake IRQ must be 3 */ 201 outw(BASE + EP_W0_RESOURCE_CFG, (sc->epb.res_cfg & 0x0fff) | 0x3000); 202 203 outw(BASE + EP_W0_PRODUCT_ID, sc->epb.prod_id); 204 205 if (sc->epb.mii_trans) { 206 /* --- 96 unchanged lines hidden --- |