From patchwork Sat Jun 25 19:53:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Larry Finger X-Patchwork-Id: 9198699 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.web.codeaurora.org (Postfix) with ESMTP id 5638F608A7 for ; Sat, 25 Jun 2016 19:54:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48A2428511 for ; Sat, 25 Jun 2016 19:54:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3DAF228525; Sat, 25 Jun 2016 19:54:08 +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=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, URIBL_BLACK 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 C092D28523 for ; Sat, 25 Jun 2016 19:54:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751759AbcFYTxv (ORCPT ); Sat, 25 Jun 2016 15:53:51 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:33339 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751700AbcFYTxt (ORCPT ); Sat, 25 Jun 2016 15:53:49 -0400 Received: by mail-oi0-f67.google.com with SMTP id w141so24214176oia.0 for ; Sat, 25 Jun 2016 12:53:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=6xOGRFTnYhDu9eqCpvm3qe52VpkwNvT6nhaqXJFbe0c=; b=oS6jXpWfFhGZc4Gz0lNN9IHOAhgcnM18ntLYlXk/6rsweKkbN+t0CmziKK+64+v0/O sdRnAQ4FQ4Mm+43YT+h8tLLdevogSHfYDuH8QORFazXC4P1+sdNjAGrDG/4BacEtVx3V U8eK0WKHvs/DfkrdXrqsJNMtZzapSBojUqw9YonjX7b+dSGkqFseuf8c1cHJgGofHte0 7SN7u3OJCguGcCkDsUekIsT+rrLTI+s6L4a/8DT+cz8oioreSoEOsHR3JeXy+z4BdUqZ TFjKEJVozmFHWg7RTrxqRHXeIE9wBGt9jMSZC8hHOr/eDBWcWzkcuUTuZy8l/XLyCDii JAUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=6xOGRFTnYhDu9eqCpvm3qe52VpkwNvT6nhaqXJFbe0c=; b=DmXNSfXysQB3Bd+bBVZ8TWvU17crrLRwyDKP2sXY7Y86dK2YGjAspE5hxyzK5wDvKX JB0KnvdbHY4lmG0X+BHdQULzyZhG529g5L1tOP1izKRpSOc/mWzrv4z9oJUPtsH7sPlp EBjecpCyB54tMpqx//c8vFvcWFQmIk6nGXatZ6xct8pwHfS6mIq46KcNSA+3CwfUhYp1 pOxjS685Rqw9u1HKaLMzi6OhhsUJoiD4PsGvOQCENh35D0uuyn3bfXDxD2HX6mxiZi9E 9isHYI0hdrXH2YgMB9v9+xNP1oP2tTgnlaShuFTGyjeI0RDwn+o9H+mUffXqs6FXVn6p 555w== X-Gm-Message-State: ALyK8tIBYDb3Qg7+EUXiyfGvPqBS4sJ2+gVPJxXhKopL4xPzAjHBmR/Mu01xXO87Byy/tw== X-Received: by 10.157.9.226 with SMTP id 31mr7061930otz.165.1466884428127; Sat, 25 Jun 2016 12:53:48 -0700 (PDT) Received: from linux.site (cpe-24-31-249-175.kc.res.rr.com. [24.31.249.175]) by smtp.gmail.com with ESMTPSA id j13sm5920465oib.1.2016.06.25.12.53.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 25 Jun 2016 12:53:47 -0700 (PDT) From: Larry Finger To: kvalo@codeaurora.org Cc: devel@driverdev.osuosl.org, linux-wireless@vger.kernel.org, Larry Finger , Arnd Bergmann Subject: [PATCH 01/10] rtlwifi: Create common routine to get hardware info Date: Sat, 25 Jun 2016 14:53:32 -0500 Message-Id: <1466884421-722-2-git-send-email-Larry.Finger@lwfinger.net> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1466884421-722-1-git-send-email-Larry.Finger@lwfinger.net> References: <1466884421-722-1-git-send-email-Larry.Finger@lwfinger.net> 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 All of the rtlwifi family of drivers have a similar routine that acquires the hardware info from efuse and initializes a number of variables in the driver's private area. A common routine is created for all drivers to use. Reported-by: Arnd Bergmann Signed-off-by: Larry Finger Cc: Arnd Bergmann --- drivers/net/wireless/realtek/rtlwifi/efuse.c | 78 ++++++++++++++++++++++++++++ drivers/net/wireless/realtek/rtlwifi/efuse.h | 2 + 2 files changed, 80 insertions(+) diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.c b/drivers/net/wireless/realtek/rtlwifi/efuse.c index 0b4082c..b8ad00e 100644 --- a/drivers/net/wireless/realtek/rtlwifi/efuse.c +++ b/drivers/net/wireless/realtek/rtlwifi/efuse.c @@ -24,6 +24,7 @@ *****************************************************************************/ #include "wifi.h" #include "efuse.h" +#include "pci.h" #include static const u8 MAX_PGPKT_SIZE = 9; @@ -1243,3 +1244,80 @@ static u8 efuse_calculate_word_cnts(u8 word_en) return word_cnts; } +int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv, + int max_size, u8 *hwinfo, int *params) +{ + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); + struct rtl_pci_priv *rtlpcipriv = rtl_pcipriv(hw); + struct device *dev = &rtlpcipriv->dev.pdev->dev; + u16 eeprom_id; + u16 i, usvalue; + + switch (rtlefuse->epromtype) { + case EEPROM_BOOT_EFUSE: + rtl_efuse_shadow_map_update(hw); + break; + + case EEPROM_93C46: + RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, + "RTL819X Not boot from eeprom, check it !!"); + return 1; + + default: + dev_warn(dev, "no efuse data\n"); + return 1; + } + + memcpy(hwinfo, &rtlefuse->efuse_map[EFUSE_INIT_MAP][0], max_size); + + RT_PRINT_DATA(rtlpriv, COMP_INIT, DBG_DMESG, "MAP", + hwinfo, max_size); + + eeprom_id = *((u16 *)&hwinfo[0]); + if (eeprom_id != params[0]) { + RT_TRACE(rtlpriv, COMP_ERR, DBG_WARNING, + "EEPROM ID(%#x) is invalid!!\n", eeprom_id); + rtlefuse->autoload_failflag = true; + } else { + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, "Autoload OK\n"); + rtlefuse->autoload_failflag = false; + } + + if (rtlefuse->autoload_failflag) + return 1; + + rtlefuse->eeprom_vid = *(u16 *)&hwinfo[params[1]]; + rtlefuse->eeprom_did = *(u16 *)&hwinfo[params[2]]; + rtlefuse->eeprom_svid = *(u16 *)&hwinfo[params[3]]; + rtlefuse->eeprom_smid = *(u16 *)&hwinfo[params[4]]; + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "EEPROMId = 0x%4x\n", eeprom_id); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "EEPROM VID = 0x%4x\n", rtlefuse->eeprom_vid); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "EEPROM DID = 0x%4x\n", rtlefuse->eeprom_did); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "EEPROM SVID = 0x%4x\n", rtlefuse->eeprom_svid); + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "EEPROM SMID = 0x%4x\n", rtlefuse->eeprom_smid); + + for (i = 0; i < 6; i += 2) { + usvalue = *(u16 *)&hwinfo[params[5] + i]; + *((u16 *)(&rtlefuse->dev_addr[i])) = usvalue; + } + RT_TRACE(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr); + + rtlefuse->eeprom_channelplan = *&hwinfo[params[6]]; + rtlefuse->eeprom_version = *(u16 *)&hwinfo[params[7]]; + rtlefuse->txpwr_fromeprom = true; + rtlefuse->eeprom_oemid = *&hwinfo[params[8]]; + + RT_TRACE(rtlpriv, COMP_INIT, DBG_LOUD, + "EEPROM Customer ID: 0x%2x\n", rtlefuse->eeprom_oemid); + + /* set channel plan to world wide 13 */ + rtlefuse->channel_plan = params[9]; + + return 0; +} +EXPORT_SYMBOL_GPL(rtl_get_hwinfo); diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.h b/drivers/net/wireless/realtek/rtlwifi/efuse.h index be02e78..51aa121 100644 --- a/drivers/net/wireless/realtek/rtlwifi/efuse.h +++ b/drivers/net/wireless/realtek/rtlwifi/efuse.h @@ -109,5 +109,7 @@ bool efuse_shadow_update_chk(struct ieee80211_hw *hw); void rtl_efuse_shadow_map_update(struct ieee80211_hw *hw); void efuse_force_write_vendor_Id(struct ieee80211_hw *hw); void efuse_re_pg_section(struct ieee80211_hw *hw, u8 section_idx); +int rtl_get_hwinfo(struct ieee80211_hw *hw, struct rtl_priv *rtlpriv, + int max_size, u8 *hwinfo, int *params); #endif