Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ config SM_CMUX
config SM_CMUX_CHANNEL_COUNT
int "Number of CMUX channels"
depends on SM_CMUX
default 2
default 4
range 1 63
help
Number of channels to be used by the CMUX implementation.
Expand Down
1 change: 1 addition & 0 deletions drivers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

add_subdirectory_ifdef(CONFIG_DTR_UART dtr_uart)
add_subdirectory_ifdef(CONFIG_MODEM_NRF91SM nrf91-sm)
1 change: 1 addition & 0 deletions drivers/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@

menu "Drivers"
rsource "dtr_uart/Kconfig"
rsource "nrf91-sm/Kconfig"
endmenu
8 changes: 8 additions & 0 deletions drivers/nrf91-sm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2026 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

zephyr_library()
zephyr_library_sources(nordic_nrf91sm.c)
13 changes: 13 additions & 0 deletions drivers/nrf91-sm/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Copyright (c) 2026 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

config MODEM_NRF91SM
bool "Nordic nRF91 Serial Modem support"
default y
depends on DT_HAS_NORDIC_NRF91_SM_V2_ENABLED
select MODEM_CELLULAR
help
Modem driver for Nordic nRF91 series running
the Serial Modem application v2.0.0 or later.
71 changes: 71 additions & 0 deletions drivers/nrf91-sm/nordic_nrf91sm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <zephyr/drivers/modem/modem_cellular.h>
#include <zephyr/device.h>

MODEM_CELLULAR_COMMON_CHAT_MATCHES();

MODEM_CELLULAR_UNSOL_DEFINE(nordic_nrf91_unsol, MODEM_CELLULAR_COMMON_UNSOL_MATCHES);

MODEM_CHAT_MATCH_DEFINE(xiccid_match, "%XICCID: ", "", modem_cellular_chat_on_iccid);
MODEM_CHAT_MATCH_DEFINE(uicc_initialized, "%XSIM: 1", "", NULL);

