diff options
author | imp <imp@FreeBSD.org> | 2008-07-09 16:47:55 +0000 |
---|---|---|
committer | imp <imp@FreeBSD.org> | 2008-07-09 16:47:55 +0000 |
commit | aa86225b8a5f1cd900542bb0fc6d05aa01a7f15e (patch) | |
tree | 0175cd8979711e34ad6e5815b3d3860a705e58f0 /sys/dev | |
parent | a51aa927fad5ab9ebbb294340935d462f68ee19b (diff) | |
download | FreeBSD-src-aa86225b8a5f1cd900542bb0fc6d05aa01a7f15e.zip FreeBSD-src-aa86225b8a5f1cd900542bb0fc6d05aa01a7f15e.tar.gz |
Improve the EEPROM parsing, based on finding a datasheet that describes
it in detail.
When setting media, don't error out when a specific media is selected.
# Note: There may be some issues still here since the EtherJet PC Card doesn't
# conform to the datasheet. Many different kinds of dongles can be plugged in
# and it is unknown how to ask which one it is.
Also, add a /* bad! */ comment to a 1/2 second delay after we set the
DC/DC parameters. This should be a *sleep of some sort for !cold.
Fortunately it is the only one and is only used when setting media, so
the benefit from removing it is small. Unfortunately, it likely
serves as an exemplar of good programming techniques, which it isn't.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/cs/if_cs.c | 12 | ||||
-rw-r--r-- | sys/dev/cs/if_csreg.h | 71 |
2 files changed, 46 insertions, 37 deletions
diff --git a/sys/dev/cs/if_cs.c b/sys/dev/cs/if_cs.c index 0784b20..f3fed0a 100644 --- a/sys/dev/cs/if_cs.c +++ b/sys/dev/cs/if_cs.c @@ -202,7 +202,7 @@ control_dc_dc(struct cs_softc *sc, int on_not_off) else self_control &= ~HCB1; cs_writereg(sc, PP_SelfCTL, self_control); - DELAY(500000); + DELAY(500000); /* Bad! */ } @@ -332,9 +332,9 @@ cs_cs89x0_probe(device_t dev) } else if (get_eeprom_cksum(START_EEPROM_DATA,CHKSUM_LEN, eeprom_buff)<0) { device_printf(dev, "EEPROM cheksum bad, assuming defaults.\n"); } else { - sc->auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET/2]; - sc->adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET/2]; - sc->isa_config = eeprom_buff[ISA_CNF_OFFSET/2]; + sc->auto_neg_cnf = eeprom_buff[AUTO_NEG_CNF_OFFSET]; + sc->adapter_cnf = eeprom_buff[ADAPTER_CNF_OFFSET]; + sc->isa_config = eeprom_buff[ISA_CNF_OFFSET]; for (i=0; i<ETHER_ADDR_LEN/2; i++) { sc->enaddr[i*2] = eeprom_buff[i]; sc->enaddr[i*2+1] = eeprom_buff[i] >> 8; @@ -1226,10 +1226,10 @@ cs_mediaset(struct cs_softc *sc, int media) error = cs_duplex_auto(sc); break; case IFM_10_2: - error = enable_bnc(sc); + enable_bnc(sc); break; case IFM_10_5: - error = enable_aui(sc); + enable_aui(sc); break; } diff --git a/sys/dev/cs/if_csreg.h b/sys/dev/cs/if_csreg.h index 34aed9c6..114800e 100644 --- a/sys/dev/cs/if_csreg.h +++ b/sys/dev/cs/if_csreg.h @@ -408,28 +408,43 @@ #define BIOS_LAST_OFFSET 0x0fc00 /* - * Byte offsets into the EEPROM configuration buffer + * Word offsets into the EEPROM configuration buffer */ -#define ISA_CNF_OFFSET 0x6 -#define TX_CTL_OFFSET (ISA_CNF_OFFSET + 8) /* 8900 eeprom */ -#define AUTO_NEG_CNF_OFFSET (ISA_CNF_OFFSET + 8) /* 8920 eeprom */ - -/* - * the assumption here is that the bits in the eeprom are generally - * in the same position as those in the autonegctl register. - * Of course the IMM bit is not in that register so it must be - * masked out - */ -#define EE_FORCE_FDX 0x8000 -#define EE_NLP_ENABLE 0x0200 -#define EE_AUTO_NEG_ENABLE 0x0100 -#define EE_ALLOW_FDX 0x0080 -#define EE_AUTO_NEG_CNF_MASK (EE_FORCE_FDX | EE_NLP_ENABLE | \ +#define ISA_CNF_OFFSET 0x3 +#define INT_NO_MASK 0x000F +#define DMA_NO_MASK 0x0070 +#define USE_SA 0x0080 +#define IOCHRDY_ENABLE 0x0100 +#define ISA_DMA_SIZE 0x0200 /* 0 16k 1 64k */ +#define ISA_AUTO_RxDMA 0x0400 +#define ISA_RxDMA 0x0800 +#define DMA_BURST 0x1000 +#define STREAM_TRANSFER 0x2000 +#define ANY_ISA_DMA (ISA_AUTO_RxDMA | ISA_RxDMA) +#define BOOT_PROM_FLAG 0x4000 +#define MEMORY_MODE 0x8000 + +#define PACKET_PAGE_BASE (ISA_CNF_OFFSET + 1) +#define BOOT_ROM_BASE (ISA_CNF_OFFSET + 2) +#define BOOT_PROM_MASK (ISA_CNF_OFFSET + 3) + +#define TX_CTL_OFFSET (ISA_CNF_OFFSET + 4) /* 8900 eeprom */ +#define AUTO_NEG_CNF_OFFSET (ISA_CNF_OFFSET + 4) /* 8920 eeprom */ + /* + * the assumption here is that the bits in the eeprom are generally + * in the same position as those in the autonegctl register. + * Of course the IMM bit is not in that register so it must be + * masked out + */ +#define EE_FORCE_FDX 0x8000 +#define EE_NLP_ENABLE 0x0200 +#define EE_AUTO_NEG_ENABLE 0x0100 +#define EE_ALLOW_FDX 0x0080 +#define EE_AUTO_NEG_CNF_MASK (EE_FORCE_FDX | EE_NLP_ENABLE | \ EE_AUTO_NEG_ENABLE | EE_ALLOW_FDX) +#define IMM_BIT 0x0040 /* ignore missing media */ -#define IMM_BIT 0x0040 /* ignore missing media */ - -#define ADAPTER_CNF_OFFSET (AUTO_NEG_CNF_OFFSET + 2) +#define ADAPTER_CNF_OFFSET (ISA_CNF_OFFSET + 5) #define A_CNF_MEDIA 0x0007 #define A_CNF_10B_T 0x0001 #define A_CNF_AUI 0x0002 @@ -440,23 +455,17 @@ #define A_CNF_MEDIA_AUI 0x0040 #define A_CNF_MEDIA_10B_2 0x0060 #define A_CNF_DC_DC_POLARITY 0x0080 +#define A_CNF_WAKE_ENABLED 0x0100 +#define A_CNF_WAKE_CFG 0x0200 +#define A_CNF_CAN_WAKE 0x0400 +#define A_CNF_OPT_FLAGS 0x1800 /* 00 server, 01 DOS 10 multi-user */ #define A_CNF_NO_AUTO_POLARITY 0x2000 #define A_CNF_LOW_RX_SQUELCH 0x4000 #define A_CNF_EXTND_10B_2 0x8000 -#define PACKET_PAGE_OFFSET 0x8 +#define MFG_DATE_OFFSET (ISA_CNF_OFFSET + 8) -/* - * Bit definitions for the ISA configuration word from the EEPROM - */ -#define INT_NO_MASK 0x000F -#define DMA_NO_MASK 0x0070 -#define ISA_DMA_SIZE 0x0200 -#define ISA_AUTO_RxDMA 0x0400 -#define ISA_RxDMA 0x0800 -#define DMA_BURST 0x1000 -#define STREAM_TRANSFER 0x2000 -#define ANY_ISA_DMA (ISA_AUTO_RxDMA | ISA_RxDMA) +#define PACKET_PAGE_OFFSET 0x8 /* DMA controller registers */ #define DMA_BASE 0x00 /* DMA controller base */ |