From patchwork Mon Aug 17 15:13:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266440 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 37C93C433E1 for ; Mon, 17 Aug 2020 15:48:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F20972177B for ; Mon, 17 Aug 2020 15:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679294; bh=Frg6GuRUhsOONlrctqAmXhrzsvKeSDaV/PFRSZRwPkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=WqPkcwODGFLwxcd5BKvG/3OTY4Ek3PpdMGVy0RMRQzUxKotREgl/1tZYQQag7nf5K 6o/sBQ9VsLwfr3pN650q9EqTUJeP7XIUl4h2P0dHp+6N+JYayPV1P/Cj+dsD3HcgCZ ek+/+2c3NpYRvR4s+A+r2Jabp7w5MaSZpGuAwDIw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730837AbgHQPsJ (ORCPT ); Mon, 17 Aug 2020 11:48:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:59828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730275AbgHQPrr (ORCPT ); Mon, 17 Aug 2020 11:47:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9C2B220855; Mon, 17 Aug 2020 15:47:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679266; bh=Frg6GuRUhsOONlrctqAmXhrzsvKeSDaV/PFRSZRwPkI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C1H/444HBBhseVtWZxD/VvjVCJfgqTdT1KNXfaQVXRDMUts8kJv5c/bFDfAkkVCs0 pJXaoDAuhJrh/1dliht7OHQByBReJWcVMn9T620c3Nvrc4gFlp0MJRS1Jxvg0Lqmdr ++mjq5XiAHexHb+HYKIPO3Sn92FlmSmzfMDT7A2o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Chen , Sean Wang , Marcel Holtmann , Sasha Levin Subject: [PATCH 5.7 151/393] Bluetooth: btmtksdio: fix up firmware download sequence Date: Mon, 17 Aug 2020 17:13:21 +0200 Message-Id: <20200817143826.940490817@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sean Wang [ Upstream commit 737cd06072a72e8984e41af8e5919338d0c5bf2b ] Data RAM on the device have to be powered on before starting to download the firmware. Fixes: 9aebfd4a2200 ("Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices") Co-developed-by: Mark Chen Signed-off-by: Mark Chen Signed-off-by: Sean Wang Signed-off-by: Marcel Holtmann Signed-off-by: Sasha Levin --- drivers/bluetooth/btmtksdio.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c index 519788c442ca3..11494cd2a9823 100644 --- a/drivers/bluetooth/btmtksdio.c +++ b/drivers/bluetooth/btmtksdio.c @@ -685,7 +685,7 @@ static int mtk_setup_firmware(struct hci_dev *hdev, const char *fwname) const u8 *fw_ptr; size_t fw_size; int err, dlen; - u8 flag; + u8 flag, param; err = request_firmware(&fw, fwname, &hdev->dev); if (err < 0) { @@ -693,6 +693,20 @@ static int mtk_setup_firmware(struct hci_dev *hdev, const char *fwname) return err; } + /* Power on data RAM the firmware relies on. */ + param = 1; + wmt_params.op = MTK_WMT_FUNC_CTRL; + wmt_params.flag = 3; + wmt_params.dlen = sizeof(param); + wmt_params.data = ¶m; + wmt_params.status = NULL; + + err = mtk_hci_wmt_sync(hdev, &wmt_params); + if (err < 0) { + bt_dev_err(hdev, "Failed to power on data RAM (%d)", err); + return err; + } + fw_ptr = fw->data; fw_size = fw->size;