summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2007-12-07 21:23:15 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2007-12-07 21:23:15 +0000
commit49ff01f0dc55da8fc0a240405983cf26512be7b9 (patch)
tree32a8820abe9ca5e6ce011cad05fa17df194bfb0b /sys
parent2acb2dd363fa92fc1a4ce4b36e50d81b2e93dfda (diff)
LEDs
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/rt2860.c60
-rw-r--r--sys/dev/ic/rt2860reg.h20
-rw-r--r--sys/dev/ic/rt2860var.h4
3 files changed, 73 insertions, 11 deletions
diff --git a/sys/dev/ic/rt2860.c b/sys/dev/ic/rt2860.c
index 16b5b0dc0d0..3de013cece8 100644
--- a/sys/dev/ic/rt2860.c
+++ b/sys/dev/ic/rt2860.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2860.c,v 1.8 2007/12/07 19:37:04 damien Exp $ */
+/* $OpenBSD: rt2860.c,v 1.9 2007/12/07 21:23:14 damien Exp $ */
/*-
* Copyright (c) 2007
@@ -122,6 +122,7 @@ void rt2860_set_basicrates(struct rt2860_softc *);
void rt2860_select_chan_group(struct rt2860_softc *, int);
void rt2860_set_chan(struct rt2860_softc *,
struct ieee80211_channel *);
+void rt2860_set_leds(struct rt2860_softc *, uint16_t);
void rt2860_set_bssid(struct rt2860_softc *, const uint8_t *);
void rt2860_set_macaddr(struct rt2860_softc *, const uint8_t *);
void rt2860_updateslot(struct ieee80211com *);
@@ -764,6 +765,11 @@ rt2860_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
timeout_del(&sc->scan_to);
timeout_del(&sc->amrr_to);
+ if (ostate == IEEE80211_S_RUN) {
+ /* light down link LED */
+ rt2860_set_leds(sc, RT2860_LED_RADIO);
+ }
+
switch (nstate) {
case IEEE80211_S_INIT:
if (ostate == IEEE80211_S_RUN) {
@@ -809,6 +815,11 @@ rt2860_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg)
rt2860_enable_tsf_sync(sc);
timeout_add(&sc->amrr_to, hz / 2);
}
+
+ /* light up link LED */
+ rt2860_set_leds(sc, RT2860_LED_RADIO |
+ (IEEE80211_IS_CHAN_2GHZ(ic->ic_bss->ni_chan) ?
+ RT2860_LED_LINK_2GHZ : RT2860_LED_LINK_5GHZ));
break;
}
@@ -1696,7 +1707,7 @@ rt2860_mcu_bbp_write(struct rt2860_softc *sc, uint8_t reg, uint8_t val)
RAL_WRITE(sc, RT2860_H2M_BBPAGENT, RT2860_BBP_RW_PARALLEL |
RT2860_BBP_CSR_KICK | reg << 8 | val);
- rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0);
+ (void)rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0);
DELAY(1000);
}
@@ -1720,7 +1731,7 @@ rt2860_mcu_bbp_read(struct rt2860_softc *sc, uint8_t reg)
RAL_WRITE(sc, RT2860_H2M_BBPAGENT, RT2860_BBP_RW_PARALLEL |
RT2860_BBP_CSR_KICK | RT2860_BBP_CSR_READ | reg << 8);
- rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0);
+ (void)rt2860_mcu_cmd(sc, RT2860_MCU_CMD_BBP, 0);
DELAY(1000);
for (ntries = 0; ntries < 100; ntries++) {
@@ -1949,6 +1960,13 @@ rt2860_set_chan(struct rt2860_softc *sc, struct ieee80211_channel *c)
}
void
+rt2860_set_leds(struct rt2860_softc *sc, uint16_t which)
+{
+ (void)rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LEDS,
+ which | (sc->leds & 0x7f));
+}
+
+void
rt2860_set_bssid(struct rt2860_softc *sc, const uint8_t *bssid)
{
RAL_WRITE(sc, RT2860_MAC_BSSID_DW0,
@@ -2216,6 +2234,26 @@ rt2860_read_eeprom(struct rt2860_softc *sc)
DPRINTF(("BBP%d=0x%02x\n", sc->bbp[i].reg, sc->bbp[i].val));
}
+ /* read RF frequency offset from EEPROM */
+ val = rt2860_eeprom_read(sc, RT2860_EEPROM_FREQ_LEDS);
+ sc->freq = ((val & 0xff) != 0xff) ? val & 0xff : 0;
+ DPRINTF(("EEPROM freq offset %d\n", sc->freq & 0xff));
+
+ /* read LEDs operating mode */
+ if ((sc->leds = val >> 8) != 0xff) {
+ sc->led[0] = rt2860_eeprom_read(sc, RT2860_EEPROM_LED1);
+ sc->led[1] = rt2860_eeprom_read(sc, RT2860_EEPROM_LED2);
+ sc->led[2] = rt2860_eeprom_read(sc, RT2860_EEPROM_LED3);
+ } else {
+ /* broken EEPROM, use default settings */
+ sc->leds = 0x01;
+ sc->led[0] = 0x5555;
+ sc->led[1] = 0x2221;
+ sc->led[2] = 0xa9f8;
+ }
+ DPRINTF(("EEPROM LED mode=0x%02x, LEDs=0x%04x/0x%04x/0x%04x\n",
+ sc->leds, sc->led[0], sc->led[1], sc->led[2]));
+
/* read RF information */
val = rt2860_eeprom_read(sc, RT2860_EEPROM_ANTENNA);
if (val == 0xffff) {
@@ -2362,11 +2400,6 @@ rt2860_read_eeprom(struct rt2860_softc *sc)
if (sc->tssi_5ghz[4] == 0xff)
sc->calib_5ghz = 0;
- /* read RF frequency offset from EEPROM */
- val = rt2860_eeprom_read(sc, RT2860_EEPROM_FREQ);
- sc->freq = ((val & 0xff) != 0xff) ? val & 0xff : 0;
- DPRINTF(("EEPROM freq offset %d\n", sc->freq & 0xff));
-
/* read RSSI offsets and LNA gains from EEPROM */
val = rt2860_eeprom_read(sc, RT2860_EEPROM_RSSI1_2GHZ);
sc->rssi_2ghz[0] = val & 0xff; /* Ant A */
@@ -2591,6 +2624,11 @@ rt2860_init(struct ifnet *ifp)
rt2860_mcu_bbp_write(sc, sc->bbp[i].reg, sc->bbp[i].val);
}
+ /* send LEDs operating mode to microcontroller */
+ (void)rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED1, sc->led[0]);
+ (void)rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED2, sc->led[1]);
+ (void)rt2860_mcu_cmd(sc, RT2860_MCU_CMD_LED3, sc->led[2]);
+
/* disable non-existing Rx chains */
bbp3 = rt2860_mcu_bbp_read(sc, 3);
bbp3 &= ~(1 << 3 | 1 << 4);
@@ -2630,6 +2668,9 @@ rt2860_init(struct ifnet *ifp)
RT2860_WPDMA_BT_SIZE64 << RT2860_WPDMA_BT_SIZE_SHIFT;
RAL_WRITE(sc, RT2860_WPDMA_GLO_CFG, tmp);
+ /* light up radio LED */
+ rt2860_set_leds(sc, RT2860_LED_RADIO);
+
/* set Rx filter */
tmp = RT2860_DROP_CRC_ERR | RT2860_DROP_PHY_ERR;
if (ic->ic_opmode != IEEE80211_M_MONITOR) {
@@ -2676,6 +2717,9 @@ rt2860_stop(struct ifnet *ifp, int disable)
ieee80211_new_state(ic, IEEE80211_S_INIT, -1); /* free all nodes */
+ /* light down all LEDs */
+ rt2860_set_leds(sc, 0);
+
/* clear RX WCID search table */
RAL_SET_REGION_4(sc, RT2860_WCID_ENTRY(0), 0, 512);
/* clear pairwise key table */
diff --git a/sys/dev/ic/rt2860reg.h b/sys/dev/ic/rt2860reg.h
index d13ec022aa2..d33bd8f6af5 100644
--- a/sys/dev/ic/rt2860reg.h
+++ b/sys/dev/ic/rt2860reg.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2860reg.h,v 1.4 2007/12/07 19:37:04 damien Exp $ */
+/* $OpenBSD: rt2860reg.h,v 1.5 2007/12/07 21:23:14 damien Exp $ */
/*-
* Copyright (c) 2007
@@ -262,6 +262,13 @@
#define RT2860_MCU_RESET (1 << 0)
/* possible values for register HOST_CMD */
+#define RT2860_MCU_CMD_SLEEP 0x30
+#define RT2860_MCU_CMD_WAKEUP 0x31
+#define RT2860_MCU_CMD_LEDS 0x50
+#define RT2860_MCU_CMD_LED_RSSI 0x51
+#define RT2860_MCU_CMD_LED1 0x52
+#define RT2860_MCU_CMD_LED2 0x53
+#define RT2860_MCU_CMD_LED3 0x54
#define RT2860_MCU_CMD_BBP 0x80
/* possible flags for register PBF_CFG */
@@ -613,6 +620,12 @@
#define RT2860_TOKEN_NO_INTR 0xff
+/* possible flags for MCU command RT2860_MCU_CMD_LEDS */
+#define RT2860_LED_RADIO (1 << 13)
+#define RT2860_LED_LINK_2GHZ (1 << 14)
+#define RT2860_LED_LINK_5GHZ (1 << 15)
+
+
/* TX descriptor */
struct rt2860_txd {
uint32_t sdp0; /* Segment Data Pointer 0 */
@@ -743,7 +756,10 @@ struct rt2860_rxwi {
#define RT2860_EEPROM_ANTENNA 0x1a
#define RT2860_EEPROM_CONFIG 0x1b
#define RT2860_EEPROM_COUNTRY 0x1c
-#define RT2860_EEPROM_FREQ 0x1d
+#define RT2860_EEPROM_FREQ_LEDS 0x1d
+#define RT2860_EEPROM_LED1 0x1e
+#define RT2860_EEPROM_LED2 0x1f
+#define RT2860_EEPROM_LED3 0x20
#define RT2860_EEPROM_LNA 0x22
#define RT2860_EEPROM_RSSI1_2GHZ 0x23
#define RT2860_EEPROM_RSSI2_2GHZ 0x24
diff --git a/sys/dev/ic/rt2860var.h b/sys/dev/ic/rt2860var.h
index 42705a14157..121383e482e 100644
--- a/sys/dev/ic/rt2860var.h
+++ b/sys/dev/ic/rt2860var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rt2860var.h,v 1.4 2007/12/07 19:37:04 damien Exp $ */
+/* $OpenBSD: rt2860var.h,v 1.5 2007/12/07 21:23:14 damien Exp $ */
/*-
* Copyright (c) 2007
@@ -152,6 +152,8 @@ struct rt2860_softc {
uint8_t reg;
uint8_t val;
} bbp[8];
+ uint8_t leds;
+ uint16_t led[3];
uint32_t txpow20mhz[5];
uint32_t txpow40mhz_2ghz[5];
uint32_t txpow40mhz_5ghz[5];