linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Bluetooth hci_h5 btrtl Add flag for keep power in suspend/resume
@ 2021-04-23  3:52 hildawu
  2021-04-23  3:52 ` [PATCH v3 1/2] Bluetooth: btrtl: Adjust the position of strcut definition hildawu
  2021-04-23  3:52 ` [PATCH v3 2/2] Bluetooth: hci_h5: Add flag for keep power during suspend/resume hildawu
  0 siblings, 2 replies; 5+ messages in thread
From: hildawu @ 2021-04-23  3:52 UTC (permalink / raw)
  To: marcel
  Cc: johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel,
	apusaka, tientzu, max.chou, alex_lu, kidman

From: hildawu <hildawu@realtek.com>

Hello!

This v3 series is for support Host can be wakeup and device no need
power down and no need re-dowload fw. Supported this feature chips
RTL8822C/RTL8852A include UART interface. Avoid re-define related
information. So move shared structure info the btrtl.h.

The patch 1 is adjust the position of strcut definition for btrtl
and hci_h5. The purpose for avoid re-defining chip features in btrtl
with USB and UART devices. Let UART devices (hci_h5) can get relevant
information too. That can be easily managed feature of chips.

The patch 2 is support for Host can received BT device signal then
wake Host up. So this patch, add a flag for these devices didnot
power off and didnot re-download patch during suspend and resume.

version 3 changes
- Reworked to use UART flag, refer to Maintainer's suggestion.
- Split into two patches for different purpose.

version 2 changes
- Add the missing struct member
- Modify title length

Thanks.
Hilda

hildawu (2):
  Bluetooth: btrtl: Adjust the position of strcut definition
  Bluetooth: hci_h5: Add flag for keep power during suspend/resume

 drivers/bluetooth/btrtl.c     | 36 -----------------------------------
 drivers/bluetooth/btrtl.h     | 36 ++++++++++++++++++++++++++++++++++-
 drivers/bluetooth/hci_h5.c    | 34 +++++++++++++++++++++++----------
 drivers/bluetooth/hci_ldisc.c |  3 ++-
 drivers/bluetooth/hci_uart.h  |  1 +
 5 files changed, 62 insertions(+), 48 deletions(-)

-- 
2.17.1


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

* [PATCH v3 1/2] Bluetooth: btrtl: Adjust the position of strcut definition
  2021-04-23  3:52 [PATCH v3 0/2] Bluetooth hci_h5 btrtl Add flag for keep power in suspend/resume hildawu
@ 2021-04-23  3:52 ` hildawu
  2021-04-23  6:56   ` Marcel Holtmann
  2021-04-23  3:52 ` [PATCH v3 2/2] Bluetooth: hci_h5: Add flag for keep power during suspend/resume hildawu
  1 sibling, 1 reply; 5+ messages in thread
From: hildawu @ 2021-04-23  3:52 UTC (permalink / raw)
  To: marcel
  Cc: johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel,
	apusaka, tientzu, max.chou, alex_lu, kidman

From: hildawu <hildawu@realtek.com>

Adjust the position of strcut definition for btrtl and hci_h5.
The purpose is to avoid re-defining some chip features and let UART devices
get relevant information too.

Signed-off-by: hildawu <hildawu@realtek.com>
---
 drivers/bluetooth/btrtl.c | 36 ------------------------------------
 drivers/bluetooth/btrtl.h | 36 +++++++++++++++++++++++++++++++++++-
 2 files changed, 35 insertions(+), 37 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..08bda0597c0c 100644
--- a/drivers/bluetooth/btrtl.h
+++ b/drivers/bluetooth/btrtl.h
@@ -12,7 +12,41 @@
 #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__)
 
-struct btrtl_device_info;
+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 rtl_download_cmd {
 	__u8 index;
-- 
2.17.1


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

* [PATCH v3 2/2] Bluetooth: hci_h5: Add flag for keep power during suspend/resume
  2021-04-23  3:52 [PATCH v3 0/2] Bluetooth hci_h5 btrtl Add flag for keep power in suspend/resume hildawu
  2021-04-23  3:52 ` [PATCH v3 1/2] Bluetooth: btrtl: Adjust the position of strcut definition hildawu
