Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp563644pxv; Thu, 22 Jul 2021 07:05:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPLIiPk/8LrywmWq05QqC7JYtPzuzbkX4e6pXb+cMSU1il5nWyCiZqDxV56Z65gE4tyZfw X-Received: by 2002:a6b:7b44:: with SMTP id m4mr30639061iop.72.1626962719635; Thu, 22 Jul 2021 07:05:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626962719; cv=none; d=google.com; s=arc-20160816; b=XiRsIDkj0qPndo9SdBdqXrpNnmSZ/TWx+lmF6yLkN624qNGc9a+Gq0oF9G4I2/C/5y bfTfFl+/nfWc5JOw6lvPOemB0UKB+wgbrX+buo0A8Spq1zR7qXnKGDKle5p857hOqEWg 8zAMPZn0nPn1hO5dFzioXM/PuEK9GhD2fzvo3kIVzdbakiAIDWroTIxLgYoirmhppr3c m4vacfTiSffrUwxuIjl6poDhQbtYGw02+auFGf1DynnBqQSOA54+OfTeS7eIAY3/jTHE NHF6KqMdd6y3+ZyWrzS4IlbmWv/iN9onJ81CnsdJyeWvI0R924rJA6oskTGqfWNjdaKv RiWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=1tEMD8IYM9f2fqkwUErofkOOi4CZng8yHmZ+Ski0d0E=; b=PRugQTHDDTZ5mDTNKdXoo8aKRhxXyxUUO9Zx+wtjPRKatkRSCwh1oWAfcgmLifxgVQ RsCvoKIoHIRxMKrf7DoP0krXXaiYjnxfkMmPgrrz7B49BWEyMfD8QTDZf2riBQjLvCIn /nnNJQJUBFLDiM8Jg7YR3bU5SnCCV2A7CcFmDprJIGO9ciJF3aAKIV+Tz/ZkYu5OwT9n 2FFgYItWG+Iudbw25fYX18jG5YGDK6bAWI4RapW7dsHtBvZ4djJp0zvunmAifQ0ilZpl MRfqJNg5MlbnOmY5yU590ON+dwrjysz6ZjpstY5N4S3P0j+rV2jKgN+FNdRp3RCpgOJh 9ZSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b20si21166229jat.16.2021.07.22.07.05.05; Thu, 22 Jul 2021 07:05:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232262AbhGVNXP convert rfc822-to-8bit (ORCPT + 99 others); Thu, 22 Jul 2021 09:23:15 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:51693 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232118AbhGVNXP (ORCPT ); Thu, 22 Jul 2021 09:23:15 -0400 Received: from smtpclient.apple (p5b3d2eb8.dip0.t-ipconnect.de [91.61.46.184]) by mail.holtmann.org (Postfix) with ESMTPSA id ACF84CECDC; Thu, 22 Jul 2021 16:03:48 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.100.0.2.22\)) Subject: Re: [PATCH v4 2/2] Bluetooth: btusb: Support Bluetooth Reset for Mediatek Chip(MT7921) From: Marcel Holtmann In-Reply-To: <20210701194243.5449-2-mark-yw.chen@mediatek.com> Date: Thu, 22 Jul 2021 16:03:48 +0200 Cc: Johan Hedberg , chris.lu@mediatek.com, will-cy.lee@mediatek.com, Sean Wang , Bluetooth Kernel Mailing List , linux-mediatek@lists.infradead.org, open list , michaelfsun@google.com, shawnku@google.com, jemele@google.com, apusaka@google.com Content-Transfer-Encoding: 8BIT Message-Id: <0FDB7895-4ABF-4975-AF61-FCFA86597254@holtmann.org> References: <20210701194243.5449-1-mark-yw.chen@mediatek.com> <20210701194243.5449-2-mark-yw.chen@mediatek.com> To: =?utf-8?B?Ik1hcmstWVcgQ2hlbiAo6Zmz5o+a5paHKSI=?= X-Mailer: Apple Mail (2.3654.100.0.2.22) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mark, > When the firmware hang or command no response, driver can reset the > bluetooth mcu via USB to recovery it. The reset steps as follows. > > 1. Cancel USB transfer requests before reset. > 2. It use speicific USB HW Register to reset Bluetooth MCU, at the > same time, the USB Endpoint0 still keep alive. > 3. Poll the USB HW register until reset is completed by Endpoint0. > 4. To recovery unexpected USB state and behavior during resetting the > Bluetooth MCU, the driver need to reset the USB device for MT7921. > 5. After the reset is completed, the Bluetooth MCU need to re-setup, > such as download patch, power-on sequence and etc. > > Signed-off-by: mark-yw.chen > --- > drivers/bluetooth/btusb.c | 127 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 127 insertions(+) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index b1249b664981..122a928ebcb5 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -3076,6 +3076,17 @@ static int btusb_shutdown_intel_new(struct hci_dev *hdev) > return 0; > } > > +/* UHW CR mapping */ > +#define BT_MISC 0x70002510 > +#define BT_SUBSYS_RST 0x70002610 > +#define UDMA_INT_STA_BT 0x74000024 > +#define UDMA_INT_STA_BT1 0x74000308 > +#define BT_WDT_STATUS 0x740003A0 > +#define EP_RST_OPT 0x74011890 > +#define EP_RST_IN_OUT_OPT 0x00010001 > +#define BT_RST_DONE 0x00000100 > +#define BT_RESET_WAIT_MS 100 > +#define BT_RESET_NUM_TRIES 10 you need to prefix these with MTK since otherwise we get confused. And we need to work towards abstracting the vendor specific position out of btusb.c (and I include the Intel part here as well). The btusb.c is getting overloaded with vendor stuff. Regards Marcel