From patchwork Thu Sep 20 09:11:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10607223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 81E7C14BD for ; Thu, 20 Sep 2018 09:25:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D9A12CDB7 for ; Thu, 20 Sep 2018 09:25:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6129F2CC06; Thu, 20 Sep 2018 09:25:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1CCE52CC06 for ; Thu, 20 Sep 2018 09:25:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=sfBEKkht8QLbq2K29euLLQp0h9ti4PQNVZqy0UCgAgo=; b=pSjNmJIQ8tOQgdZKD08Jsk+ik3 RNieK/aq0YLI8uSW2r0brMrCyzFW8qoT7CQXDoaoC27elpNCq66jFk1NWEZq4qaGm+nNhpnr8v2EF gf0QekdgOvf/huBfLvKArqnb8r2xTSQ2OtskA0rhgnDyDLbhaPrfwKnUbCPN5ZSB8qZTxTjmkmxDk UfADVOomThSLUPlNsge3XYpuMlOlOCQBPOUVWNVfNOTQvEUFYPwlHe9vS6Ud0DtccE4SRBRFqlPRx QNK73AtS5KM7qlEQi9m7xNpueDh1m/eJeuR1y3coI/gD2EOCS7F6ND6maceSznN0i1YZtw2gcyAyD YR1TSvog==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2vCz-0006XQ-63; Thu, 20 Sep 2018 09:25:13 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2vCn-0006Dy-Pr for linux-mediatek@bombadil.infradead.org; Thu, 20 Sep 2018 09:25:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=11IHtODnFdTrf4yR6ESPEqelh8x6D7lbJdyCF6NPMG4=; b=nzmqggo0sZxdO0VlWe1RJlxjG oywSX2Mnlyo+oe5VjRtzU065Rg9JGcwYQrOH05x0KHO+IEdcV+vc1I1Yx52zRTmjwued988Du3TL7 Fmak7TmCM21TIQIBW6c/D7TP3+jgMozYI0MQM/cYa7kBMkSHdh32bPDfg0C4ewpUt3KrNUTArCF3j D2+UT7FQtN+leUTXnZS5eulJ8HOPL0dxT6/aj03WVu3mHqQxcViR/ScROe/Hds4yfLV/i139k5679 ZUNYeGJxiECgoEizv5SrkAoCNOJ+TQVJS0quETJiUUOnz61k2ToyHWYXlLumTO271nfSt+/9JfTJk mcDxnwicQ==; Received: from mail-wm1-f66.google.com ([209.85.128.66]) by casper.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2v0r-000494-9j for linux-mediatek@lists.infradead.org; Thu, 20 Sep 2018 09:12:43 +0000 Received: by mail-wm1-f66.google.com with SMTP id n11-v6so10014059wmc.2 for ; Thu, 20 Sep 2018 02:12:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=11IHtODnFdTrf4yR6ESPEqelh8x6D7lbJdyCF6NPMG4=; b=ZjcFZwZ6xeM9uMyfph9+LzycEFLquQtNx97uI0YvbhuIlGiHP5X4CUx/XgZeGLgAbd FVxcTKJRi9S/nBD8Cy9fJCS6N2lEaKpoYnHVnXal4AenGgN7CZbshbAqqN2cax9GDcfQ d99U5/CJvjdK/E5a1+apdMSnQohGnEcVp3PE9htiTync19AV4WwWE6dem76M0bSjBpdL 1hgbKaxa0/r3+3vO+mIH2lYiEJFEw6Kv5qo9BApS7+rPIBbQdrnONZY0bBoQ9yieSlfv YauYewNk24BoZwaq0X2t0armP3JQrLU5f6AJoQ2mlS0k03WSUZv5JN0xwurmUs84uOu1 NRnw== X-Gm-Message-State: APzg51BwuSNv0zrwj2EXW8+wSvz+EuXqflNUQkJXeedN8pufu/A7jA6u Yo7aZOozZy4QsqWz0/1uz0oozQ== X-Google-Smtp-Source: ANB0VdawNUfx5C5MdSKS3qhsT85zF1jGOZpqxL/aJONDjIRUFHhHZw7X0PYxxmQIkUV0dR4k2oFpxQ== X-Received: by 2002:a1c:2787:: with SMTP id n129-v6mr1488786wmn.101.1537434750025; Thu, 20 Sep 2018 02:12:30 -0700 (PDT) Received: from localhost.localdomain.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id 34-v6sm35501691wra.20.2018.09.20.02.12.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 02:12:28 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Subject: [PATCH 05/20] mt76: move mt76x2_eeprom_get in mt76x02_eeprom.h Date: Thu, 20 Sep 2018 11:11:52 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180920_101241_354280_BC035502 X-CRM114-Status: GOOD ( 16.90 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sgruszka@redhat.com, linux-mediatek@lists.infradead.org, linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Move mt76x2_eeprom_get utility routine in mt76x02_eeprom.h since it will be used to parse mt76x0 eeprom in order to unify eeprom support between mt76x2 and mt76x0 drivers Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt76x02_eeprom.h | 10 +++ .../wireless/mediatek/mt76/mt76x2_eeprom.c | 87 +++++++++++-------- .../wireless/mediatek/mt76/mt76x2_eeprom.h | 17 +--- .../net/wireless/mediatek/mt76/mt76x2_init.c | 6 +- .../net/wireless/mediatek/mt76/mt76x2_mcu.c | 2 +- .../mediatek/mt76/mt76x2_mcu_common.c | 5 +- .../net/wireless/mediatek/mt76/mt76x2_phy.c | 2 +- .../net/wireless/mediatek/mt76/mt76x2u_mac.c | 6 +- .../net/wireless/mediatek/mt76/mt76x2u_phy.c | 2 +- 9 files changed, 77 insertions(+), 60 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h index 1575c2352d9b..85dd4f9b97a5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_eeprom.h @@ -136,4 +136,14 @@ mt76x02_sign_extend(u32 val, unsigned int size) return sign ? val : -val; } +static inline int +mt76x02_eeprom_get(struct mt76_dev *dev, + enum mt76x02_eeprom_field field) +{ + if ((field & 1) || field >= __MT_EE_MAX) + return -1; + + return get_unaligned_le16(dev->eeprom.data + field); +} + #endif /* __MT76x02_EEPROM_H */ diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c index 2db495d9f99f..aea8033f13ce 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.c @@ -42,7 +42,7 @@ mt76x2_eeprom_get_macaddr(struct mt76x2_dev *dev) void mt76x2_eeprom_parse_hw_cap(struct mt76x2_dev *dev) { - u16 val = mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_0); + u16 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_0); switch (FIELD_GET(MT_EE_NIC_CONF_0_BOARD_TYPE, val)) { case BOARD_TYPE_5GHZ: @@ -319,17 +319,23 @@ mt76x2_get_5g_rx_gain(struct mt76x2_dev *dev, u8 channel) group = mt76x2_get_cal_channel_group(channel); switch (group) { case MT_CH_5G_JAPAN: - return mt76x2_eeprom_get(dev, MT_EE_RF_5G_GRP0_1_RX_HIGH_GAIN); + return mt76x02_eeprom_get(&dev->mt76, + MT_EE_RF_5G_GRP0_1_RX_HIGH_GAIN); case MT_CH_5G_UNII_1: - return mt76x2_eeprom_get(dev, MT_EE_RF_5G_GRP0_1_RX_HIGH_GAIN) >> 8; + return mt76x02_eeprom_get(&dev->mt76, + MT_EE_RF_5G_GRP0_1_RX_HIGH_GAIN) >> 8; case MT_CH_5G_UNII_2: - return mt76x2_eeprom_get(dev, MT_EE_RF_5G_GRP2_3_RX_HIGH_GAIN); + return mt76x02_eeprom_get(&dev->mt76, + MT_EE_RF_5G_GRP2_3_RX_HIGH_GAIN); case MT_CH_5G_UNII_2E_1: - return mt76x2_eeprom_get(dev, MT_EE_RF_5G_GRP2_3_RX_HIGH_GAIN) >> 8; + return mt76x02_eeprom_get(&dev->mt76, + MT_EE_RF_5G_GRP2_3_RX_HIGH_GAIN) >> 8; case MT_CH_5G_UNII_2E_2: - return mt76x2_eeprom_get(dev, MT_EE_RF_5G_GRP4_5_RX_HIGH_GAIN); + return mt76x02_eeprom_get(&dev->mt76, + MT_EE_RF_5G_GRP4_5_RX_HIGH_GAIN); default: - return mt76x2_eeprom_get(dev, MT_EE_RF_5G_GRP4_5_RX_HIGH_GAIN) >> 8; + return mt76x02_eeprom_get(&dev->mt76, + MT_EE_RF_5G_GRP4_5_RX_HIGH_GAIN) >> 8; } } @@ -342,30 +348,31 @@ void mt76x2_read_rx_gain(struct mt76x2_dev *dev) u16 val; if (chan->band == NL80211_BAND_2GHZ) - val = mt76x2_eeprom_get(dev, MT_EE_RF_2G_RX_HIGH_GAIN) >> 8; + val = mt76x02_eeprom_get(&dev->mt76, + MT_EE_RF_2G_RX_HIGH_GAIN) >> 8; else val = mt76x2_get_5g_rx_gain(dev, channel); mt76x2_set_rx_gain_group(dev, val); if (chan->band == NL80211_BAND_2GHZ) { - val = mt76x2_eeprom_get(dev, MT_EE_RSSI_OFFSET_2G_0); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_RSSI_OFFSET_2G_0); mt76x2_set_rssi_offset(dev, 0, val); mt76x2_set_rssi_offset(dev, 1, val >> 8); } else { - val = mt76x2_eeprom_get(dev, MT_EE_RSSI_OFFSET_5G_0); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_RSSI_OFFSET_5G_0); mt76x2_set_rssi_offset(dev, 0, val); mt76x2_set_rssi_offset(dev, 1, val >> 8); } - val = mt76x2_eeprom_get(dev, MT_EE_LNA_GAIN); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_LNA_GAIN); lna_2g = val & 0xff; lna_5g[0] = val >> 8; - val = mt76x2_eeprom_get(dev, MT_EE_RSSI_OFFSET_2G_1); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_RSSI_OFFSET_2G_1); lna_5g[1] = val >> 8; - val = mt76x2_eeprom_get(dev, MT_EE_RSSI_OFFSET_5G_1); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_RSSI_OFFSET_5G_1); lna_5g[2] = val >> 8; if (!mt76x02_field_valid(lna_5g[1])) @@ -379,7 +386,7 @@ void mt76x2_read_rx_gain(struct mt76x2_dev *dev) dev->cal.rx.mcu_gain |= (lna_5g[1] & 0xff) << 16; dev->cal.rx.mcu_gain |= (lna_5g[2] & 0xff) << 24; - val = mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_1); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_1); if (val & MT_EE_NIC_CONF_1_LNA_EXT_2G) lna_2g = 0; if (val & MT_EE_NIC_CONF_1_LNA_EXT_5G) @@ -420,50 +427,54 @@ void mt76x2_get_rate_power(struct mt76x2_dev *dev, struct mt76_rate_power *t, memset(t, 0, sizeof(*t)); - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_CCK); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_CCK); t->cck[0] = t->cck[1] = mt76x2_rate_power_val(val); t->cck[2] = t->cck[3] = mt76x2_rate_power_val(val >> 8); if (is_5ghz) - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_OFDM_5G_6M); + val = mt76x02_eeprom_get(&dev->mt76, + MT_EE_TX_POWER_OFDM_5G_6M); else - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_OFDM_2G_6M); + val = mt76x02_eeprom_get(&dev->mt76, + MT_EE_TX_POWER_OFDM_2G_6M); t->ofdm[0] = t->ofdm[1] = mt76x2_rate_power_val(val); t->ofdm[2] = t->ofdm[3] = mt76x2_rate_power_val(val >> 8); if (is_5ghz) - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_OFDM_5G_24M); + val = mt76x02_eeprom_get(&dev->mt76, + MT_EE_TX_POWER_OFDM_5G_24M); else - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_OFDM_2G_24M); + val = mt76x02_eeprom_get(&dev->mt76, + MT_EE_TX_POWER_OFDM_2G_24M); t->ofdm[4] = t->ofdm[5] = mt76x2_rate_power_val(val); t->ofdm[6] = t->ofdm[7] = mt76x2_rate_power_val(val >> 8); - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_HT_MCS0); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_HT_MCS0); t->ht[0] = t->ht[1] = mt76x2_rate_power_val(val); t->ht[2] = t->ht[3] = mt76x2_rate_power_val(val >> 8); - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_HT_MCS4); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_HT_MCS4); t->ht[4] = t->ht[5] = mt76x2_rate_power_val(val); t->ht[6] = t->ht[7] = mt76x2_rate_power_val(val >> 8); memcpy(t->stbc, t->ht, sizeof(t->stbc)); - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_HT_MCS8); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_HT_MCS8); t->ht[8] = t->ht[9] = mt76x2_rate_power_val(val); t->ht[10] = t->ht[11] = mt76x2_rate_power_val(val >> 8); - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_HT_MCS12); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_HT_MCS12); t->ht[12] = t->ht[13] = mt76x2_rate_power_val(val); t->ht[14] = t->ht[15] = mt76x2_rate_power_val(val >> 8); - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_VHT_MCS0); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_VHT_MCS0); t->vht[0] = t->vht[1] = mt76x2_rate_power_val(val); t->vht[2] = t->vht[3] = mt76x2_rate_power_val(val >> 8); - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_VHT_MCS4); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_VHT_MCS4); t->vht[4] = t->vht[5] = mt76x2_rate_power_val(val); t->vht[6] = t->vht[7] = mt76x2_rate_power_val(val >> 8); - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_VHT_MCS8); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_VHT_MCS8); if (!is_5ghz) val >>= 8; t->vht[8] = t->vht[9] = mt76x2_rate_power_val(val >> 8); @@ -505,7 +516,7 @@ mt76x2_get_power_info_2g(struct mt76x2_dev *dev, struct mt76x2_tx_power_info *t, t->chain[chain].target_power = data[2]; t->chain[chain].delta = mt76x2_sign_extend_optional(data[delta_idx], 7); - val = mt76x2_eeprom_get(dev, MT_EE_RF_2G_TSSI_OFF_TXPOWER); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_RF_2G_TSSI_OFF_TXPOWER); t->target_power = val >> 8; } @@ -554,7 +565,7 @@ mt76x2_get_power_info_5g(struct mt76x2_dev *dev, struct mt76x2_tx_power_info *t, t->chain[chain].target_power = data[2]; t->chain[chain].delta = mt76x2_sign_extend_optional(data[delta_idx], 7); - val = mt76x2_eeprom_get(dev, MT_EE_RF_2G_RX_HIGH_GAIN); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_RF_2G_RX_HIGH_GAIN); t->target_power = val & 0xff; } @@ -566,8 +577,8 @@ void mt76x2_get_power_info(struct mt76x2_dev *dev, memset(t, 0, sizeof(*t)); - bw40 = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_DELTA_BW40); - bw80 = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_DELTA_BW80); + bw40 = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_DELTA_BW40); + bw80 = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_DELTA_BW80); if (chan->band == NL80211_BAND_5GHZ) { bw40 >>= 8; @@ -605,14 +616,18 @@ int mt76x2_get_temp_comp(struct mt76x2_dev *dev, struct mt76x2_temp_comp *t) if (!mt76x2_ext_pa_enabled(dev, band)) return -EINVAL; - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_EXT_PA_5G) >> 8; + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_EXT_PA_5G) >> 8; t->temp_25_ref = val & 0x7f; if (band == NL80211_BAND_5GHZ) { - slope = mt76x2_eeprom_get(dev, MT_EE_RF_TEMP_COMP_SLOPE_5G); - bounds = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_EXT_PA_5G); + slope = mt76x02_eeprom_get(&dev->mt76, + MT_EE_RF_TEMP_COMP_SLOPE_5G); + bounds = mt76x02_eeprom_get(&dev->mt76, + MT_EE_TX_POWER_EXT_PA_5G); } else { - slope = mt76x2_eeprom_get(dev, MT_EE_RF_TEMP_COMP_SLOPE_2G); - bounds = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_DELTA_BW80) >> 8; + slope = mt76x02_eeprom_get(&dev->mt76, + MT_EE_RF_TEMP_COMP_SLOPE_2G); + bounds = mt76x02_eeprom_get(&dev->mt76, + MT_EE_TX_POWER_DELTA_BW80) >> 8; } t->high_slope = slope & 0xff; @@ -626,7 +641,7 @@ EXPORT_SYMBOL_GPL(mt76x2_get_temp_comp); bool mt76x2_ext_pa_enabled(struct mt76x2_dev *dev, enum nl80211_band band) { - u16 conf0 = mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_0); + u16 conf0 = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_0); if (band == NL80211_BAND_5GHZ) return !(conf0 & MT_EE_NIC_CONF_0_PA_INT_5G); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h index 64b91fb57e3b..6064ef103d2c 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_eeprom.h @@ -56,15 +56,6 @@ struct mt76x2_temp_comp { unsigned int low_slope; /* J / dB */ }; -static inline int -mt76x2_eeprom_get(struct mt76x2_dev *dev, enum mt76x02_eeprom_field field) -{ - if ((field & 1) || field >= __MT_EE_MAX) - return -1; - - return get_unaligned_le16(dev->mt76.eeprom.data + field); -} - void mt76x2_get_rate_power(struct mt76x2_dev *dev, struct mt76_rate_power *t, struct ieee80211_channel *chan); int mt76x2_get_max_rate_power(struct mt76_rate_power *r); @@ -81,11 +72,11 @@ mt76x2_temp_tx_alc_enabled(struct mt76x2_dev *dev) { u16 val; - val = mt76x2_eeprom_get(dev, MT_EE_TX_POWER_EXT_PA_5G); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_TX_POWER_EXT_PA_5G); if (!(val & BIT(15))) return false; - return mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_1) & + return mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_1) & MT_EE_NIC_CONF_1_TEMP_TX_ALC; } @@ -93,14 +84,14 @@ static inline bool mt76x2_tssi_enabled(struct mt76x2_dev *dev) { return !mt76x2_temp_tx_alc_enabled(dev) && - (mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_1) & + (mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_1) & MT_EE_NIC_CONF_1_TX_ALC_EN); } static inline bool mt76x2_has_ext_lna(struct mt76x2_dev *dev) { - u32 val = mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_1); + u32 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_1); if (dev->mt76.chandef.chan->band == NL80211_BAND_2GHZ) return val & MT_EE_NIC_CONF_1_LNA_EXT_2G; diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_init.c b/drivers/net/wireless/mediatek/mt76/mt76x2_init.c index 33f7fabf45c0..72005faee00e 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_init.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_init.c @@ -44,7 +44,7 @@ mt76x2_fixup_xtal(struct mt76x2_dev *dev) u16 eep_val; s8 offset = 0; - eep_val = mt76x2_eeprom_get(dev, MT_EE_XTAL_TRIM_2); + eep_val = mt76x02_eeprom_get(&dev->mt76, MT_EE_XTAL_TRIM_2); offset = eep_val & 0x7f; if ((eep_val & 0xff) == 0xff) @@ -54,7 +54,7 @@ mt76x2_fixup_xtal(struct mt76x2_dev *dev) eep_val >>= 8; if (eep_val == 0x00 || eep_val == 0xff) { - eep_val = mt76x2_eeprom_get(dev, MT_EE_XTAL_TRIM_1); + eep_val = mt76x02_eeprom_get(&dev->mt76, MT_EE_XTAL_TRIM_1); eep_val &= 0xff; if (eep_val == 0x00 || eep_val == 0xff) @@ -65,7 +65,7 @@ mt76x2_fixup_xtal(struct mt76x2_dev *dev) mt76_rmw_field(dev, MT_XO_CTRL5, MT_XO_CTRL5_C2_VAL, eep_val + offset); mt76_set(dev, MT_XO_CTRL6, MT_XO_CTRL6_C2_CTRL); - eep_val = mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_2); + eep_val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_2); switch (FIELD_GET(MT_EE_NIC_CONF_2_XTAL_OPTION, eep_val)) { case 0: mt76_wr(dev, MT_XO_CTRL7, 0x5c1fee80); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c index f92bebfa21fd..2b25414ed16b 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_mcu.c @@ -141,7 +141,7 @@ mt76pci_load_firmware(struct mt76x2_dev *dev) mt76_wr(dev, MT_MCU_PCIE_REMAP_BASE4, 0); - val = mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_2); + val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_2); if (FIELD_GET(MT_EE_NIC_CONF_2_XTAL_OPTION, val) == 1) mt76_set(dev, MT_MCU_COM_REG0, BIT(30)); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_mcu_common.c b/drivers/net/wireless/mediatek/mt76/mt76x2_mcu_common.c index 72f6bfb7a258..a3669c00ddd5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_mcu_common.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_mcu_common.c @@ -60,6 +60,7 @@ EXPORT_SYMBOL_GPL(mt76x2_mcu_set_channel); int mt76x2_mcu_load_cr(struct mt76x2_dev *dev, u8 type, u8 temp_level, u8 channel) { + struct mt76_dev *mdev = &dev->mt76; struct sk_buff *skb; struct { u8 cr_mode; @@ -76,8 +77,8 @@ int mt76x2_mcu_load_cr(struct mt76x2_dev *dev, u8 type, u8 temp_level, u32 val; val = BIT(31); - val |= (mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_0) >> 8) & 0x00ff; - val |= (mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_1) << 8) & 0xff00; + val |= (mt76x02_eeprom_get(mdev, MT_EE_NIC_CONF_0) >> 8) & 0x00ff; + val |= (mt76x02_eeprom_get(mdev, MT_EE_NIC_CONF_1) << 8) & 0xff00; msg.cfg = cpu_to_le32(val); /* first set the channel without the extension channel info */ diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c index 920bb7c89af9..4477a4e184e9 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c @@ -360,7 +360,7 @@ int mt76x2_phy_set_channel(struct mt76x2_dev *dev, mt76_set(dev, MT_BBP(RXO, 13), BIT(10)); if (!dev->cal.init_cal_done) { - u8 val = mt76x2_eeprom_get(dev, MT_EE_BT_RCAL_RESULT); + u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT); if (val != 0xff) mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_R, 0, true); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c b/drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c index 9604c6a809be..b59336110746 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2u_mac.c @@ -32,7 +32,7 @@ static void mt76x2u_mac_fixup_xtal(struct mt76x2_dev *dev) s8 offset = 0; u16 eep_val; - eep_val = mt76x2_eeprom_get(dev, MT_EE_XTAL_TRIM_2); + eep_val = mt76x02_eeprom_get(&dev->mt76, MT_EE_XTAL_TRIM_2); offset = eep_val & 0x7f; if ((eep_val & 0xff) == 0xff) @@ -42,7 +42,7 @@ static void mt76x2u_mac_fixup_xtal(struct mt76x2_dev *dev) eep_val >>= 8; if (eep_val == 0x00 || eep_val == 0xff) { - eep_val = mt76x2_eeprom_get(dev, MT_EE_XTAL_TRIM_1); + eep_val = mt76x02_eeprom_get(&dev->mt76, MT_EE_XTAL_TRIM_1); eep_val &= 0xff; if (eep_val == 0x00 || eep_val == 0xff) @@ -67,7 +67,7 @@ static void mt76x2u_mac_fixup_xtal(struct mt76x2_dev *dev) /* init fce */ mt76_clear(dev, MT_FCE_L2_STUFF, MT_FCE_L2_STUFF_WR_MPDU_LEN_EN); - eep_val = mt76x2_eeprom_get(dev, MT_EE_NIC_CONF_2); + eep_val = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_2); switch (FIELD_GET(MT_EE_NIC_CONF_2_XTAL_OPTION, eep_val)) { case 0: mt76_wr(dev, MT_XO_CTRL7, 0x5c1fee80); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c index 97f40fef5559..9842ed04d764 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x2u_phy.c @@ -209,7 +209,7 @@ int mt76x2u_phy_set_channel(struct mt76x2_dev *dev, mt76_set(dev, MT_BBP(RXO, 13), BIT(10)); if (!dev->cal.init_cal_done) { - u8 val = mt76x2_eeprom_get(dev, MT_EE_BT_RCAL_RESULT); + u8 val = mt76x02_eeprom_get(&dev->mt76, MT_EE_BT_RCAL_RESULT); if (val != 0xff) mt76x02_mcu_calibrate(&dev->mt76, MCU_CAL_R,