@ 2021-04-23  3:52 ` hildawu
  2021-04-23  6:54   ` Marcel Holtmann
  1 sibling, 1 reply; 5+ messages in thread
From: hildawu @ 2021-04-23  3:52 UTC (permalink / raw)
  To: marcel
  Cc: johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel,
	apusaka, tientzu, max.chou, alex_lu, kidman

From: hildawu <hildawu@realtek.com>

RTL8822C and RTL8852A devices support BT wakeup Host. Add a flag
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 wake Host up.

Signed-off-by: hildawu <hildawu@realtek.com>
---
Changed in v3:
- Reworked to use UART flag, refer to Maintainer's suggestion.
- Split into two patches for different purpose.

Changes in v2:
- Add the missing struct member
- Modify title length
---
---
 drivers/bluetooth/hci_h5.c    | 34 ++++++++++++++++++++++++----------
 drivers/bluetooth/hci_ldisc.c |  3 ++-
 drivers/bluetooth/hci_uart.h  |  1 +
 3 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index 27e96681d583..9cacc4cdc928 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -911,6 +911,15 @@ static int h5_btrtl_setup(struct h5 *h5)
 	 */
 	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_UART_WAKEUP_ENABLE, &h5->hu->hdev_flags);
+		break;
+	default:
+		break;
+	}
+
 out_free:
 	btrtl_free(btrtl_dev);
 
@@ -945,8 +954,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_UART_WAKEUP_ENABLE, &h5->hu->hdev_flags)) {
+		gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
+		gpiod_set_value_cansleep(h5->enable_gpio, 0);
+	}
 	return 0;
 }
 
