From owner-svn-src-head@freebsd.org Sun Jan 17 00:52:22 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8819A6AB6C; Sun, 17 Jan 2016 00:52:22 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 896231EC8; Sun, 17 Jan 2016 00:52:22 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0H0qLGc078701; Sun, 17 Jan 2016 00:52:21 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0H0qLB3078698; Sun, 17 Jan 2016 00:52:21 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201601170052.u0H0qLB3078698@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sun, 17 Jan 2016 00:52:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294198 - head/sys/dev/usb/wlan X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 17 Jan 2016 00:52:23 -0000 Author: avos Date: Sun Jan 17 00:52:21 2016 New Revision: 294198 URL: https://svnweb.freebsd.org/changeset/base/294198 Log: 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 Modified: head/sys/dev/usb/wlan/if_urtwn.c head/sys/dev/usb/wlan/if_urtwnreg.h head/sys/dev/usb/wlan/if_urtwnvar.h Modified: head/sys/dev/usb/wlan/if_urtwn.c ============================================================================== --- head/sys/dev/usb/wlan/if_urtwn.c Sun Jan 17 00:14:22 2016 (r294197) +++ head/sys/dev/usb/wlan/if_urtwn.c Sun Jan 17 00:52:21 2016 (r294198) @@ -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_soft 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_soft } /* 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; Modified: head/sys/dev/usb/wlan/if_urtwnreg.h ============================================================================== --- head/sys/dev/usb/wlan/if_urtwnreg.h Sun Jan 17 00:14:22 2016 (r294197) +++ head/sys/dev/usb/wlan/if_urtwnreg.h Sun Jan 17 00:52:21 2016 (r294198) @@ -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 Modified: head/sys/dev/usb/wlan/if_urtwnvar.h ============================================================================== --- head/sys/dev/usb/wlan/if_urtwnvar.h Sun Jan 17 00:14:22 2016 (r294197) +++ head/sys/dev/usb/wlan/if_urtwnvar.h Sun Jan 17 00:52:21 2016 (r294198) @@ -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;