Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp258864pxb; Wed, 11 Nov 2020 03:02:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlf2Sh5ffb51Wc30/fBOW4P0PNYb11H6WMXYKNrmYCP4sI3EZsExKOGQr3YOOyHpqNoADs X-Received: by 2002:a17:906:3a4e:: with SMTP id a14mr24249949ejf.140.1605092523492; Wed, 11 Nov 2020 03:02:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605092523; cv=none; d=google.com; s=arc-20160816; b=mwDNmCu/jBY480cVmckVlZnCZpbkPNEzzU6fD+3s9p1wT+QyDa0PAzYmwmh2zTjQ/j zSoqyeCpm1W5ODngY0MPqebFCrQsuT59BFVsSe5s1b8gSW08nJll2/t4Xepb7B3rHpx1 FCMa5XcvwFzaOzdrLsdU2+QDnIF1eiYxQSGqh+To+X+JT3TUKdPA38jo4EtHW0hF3Mrp IHFa4T+IrDQ9z3j5dE1Y3M8SkTYUqslDGxN+87dhTidCvkwAYXEw8FhHIfXZudPxOE28 fwnwFPje5BXod8KoxTnYXD7k6qe5UWIYiLR45UjIGlV9eoHnr9SxUh7MiwK2j3kBAPZ5 QGqA== 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=bkqXOaKhfBwctaeHvpjIYp9EKZRVKkR9HAULfwRUrMs=; b=i5ij/ZX/0wHmus8a5NQVMzKbB/hdhgzHWWjRCdhCIlst+TGPtVnPiKpqcrR3410/vl 3XLQ4oElA8qRJRYpqSMlYxqn3fTXZStPf2/F1a3Btc2SU248BsncMZMAxyyyEX5iGkTf 3JxviVwtU81qi4UF46QL84B4W2TRGwSe1mRwHOorQ6BhTa+4c7uAr0LFRLFQ6hrY0KZd Sa6fz9xJvVU8BLsjDh0UX+GeV+vI1i1yidcFSywmk7J+LddKtdZXGDOE1VfJ/5O98Ljp lkxLdsQPsg30mTlhVUJvUwPZTuj+7cawOZzROLwTmibf7sVp4OTj2i6WQ9oqxX5FMwk7 vaOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-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 b9si1137630ejd.156.2020.11.11.03.01.36; Wed, 11 Nov 2020 03:02:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth-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-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725965AbgKKLB2 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Nov 2020 06:01:28 -0500 Received: from coyote.holtmann.net ([212.227.132.17]:41714 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbgKKLB1 (ORCPT ); Wed, 11 Nov 2020 06:01:27 -0500 Received: from marcel-macbook.holtmann.net (unknown [37.83.201.106]) by mail.holtmann.org (Postfix) with ESMTPSA id CDDCACECFC; Wed, 11 Nov 2020 12:08:33 +0100 (CET) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.4\)) Subject: Re: [PATCH v7 1/4] Bluetooth: btusb: Add *setup* function for new generation Intel controllers From: Marcel Holtmann In-Reply-To: <1602678517-9912-1-git-send-email-kiran.k@intel.com> Date: Wed, 11 Nov 2020 12:01:23 +0100 Cc: linux-bluetooth , Sathish Narsimman , Chethan T N , "Srivatsa, Ravishankar" , Kiran K , Amit K Bag , Raghuram Hegde Content-Transfer-Encoding: 8BIT Message-Id: <84956E68-8DAC-4170-BE38-498D8C92604A@holtmann.org> References: <1602678517-9912-1-git-send-email-kiran.k@intel.com> To: Kiran K X-Mailer: Apple Mail (2.3608.120.23.2.4) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Kiran, > Signed-off-by: Kiran K > Signed-off-by: Amit K Bag > Signed-off-by: Raghuram Hegde > Reviewed-by: Sathish Narasimman > Reviewed-by: Chethan T N > Reviewed-by: Srivatsa Ravishankar > --- > Changes in v7: > * split code in to multiple patches > > Changes in v6: > * Revert to v4 > * Move TyphoonPeak controller mapping to BTUSB_INTEL_NEWGEN to > a separte patch > > Changes in v5: > * Remove BTUSB_INTEL_NEWGEN and use usb vid/pid combination to > identify controller type > > Changes in v4: > * Rebase patchset > * Fix indentation issues > * make btusb_setup_intel_new_get_fw_name to return void as return value is > not getting used > > Changes in v3: > * Combine the two patches in v2 series to one to avoid compiler warnings > reported by kernel bot (lkp) > > Changed in v2: > * Fix typo in commit message > > drivers/bluetooth/btusb.c | 144 +++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 143 insertions(+), 1 deletion(-) > > diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c > index 1005b6e..2e40885 100644 > --- a/drivers/bluetooth/btusb.c > +++ b/drivers/bluetooth/btusb.c > @@ -60,6 +60,7 @@ static struct usb_driver btusb_driver; > #define BTUSB_WIDEBAND_SPEECH 0x400000 > #define BTUSB_VALID_LE_STATES 0x800000 > #define BTUSB_QCA_WCN6855 0x1000000 > +#define BTUSB_INTEL_NEWGEN 0x2000000 > > static const struct usb_device_id btusb_table[] = { > /* Generic Bluetooth USB device */ > @@ -2693,6 +2694,132 @@ static int btusb_setup_intel_new(struct hci_dev *hdev) > return 0; > } > > +static int btusb_setup_intel_newgen(struct hci_dev *hdev) > +{ > + struct btusb_data *data = hci_get_drvdata(hdev); > + u32 boot_param; > + char ddcname[64]; > + ktime_t calltime, delta, rettime; > + unsigned long long duration; > + int err; > + struct intel_debug_features features; > + struct intel_version_tlv version; > + > + BT_DBG("%s", hdev->name); lets use bt_dev_dbg here. > + > + /* Set the default boot parameter to 0x0 and it is updated to > + * SKU specific boot parameter after reading Intel_Write_Boot_Params > + * command while downloading the firmware. > + */ > + boot_param = 0x00000000; > + > + calltime = ktime_get(); > + > + /* Read the Intel version information to determine if the device > + * is in bootloader mode or if it already has operational firmware > + * loaded. > + */ > + err = btintel_read_version_tlv(hdev, &version); > + if (err) { > + bt_dev_err(hdev, "Intel Read version failed (%d)", err); > + btintel_reset_to_bootloader(hdev); > + return err; > + } > + > + btintel_version_info_tlv(hdev, &version); > + > + /* TODO: Plugin in code here to download firmware */ > + > + /* check if controller is already having an operational firmware */ > + if (version.img_type == 0x03) > + goto finish; > + > + rettime = ktime_get(); > + delta = ktime_sub(rettime, calltime); > + duration = (unsigned long long)ktime_to_ns(delta) >> 10; > + > + bt_dev_info(hdev, "Firmware loaded in %llu usecs", duration); > + > + calltime = ktime_get(); > + > + set_bit(BTUSB_BOOTING, &data->flags); > + > + err = btintel_send_intel_reset(hdev, boot_param); > + if (err) { > + bt_dev_err(hdev, "Intel Soft Reset failed (%d)", err); > + btintel_reset_to_bootloader(hdev); > + return err; > + } > + > + /* The bootloader will not indicate when the device is ready. This > + * is done by the operational firmware sending bootup notification. > + * > + * Booting into operational firmware should not take longer than > + * 1 second. However if that happens, then just fail the setup > + * since something went wrong. > + */ > + bt_dev_info(hdev, "Waiting for device to boot"); > + > + err = wait_on_bit_timeout(&data->flags, BTUSB_BOOTING, > + TASK_INTERRUPTIBLE, > + msecs_to_jiffies(1000)); > + > + if (err == -EINTR) { > + bt_dev_err(hdev, "Device boot interrupted"); > + return -EINTR; > + } > + > + if (err) { > + bt_dev_err(hdev, "Device boot timeout"); > + btintel_reset_to_bootloader(hdev); > + return -ETIMEDOUT; > + } > + > + rettime = ktime_get(); > + delta = ktime_sub(rettime, calltime); > + duration = (unsigned long long)ktime_to_ns(delta) >> 10; > + > + bt_dev_info(hdev, "Device booted in %llu usecs", duration); > + > + clear_bit(BTUSB_BOOTLOADER, &data->flags); > + > + /* TODO: Insert function call here to get the ddc file name */ Don’t add TODO. Just provide the patches in the right order. > + > + /* Once the device is running in operational mode, it needs to > + * apply the device configuration (DDC) parameters. > + * > + * The device can work without DDC parameters, so even if it > + * fails to load the file, no need to fail the setup. > + */ > + btintel_load_ddc_config(hdev, ddcname); > + > + /* Read the Intel supported features and if new exception formats > + * supported, need to load the additional DDC config to enable. > + */ > + btintel_read_debug_features(hdev, &features); > + > + /* Set DDC mask for available debug features */ > + btintel_set_debug_features(hdev, &features); > + > + /* Read the Intel version information after loading the FW */ > + err = btintel_read_version_tlv(hdev, &version); > + if (err) > + return err; > + > + btintel_version_info_tlv(hdev, &version); > + > +finish: > + /* Set the event mask for Intel specific vendor events. This enables > + * a few extra events that are useful during general operation. It > + * does not enable any debugging related events. > + * > + * The device will function correctly without these events enabled > + * and thus no need to fail the setup. > + */ > + btintel_set_event_mask(hdev, false); > + > + return 0; > +} > static int btusb_shutdown_intel(struct hci_dev *hdev) > { > struct sk_buff *skb; > @@ -3969,7 +4096,8 @@ static int btusb_probe(struct usb_interface *intf, > init_usb_anchor(&data->ctrl_anchor); > spin_lock_init(&data->rxlock); > > - if (id->driver_info & BTUSB_INTEL_NEW) { > + if ((id->driver_info & BTUSB_INTEL_NEW) || > + (id->driver_info & BTUSB_INTEL_NEWGEN)) { This seems to be a leftover. Put all in the BTUSB_INTEL_NEWGEN section. > data->recv_event = btusb_recv_event_intel; > data->recv_bulk = btusb_recv_bulk_intel; > set_bit(BTUSB_BOOTLOADER, &data->flags); > @@ -4078,6 +4206,20 @@ static int btusb_probe(struct usb_interface *intf, > set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); > } > > + if (id->driver_info & BTUSB_INTEL_NEWGEN) { > + hdev->manufacturer = 2; > + hdev->send = btusb_send_frame_intel; > + hdev->setup = btusb_setup_intel_newgen; > + hdev->shutdown = btusb_shutdown_intel_new; > + hdev->hw_error = btintel_hw_error; > + hdev->set_diag = btintel_set_diag; > + hdev->set_bdaddr = btintel_set_bdaddr; > + hdev->cmd_timeout = btusb_intel_cmd_timeout; > + set_bit(HCI_QUIRK_STRICT_DUPLICATE_FILTER, &hdev->quirks); > + set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); > + set_bit(HCI_QUIRK_NON_PERSISTENT_DIAG, &hdev->quirks); > + } > + > if (id->driver_info & BTUSB_MARVELL) > hdev->set_bdaddr = btusb_set_bdaddr_marvell; Regards Marcel