diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2007-11-03 14:10:38 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2007-11-03 14:10:38 +0000 |
commit | b1c67c8850d5f5e35e1f4fdfb3b73b0bad2bdb57 (patch) | |
tree | 3e393f7b760515646675325363a1487109d1ddb5 /sys | |
parent | 0a92a05758622cc6774cc6d9742220aee6e4cf9a (diff) |
two fixes from FreeBSD:
- fix an incorrect setting of `retry times' in case of zd1211b
- increase max rx size so there's room for multi-frame transactions
(slightly modified version)
from the Linux zd1211rw driver:
- patch registers CR47 and CR157 on devices that require it
- fix power calibration setting on ZD1211B
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/if_zyd.c | 41 | ||||
-rw-r--r-- | sys/dev/usb/if_zydreg.h | 10 |
2 files changed, 36 insertions, 15 deletions
diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index 3fce5aea50d..caa6836bc90 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_zyd.c,v 1.62 2007/10/14 08:31:55 fkr Exp $ */ +/* $OpenBSD: if_zyd.c,v 1.63 2007/11/03 14:10:37 damien Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> @@ -1497,6 +1497,7 @@ zyd_hw_init(struct zyd_softc *sc) { struct zyd_rf *rf = &sc->sc_rf; const struct zyd_phy_pair *phyp; + uint32_t tmp; int error; /* specify that the plug and play is finished */ @@ -1521,6 +1522,10 @@ zyd_hw_init(struct zyd_softc *sc) if ((error = zyd_write16(sc, phyp->reg, phyp->val)) != 0) goto fail; } + if (sc->fix_cr157) { + if (zyd_read32(sc, ZYD_EEPROM_PHY_REG, &tmp) == 0) + (void)zyd_write32(sc, ZYD_CR157, tmp >> 8); + } zyd_unlock_phy(sc); /* HMAC init */ @@ -1530,13 +1535,13 @@ zyd_hw_init(struct zyd_softc *sc) if (sc->mac_rev == ZYD_ZD1211) { zyd_write32(sc, ZYD_MAC_RETRY, 0x00000002); } else { - zyd_write32(sc, ZYD_MAC_RETRY, 0x02020202); + zyd_write32(sc, ZYD_MACB_MAX_RETRY, 0x02020202); zyd_write32(sc, ZYD_MACB_TXPWR_CTL4, 0x007f003f); zyd_write32(sc, ZYD_MACB_TXPWR_CTL3, 0x007f003f); zyd_write32(sc, ZYD_MACB_TXPWR_CTL2, 0x003f001f); zyd_write32(sc, ZYD_MACB_TXPWR_CTL1, 0x001f000f); zyd_write32(sc, ZYD_MACB_AIFS_CTL1, 0x00280028); - zyd_write32(sc, ZYD_MACB_AIFS_CTL2, 0x008C003C); + zyd_write32(sc, ZYD_MACB_AIFS_CTL2, 0x008C003c); zyd_write32(sc, ZYD_MACB_TXOP, 0x01800824); } @@ -1594,8 +1599,10 @@ zyd_read_eeprom(struct zyd_softc *sc) ic->ic_myaddr[5] = tmp >> 8; (void)zyd_read32(sc, ZYD_EEPROM_POD, &tmp); - sc->rf_rev = tmp & 0x0f; - sc->pa_rev = (tmp >> 16) & 0x0f; + sc->rf_rev = tmp & 0x0f; + sc->fix_cr47 = (tmp >> 8 ) & 0x01; + sc->fix_cr157 = (tmp >> 13) & 0x01; + sc->pa_rev = (tmp >> 16) & 0x0f; /* read regulatory domain (currently unused) */ (void)zyd_read32(sc, ZYD_EEPROM_SUBID, &tmp); @@ -1708,6 +1715,7 @@ zyd_set_chan(struct zyd_softc *sc, struct ieee80211_channel *c) { struct ieee80211com *ic = &sc->sc_ic; struct zyd_rf *rf = &sc->sc_rf; + uint32_t tmp; u_int chan; chan = ieee80211_chan2ieee(ic, c); @@ -1719,18 +1727,27 @@ zyd_set_chan(struct zyd_softc *sc, struct ieee80211_channel *c) (*rf->set_channel)(rf, chan); /* update Tx power */ - (void)zyd_write32(sc, ZYD_CR31, sc->pwr_int[chan - 1]); - (void)zyd_write32(sc, ZYD_CR68, sc->pwr_cal[chan - 1]); + (void)zyd_write16(sc, ZYD_CR31, sc->pwr_int[chan - 1]); if (sc->mac_rev == ZYD_ZD1211B) { - (void)zyd_write32(sc, ZYD_CR67, sc->ofdm36_cal[chan - 1]); - (void)zyd_write32(sc, ZYD_CR66, sc->ofdm48_cal[chan - 1]); - (void)zyd_write32(sc, ZYD_CR65, sc->ofdm54_cal[chan - 1]); + (void)zyd_write16(sc, ZYD_CR67, sc->ofdm36_cal[chan - 1]); + (void)zyd_write16(sc, ZYD_CR66, sc->ofdm48_cal[chan - 1]); + (void)zyd_write16(sc, ZYD_CR65, sc->ofdm54_cal[chan - 1]); + + (void)zyd_write16(sc, ZYD_CR68, sc->pwr_cal[chan - 1]); - (void)zyd_write32(sc, ZYD_CR69, 0x28); - (void)zyd_write32(sc, ZYD_CR69, 0x2a); + (void)zyd_write16(sc, ZYD_CR69, 0x28); + (void)zyd_write16(sc, ZYD_CR69, 0x2a); } + if (sc->fix_cr47) { + /* set CCK baseband gain from EEPROM */ + if (zyd_read32(sc, ZYD_EEPROM_PHY_REG, &tmp) == 0) + (void)zyd_write16(sc, ZYD_CR47, tmp & 0xff); + } + + (void)zyd_write32(sc, ZYD_CR_CONFIG_PHILIPS, 0); + zyd_unlock_phy(sc); } diff --git a/sys/dev/usb/if_zydreg.h b/sys/dev/usb/if_zydreg.h index 49fa600d5be..cd0f48de076 100644 --- a/sys/dev/usb/if_zydreg.h +++ b/sys/dev/usb/if_zydreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_zydreg.h,v 1.20 2007/06/06 19:25:49 mk Exp $ */ +/* $OpenBSD: if_zydreg.h,v 1.21 2007/11/03 14:10:37 damien Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini <damien.bergamini@free.fr> @@ -1081,8 +1081,10 @@ struct zyd_notif_retry { (sizeof (struct zyd_plcphdr) + IEEE80211_MIN_LEN + \ sizeof (struct zyd_rx_stat)) #define ZYD_MIN_RXBUFSZ ZYD_MIN_FRAGSZ -#define ZYX_MAX_RXBUFSZ \ - (sizeof (struct zyd_plcphdr) + MCLBYTES + sizeof (struct zyd_rx_desc)) +#define ZYX_MAX_RXBUFSZ \ + ((sizeof (struct zyd_plcphdr) + IEEE80211_MAX_LEN + \ + sizeof (struct zyd_rx_stat)) * ZYD_MAX_RXFRAMECNT + \ + sizeof (struct zyd_rx_desc)) #define ZYD_CMD_FLAG_READ (1 << 0) @@ -1187,6 +1189,8 @@ struct zyd_softc { uint16_t fw_rev; uint8_t rf_rev; uint8_t pa_rev; + uint8_t fix_cr47; + uint8_t fix_cr157; uint8_t pwr_cal[14]; uint8_t pwr_int[14]; uint8_t ofdm36_cal[14]; |