Received: by 2002:ab2:7a09:0:b0:1f8:46dc:890e with SMTP id k9csp323607lqo; Wed, 15 May 2024 16:16:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXlDU06ERCloKylgFfrec56zwrWIkHmJRioe+gMr6Rnm8fcBsYpGXiobKZAZShftAlgnxwBpI2x4IsPaakmAWBrOIdJBUH2RcHUkMn6HQ== X-Google-Smtp-Source: AGHT+IFawXnizSqb44bygZWViCBaIF/CISwn8KjnlBCq35/hIZiPDszZbbMAC4GaRiOqQcVsv3Yd X-Received: by 2002:a05:6871:3408:b0:245:112c:6ae5 with SMTP id 586e51a60fabf-245112c6c43mr7100651fac.44.1715815003585; Wed, 15 May 2024 16:16:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715815003; cv=pass; d=google.com; s=arc-20160816; b=Sl2aT9GZYJyR0rC4gTHfOIwcDniHesiSXN5a0alewoyxiDSu5Pl8AuTsoU170WtVPi doHt3P4mshoJC2D1n09DO1dXe7VUUTJ8sTMXo7aC8oY69SCLNIs6YaKiTY0f6IYJQMyP 3KKD+2T1Xk/b6EoecUswUxdPlqPzOgmeKUfrwonyFAJp3WEK/Xq2yjTnJDPwfHD/3/ZL mSeMBWJp8rieh8L00rxL5ouHmsVbwPyltrgaEaT74r5jWgLUWtRhOtDnIc9lsPG/oBNk 3ZhgHB7p+jvCXmcl813VBn8UEV19a1R64CC1tLB22zPTqGXyheJwEw7Jvt9NwS8DGJUH M/5Q== 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=Ze1QygMwN68meqo9PDmwz469IrrkJxaffJS5Hm7aDfQ=; fh=+MowP6e4nRoSD+LU6dk2kEAQxEl01jGtKzUQaSluSU8=; b=xgDthsqXTXiDF+Gaat/aS86mVTqo5O+JXY8UEBX/mk++XN31uO2xT8WDrdT5bi+SQz Oe4rNB3T1bawnlX091i1EkZIPabq/PLYKqlnmtlZjouFP087y4K+DYrkCEiXGEJVJi9T cxhDBbCzT3I8EWBTZU0MS6mV2YJFqotzzVt/kNYh+CepJBVRBDozvH6u+MhPDKdh5Mkg 1MFdqX69h9ExPAbwnV7zvHLM+yig2gtkVLvpNeYTmAugwIeFJ7SRVuB/lZ26/lHxeyp6 polsI7uRXeZUNjzyacWm9rrwqzwEps9ctAq+cWZG4upW2O0n3CNM4Q6wxIW4Tju9Mate mFnQ==; 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-4675-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4675-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-43e202faa03si63582111cf.707.2024.05.15.16.16.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 16:16:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-4675-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gmail.com); spf=pass (google.com: domain of linux-bluetooth+bounces-4675-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-4675-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 4E7B91C21FC0 for ; Wed, 15 May 2024 23:16:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82787101C8; Wed, 15 May 2024 23:15:43 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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 BDF9B15CD46; Wed, 15 May 2024 23:15:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715814943; cv=none; b=F6RAzSkOlXxfx0jGxBmKmZBYNSq86kg9pKqoU2uwdXiPzDmAhyzOAW5irVuGB/BdqWRVC1u5cbjalvw+b0A2TFCpQZ14Gf1KJhYf7uhwloAdvc3xDLao3G0e/P3kH8e4sdrQgOkGOIvKMChfF5FbRS95Qq0o39152dwW3UU435M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715814943; c=relaxed/simple; bh=Jp3BgbsRv61fdluoqzPcfIEveCnVhqg8xF3iPZw2188=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iG0aKf3dT4HNVIhMuwyR6KWMOP+7Le0BsF/gXWsDDWaBGcvv5xNEELH9suM5n9Pqy4aR3IsnrB5iyNZVwh1dNswTs6y2dGRQ4RZedICgAHE821T8zx+0USoxA94zCjv02lNOUVVMUQI3phcPE5fjzRdwfoVPUcJLmqBli14x0fs= 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.167.170 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-oi1-f170.google.com with SMTP id 5614622812f47-3c998b36c6bso1208073b6e.3; Wed, 15 May 2024 16:15:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715814941; x=1716419741; 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=Ze1QygMwN68meqo9PDmwz469IrrkJxaffJS5Hm7aDfQ=; b=p/1DFGmnDUJn2dxuWA/VA4gbpJX0Q3UajADBE2wcWF/CGcB33g6FcgJQSkpjYI8bOl vgC9tcKQ3LT+ZclLD2LV40KiVBCjk5vo1Kq0QGysfLSQVBLprKrkOafmCYR43gmViQlE 12miX+dJMqZoLGg8XCYxIMiC16QsKCwd7GhJhdZD20FmZfBXAD64c1/x93N4aTevjxaO 7dXvoI00kKBgAQrl6jbf06ijwQ/hHqnq9hctXXjEjyZRTgLTMABfCF2/X4XNf8d/KfL/ TVHRj6E/kw8BhQIhyPhv1DWu9/jG8Tl+mBC7xwba6CyVaRBmSmk/o6cmqKRsuxAs5WtD T4sA== X-Forwarded-Encrypted: i=1; AJvYcCVchA+hcKpXZmISWS5ht3g2t5Tsaqzz9zHSnshF2YvjwI9M2PEABlKtW5tZOjgntlZpQiapAWdHKTYs77IUZQaGT626npPIYMkthRU6 X-Gm-Message-State: AOJu0YwF6F24yrdG/WyJuo0xz4J5pZ+FwTcqplJ5ADoADrKXmw9thB+d fPV+yMg1sXvV/v0WtMzz37Cvdm0iQrYMT+ES6t3JLvv/RTKGU+T2 X-Received: by 2002:a4a:de14:0:b0:5b2:7aa7:7b29 with SMTP id 006d021491bc7-5b28193d5e7mr17763186eaf.1.1715814940930; Wed, 15 May 2024 16:15:40 -0700 (PDT) Received: from sean-ThinkPad-T450s.lan ([207.191.35.252]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-6f0ec2e566dsm2032159a34.15.2024.05.15.16.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 16:15:40 -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 v5 5/5] Bluetooth: btusb: mediatek: add MT7922 subsystem reset Date: Wed, 15 May 2024 16:15:21 -0700 Message-Id: <90f8b0663933990ed1bf47dd6698d8ff69f1a948.1715813148.git.sean.wang@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: 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 v5: no change --- 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 ddd5ca7596e5..79aefdb3324d 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