Skip to contentSkip to conversation

Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices

PATCH In review [email protected] 2 participants 7 messages Mar 8, 2019 – Mar 11, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices

From: Sean Wang <[email protected]>

This adds the support of enabling MT7663S and MT7668S SDIO-based Bluetooth function.

patch 1: add MediaTek SDIO identifiers
patch 2: add support for MediaTek MT7663S and MT7668S SDIO devices

Sean Wang (2):
mmc: add SDIO identifiers for MediaTek Bluetooth devices
Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO
devices

 drivers/bluetooth/Kconfig     |  11 +
 drivers/bluetooth/Makefile    |   1 +
 drivers/bluetooth/btmtksdio.c | 979 ++++++++++++++++++++++++++++++++++
 include/linux/mmc/sdio_ids.h  |   2 +
 4 files changed, 993 insertions(+)
 create mode 100644 drivers/bluetooth/btmtksdio.c
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/2 mmc: add SDIO identifiers for MediaTek Bluetooth devices

From: Sean Wang <[email protected]>

The SDIO identifier for MediaTek Bluetooth devices were defined in the MediaTek Bluetooth driver. Moving the definitions in MMC header file seems common sense.

---
 include/linux/mmc/sdio_ids.h | 2 ++
 1 file changed, 2 insertions(+)
include/linux/mmc/sdio_ids.h +2 -0
index 4332199c71c2..d1a5d5df02f5 100644
@@ -59,6 +59,8 @@
 #define SDIO_DEVICE_ID_MARVELL_8797_F0		0x9128
 #define SDIO_DEVICE_ID_MARVELL_8887WLAN	0x9134
 
+#define SDIO_VENDOR_ID_MEDIATEK			0x037a
+
 #define SDIO_VENDOR_ID_SIANO			0x039a
 #define SDIO_DEVICE_ID_SIANO_NOVA_B0		0x0201
 #define SDIO_DEVICE_ID_SIANO_NICE		0x0202
Signature · 1 line
2.18.0
maintainer
#2 lore raw

Re: [PATCH v1 1/2] mmc: add SDIO identifiers for MediaTek Bluetooth devices

Hi Sean,

Quoted 8 lines

The SDIO identifier for MediaTek Bluetooth devices were defined in the MediaTek Bluetooth driver. Moving the definitions in MMC header file seems common sense.

---
include/linux/mmc/sdio_ids.h | 2 ++

1 file changed, 2 insertions(+)

patch has been applied to bluetooth-next tree.

Can we also update the sdio.ids database inside systemd.

https://github.com/systemd/systemd/blob/master/hwdb/sdio.ids

Regards

Marcel

author
#3 lore raw

Re: [PATCH v1 1/2] mmc: add SDIO identifiers for MediaTek Bluetooth devices

Quoted 11 lines · Marcel Holtmann

Hi Sean,

Quoted 8 lines

The SDIO identifier for MediaTek Bluetooth devices were defined in the MediaTek Bluetooth driver. Moving the definitions in MMC header file seems common sense.

---
include/linux/mmc/sdio_ids.h | 2 ++

1 file changed, 2 insertions(+)
Quoted 6 lines

patch has been applied to bluetooth-next tree.

Can we also update the sdio.ids database inside systemd.

https://github.com/systemd/systemd/blob/master/hwdb/sdio.ids

Sure, thanks for showing me the information and I'll update the database for the card.

Quoted 9 lines

Regards

Marcel

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#4 lore raw

PATCH 2/2 Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO devices

In reply to [email protected]

From: Sean Wang <[email protected]>

This adds the support of enabling MT7663S and MT7668S SDIO-based Bluetooth function.

There are quite many differences between MT766[3,8]S and standard Bluetooth SDIO devices such as Type-A and Type-B devices. For example, MT766[3,8]S have its own SDIO registers layout, definition, SDIO packet format, and the specific flow should be programmed on them to complete the device initialization and low power control and so on.

Currently, there are many independent programming sequences from the transport which are exactly the same as the ones in btusb.c about MediaTek support [1] and btmtkuart.c. We can try to split the transport independent Bluetooth setups on the advance, place them into the common files and allow varous transport drivers to reuse them in the future.

[1] http://lists.infradead.org/pipermail/linux-mediatek/2019-January/017074.html

---
 drivers/bluetooth/Kconfig     |  11 +
 drivers/bluetooth/Makefile    |   1 +
 drivers/bluetooth/btmtksdio.c | 979 ++++++++++++++++++++++++++++++++++
 3 files changed, 991 insertions(+)
 create mode 100644 drivers/bluetooth/btmtksdio.c
drivers/bluetooth/Kconfig +11 -0
index de62ccf43df6..bff51d45cdcf 100644
@@ -390,6 +390,17 @@ config BT_WILINK
 	  Say Y here to compile support for Texas Instrument's WiLink7 driver
 	  into the kernel or say M to compile it as module (btwilink).
 
+config BT_MTKSDIO
+	tristate "MediaTek HCI SDIO driver"
+	depends on MMC
+	help
+	  MediaTek Bluetooth HCI SDIO driver.
+	  This driver is required if you want to use MediaTek Bluetooth
+	  with SDIO interface.
+
+	  Say Y here to compile support for MediaTek Bluetooth SDIO devices
+	  into the kernel or say M to compile it as module (btmtksdio).
+
 config BT_MTKUART
 	tristate "MediaTek HCI UART driver"
 	depends on SERIAL_DEV_BUS
