Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp69114lqo; Tue, 7 May 2024 12:23:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUvOpYkvkzpanRJFOpkGPjzTFr5H1GyMwZ5imaQiMex0/xTKpPhfF2nZ4Z6wMlcWhiLjaEyWTBa8KrLEFbGXUyEh0dxfy/ViazuZn4R6w== X-Google-Smtp-Source: AGHT+IGaohgESRuwQKryun3/Sx4yHUTcmUahhFugXL56C4Jgyaq+6y4+JWVbfhreQg+l6ripetDA X-Received: by 2002:a17:902:a60d:b0:1e8:5dc6:4060 with SMTP id d9443c01a7336-1eeb03a2974mr5644675ad.33.1715109796589; Tue, 07 May 2024 12:23:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715109796; cv=pass; d=google.com; s=arc-20160816; b=k0Jq+cw7zQUBWp6tIEfQsJM34Hs/8tymFAeLdzKpNXELauczja2DK9A0Q7uOQ4s/eh T5G538N6RFqA+5gN14u98sGafAvC9WE0wHmKi4WOoQgo4b37J+67Ly+f6xnQXVGjGfpY MAtRQ/zQ/DuCTogGt1UDaAuISZo1P+rqgc5RwKwGsplLWG7MTph55aHIMfdQQRDmefFf pIUz41dWtPggafNeXM69w5nGjuZAuoj8b83J3aI4IhOKQwL31f1a3btRPrluKFCVMxq+ skWcfAgOJ/y6nvaal+fETU9+eCtQnShWnHiCsWCfTXxTLLsuFeLAXousrIogKF80VCDK T4qQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=ToNbBgB0lLDuXRtTbvd57CqqqGRtlld+OojUmDuwhxc=; fh=dLlcIK24wN7dxxcdQIG9SlibMx6VDoobIZGXv+VQXPE=; b=KCQxqV1Q9Yc3a8EOuDzaGTYp2nAa+fs4l2ti8v8p+SeFUyvgtabc2InJMK4qXkBbWz vzk5ko8mUs5QsM4HWmvKNy3cBWWHWn28jLXlnYX0XjLt6v5wIJ4J1tFNHuhQmqV6D84u KwNiZjvjnxjnZ1LTCJPp0wSgHVpMhRHFuiwutXisQuhDog6x/FrE37pA9ESnoottqRaB Q1Fc1krbsmut4OqWIAMBDOy3ohQXHOZbbDMUKjcx+W56L4UEmEiyVyXB90+4q75jBdOU Xy175kq15t4aImVowDzKrBwOU1VenYfg/2e6UUsWDSLrajBL3RxTMGuQgsTgjW1R1inG Hykw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4367-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4367-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q6-20020a170902dac600b001ec41272fc1si11029958plx.602.2024.05.07.12.23.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 12:23:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4367-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4367-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4367-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4E80F28A461 for ; Tue, 7 May 2024 19:23:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1830516F27D; Tue, 7 May 2024 19:22:14 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5149C16F0DF; Tue, 7 May 2024 19:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715109733; cv=none; b=QzvIkiFHiqPJaFRfk7nQG9YCOWdn3AStbNY+o7F9JlA4a89cdImYQK+AeRjzu2shTtaECycpGK6GPvTsPzCR+cJH+s8qB/rWlXGy3Cns8FaEAAFLz7Z8j2dwGiwoUS/2msVuLqnz+cAo4KJNenxYYIEeWM4a1JSK1Ae81kyXUHk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715109733; c=relaxed/simple; bh=t3anCqoQvYawKfAJbp+mSiJnVoopchGAQ15If8ihT9A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N1YM5XMdSQpXtK412plbt35bYWD8J5FDYYPMAPAD3TbbH+OBsKrHEyoMXSQB4zUXDVoWltKBTtHeNkHKf9SbVNXjACponA3TCJA2pjZPACD6y1ox7LSTgEP1YscDpQvKRsI65S+ZjojE4XeLV0DgOZrDE69o9t7EcBwwgkqiRZU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-6ea0a6856d7so194684a34.1; Tue, 07 May 2024 12:22:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715109731; x=1715714531; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ToNbBgB0lLDuXRtTbvd57CqqqGRtlld+OojUmDuwhxc=; b=EX1pYKfUgxomkYtL7nu2rsUmJJfEG/z+iR5zfCupC3EIxU8YYkF+4K3mbiC9m0NcVz Tvpc2VN+A/lsTTGATKbyS2wyzWeYURVCrLB5FCYKPAoPQPSq+Vh/UqqG/t8786chAoKN s3glmEUN4xQ2gmLy/fcY7R25ygC0j+ZPhhiGVpJ09KJU2afO84EqiwbYFVBftOz76EZa IRZM1UtUqNt7uOiWvWKhK6OjcmIUfUnEyG71B6k2uQhsyJTulWqfKHzD3bfEDKO78OiD R60u4Ji3GFfY33gpax35Z1LQnN7MunJck6zjYwtv1A/0lsI5w9ucUsHvBV/6USDB14yl c56w== X-Forwarded-Encrypted: i=1; AJvYcCWX24lMdz8pJJSAnl4tTZNTMPFHn9ooQdEyhr6/Fw0SXGdnLqqkc0SDn3uZXeiTCj9+kPGl6+zwkTsGW1xyB9KVyjsIxbRs/5aj6CxF X-Gm-Message-State: AOJu0YxNOu0VyIDIPlKU/Lne5N0Su4E/M3zrLi0Q5nO+jLig63wECN5T wB+ojAN8LtYilWC+B44sTZv8kxGZcUal9RfavvAbb14/JBg4gMPj X-Received: by 2002:a05:6808:1a21:b0:3c8:49d6:2df0 with SMTP id 5614622812f47-3c9851ea375mr670264b6e.0.1715109731470; Tue, 07 May 2024 12:22:11 -0700 (PDT) Received: from sean-ThinkPad-T450s.lan ([207.191.35.252]) by smtp.gmail.com with ESMTPSA id ec18-20020a056808639200b003c8643f0e5csm1937839oib.16.2024.05.07.12.22.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 12:22:10 -0700 (PDT) From: sean.wang@kernel.org To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com Cc: linux-bluetooth@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Hao Qin , Sean Wang Subject: [PATCH v4 5/5] Bluetooth: btusb: mediatek: add MT7922 subsystem reset Date: Tue, 7 May 2024 12:22:01 -0700 Message-Id: <346166eebadac93848e733277e164d5ce4c1d8c2.1715109394.git.sean.wang@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <965cd14922aea67e2750ff2c2ecad773f8ba485a.1715109394.git.sean.wang@kernel.org> References: <965cd14922aea67e2750ff2c2ecad773f8ba485a.1715109394.git.sean.wang@kernel.org> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Hao Qin Add the support of MT7922 bluetooth subsystem reset that was called the auto revert to self-recover from the fatal error in the controller like the host encounters HCI cmd timeout or the controller crashes. Co-developed-by: Sean Wang Signed-off-by: Sean Wang Signed-off-by: Hao Qin --- v3: split from the v2 to make the patch do one thing in a patch. v4: rebase onto the latest code --- drivers/bluetooth/btusb.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 054e8c06bcf3..a70a5e12912b 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -3039,7 +3039,16 @@ static int btusb_mtk_subsys_reset(struct hci_dev *hdev, u32 dev_id) u32 val; int err; - if (dev_id == 0x7925) { + if (dev_id == 0x7922) { + btusb_mtk_uhw_reg_read(data, MTK_BT_SUBSYS_RST, &val); + val |= 0x00002020; + btusb_mtk_uhw_reg_write(data, MTK_BT_SUBSYS_RST, val); + btusb_mtk_uhw_reg_write(data, MTK_EP_RST_OPT, 0x00010001); + btusb_mtk_uhw_reg_read(data, MTK_BT_SUBSYS_RST, &val); + val |= BIT(0); + btusb_mtk_uhw_reg_write(data, MTK_BT_SUBSYS_RST, val); + msleep(100); + } else if (dev_id == 0x7925) { btusb_mtk_uhw_reg_read(data, MTK_BT_RESET_REG_CONNV3, &val); val |= (1 << 5); btusb_mtk_uhw_reg_write(data, MTK_BT_RESET_REG_CONNV3, val); @@ -3079,6 +3088,9 @@ static int btusb_mtk_subsys_reset(struct hci_dev *hdev, u32 dev_id) if (err < 0) bt_dev_err(hdev, "Reset timeout"); + if (dev_id == 0x7922) + btusb_mtk_uhw_reg_write(data, MTK_UDMA_INT_STA_BT, 0x000000FF); + btusb_mtk_id_get(data, 0x70010200, &val); if (!val) bt_dev_err(hdev, "Can't get device id, subsys reset fail."); -- 2.25.1