All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] Bluetooth: hci_h5: btrtl: Add quirk for keep power in suspend/resume
@ 2021-03-16 10:06 hildawu
  2021-03-16 11:27 ` [v2] " bluez.test.bot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: hildawu @ 2021-03-16 10:06 UTC (permalink / raw)
  To: marcel
  Cc: johan.hedberg, luiz.dentz, davem, kuba, linux-bluetooth,
	linux-kernel, netdev, tientzu, max.chou, alex_lu, kidman

From: hildawu <hildawu@realtek.com>

RTL8822C devices support BT wakeup Host. Add a quirk for these specific
devices did not power off during suspend and resume.
By this change, if the Host support that received BT device signal then
it can be wakeup.

Signed-off-by: hildawu <hildawu@realtek.com>
---
Changes in v2:
- Add missing struct member
- Modify title for fit length
---
---
 drivers/bluetooth/btrtl.c   | 36 ------------------------------------
 drivers/bluetooth/btrtl.h   | 36 ++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/hci_h5.c  | 35 ++++++++++++++++++++++++-----------
 include/net/bluetooth/hci.h |  9 +++++++++
 4 files changed, 69 insertions(+), 47 deletions(-)

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index e7fe5fb22753..94d1e7885aee 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -38,42 +38,6 @@
 	.hci_ver = (hciv), \
 	.hci_bus = (bus)
 
-enum btrtl_chip_id {
-	CHIP_ID_8723A,
-	CHIP_ID_8723B,
-	CHIP_ID_8821A,
-	CHIP_ID_8761A,
-	CHIP_ID_8822B = 8,
-	CHIP_ID_8723D,
-	CHIP_ID_8821C,
-	CHIP_ID_8822C = 13,
-	CHIP_ID_8761B,
-	CHIP_ID_8852A = 18,
-};
-
-struct id_table {
-	__u16 match_flags;
-	__u16 lmp_subver;
-	__u16 hci_rev;
-	__u8 hci_ver;
-	__u8 hci_bus;
-	bool config_needed;
-	bool has_rom_version;
-	char *fw_name;
-	char *cfg_name;
-};
-
-struct btrtl_device_info {
-	const struct id_table *ic_info;
-	u8 rom_version;
-	u8 *fw_data;
-	int fw_len;
-	u8 *cfg_data;
-	int cfg_len;
-	bool drop_fw;
-	int project_id;
-};
-
 static const struct id_table ic_id_table[] = {
 	/* 8723A */
 	{ IC_INFO(RTL_ROM_LMP_8723A, 0xb, 0x6, HCI_USB),
diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h
index 2a582682136d..713768b38e21 100644
--- a/drivers/bluetooth/btrtl.h
+++ b/drivers/bluetooth/btrtl.h
@@ -12,6 +12,42 @@
 #define rtl_dev_info(dev, fmt, ...) bt_dev_info(dev, "RTL: " fmt, ##__VA_ARGS__)
 #define rtl_dev_dbg(dev, fmt, ...) bt_dev_dbg(dev, "RTL: " fmt, ##__VA_ARGS__)
 
+enum btrtl_chip_id {
+	CHIP_ID_8723A,
+	CHIP_ID_8723B,
+	CHIP_ID_8821A,
+	CHIP_ID_8761A,
+	CHIP_ID_8822B = 8,
+	CHIP_ID_8723D,
+	CHIP_ID_8821C,
+	CHIP_ID_8822C = 13,
+	CHIP_ID_8761B,
+	CHIP_ID_8852A = 18,
+};
+
+struct id_table {
+	__u16 match_flags;
+	__u16 lmp_subver;
+	__u16 hci_rev;
+	__u8 hci_ver;
+	__u8 hci_bus;
+	bool config_needed;
+	bool has_rom_version;
+	char *fw_name;
+	char *cfg_name;
+};
+
+struct btrtl_device_info {
+	const struct id_table *ic_info;
+	u8 rom_version;
+	u8 *fw_data;
+	int fw_len;
+	u8 *cfg_data;
+	int cfg_len;
+	bool drop_fw;
+	int project_id;
+};
+
 struct btrtl_device_info;
 
 struct rtl_download_cmd {
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index 27e96681d583..1ca4ff89ea14 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -909,7 +909,15 @@ static int h5_btrtl_setup(struct h5 *h5)
 	/* Enable controller to do both LE scan and BR/EDR inquiry
 	 * simultaneously.
 	 */
-	set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
+	switch (btrtl_dev->project_id) {
+	case CHIP_ID_8822C:
+	case CHIP_ID_8852A:
+		set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
+		set_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks);
+		break;
+	default:
+		break;
+	}
 
 out_free:
 	btrtl_free(btrtl_dev);
@@ -945,8 +953,11 @@ static void h5_btrtl_close(struct h5 *h5)
 static int h5_btrtl_suspend(struct h5 *h5)
 {
 	serdev_device_set_flow_control(h5->hu->serdev, false);
-	gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
-	gpiod_set_value_cansleep(h5->enable_gpio, 0);
+
+	if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
+		gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
+		gpiod_set_value_cansleep(h5->enable_gpio, 0);
+	}
 	return 0;
 }
 
@@ -972,17 +983,19 @@ static void h5_btrtl_reprobe_worker(struct work_struct *work)
 
 static int h5_btrtl_resume(struct h5 *h5)
 {
-	struct h5_btrtl_reprobe *reprobe;
+	if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
+		struct h5_btrtl_reprobe *reprobe;
 
-	reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
-	if (!reprobe)
-		return -ENOMEM;
+		reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
+		if (!reprobe)
+			return -ENOMEM;
 
-	__module_get(THIS_MODULE);
+		__module_get(THIS_MODULE);
 
-	INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
-	reprobe->dev = get_device(&h5->hu->serdev->dev);
-	queue_work(system_long_wq, &reprobe->work);
+		INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
+		reprobe->dev = get_device(&h5->hu->serdev->dev);
+		queue_work(system_long_wq, &reprobe->work);
+	}
 	return 0;
 }
 
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index ea4ae551c426..1e4c2a97ab8d 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -246,6 +246,15 @@ enum {
 	 * HCI after resume.
 	 */
 	HCI_QUIRK_NO_SUSPEND_NOTIFIER,
+
+	/* When this quirk is set, the controller does not power off
+	 * during suspend and resume. This mechanism lets BT devices wake
+	 * the Host up if the Host and chips support.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED,
 };
 
 /* HCI device flags */
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [v2] Bluetooth: hci_h5: btrtl: Add quirk for keep power in suspend/resume
  2021-03-16 10:06 [PATCH v2] Bluetooth: hci_h5: btrtl: Add quirk for keep power in suspend/resume hildawu
@ 2021-03-16 11:27 ` bluez.test.bot
  2021-03-30  6:22 ` [PATCH v2] " Hilda Wu
  2021-04-09 14:22 ` Marcel Holtmann
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2021-03-16 11:27 UTC (permalink / raw)
  To: linux-bluetooth, hildawu

