diff options
author | avos <avos@FreeBSD.org> | 2016-01-17 00:52:21 +0000 |
---|---|---|
committer | avos <avos@FreeBSD.org> | 2016-01-17 00:52:21 +0000 |
commit | f6c1bea004ecaa12d094346b2d959a51eceb1ebd (patch) | |
tree | 3cf4447536096b02d3e3a8dcee190d2afc78d43b | |
parent | c9a5e0d1165c1bba24e6158f440ff0a6f621d797 (diff) | |
download | FreeBSD-src-f6c1bea004ecaa12d094346b2d959a51eceb1ebd.zip FreeBSD-src-f6c1bea004ecaa12d094346b2d959a51eceb1ebd.tar.gz |
urtwn: add ROM structure for RTL8188EU
- Add the structure with already known fields offsets
(some of them were taken from this driver,
some (channel_plan, rf_* fields) - from TP-LINK official driver)
- Fix a typo / dehardcode a constant in RTL8192C ROM structure.
Tested with RTL8188EU, STA mode
Reviewed by: kevlo
Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D4274
-rw-r--r-- | sys/dev/usb/wlan/if_urtwn.c | 28 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_urtwnreg.h | 34 | ||||
-rw-r--r-- | sys/dev/usb/wlan/if_urtwnvar.h | 8 |
3 files changed, 47 insertions, 23 deletions
diff --git a/sys/dev/usb/wlan/if_urtwn.c b/sys/dev/usb/wlan/if_urtwn.c index 13f3926..7466d1a 100644 --- a/sys/dev/usb/wlan/if_urtwn.c +++ b/sys/dev/usb/wlan/if_urtwn.c @@ -1707,27 +1707,22 @@ urtwn_read_rom(struct urtwn_softc *sc) static int urtwn_r88e_read_rom(struct urtwn_softc *sc) { - uint8_t *rom = sc->rom.r88e_rom; - uint16_t addr; - int error, i; + struct r88e_rom *rom = &sc->rom.r88e_rom; + int error; - error = urtwn_efuse_read(sc, rom, sizeof(sc->rom.r88e_rom)); + error = urtwn_efuse_read(sc, (uint8_t *)rom, sizeof(sc->rom.r88e_rom)); if (error != 0) return (error); - addr = 0x10; - for (i = 0; i < 6; i++) - sc->cck_tx_pwr[i] = rom[addr++]; - for (i = 0; i < 5; i++) - sc->ht40_tx_pwr[i] = rom[addr++]; - sc->bw20_tx_pwr_diff = (rom[addr] & 0xf0) >> 4; + sc->bw20_tx_pwr_diff = (rom->tx_pwr_diff >> 4); if (sc->bw20_tx_pwr_diff & 0x08) sc->bw20_tx_pwr_diff |= 0xf0; - sc->ofdm_tx_pwr_diff = (rom[addr] & 0xf); + sc->ofdm_tx_pwr_diff = (rom->tx_pwr_diff & 0xf); if (sc->ofdm_tx_pwr_diff & 0x08) sc->ofdm_tx_pwr_diff |= 0xf0; - sc->regulatory = MS(rom[0xc1], R92C_ROM_RF1_REGULATORY); - IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, &rom[0xd7]); + sc->regulatory = MS(rom->rf_board_opt, R92C_ROM_RF1_REGULATORY); + DPRINTF("regulatory type=%d\n", sc->regulatory); + IEEE80211_ADDR_COPY(sc->sc_ic.ic_macaddr, rom->macaddr); sc->sc_rf_write = urtwn_r88e_rf_write; sc->sc_power_on = urtwn_r88e_power_on; @@ -3620,7 +3615,7 @@ urtwn_bb_init(struct urtwn_softc *sc) urtwn_bb_write(sc, R92C_OFDM0_AGCCORE1(0), 0x69553420); urtwn_ms_delay(sc); - crystalcap = sc->rom.r88e_rom[0xb9]; + crystalcap = sc->rom.r88e_rom.crystalcap; if (crystalcap == 0xff) crystalcap = 0x20; crystalcap &= 0x3f; @@ -4002,6 +3997,7 @@ urtwn_r88e_get_txpower(struct urtwn_softc *sc, int chain, uint16_t power[URTWN_RIDX_COUNT]) { struct ieee80211com *ic = &sc->sc_ic; + struct r88e_rom *rom = &sc->rom.r88e_rom; uint16_t cckpow, ofdmpow, bw20pow, htpow; const struct urtwn_r88e_txpwr *base; int ridx, chan, group; @@ -4040,14 +4036,14 @@ urtwn_r88e_get_txpower(struct urtwn_softc *sc, int chain, } /* Compute per-CCK rate Tx power. */ - cckpow = sc->cck_tx_pwr[group]; + cckpow = rom->cck_tx_pwr[group]; for (ridx = URTWN_RIDX_CCK1; ridx <= URTWN_RIDX_CCK11; ridx++) { power[ridx] += cckpow; if (power[ridx] > R92C_MAX_TX_PWR) power[ridx] = R92C_MAX_TX_PWR; } - htpow = sc->ht40_tx_pwr[group]; + htpow = rom->ht40_tx_pwr[group]; /* Compute per-OFDM rate Tx power. */ ofdmpow = htpow + sc->ofdm_tx_pwr_diff; diff --git a/sys/dev/usb/wlan/if_urtwnreg.h b/sys/dev/usb/wlan/if_urtwnreg.h index 2c5f2ef..f4d1d73 100644 --- a/sys/dev/usb/wlan/if_urtwnreg.h +++ b/sys/dev/usb/wlan/if_urtwnreg.h @@ -953,7 +953,7 @@ struct r92c_rom { uint16_t reserved3; uint8_t usb_phy; uint8_t reserved4[3]; - uint8_t macaddr[6]; + uint8_t macaddr[IEEE80211_ADDR_LEN]; uint8_t string[61]; /* "Realtek" */ uint8_t subcustomer_id; uint8_t cck_tx_pwr[R92C_MAX_CHAINS][3]; @@ -982,7 +982,37 @@ struct r92c_rom { uint8_t rf_opt4; uint8_t channel_plan; uint8_t version; - uint8_t curstomer_id; + uint8_t customer_id; +} __packed; + +/* + * RTL8188EU ROM image. + */ +struct r88e_rom { + uint8_t reserved1[16]; + uint8_t cck_tx_pwr[6]; + uint8_t ht40_tx_pwr[5]; + uint8_t tx_pwr_diff; + uint8_t reserved2[156]; + uint8_t channel_plan; + uint8_t crystalcap; + uint8_t reserved3[7]; + uint8_t rf_board_opt; + uint8_t rf_feature_opt; + uint8_t rf_bt_opt; + uint8_t version; + uint8_t customer_id; + uint8_t reserved4[3]; + uint8_t rf_ant_opt; + uint8_t reserved5[6]; + uint16_t vid; + uint16_t pid; + uint8_t usb_opt; + uint8_t reserved6[2]; + uint8_t macaddr[IEEE80211_ADDR_LEN]; + uint8_t reserved7[2]; + uint8_t string[33]; /* "realtek 802.11n NIC" */ + uint8_t reserved8[256]; } __packed; #define URTWN_EFUSE_MAX_LEN 512 diff --git a/sys/dev/usb/wlan/if_urtwnvar.h b/sys/dev/usb/wlan/if_urtwnvar.h index 8eb7fb6..40ad1ca 100644 --- a/sys/dev/usb/wlan/if_urtwnvar.h +++ b/sys/dev/usb/wlan/if_urtwnvar.h @@ -141,7 +141,7 @@ enum { union urtwn_rom { struct r92c_rom r92c_rom; - uint8_t r88e_rom[URTWN_EFUSE_MAX_LEN]; + struct r88e_rom r88e_rom; }; struct urtwn_softc { @@ -176,6 +176,8 @@ struct urtwn_softc { uint8_t board_type; uint8_t regulatory; uint8_t pa_setting; + int8_t ofdm_tx_pwr_diff; + int8_t bw20_tx_pwr_diff; int avg_pwdb; int thcal_state; int thcal_lctemp; @@ -199,10 +201,6 @@ struct urtwn_softc { void *fw_virtaddr; union urtwn_rom rom; - uint8_t cck_tx_pwr[6]; - uint8_t ht40_tx_pwr[5]; - int8_t bw20_tx_pwr_diff; - int8_t ofdm_tx_pwr_diff; uint16_t last_rom_addr; struct callout sc_watchdog_ch; |