Skip to contentSkip to conversation

Bluetooth: btusb: use usb vid/pid for initializing hal callbacks

PATCH In review Kiran K 3 participants 4 messages Oct 3, 2020 Bluetooth drivers

lore
Share & tools
lore

Kiran K

author
#0 lore raw

PATCH v5 1/2 Bluetooth: btusb: use usb vid/pid for initializing hal callbacks

For Intel controllers, use vid/pid for initalizing hardware abstraction layer callbacks to avoid defining new quirk flags for new products.

---
Changes in v5:
* Use usb vid/pid combination to identify controller type istead of using flags

Changes in previous versions:
None. This is a new patch created part of v5

 drivers/bluetooth/btusb.c | 79 ++++++++++++++++++++++++++++-------------------
 1 file changed, 48 insertions(+), 31 deletions(-)
drivers/bluetooth/btusb.c +48 -31
index 1005b6e..e2cd78d 100644
@@ -3969,13 +3969,21 @@ 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) {
-		data->recv_event = btusb_recv_event_intel;
-		data->recv_bulk = btusb_recv_bulk_intel;
-		set_bit(BTUSB_BOOTLOADER, &data->flags);
-	} else {
-		data->recv_event = hci_recv_frame;
-		data->recv_bulk = btusb_recv_bulk;
+	data->recv_event = hci_recv_frame;
+	data->recv_bulk = btusb_recv_bulk;
+
+	if (id->idVendor == 0x8087) {
+		switch (id->idProduct) {
+		case 0x0025:
+		case 0x0026:
+		case 0x0029:
+		case 0x0a2b:
+		case 0x0aaa:
+			data->recv_event = btusb_recv_event_intel;
+			data->recv_bulk = btusb_recv_bulk_intel;
+			set_bit(BTUSB_BOOTLOADER, &data->flags);
+			break;
+		}
 	}
 
 	hdev = hci_alloc_dev();
@@ -4052,30 +4060,39 @@ static int btusb_probe(struct usb_interface *intf,
 		data->diag = usb_ifnum_to_if(data->udev, ifnum_base + 2);
 	}
 
-	if (id->driver_info & BTUSB_INTEL) {
-		hdev->manufacturer = 2;
-		hdev->setup = btusb_setup_intel;
-		hdev->shutdown = btusb_shutdown_intel;
-		hdev->set_diag = btintel_set_diag_mfg;
-		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_INTEL_NEW) {
-		hdev->manufacturer = 2;
-		hdev->send = btusb_send_frame_intel;
-		hdev->setup = btusb_setup_intel_new;
-		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->idVendor == 0x8087) {
+		switch (id->idProduct) {
+		case 0x07dc:
+		case 0x0a2a:
+		case 0x0aa7:
+			hdev->manufacturer = 2;
+			hdev->setup = btusb_setup_intel;
+			hdev->shutdown = btusb_shutdown_intel;
+			hdev->set_diag = btintel_set_diag_mfg;
+			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);
+			break;
+		case 0x0025:
+		case 0x0026:
+		case 0x0029:
+		case 0x0a2b:
+		case 0x0aaa:
+			hdev->manufacturer = 2;
+			hdev->send = btusb_send_frame_intel;
+			hdev->setup = btusb_setup_intel_new;
+			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);
+			break;
+		}
 	}
 
 	if (id->driver_info & BTUSB_MARVELL)
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v5 2/2 Bluetooth: btintel: Add *setup* function for new generation Intel controllers

1) add a helper function to download firmware

2) add a function to construct firmware / ddc file name

3) define *setup* and hook it up for new genertion Intel controllers

---
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/btintel.h |   6 +
 drivers/bluetooth/btusb.c   | 318 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 324 insertions(+)
drivers/bluetooth/btintel.h +6 -0
index 09346ae..c4e28a8 100644
@@ -132,6 +132,12 @@ struct intel_debug_features {
 	__u8    page1[16];
 } __packed;
 
+#define INTEL_HW_PLATFORM(cnvx_bt)	((u8)(((cnvx_bt) & 0x0000ff00) >> 8))
+#define INTEL_HW_VARIANT(cnvx_bt)	((u8)(((cnvx_bt) & 0x003f0000) >> 16))
+#define INTEL_CNVX_TOP_TYPE(cnvx_top)	((cnvx_top) & 0x00000fff)
+#define INTEL_CNVX_TOP_STEP(cnvx_top)	(((cnvx_top) & 0x0f000000) >> 24)
+#define INTEL_CNVX_TOP_PACK_SWAB(t, s)	__swab16(((__u16)(((t) << 4) | (s))))
+
 #if IS_ENABLED(CONFIG_BT_INTEL)
 
 int btintel_check_bdaddr(struct hci_dev *hdev);
drivers/bluetooth/btusb.c +318 -0

342 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#2 lore raw
In reply to Kiran K

