Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1191654pxb; Thu, 16 Sep 2021 01:42:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxi9oXCBaqw1zpC7tZqs1xeLZpS3hvDrB+YZvlKtEU9Q6JJjRhfg1CYv3p6k+SXQUr77fmK X-Received: by 2002:a05:6638:3726:: with SMTP id k38mr3455848jav.105.1631781723741; Thu, 16 Sep 2021 01:42:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631781723; cv=none; d=google.com; s=arc-20160816; b=WnG5ZegzRJKKPV84SqWgupDF9rnTPBdPgcgfmoaei6i5nGbhLJ6+blS71+jyiy6+2t yz9J5junYI0TOKvKP37h6SwIL5DZquTUMAKnhmzo88SfsMRQw6dDFq2Hp5/Uz9c9kIAw Acg4/OxtCAr1IZvzmBdFSbDF9qs7MWaaHBCPMThV1+xHmAkiliyDv94ncb5S/o4wxXa3 FfkOi3GaJQEZpGjiJc/cNgGsM5vDkFYMEKlganHyaFfNSsQoK+ElNcsM+bngDQZ0zm4q Ge22PpHsJLDeODhYHeONh/i0LF6h5N37TQ4nxqhRGxWBZsOihbsvw6E0D/LI49qLoLbr LvRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:subject:cc:to:from:date :content-transfer-encoding:mime-version:sender:dkim-signature; bh=vH/3PJSvt6dKKjRhpN7SN/NYDcrVA+09ITtulvlItFs=; b=ynzZskgQ+gh6RyMaQV0byfpboZjDv0hyFn3pNTKbFSJUcCYsd9vZ4CbUPreC4TV6l3 VXo2QqT+yjtLjzrGFPNhQJe4n1wju5bCfEyTYADE17mOtKduucBYswmKnztYsOh4Vqvo AJz+6LhEwzhKuoVf5YWRcCC44LUqdoZ5Spmn8mnVXKwMplQkS3DUDGJbM6bHx5uQr1d0 rCl0sLiNJXqUjXLrSU/nnHnuEx7qhzjG1WijYYq3j8osdGW2WVLyvidOY/BM4OYmr9fd zOT8KhpY+xg5q4Kw4rvNaCViY2iYvThgARR9CUgfISSg+iUEutlet1p3Qp4IbC3nfYeT mf9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=xISPuWT8; 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 m24si2171631jac.82.2021.09.16.01.41.51; Thu, 16 Sep 2021 01:42:03 -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; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=xISPuWT8; 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 S234268AbhIPIma (ORCPT + 99 others); Thu, 16 Sep 2021 04:42:30 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:35871 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235138AbhIPIm3 (ORCPT ); Thu, 16 Sep 2021 04:42:29 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1631781669; h=Message-ID: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=vH/3PJSvt6dKKjRhpN7SN/NYDcrVA+09ITtulvlItFs=; b=xISPuWT8sn1fhPJWzG+4wy3WMpeK7gyiVE2lRTT2mCGA12KWIx5MDzdLFFq6H9go5Oja9zef IWi0krajAJwpec5hGc+MUK7MNNm9HdwpQqkyQHjBjpqzas4TqX5u/1xitG1nnZHiuukVwlIJ 8ORpdixeNoV8hiK2PGte1UJzGCo= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 61430324d914b05182d9ba14 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 16 Sep 2021 08:41:08 GMT Sender: tjiang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id D59ADC4360D; Thu, 16 Sep 2021 08:41:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: tjiang) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2264CC4338F; Thu, 16 Sep 2021 08:41:06 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 16 Sep 2021 16:41:06 +0800 From: tjiang@codeaurora.org To: marcel@holtmann.org, johan.hedberg@gmail.com, luiz.dentz@gmail.com Cc: linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-arm-msm@vger.kernel.org, bgodavar@codeaurora.org, c-hbandi@codeaurora.org, hemantg@codeaurora.org, mka@chromium.org, rjliao@codeaurora.org, zijuhu@codeaurora.org, tjiang@codeaurora.org Subject: [PATCH v1] Bluetooth: btusb: Add gpio reset way for qca btsoc in cmd_timeout Message-ID: X-Sender: tjiang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org if platform provide gpio connect to BT_EN reset pin of qca btsoc chip, we can do hardware reset instead of usb port reset. Signed-off-by: Tim Jiang --- drivers/bluetooth/btusb.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index 8ef4e0f6e0bb..da85cc14f931 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c @@ -657,11 +657,33 @@ static void btusb_rtl_cmd_timeout(struct hci_dev *hdev) static void btusb_qca_cmd_timeout(struct hci_dev *hdev) { struct btusb_data *data = hci_get_drvdata(hdev); + struct gpio_desc *reset_gpio = data->reset_gpio; int err; if (++data->cmd_timeout_cnt < 5) return; + if (reset_gpio) { + bt_dev_err(hdev, "Reset qca device via bt_en gpio"); + + /* Toggle the hard reset line. The qca bt device is going to + * yank itself off the USB and then replug. The cleanup is handled + * correctly on the way out (standard USB disconnect), and the new + * device is detected cleanly and bound to the driver again like + * it should be. + */ + if (test_and_set_bit(BTUSB_HW_RESET_ACTIVE, &data->flags)) { + bt_dev_err(hdev, "last reset failed? Not resetting again"); + return; + } + + gpiod_set_value_cansleep(reset_gpio, 0); + msleep(200); + gpiod_set_value_cansleep(reset_gpio, 1); + + return; + } + bt_dev_err(hdev, "Multiple cmd timeouts seen. Resetting usb device."); /* This is not an unbalanced PM reference since the device will reset */ err = usb_autopm_get_interface(data->intf); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project