drivers: modem_cellular: add nRF91 series (w/ SLM)

The nRF91 series devices, when running the Serial LTE Modem (SLM)
application starting with nRF Connect SDK 2.6.0, can now be used as
standalone modems via the generic modem_cellular driver.

A configuration to run the cellular_modem sample on the nRF9160 DK
(plugged in to another nRF91 series device running SLM) is provided.

Signed-off-by: Tomi Fontanilles <tomi.fontanilles@nordicsemi.no>
This commit is contained in:
Tomi Fontanilles 2024-02-14 10:27:55 +02:00 committed by Carles Cufí
parent c7be3bcd4f
commit 9a3dbaf993
6 changed files with 134 additions and 1 deletions

View file

@ -15,7 +15,8 @@ config MODEM_CELLULAR
depends on (DT_HAS_QUECTEL_BG95_ENABLED || DT_HAS_ZEPHYR_GSM_PPP_ENABLED || \
DT_HAS_SIMCOM_SIM7080_ENABLED || DT_HAS_U_BLOX_SARA_R4_ENABLED || \
DT_HAS_U_BLOX_SARA_R5_ENABLED || DT_HAS_SWIR_HL7800_ENABLED || \
DT_HAS_TELIT_ME910G1_ENABLED || DT_HAS_QUECTEL_EG25_G_ENABLED)
DT_HAS_TELIT_ME910G1_ENABLED || DT_HAS_QUECTEL_EG25_G_ENABLED || \
DT_HAS_NORDIC_NRF91_SLM_ENABLED)
help
This driver uses the generic 3gpp AT commands, along
with the standard protocols CMUX and PPP, to configure

View file

@ -1933,6 +1933,41 @@ MODEM_CHAT_SCRIPT_DEFINE(telit_me910g1_periodic_chat_script,
modem_cellular_chat_callback_handler, 4);
#endif
#if DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf91_slm)
MODEM_CHAT_SCRIPT_CMDS_DEFINE(nordic_nrf91_slm_init_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP_MULT("AT", allow_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CMEE=1", ok_match),
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+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#XCMUX=1", ok_match));
MODEM_CHAT_SCRIPT_DEFINE(nordic_nrf91_slm_init_chat_script, nordic_nrf91_slm_init_chat_script_cmds,
abort_matches, modem_cellular_chat_callback_handler, 10);
MODEM_CHAT_SCRIPT_CMDS_DEFINE(nordic_nrf91_slm_dial_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CFUN=4", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CFUN=1", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT#XCMUX=2", ok_match));
MODEM_CHAT_SCRIPT_DEFINE(nordic_nrf91_slm_dial_chat_script, nordic_nrf91_slm_dial_chat_script_cmds,
dial_abort_matches, modem_cellular_chat_callback_handler, 10);
MODEM_CHAT_SCRIPT_CMDS_DEFINE(nordic_nrf91_slm_periodic_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CEREG?", ok_match));
MODEM_CHAT_SCRIPT_DEFINE(nordic_nrf91_slm_periodic_chat_script,
nordic_nrf91_slm_periodic_chat_script_cmds, abort_matches,
modem_cellular_chat_callback_handler, 4);
#endif
#define MODEM_CELLULAR_INST_NAME(name, inst) \
_CONCAT(_CONCAT(_CONCAT(name, _), DT_DRV_COMPAT), inst)
@ -2169,6 +2204,34 @@ MODEM_CHAT_SCRIPT_DEFINE(telit_me910g1_periodic_chat_script,
&MODEM_CELLULAR_INST_NAME(config, inst), POST_KERNEL, 99, \
&modem_cellular_api);
#define MODEM_CELLULAR_DEVICE_NORDIC_NRF91_SLM(inst) \
MODEM_PPP_DEFINE(MODEM_CELLULAR_INST_NAME(ppp, inst), NULL, 98, 1500, 1500); \
\
static struct modem_cellular_data MODEM_CELLULAR_INST_NAME(data, inst) = { \
.chat_delimiter = "\r\n", \
.ppp = &MODEM_CELLULAR_INST_NAME(ppp, inst), \
}; \
\
static struct modem_cellular_config MODEM_CELLULAR_INST_NAME(config, inst) = { \
.uart = DEVICE_DT_GET(DT_INST_BUS(inst)), \
.power_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, mdm_power_gpios, {}), \
.reset_gpio = GPIO_DT_SPEC_INST_GET_OR(inst, mdm_reset_gpios, {}), \
.power_pulse_duration_ms = 100, \
.reset_pulse_duration_ms = 100, \
.startup_time_ms = 2000, \
.shutdown_time_ms = 3000, \
.init_chat_script = &nordic_nrf91_slm_init_chat_script, \
.dial_chat_script = &nordic_nrf91_slm_dial_chat_script, \
.periodic_chat_script = &nordic_nrf91_slm_periodic_chat_script, \
}; \
\
PM_DEVICE_DT_INST_DEFINE(inst, modem_cellular_pm_action); \
\
DEVICE_DT_INST_DEFINE(inst, modem_cellular_init, PM_DEVICE_DT_INST_GET(inst), \
&MODEM_CELLULAR_INST_NAME(data, inst), \
&MODEM_CELLULAR_INST_NAME(config, inst), POST_KERNEL, 99, \
&modem_cellular_api);
#define DT_DRV_COMPAT quectel_bg95
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_QUECTEL_BG95)
#undef DT_DRV_COMPAT
@ -2200,3 +2263,7 @@ DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_SWIR_HL7800)
#define DT_DRV_COMPAT telit_me910g1
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_TELIT_ME910G1)
#undef DT_DRV_COMPAT
#define DT_DRV_COMPAT nordic_nrf91_slm
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_NORDIC_NRF91_SLM)
#undef DT_DRV_COMPAT

