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: 9516539 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 D6ED560761 for ; Fri, 13 Jan 2017 21:35:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C87E128584 for ; Fri, 13 Jan 2017 21:35:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BDAC3286B9; Fri, 13 Jan 2017 21:35:48 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 B3FFB28609 for ; Fri, 13 Jan 2017 21:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751481AbdAMVfo (ORCPT ); Fri, 13 Jan 2017 16:35:44 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34762 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751440AbdAMVf2 (ORCPT ); Fri, 13 Jan 2017 16:35:28 -0500 Received: by mail-lf0-f65.google.com with SMTP id q89so7082095lfi.1 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=fn4NR+ASlbPDS1J4cdZRrV9mffXU2mqw3Cxz8aOSbaJNeciNU/d3laPsBp7IN1Du02 51JhkIN35I2UEquq4EERMV2NXNIG3BbZCaqF4BujlRTBQkhVJ7ezl6+XLG8ChBuEy//X CKLBaQTgTZhVA5eQcOpBpKYdN5+JmGLjvz6jay7wqdUYvmx4jiK0usWyEoS3MOJMSfO5 EuxUIx2XD3gXiyBxWZbhPCsH2eAyMw3jddvB0UDAtZMDGDAs70KP9DcN7+zfXR5Tmsui mPWMzWCc9O4J7Rxm6AdvwakAXoQMa+4IdzpRWLkQgGdJ23Sojohx6qMonrQv8DxExE4H q9rQ== X-Gm-Message-State: AIkVDXIFsfijmK9ABwiHDEZEN5Hjc2CR9+9CJD3WOohUWF0HuBfA1CAy2JANrWhKqS55iQ== 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 Cc: Erik Stromdahl 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> 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 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"