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: 10607259 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 33BE26CB for ; Thu, 20 Sep 2018 09:34:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F372CDCB for ; Thu, 20 Sep 2018 09:34:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15F592CECD; Thu, 20 Sep 2018 09:34: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=-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 9B3D82CDCB for ; Thu, 20 Sep 2018 09:34:42 +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=itA2zT8dXE4oeLLrnYG/zM5MKz6a/idWu4y2Zso3u3o=; b=RsjaYbMitNu/XetumYZVvbZvHs 3iZ6iIPe4ix+5RYjh/QCM9tJ5WnRG9dS+pFyBTtSx7h0+92aLoYiUwPl/syuuO4zLZEIvsue3cY4u 6uiBlulUc5sTI3MgDi00jdAc/bNAybF+ljQ1j+kCpV6xPQ8lYqnp8W4ifkEQsvEUZvYMHPcshPhQd bI/qOl9VpEmalzI5eKv1IxtkEzWoG7WltRSHnyGzIYmUCigNxwtygnhW3NvL+m4Ru9hToeQ1Cu9w/ UtXuBvGZFAuwJCoePxnklrBcRk6/r79ybF2ug+wE5sbtmesBvNJP67prd+v7tSAxlnGARRcMb46/X I+DM7Bzg==; 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 1g2vM4-0004CK-14; Thu, 20 Sep 2018 09:34:36 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2vE5-0007yC-Cp for linux-mediatek@bombadil.infradead.org; Thu, 20 Sep 2018 09:26:21 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.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=0kU0C8Nhicf7sIvQrWYxoE3jPGvMrT4w6oq8fTSSyIM=; b=sZQWbiR1Y1jZtYymtWRDS3aLi S0NgoYK+nIItaOuIX6HQhbKhXNs6BdalhYMinRVbngmX/FSEI2qna1eDBRLJtViN7T2bk77YmmTxd 5RFaJRAJp2wntPUXJLv1ySeISo5O602wYNz31RfdV8gc21Xxjhh/fZLU0rz8aLr09RWd1KdVeRxeU +bpdMBU9bDMlSEZyybYfKYENJ1fi5SQygV/6OF2R035gGl10wa/OFDoTSrtuKdpanz7TzYNjHER4H GgLiZKZAjVa7Z0AyjmL8DeyvzBce0VY/JIkdvsXqmUtW6sNuN38H1pAuippW3HGBEEkFKPhePkKmY 41smNVJdg==; Received: from mail-wr1-f67.google.com ([209.85.221.67]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1g2v12-0000Xb-F4 for linux-mediatek@lists.infradead.org; Thu, 20 Sep 2018 09:12:52 +0000 Received: by mail-wr1-f67.google.com with SMTP id v17-v6so8579545wrr.9 for ; Thu, 20 Sep 2018 02:12:42 -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=tGpXG8sUku+Pf76hqVWgUPwmVYNxsP4iigmNZjxC/TV9/Tj8N2LZmGQYysPgz54elZ Nom1apWop+mxCzlppEoNxARKvXxSpCPRSWrRIV/EoG6vxhT9Cp67UMvSZkf9JqjLJ6db v1VAHRNebG3cEF+ijuc1M2woJAsio5RVyYWheIMYrTrTY0J03v4AQdDZ1Z06UUv2t1WN DbJoJ1rv72g33mOUDqLqjBozk1UsMInVLzEgaYpmTcpgbTYVRZKVEKtGmFt4IpxzNmRR ZCk3+b2oBUXL9+fSOxE7vQiD6RDEOqRCQJvyoofDqksg7r1nR5uEsgrLIZ5W91RlWxh7 wAZQ== X-Gm-Message-State: APzg51A0TVxEY7qb0QF6fI6eZ+QHnasK/4fTGZaWa/b0yb9E6SwaeXiM TE41tOngCRzDpcB6YUFjMwaRGQ== 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 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180920_051252_539041_6DFC02C4 X-CRM114-Status: GOOD ( 10.76 ) 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 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;