mbox series

[0/3,V4] Bluetooth: Add support for RTL8821CS

Message ID 20230228152205.133582-1-macroalpha82@gmail.com
Headers show
Series Bluetooth: Add support for RTL8821CS | expand

Message

Chris Morgan Feb. 28, 2023, 3:22 p.m. UTC
From: Chris Morgan <macromorgan@hotmail.com>

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 0x75b8f098 which has been
submitted by Realtek for inclusion in linux-firmware.

https://lore.kernel.org/linux-firmware/20230223062453.181239-1-max.chou@realtek.com/

Changes from V3:
 - Corrected bindings so that all but the 8821 use enum, and 8821 uses
   items.

Changes from V2:
 - Corrected devicetree documentation to change compatible from const
   back to enum.
 - Removed "reviewed-by" from Alistair Francis as binding documentation
   updated with changes.

Changes from V1:
 - Switched to use a fallback string for the rtl8822cs so as to not add
   an extra entry to the of_device_id table. The driver is capable of
   selecting the correct firmware blob to load.
 - Updated the messages to note a new version of the firmware was
   tested and that Realtek has submitted this firmware upstream.
 - Updated the devicetree node on the Anbernic RGxx3 series to use the
   fallback string of realtek,rtl8822cs-bt.

Chris Morgan (3):
  dt-bindings: net: realtek-bluetooth: Add RTL8821CS
  Bluetooth: hci_h5: btrtl: Add support for RTL8821CS
  arm64: dts: rockchip: Update compatible for bluetooth

 .../bindings/net/realtek-bluetooth.yaml       | 24 ++++++++++++-------
 .../dts/rockchip/rk3566-anbernic-rgxx3.dtsi   |  2 +-
 drivers/bluetooth/btrtl.c                     |  8 +++++++
 3 files changed, 24 insertions(+), 10 deletions(-)

Comments

Chris Morgan March 13, 2023, 6:12 p.m. UTC | #1
I found the fix, simply put changing the compatible from
realtek,rtl8822cs-bt to realtek,rtl8732bs-bt fixes it (because it sets
the "H5_INFO_WAKEUP_DISABLE" flag). Is it too late for a V5, or should
I submit this as a fix to the devicetree and devicetree documentation?

Thank you.

On Fri, Mar 10, 2023 at 10:25 AM Chris Morgan <macroalpha82@gmail.com> wrote:
>
> I shudder to bring this up now, but I'm encountering a new bug and
> might have to withdraw this.
>
> I'm receiving errors in dmesg of the following, and I can't seem to
> figure out the root cause:
> Bluetooth: hci0: Out-of-order packet arrived
>
> Any thoughts on what might cause it?
> Thank you.
>
> On Tue, Feb 28, 2023 at 9:22 AM Chris Morgan <macroalpha82@gmail.com> wrote:
> >
> > From: Chris Morgan <macromorgan@hotmail.com>
> >
> > 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
> > 0x75b8f098.
> >
> > Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
> > ---
> >  drivers/bluetooth/btrtl.c | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
> > index 69c3fe649ca7..72947d319fa6 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,
> > --
> > 2.34.1
> >
Vasily Khoruzhick March 13, 2023, 6:36 p.m. UTC | #2
On Mon, Mar 13, 2023 at 11:12 AM Chris Morgan <macroalpha82@gmail.com> wrote:
>
> I found the fix, simply put changing the compatible from
> realtek,rtl8822cs-bt to realtek,rtl8732bs-bt fixes it (because it sets
> the "H5_INFO_WAKEUP_DISABLE" flag). Is it too late for a V5, or should
> I submit this as a fix to the devicetree and devicetree documentation?

But is it actually compatible with rtl8723bs-bt though? I think you
may need to add an entry for 8821cs to rtl_bluetooth_of_match in
hci_h5.c

> Thank you.
>
> On Fri, Mar 10, 2023 at 10:25 AM Chris Morgan <macroalpha82@gmail.com> wrote:
> >
> > I shudder to bring this up now, but I'm encountering a new bug and
> > might have to withdraw this.
> >
> > I'm receiving errors in dmesg of the following, and I can't seem to
> > figure out the root cause:
> > Bluetooth: hci0: Out-of-order packet arrived
> >
> > Any thoughts on what might cause it?
> > Thank you.
> >
> > On Tue, Feb 28, 2023 at 9:22 AM Chris Morgan <macroalpha82@gmail.com> wrote:
> > >
> > > From: Chris Morgan <macromorgan@hotmail.com>
> > >
> > > 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
> > > 0x75b8f098.
> > >
> > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
> > > ---
> > >  drivers/bluetooth/btrtl.c | 8 ++++++++
> > >  1 file changed, 8 insertions(+)
> > >
> > > diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
> > > index 69c3fe649ca7..72947d319fa6 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,
> > > --
> > > 2.34.1
> > >
Chris Morgan March 13, 2023, 7:14 p.m. UTC | #3
On Mon, Mar 13, 2023 at 11:36:21AM -0700, Vasily Khoruzhick wrote:
> On Mon, Mar 13, 2023 at 11:12 AM Chris Morgan <macroalpha82@gmail.com> wrote:
> >
> > I found the fix, simply put changing the compatible from
> > realtek,rtl8822cs-bt to realtek,rtl8732bs-bt fixes it (because it sets
> > the "H5_INFO_WAKEUP_DISABLE" flag). Is it too late for a V5, or should
> > I submit this as a fix to the devicetree and devicetree documentation?
> 
> But is it actually compatible with rtl8723bs-bt though? I think you
> may need to add an entry for 8821cs to rtl_bluetooth_of_match in
> hci_h5.c

The compatible string would be an exact copy of what is present for
rtl8723bs-bt. Previously I was advised by the devicetree team to just
use a fallback string rather than add a duplicate entry to the driver,
so that's what I did. The driver itself can detect the difference
between the 8821cs and 8723bs and load the appropriate firmware.

Technically the rtl8822cs-bt also works as long as you only want to
"test" the driver and not use it. It's the power management stuff
that causes it to fail roughly 9 out of every 10 times you try to
use it for more than simple pairing (I tested 3 different controllers
with the new compatible string for a total of 7 tests and it works
consistently now).

If you're okay with the compatible string change, I'll update it and
resubmit this as a V5. It shouldn't require a change to the driver,
only the binding.

Thank you.

> 
> > Thank you.
> >
> > On Fri, Mar 10, 2023 at 10:25 AM Chris Morgan <macroalpha82@gmail.com> wrote:
> > >
> > > I shudder to bring this up now, but I'm encountering a new bug and
> > > might have to withdraw this.
> > >
> > > I'm receiving errors in dmesg of the following, and I can't seem to
> > > figure out the root cause:
> > > Bluetooth: hci0: Out-of-order packet arrived
> > >
> > > Any thoughts on what might cause it?
> > > Thank you.
> > >
> > > On Tue, Feb 28, 2023 at 9:22 AM Chris Morgan <macroalpha82@gmail.com> wrote:
> > > >
> > > > From: Chris Morgan <macromorgan@hotmail.com>
> > > >
> > > > 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
> > > > 0x75b8f098.
> > > >
> > > > Signed-off-by: Chris Morgan <macromorgan@hotmail.com>
> > > > ---
> > > >  drivers/bluetooth/btrtl.c | 8 ++++++++
> > > >  1 file changed, 8 insertions(+)
> > > >
> > > > diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
> > > > index 69c3fe649ca7..72947d319fa6 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,
> > > > --
> > > > 2.34.1
> > > >