summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcus Glocker <mglocker@cvs.openbsd.org>2007-02-18 00:05:40 +0000
committerMarcus Glocker <mglocker@cvs.openbsd.org>2007-02-18 00:05:40 +0000
commit6d7b2d932b62f66b95bcad9abc64e86f444ac814 (patch)
treea05232857d97375224778eb726b7c977696c92a7
parent5cb17b9e44e0f5b04df3d136964b9cd4e2296206 (diff)
Turn radio (version 2050) on.
-rw-r--r--sys/dev/ic/bcw.c62
-rw-r--r--sys/dev/ic/bcwreg.h4
-rw-r--r--sys/dev/ic/bcwvar.h7
3 files changed, 61 insertions, 12 deletions
diff --git a/sys/dev/ic/bcw.c b/sys/dev/ic/bcw.c
index 4cdb00df7d7..659a2e436c6 100644
--- a/sys/dev/ic/bcw.c
+++ b/sys/dev/ic/bcw.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcw.c,v 1.36 2007/01/14 10:48:23 mglocker Exp $ */
+/* $OpenBSD: bcw.c,v 1.37 2007/02/18 00:05:39 mglocker Exp $ */
/*
* Copyright (c) 2006 Jon Simola <jsimola@gmail.com>
@@ -105,6 +105,8 @@ int bcw_change_core(struct bcw_softc *, int);
void bcw_radio_off(struct bcw_softc *);
void bcw_radio_on(struct bcw_softc *);
int bcw_radio_channel(struct bcw_softc *, uint8_t, int );
+void bcw_spw(struct bcw_softc *, uint8_t);
+int bcw_chan2freq_bg(uint8_t);
int bcw_reset_core(struct bcw_softc *, uint32_t);
int bcw_get_firmware(const char *, const uint8_t *, size_t,
size_t *, size_t *);
@@ -1220,7 +1222,9 @@ bcw_init(struct ifnet *ifp)
return (error);
/* turn radio on */
- //bcw_radio_on(sc);
+ bcw_radio_on(sc);
+
+ BCW_WRITE16(sc, 0x03e6, 0);
return (0);
@@ -2161,6 +2165,8 @@ bcw_radio_off(struct bcw_softc *sc)
0xff73);
} else
bcw_phy_write16(sc, 0x0015, 0xaa00);
+
+ DPRINTF(("%s: Radio turned off\n", sc->sc_dev.dv_xname));
}
void
@@ -2180,13 +2186,15 @@ bcw_radio_on(struct bcw_softc *sc)
case BCW_PHY_TYPEG:
bcw_phy_write16(sc, 0x0015, 0x8000);
bcw_phy_write16(sc, 0x0015, 0xcc00);
- /* XXX we must check for phy connected later */
- bcw_phy_write16(sc, 0x0015, 1 ? 0x00c0 : 0);
- /* TODO bcw_radio_channel() */
+ bcw_phy_write16(sc, 0x0015, 0); /* XXX check for phy connect */
+ if (bcw_radio_channel(sc, BCW_RADIO_DEFAULT_CHANNEL, 1))
+ return;
break;
default:
- break;
+ return;
}
+
+ DPRINTF(("%s: Radio turned on\n", sc->sc_dev.dv_xname));
}
int
@@ -2208,7 +2216,8 @@ bcw_radio_channel(struct bcw_softc *sc, uint8_t channel, int spw)
if (freq >= 4920 && freq <= 5500)
r8 = 3 * freq / 116;
- if (1) {
+ if (sc->sc_radioid == 0x17f && sc->sc_radiotype == 0x2060 &&
+ sc->sc_radiorev == 1) {
bcw_radio_write16(sc, 0x0007, (r8 << 4) | r8);
bcw_radio_write16(sc, 0x0020, (r8 << 4) | r8);
bcw_radio_write16(sc, 0x0021, (r8 << 4) | r8);
@@ -2237,7 +2246,12 @@ bcw_radio_channel(struct bcw_softc *sc, uint8_t channel, int spw)
/* TODO bcw_radio_phy_xmitpower() */
} else {
- /* TODO */
+ if (spw)
+ bcw_spw(sc, channel);
+
+ BCW_WRITE16(sc, BCW_MMIO_CHANNEL, bcw_chan2freq_bg(channel));
+
+ /* TODO more stuff if channel = 14 */
}
delay(8000);
@@ -2245,6 +2259,38 @@ bcw_radio_channel(struct bcw_softc *sc, uint8_t channel, int spw)
return (0);
}
+void
+bcw_spw(struct bcw_softc *sc, uint8_t channel)
+{
+ if (sc->sc_radiotype != 0x2050 || sc->sc_radiorev >= 6)
+ /* we do not need the workaround */
+ return;
+
+ if (channel <= 10)
+ BCW_WRITE16(sc, BCW_MMIO_CHANNEL,
+ bcw_chan2freq_bg(channel + 4));
+ else
+ BCW_WRITE16(sc, BCW_MMIO_CHANNEL, bcw_chan2freq_bg(1));
+
+ delay(100);
+
+ BCW_WRITE16(sc, BCW_MMIO_CHANNEL, bcw_chan2freq_bg(channel));
+}
+
+int
+bcw_chan2freq_bg(uint8_t channel)
+{
+ static const uint16_t freqs_bg[14] = {
+ 12, 17, 22, 27,
+ 32, 37, 42, 47,
+ 52, 57, 62, 67,
+ 72, 84 };
+
+ if (channel < 1 && channel > 14)
+ return (0);
+
+ return (freqs_bg[channel - 1]);
+}
int
bcw_reset_core(struct bcw_softc *sc, uint32_t flags)
diff --git a/sys/dev/ic/bcwreg.h b/sys/dev/ic/bcwreg.h
index bab710fce00..aae2d3ca578 100644
--- a/sys/dev/ic/bcwreg.h
+++ b/sys/dev/ic/bcwreg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcwreg.h,v 1.10 2007/01/07 00:29:44 mglocker Exp $ */
+/* $OpenBSD: bcwreg.h,v 1.11 2007/02/18 00:05:39 mglocker Exp $ */
/*
* Copyright (c) 2006 Jon Simola <jsimola@gmail.com>
@@ -338,6 +338,8 @@
#define BCW_GPIO_MASK 0x49e
#define BCW_GPIO_CTRL 0x6c
+#define BCW_MMIO_CHANNEL 0x3f0
+
/* LEDS */
#define BCW_NR_LEDS 4
diff --git a/sys/dev/ic/bcwvar.h b/sys/dev/ic/bcwvar.h
index fabf8c6253b..792a0004498 100644
--- a/sys/dev/ic/bcwvar.h
+++ b/sys/dev/ic/bcwvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcwvar.h,v 1.13 2007/01/07 00:29:44 mglocker Exp $ */
+/* $OpenBSD: bcwvar.h,v 1.14 2007/02/18 00:05:39 mglocker Exp $ */
/*
* Copyright (c) 2006 Jon Simola <jsimola@gmail.com>
@@ -71,7 +71,8 @@ enum {
BCW_LED_BCM4303_3 = 0x19,
};
-#define BCW_MAX_RADIOS 2
+#define BCW_RADIO_DEFAULT_CHANNEL 6
+#define BCW_RADIO_MAX 2
struct bcw_radio {
uint16_t id;
uint16_t info;
@@ -207,7 +208,7 @@ struct bcw_softc {
uint16_t sc_chiprev; /* Chip Revision */
uint16_t sc_prodid; /* Product ID */
struct bcw_core sc_core[BCW_MAX_CORES];
-// struct bcw_radio radio[BCW_MAX_RADIOS];
+// struct bcw_radio radio[BCW_RADIO_MAX];
uint16_t sc_phy_version;
uint16_t sc_phy_type;
uint16_t sc_phy_rev;