2020-04-20 08:51:54

by Christian Hewitt

[permalink] [raw]
Subject: How to handle different operating speed for QCA9377 SDIO BT module?

Resend to expand the audience and include the linux-amlogic and ath10k lists.

>>>>>

I’m working with a QCA9337 SDIO device on an Android (now Linux) set-top box with an Amlogic S905D SoC.

SDIO WiFi (ath10k) is working since 5.7-rc1, but the BT side of the module is still missing.

Most Amlogic devices (95%+) use Broadcom SDIO modules with the following device tree content:

&uart_A {
bluetooth {
compatible = "brcm,bcm43438-bt";
shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
max-speed = <2000000>;
clocks = <&wifi32k>;
clock-names = "lpo";
};
};

I changed the compatible to "qcom,qca9377-bt” and applied the following patch:

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 439392b1c043..6f0350fbdcd6 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -2046,6 +2046,7 @@ static SIMPLE_DEV_PM_OPS(qca_pm_ops, qca_suspend, qca_resume);

static const struct of_device_id qca_bluetooth_of_match[] = {
{ .compatible = "qcom,qca6174-bt" },
+ { .compatible = "qcom,qca9377-bt" },
{ .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data_wcn3990},
{ .compatible = "qcom,wcn3991-bt", .data = &qca_soc_data_wcn3991},
{ .compatible = "qcom,wcn3998-bt", .data = &qca_soc_data_wcn3998},

This results in probing with errors: http://ix.io/2i6P

I noticed "max-speed = <2000000>;” while hci_qca.c sets 3000000. I attempted to set "max-speed = <3000000>;” but this made no difference, so I patched a lower value in hci_qca:

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 6f0350fbdcd6..b7ea1e9f4904 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -1678,7 +1678,7 @@ static const struct hci_uart_proto qca_proto = {
.name = "QCA",
.manufacturer = 29,
.init_speed = 115200,
- .oper_speed = 3000000,
+ .oper_speed = 2000000,
.open = qca_open,
.close = qca_close,
.flush = qca_flush,

This results in an attempt to load firmware, see: http://ix.io/2i6Q and using renamed files from https://github.com/boundarydevices/qca-firmware/tree/bd-sdmac-ath10k/qca the module is now otherwise up/working - I can scan/see/pair other BT devices.

see: http://ix.io/2i6S and:

SML5442TW:~ # bluetoothctl show
Controller 91:08:00:00:00:00 (public)
Name: SML5442TW
Alias: SML5442TW
Class: 0x000c0000
Powered: yes
Discoverable: no
DiscoverableTimeout: 0x000000b4
Pairable: yes
UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0536
Discovering: no
Advertising Features:
ActiveInstances: 0x00
SupportedInstances: 0x05
SupportedIncludes: tx-power
SupportedIncludes: appearance
SupportedIncludes: local-name

So it looks like hci_qca.c needs modification to handle multiple operating speeds, perhaps using the max-speed description from device-tree if available, or defaulting to the current 3000000 value if not.

I’m not a coding developer so if someone can suggest a patch - I can test and confirm it works. Or if someone can explain how this should be implemented I will see if I can find someone to help with the task.

Christian


2020-04-20 16:13:32

by Abhishek Pandit-Subedi

[permalink] [raw]
Subject: Re: How to handle different operating speed for QCA9377 SDIO BT module?

Hi Christian,

Looks like the max-speed setting is inside an if block and that might
be why you're not able to set it
(https://github.com/torvalds/linux/blame/master/drivers/bluetooth/hci_qca.c#L1892).
I would suggest moving that outside the if block and trying again.

Abhishek

On Mon, Apr 20, 2020 at 1:51 AM Christian Hewitt
<[email protected]> wrote:
>
> Resend to expand the audience and include the linux-amlogic and ath10k lists.
>
> >>>>>
>
> I’m working with a QCA9337 SDIO device on an Android (now Linux) set-top box with an Amlogic S905D SoC.
>
> SDIO WiFi (ath10k) is working since 5.7-rc1, but the BT side of the module is still missing.
>
> Most Amlogic devices (95%+) use Broadcom SDIO modules with the following device tree content:
>
> &uart_A {
> bluetooth {
> compatible = "brcm,bcm43438-bt";
> shutdown-gpios = <&gpio GPIOX_17 GPIO_ACTIVE_HIGH>;
> max-speed = <2000000>;
> clocks = <&wifi32k>;
> clock-names = "lpo";
> };
> };
>
> I changed the compatible to "qcom,qca9377-bt” and applied the following patch:
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 439392b1c043..6f0350fbdcd6 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -2046,6 +2046,7 @@ static SIMPLE_DEV_PM_OPS(qca_pm_ops, qca_suspend, qca_resume);
>
> static const struct of_device_id qca_bluetooth_of_match[] = {
> { .compatible = "qcom,qca6174-bt" },
> + { .compatible = "qcom,qca9377-bt" },
> { .compatible = "qcom,wcn3990-bt", .data = &qca_soc_data_wcn3990},
> { .compatible = "qcom,wcn3991-bt", .data = &qca_soc_data_wcn3991},
> { .compatible = "qcom,wcn3998-bt", .data = &qca_soc_data_wcn3998},
>
> This results in probing with errors: http://ix.io/2i6P
>
> I noticed "max-speed = <2000000>;” while hci_qca.c sets 3000000. I attempted to set "max-speed = <3000000>;” but this made no difference, so I patched a lower value in hci_qca:
>
> diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
> index 6f0350fbdcd6..b7ea1e9f4904 100644
> --- a/drivers/bluetooth/hci_qca.c
> +++ b/drivers/bluetooth/hci_qca.c
> @@ -1678,7 +1678,7 @@ static const struct hci_uart_proto qca_proto = {
> .name = "QCA",
> .manufacturer = 29,
> .init_speed = 115200,
> - .oper_speed = 3000000,
> + .oper_speed = 2000000,
> .open = qca_open,
> .close = qca_close,
> .flush = qca_flush,
>
> This results in an attempt to load firmware, see: http://ix.io/2i6Q and using renamed files from https://github.com/boundarydevices/qca-firmware/tree/bd-sdmac-ath10k/qca the module is now otherwise up/working - I can scan/see/pair other BT devices.
>
> see: http://ix.io/2i6S and:
>
> SML5442TW:~ # bluetoothctl show
> Controller 91:08:00:00:00:00 (public)
> Name: SML5442TW
> Alias: SML5442TW
> Class: 0x000c0000
> Powered: yes
> Discoverable: no
> DiscoverableTimeout: 0x000000b4
> Pairable: yes
> UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
> UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
> UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
> UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
> UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
> UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
> UUID: Audio Sink (0000110b-0000-1000-8000-00805f9b34fb)
> Modalias: usb:v1D6Bp0246d0536
> Discovering: no
> Advertising Features:
> ActiveInstances: 0x00
> SupportedInstances: 0x05
> SupportedIncludes: tx-power
> SupportedIncludes: appearance
> SupportedIncludes: local-name
>
> So it looks like hci_qca.c needs modification to handle multiple operating speeds, perhaps using the max-speed description from device-tree if available, or defaulting to the current 3000000 value if not.
>
> I’m not a coding developer so if someone can suggest a patch - I can test and confirm it works. Or if someone can explain how this should be implemented I will see if I can find someone to help with the task.
>
> Christian
>