-
Notifications
You must be signed in to change notification settings - Fork 1.4k
manifest: sdk-zephyr: Cherry pick remove pm device runtime auto #23607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
600b0cb
e1b647b
848dd41
4a05846
f3bcd32
c509075
7b5eee4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,8 +19,9 @@ | |
| #include <zephyr/drivers/uart.h> | ||
| #include <zephyr/kernel.h> | ||
| #include <zephyr/logging/log.h> | ||
| #include <zephyr/pm/device.h> | ||
| #include <zephyr/pm/device_runtime.h> | ||
| #include <zephyr/sys/ring_buffer.h> | ||
| #include <zephyr/sys/atomic.h> | ||
| LOG_MODULE_REGISTER(slm_at_host, CONFIG_SLM_LOG_LEVEL); | ||
|
|
||
| #define SLM_SYNC_STR "Ready\r\n" | ||
|
|
@@ -53,11 +54,33 @@ static uint8_t quit_str_partial_match; | |
| K_MUTEX_DEFINE(mutex_data); /* Protects the data_rb and quit_str_partial_match. */ | ||
|
|
||
| static struct k_work raw_send_scheduled_work; | ||
| static bool slm_uart_dev_active; | ||
|
|
||
| /* global functions defined in different files */ | ||
| int slm_at_init(void); | ||
| void slm_at_uninit(void); | ||
|
|
||
| static int set_uart_dev_power_state(bool active) | ||
| { | ||
| int err; | ||
|
|
||
| if ((active && slm_uart_dev_active) || (!active && !slm_uart_dev_active)) { | ||
| return 0; | ||
| } | ||
|
|
||
| if (active) { | ||
| err = pm_device_runtime_get(slm_uart_dev); | ||
| } else { | ||
| err = pm_device_runtime_put(slm_uart_dev); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to self: Test power consumption with AT#XSLEEP=2 after this change. |
||
| } | ||
|
|
||
| if (err == 0) { | ||
| slm_uart_dev_active = active; | ||
| } | ||
|
|
||
| return err; | ||
| } | ||
|
|
||
| static enum slm_operation_mode get_slm_mode(void) | ||
| { | ||
| enum slm_operation_mode mode; | ||
|
|
@@ -506,10 +529,7 @@ static int slm_at_send_indicate(const uint8_t *data, size_t len, | |
| } | ||
|
|
||
| if (indicate) { | ||
| enum pm_device_state state = PM_DEVICE_STATE_OFF; | ||
|
|
||
| pm_device_state_get(slm_uart_dev, &state); | ||
| if (state != PM_DEVICE_STATE_ACTIVE) { | ||
| if (!slm_uart_dev_is_active()) { | ||
| slm_ctrl_pin_indicate(); | ||
| } | ||
| } | ||
|
|
@@ -1006,10 +1026,7 @@ static int at_host_power_off(bool shutting_down) | |
| if (!err || shutting_down) { | ||
|
|
||
| /* Power off UART module */ | ||
| err = pm_device_action_run(slm_uart_dev, PM_DEVICE_ACTION_SUSPEND); | ||
| if (err == -EALREADY) { | ||
| err = 0; | ||
| } | ||
| err = set_uart_dev_power_state(false); | ||
| if (err) { | ||
| LOG_WRN("Failed to suspend UART. (%d)", err); | ||
| if (!shutting_down) { | ||
|
|
@@ -1033,9 +1050,9 @@ int slm_at_host_power_off(void) | |
|
|
||
| int slm_at_host_power_on(void) | ||
| { | ||
| const int err = pm_device_action_run(slm_uart_dev, PM_DEVICE_ACTION_RESUME); | ||
| const int err = set_uart_dev_power_state(true); | ||
|
|
||
| if (err && err != -EALREADY) { | ||
| if (err) { | ||
| LOG_ERR("Failed to resume UART. (%d)", err); | ||
| return err; | ||
| } | ||
|
|
@@ -1047,6 +1064,11 @@ int slm_at_host_power_on(void) | |
| return 0; | ||
| } | ||
|
|
||
| bool slm_uart_dev_is_active(void) | ||
| { | ||
| return slm_uart_dev_active; | ||
| } | ||
|
|
||
| void slm_at_host_uninit(void) | ||
| { | ||
| k_mutex_lock(&mutex_mode, K_FOREVER); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -703,7 +703,6 @@ static void ppp_data_passing_thread(void*, void*, void*) | |
| { | ||
| const size_t mtu = net_if_get_mtu(ppp_iface); | ||
| struct zsock_pollfd fds[PPP_FDS_COUNT]; | ||
| enum pm_device_state state = PM_DEVICE_STATE_OFF; | ||
|
|
||
| for (size_t i = 0; i != ARRAY_SIZE(fds); ++i) { | ||
| fds[i].fd = ppp_fds[i]; | ||
|
|
@@ -745,8 +744,7 @@ static void ppp_data_passing_thread(void*, void*, void*) | |
|
|
||
| /* When DL data is received from the network, check if UART is suspended */ | ||
| if (src == MODEM_FD_IDX) { | ||
| pm_device_state_get(ppp_uart_dev, &state); | ||
| if (state != PM_DEVICE_STATE_ACTIVE) { | ||
| if (!slm_uart_dev_is_active()) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this is a different UART in some use cases, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. In this case we should be checking ppp_uart_dev, which is either ncs_slm_uart or ncs_slm_ppp_uart. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That said, we are missing putting the second UART to sleep, for which there is a Jira ticket. I think that it might be reasonable to remove the changes in this file and we could implement those later. |
||
| LOG_DBG("PPP data received but UART not active"); | ||
| slm_ctrl_pin_indicate(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,5 +15,4 @@ | |
| /delete-node/ &button3; | ||
|
|
||
| &uart20 { | ||
| zephyr,pm-device-runtime-auto; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,5 +15,4 @@ | |
| /delete-node/ &button3; | ||
|
|
||
| &uart20 { | ||
| zephyr,pm-device-runtime-auto; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,5 +15,4 @@ | |
| /delete-node/ &button3; | ||
|
|
||
| &uart20 { | ||
| zephyr,pm-device-runtime-auto; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,5 +15,4 @@ | |
| /delete-node/ &button3; | ||
|
|
||
| &uart20 { | ||
| zephyr,pm-device-runtime-auto; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,5 +15,4 @@ | |
| /delete-node/ &button3; | ||
|
|
||
| &uart20 { | ||
| zephyr,pm-device-runtime-auto; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,5 +15,4 @@ | |
| /delete-node/ &button3; | ||
|
|
||
| &uart30 { | ||
| zephyr,pm-device-runtime-auto; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,5 +5,4 @@ | |
| */ | ||
|
|
||
| &uart20 { | ||
| zephyr,pm-device-runtime-auto; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,5 +5,4 @@ | |
| */ | ||
|
|
||
| &uart20 { | ||
| zephyr,pm-device-runtime-auto; | ||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,5 +5,4 @@ | |
| */ | ||
|
|
||
| &uart20 { | ||
| zephyr,pm-device-runtime-auto; | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the check here should be removed. Now we should always call
pm_device_runtime_gethere (also after we return from the suspended state), right?