Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2311931yba; Fri, 17 May 2019 14:41:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqzS+nufg2nRcREhM7Qt5sluSeFUOUDYcf+4S0qlq02WMnIUalRtmHOOpiZDI0u2A5oq+5KB X-Received: by 2002:a62:575b:: with SMTP id l88mr62710491pfb.143.1558129273696; Fri, 17 May 2019 14:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558129273; cv=none; d=google.com; s=arc-20160816; b=dcSulYBfTGTu+/BV03X4t6pFNyxXWoBgtIywny+UujaRang1ggj7VDE5+iZU3Sbnbz 9lG2+uQB//8ZClVD83o7hQazC1iGe1CH2qjth2S4Dhl+uNcQ3ppJEhgMYSNRxMgyLM7k aKduqznmGPAnguZpVAdJNVYeK97ehgNhM8UCjabfY4riHQ4I/jHefIwEDUolNH6otJb3 krpDx6DRS9lLr9kv7qh5Xje+qlPpKh8WufMyqLMQbgk0yuh1u9QukrpvdVaS81KJoUV4 1v02sFQUKjetjr26Hjrib3U31LSSa4Hjo+HCJszARlkd8YYlOpZNgq76qVLaTkPB57u/ cXRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Ai06EX2P2rLu1K8Dt8qW2coPIZy5r53DNJLjSyTUKzI=; b=ge7aUDvMeAi3fhjG2qygVMuBaAkw2G6LFNwFDYHTn8cTNfPhXovhqJ3lbWrFsiEkM4 sz6TgjCvzOp5r5G1IxlTymJavblztfu1Cn3JpdDC9J4JFm+UoyNoe8J4p8mn6kgm9opK Q1tewJtoskFxwMOGdEa+4h3Mf89Hklnoa0zKMeUqouxe+6pUHxnrh5pqWJ4RwZ2iGVfY NVZZ24Bnjts7n/oPMhs6BiC9QNT6HPvHcVAJef9E2bfQzbyFAE8tA884X4xV9YPvZnjG jbITFF1HvZSIu6gjXU+JaCFc6gv05NuLKZ0MG14lnpi+g2sXGdlB/FTV5zdbQElFJTEt LrMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jP1aVt0x; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b1si8888445pgg.392.2019.05.17.14.40.44; Fri, 17 May 2019 14:41:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jP1aVt0x; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727380AbfEQVdL (ORCPT + 99 others); Fri, 17 May 2019 17:33:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:42292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726960AbfEQVdL (ORCPT ); Fri, 17 May 2019 17:33:11 -0400 Received: from lore-desk-wlan.lan (unknown [151.66.17.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 67D162087E; Fri, 17 May 2019 21:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558128790; bh=HIgHkD6Qu/m6kAvuo9TQMy15ncawMvGhNHmWpuSUjGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jP1aVt0xqm/BzPa8xp912bJl7q7ylYAVzVis7alAdZyAg+WZX238jASn/G26btt/M yxzFBbkKDAwFP7krzamrEuyaVUfHYKnPHKE6Z2X35L3V15DPRo8b5CJglMaZRnRHfQ NT8uSU0FAfIm5dLEq+rqQ5DJgWmnbjjYRLG97voo= From: Lorenzo Bianconi To: nbd@nbd.name Cc: lorenzo.bianconi@redhat.com, linux-wireless@vger.kernel.org, ryder.lee@mediatek.com, royluo@google.com Subject: [PATCH] mt76: mt7615: select wifi band according to eeprom Date: Fri, 17 May 2019 23:32:56 +0200 Message-Id: <38aa977df45a92f60d78d9cb7e575289ccbaeef6.1558127930.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Select supported band according to the value read from eeprom mtd/otp partition Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt7615/eeprom.c | 24 ++++++++++++++++--- .../wireless/mediatek/mt76/mt7615/eeprom.h | 9 +++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c index 1712f66520a8..714590878d65 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.c @@ -90,6 +90,26 @@ static int mt7615_check_eeprom(struct mt76_dev *dev) } } +static void mt7615_eeprom_parse_hw_cap(struct mt7615_dev *dev) +{ + u8 val, *eeprom = dev->mt76.eeprom.data; + + val = FIELD_GET(MT_EE_NIC_WIFI_CONF_BAND_SEL, + eeprom[MT_EE_WIFI_CONF]); + switch (val) { + case MT_EE_5GHZ: + dev->mt76.cap.has_5ghz = true; + break; + case MT_EE_2GHZ: + dev->mt76.cap.has_2ghz = true; + break; + default: + dev->mt76.cap.has_2ghz = true; + dev->mt76.cap.has_5ghz = true; + break; + } +} + int mt7615_eeprom_init(struct mt7615_dev *dev) { int ret; @@ -103,9 +123,7 @@ int mt7615_eeprom_init(struct mt7615_dev *dev) memcpy(dev->mt76.eeprom.data, dev->mt76.otp.data, MT7615_EEPROM_SIZE); - dev->mt76.cap.has_2ghz = true; - dev->mt76.cap.has_5ghz = true; - + mt7615_eeprom_parse_hw_cap(dev); memcpy(dev->mt76.macaddr, dev->mt76.eeprom.data + MT_EE_MAC_ADDR, ETH_ALEN); diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h index a4cf16688171..b422e395d6ee 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h +++ b/drivers/net/wireless/mediatek/mt76/mt7615/eeprom.h @@ -11,8 +11,17 @@ enum mt7615_eeprom_field { MT_EE_VERSION = 0x002, MT_EE_MAC_ADDR = 0x004, MT_EE_NIC_CONF_0 = 0x034, + MT_EE_WIFI_CONF = 0x03e, __MT_EE_MAX = 0x3bf }; +#define MT_EE_NIC_WIFI_CONF_BAND_SEL GENMASK(5, 4) +enum mt7615_eeprom_band { + MT_EE_DUAL_BAND, + MT_EE_5GHZ, + MT_EE_2GHZ, + MT_EE_DBDC, +}; + #endif -- 2.20.1