From patchwork Mon Aug 17 15:15:08 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: 266216 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 E5DBCC433E3 for ; Mon, 17 Aug 2020 18:21:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B1FBE20716 for ; Mon, 17 Aug 2020 18:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597688502; bh=dXcRGZv1/HVg/ovziSEWjfsIO6DWEDv+YO8KxW5bfrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=OwBoDtSXY9jykTpY3xultG6gXhWZAoI1UtuLoPRqGNc77lkGajLnv/Xh4HdojQmuv hflnxuT9I2Wpxt0sjTKF3FV9t0FxPQRizLHf6chBTCV7mABwFLyOW5MBEfnS0sk3LN iq/ptkdNI4xCUEtkTzsBcXIINmT+MVhciNmNJR+s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389303AbgHQSVj (ORCPT ); Mon, 17 Aug 2020 14:21:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:51692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388274AbgHQQD6 (ORCPT ); Mon, 17 Aug 2020 12:03:58 -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 C8B132053B; Mon, 17 Aug 2020 16:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680238; bh=dXcRGZv1/HVg/ovziSEWjfsIO6DWEDv+YO8KxW5bfrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O1+QuEv0Ax6sQLAncq/qoF9I+bjI9k2Hilg5KRTBKNucd3DU9kKDAkkxS4u+aPDs/ sX4WiTSB16olGK2Q8Ud4Uc+gZnK3aYUpel+80tnNAMWh/xqd47E8kjexeOXkHwuARP HsN5XgweE0goIjhlC25KJ9tsh3WTji5WZMVaYHt8= 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.4 107/270] Bluetooth: btmtksdio: fix up firmware download sequence Date: Mon, 17 Aug 2020 17:15:08 +0200 Message-Id: <20200817143801.108532235@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@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 8133382884537..b7de7cb8cca90 100644 --- a/drivers/bluetooth/btmtksdio.c +++ b/drivers/bluetooth/btmtksdio.c @@ -684,7 +684,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) { @@ -692,6 +692,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;