[-- Attachment #1: Type: text/plain, Size: 1599 bytes --]

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=448931

---Test result---

##############################
    Test: CheckPatch - PASS
    

    ##############################
    Test: CheckGitLint - PASS
    

    ##############################
    Test: CheckBuildK - PASS
    

    ##############################
    Test: CheckTestRunner: Setup - PASS
    

    ##############################
    Test: CheckTestRunner: l2cap-tester - PASS
    Total: 40, Passed: 34 (85.0%), Failed: 0, Not Run: 6

    ##############################
    Test: CheckTestRunner: bnep-tester - PASS
    Total: 1, Passed: 1 (100.0%), Failed: 0, Not Run: 0

    ##############################
    Test: CheckTestRunner: mgmt-tester - FAIL
    Total: 416, Passed: 399 (95.9%), Failed: 3, Not Run: 14

    ##############################
    Test: CheckTestRunner: rfcomm-tester - PASS
    Total: 9, Passed: 9 (100.0%), Failed: 0, Not Run: 0

    ##############################
    Test: CheckTestRunner: sco-tester - PASS
    Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

    ##############################
    Test: CheckTestRunner: smp-tester - PASS
    Total: 8, Passed: 8 (100.0%), Failed: 0, Not Run: 0

    ##############################
    Test: CheckTestRunner: userchan-tester - PASS
    Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0

    

---
Regards,
Linux Bluetooth


[-- Attachment #2: l2cap-tester.log --]
[-- Type: application/octet-stream, Size: 43342 bytes --]

[-- Attachment #3: bnep-tester.log --]
[-- Type: application/octet-stream, Size: 3532 bytes --]

[-- Attachment #4: mgmt-tester.log --]
[-- Type: application/octet-stream, Size: 547124 bytes --]

[-- Attachment #5: rfcomm-tester.log --]
[-- Type: application/octet-stream, Size: 11653 bytes --]

[-- Attachment #6: sco-tester.log --]
[-- Type: application/octet-stream, Size: 9888 bytes --]

[-- Attachment #7: smp-tester.log --]
[-- Type: application/octet-stream, Size: 11799 bytes --]

[-- Attachment #8: userchan-tester.log --]
[-- Type: application/octet-stream, Size: 5430 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] Bluetooth: hci_h5: btrtl: Add quirk for keep power in suspend/resume
  2021-03-16 10:06 [PATCH v2] Bluetooth: hci_h5: btrtl: Add quirk for keep power in suspend/resume hildawu
  2021-03-16 11:27 ` [v2] " bluez.test.bot
@ 2021-03-30  6:22 ` Hilda Wu
  2021-04-09 14:22 ` Marcel Holtmann
  2 siblings, 0 replies; 4+ messages in thread
From: Hilda Wu @ 2021-03-30  6:22 UTC (permalink / raw)
  To: marcel@holtmann.org
  Cc: johan.hedberg@gmail.com, luiz.dentz@gmail.com,
	davem@davemloft.net, kuba@kernel.org,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org, tientzu@chromium.org, Max Chou,
	alex_lu@realsil.com.cn, KidmanLee

Hi Maintainers,

About this commit, do you have any further comments/suggestions on this?
If you have any questions or concerns, please kindly let me know.
Thank you.

Regards,
Hilda

-----Original Message-----
From: Hilda Wu <hildawu@realtek.com> 
Sent: Tuesday, March 16, 2021 6:07 PM
To: marcel@holtmann.org
Cc: johan.hedberg@gmail.com; luiz.dentz@gmail.com; davem@davemloft.net; kuba@kernel.org; linux-bluetooth@vger.kernel.org; linux-kernel@vger.kernel.org; netdev@vger.kernel.org; tientzu@chromium.org; Max Chou <max.chou@realtek.com>; alex_lu@realsil.com.cn; KidmanLee <kidman@realtek.com>
Subject: [PATCH v2] Bluetooth: hci_h5: btrtl: Add quirk for keep power in suspend/resume

From: hildawu <hildawu@realtek.com>

RTL8822C devices support BT wakeup Host. Add a quirk for these specific devices did not power off during suspend and resume.
By this change, if the Host support that received BT device signal then it can be wakeup.

Signed-off-by: hildawu <hildawu@realtek.com>
---
Changes in v2:
- Add missing struct member
- Modify title for fit length
---
---
 drivers/bluetooth/btrtl.c   | 36 ------------------------------------
 drivers/bluetooth/btrtl.h   | 36 ++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/hci_h5.c  | 35 ++++++++++++++++++++++++-----------
 include/net/bluetooth/hci.h |  9 +++++++++
 4 files changed, 69 insertions(+), 47 deletions(-)

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c index e7fe5fb22753..94d1e7885aee 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -38,42 +38,6 @@
 	.hci_ver = (hciv), \
 	.hci_bus = (bus)
 
-enum btrtl_chip_id {
-	CHIP_ID_8723A,
-	CHIP_ID_8723B,
-	CHIP_ID_8821A,
-	CHIP_ID_8761A,
-	CHIP_ID_8822B = 8,
-	CHIP_ID_8723D,
-	CHIP_ID_8821C,
-	CHIP_ID_8822C = 13,
-	CHIP_ID_8761B,
-	CHIP_ID_8852A = 18,
-};
-
-struct id_table {
-	__u16 match_flags;
-	__u16 lmp_subver;
-	__u16 hci_rev;
-	__u8 hci_ver;
-	__u8 hci_bus;
-	bool config_needed;
-	bool has_rom_version;
-	char *fw_name;
-	char *cfg_name;
-};
-
-struct btrtl_device_info {
-	const struct id_table *ic_info;
-	u8 rom_version;
-	u8 *fw_data;
-	int fw_len;
-	u8 *cfg_data;
-	int cfg_len;
-	bool drop_fw;
-	int project_id;
-};
-
 static const struct id_table ic_id_table[] = {
 	/* 8723A */
 	{ IC_INFO(RTL_ROM_LMP_8723A, 0xb, 0x6, HCI_USB), diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h index 2a582682136d..713768b38e21 100644
--- a/drivers/bluetooth/btrtl.h
+++ b/drivers/bluetooth/btrtl.h
@@ -12,6 +12,42 @@
 #define rtl_dev_info(dev, fmt, ...) bt_dev_info(dev, "RTL: " fmt, ##__VA_ARGS__)  #define rtl_dev_dbg(dev, fmt, ...) bt_dev_dbg(dev, "RTL: " fmt, ##__VA_ARGS__)
 
+enum btrtl_chip_id {
+	CHIP_ID_8723A,
+	CHIP_ID_8723B,
+	CHIP_ID_8821A,
+	CHIP_ID_8761A,
+	CHIP_ID_8822B = 8,
+	CHIP_ID_8723D,
+	CHIP_ID_8821C,
+	CHIP_ID_8822C = 13,
+	CHIP_ID_8761B,
+	CHIP_ID_8852A = 18,
+};
+
+struct id_table {
+	__u16 match_flags;
+	__u16 lmp_subver;
+	__u16 hci_rev;
+	__u8 hci_ver;
+	__u8 hci_bus;
+	bool config_needed;
+	bool has_rom_version;
+	char *fw_name;
+	char *cfg_name;
+};
+
+struct btrtl_device_info {
+	const struct id_table *ic_info;
+	u8 rom_version;
+	u8 *fw_data;
+	int fw_len;
+	u8 *cfg_data;
+	int cfg_len;
+	bool drop_fw;
+	int project_id;
+};
+
 struct btrtl_device_info;
 
 struct rtl_download_cmd {
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index 27e96681d583..1ca4ff89ea14 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -909,7 +909,15 @@ static int h5_btrtl_setup(struct h5 *h5)
 	/* Enable controller to do both LE scan and BR/EDR inquiry
 	 * simultaneously.
 	 */
-	set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
+	switch (btrtl_dev->project_id) {
+	case CHIP_ID_8822C:
+	case CHIP_ID_8852A:
+		set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
+		set_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks);
+		break;
+	default:
+		break;
+	}
 
 out_free:
 	btrtl_free(btrtl_dev);
@@ -945,8 +953,11 @@ static void h5_btrtl_close(struct h5 *h5)  static int h5_btrtl_suspend(struct h5 *h5)  {
 	serdev_device_set_flow_control(h5->hu->serdev, false);
-	gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
-	gpiod_set_value_cansleep(h5->enable_gpio, 0);
+
+	if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
+		gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
+		gpiod_set_value_cansleep(h5->enable_gpio, 0);
+	}
 	return 0;
 }
 
@@ -972,17 +983,19 @@ static void h5_btrtl_reprobe_worker(struct work_struct *work)
 
 static int h5_btrtl_resume(struct h5 *h5)  {
-	struct h5_btrtl_reprobe *reprobe;
+	if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
+		struct h5_btrtl_reprobe *reprobe;
 
-	reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
-	if (!reprobe)
-		return -ENOMEM;
+		reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
+		if (!reprobe)
+			return -ENOMEM;
 
-	__module_get(THIS_MODULE);
+		__module_get(THIS_MODULE);
 
-	INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
-	reprobe->dev = get_device(&h5->hu->serdev->dev);
-	queue_work(system_long_wq, &reprobe->work);
+		INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
+		reprobe->dev = get_device(&h5->hu->serdev->dev);
+		queue_work(system_long_wq, &reprobe->work);
+	}
 	return 0;
 }
 
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index ea4ae551c426..1e4c2a97ab8d 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -246,6 +246,15 @@ enum {
 	 * HCI after resume.
 	 */
 	HCI_QUIRK_NO_SUSPEND_NOTIFIER,
+
+	/* When this quirk is set, the controller does not power off
+	 * during suspend and resume. This mechanism lets BT devices wake
+	 * the Host up if the Host and chips support.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED,
 };
 
 /* HCI device flags */
--
2.17.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Bluetooth: hci_h5: btrtl: Add quirk for keep power in suspend/resume
  2021-03-16 10:06 [PATCH v2] Bluetooth: hci_h5: btrtl: Add quirk for keep power in suspend/resume hildawu
  2021-03-16 11:27 ` [v2] " bluez.test.bot
  2021-03-30  6:22 ` [PATCH v2] " Hilda Wu
@ 2021-04-09 14:22 ` Marcel Holtmann
  2 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2021-04-09 14:22 UTC (permalink / raw)
  To: Hilda Wu
  Cc: Johan Hedberg, Luiz Augusto von Dentz, David S. Miller,
	Jakub Kicinski, linux-bluetooth, LKML, netdev, tientzu, max.chou,
	alex_lu, kidman

Hi Hilda,

> RTL8822C devices support BT wakeup Host. Add a quirk for these specific
> devices did not power off during suspend and resume.
> By this change, if the Host support that received BT device signal then
> it can be wakeup.
> 
> Signed-off-by: hildawu <hildawu@realtek.com>
> ---
> Changes in v2:
> - Add missing struct member
> - Modify title for fit length
> ---
> ---
> drivers/bluetooth/btrtl.c   | 36 ------------------------------------
> drivers/bluetooth/btrtl.h   | 36 ++++++++++++++++++++++++++++++++++++
> drivers/bluetooth/hci_h5.c  | 35 ++++++++++++++++++++++++-----------
> include/net/bluetooth/hci.h |  9 +++++++++
> 4 files changed, 69 insertions(+), 47 deletions(-)
> 
> diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
> index e7fe5fb22753..94d1e7885aee 100644
> --- a/drivers/bluetooth/btrtl.c
> +++ b/drivers/bluetooth/btrtl.c
> @@ -38,42 +38,6 @@
> 	.hci_ver = (hciv), \
> 	.hci_bus = (bus)
> 
> -enum btrtl_chip_id {
> -	CHIP_ID_8723A,
> -	CHIP_ID_8723B,
> -	CHIP_ID_8821A,
> -	CHIP_ID_8761A,
> -	CHIP_ID_8822B = 8,
> -	CHIP_ID_8723D,
> -	CHIP_ID_8821C,
> -	CHIP_ID_8822C = 13,
> -	CHIP_ID_8761B,
> -	CHIP_ID_8852A = 18,
> -};
> -
> -struct id_table {
> -	__u16 match_flags;
> -	__u16 lmp_subver;
> -	__u16 hci_rev;
> -	__u8 hci_ver;
> -	__u8 hci_bus;
> -	bool config_needed;
> -	bool has_rom_version;
> -	char *fw_name;
> -	char *cfg_name;
> -};
> -
> -struct btrtl_device_info {
> -	const struct id_table *ic_info;
> -	u8 rom_version;
> -	u8 *fw_data;
> -	int fw_len;
> -	u8 *cfg_data;
> -	int cfg_len;
> -	bool drop_fw;
> -	int project_id;
> -};
> -
> static const struct id_table ic_id_table[] = {
> 	/* 8723A */
> 	{ IC_INFO(RTL_ROM_LMP_8723A, 0xb, 0x6, HCI_USB),
> diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h
> index 2a582682136d..713768b38e21 100644
> --- a/drivers/bluetooth/btrtl.h
> +++ b/drivers/bluetooth/btrtl.h
> @@ -12,6 +12,42 @@
> #define rtl_dev_info(dev, fmt, ...) bt_dev_info(dev, "RTL: " fmt, ##__VA_ARGS__)
> #define rtl_dev_dbg(dev, fmt, ...) bt_dev_dbg(dev, "RTL: " fmt, ##__VA_ARGS__)
> 
> +enum btrtl_chip_id {
> +	CHIP_ID_8723A,
> +	CHIP_ID_8723B,
> +	CHIP_ID_8821A,
> +	CHIP_ID_8761A,
> +	CHIP_ID_8822B = 8,
> +	CHIP_ID_8723D,
> +	CHIP_ID_8821C,
> +	CHIP_ID_8822C = 13,
> +	CHIP_ID_8761B,
> +	CHIP_ID_8852A = 18,
> +};
> +
> +struct id_table {
> +	__u16 match_flags;
> +	__u16 lmp_subver;
> +	__u16 hci_rev;
> +	__u8 hci_ver;
> +	__u8 hci_bus;
> +	bool config_needed;
> +	bool has_rom_version;
> +	char *fw_name;
> +	char *cfg_name;
> +};
> +
> +struct btrtl_device_info {
> +	const struct id_table *ic_info;
> +	u8 rom_version;
> +	u8 *fw_data;
> +	int fw_len;
> +	u8 *cfg_data;
> +	int cfg_len;
> +	bool drop_fw;
> +	int project_id;
> +};
> +
> struct btrtl_device_info;

I rather not move around these things.

> struct rtl_download_cmd {
> diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
> index 27e96681d583..1ca4ff89ea14 100644
> --- a/drivers/bluetooth/hci_h5.c
> +++ b/drivers/bluetooth/hci_h5.c
> @@ -909,7 +909,15 @@ static int h5_btrtl_setup(struct h5 *h5)
> 	/* Enable controller to do both LE scan and BR/EDR inquiry
> 	 * simultaneously.
> 	 */
> -	set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
> +	switch (btrtl_dev->project_id) {
> +	case CHIP_ID_8822C:
> +	case CHIP_ID_8852A:
> +		set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
> +		set_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks);
> +		break;
> +	default:
> +		break;
> +	}
> 
> out_free:
> 	btrtl_free(btrtl_dev);
> @@ -945,8 +953,11 @@ static void h5_btrtl_close(struct h5 *h5)
> static int h5_btrtl_suspend(struct h5 *h5)
> {
> 	serdev_device_set_flow_control(h5->hu->serdev, false);
> -	gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
> -	gpiod_set_value_cansleep(h5->enable_gpio, 0);
> +
> +	if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
> +		gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
> +		gpiod_set_value_cansleep(h5->enable_gpio, 0);
> +	}
> 	return 0;
> }
> 
> @@ -972,17 +983,19 @@ static void h5_btrtl_reprobe_worker(struct work_struct *work)
> 
> static int h5_btrtl_resume(struct h5 *h5)
> {
> -	struct h5_btrtl_reprobe *reprobe;
> +	if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
> +		struct h5_btrtl_reprobe *reprobe;
> 
> -	reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
> -	if (!reprobe)
> -		return -ENOMEM;
> +		reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
> +		if (!reprobe)
> +			return -ENOMEM;
> 
> -	__module_get(THIS_MODULE);
> +		__module_get(THIS_MODULE);
> 
> -	INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
> -	reprobe->dev = get_device(&h5->hu->serdev->dev);
> -	queue_work(system_long_wq, &reprobe->work);
> +		INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
> +		reprobe->dev = get_device(&h5->hu->serdev->dev);
> +		queue_work(system_long_wq, &reprobe->work);
> +	}
> 	return 0;
> }
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index ea4ae551c426..1e4c2a97ab8d 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -246,6 +246,15 @@ enum {
> 	 * HCI after resume.
> 	 */
> 	HCI_QUIRK_NO_SUSPEND_NOTIFIER,
> +
> +	/* When this quirk is set, the controller does not power off
> +	 * during suspend and resume. This mechanism lets BT devices wake
> +	 * the Host up if the Host and chips support.
> +	 *
> +	 * This quirk can be set before hci_register_dev is called or
> +	 * during the hdev->setup vendor callback.
> +	 */
> +	HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED,
> };

Since this hci_uart specific, please don’t introduce another quirk and keep this internal.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-04-09 14:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-16 10:06 [PATCH v2] Bluetooth: hci_h5: btrtl: Add quirk for keep power in suspend/resume hildawu
2021-03-16 11:27 ` [v2] " bluez.test.bot
2021-03-30  6:22 ` [PATCH v2] " Hilda Wu
2021-04-09 14:22 ` Marcel Holtmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.