drivers/bluetooth/Makefile +1 -0
index b7e393cfc1e3..34887b9b3a85 100644
@@ -20,6 +20,7 @@ obj-$(CONFIG_BT_ATH3K)		+= ath3k.o
 obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
 obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
 obj-$(CONFIG_BT_WILINK)		+= btwilink.o
+obj-$(CONFIG_BT_MTKSDIO)	+= btmtksdio.o
 obj-$(CONFIG_BT_MTKUART)	+= btmtkuart.o
 obj-$(CONFIG_BT_QCOMSMD)	+= btqcomsmd.o
 obj-$(CONFIG_BT_BCM)		+= btbcm.o
drivers/bluetooth/btmtksdio.c new file +979 -0

979 lines not on this page · raw message

Signature · 1 line
2.18.0
maintainer
#5 lore raw

Hi Sean,

Quoted 17 lines

This adds the support of enabling MT7663S and MT7668S SDIO-based Bluetooth function.

There are quite many differences between MT766[3,8]S and standard Bluetooth SDIO devices such as Type-A and Type-B devices. For example, MT766[3,8]S have its own SDIO registers layout, definition, SDIO packet format, and the specific flow should be programmed on them to complete the device initialization and low power control and so on.

Currently, there are many independent programming sequences from the transport which are exactly the same as the ones in btusb.c about MediaTek support [1] and btmtkuart.c. We can try to split the transport independent Bluetooth setups on the advance, place them into the common files and allow varous transport drivers to reuse them in the future.

[1] http://lists.infradead.org/pipermail/linux-mediatek/2019-January/017074.html

Quoted 7 lines

---

drivers/bluetooth/Kconfig     |  11 +
drivers/bluetooth/Makefile    |   1 +
drivers/bluetooth/btmtksdio.c | 979 ++++++++++++++++++++++++++++++++++
3 files changed, 991 insertions(+)

create mode 100644 drivers/bluetooth/btmtksdio.c

patch has been applied to bluetooth-next tree.

You also need to send an extra patch providing a fix for this:

CC drivers/bluetooth/btmtksdio.o
drivers/bluetooth/btmtksdio.c: In function ‘btmtksdio_interrupt’:
drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          old_data, old_len, true);
          ~~~~~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btmtksdio.c:376:15: note: ‘old_len’ was declared here
  unsigned int old_len;
               ^~~~~~~
drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_data’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          old_data, old_len, true);
          ~~~~~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btmtksdio.c:375:17: note: ‘old_data’ was declared here
  unsigned char *old_data;
                 ^~~~~~~~

And can we actually introduce module_sdio_driver similar to module_usb_driver.

Regards

Marcel

author
#6 lore raw
Quoted 27 lines · Marcel Holtmann

Hi Sean,

Quoted 17 lines

This adds the support of enabling MT7663S and MT7668S SDIO-based Bluetooth function.

There are quite many differences between MT766[3,8]S and standard Bluetooth SDIO devices such as Type-A and Type-B devices. For example, MT766[3,8]S have its own SDIO registers layout, definition, SDIO packet format, and the specific flow should be programmed on them to complete the device initialization and low power control and so on.

Currently, there are many independent programming sequences from the transport which are exactly the same as the ones in btusb.c about MediaTek support [1] and btmtkuart.c. We can try to split the transport independent Bluetooth setups on the advance, place them into the common files and allow varous transport drivers to reuse them in the future.

[1] http://lists.infradead.org/pipermail/linux-mediatek/2019-January/017074.html

Quoted 7 lines

---

drivers/bluetooth/Kconfig     |  11 +
drivers/bluetooth/Makefile    |   1 +
drivers/bluetooth/btmtksdio.c | 979 ++++++++++++++++++++++++++++++++++
3 files changed, 991 insertions(+)

create mode 100644 drivers/bluetooth/btmtksdio.c

Quoted 4 lines

patch has been applied to bluetooth-next tree.

You also need to send an extra patch providing a fix for this:

Thanks for the reporting. I'll fix it up soon.

Quoted 19 lines

CC drivers/bluetooth/btmtksdio.o
drivers/bluetooth/btmtksdio.c: In function ‘btmtksdio_interrupt’:
drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          old_data, old_len, true);
          ~~~~~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btmtksdio.c:376:15: note: ‘old_len’ was declared here
  unsigned int old_len;
               ^~~~~~~
drivers/bluetooth/btmtksdio.c:470:2: warning: ‘old_data’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1,
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          old_data, old_len, true);
          ~~~~~~~~~~~~~~~~~~~~~~~~
drivers/bluetooth/btmtksdio.c:375:17: note: ‘old_data’ was declared here
  unsigned char *old_data;
                 ^~~~~~~~
Quoted 2 lines

And can we actually introduce module_sdio_driver similar to module_usb_driver.

Sure, I can add and apply module_sdio_driver on the driver and then see if Ulf like it.

Quoted 4 lines

Regards

Marcel