|
16 | 16 | #include <zephyr/drivers/flash.h>
|
17 | 17 | #include <zephyr/bluetooth/hci_types.h>
|
18 | 18 | #include <soc.h>
|
| 19 | +#include <zephyr/pm/policy.h> |
19 | 20 |
|
20 | 21 | #include <fwk_platform_ble.h>
|
21 | 22 | #include <fwk_platform.h>
|
@@ -71,6 +72,12 @@ LOG_MODULE_REGISTER(bt_driver);
|
71 | 72 | #if !defined(CONFIG_BT_HCI_SET_PUBLIC_ADDR)
|
72 | 73 | #define bt_nxp_set_mac_address(public_addr) 0
|
73 | 74 | #endif
|
| 75 | + |
| 76 | +#if DT_NODE_HAS_STATUS(DT_NODELABEL(standby), okay) && defined(CONFIG_PM) &&\ |
| 77 | + defined(CONFIG_HCI_NXP_ENABLE_AUTO_SLEEP) |
| 78 | +#define HCI_NXP_LOCK_STANDBY_BEFORE_SEND |
| 79 | +#endif |
| 80 | + |
74 | 81 | /* -------------------------------------------------------------------------- */
|
75 | 82 | /* Public prototypes */
|
76 | 83 | /* -------------------------------------------------------------------------- */
|
@@ -413,7 +420,18 @@ static int bt_nxp_send(const struct device *dev, struct net_buf *buf)
|
413 | 420 | }
|
414 | 421 |
|
415 | 422 | net_buf_push_u8(buf, packetType);
|
| 423 | +#if defined(HCI_NXP_LOCK_STANDBY_BEFORE_SEND) |
| 424 | + /* Sending an HCI message requires to wake up the controller core if it's asleep. |
| 425 | + * Platform controllers may send reponses using non wakeable interrupts which can |
| 426 | + * be lost during standby usage. |
| 427 | + * Blocking standby usage until the HCI message is sent. |
| 428 | + */ |
| 429 | + pm_policy_state_lock_get(PM_STATE_STANDBY, PM_ALL_SUBSTATES); |
| 430 | +#endif |
416 | 431 | PLATFORM_SendHciMessage(buf->data, buf->len);
|
| 432 | +#if defined(HCI_NXP_LOCK_STANDBY_BEFORE_SEND) |
| 433 | + pm_policy_state_lock_put(PM_STATE_STANDBY, PM_ALL_SUBSTATES); |
| 434 | +#endif |
417 | 435 |
|
418 | 436 | net_buf_unref(buf);
|
419 | 437 |
|
|
0 commit comments