diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2007-12-07 21:23:15 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2007-12-07 21:23:15 +0000 |
commit | 49ff01f0dc55da8fc0a240405983cf26512be7b9 (patch) | |
tree | 32a8820abe9ca5e6ce011cad05fa17df194bfb0b /sys/dev/ic/rt2860.c | |
parent | 2acb2dd363fa92fc1a4ce4b36e50d81b2e93dfda (diff) |
LEDs
Diffstat (limited to 'sys/dev/ic/rt2860.c')
-rw-r--r-- | sys/dev/ic/rt2860.c | 60 |
1 files changed, 52 insertions, 8 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 */ |