Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/ic Realtek sample sources are not consistent about t...
details: https://anonhg.NetBSD.org/src/rev/ba0fe838835d
branches: trunk
changeset: 572127:ba0fe838835d
user: dyoung <dyoung%NetBSD.org@localhost>
date: Mon Dec 20 23:05:41 2004 +0000
description:
Realtek sample sources are not consistent about the "Digital PHY"
bit in the SROM. It seems as if it is set to 1 when the PHY is
*analog*, not *digital*. Fix my sources.
In rtw_intr_rx, use units of 500kb/s instead of 100kb/s for rate,
to be consistent with net80211's expectations. Polish up some
debugging ugly messages. Dump raw 802.11 packets if IFF_DEBUG|IFF_LINK2
and RTW_DEBUG is defined.
Polish power-state (on/sleep/off) handling. Especially improve
support for RFMD (totally untested) and Maxim. For Philips, take
the Digital PHY property into account.
Call the net80211 watchdog function from rtw_watchdog, so that we
scan again if auth/assoc fails.
Be a little more cautious about writing register[RTW_TPPOLL], since
other drivers are.... Don't frob the high/low-priority queues
right now, since I don't use them.
Add rtw_join_bss which programs the card with the BSSID and other
properties of a BSS. Use it on state transitions. Factor out
rtw_set_nettype.
Make rtw_recv_beacon call ieee80211_recv_mgmt instead of dropping
beacons on the floor! TBD IBSS merges.
Change some rtw_debug=2 printfs to rtw_debug=3 (RTW_DPRINTF3)
printfs so the console doesn't get spammed so badly at rtw_debug=2.
Change some debugging printfs to RTW_DPRINTFs. E.g., print the
"RF programming method" only if debugging is enabled.
diffstat:
sys/dev/ic/rtw.c | 270 ++++++++++++++++++++++++++++++++++---------------
sys/dev/ic/rtwphyio.c | 6 +-
sys/dev/ic/rtwreg.h | 67 ++++++++----
sys/dev/ic/rtwvar.h | 4 +-
4 files changed, 236 insertions(+), 111 deletions(-)
diffs (truncated from 705 to 300 lines):
diff -r 9a6342000d8a -r ba0fe838835d sys/dev/ic/rtw.c
--- a/sys/dev/ic/rtw.c Mon Dec 20 23:04:55 2004 +0000
+++ b/sys/dev/ic/rtw.c Mon Dec 20 23:05:41 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rtw.c,v 1.9 2004/12/20 01:28:24 dyoung Exp $ */
+/* $NetBSD: rtw.c,v 1.10 2004/12/20 23:05:41 dyoung Exp $ */
/*-
* Copyright (c) 2004, 2005 David Young. All rights reserved.
*
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.9 2004/12/20 01:28:24 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtw.c,v 1.10 2004/12/20 23:05:41 dyoung Exp $");
#include "bpfilter.h"
@@ -672,7 +672,10 @@
if ((RTW_SR_GET(sr, RTW_SR_CONFIG2) & RTW_CONFIG2_ANT) != 0)
*flags |= RTW_F_ANTDIV;
- if ((RTW_SR_GET(sr, RTW_SR_RFPARM) & RTW_SR_RFPARM_DIGPHY) != 0)
+ /* Note well: the sense of the RTW_SR_RFPARM_DIGPHY bit seems
+ * to be reversed.
+ */
+ if ((RTW_SR_GET(sr, RTW_SR_RFPARM) & RTW_SR_RFPARM_DIGPHY) == 0)
*flags |= RTW_F_DIGPHY;
if ((RTW_SR_GET(sr, RTW_SR_RFPARM) & RTW_SR_RFPARM_DFLANTB) != 0)
*flags |= RTW_F_DFLANTB;
@@ -855,8 +858,8 @@
RTW_WBR(regs, RTW_CONFIG4, RTW_CONFIG4);
- printf("%s: %s RF programming method, %#02x\n", dvname, method,
- RTW_READ8(regs, RTW_CONFIG4));
+ RTW_DPRINTF(("%s: %s RF programming method, %#02x\n", dvname, method,
+ RTW_READ8(regs, RTW_CONFIG4)));
}
#if 0
@@ -1236,8 +1239,8 @@
htsfth = le32toh(hrx->hrx_tsfth);
htsftl = le32toh(hrx->hrx_tsftl);
- RTW_DPRINTF2(("%s: rxdesc[%d] hstat %#08x hrssi %#08x "
- "htsft %#08x%08x\n", __func__, next,
+ RTW_DPRINTF2(("%s: rxdesc[%d] hstat %08x hrssi %08x "
+ "htsft %08x%08x\n", __func__, next,
hstat, hrssi, htsfth, htsftl));
if ((hstat & RTW_RXSTAT_OWN) != 0) /* belongs to NIC */
@@ -1252,13 +1255,13 @@
switch (hstat & RTW_RXSTAT_RATE_MASK) {
case RTW_RXSTAT_RATE_1MBPS:
- rate = 10;
+ rate = 2;
break;
case RTW_RXSTAT_RATE_2MBPS:
- rate = 20;
+ rate = 4;
break;
case RTW_RXSTAT_RATE_5MBPS:
- rate = 55;
+ rate = 11;
break;
default:
#ifdef RTW_DEBUG
@@ -1270,12 +1273,10 @@
#endif /* RTW_DEBUG */
/*FALLTHROUGH*/
case RTW_RXSTAT_RATE_11MBPS:
- rate = 110;
+ rate = 22;
break;
}
- RTW_DPRINTF2(("%s: rate %d\n", __func__, rate));
-
#ifdef RTW_DEBUG
#define PRINTSTAT(flag) do { \
if ((hstat & flag) != 0) { \
@@ -1287,7 +1288,7 @@
const char *delim = "<";
printf("%s: ", sc->sc_dev.dv_xname);
if ((hstat & RTW_RXSTAT_DEBUG) != 0) {
- printf("status %08x<", hstat);
+ printf("status %08x", hstat);
PRINTSTAT(RTW_RXSTAT_SPLCP);
PRINTSTAT(RTW_RXSTAT_MAR);
PRINTSTAT(RTW_RXSTAT_PAR);
@@ -1298,7 +1299,7 @@
printf(">, ");
}
printf("rate %d.%d Mb/s, time %08x%08x\n",
- rate / 10, rate % 10, htsfth, htsftl);
+ (rate * 5) / 10, (rate * 5) % 10, htsfth, htsftl);
}
#endif /* RTW_DEBUG */
@@ -1348,6 +1349,13 @@
sc->sc_tsfth = htsfth;
+#ifdef RTW_DEBUG
+ if ((sc->sc_if.if_flags & (IFF_DEBUG|IFF_LINK2)) ==
+ (IFF_DEBUG|IFF_LINK2)) {
+ ieee80211_dump_pkt(mtod(m, uint8_t *), m->m_pkthdr.len,
+ rate, rssi);
+ }
+#endif /* RTW_DEBUG */
ieee80211_input(&sc->sc_if, m, ni, rssi, htsftl);
ieee80211_release_node(&sc->sc_ic, ni);
next:
@@ -1742,95 +1750,135 @@
}
}
-/* XXX I am using the RFMD settings gleaned from the reference
- * driver.
+/* XXX For Maxim, I am using the RFMD settings gleaned from the
+ * reference driver, plus a magic Maxim "ON" value that comes from
+ * the Realtek document "Windows PG for Rtl8180."
*/
static void
rtw_maxim_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
- int before_rf)
+ int before_rf, int digphy)
{
u_int32_t anaparm;
- RTW_DPRINTF(("%s: power state %s, %s RF\n", __func__,
- rtw_pwrstate_string(power), (before_rf) ? "before" : "after"));
-
anaparm = RTW_READ(regs, RTW_ANAPARM);
- anaparm &= ~(RTW_ANAPARM_RFPOW0_MASK|RTW_ANAPARM_RFPOW1_MASK);
- anaparm &= ~RTW_ANAPARM_TXDACOFF;
+ anaparm &= ~(RTW_ANAPARM_RFPOW_MASK | RTW_ANAPARM_TXDACOFF);
switch (power) {
case RTW_OFF:
if (before_rf)
return;
- anaparm |= RTW_ANAPARM_RFPOW0_RFMD_OFF;
- anaparm |= RTW_ANAPARM_RFPOW1_RFMD_OFF;
+ anaparm |= RTW_ANAPARM_RFPOW_MAXIM_OFF;
anaparm |= RTW_ANAPARM_TXDACOFF;
break;
case RTW_SLEEP:
if (!before_rf)
return;
- anaparm |= RTW_ANAPARM_RFPOW0_RFMD_SLEEP;
- anaparm |= RTW_ANAPARM_RFPOW1_RFMD_SLEEP;
+ anaparm |= RTW_ANAPARM_RFPOW_MAXIM_SLEEP;
anaparm |= RTW_ANAPARM_TXDACOFF;
break;
case RTW_ON:
if (!before_rf)
return;
- anaparm |= RTW_ANAPARM_RFPOW0_RFMD_ON;
- anaparm |= RTW_ANAPARM_RFPOW1_RFMD_ON;
+ anaparm |= RTW_ANAPARM_RFPOW_MAXIM_ON;
break;
}
+ RTW_DPRINTF(("%s: power state %s, %s RF, reg[ANAPARM] <- %08x\n",
+ __func__, rtw_pwrstate_string(power),
+ (before_rf) ? "before" : "after", anaparm));
+
+ RTW_WRITE(regs, RTW_ANAPARM, anaparm);
+ RTW_SYNC(regs, RTW_ANAPARM, RTW_ANAPARM);
+}
+
+/* XXX I am using the RFMD settings gleaned from the reference
+ * driver. They agree
+ */
+static void
+rtw_rfmd_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
+ int before_rf, int digphy)
+{
+ u_int32_t anaparm;
+
+ anaparm = RTW_READ(regs, RTW_ANAPARM);
+ anaparm &= ~(RTW_ANAPARM_RFPOW_MASK | RTW_ANAPARM_TXDACOFF);
+
+ switch (power) {
+ case RTW_OFF:
+ if (before_rf)
+ return;
+ anaparm |= RTW_ANAPARM_RFPOW_RFMD_OFF;
+ anaparm |= RTW_ANAPARM_TXDACOFF;
+ break;
+ case RTW_SLEEP:
+ if (!before_rf)
+ return;
+ anaparm |= RTW_ANAPARM_RFPOW_RFMD_SLEEP;
+ anaparm |= RTW_ANAPARM_TXDACOFF;
+ break;
+ case RTW_ON:
+ if (!before_rf)
+ return;
+ anaparm |= RTW_ANAPARM_RFPOW_RFMD_ON;
+ break;
+ }
+ RTW_DPRINTF(("%s: power state %s, %s RF, reg[ANAPARM] <- %08x\n",
+ __func__, rtw_pwrstate_string(power),
+ (before_rf) ? "before" : "after", anaparm));
+
RTW_WRITE(regs, RTW_ANAPARM, anaparm);
RTW_SYNC(regs, RTW_ANAPARM, RTW_ANAPARM);
}
static void
rtw_philips_pwrstate(struct rtw_regs *regs, enum rtw_pwrstate power,
- int before_rf)
+ int before_rf, int digphy)
{
u_int32_t anaparm;
- RTW_DPRINTF(("%s: power state %s, %s RF\n", __func__,
- rtw_pwrstate_string(power), (before_rf) ? "before" : "after"));
-
anaparm = RTW_READ(regs, RTW_ANAPARM);
- anaparm &= ~(RTW_ANAPARM_RFPOW0_MASK|RTW_ANAPARM_RFPOW1_MASK);
- anaparm &= ~RTW_ANAPARM_TXDACOFF;
+ anaparm &= ~(RTW_ANAPARM_RFPOW_MASK | RTW_ANAPARM_TXDACOFF);
switch (power) {
case RTW_OFF:
if (before_rf)
return;
- anaparm |= RTW_ANAPARM_RFPOW0_PHILIPS_OFF;
- anaparm |= RTW_ANAPARM_RFPOW1_PHILIPS_OFF;
+ anaparm |= RTW_ANAPARM_RFPOW_PHILIPS_OFF;
anaparm |= RTW_ANAPARM_TXDACOFF;
break;
case RTW_SLEEP:
if (!before_rf)
return;
- anaparm |= RTW_ANAPARM_RFPOW0_PHILIPS_SLEEP;
- anaparm |= RTW_ANAPARM_RFPOW1_PHILIPS_SLEEP;
+ anaparm |= RTW_ANAPARM_RFPOW_PHILIPS_SLEEP;
anaparm |= RTW_ANAPARM_TXDACOFF;
break;
case RTW_ON:
if (!before_rf)
return;
- anaparm |= RTW_ANAPARM_RFPOW0_PHILIPS_ON;
- anaparm |= RTW_ANAPARM_RFPOW1_PHILIPS_ON;
+ if (digphy) {
+ anaparm |= RTW_ANAPARM_RFPOW_DIG_PHILIPS_ON;
+ /* XXX guess */
+ anaparm |= RTW_ANAPARM_TXDACOFF;
+ } else
+ anaparm |= RTW_ANAPARM_RFPOW_ANA_PHILIPS_ON;
break;
}
+ RTW_DPRINTF(("%s: power state %s, %s RF, reg[ANAPARM] <- %08x\n",
+ __func__, rtw_pwrstate_string(power),
+ (before_rf) ? "before" : "after", anaparm));
+
RTW_WRITE(regs, RTW_ANAPARM, anaparm);
RTW_SYNC(regs, RTW_ANAPARM, RTW_ANAPARM);
}
static void
-rtw_pwrstate0(struct rtw_softc *sc, enum rtw_pwrstate power, int before_rf)
+rtw_pwrstate0(struct rtw_softc *sc, enum rtw_pwrstate power, int before_rf,
+ int digphy)
{
struct rtw_regs *regs = &sc->sc_regs;
rtw_set_access(sc, RTW_ACCESS_ANAPARM);
- (*sc->sc_pwrstate_cb)(regs, power, before_rf);
+ (*sc->sc_pwrstate_cb)(regs, power, before_rf, digphy);
rtw_set_access(sc, RTW_ACCESS_NONE);
@@ -1848,9 +1896,9 @@
if (sc->sc_pwrstate == power)
return 0;
- rtw_pwrstate0(sc, power, 1);
+ rtw_pwrstate0(sc, power, 1, sc->sc_flags & RTW_F_DIGPHY);
rc = rtw_rf_pwrstate(sc->sc_rf, power);
- rtw_pwrstate0(sc, power, 0);
+ rtw_pwrstate0(sc, power, 0, sc->sc_flags & RTW_F_DIGPHY);
switch (power) {
case RTW_ON:
@@ -1955,13 +2003,16 @@
tcr = RTW_READ(regs, RTW_TCR);
+ tcr |= RTW_TCR_CWMIN;
+ tcr &= ~RTW_TCR_MXDMA_MASK;
+ tcr |= RTW_TCR_MXDMA_256;
tcr |= RTW_TCR_SAT; /* send ACK as fast as possible */
tcr &= ~RTW_TCR_LBK_MASK;
Home |
Main Index |
Thread Index |
Old Index