summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2007-02-23 10:40:55 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2007-02-23 10:40:55 +0000
commitb2d35d8df48958f6aabb713845d4f45261d559ae (patch)
treeba25d76f4f4d4d2c870c63499f4a1150b56490f4 /sys/dev
parentef36c7fbbdba58dbbc72c8390ed82eb390e98458 (diff)
Complement bcw_phy_inita(), add bcw_radio_init2060().
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/bcw.c136
-rw-r--r--sys/dev/ic/bcwreg.h4
-rw-r--r--sys/dev/ic/bcwvar.h5
3 files changed, 140 insertions, 5 deletions
diff --git a/sys/dev/ic/bcw.c b/sys/dev/ic/bcw.c
index 5cd7fecd102..337d4615abd 100644
--- a/sys/dev/ic/bcw.c
+++ b/sys/dev/ic/bcw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcw.c,v 1.46 2007/02/22 21:26:49 mglocker Exp $ */
+/* $OpenBSD: bcw.c,v 1.47 2007/02/23 10:40:54 mglocker Exp $ */
/*
* Copyright (c) 2006 Jon Simola <jsimola@gmail.com>
@@ -157,13 +157,16 @@ void bcw_radio_set_all_gains(struct bcw_softc *, int16_t, int16_t,
int16_t);
void bcw_radio_set_original_gains(struct bcw_softc *);
uint16_t bcw_radio_calibrationvalue(struct bcw_softc *);
+void bcw_radio_set_txpower_a(struct bcw_softc *, uint16_t);
void bcw_radio_set_txpower_bg(struct bcw_softc *, uint16_t, uint16_t,
uint16_t);
+void bcw_radio_init2060(struct bcw_softc *);
void bcw_radio_spw(struct bcw_softc *, uint8_t);
int bcw_radio_channel(struct bcw_softc *, uint8_t, int );
int bcw_radio_chan2freq_bg(uint8_t);
uint16_t bcw_radio_defaultbaseband(struct bcw_softc *);
void bcw_radio_clear_tssi(struct bcw_softc *);
+void bcw_radio_set_tx_iq(struct bcw_softc *);
/* ilt */
void bcw_ilt_write(struct bcw_softc *, uint16_t, uint16_t);
uint16_t bcw_ilt_read(struct bcw_softc *, uint16_t);
@@ -3559,7 +3562,7 @@ bcw_phy_initb6(struct bcw_softc *sc)
void
bcw_phy_inita(struct bcw_softc *sc)
{
- //uint16_t val;
+ uint16_t tval;
if (sc->sc_phy_type == BCW_PHY_TYPEA)
bcw_phy_setupa(sc);
@@ -3569,6 +3572,42 @@ bcw_phy_inita(struct bcw_softc *sc)
bcw_phy_write16(sc, 0x046e, 0x03cf);
return;
}
+
+ bcw_phy_write16(sc, BCW_PHY_A_CRS, (bcw_phy_read16(sc, BCW_PHY_A_CRS) &
+ 0xf83c) | 0x0340);
+ bcw_phy_write16(sc, 0x0034, 0x0001);
+
+ bcw_phy_write16(sc, BCW_PHY_A_CRS, bcw_phy_read16(sc, BCW_PHY_A_CRS) |
+ (1 << 14));
+ bcw_radio_init2060(sc);
+
+ if (1) { /* XXX board_vendor, board_type */
+ if (sc->sc_radio_lofcal == 0xffff)
+ bcw_radio_set_tx_iq(sc);
+ else
+ bcw_radio_write16(sc, 0x001e, sc->sc_radio_lofcal);
+ }
+
+ bcw_phy_write16(sc, 0x007a, 0xf111);
+
+ if (sc->sc_phy_savedpctlreg == 0xffff) {
+ bcw_radio_write16(sc, 0x0019, 0x0000);
+ bcw_radio_write16(sc, 0x0017, 0x0020);
+
+ tval = bcw_ilt_read(sc, 0x3001);
+ if (sc->sc_phy_rev == 1)
+ bcw_ilt_write(sc, 0x3001, (bcw_ilt_read(sc, 0x3001) &
+ 0xff87) | 0x0058);
+ else
+ bcw_ilt_write(sc, 0x3001, (bcw_ilt_read(sc, 0x3001) &
+ 0xffc3) | 0x002c);
+ bcw_dummy_transmission(sc);
+ sc->sc_phy_savedpctlreg = bcw_phy_read16(sc, BCW_PHY_A_PCTL);
+ bcw_ilt_write(sc, 0x3001, tval);
+
+ bcw_radio_set_txpower_a(sc, 0x0018);
+ }
+ bcw_radio_clear_tssi(sc);
}
void
@@ -5096,6 +5135,34 @@ bcw_radio_calibrationvalue(struct bcw_softc *sc)
}
void
+bcw_radio_set_txpower_a(struct bcw_softc *sc, uint16_t txpower)
+{
+ uint16_t pamp, base, dac, ilt;
+
+ /* TODO txpower = limit_value(txpower, 0, 63); */
+
+ /* TODO pamp = bcw_get_txgain_freq_power_amp(txpower); */
+ pamp <<= 5;
+ pamp &= 0x00e0;
+ bcw_phy_write16(sc, 0x0019, pamp);
+
+ /*TODO base = bcw_get_txgain_banseband(txpower); */
+ base &= 0x000f;
+ bcw_phy_write16(sc, 0x0017, base | 0x0020);
+
+ ilt = bcw_ilt_read(sc, 0x3001);
+ ilt &= 0x0007;
+
+ /* TODO dac = bcw_get_txgain_dac(txpower); */
+ dac <<= 3;
+ dac |= ilt;
+
+ bcw_ilt_write(sc, 0x3001, dac);
+
+ sc->sc_radio_txpwr_offset = txpower;
+}
+
+void
bcw_radio_set_txpower_bg(struct bcw_softc *sc, uint16_t baseband_atten,
uint16_t radio_atten, uint16_t txpower)
{
@@ -5125,6 +5192,50 @@ bcw_radio_set_txpower_bg(struct bcw_softc *sc, uint16_t baseband_atten,
}
void
+bcw_radio_init2060(struct bcw_softc *sc)
+{
+ int error;
+
+ bcw_radio_write16(sc, 0x0004, 0x00c0);
+ bcw_radio_write16(sc, 0x0005, 0x0008);
+ bcw_radio_write16(sc, 0x0009, 0x0040);
+ bcw_radio_write16(sc, 0x0005, 0x00aa);
+ bcw_radio_write16(sc, 0x0032, 0x008f);
+ bcw_radio_write16(sc, 0x0006, 0x008f);
+ bcw_radio_write16(sc, 0x0034, 0x008f);
+ bcw_radio_write16(sc, 0x002c, 0x0007);
+ bcw_radio_write16(sc, 0x0082, 0x0080);
+ bcw_radio_write16(sc, 0x0080, 0x0000);
+ bcw_radio_write16(sc, 0x003f, 0x00d4);
+ bcw_radio_write16(sc, 0x0005, bcw_radio_read16(sc, 0x0005) & ~0x0008);
+ bcw_radio_write16(sc, 0x0081, bcw_radio_read16(sc, 0x0081) & ~0x0010);
+ bcw_radio_write16(sc, 0x0081, bcw_radio_read16(sc, 0x0081) & ~0x0020);
+ bcw_radio_write16(sc, 0x0081, bcw_radio_read16(sc, 0x0081) & ~0x0020);
+ delay(400);
+ bcw_radio_write16(sc, 0x0081, (bcw_radio_read16(sc, 0x0081) & ~0x0020) |
+ 0x0010);
+ delay(400);
+ bcw_radio_write16(sc, 0x0005, (bcw_radio_read16(sc, 0x0005) & ~0x0020) |
+ 0x0008);
+ bcw_radio_write16(sc, 0x0085, bcw_radio_read16(sc, 0x0085) & ~0x0010);
+ bcw_radio_write16(sc, 0x0005, bcw_radio_read16(sc, 0x0005) & ~0x0008);
+ bcw_radio_write16(sc, 0x0081, bcw_radio_read16(sc, 0x0081) & ~0x0040);
+ bcw_radio_write16(sc, 0x0081, (bcw_radio_read16(sc, 0x0081) & ~0x0040) |
+ 0x0040);
+ bcw_radio_write16(sc, 0x0005, (bcw_radio_read16(sc, 0x0081) & ~0x0008) |
+ 0x0008);
+ bcw_phy_write16(sc, 0x0063, 0xddc6);
+ bcw_phy_write16(sc, 0x0069, 0x07be);
+ bcw_phy_write16(sc, 0x006a, 0x0000);
+
+ error = bcw_radio_channel(sc, BCW_RADIO_DEFAULT_CHANNEL_A, 0);
+
+ /* XXX assert(error == 0) ? */
+
+ delay(1000);
+}
+
+void
bcw_radio_spw(struct bcw_softc *sc, uint8_t channel)
{
if (sc->sc_radio_ver != 0x2050 || sc->sc_radio_rev >= 6)
@@ -5187,7 +5298,7 @@ bcw_radio_channel(struct bcw_softc *sc, uint8_t channel, int spw)
bcw_radio_write16(sc, 0x0035, (bcw_radio_read16(sc, 0x0035) &
0xffef) | 0x0010);
- /* TODO bcw_radio_set_tx_iq() */
+ bcw_radio_set_tx_iq(sc);
/* TODO bcw_radio_phy_xmitpower() */
} else {
@@ -5247,6 +5358,25 @@ bcw_radio_clear_tssi(struct bcw_softc *sc)
}
}
+void
+bcw_radio_set_tx_iq(struct bcw_softc *sc)
+{
+ const uint8_t data_high[5] = { 0x00, 0x40, 0x80, 0x90, 0xD0 };
+ const uint8_t data_low[5] = { 0x00, 0x01, 0x05, 0x06, 0x0A };
+ uint16_t tmp = bcw_radio_read16(sc, 0x001e);
+ int i, j;
+
+ for (i = 0; i < 5; i++) {
+ for (j = 0; j < 5; j++) {
+ if (tmp == (data_high[i] << 4 | data_low[j])) {
+ bcw_phy_write16(sc, 0x0069, (i - j) << 8 |
+ 0x00c0);
+ return;
+ }
+ }
+ }
+}
+
/*
* ILT
*/
diff --git a/sys/dev/ic/bcwreg.h b/sys/dev/ic/bcwreg.h
index f674bbf2845..22f34594a12 100644
--- a/sys/dev/ic/bcwreg.h
+++ b/sys/dev/ic/bcwreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcwreg.h,v 1.14 2007/02/22 17:04:31 mglocker Exp $ */
+/* $OpenBSD: bcwreg.h,v 1.15 2007/02/23 10:40:54 mglocker Exp $ */
/*
* Copyright (c) 2006 Jon Simola <jsimola@gmail.com>
@@ -354,8 +354,10 @@
#define BCW_PHY_ILT_G_CTRL 0x0472
#define BCW_PHY_ILT_G_DATA1 0x0473
#define BCW_PHY_G_CRS 0x0429
+#define BCW_PHY_A_CRS 0x0029
#define BCW_PHY_NRSSILT_CTRL 0x0803
#define BCW_PHY_NRSSILT_DATA 0x0804
+#define BCW_PHY_A_PCTL 0x007b
#define BCW_PHY_G_PCTL 0x0029
#define BCW_READ16(sc, reg) \
diff --git a/sys/dev/ic/bcwvar.h b/sys/dev/ic/bcwvar.h
index 5d4e32be5bf..632a36e22ba 100644
--- a/sys/dev/ic/bcwvar.h
+++ b/sys/dev/ic/bcwvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcwvar.h,v 1.19 2007/02/22 21:26:49 mglocker Exp $ */
+/* $OpenBSD: bcwvar.h,v 1.20 2007/02/23 10:40:54 mglocker Exp $ */
/*
* Copyright (c) 2006 Jon Simola <jsimola@gmail.com>
@@ -72,6 +72,7 @@ enum {
};
#define BCW_RADIO_INTERFMODE_NONWLAN 1
+#define BCW_RADIO_DEFAULT_CHANNEL_A 36
#define BCW_RADIO_DEFAULT_CHANNEL_BG 6
#define BCW_RADIO_MAX 2
struct bcw_radio {
@@ -250,6 +251,8 @@ struct bcw_softc {
sc_radio_aci_wlan_automatic:1,
sc_radio_aci_hw_rssi;
int32_t sc_radio_nrssislope;
+ uint16_t sc_radio_txpwr_offset;
+ uint16_t sc_radio_lofcal;
uint32_t sc_phyinfo;
uint16_t sc_numcores;
uint16_t sc_havecommon;