From 2445896ee0caed8c7477415c87d87326a7fb9573 Mon Sep 17 00:00:00 2001 From: Serhii Date: Fri, 24 Mar 2023 20:57:05 +0200 Subject: [PATCH] [Telink] Ability to disable/enable PM during BLE operation (#25769) * [Telink] Remove tlsr9518adk80d.overlay * [Telink] Ability to disable Zephyr PM during BLE --- config/telink/chip-module/Kconfig | 6 ++++++ examples/all-clusters-app/telink/prj.conf | 1 + .../telink/boards/tlsr9518adk80d.overlay | 3 --- examples/contact-sensor-app/telink/prj.conf | 1 + .../telink/boards/tlsr9518adk80d.overlay | 3 --- examples/light-switch-app/telink/prj.conf | 1 + examples/lighting-app/telink/prj.conf | 1 + examples/lock-app/telink/prj.conf | 1 + examples/ota-requestor-app/telink/prj.conf | 1 + examples/pump-app/telink/prj.conf | 1 + examples/pump-controller-app/telink/prj.conf | 1 + examples/temperature-measurement-app/telink/prj.conf | 1 + .../thermostat/telink/boards/tlsr9518adk80d.overlay | 3 --- examples/thermostat/telink/prj.conf | 1 + examples/window-app/telink/prj.conf | 1 + src/platform/telink/BLEManagerImpl.cpp | 11 +++++++++++ 16 files changed, 28 insertions(+), 9 deletions(-) delete mode 100755 examples/contact-sensor-app/telink/boards/tlsr9518adk80d.overlay delete mode 100644 examples/light-switch-app/telink/boards/tlsr9518adk80d.overlay delete mode 100755 examples/thermostat/telink/boards/tlsr9518adk80d.overlay diff --git a/config/telink/chip-module/Kconfig b/config/telink/chip-module/Kconfig index 80d8770e8ed7e3..f047a9cace7526 100644 --- a/config/telink/chip-module/Kconfig +++ b/config/telink/chip-module/Kconfig @@ -162,3 +162,9 @@ config CHIP_ENABLE_APPLICATION_STATUS_LED default y help Enable application status LED. + +config CHIP_ENABLE_PM_DURING_BLE + bool "Enable PM during BLE operation" + default y + help + Enable PM during BLE operation. diff --git a/examples/all-clusters-app/telink/prj.conf b/examples/all-clusters-app/telink/prj.conf index 867ef065f12fe0..bc8ce45c357204 100644 --- a/examples/all-clusters-app/telink/prj.conf +++ b/examples/all-clusters-app/telink/prj.conf @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n diff --git a/examples/contact-sensor-app/telink/boards/tlsr9518adk80d.overlay b/examples/contact-sensor-app/telink/boards/tlsr9518adk80d.overlay deleted file mode 100755 index 6e5b59a7c5a8f0..00000000000000 --- a/examples/contact-sensor-app/telink/boards/tlsr9518adk80d.overlay +++ /dev/null @@ -1,3 +0,0 @@ -&cpu0 { - clock-frequency = <32000000>; -}; \ No newline at end of file diff --git a/examples/contact-sensor-app/telink/prj.conf b/examples/contact-sensor-app/telink/prj.conf index 8ad82c35fab3a8..7b643ece5322c4 100755 --- a/examples/contact-sensor-app/telink/prj.conf +++ b/examples/contact-sensor-app/telink/prj.conf @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n diff --git a/examples/light-switch-app/telink/boards/tlsr9518adk80d.overlay b/examples/light-switch-app/telink/boards/tlsr9518adk80d.overlay deleted file mode 100644 index 6e5b59a7c5a8f0..00000000000000 --- a/examples/light-switch-app/telink/boards/tlsr9518adk80d.overlay +++ /dev/null @@ -1,3 +0,0 @@ -&cpu0 { - clock-frequency = <32000000>; -}; \ No newline at end of file diff --git a/examples/light-switch-app/telink/prj.conf b/examples/light-switch-app/telink/prj.conf index 6a715e8b05e6da..9b8262eca31d06 100755 --- a/examples/light-switch-app/telink/prj.conf +++ b/examples/light-switch-app/telink/prj.conf @@ -73,3 +73,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n diff --git a/examples/lighting-app/telink/prj.conf b/examples/lighting-app/telink/prj.conf index cebd1abc50fdce..28f890f98bd9eb 100644 --- a/examples/lighting-app/telink/prj.conf +++ b/examples/lighting-app/telink/prj.conf @@ -73,6 +73,7 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n # Custom RF power values CONFIG_B91_BLE_CTRL_RF_POWER_P9P11DBM=y diff --git a/examples/lock-app/telink/prj.conf b/examples/lock-app/telink/prj.conf index 0f34d45d8f9cd4..e57b152edb82f8 100755 --- a/examples/lock-app/telink/prj.conf +++ b/examples/lock-app/telink/prj.conf @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n diff --git a/examples/ota-requestor-app/telink/prj.conf b/examples/ota-requestor-app/telink/prj.conf index a5946d1a0f3fc4..de139770a43d74 100755 --- a/examples/ota-requestor-app/telink/prj.conf +++ b/examples/ota-requestor-app/telink/prj.conf @@ -66,3 +66,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n diff --git a/examples/pump-app/telink/prj.conf b/examples/pump-app/telink/prj.conf index 93c255aacc7e76..6bd026d01cc298 100755 --- a/examples/pump-app/telink/prj.conf +++ b/examples/pump-app/telink/prj.conf @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n diff --git a/examples/pump-controller-app/telink/prj.conf b/examples/pump-controller-app/telink/prj.conf index 60a7f8ef53ed99..07b9cd80e6bee4 100755 --- a/examples/pump-controller-app/telink/prj.conf +++ b/examples/pump-controller-app/telink/prj.conf @@ -72,3 +72,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n diff --git a/examples/temperature-measurement-app/telink/prj.conf b/examples/temperature-measurement-app/telink/prj.conf index 57d38353f586fb..581d7714188ff6 100644 --- a/examples/temperature-measurement-app/telink/prj.conf +++ b/examples/temperature-measurement-app/telink/prj.conf @@ -73,6 +73,7 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n # Custom RF power values CONFIG_B91_BLE_CTRL_RF_POWER_P9P11DBM=y diff --git a/examples/thermostat/telink/boards/tlsr9518adk80d.overlay b/examples/thermostat/telink/boards/tlsr9518adk80d.overlay deleted file mode 100755 index 6e5b59a7c5a8f0..00000000000000 --- a/examples/thermostat/telink/boards/tlsr9518adk80d.overlay +++ /dev/null @@ -1,3 +0,0 @@ -&cpu0 { - clock-frequency = <32000000>; -}; \ No newline at end of file diff --git a/examples/thermostat/telink/prj.conf b/examples/thermostat/telink/prj.conf index 74e9f2b682d607..f2994ffd67ed78 100755 --- a/examples/thermostat/telink/prj.conf +++ b/examples/thermostat/telink/prj.conf @@ -73,3 +73,4 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n diff --git a/examples/window-app/telink/prj.conf b/examples/window-app/telink/prj.conf index a148cdaac140c9..0abc1f68818e50 100644 --- a/examples/window-app/telink/prj.conf +++ b/examples/window-app/telink/prj.conf @@ -72,6 +72,7 @@ CONFIG_CHIP_ENABLE_APPLICATION_STATUS_LED=y # Enable Power Management CONFIG_PM=n CONFIG_PM_DEVICE=n +CONFIG_CHIP_ENABLE_PM_DURING_BLE=n # Custom RF power values CONFIG_B91_BLE_CTRL_RF_POWER_P9P11DBM=y diff --git a/src/platform/telink/BLEManagerImpl.cpp b/src/platform/telink/BLEManagerImpl.cpp index dd330a743a1066..4f09f525bced75 100644 --- a/src/platform/telink/BLEManagerImpl.cpp +++ b/src/platform/telink/BLEManagerImpl.cpp @@ -43,6 +43,10 @@ #include #include +#if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE) +#include +#endif + #include // Includes for ieee802154 switchings @@ -316,6 +320,9 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) VerifyOrReturnError(err == 0, MapErrorZephyr(err)); (void) bt_set_name(bt_dev_name); BLERadioInitialized = true; +#if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE) + pm_policy_state_lock_get(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES); +#endif } // Prepare advertising request @@ -959,6 +966,10 @@ void BLEManagerImpl::SwitchToIeee802154(void) // irq_disable(IRQ1_SYSTIMER); BLERadioInitialized = false; +#if defined(CONFIG_PM) && !defined(CONFIG_CHIP_ENABLE_PM_DURING_BLE) + pm_policy_state_lock_put(PM_STATE_SUSPEND_TO_IDLE, PM_ALL_SUBSTATES); +#endif + const struct device * radio_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_ieee802154)); __ASSERT(radio_dev != NULL, "Get radio_dev fail");