View file

@ -0,0 +1,9 @@
description: Nordic nRF91 series running the Serial LTE Modem application
compatible: "nordic,nrf91-slm"
include: uart-device.yaml
properties:
mdm-power-gpios:
type: phandle-array

View file

@ -0,0 +1,16 @@
CONFIG_UART_ASYNC_API=y
# Align with the Serial LTE Modem (SLM) application.
CONFIG_MODEM_CELLULAR_CMUX_MAX_FRAME_SIZE=1500
CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES=1500
# Allow large UART TXs to go through @115200.
CONFIG_MODEM_BACKEND_UART_ASYNC_TRANSMIT_TIMEOUT_MS=200
# Prevent sockets getting offloaded to the modem.
CONFIG_NET_SOCKETS_OFFLOAD=n
# Print logs and printk() output on uart0.
CONFIG_LOG=y
CONFIG_LOG_BACKEND_UART=y
CONFIG_MODEM_LOG_LEVEL_DBG=y

View file

@ -0,0 +1,34 @@
/ {
aliases {
modem = &modem;
};
};
&uart1 {
compatible = "nordic,nrf-uarte";
current-speed = <115200>;
hw-flow-control;
status = "okay";
pinctrl-0 = <&uart1_default_alt>;
modem: modem {
compatible = "nordic,nrf91-slm";
status = "okay";
mdm-power-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
};
};
&pinctrl {
uart1_default_alt: uart1_default_alt {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 11)>;
bias-pull-up;
};
group2 {
psels = <NRF_PSEL(UART_TX, 0, 10)>,
<NRF_PSEL(UART_RTS, 0, 12)>,
<NRF_PSEL(UART_CTS, 0, 13)>;
};
};
};

View file

@ -70,3 +70,9 @@ test_telit_me910g1: telit_me910g1 {
test_esp_at: esp_at {
compatible = "espressif,esp-at";
};
test_nordic_nrf91_slm: nordic_nrf91_slm {
compatible = "nordic,nrf91-slm";
mdm-power-gpios = <&test_gpio 0 0>;
};