Hi Kiran,

Quoted 35 lines

For Intel controllers, use vid/pid for initalizing hardware abstraction layer callbacks to avoid defining new quirk flags for new products.

---
Changes in v5:
* Use usb vid/pid combination to identify controller type istead of using flags

Changes in previous versions:
None. This is a new patch created part of v5

drivers/bluetooth/btusb.c | 79 ++++++++++++++++++++++++++++-------------------

1 file changed, 48 insertions(+), 31 deletions(-)
drivers/bluetooth/btusb.c +6 -7
index 1005b6e..e2cd78d 100644
@@ -3969,13 +3969,21 @@ 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) {
-		data->recv_event = btusb_recv_event_intel;
-		data->recv_bulk = btusb_recv_bulk_intel;
-		set_bit(BTUSB_BOOTLOADER, &data->flags);
-	} else {
-		data->recv_event = hci_recv_frame;
-		data->recv_bulk = btusb_recv_bulk;
+	data->recv_event = hci_recv_frame;
+	data->recv_bulk = btusb_recv_bulk;
+
+	if (id->idVendor == 0x8087) {
+		switch (id->idProduct) {
+		case 0x0025:

drivers/bluetooth/btusb.c static int btusb_probe(struct usb_interface *intf, · line 3987

Quoted 10 lines
drivers/bluetooth/btusb.c +9 -0
+		case 0x0026:
+		case 0x0029:
+		case 0x0a2b:
+		case 0x0aaa:
+			data->recv_event = btusb_recv_event_intel;
+			data->recv_bulk = btusb_recv_bulk_intel;
+			set_bit(BTUSB_BOOTLOADER, &data->flags);
+			break;
+		}
 	}

please don’t do this. This is exactly what I didn’t want. Listing PID in the device table and then also again in the probe callback is bound to be error prone.

Regards

Marcel

#3 lore raw

Hi Marcel,

Quoted 58 lines

-----Original Message-----
From: Marcel Holtmann <[email protected]>
Sent: Saturday, October 3, 2020 1:57 PM
To: Kiran K <[email protected]>
Cc: linux-bluetooth <[email protected]>; Narasimman, Sathish <[email protected]>; Tumkur Narayan, Chethan <[email protected]>; Srivatsa, Ravishankar <[email protected]>; K, Kiran <[email protected]>
Subject: Re: [PATCH v5 1/2] Bluetooth: btusb: use usb vid/pid for initializing hal callbacks

Hi Kiran,

Quoted 2 lines

For Intel controllers, use vid/pid for initalizing hardware abstraction layer callbacks to avoid defining new quirk flags for new

products.

drivers/bluetooth/btusb.c static int btusb_probe(struct usb_interface

Quoted 19 lines

---
Changes in v5:
* Use usb vid/pid combination to identify controller type istead of using flags

Changes in previous versions:
None. This is a new patch created part of v5

drivers/bluetooth/btusb.c | 79
++++++++++++++++++++++++++++-------------------

1 file changed, 48 insertions(+), 31 deletions(-)
drivers/bluetooth/btusb.c +0 -0
index 1005b6e..e2cd78d 100644
@@ -3969,13 +3969,21 @@ static int btusb_probe(struct usb_interface

*intf,

Quoted 22 lines
drivers/bluetooth/btusb.c +12 -7
 	init_usb_anchor(&data->ctrl_anchor);
 	spin_lock_init(&data->rxlock);
 
-	if (id->driver_info & BTUSB_INTEL_NEW) {
-		data->recv_event = btusb_recv_event_intel;
-		data->recv_bulk = btusb_recv_bulk_intel;
-		set_bit(BTUSB_BOOTLOADER, &data->flags);
-	} else {
-		data->recv_event = hci_recv_frame;
-		data->recv_bulk = btusb_recv_bulk;
+	data->recv_event = hci_recv_frame;
+	data->recv_bulk = btusb_recv_bulk;
+
+	if (id->idVendor == 0x8087) {
+		switch (id->idProduct) {
+		case 0x0025:
+		case 0x0026:
+		case 0x0029:
+		case 0x0a2b:
+		case 0x0aaa:
+			data->recv_event = btusb_recv_event_intel;
+			data->recv_bulk = btusb_recv_bulk_intel;
Quoted 9 lines

drivers/bluetooth/btusb.c static int btusb_probe(struct usb_interface *intf, · line 3987

Quoted 4 lines
drivers/bluetooth/btusb.c +3 -0
+			set_bit(BTUSB_BOOTLOADER, &data->flags);
+			break;
+		}
 	}

please don’t do this. This is exactly what I didn’t want. Listing PID in the device table and then also again in the probe callback is bound to be error prone.

Got your point. I will send the fix with BTUSB_INTEL_NEWGEN as discussed earlier. Thanks.

Quoted 3 lines

Regards

Marcel

Regards,
Kiran