2023-01-26 16:55:39

by Chris Morgan

[permalink] [raw]
Subject: [PATCH RFC 0/2] Bluetooth: Add support for RTL8821CS

From: Chris Morgan <[email protected]>

This patch series is to add support for the RTL8821CS Bluetooth
controller found on the RTL8821CS WiFi/Bluetooth combo chip.

This has been tested with firmware version 0xaa9a4e68. I am submitting
as an RFC to hopefully get guidance from Realtek on submission of this
firmware (or a later version) to the linux-firmware repository.

Chris Morgan (2):
dt-bindings: net: realtek-bluetooth: Add RTL8821CS
Bluetooth: hci_h5: btrtl: Add support for RTL8821CS

.../devicetree/bindings/net/realtek-bluetooth.yaml | 1 +
drivers/bluetooth/btrtl.c | 8 ++++++++
drivers/bluetooth/hci_h5.c | 2 ++
3 files changed, 11 insertions(+)

--
2.34.1



2023-01-26 16:55:41

by Chris Morgan

[permalink] [raw]
Subject: [PATCH RFC 1/2] dt-bindings: net: realtek-bluetooth: Add RTL8821CS

From: Chris Morgan <[email protected]>

Add compatible string for RTL8821CS for existing Realtek Bluetooth
driver.

Signed-off-by: Chris Morgan <[email protected]>
---
Documentation/devicetree/bindings/net/realtek-bluetooth.yaml | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/net/realtek-bluetooth.yaml b/Documentation/devicetree/bindings/net/realtek-bluetooth.yaml
index 143b5667abad..5af4731338c0 100644
--- a/Documentation/devicetree/bindings/net/realtek-bluetooth.yaml
+++ b/Documentation/devicetree/bindings/net/realtek-bluetooth.yaml
@@ -21,6 +21,7 @@ properties:
- realtek,rtl8723bs-bt
- realtek,rtl8723cs-bt
- realtek,rtl8723ds-bt
+ - realtek,rtl8821cs-bt
- realtek,rtl8822cs-bt

device-wake-gpios:
--
2.34.1


2023-01-26 16:55:41

by Chris Morgan

[permalink] [raw]
Subject: [PATCH RFC 2/2] Bluetooth: hci_h5: btrtl: Add support for RTL8821CS

From: Chris Morgan <[email protected]>

RTL8821CS is a WiFi + Bluetooth combo chip from Realtek that provides
WiFi A/B/G/N/AC over an SDIO interface and Bluetooth 4.2 over a UART
interface.

Note that the firmware this was tested with was firmware version
0xaa9a4e68 as reported by the driver. Attempts at using other
firmware were unsucessful.

Signed-off-by: Chris Morgan <[email protected]>
---
drivers/bluetooth/btrtl.c | 8 ++++++++
drivers/bluetooth/hci_h5.c | 2 ++
2 files changed, 10 insertions(+)

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index 69c3fe649ca7..c95e55d8d696 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -128,6 +128,14 @@ static const struct id_table ic_id_table[] = {
.fw_name = "rtl_bt/rtl8821c_fw.bin",
.cfg_name = "rtl_bt/rtl8821c_config" },

