From patchwork Sat Jun 16 06:27:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Balakrishna Godavarthi X-Patchwork-Id: 10467903 X-Patchwork-Delegate: agross@codeaurora.org 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 24D28601C2 for ; Sat, 16 Jun 2018 06:27:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2401328826 for ; Sat, 16 Jun 2018 06:27:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 186B928DB7; Sat, 16 Jun 2018 06:27:59 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 8BC5028826 for ; Sat, 16 Jun 2018 06:27:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754040AbeFPG15 (ORCPT ); Sat, 16 Jun 2018 02:27:57 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44192 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754009AbeFPG14 (ORCPT ); Sat, 16 Jun 2018 02:27:56 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 85E52607E4; Sat, 16 Jun 2018 06:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529130475; bh=SuVvLUg6mifeEObMuuPkn2FApyVKGhhtvuzDuczK02Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqVScJuZl9O4ZdZJkuftnK3W6m8I9UsX4AYQjDAVNk+zm7MAMr/BEyc9uc5DfvxzV RmOdlZh8YoxVJoHxv/qW9tDgIUSigkmLzGXdSdtHdv5e2zhXNy1g2wjxDG4d6dr5cJ oMKHZfki9yOXrfApfmQexuZYsfpcIa7LQf6X2hzU= Received: from bgodavar-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: bgodavar@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 4BDA7606FA; Sat, 16 Jun 2018 06:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1529130475; bh=SuVvLUg6mifeEObMuuPkn2FApyVKGhhtvuzDuczK02Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqVScJuZl9O4ZdZJkuftnK3W6m8I9UsX4AYQjDAVNk+zm7MAMr/BEyc9uc5DfvxzV RmOdlZh8YoxVJoHxv/qW9tDgIUSigkmLzGXdSdtHdv5e2zhXNy1g2wjxDG4d6dr5cJ oMKHZfki9yOXrfApfmQexuZYsfpcIa7LQf6X2hzU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4BDA7606FA Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=bgodavar@codeaurora.org From: Balakrishna Godavarthi To: marcel@holtmann.org, johan.hedberg@gmail.com, robh@kernel.org, mka@chromium.org, thierry.escande@linaro.org Cc: linux-bluetooth@vger.kernel.org, rtatiya@codeaurora.org, hemantg@codeaurora.org, linux-arm-msm@vger.kernel.org, Balakrishna Godavarthi Subject: [PATCH v7 4/8] Bluetooth: btqca: Redefine qca_uart_setup() to generic function. Date: Sat, 16 Jun 2018 11:57:14 +0530 Message-Id: <20180616062718.29844-5-bgodavar@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180616062718.29844-1-bgodavar@codeaurora.org> References: <20180616062718.29844-1-bgodavar@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Redefinition of qca_uart_setup will help future Qualcomm Bluetooth SoC, to use the same function instead of duplicating the function. Added new arguments soc_type and soc_ver to the functions. These arguments will help to decide type of firmware files to be loaded into Bluetooth chip. soc_type holds the Bluetooth chip connected to APPS processor. soc_ver holds the Bluetooth chip version. Signed-off-by: Balakrishna Godavarthi --- Changes in v7: * initial patch * redefined qca_uart_setup function to generic. --- drivers/bluetooth/btqca.c | 23 ++++++++++++----------- drivers/bluetooth/btqca.h | 13 +++++++++++-- drivers/bluetooth/hci_qca.c | 3 ++- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/bluetooth/btqca.c b/drivers/bluetooth/btqca.c index c5cf9cab438a..f748730039cf 100644 --- a/drivers/bluetooth/btqca.c +++ b/drivers/bluetooth/btqca.c @@ -327,9 +327,9 @@ int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr) } EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome); -int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) +int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, + u32 soc_ver) { - u32 rome_ver = 0; struct rome_config config; int err; @@ -337,19 +337,20 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) config.user_baud_rate = baudrate; - /* Get QCA version information */ - err = qca_read_soc_version(hdev, &rome_ver); - if (err < 0 || rome_ver == 0) { - bt_dev_err(hdev, "QCA Failed to get version %d", err); - return err; + if (!soc_ver) { + /* Get QCA version information */ + err = qca_read_soc_version(hdev, &soc_ver); + if (err < 0 || soc_ver == 0) { + bt_dev_err(hdev, "QCA Failed to get version %d", err); + return err; + } + bt_dev_info(hdev, "QCA controller version 0x%08x", soc_ver); } - bt_dev_info(hdev, "QCA controller version 0x%08x", rome_ver); - /* Download rampatch file */ config.type = TLV_TYPE_PATCH; snprintf(config.fwname, sizeof(config.fwname), "qca/rampatch_%08x.bin", - rome_ver); + soc_ver); err = qca_download_firmware(hdev, &config); if (err < 0) { bt_dev_err(hdev, "QCA Failed to download patch (%d)", err); @@ -359,7 +360,7 @@ int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) /* Download NVM configuration */ config.type = TLV_TYPE_NVM; snprintf(config.fwname, sizeof(config.fwname), "qca/nvm_%08x.bin", - rome_ver); + soc_ver); err = qca_download_firmware(hdev, &config); if (err < 0) { bt_dev_err(hdev, "QCA Failed to download NVM (%d)", err); diff --git a/drivers/bluetooth/btqca.h b/drivers/bluetooth/btqca.h index d0ee96540636..c7a5d1754f47 100644 --- a/drivers/bluetooth/btqca.h +++ b/drivers/bluetooth/btqca.h @@ -124,10 +124,18 @@ struct tlv_type_hdr { __u8 data[0]; } __packed; +enum qca_btsoc_type { + QCA_INVALID = -1, + QCA_AR3002, + QCA_ROME, + QCA_WCN3990 +}; + #if IS_ENABLED(CONFIG_BT_QCA) int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr); -int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate); +int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, uint8_t soc_type, + u32 soc_ver); int qca_read_soc_version(struct hci_dev *hdev, u32 *soc_version); #else @@ -137,7 +145,8 @@ static inline int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdad return -EOPNOTSUPP; } -static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate) +static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, + uint8_t soc_type, u32 soc_ver) { return -EOPNOTSUPP; } diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c index d7b60669b656..fe62420ef838 100644 --- a/drivers/bluetooth/hci_qca.c +++ b/drivers/bluetooth/hci_qca.c @@ -929,6 +929,7 @@ static int qca_setup(struct hci_uart *hu) struct qca_data *qca = hu->priv; unsigned int speed, qca_baudrate = QCA_BAUDRATE_115200; int ret; + int soc_ver = 0; bt_dev_info(hdev, "ROME setup"); @@ -966,7 +967,7 @@ static int qca_setup(struct hci_uart *hu) } /* Setup patch / NVM configurations */ - ret = qca_uart_setup(hdev, qca_baudrate); + ret = qca_uart_setup(hdev, qca_baudrate, QCA_ROME, soc_ver); if (!ret) { set_bit(STATE_IN_BAND_SLEEP_ENABLED, &qca->flags); qca_debugfs_init(hdev);