@@ -972,17 +984,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_UART_WAKEUP_ENABLE, &h5->hu->hdev_flags)) {
+		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/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 637c5b8c2aa1..3a1038e9dc6a 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -719,7 +719,8 @@ static int hci_uart_set_flags(struct hci_uart *hu, unsigned long flags)
 				    BIT(HCI_UART_CREATE_AMP) |
 				    BIT(HCI_UART_INIT_PENDING) |
 				    BIT(HCI_UART_EXT_CONFIG) |
-				    BIT(HCI_UART_VND_DETECT);
+				    BIT(HCI_UART_VND_DETECT) |
+				    BIT(HCI_UART_WAKEUP_ENABLE);
 
 	if (flags & ~valid_flags)
 		return -EINVAL;
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 4e039d7a16f8..25f5e5c7544c 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -41,6 +41,7 @@
 #define HCI_UART_INIT_PENDING	3
 #define HCI_UART_EXT_CONFIG	4
 #define HCI_UART_VND_DETECT	5
+#define HCI_UART_WAKEUP_ENABLE	6
 
 struct hci_uart;
 struct serdev_device;
-- 
2.17.1


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

* Re: [PATCH v3 2/2] Bluetooth: hci_h5: Add flag for keep power during suspend/resume
  2021-04-23  3:52 ` [PATCH v3 2/2] Bluetooth: hci_h5: Add flag for keep power during suspend/resume hildawu
@ 2021-04-23  6:54   ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2021-04-23  6:54 UTC (permalink / raw)
  To: Hilda Wu
  Cc: Johan Hedberg, Luiz Augusto von Dentz,
	Bluetooth Kernel Mailing List, open list, apusaka, tientzu,
	max.chou, alex_lu, kidman

Hi Hilda,

> RTL8822C and RTL8852A devices support BT wakeup Host. Add a flag
> 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 wake Host up.
> 
> Signed-off-by: hildawu <hildawu@realtek.com>
> ---
> Changed in v3:
> - Reworked to use UART flag, refer to Maintainer's suggestion.
> - Split into two patches for different purpose.
> 
> Changes in v2:
> - Add the missing struct member
> - Modify title length
> ---
> ---
> drivers/bluetooth/hci_h5.c    | 34 ++++++++++++++++++++++++----------
> drivers/bluetooth/hci_ldisc.c |  3 ++-
> drivers/bluetooth/hci_uart.h  |  1 +
> 3 files changed, 27 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
> index 27e96681d583..9cacc4cdc928 100644
> --- a/drivers/bluetooth/hci_h5.c
> +++ b/drivers/bluetooth/hci_h5.c
> @@ -911,6 +911,15 @@ static int h5_btrtl_setup(struct h5 *h5)
> 	 */
> 	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_UART_WAKEUP_ENABLE, &h5->hu->hdev_flags);
> +		break;
> +	default:
> +		break;
> +	}
> +
> out_free:
> 	btrtl_free(btrtl_dev);
> 
> @@ -945,8 +954,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_UART_WAKEUP_ENABLE, &h5->hu->hdev_flags)) {
> +		gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
> +		gpiod_set_value_cansleep(h5->enable_gpio, 0);
> +	}
> 	return 0;
> }
> 
> @@ -972,17 +984,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_UART_WAKEUP_ENABLE, &h5->hu->hdev_flags)) {
> +		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/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
> index 637c5b8c2aa1..3a1038e9dc6a 100644
> --- a/drivers/bluetooth/hci_ldisc.c
> +++ b/drivers/bluetooth/hci_ldisc.c
> @@ -719,7 +719,8 @@ static int hci_uart_set_flags(struct hci_uart *hu, unsigned long flags)
> 				    BIT(HCI_UART_CREATE_AMP) |
> 				    BIT(HCI_UART_INIT_PENDING) |
> 				    BIT(HCI_UART_EXT_CONFIG) |
> -				    BIT(HCI_UART_VND_DETECT);
> +				    BIT(HCI_UART_VND_DETECT) |
> +				    BIT(HCI_UART_WAKEUP_ENABLE);
> 
> 	if (flags & ~valid_flags)
> 		return -EINVAL;
> diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
> index 4e039d7a16f8..25f5e5c7544c 100644
> --- a/drivers/bluetooth/hci_uart.h
> +++ b/drivers/bluetooth/hci_uart.h
> @@ -41,6 +41,7 @@
> #define HCI_UART_INIT_PENDING	3
> #define HCI_UART_EXT_CONFIG	4
> #define HCI_UART_VND_DETECT	5
> +#define HCI_UART_WAKEUP_ENABLE	6

don’t use these flags since they are an ioctl API.

Regards

Marcel


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

* Re: [PATCH v3 1/2] Bluetooth: btrtl: Adjust the position of strcut definition
  2021-04-23  3:52 ` [PATCH v3 1/2] Bluetooth: btrtl: Adjust the position of strcut definition hildawu
@ 2021-04-23  6:56   ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2021-04-23  6:56 UTC (permalink / raw)
  To: Hilda Wu
  Cc: Johan Hedberg, Luiz Augusto von Dentz, linux-bluetooth,
	linux-kernel, apusaka, tientzu, max.chou, alex_lu, kidman

Hi Hilda,

> Adjust the position of strcut definition for btrtl and hci_h5.
> The purpose is to avoid re-defining some chip features and let UART devices
> get relevant information too.
> 
> Signed-off-by: hildawu <hildawu@realtek.com>
> ---
> drivers/bluetooth/btrtl.c | 36 ------------------------------------
> drivers/bluetooth/btrtl.h | 36 +++++++++++++++++++++++++++++++++++-
> 2 files changed, 35 insertions(+), 37 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..08bda0597c0c 100644
> --- a/drivers/bluetooth/btrtl.h
> +++ b/drivers/bluetooth/btrtl.h
> @@ -12,7 +12,41 @@
> #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__)
> 
> -struct btrtl_device_info;
> +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;
> +};

I really doubt that you need to expose all of these. Provide access function if needed.

Regards

Marcel


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

end of thread, other threads:[~2021-04-23  6:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23  3:52 [PATCH v3 0/2] Bluetooth hci_h5 btrtl Add flag for keep power in suspend/resume hildawu
2021-04-23  3:52 ` [PATCH v3 1/2] Bluetooth: btrtl: Adjust the position of strcut definition hildawu
2021-04-23  6:56   ` Marcel Holtmann
2021-04-23  3:52 ` [PATCH v3 2/2] Bluetooth: hci_h5: Add flag for keep power during suspend/resume hildawu
2021-04-23  6:54   ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).