MODEM_CHAT_SCRIPT_CMDS_DEFINE(
init_chat_script_cmds, MODEM_CHAT_SCRIPT_CMD_RESP("AT", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CMEE=1", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGSN", imei_match), MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGMM", cgmm_match), MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGMI", cgmi_match), MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGMR", cgmr_match), MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT#XCMUXURC=1", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT%XSIM=1", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT%XSIM?\rAT+CFUN=41", uicc_initialized),
MODEM_CHAT_SCRIPT_CMD_RESP("AT%XICCID", xiccid_match),
MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match), MODEM_CHAT_SCRIPT_CMD_RESP("AT+CIMI", cimi_match),
MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match), MODEM_CHAT_SCRIPT_CMD_RESP("AT%XSIM=0", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CMUX=0", ok_match));

MODEM_CHAT_SCRIPT_DEFINE(init_chat_script, init_chat_script_cmds, abort_matches,
modem_cellular_chat_callback_handler, 10);

MODEM_CHAT_SCRIPT_CMDS_DEFINE(network_cmds, MODEM_CHAT_SCRIPT_CMD_RESP("AT+CEREG=1", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CEREG?", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CFUN=1", ok_match));

MODEM_CHAT_SCRIPT_DEFINE(network_chat_script, network_cmds, abort_matches,
modem_cellular_chat_callback_handler, 10);

MODEM_CHAT_SCRIPT_CMDS_DEFINE(dial_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGDATA", connect_match));

MODEM_CHAT_SCRIPT_DEFINE(dial_chat_script, dial_chat_script_cmds, abort_matches,
modem_cellular_chat_callback_handler, 10);

MODEM_CHAT_SCRIPT_CMDS_DEFINE(shutdown_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CEREG=0", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CFUN=0", ok_match));

MODEM_CHAT_SCRIPT_DEFINE(shutdown_chat_script, shutdown_chat_script_cmds, abort_matches,
modem_cellular_chat_callback_handler, 10);

static const struct modem_cellular_config_scripts nrf91_sm_scripts = {
.init = &init_chat_script,
.network = &network_chat_script,
.dial = &dial_chat_script,
.shutdown = &shutdown_chat_script,
};

#define NRF91SM_DEVICE(inst) \
MODEM_DT_INST_PPP_DEFINE(inst, MODEM_CELLULAR_INST_NAME(ppp, inst), NULL, 98, 1500, 64); \
\
static struct modem_cellular_data MODEM_CELLULAR_INST_NAME(data, inst) = { \
.chat_delimiter = "\r\n", \
.ppp = &MODEM_CELLULAR_INST_NAME(ppp, inst), \
}; \
\
MODEM_CELLULAR_DEFINE_AND_INIT_USER_PIPES(inst, (user_pipe_0, 3), (user_pipe_1, 4)) \
\
MODEM_CELLULAR_DEFINE_INSTANCE(inst, 0, 500, 2000, 100, true, &nrf91_sm_scripts, \
&nordic_nrf91_unsol)

#define DT_DRV_COMPAT nordic_nrf91_sm_v2
DT_INST_FOREACH_STATUS_OKAY(NRF91SM_DEVICE)
#undef DT_DRV_COMPAT
22 changes: 22 additions & 0 deletions dts/bindings/nordic,nrf91-sm-v2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright (c) 2026 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

title: Nordic nRF91 Serial Modem

description: |
Nordic nRF91 series running the Serial Modem application v2.0.0 or later.
This includes the nRF91M1 module.

compatible: "nordic,nrf91-sm-v2"

include: zephyr,cellular-modem-device.yaml

properties:
zephyr,use-default-pdp-ctx:
default: 1

zephyr,mdm-reset-behavior:
default: ["toggle_on_recovery"]

autostarts:
required: true
5 changes: 5 additions & 0 deletions samples/sm_ppp_shell/boards/nrf54l15dk_nrf54l15_cpuapp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ CONFIG_SHELL_BACKEND_SERIAL_API_ASYNC=y
# For debugging purposes, enable GPIO shell commands.
CONFIG_GPIO=y
CONFIG_GPIO_SHELL=y

CONFIG_SHELL_WILDCARD=n
CONFIG_MODEM_AT_SHELL=y
CONFIG_MODEM_AT_USER_PIPE_IDX=0
CONFIG_MODEM_CMUX_MSC_FC_THRESHOLD=32
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
zephyr,console = &uart20;
zephyr,shell-uart = &uart20;
};
aliases {
modem = &modem;
};
};

/* Zephyr modem UART <-> nRF91 Serial Modem UART */
Expand All @@ -35,14 +38,15 @@

/* Nordic nRF91 Serial Modem configuration */
modem: modem {
compatible = "nordic,nrf91-slm";
compatible = "nordic,nrf91-sm-v2";
status = "okay";
mdm-ring-gpios = <&gpio1 12 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
mdm-dtr-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
zephyr,pm-device-runtime-auto;
cmux-enable-runtime-power-save;
cmux-close-pipe-on-power-save;
cmux-idle-timeout-ms = <5000>;
autostarts;
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ CONFIG_GPIO_SHELL=y

# When building for /NS, silence TFM logs to avoid conflicts with modem UART.
CONFIG_TFM_LOG_LEVEL_SILENCE=y

CONFIG_SHELL_WILDCARD=n
CONFIG_MODEM_AT_SHELL=y
CONFIG_MODEM_AT_USER_PIPE_IDX=0
CONFIG_MODEM_CMUX_MSC_FC_THRESHOLD=32
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
zephyr,console = &uart20;
zephyr,shell-uart = &uart20;
};
aliases {
modem = &modem;
};
};

/* Zephyr modem UART <-> nRF91 Serial Modem UART */
Expand All @@ -35,14 +38,15 @@

/* Nordic nRF91 Serial Modem configuration */
modem: modem {
compatible = "nordic,nrf91-slm";
compatible = "nordic,nrf91-sm-v2";
status = "okay";
mdm-ring-gpios = <&gpio1 12 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
mdm-dtr-gpios = <&gpio1 11 GPIO_ACTIVE_LOW>;
zephyr,pm-device-runtime-auto;
cmux-enable-runtime-power-save;
cmux-close-pipe-on-power-save;
cmux-idle-timeout-ms = <5000>;
autostarts;
};
};

Expand Down
Loading