From patchwork Fri Jan 13 21:35:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Stromdahl X-Patchwork-Id: 9516551 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 93C5E60761 for ; Fri, 13 Jan 2017 21:36:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84D3628609 for ; Fri, 13 Jan 2017 21:36:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 795B828782; Fri, 13 Jan 2017 21:36:09 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 34E5D28609 for ; Fri, 13 Jan 2017 21:36:09 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cS9Vz-00041m-TW; Fri, 13 Jan 2017 21:36:03 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cS9Vj-0003ax-Re for ath10k@lists.infradead.org; Fri, 13 Jan 2017 21:35:53 +0000 Received: by mail-lf0-x244.google.com with SMTP id v186so7072137lfa.2 for ; Fri, 13 Jan 2017 13:35:27 -0800 (PST) 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; bh=Ndu/d+vhfbagAFfO32gGaltYgKZajb4rT78f+t7FBVk=; b=ockszjen/BFz8DccqNO6xazrINk6ILg0kd0Uip6dcItM5MbWFqLGgA4fQ56RYm7AyU 2MHTXddd9PPbz9AyIlHioEMeGB1H+5Ov7hrizVLGE/eREhBNXXI3SRiPLmHMtKWB5MFo IGoQaKeXl9GqTEbU8lJLaDqTrskkDe3DvIiwp0kYJkEfbdCH/oWhsztRz6p1P/L2gQ47 crl8UQoRwoYWLPydPibAPS3PKYQLurNXwtkZ7E+fYJwbeREzo5QoiqcuRnxgiaCyeELN ngzWv7QiHIxgDbDe9OOw1epEJOz9J4ZYxb3meNU2hj/jwj7lA9u07sVoYKZtWsAY9KNf Cy7A== 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=Ndu/d+vhfbagAFfO32gGaltYgKZajb4rT78f+t7FBVk=; b=SlIx7/yXQaSjQDbF4JBjGSIApibFkqecjHMxAL+V2xhPS4sh3Qlm+9dFvLYZXRCzkl yHx49TFV2rwc6ghKmCDfwNbB9KEhUqOrvfB5jVzpShzOcW7aottWkvWpfAinN2VSKmQm JvTx/Bu+XzDe1N95Yfny1fbq71/xNnNCiqxIswy9qdMp9KAsUUNKt9aifSeDtF4ql+Q1 X11HX7bZNx/PcKxZEMSZLldBid/46dT1g3b1BaCg43QmpT/2G/YOgtN7oTyppOWtM8H2 ppNQSSeKJ+MrJ8HfCJv14clbHMsJ5An9qxvvpJed3HVe4lYkC1CMC/wEUoEwEC7i5Kqo zGjg== X-Gm-Message-State: AIkVDXLNfTVN0I/2gi/hKJtA9UcNuGbXrAqaSdgofb99ZPkhaOeKw5B2OeltmblmKhz95g== X-Received: by 10.25.227.14 with SMTP id a14mr8876303lfh.42.1484343326126; Fri, 13 Jan 2017 13:35:26 -0800 (PST) Received: from erik-mate-1604.lan (90-227-62-61-no75.tbcn.telia.com. [90.227.62.61]) by smtp.gmail.com with ESMTPSA id 66sm4437411lfy.42.2017.01.13.13.35.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 13 Jan 2017 13:35:25 -0800 (PST) From: Erik Stromdahl To: kvalo@qca.qualcomm.com, linux-wireless@vger.kernel.org, ath10k@lists.infradead.org Subject: [RFC 04/10] ath10k: new fw fetch functionality Date: Fri, 13 Jan 2017 22:35:03 +0100 Message-Id: <1484343309-6327-5-git-send-email-erik.stromdahl@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484343309-6327-1-git-send-email-erik.stromdahl@gmail.com> References: <1484343309-6327-1-git-send-email-erik.stromdahl@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170113_133548_099841_FFEE4D7B X-CRM114-Status: GOOD ( 11.83 ) X-BeenThere: ath10k@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Erik Stromdahl MIME-Version: 1.0 Sender: "ath10k" Errors-To: ath10k-bounces+patchwork-ath10k=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP A new function for creating the fw file name dynamically. Since both SDIO and USB based chipsets will use different firmware from the PCIe and AHB chipsets, the fw file name is created dynamically. The new firmware names are: For PCIe and AHB: firmware-.bin (same as before) For SDIO: firmware-sdio-.bin For USB: firmware-usb-.bin Signed-off-by: Erik Stromdahl --- drivers/net/wireless/ath/ath10k/core.c | 56 ++++++++++++++++------------------ drivers/net/wireless/ath/ath10k/hw.h | 4 +++ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index e985316..c275a52 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c @@ -1284,44 +1284,40 @@ int ath10k_core_fetch_firmware_api_n(struct ath10k *ar, const char *name, return ret; } +static void ath10k_core_get_fw_name(struct ath10k *ar, char *fw_name, + int fw_api) +{ + if ((ar->hif.bus != ATH10K_BUS_PCI) && (ar->hif.bus != ATH10K_BUS_AHB)) + snprintf(fw_name, ATH10K_FW_FILE_NAME_MAX_LEN, "%s-%s-%d.bin", + ATH10K_FW_FILE_BASE, ath10k_bus_str(ar->hif.bus), + fw_api); + else + snprintf(fw_name, ATH10K_FW_FILE_NAME_MAX_LEN, "%s-%d.bin", + ATH10K_FW_FILE_BASE, fw_api); +} + static int ath10k_core_fetch_firmware_files(struct ath10k *ar) { - int ret; + int ret, i; + char fw_name[ATH10K_FW_FILE_NAME_MAX_LEN]; /* calibration file is optional, don't check for any errors */ ath10k_fetch_cal_file(ar); - ar->fw_api = 5; - ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); - - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API5_FILE, - &ar->normal_mode_fw.fw_file); - if (ret == 0) - goto success; - - ar->fw_api = 4; - ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); - - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API4_FILE, - &ar->normal_mode_fw.fw_file); - if (ret == 0) - goto success; - - ar->fw_api = 3; - ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); - - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API3_FILE, - &ar->normal_mode_fw.fw_file); - if (ret == 0) - goto success; + for (i = 5; i >= 2; i--) { + ar->fw_api = i; + ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", + ar->fw_api); - ar->fw_api = 2; - ath10k_dbg(ar, ATH10K_DBG_BOOT, "trying fw api %d\n", ar->fw_api); + ath10k_core_get_fw_name(ar, fw_name, ar->fw_api); + ret = ath10k_core_fetch_firmware_api_n(ar, fw_name, + &ar->normal_mode_fw.fw_file); + if (!ret) + goto success; + } - ret = ath10k_core_fetch_firmware_api_n(ar, ATH10K_FW_API2_FILE, - &ar->normal_mode_fw.fw_file); - if (ret) - return ret; + /* We end up here if we couldn't fetch any firmware */ + return ret; success: ath10k_dbg(ar, ATH10K_DBG_BOOT, "using fw api %d\n", ar->fw_api); diff --git a/drivers/net/wireless/ath/ath10k/hw.h b/drivers/net/wireless/ath/ath10k/hw.h index 6bdea86..9f4cd76 100644 --- a/drivers/net/wireless/ath/ath10k/hw.h +++ b/drivers/net/wireless/ath/ath10k/hw.h @@ -128,6 +128,10 @@ enum qca9377_chip_id_rev { #define QCA4019_HW_1_0_BOARD_DATA_FILE "board.bin" #define QCA4019_HW_1_0_PATCH_LOAD_ADDR 0x1234 +#define ATH10K_FW_FILE_NAME_MAX_LEN 100 + +#define ATH10K_FW_FILE_BASE "firmware" + #define ATH10K_FW_API2_FILE "firmware-2.bin" #define ATH10K_FW_API3_FILE "firmware-3.bin"