From patchwork Thu Sep 20 09:12:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Bianconi X-Patchwork-Id: 10607191 X-Patchwork-Delegate: kvalo@adurom.com 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 C51A86CB for ; Thu, 20 Sep 2018 09:12:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B37BF2CC13 for ; Thu, 20 Sep 2018 09:12:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A798D2CC70; Thu, 20 Sep 2018 09:12:43 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CB792CC13 for ; Thu, 20 Sep 2018 09:12:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387507AbeITOzL (ORCPT ); Thu, 20 Sep 2018 10:55:11 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36438 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387496AbeITOzK (ORCPT ); Thu, 20 Sep 2018 10:55:10 -0400 Received: by mail-wr1-f68.google.com with SMTP id e1-v6so8601585wrt.3 for ; Thu, 20 Sep 2018 02:12:41 -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=0kU0C8Nhicf7sIvQrWYxoE3jPGvMrT4w6oq8fTSSyIM=; b=MqPCHV9+wWiUgv3UqQV2xFxrFD0/7tPID/ZnvmTts2sJq8WEN/0srTbRKfmBbmYBnH 4fjw9wYypdg2acd/FinfyKYUWC9OJDyHb/4n+VClb12F+YLTkhgu70C10J2qVmmfvoec mYuH58q76+bo+ytEQJrZNHTNNnXA8wAPTtlyXisOFUUJA4TiiyqYMEQYi59+JD1CkEFh MpRl6Wy7y5uhqEVG+smt9GIqK2wvlSPb90iJaFc5/btm1vOD2mvKsj+FO7I9m9rP3+QW rd2FT3RuIkeORuSE4gtJWChmhbJhRXcNEtYojheZ+ElATQE80t1TYjEepZDqN3421e8K MJBw== X-Gm-Message-State: APzg51Cb5ugCY8lFIgdr03c8EVDboJjt8Vu5JPMQKmc77GRAaiFHwvLZ XKXN5GrwYKD/a82rjb1oXX8hgA== X-Google-Smtp-Source: ANB0VdacWWHyevzcubtSte2ozcPHgQUDdys5/xNTxwHdazDQF1N03HKfe+AogcqAi1USyzS3d1wsjw== X-Received: by 2002:a5d:528f:: with SMTP id c15-v6mr32913915wrv.102.1537434761014; Thu, 20 Sep 2018 02:12:41 -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.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 20 Sep 2018 02:12:40 -0700 (PDT) From: Lorenzo Bianconi To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, sgruszka@redhat.com, linux-mediatek@lists.infradead.org Subject: [PATCH 16/20] mt76x0: unify parse hw capabilities Date: Thu, 20 Sep 2018 11:12:03 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Unify parse hw capabilities with mt76x2 driver using mt76x02_eeprom_parse_hw_cap utility routine available in mt76x02-lib module Signed-off-by: Lorenzo Bianconi --- .../wireless/mediatek/mt76/mt76x0/eeprom.c | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c index 70dd96051e77..f9d917a7f3f5 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x0/eeprom.c @@ -51,29 +51,13 @@ mt76x0_efuse_physical_size_check(struct mt76x0_dev *dev) return 0; } -static void -mt76x0_set_chip_cap(struct mt76x0_dev *dev, u8 *eeprom) +static void mt76x0_set_chip_cap(struct mt76x0_dev *dev) { - enum mt76x2_board_type { BOARD_TYPE_2GHZ = 1, BOARD_TYPE_5GHZ = 2 }; - u16 nic_conf0 = get_unaligned_le16(eeprom + MT_EE_NIC_CONF_0); - u16 nic_conf1 = get_unaligned_le16(eeprom + MT_EE_NIC_CONF_1); - - dev_dbg(dev->mt76.dev, "NIC_CONF0: %04x NIC_CONF1: %04x\n", nic_conf0, nic_conf1); - - switch (FIELD_GET(MT_EE_NIC_CONF_0_BOARD_TYPE, nic_conf0)) { - case BOARD_TYPE_5GHZ: - dev->mt76.cap.has_5ghz = true; - break; - case BOARD_TYPE_2GHZ: - dev->mt76.cap.has_2ghz = true; - break; - default: - dev->mt76.cap.has_2ghz = true; - dev->mt76.cap.has_5ghz = true; - break; - } + u16 nic_conf0 = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_0); + u16 nic_conf1 = mt76x02_eeprom_get(&dev->mt76, MT_EE_NIC_CONF_1); - dev_dbg(dev->mt76.dev, "Has 2GHZ %d 5GHZ %d\n", + mt76x02_eeprom_parse_hw_cap(&dev->mt76); + dev_dbg(dev->mt76.dev, "2GHz %d 5GHz %d\n", dev->mt76.cap.has_2ghz, dev->mt76.cap.has_5ghz); if (!mt76x02_field_valid(nic_conf1 & 0xff)) @@ -81,15 +65,14 @@ mt76x0_set_chip_cap(struct mt76x0_dev *dev, u8 *eeprom) if (nic_conf1 & MT_EE_NIC_CONF_1_HW_RF_CTRL) dev_err(dev->mt76.dev, - "Error: this driver does not support HW RF ctrl\n"); + "driver does not support HW RF ctrl\n"); if (!mt76x02_field_valid(nic_conf0 >> 8)) return; if (FIELD_GET(MT_EE_NIC_CONF_0_RX_PATH, nic_conf0) > 1 || FIELD_GET(MT_EE_NIC_CONF_0_TX_PATH, nic_conf0) > 1) - dev_err(dev->mt76.dev, - "Error: device has more than 1 RX/TX stream!\n"); + dev_err(dev->mt76.dev, "invalid tx-rx stream\n"); } static void mt76x0_set_temp_offset(struct mt76x0_dev *dev) @@ -283,7 +266,7 @@ mt76x0_eeprom_init(struct mt76x0_dev *dev) eeprom[MT_EE_VERSION + 1], eeprom[MT_EE_VERSION]); mt76x02_mac_setaddr(&dev->mt76, eeprom + MT_EE_MAC_ADDR); - mt76x0_set_chip_cap(dev, eeprom); + mt76x0_set_chip_cap(dev); mt76x0_set_freq_offset(dev); mt76x0_set_temp_offset(dev); dev->chainmask = 0x0101;