From patchwork Fri Sep 18 16:29:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 11785387 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DEEDD6CA for ; Fri, 18 Sep 2020 16:29:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE703235FA for ; Fri, 18 Sep 2020 16:29:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fNH63PJd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726469AbgIRQ3j (ORCPT ); Fri, 18 Sep 2020 12:29:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726416AbgIRQ3h (ORCPT ); Fri, 18 Sep 2020 12:29:37 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCCE1C0613CE; Fri, 18 Sep 2020 09:29:35 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id j2so6252249wrx.7; Fri, 18 Sep 2020 09:29:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=S49aIuYLpT+2JYfKysryYvgN235gurfGFJHDPWL3QzE=; b=fNH63PJdbtii5p28SJargFVtP29JBMqu4VRxmdKvPFyOkSjLgc4EnArJAxzT7iRYRG 6Z6DqQADU16LveutJ0fL10Alcjr96VTtQwK/5vz6eJHBxPPV4w4Da8RX6d2u2WizDjf/ D6rn2lvsQS5KrnMTUmqEf8WzyZnN4YEugFrrJSISst5VrZ3ixIC9+pWWevaRoM9+lOKH 477U0HNJdiqVxsbEG2VhnAwlOvYfZpCCum3IvjAleQInirKCIwSs1Gh4/i1I2TLgO2qE 7dMIfXM+hCyB1ttA/11ZAyUTU9POcCLOFV8edA1GL4PxPcIoxX0zXUye314LTwKgy5A3 9ZFQ== 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:mime-version :content-transfer-encoding; bh=S49aIuYLpT+2JYfKysryYvgN235gurfGFJHDPWL3QzE=; b=lqwPepsc4mBIXVJSBZXixkpmdfYp8OsU49Dpjam6zDU2hafq0xzsWDZW5Tnuba5OjQ Qx6y0KW63tFSA9GfSq2VbuqHQ37f4OR+r7rULmOzk9CMwxxWTd4431vK2lJV09fa4+1l 4oPJdR2nZuhmdJnw/UHseOa1nc9m3lzcLaOdLiAqnysNqHqDZEk3pQjPDPpHBErMmtmh RdObs2SRjVB91air6vJzuo8Zs4XpWnpLsu83nDPFwTsWK9gSZ6YN6aqf5ujNk/WEKv4+ v8Nc8ftaqmx0l5yDKnrYLolkavKHvOZ13vbh6MgiEHdVR9Lre/480lzJUnYjUfgmAfEZ qvjg== X-Gm-Message-State: AOAM530e8Qjprj/QV/8PevaN0jSmUt5/nJQNA2zUYuyiXU2REG6xwLtZ rQLMOy9/ay9gEESpx33v5jr+f62I5ng= X-Google-Smtp-Source: ABdhPJw4wGg1+Wn7ryPfoWJp2mkPbx+vkCKrpZOZh7g3Lg8TmO6D2tc0OYSc0+e2jdBwIiC1DuF/XQ== X-Received: by 2002:adf:c3cc:: with SMTP id d12mr39463130wrg.399.1600446574306; Fri, 18 Sep 2020 09:29:34 -0700 (PDT) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id b11sm6028921wrt.38.2020.09.18.09.29.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 09:29:33 -0700 (PDT) From: Ansuel Smith To: Kalle Valo Cc: Ansuel Smith , "David S. Miller" , Jakub Kicinski , Rob Herring , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, ath10k@lists.infradead.org Subject: [PATCH] ath10k: Introduce download cal from mtd Date: Fri, 18 Sep 2020 18:29:27 +0200 Message-Id: <20200918162928.14335-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Most of routers that have the ath10k wifi chip integrated in the Soc have the pre-cal data stored in the art (or equivalent) mtd partition. Introduce a new function to directly extract and use it based on what is set in the dt if the system have mtd support. Pre-cal file have still priority to everything else. Tested-on: QCA9984 hw1.0 PCI 10.4 Signed-off-by: Ansuel Smith --- drivers/net/wireless/ath/ath10k/core.c | 74 ++++++++++++++++++++++++++ drivers/net/wireless/ath/ath10k/core.h | 3 ++ 2 files changed, 77 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 5f4e12196..eef00d657 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "core.h" #include "mac.h" @@ -1701,6 +1702,69 @@ static int ath10k_download_and_run_otp(struct ath10k *ar) return 0; } +static int ath10k_download_cal_mtd(struct ath10k *ar) +{ +#ifdef CONFIG_MTD + struct device_node *node, *mtd_node = NULL; + struct mtd_info *mtd; + const __be32 *list; + u32 offset, size; + const char *part; + phandle phandle; + size_t retlen; + char *file; + int ret; + + node = ar->dev->of_node; + if (!node) + return -ENOENT; + + list = of_get_property(node, "qcom,ath10k-pre-calibration-data-mtd", &size); + if (!list || (size != (3 * sizeof(*list)))) + return -EINVAL; + + phandle = be32_to_cpup(list++); + if (phandle) + mtd_node = of_find_node_by_phandle(phandle); + + if (!mtd_node) + return -ENODEV; + + part = of_get_property(mtd_node, "label", NULL); + if (!part) + part = mtd_node->name; + + mtd = get_mtd_device_nm(part); + if (IS_ERR(mtd)) + return -ENODEV; + + offset = be32_to_cpup(list++); + size = be32_to_cpup(list); + + file = kzalloc(size, GFP_KERNEL); + if (!file) + return -ENOMEM; + + ret = mtd_read(mtd, offset, size, &retlen, file); + put_mtd_device(mtd); + + ret = ath10k_download_board_data(ar, file, size); + if (ret) { + ath10k_err(ar, "failed to download cal_file data: %d\n", ret); + goto err; + } + + ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot cal file downloaded\n"); + + return 0; + +err: + kfree(file); + return ret; +#endif + return -EOPNOTSUPP; +} + static int ath10k_download_cal_file(struct ath10k *ar, const struct firmware *file) { @@ -2047,6 +2111,16 @@ static int ath10k_core_pre_cal_download(struct ath10k *ar) goto success; } + ath10k_dbg(ar, ATH10K_DBG_BOOT, + "boot did not find a pre calibration file, try MTD next: %d\n", + ret); + + ret = ath10k_download_cal_mtd(ar); + if (ret == 0) { + ar->cal_mode = ATH10K_PRE_CAL_MODE_MTD; + goto success; + } + ath10k_dbg(ar, ATH10K_DBG_BOOT, "boot did not find a pre calibration file, try DT next: %d\n", ret); diff --git a/drivers/net/wireless/ath/ath10k/core.h b/drivers/net/wireless/ath/ath10k/core.h index 4cf5bd489..3ca158605 100644 --- a/drivers/net/wireless/ath/ath10k/core.h +++ b/drivers/net/wireless/ath/ath10k/core.h @@ -864,6 +864,7 @@ enum ath10k_cal_mode { ATH10K_CAL_MODE_OTP, ATH10K_CAL_MODE_DT, ATH10K_PRE_CAL_MODE_FILE, + ATH10K_PRE_CAL_MODE_MTD, ATH10K_PRE_CAL_MODE_DT, ATH10K_CAL_MODE_EEPROM, }; @@ -886,6 +887,8 @@ static inline const char *ath10k_cal_mode_str(enum ath10k_cal_mode mode) return "dt"; case ATH10K_PRE_CAL_MODE_FILE: return "pre-cal-file"; + case ATH10K_PRE_CAL_MODE_MTD: + return "pre-cal-mtd"; case ATH10K_PRE_CAL_MODE_DT: return "pre-cal-dt"; case ATH10K_CAL_MODE_EEPROM: From patchwork Fri Sep 18 16:29:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 11785391 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D226F139A for ; Fri, 18 Sep 2020 16:30:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD622235FA for ; Fri, 18 Sep 2020 16:30:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Il95zl7d" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726537AbgIRQ3y (ORCPT ); Fri, 18 Sep 2020 12:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbgIRQ3j (ORCPT ); Fri, 18 Sep 2020 12:29:39 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD2B7C0613CE; Fri, 18 Sep 2020 09:29:38 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id x23so5889499wmi.3; Fri, 18 Sep 2020 09:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+ALrwdNETU2MxK86SGthSKgE8MUMcPyrI0lP0CVqjQI=; b=Il95zl7ds9a5Wa/+A3ecWvYzrSZ+BLTqfj6ec6fYPbvqhhdmJVYxEZzqRc9s9v/yP2 4m4R4HC+r9fa7HBll/1tev5GP4Bjq/AaAPYaGzfbpTCEF7ibb/gsMgFbIbQ/WBJcC5ee woI+46IAtNgGvB/Nj6BfLGomZmU5ngVz+pqPO02a1iVbRydvRydQqCj7Jby1G6R3yCb1 /WScm3GI19p5i0BhBzU7+4GN6PDp9B8Rm1iEcS6qckXfU6hf621shoGLV2zYv/gfIqS9 w3YMCAa/ZdDbPiPz957p3OFF83IzcNHRrAWKezqElxGFg5UDXiYgO3LlVaZ7iudwLXkO MfvQ== 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:mime-version:content-transfer-encoding; bh=+ALrwdNETU2MxK86SGthSKgE8MUMcPyrI0lP0CVqjQI=; b=XbxGB2ilTCyB3uYiEGJLXI4UoavwEA7TvQMlfWhdXqw4/HPJY6YVPHFkgufJJzGqWl 2RX8PcHLWVqz4sG+jDUnjO/MCkWIInCbVyt0jXDiu/Fe3EarHpp89QRECdjshpMcTyJ7 5UTdgdFZtAhTjFlewRVNKQyibarpa1OamiGXZpCMuSoTAOXFvr2JkUWCWSnIxQ5VK5zw dJcO82a8RIoAGEQHP56jldXyI7INXZ1y5Q7ESIZLOX1IH86b+pTKPRWLLeefz8Ec9nBK caFgMDwdCixiVGZMSPBH8uj+Qhax2D2RRkqe9beNFQjWjgiGDxLzfd6iZFTrum6j2s2l I0lA== X-Gm-Message-State: AOAM530AVTw5fcErBJ7pXzJHyFeUzr/3AZt8EGtCx4W+LkgTeKfW7oDW dRvXc/vhZl9qqdGnpHJ3fiY= X-Google-Smtp-Source: ABdhPJwhMLFx/NFsWruwmp6xyVAv5jlnAK8e/0Ui5smBeskjIRpqc6rufsaW1nM9w8xzSUglIbmcnQ== X-Received: by 2002:a7b:cc8f:: with SMTP id p15mr16559476wma.18.1600446577309; Fri, 18 Sep 2020 09:29:37 -0700 (PDT) Received: from Ansuel-XPS.localdomain (93-39-149-95.ip76.fastwebnet.it. [93.39.149.95]) by smtp.googlemail.com with ESMTPSA id b11sm6028921wrt.38.2020.09.18.09.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2020 09:29:36 -0700 (PDT) From: Ansuel Smith To: Kalle Valo Cc: Ansuel Smith , "David S. Miller" , Jakub Kicinski , Rob Herring , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, ath10k@lists.infradead.org Subject: [PATCH 2/2] dt: bindings: ath10k: Document qcom,ath10k-pre-calibration-data-mtd Date: Fri, 18 Sep 2020 18:29:28 +0200 Message-Id: <20200918162928.14335-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200918162928.14335-1-ansuelsmth@gmail.com> References: <20200918162928.14335-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Document use of qcom,ath10k-pre-calibration-data-mtd bindings used to define from where the driver will load the pre-cal data in the defined mtd partition. Signed-off-by: Ansuel Smith --- .../devicetree/bindings/net/wireless/qcom,ath10k.txt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/net/wireless/qcom,ath10k.txt b/Documentation/devicetree/bindings/net/wireless/qcom,ath10k.txt index b61c2d5a0..568364243 100644 --- a/Documentation/devicetree/bindings/net/wireless/qcom,ath10k.txt +++ b/Documentation/devicetree/bindings/net/wireless/qcom,ath10k.txt @@ -15,9 +15,9 @@ and also uses most of the properties defined in this doc (except "qcom,ath10k-calibration-data"). It uses "qcom,ath10k-pre-calibration-data" to carry pre calibration data. -In general, entry "qcom,ath10k-pre-calibration-data" and -"qcom,ath10k-calibration-data" conflict with each other and only one -can be provided per device. +In general, entry "qcom,ath10k-pre-calibration-data", +"qcom,ath10k-calibration-data-mtd" and "qcom,ath10k-calibration-data" conflict with +each other and only one can be provided per device. SNOC based devices (i.e. wcn3990) uses compatible string "qcom,wcn3990-wifi". @@ -63,6 +63,12 @@ Optional properties: hw versions. - qcom,ath10k-pre-calibration-data : pre calibration data as an array, the length can vary between hw versions. +- qcom,ath10k-pre-calibration-data-mtd : + Usage: optional + Value type: + Definition: pre calibration data read from mtd partition. Take 3 value, the + mtd to read data from, the offset in the mtd partition and the + size of data to read. - -supply: handle to the regulator device tree node optional "supply-name" are "vdd-0.8-cx-mx", "vdd-1.8-xo", "vdd-1.3-rfa", "vdd-3.3-ch0",