diff --git a/doc/nrf/libraries/modem/modem_slm.rst b/doc/nrf/libraries/modem/modem_slm.rst index 5c2710961219..c3dddfede17d 100644 --- a/doc/nrf/libraries/modem/modem_slm.rst +++ b/doc/nrf/libraries/modem/modem_slm.rst @@ -41,13 +41,16 @@ Optionally configure the following Kconfig options based on need: * :kconfig:option:`CONFIG_MODEM_SLM_SHELL` - Enables the shell function in the Modem SLM library, which is not enabled by default. * :kconfig:option:`CONFIG_MODEM_SLM_INDICATE_PIN` - Configures the optional indicator GPIO, which is not configured by default. -The application must use Zephyr chosen nodes in devicetree to select UART device. For example: +The application must use Zephyr ``chosen`` nodes in devicetree to select UART device. +Additionally, GPIO can also be selected. +For example: .. code-block:: devicetree / { chosen { ncs,slm-uart = &uart1; + ncs,slm-gpio = &gpio0; }; }; diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index 97480434cd94..2ff00b510979 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -453,6 +453,10 @@ Modem libraries * The deprecated Kconfig option ``CONFIG_NRF_MODEM_LIB_SYS_INIT``. * The deprecated Kconfig option ``CONFIG_NRF_MODEM_LIB_IPC_IRQ_PRIO_OVERRIDE``. +* :ref:`lib_modem_slm`: + + * Changed the GPIO used to be configurable using devicetree. + * :ref:`pdn_readme` library: * Fixed a potential issue where the library tries to free the PDN context twice, causing the application to crash. diff --git a/lib/modem_slm/modem_slm.c b/lib/modem_slm/modem_slm.c index 1eb69d9231c1..1c14e7692afd 100644 --- a/lib/modem_slm/modem_slm.c +++ b/lib/modem_slm/modem_slm.c @@ -42,7 +42,11 @@ static enum at_cmd_state slm_at_state; RING_BUF_DECLARE(slm_data_rb, SLM_AT_CMD_RESPONSE_MAX_LEN); static struct k_work slm_data_work; +#if DT_HAS_CHOSEN(ncs_slm_gpio) +static const struct device *gpio_dev = DEVICE_DT_GET(DT_CHOSEN(ncs_slm_gpio)); +#else static const struct device *gpio_dev = DEVICE_DT_GET(DT_NODELABEL(gpio0)); +#endif static struct k_work_delayable gpio_wakeup_work; static slm_ind_handler_t ind_handler; @@ -59,7 +63,7 @@ static void gpio_wakeup_wk(struct k_work *work) ARG_UNUSED(work); if (gpio_pin_set(gpio_dev, CONFIG_MODEM_SLM_WAKEUP_PIN, 0) != 0) { - LOG_WRN("GPIO_0 set error"); + LOG_WRN("GPIO set error"); } LOG_DBG("Stop wake-up"); } @@ -338,7 +342,7 @@ static int gpio_init(void) err = gpio_pin_configure(gpio_dev, CONFIG_MODEM_SLM_WAKEUP_PIN, GPIO_OUTPUT_INACTIVE | GPIO_ACTIVE_LOW); if (err) { - LOG_ERR("GPIO_0 config error: %d", err); + LOG_ERR("GPIO config error: %d", err); return err; } @@ -346,19 +350,19 @@ static int gpio_init(void) err = gpio_pin_configure(gpio_dev, CONFIG_MODEM_SLM_INDICATE_PIN, GPIO_INPUT | GPIO_PULL_UP | GPIO_ACTIVE_LOW); if (err) { - LOG_ERR("GPIO_0 config error: %d", err); + LOG_ERR("GPIO config error: %d", err); return err; } gpio_init_callback(&gpio_cb, gpio_cb_func, BIT(CONFIG_MODEM_SLM_INDICATE_PIN)); err = gpio_add_callback(gpio_dev, &gpio_cb); if (err) { - LOG_WRN("GPIO_0 add callback error: %d", err); + LOG_WRN("GPIO add callback error: %d", err); } err = gpio_pin_interrupt_configure(gpio_dev, CONFIG_MODEM_SLM_INDICATE_PIN, GPIO_INT_LEVEL_LOW); if (err) { - LOG_WRN("GPIO_0 enable callback error: %d", err); + LOG_WRN("GPIO enable callback error: %d", err); } #endif @@ -447,7 +451,7 @@ int modem_slm_wake_up(void) err = gpio_pin_set(gpio_dev, CONFIG_MODEM_SLM_WAKEUP_PIN, 1); if (err) { - LOG_ERR("GPIO_0 set error: %d", err); + LOG_ERR("GPIO set error: %d", err); } else { k_work_reschedule(&gpio_wakeup_work, K_MSEC(CONFIG_MODEM_SLM_WAKEUP_TIME)); } diff --git a/samples/cellular/slm_shell/boards/nrf52840dk_nrf52840.overlay b/samples/cellular/slm_shell/boards/nrf52840dk_nrf52840.overlay index bd2f5af7325f..5cabf2d877a5 100644 --- a/samples/cellular/slm_shell/boards/nrf52840dk_nrf52840.overlay +++ b/samples/cellular/slm_shell/boards/nrf52840dk_nrf52840.overlay @@ -7,6 +7,7 @@ / { chosen { ncs,slm-uart = &uart1; + ncs,slm-gpio = &gpio0; }; }; diff --git a/samples/cellular/slm_shell/boards/nrf5340dk_nrf5340_cpuapp.overlay b/samples/cellular/slm_shell/boards/nrf5340dk_nrf5340_cpuapp.overlay index dfcddbe19243..fdbbf61fa942 100644 --- a/samples/cellular/slm_shell/boards/nrf5340dk_nrf5340_cpuapp.overlay +++ b/samples/cellular/slm_shell/boards/nrf5340dk_nrf5340_cpuapp.overlay @@ -7,6 +7,7 @@ / { chosen { ncs,slm-uart = &uart2; + ncs,slm-gpio = &gpio0; }; }; diff --git a/samples/cellular/slm_shell/boards/nrf7002dk_nrf5340_cpuapp.overlay b/samples/cellular/slm_shell/boards/nrf7002dk_nrf5340_cpuapp.overlay index dfcddbe19243..fdbbf61fa942 100644 --- a/samples/cellular/slm_shell/boards/nrf7002dk_nrf5340_cpuapp.overlay +++ b/samples/cellular/slm_shell/boards/nrf7002dk_nrf5340_cpuapp.overlay @@ -7,6 +7,7 @@ / { chosen { ncs,slm-uart = &uart2; + ncs,slm-gpio = &gpio0; }; };