mbox series

[0/8] Add support for rtl8723bs/rtl8723cs bluetooth

Message ID 20190118170232.16142-1-anarsoul@gmail.com
Headers show
Series Add support for rtl8723bs/rtl8723cs bluetooth | expand

Message

Vasily Khoruzhick Jan. 18, 2019, 5:02 p.m. UTC
rtl8723{bc}s is WiFi/Bluetooth module, WiFi part is connected over SDIO
while bluetooth is connected over UART.

This series adds support for rtl8723bs/rtl8723cs bluetooth.

Bluetooth module in rtl8723cs is buggy - it advertises some features that
it doesn't support and responds either with garbage or with errors on
corresponding commands. Unfortunately that confuses bluetooth stack,
so we need to introduce another quirk.

Patches for Pine64 and Sopine are provided as examples since WiFi/BT module
is optional on these boards.

Vasily Khoruzhick (8):
  Bluetooth: Add new quirk for broken local ext features max_page
  Bluetooth: hci_h5: Add support for reset GPIO
  dt-bindings: net: bluetooth: Add rtl8723bs-bluetooth
  Bluetooth: hci_h5: Add support for binding RTL8723BS with device tree
  Bluetooth: btrtl: add support for the RTL8723CS
  arm64: allwinner: a64: enable Bluetooth On Pinebook
  DO-NOT-MERGE: arm64: allwinner: a64: enable Bluetooth On Pine64
  DO-NOT-MERGE: arm64: allwinner: a64: enable Bluetooth On SoPine
    baseboard

 .../bindings/net/rtl8723bs-bluetooth.txt      |  35 +++++
 .../boot/dts/allwinner/sun50i-a64-pine64.dts  |  10 +-
 .../dts/allwinner/sun50i-a64-pinebook.dts     |  14 ++
 .../allwinner/sun50i-a64-sopine-baseboard.dts |  14 ++
 drivers/bluetooth/btrtl.c                     | 128 +++++++++++++++++-
 drivers/bluetooth/btrtl.h                     |  12 ++
 drivers/bluetooth/hci_h5.c                    |  33 +++++
 include/net/bluetooth/hci.h                   |   7 +
 net/bluetooth/hci_event.c                     |   4 +-
 9 files changed, 252 insertions(+), 5 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/rtl8723bs-bluetooth.txt

Comments

Chen-Yu Tsai Jan. 18, 2019, 5:13 p.m. UTC | #1
On Sat, Jan 19, 2019 at 1:02 AM Vasily Khoruzhick <anarsoul@gmail.com> wrote:
>
> Some boards (e.g. Pine64 and Pinebook) wire a GPIO to reset pin of
> RTL8723BS

Pine64 / Pinebook don't have the enable pin. One could say that the
enable pin and the reset pin you add here are actually the same thing.

ChenYu

> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
> ---
>  drivers/bluetooth/hci_h5.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
> index 069d1c8fde73..7ead8c3d8657 100644
> --- a/drivers/bluetooth/hci_h5.c
> +++ b/drivers/bluetooth/hci_h5.c
> @@ -107,6 +107,7 @@ struct h5 {
>         const struct h5_vnd *vnd;
>         const char *id;
>
> +       struct gpio_desc *reset_gpio;
>         struct gpio_desc *enable_gpio;
>         struct gpio_desc *device_wake_gpio;
>  };
> @@ -833,6 +834,10 @@ static int h5_serdev_probe(struct serdev_device *serdev)
>         if (IS_ERR(h5->device_wake_gpio))
>                 return PTR_ERR(h5->device_wake_gpio);
>
> +       h5->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
> +       if (IS_ERR(h5->reset_gpio))
> +               return PTR_ERR(h5->reset_gpio);
> +
>         return hci_uart_register_device(&h5->serdev_hu, &h5p);
>  }
>
> @@ -921,6 +926,9 @@ static void h5_btrtl_open(struct h5 *h5)
>
>         /* The controller needs up to 500ms to wakeup */
>         gpiod_set_value_cansleep(h5->enable_gpio, 1);
> +       /* Take it out of reset */
> +       gpiod_set_value_cansleep(h5->reset_gpio, 0);
> +       msleep(100);
>         gpiod_set_value_cansleep(h5->device_wake_gpio, 1);
>         msleep(500);
>  }
> @@ -928,6 +936,7 @@ static void h5_btrtl_open(struct h5 *h5)
>  static void h5_btrtl_close(struct h5 *h5)
>  {
>         gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
> +       gpiod_set_value_cansleep(h5->reset_gpio, 1);
>         gpiod_set_value_cansleep(h5->enable_gpio, 0);
>  }
>
> --
> 2.20.1
>