summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2010-04-06 16:41:55 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2010-04-06 16:41:55 +0000
commitb66b5e8e334073beee0ea60a7a5401bf8134868c (patch)
tree6a686b7c4be2483c6acf9bf7cdb2a6c0d6d5ae59 /sys
parentdb6f58553792a2518ccb4d251d823a01c9e175b2 (diff)
On RT3090 chips, read vendor RF settings from ROM and apply them.
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/rt2860.c54
-rw-r--r--sys/dev/ic/rt2860reg.h4
-rw-r--r--sys/dev/ic/rt2860var.h4
3 files changed, 56 insertions, 6 deletions
diff --git a/sys/dev/ic/rt2860.c b/sys/dev/ic/rt2860.c
index ae9e2bc4428..bb2b9ab3b4d 100644
--- a/sys/dev/ic/rt2860.c
+++ b/sys/dev/ic/rt2860.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2860.c,v 1.46 2010/04/06 16:14:47 damien Exp $ */
+/* $OpenBSD: rt2860.c,v 1.47 2010/04/06 16:41:54 damien Exp $ */
/*-
* Copyright (c) 2007-2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -127,6 +127,7 @@ void rt3090_set_chan(struct rt2860_softc *, u_int);
int rt3090_rf_init(struct rt2860_softc *);
int rt3090_filter_calib(struct rt2860_softc *, uint8_t, uint8_t,
uint8_t *);
+void rt3090_rf_setup(struct rt2860_softc *);
void rt2860_set_leds(struct rt2860_softc *, uint16_t);
void rt2860_set_gp_timer(struct rt2860_softc *, int);
void rt2860_set_bssid(struct rt2860_softc *, const uint8_t *);
@@ -2395,6 +2396,36 @@ rt3090_filter_calib(struct rt2860_softc *sc, uint8_t init, uint8_t target,
}
void
+rt3090_rf_setup(struct rt2860_softc *sc)
+{
+ uint8_t bbp;
+ int i;
+
+ if (sc->mac_rev >= 0x0211) {
+ /* enable DC filter */
+ rt2860_mcu_bbp_write(sc, 103, 0xc0);
+
+ /* improve power consumption */
+ bbp = rt2860_mcu_bbp_read(sc, 31);
+ rt2860_mcu_bbp_write(sc, 31, bbp & ~0x03);
+ }
+
+ RAL_WRITE(sc, RT2860_TX_SW_CFG1, 0);
+ if (sc->mac_rev < 0x0211) {
+ RAL_WRITE(sc, RT2860_TX_SW_CFG2,
+ sc->patch_dac ? 0x2c : 0x0f);
+ } else
+ RAL_WRITE(sc, RT2860_TX_SW_CFG2, 0);
+
+ /* initialize RF registers from ROM */
+ for (i = 0; i < 10; i++) {
+ if (sc->rf[i].reg == 0 || sc->rf[i].reg == 0xff)
+ continue;
+ rt3090_rf_write(sc, sc->rf[i].reg, sc->rf[i].val);
+ }
+}
+
+void
rt2860_set_leds(struct rt2860_softc *sc, uint16_t which)
{
(void)rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LEDS,
@@ -2749,13 +2780,23 @@ rt2860_read_eeprom(struct rt2860_softc *sc)
val = rt2860_srom_read(sc, RT2860_EEPROM_COUNTRY);
DPRINTF(("EEPROM region code=0x%04x\n", val));
- /* read default BBP settings */
+ /* read vendor BBP settings */
for (i = 0; i < 8; i++) {
val = rt2860_srom_read(sc, RT2860_EEPROM_BBP_BASE + i);
sc->bbp[i].val = val & 0xff;
sc->bbp[i].reg = val >> 8;
DPRINTF(("BBP%d=0x%02x\n", sc->bbp[i].reg, sc->bbp[i].val));
}
+ if (sc->mac_ver >= 0x3090) {
+ /* read vendor RF settings */
+ for (i = 0; i < 10; i++) {
+ val = rt2860_srom_read(sc, RT3071_EEPROM_RF_BASE + i);
+ sc->rf[i].val = val & 0xff;
+ sc->rf[i].reg = val >> 8;
+ DPRINTF(("RF%d=0x%02x\n", sc->rf[i].reg,
+ sc->rf[i].val));
+ }
+ }
/* read RF frequency offset from EEPROM */
val = rt2860_srom_read(sc, RT2860_EEPROM_FREQ_LEDS);
@@ -3287,9 +3328,16 @@ rt2860_init(struct ifnet *ifp)
/* disable non-existing Tx chains */
bbp1 = rt2860_mcu_bbp_read(sc, 1);
if (sc->ntxchains == 1)
- bbp1 &= ~(1 << 3 | 1 << 4);
+ bbp1 = (bbp1 & ~(1 << 3 | 1 << 4));
+ else if (sc->mac_ver == 0x3593 && sc->ntxchains == 2)
+ bbp1 = (bbp1 & ~(1 << 4)) | 1 << 3;
+ else if (sc->mac_ver == 0x3593 && sc->ntxchains == 3)
+ bbp1 = (bbp1 & ~(1 << 3)) | 1 << 4;
rt2860_mcu_bbp_write(sc, 1, bbp1);
+ if (sc->mac_ver >= 0x3090)
+ rt3090_rf_setup(sc);
+
/* select default channel */
ic->ic_bss->ni_chan = ic->ic_ibss_chan;
rt2860_switch_chan(sc, ic->ic_ibss_chan);
diff --git a/sys/dev/ic/rt2860reg.h b/sys/dev/ic/rt2860reg.h
index 9229c89c068..a0e2a037b69 100644
--- a/sys/dev/ic/rt2860reg.h
+++ b/sys/dev/ic/rt2860reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2860reg.h,v 1.27 2010/04/05 14:14:02 damien Exp $ */
+/* $OpenBSD: rt2860reg.h,v 1.28 2010/04/06 16:41:54 damien Exp $ */
/*-
* Copyright (c) 2007
@@ -24,6 +24,8 @@
#define RT2860_PCI_SYSCTRL 0x000c
#define RT2860_PCIE_JTAG 0x0010
+#define RT3090_AUX_CTRL 0x010c
+
#define RT3070_OPT_14 0x0114
/* SCH/DMA registers */
diff --git a/sys/dev/ic/rt2860var.h b/sys/dev/ic/rt2860var.h
index 8fccfd0366f..b2f5b239454 100644
--- a/sys/dev/ic/rt2860var.h
+++ b/sys/dev/ic/rt2860var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2860var.h,v 1.15 2010/04/05 14:14:02 damien Exp $ */
+/* $OpenBSD: rt2860var.h,v 1.16 2010/04/06 16:41:54 damien Exp $ */
/*-
* Copyright (c) 2007
@@ -171,7 +171,7 @@ struct rt2860_softc {
struct {
uint8_t reg;
uint8_t val;
- } bbp[8];
+ } bbp[8], rf[10];
uint8_t leds;
uint16_t led[3];
uint32_t txpow20mhz[5];