All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] Bluetooth: btnxpuart: Add system suspend and resume handlers
@ 2024-07-04 12:58 Neeraj Sanjay Kale
  2024-07-04 13:36 ` [v1] " bluez.test.bot
  2024-07-05  6:36 ` [PATCH v1] " Luke Wang
  0 siblings, 2 replies; 3+ messages in thread
From: Neeraj Sanjay Kale @ 2024-07-04 12:58 UTC (permalink / raw)
  To: marcel, luiz.dentz
  Cc: linux-bluetooth, linux-kernel, amitkumar.karwar, rohit.fule,
	neeraj.sanjaykale, sherry.sun, ziniu.wang_1, haibo.chen, LnxRevLi

This adds handling for system suspend and resume. While the host enters
suspend state, the driver will drive the chip into low power state.

Similarly when system is resuming, the driver will wake up the chip.

Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
---
 drivers/bluetooth/btnxpuart.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index da18fd4f54f3..acd360fcc3b8 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -1498,6 +1498,24 @@ static void nxp_serdev_remove(struct serdev_device *serdev)
 	hci_free_dev(hdev);
 }
 
+static int nxp_suspend(struct device *dev)
+{
+	struct btnxpuart_dev *nxpdev = dev_get_drvdata(dev);
+	struct ps_data *psdata = &nxpdev->psdata;
+
+	ps_control(psdata->hdev, PS_STATE_SLEEP);
+	return 0;
+}
+
+static int nxp_resume(struct device *dev)
+{
+	struct btnxpuart_dev *nxpdev = dev_get_drvdata(dev);
+	struct ps_data *psdata = &nxpdev->psdata;
+
+	ps_control(data->hdev, PS_STATE_AWAKE);
+	return 0;
+}
+
 static struct btnxpuart_data w8987_data __maybe_unused = {
 	.helper_fw_name = NULL,
 	.fw_name = FIRMWARE_W8987,
@@ -1517,12 +1535,17 @@ static const struct of_device_id nxpuart_of_match_table[] __maybe_unused = {
 };
 MODULE_DEVICE_TABLE(of, nxpuart_of_match_table);
 
+static const struct dev_pm_ops nxp_pm_ops = {
+	SET_SYSTEM_SLEEP_PM_OPS(nxp_suspend, nxp_resume)
+};
+
 static struct serdev_device_driver nxp_serdev_driver = {
 	.probe = nxp_serdev_probe,
 	.remove = nxp_serdev_remove,
 	.driver = {
 		.name = "btnxpuart",
 		.of_match_table = of_match_ptr(nxpuart_of_match_table),
+		.pm = &nxp_pm_ops,
 	},
 };
 
-- 
2.34.1


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

* RE: [v1] Bluetooth: btnxpuart: Add system suspend and resume handlers
  2024-07-04 12:58 [PATCH v1] Bluetooth: btnxpuart: Add system suspend and resume handlers Neeraj Sanjay Kale
@ 2024-07-04 13:36 ` bluez.test.bot
  2024-07-05  6:36 ` [PATCH v1] " Luke Wang
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2024-07-04 13:36 UTC (permalink / raw)
  To: linux-bluetooth, neeraj.sanjaykale

[-- Attachment #1: Type: text/plain, Size: 1695 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=868445

---Test result---

Test Summary:
CheckPatch                    PASS      0.68 seconds
GitLint                       PASS      0.31 seconds
SubjectPrefix                 PASS      0.12 seconds
BuildKernel                   PASS      29.89 seconds
CheckAllWarning               PASS      32.70 seconds
CheckSparse                   PASS      38.23 seconds
CheckSmatch                   PASS      104.39 seconds
BuildKernel32                 PASS      29.64 seconds
TestRunnerSetup               PASS      531.46 seconds
TestRunner_l2cap-tester       PASS      20.26 seconds
TestRunner_iso-tester         FAIL      41.33 seconds
TestRunner_bnep-tester        PASS      6.30 seconds
TestRunner_mgmt-tester        PASS      114.14 seconds
TestRunner_rfcomm-tester      PASS      7.46 seconds
TestRunner_sco-tester         PASS      15.07 seconds
TestRunner_ioctl-tester       PASS      7.86 seconds
TestRunner_mesh-tester        PASS      6.03 seconds
TestRunner_smp-tester         PASS      7.01 seconds
TestRunner_userchan-tester    PASS      5.11 seconds
IncrementalBuild              PASS      28.17 seconds

Details
##############################
Test: TestRunner_iso-tester - FAIL
Desc: Run iso-tester with test-runner
Output:
Total: 122, Passed: 117 (95.9%), Failed: 1, Not Run: 4

Failed Test Cases
ISO Connect2 Suspend - Success                       Failed       4.240 seconds


---
Regards,
Linux Bluetooth


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

* RE: [PATCH v1] Bluetooth: btnxpuart: Add system suspend and resume handlers
  2024-07-04 12:58 [PATCH v1] Bluetooth: btnxpuart: Add system suspend and resume handlers Neeraj Sanjay Kale
  2024-07-04 13:36 ` [v1] " bluez.test.bot
@ 2024-07-05  6:36 ` Luke Wang
  1 sibling, 0 replies; 3+ messages in thread
From: Luke Wang @ 2024-07-05  6:36 UTC (permalink / raw)
  To: Neeraj Sanjay Kale, marcel@holtmann.org, luiz.dentz@gmail.com
  Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	Amitkumar Karwar, Rohit Fule, Neeraj Sanjay Kale, Sherry Sun,
	Bough Chen, LnxRevLi

Hi Neeraj

> -----Original Message-----
> From: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> Sent: Thursday, July 4, 2024 8:58 PM
> To: marcel@holtmann.org; luiz.dentz@gmail.com
> Cc: linux-bluetooth@vger.kernel.org; linux-kernel@vger.kernel.org;
> Amitkumar Karwar <amitkumar.karwar@nxp.com>; Rohit Fule
> <rohit.fule@nxp.com>; Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>;
> Sherry Sun <sherry.sun@nxp.com>; Luke Wang <ziniu.wang_1@nxp.com>;
> Bough Chen <haibo.chen@nxp.com>; LnxRevLi <LnxRevLi@nxp.com>
> Subject: [PATCH v1] Bluetooth: btnxpuart: Add system suspend and resume
> handlers
> 
> This adds handling for system suspend and resume. While the host enters
> suspend state, the driver will drive the chip into low power state.
> 
> Similarly when system is resuming, the driver will wake up the chip.
> 
> Signed-off-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>
> ---
>  drivers/bluetooth/btnxpuart.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
> index da18fd4f54f3..acd360fcc3b8 100644
> --- a/drivers/bluetooth/btnxpuart.c
> +++ b/drivers/bluetooth/btnxpuart.c
> @@ -1498,6 +1498,24 @@ static void nxp_serdev_remove(struct
> serdev_device *serdev)
>  	hci_free_dev(hdev);
>  }
> 
> +static int nxp_suspend(struct device *dev)
> +{
> +	struct btnxpuart_dev *nxpdev = dev_get_drvdata(dev);
> +	struct ps_data *psdata = &nxpdev->psdata;
> +
> +	ps_control(psdata->hdev, PS_STATE_SLEEP);
> +	return 0;
> +}
> +
> +static int nxp_resume(struct device *dev)
> +{
> +	struct btnxpuart_dev *nxpdev = dev_get_drvdata(dev);
> +	struct ps_data *psdata = &nxpdev->psdata;
> +
> +	ps_control(data->hdev, PS_STATE_AWAKE);
> +	return 0;
> +}
> +

Is it better to use btnxpuart_suspend/resume or nxp_serdev_suspend/resume? 

>  static struct btnxpuart_data w8987_data __maybe_unused = {
>  	.helper_fw_name = NULL,
>  	.fw_name = FIRMWARE_W8987,
> @@ -1517,12 +1535,17 @@ static const struct of_device_id
> nxpuart_of_match_table[] __maybe_unused = {
>  };
>  MODULE_DEVICE_TABLE(of, nxpuart_of_match_table);
> 
> +static const struct dev_pm_ops nxp_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(nxp_suspend, nxp_resume)
> +};
> +
>  static struct serdev_device_driver nxp_serdev_driver = {
>  	.probe = nxp_serdev_probe,
>  	.remove = nxp_serdev_remove,
>  	.driver = {
>  		.name = "btnxpuart",
>  		.of_match_table = of_match_ptr(nxpuart_of_match_table),
> +		.pm = &nxp_pm_ops,
>  	},
>  };
> 
> --
> 2.34.1


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

end of thread, other threads:[~2024-07-05  6:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04 12:58 [PATCH v1] Bluetooth: btnxpuart: Add system suspend and resume handlers Neeraj Sanjay Kale
2024-07-04 13:36 ` [v1] " bluez.test.bot
2024-07-05  6:36 ` [PATCH v1] " Luke Wang

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.