if_ep_pccard.c (119572) | if_ep_pccard.c (121206) |
---|---|
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 --- 15 unchanged lines hidden (view full) --- 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 31#include <sys/cdefs.h> | 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 --- 15 unchanged lines hidden (view full) --- 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 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep_pccard.c 119572 2003-08-30 08:10:58Z markm $"); | 32__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep_pccard.c 121206 2003-10-18 15:22:43Z imp $"); |
33 34/* 35 * Pccard support for 3C589 by: 36 * HAMADA Naoki 37 * nao@tom-yam.or.jp 38 */ 39 40#include <sys/cdefs.h> | 33 34/* 35 * Pccard support for 3C589 by: 36 * HAMADA Naoki 37 * nao@tom-yam.or.jp 38 */ 39 40#include <sys/cdefs.h> |
41__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep_pccard.c 119572 2003-08-30 08:10:58Z markm $"); | 41__FBSDID("$FreeBSD: head/sys/dev/ep/if_ep_pccard.c 121206 2003-10-18 15:22:43Z imp $"); |
42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/kernel.h> 46#include <sys/socket.h> 47#include <sys/module.h> 48#include <sys/bus.h> 49 --- 27 unchanged lines hidden (view full) --- 77 u_int16_t result; 78 int error; 79 80 error = ep_alloc(dev); 81 if (error) 82 return (error); 83 84 /* | 42 43#include <sys/param.h> 44#include <sys/systm.h> 45#include <sys/kernel.h> 46#include <sys/socket.h> 47#include <sys/module.h> 48#include <sys/bus.h> 49 --- 27 unchanged lines hidden (view full) --- 77 u_int16_t result; 78 int error; 79 80 error = ep_alloc(dev); 81 if (error) 82 return (error); 83 84 /* |
85 * It appears that the eeprom comes in two sizes. There's 86 * a 512 byte eeprom and a 2k eeprom. Bit 13 of the eeprom 87 * command register is supposed to contain the size of the 88 * eeprom. 89 */ 90 /* |
|
85 * XXX - Certain (newer?) 3Com cards need epb->cmd_off == 86 * 2. Sadly, you need to have a correct cmd_off in order to 87 * identify the card. So we have to hit it with both and 88 * cross our virtual fingers. There's got to be a better way 89 * to do this. jyoung@accessus.net 09/11/1999 90 */ 91 92 epb->cmd_off = 0; --- 53 unchanged lines hidden (view full) --- 146 } 147} 148 149static int 150ep_pccard_card_attach(struct ep_board * epb) 151{ 152 /* Determine device type and associated MII capabilities */ 153 switch (epb->prod_id) { | 91 * XXX - Certain (newer?) 3Com cards need epb->cmd_off == 92 * 2. Sadly, you need to have a correct cmd_off in order to 93 * identify the card. So we have to hit it with both and 94 * cross our virtual fingers. There's got to be a better way 95 * to do this. jyoung@accessus.net 09/11/1999 96 */ 97 98 epb->cmd_off = 0; --- 53 unchanged lines hidden (view full) --- 152 } 153} 154 155static int 156ep_pccard_card_attach(struct ep_board * epb) 157{ 158 /* Determine device type and associated MII capabilities */ 159 switch (epb->prod_id) { |
154 case 0x6055: /* 3C556 */ 155 case 0x2b57: /* 3C572BT */ 156 case 0x4057: /* 3C574 */ 157 case 0x4b57: /* 3C574B */ 158 case 0x0010: /* 3C1 */ | 160 case 0x6055: /* 3C556 */ 161 case 0x2b57: /* 3C572BT */ 162 case 0x4057: /* 3C574 */ 163 case 0x4b57: /* 3C574B */ |
159 epb->mii_trans = 1; 160 return (1); 161 case 0x2056: /* 3C562D/3C563D */ 162 case 0x9058: /* 3C589 */ | 164 epb->mii_trans = 1; 165 return (1); 166 case 0x2056: /* 3C562D/3C563D */ 167 case 0x9058: /* 3C589 */ |
168 case 0x0010: /* 3C1 */ |
|
163 epb->mii_trans = 0; 164 return (1); 165 default: 166 return (0); 167 } 168} 169 170static int --- 25 unchanged lines hidden (view full) --- 196 error = ENXIO; 197 goto bad; 198 } 199 } 200 error = get_e(sc, EEPROM_ADDR_CFG, &result); 201 202 /* ROM size = 0, ROM base = 0 */ 203 /* For now, ignore AUTO SELECT feature of 3C589B and later. */ | 169 epb->mii_trans = 0; 170 return (1); 171 default: 172 return (0); 173 } 174} 175 176static int --- 25 unchanged lines hidden (view full) --- 202 error = ENXIO; 203 goto bad; 204 } 205 } 206 error = get_e(sc, EEPROM_ADDR_CFG, &result); 207 208 /* ROM size = 0, ROM base = 0 */ 209 /* For now, ignore AUTO SELECT feature of 3C589B and later. */ |
204 outw(BASE + EP_W0_ADDRESS_CFG, result & 0xc000); | 210 EP_WRITE_2(sc, EP_W0_ADDRESS_CFG, result & 0xc000); |
205 206 /* Fake IRQ must be 3 */ | 211 212 /* Fake IRQ must be 3 */ |
207 outw(BASE + EP_W0_RESOURCE_CFG, (sc->epb.res_cfg & 0x0fff) | 0x3000); | 213 EP_WRITE_2(sc, EP_W0_RESOURCE_CFG, (sc->epb.res_cfg & 0x0fff) | 0x3000); |
208 | 214 |
209 outw(BASE + EP_W0_PRODUCT_ID, sc->epb.prod_id); | 215 EP_WRITE_2(sc, EP_W0_PRODUCT_ID, sc->epb.prod_id); |
210 211 if (sc->epb.mii_trans) { 212 /* 213 * turn on the MII transciever 214 */ 215 GO_WINDOW(3); | 216 217 if (sc->epb.mii_trans) { 218 /* 219 * turn on the MII transciever 220 */ 221 GO_WINDOW(3); |
216 outw(BASE + EP_W3_OPTIONS, 0x8040); | 222 EP_WRITE_2(sc, EP_W3_OPTIONS, 0x8040); |
217 DELAY(1000); | 223 DELAY(1000); |
218 outw(BASE + EP_W3_OPTIONS, 0xc040); 219 outw(BASE + EP_COMMAND, RX_RESET); 220 outw(BASE + EP_COMMAND, TX_RESET); 221 while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS); | 224 EP_WRITE_2(sc, EP_W3_OPTIONS, 0xc040); 225 EP_WRITE_2(sc, EP_COMMAND, RX_RESET); 226 EP_WRITE_2(sc, EP_COMMAND, TX_RESET); 227 while (EP_READ_2(sc, EP_STATUS) & S_COMMAND_IN_PROGRESS); |
222 DELAY(1000); | 228 DELAY(1000); |
223 outw(BASE + EP_W3_OPTIONS, 0x8040); | 229 EP_WRITE_2(sc, EP_W3_OPTIONS, 0x8040); |
224 } else 225 ep_get_media(sc); 226 227 if ((error = ep_attach(sc))) { 228 device_printf(dev, "ep_attach() failed! (%d)\n", error); 229 goto bad; 230 } 231 if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET, ep_intr, --- 58 unchanged lines hidden --- | 230 } else 231 ep_get_media(sc); 232 233 if ((error = ep_attach(sc))) { 234 device_printf(dev, "ep_attach() failed! (%d)\n", error); 235 goto bad; 236 } 237 if ((error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET, ep_intr, --- 58 unchanged lines hidden --- |