Linux-Bluetooth Archive on lore.kernel.org
 help / color / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: Max Chou <max.chou@realtek.com>
Cc: Johan Hedberg <johan.hedberg@gmail.com>,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	alex_lu@realsil.com.cn, hildawu@realtek.com, kidman@realtek.com
Subject: Re: [PATCH] Bluetooth: hci_h5: btrtl: Add support for RTL8822C
Date: Fri, 14 Feb 2020 08:39:56 +0100
Message-ID: <FDDB4E96-85DE-405C-907C-5B15F3218C05@holtmann.org> (raw)
In-Reply-To: <20200213075140.25105-1-max.chou@realtek.com>

Hi Max,

> Add new compatible and FW loading support for RTL8822C.
> 
> Signed-off-by: Max Chou <max.chou@realtek.com>
> ---
> drivers/bluetooth/Kconfig  |  2 +-
> drivers/bluetooth/btrtl.c  | 12 ++++++++++++
> drivers/bluetooth/hci_h5.c | 18 +++++++++++++++++-
> 3 files changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
> index f7aa2dc1ff85..052020b07e56 100644
> --- a/drivers/bluetooth/Kconfig
> +++ b/drivers/bluetooth/Kconfig
> @@ -211,7 +211,7 @@ config BT_HCIUART_RTL
> 	depends on BT_HCIUART
> 	depends on BT_HCIUART_SERDEV
> 	depends on GPIOLIB
> -	depends on ACPI
> +	depends on (ACPI || SERIAL_DEV_CTRL_TTYPORT)
> 	select BT_HCIUART_3WIRE
> 	select BT_RTL
> 	help
> diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
> index 577cfa3329db..67f4bc21e7c5 100644
> --- a/drivers/bluetooth/btrtl.c
> +++ b/drivers/bluetooth/btrtl.c
> @@ -136,6 +136,18 @@ static const struct id_table ic_id_table[] = {
> 	  .fw_name  = "rtl_bt/rtl8761a_fw.bin",
> 	  .cfg_name = "rtl_bt/rtl8761a_config" },
> 
> +	/* 8822C with UART interface */
> +	{ .match_flags = IC_MATCH_FL_LMPSUBV | IC_MATCH_FL_HCIREV |
> +			 IC_MATCH_FL_HCIBUS,
> +	  .lmp_subver = RTL_ROM_LMP_8822B,
> +	  .hci_rev = 0x000c,
> +	  .hci_ver = 0x0a,
> +	  .hci_bus = HCI_UART,
> +	  .config_needed = true,
> +	  .has_rom_version = true,
> +	  .fw_name  = "rtl_bt/rtl8822cs_fw.bin",
> +	  .cfg_name = "rtl_bt/rtl8822cs_config" },
> +
> 	/* 8822C with USB interface */
> 	{ IC_INFO(RTL_ROM_LMP_8822B, 0xc),
> 	  .config_needed = false,
> diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
> index 0b14547482a7..666b0c009004 100644
> --- a/drivers/bluetooth/hci_h5.c
> +++ b/drivers/bluetooth/hci_h5.c
> @@ -11,6 +11,7 @@
> #include <linux/gpio/consumer.h>
> #include <linux/kernel.h>
> #include <linux/mod_devicetable.h>
> +#include <linux/of_device.h>
> #include <linux/serdev.h>
> #include <linux/skbuff.h>
> 
> @@ -786,6 +787,7 @@ static const struct hci_uart_proto h5p = {
> static int h5_serdev_probe(struct serdev_device *serdev)
> {
> 	const struct acpi_device_id *match;
> +	const void *data;
> 	struct device *dev = &serdev->dev;
> 	struct h5 *h5;
> 
> @@ -799,7 +801,11 @@ static int h5_serdev_probe(struct serdev_device *serdev)
> 	h5->serdev_hu.serdev = serdev;
> 	serdev_device_set_drvdata(serdev, h5);
> 
> -	if (has_acpi_companion(dev)) {
> +	data = of_device_get_match_data(dev);
> +	if (data)
> +		h5->vnd = (const struct h5_vnd *)data;
> +
> +	if (!data && has_acpi_companion(dev)) {
> 		match = acpi_match_device(dev->driver->acpi_match_table, dev);
> 		if (!match)
> 			return -ENODEV;

why is this change done this way?

	if (has_acpi_companion(dev)) {
		/* do the ACPI stuff */
	} else {
		/* do the OF stuff */
	}

> @@ -1003,6 +1009,15 @@ static const struct dev_pm_ops h5_serdev_pm_ops = {
> 	SET_SYSTEM_SLEEP_PM_OPS(h5_serdev_suspend, h5_serdev_resume)
> };
> 
> +static const struct of_device_id rtl_bluetooth_of_match[] = {
> +#ifdef CONFIG_BT_HCIUART_RTL
> +	{ .compatible = "realtek,rtl8822cs-bt",
> +	  .data = (const void *)&rtl_vnd },
> +#endif
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(of, rtl_bluetooth_of_match);
> +
> static struct serdev_device_driver h5_serdev_driver = {
> 	.probe = h5_serdev_probe,
> 	.remove = h5_serdev_remove,
> @@ -1010,6 +1025,7 @@ static struct serdev_device_driver h5_serdev_driver = {
> 		.name = "hci_uart_h5",
> 		.acpi_match_table = ACPI_PTR(h5_acpi_match),
> 		.pm = &h5_serdev_pm_ops,
> +		.of_match_table = rtl_bluetooth_of_match,
> 	},
> };

And I did post an initial bt3wire.c driver that would be a lot better and cleaner than trying to add everything to hci_h5.c.

Regards

Marcel


      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-13  7:51 max.chou
2020-02-14  7:39 ` Marcel Holtmann [this message]

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FDDB4E96-85DE-405C-907C-5B15F3218C05@holtmann.org \
    --to=marcel@holtmann.org \
    --cc=alex_lu@realsil.com.cn \
    --cc=hildawu@realtek.com \
    --cc=johan.hedberg@gmail.com \
    --cc=kidman@realtek.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=max.chou@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org
	public-inbox-index linux-bluetooth

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git