+ /* 8821CS */
+ { IC_INFO(RTL_ROM_LMP_8821A, 0xc, 0x8, HCI_UART),
+ .config_needed = true,
+ .has_rom_version = true,
+ .has_msft_ext = true,
+ .fw_name = "rtl_bt/rtl8821cs_fw.bin",
+ .cfg_name = "rtl_bt/rtl8821cs_config" },
+
/* 8761A */
{ IC_INFO(RTL_ROM_LMP_8761A, 0xa, 0x6, HCI_USB),
.config_needed = false,
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index 6455bc4fb5bb..9531f092a71a 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -1096,6 +1096,8 @@ static const struct dev_pm_ops h5_serdev_pm_ops = {

static const struct of_device_id rtl_bluetooth_of_match[] = {
#ifdef CONFIG_BT_HCIUART_RTL
+ { .compatible = "realtek,rtl8821cs-bt",
+ .data = (const void *)&h5_data_rtl8822cs },
{ .compatible = "realtek,rtl8822cs-bt",
.data = (const void *)&h5_data_rtl8822cs },
{ .compatible = "realtek,rtl8723bs-bt",
--
2.34.1


2023-01-26 17:36:05

by bluez.test.bot

[permalink] [raw]
Subject: RE: Bluetooth: Add support for RTL8821CS

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=715934

---Test result---

Test Summary:
CheckPatch PASS 2.17 seconds
GitLint PASS 0.75 seconds
SubjectPrefix FAIL 0.58 seconds
BuildKernel PASS 38.49 seconds
CheckAllWarning PASS 41.50 seconds
CheckSparse WARNING 47.05 seconds
CheckSmatch WARNING 127.35 seconds
BuildKernel32 PASS 36.70 seconds
TestRunnerSetup PASS 526.86 seconds
TestRunner_l2cap-tester PASS 19.05 seconds
TestRunner_iso-tester PASS 20.75 seconds
TestRunner_bnep-tester PASS 6.80 seconds
TestRunner_mgmt-tester PASS 129.94 seconds
TestRunner_rfcomm-tester PASS 10.75 seconds
TestRunner_sco-tester PASS 9.87 seconds
TestRunner_ioctl-tester PASS 11.82 seconds
TestRunner_mesh-tester PASS 8.72 seconds
TestRunner_smp-tester PASS 9.75 seconds
TestRunner_userchan-tester PASS 7.21 seconds
IncrementalBuild PASS 40.32 seconds

Details
##############################
Test: SubjectPrefix - FAIL
Desc: Check subject contains "Bluetooth" prefix
Output:
"Bluetooth: " prefix is not specified in the subject
##############################
Test: CheckSparse - WARNING
Desc: Run sparse tool with linux kernel
Output:
drivers/bluetooth/btrtl.c: note: in included file:drivers/bluetooth/btrtl.h:47:45: warning: array of flexible structures
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
drivers/bluetooth/btrtl.c: note: in included file:drivers/bluetooth/btrtl.h:47:45: warning: array of flexible structures


---
Regards,
Linux Bluetooth

2023-01-27 10:24:09

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH RFC 1/2] dt-bindings: net: realtek-bluetooth: Add RTL8821CS

On 26/01/2023 17:55, Chris Morgan wrote:
> From: Chris Morgan <[email protected]>
>
> Add compatible string for RTL8821CS for existing Realtek Bluetooth
> driver.
>
> Signed-off-by: Chris Morgan <[email protected]>
> ---
> Documentation/devicetree/bindings/net/realtek-bluetooth.yaml | 1 +
> 1 file changed, 1 insertion(+)
>

Based on your driver it is compatible with rtl8822cs, so you can
indicate it in the binding and use just one of_device_id entry.

Best regards,
Krzysztof


2023-01-27 16:47:28

by Chris Morgan

[permalink] [raw]
Subject: Re: [PATCH RFC 1/2] dt-bindings: net: realtek-bluetooth: Add RTL8821CS

On Fri, Jan 27, 2023 at 11:24:03AM +0100, Krzysztof Kozlowski wrote:
> On 26/01/2023 17:55, Chris Morgan wrote:
> > From: Chris Morgan <[email protected]>
> >
> > Add compatible string for RTL8821CS for existing Realtek Bluetooth
> > driver.
> >
> > Signed-off-by: Chris Morgan <[email protected]>
> > ---
> > Documentation/devicetree/bindings/net/realtek-bluetooth.yaml | 1 +
> > 1 file changed, 1 insertion(+)
> >
>
> Based on your driver it is compatible with rtl8822cs, so you can
> indicate it in the binding and use just one of_device_id entry.

It's very similar, and uses some of the same constants, but has a
different firmware. I assumed the firmware difference is enough to
require it to be differentiated, but I wasn't sure. You are saying
it does not? I just want to be clear.

As always, thank you.

>
> Best regards,
> Krzysztof
>

2023-01-27 16:54:19

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH RFC 1/2] dt-bindings: net: realtek-bluetooth: Add RTL8821CS

On 27/01/2023 17:46, Chris Morgan wrote:
> On Fri, Jan 27, 2023 at 11:24:03AM +0100, Krzysztof Kozlowski wrote:
>> On 26/01/2023 17:55, Chris Morgan wrote:
>>> From: Chris Morgan <[email protected]>
>>>
>>> Add compatible string for RTL8821CS for existing Realtek Bluetooth
>>> driver.
>>>
>>> Signed-off-by: Chris Morgan <[email protected]>
>>> ---
>>> Documentation/devicetree/bindings/net/realtek-bluetooth.yaml | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>
>> Based on your driver it is compatible with rtl8822cs, so you can
>> indicate it in the binding and use just one of_device_id entry.
>
> It's very similar, and uses some of the same constants, but has a
> different firmware. I assumed the firmware difference is enough to
> require it to be differentiated, but I wasn't sure. You are saying
> it does not? I just want to be clear.

If by "differentiated" you mean "incompatible", then depends:
1. You have firmware-name property to indicate the firmware to load and
then you can use one compatible to bind and just load different firmware,
2. If device variant is autodectable, it's compatible.

realtek,rtl8723ds-bt also was added to the driver uselessly...

Best regards,
Krzysztof


2023-01-27 17:00:16

by Chris Morgan

[permalink] [raw]
Subject: Re: [PATCH RFC 1/2] dt-bindings: net: realtek-bluetooth: Add RTL8821CS

On Fri, Jan 27, 2023 at 05:53:49PM +0100, Krzysztof Kozlowski wrote:
> On 27/01/2023 17:46, Chris Morgan wrote:
> > On Fri, Jan 27, 2023 at 11:24:03AM +0100, Krzysztof Kozlowski wrote:
> >> On 26/01/2023 17:55, Chris Morgan wrote:
> >>> From: Chris Morgan <[email protected]>
> >>>
> >>> Add compatible string for RTL8821CS for existing Realtek Bluetooth
> >>> driver.
> >>>
> >>> Signed-off-by: Chris Morgan <[email protected]>
> >>> ---
> >>> Documentation/devicetree/bindings/net/realtek-bluetooth.yaml | 1 +
> >>> 1 file changed, 1 insertion(+)
> >>>
> >>
> >> Based on your driver it is compatible with rtl8822cs, so you can
> >> indicate it in the binding and use just one of_device_id entry.
> >
> > It's very similar, and uses some of the same constants, but has a
> > different firmware. I assumed the firmware difference is enough to
> > require it to be differentiated, but I wasn't sure. You are saying
> > it does not? I just want to be clear.
>
> If by "differentiated" you mean "incompatible", then depends:
> 1. You have firmware-name property to indicate the firmware to load and
> then you can use one compatible to bind and just load different firmware,
> 2. If device variant is autodectable, it's compatible.
>
> realtek,rtl8723ds-bt also was added to the driver uselessly...

Gotcha.

They are incompatible, but the driver should be able to autodetect each
device as best I can tell. In fact all of the devices listed in the
bindings should be autodetectable by the driver (again, as best I can
tell). Honestly though that's assuming I'm using the correct firmware,
which is why I have this tagged as an RFC. I'm really hoping to get
Realtek's attention for them to chime in to confirm I'm using the
most recent firmware and under what license/terms the firmware can
be redistributed so that the firmware may be added to linux-firmware.

Assuming everything is good though, I can resubmit V2 and instead of
adding a new compatible just noting that the 8822CS and 8821CS use
the same bindings.

Thank you.

>
> Best regards,
> Krzysztof
>

2023-01-27 17:02:19

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH RFC 1/2] dt-bindings: net: realtek-bluetooth: Add RTL8821CS

On 27/01/2023 18:00, Chris Morgan wrote:
> On Fri, Jan 27, 2023 at 05:53:49PM +0100, Krzysztof Kozlowski wrote:
>> On 27/01/2023 17:46, Chris Morgan wrote:
>>> On Fri, Jan 27, 2023 at 11:24:03AM +0100, Krzysztof Kozlowski wrote:
>>>> On 26/01/2023 17:55, Chris Morgan wrote:
>>>>> From: Chris Morgan <[email protected]>
>>>>>
>>>>> Add compatible string for RTL8821CS for existing Realtek Bluetooth
>>>>> driver.
>>>>>
>>>>> Signed-off-by: Chris Morgan <[email protected]>
>>>>> ---
>>>>> Documentation/devicetree/bindings/net/realtek-bluetooth.yaml | 1 +
>>>>> 1 file changed, 1 insertion(+)
>>>>>
>>>>
>>>> Based on your driver it is compatible with rtl8822cs, so you can
>>>> indicate it in the binding and use just one of_device_id entry.
>>>
>>> It's very similar, and uses some of the same constants, but has a
>>> different firmware. I assumed the firmware difference is enough to
>>> require it to be differentiated, but I wasn't sure. You are saying
>>> it does not? I just want to be clear.
>>
>> If by "differentiated" you mean "incompatible", then depends:
>> 1. You have firmware-name property to indicate the firmware to load and
>> then you can use one compatible to bind and just load different firmware,
>> 2. If device variant is autodectable, it's compatible.
>>
>> realtek,rtl8723ds-bt also was added to the driver uselessly...
>
> Gotcha.
>
> They are incompatible, but the driver should be able to autodetect each
> device as best I can tell. In fact all of the devices listed in the
> bindings should be autodetectable by the driver (again, as best I can
> tell). Honestly though that's assuming I'm using the correct firmware,
> which is why I have this tagged as an RFC. I'm really hoping to get
> Realtek's attention for them to chime in to confirm I'm using the
> most recent firmware and under what license/terms the firmware can
> be redistributed so that the firmware may be added to linux-firmware.
>
> Assuming everything is good though, I can resubmit V2 and instead of
> adding a new compatible just noting that the 8822CS and 8821CS use
> the same bindings.

They cannot use the same bindings. You always need specific compatible
and this was not discussed here. What's discussed is to drop the driver
change in of_device_id.

Best regards,
Krzysztof