Skip to content

drivers: modem: generalize Quectel BG9X support #93105

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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 boards/rakwireless/rak5010/rak5010_nrf52840.dts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
pinctrl-1 = <&uart0_sleep>;
pinctrl-names = "default", "sleep";
modem: modem {
compatible = "quectel,bg95";
compatible = "quectel,bg9x";
mdm-power-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
status = "okay";
};
Expand Down
1 change: 0 additions & 1 deletion drivers/modem/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ config MODEM_CELL_INFO
Query for numerical operator id, location area code and cell id.

source "drivers/modem/Kconfig.ublox-sara-r4"
source "drivers/modem/Kconfig.quectel-bg9x"
source "drivers/modem/Kconfig.wncm14a2a"
source "drivers/modem/Kconfig.cellular"
source "drivers/modem/Kconfig.at_shell"
Expand Down
2 changes: 1 addition & 1 deletion drivers/modem/Kconfig.cellular
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ config MODEM_CELLULAR
select NET_L2_PPP_OPTION_MRU
select NET_L2_PPP_PAP
select NET_L2_PPP_MGMT
depends on (DT_HAS_QUECTEL_BG95_ENABLED || DT_HAS_SIMCOM_A76XX_ENABLED || \
depends on (DT_HAS_QUECTEL_BG9X_ENABLED || DT_HAS_SIMCOM_A76XX_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_TELIT_ME310G1_ENABLED || \
Expand Down
3 changes: 2 additions & 1 deletion drivers/modem/Kconfig.quectel-bg9x
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
# SPDX-License-Identifier: Apache-2.0

config MODEM_QUECTEL_BG9X
bool "Quectel modem driver"
bool "Quectel modem driver [ DEPRECATED ]"
select MODEM_CONTEXT
select MODEM_CMD_HANDLER
select MODEM_IFACE_UART
select MODEM_SOCKET
select NET_SOCKETS_OFFLOAD
select DEPRECATED
help
Choose this setting to enable quectel BG9x LTE-CatM1/NB-IoT modem
driver.
Expand Down
30 changes: 15 additions & 15 deletions drivers/modem/modem_cellular.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ MODEM_CHAT_MATCHES_DEFINE(dial_abort_matches,

#if DT_HAS_COMPAT_STATUS_OKAY(swir_hl7800) || DT_HAS_COMPAT_STATUS_OKAY(sqn_gm02s) || \
DT_HAS_COMPAT_STATUS_OKAY(quectel_eg800q) || DT_HAS_COMPAT_STATUS_OKAY(quectel_eg25_g) || \
DT_HAS_COMPAT_STATUS_OKAY(quectel_bg95) || DT_HAS_COMPAT_STATUS_OKAY(simcom_a76xx)
DT_HAS_COMPAT_STATUS_OKAY(quectel_bg9x) || DT_HAS_COMPAT_STATUS_OKAY(simcom_a76xx)
MODEM_CHAT_MATCH_DEFINE(connect_match, "CONNECT", "", NULL);
#endif

Expand Down Expand Up @@ -1939,8 +1939,8 @@ static int modem_cellular_init(const struct device *dev)
* dial out and put the DLCI channel into data mode.
*/

#if DT_HAS_COMPAT_STATUS_OKAY(quectel_bg95)
MODEM_CHAT_SCRIPT_CMDS_DEFINE(quectel_bg95_init_chat_script_cmds,
#if DT_HAS_COMPAT_STATUS_OKAY(quectel_bg9x)
MODEM_CHAT_SCRIPT_CMDS_DEFINE(quectel_bg9x_init_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP("ATE0", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CFUN=4", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CMEE=1", ok_match),
Expand All @@ -1964,27 +1964,27 @@ MODEM_CHAT_SCRIPT_CMDS_DEFINE(quectel_bg95_init_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP("", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP_NONE("AT+CMUX=0,0,5,127", 300));

MODEM_CHAT_SCRIPT_DEFINE(quectel_bg95_init_chat_script, quectel_bg95_init_chat_script_cmds,
MODEM_CHAT_SCRIPT_DEFINE(quectel_bg9x_init_chat_script, quectel_bg9x_init_chat_script_cmds,
abort_matches, modem_cellular_chat_callback_handler, 10);

MODEM_CHAT_SCRIPT_CMDS_DEFINE(quectel_bg95_dial_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMDS_DEFINE(quectel_bg9x_dial_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP_MULT("AT+CGACT=0,1", allow_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGDCONT=1,\"IP\","
"\""CONFIG_MODEM_CELLULAR_APN"\"",
ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CFUN=1", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("ATD*99***1#", connect_match));

MODEM_CHAT_SCRIPT_DEFINE(quectel_bg95_dial_chat_script, quectel_bg95_dial_chat_script_cmds,
MODEM_CHAT_SCRIPT_DEFINE(quectel_bg9x_dial_chat_script, quectel_bg9x_dial_chat_script_cmds,
dial_abort_matches, modem_cellular_chat_callback_handler, 10);

MODEM_CHAT_SCRIPT_CMDS_DEFINE(quectel_bg95_periodic_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMDS_DEFINE(quectel_bg9x_periodic_chat_script_cmds,
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CREG?", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CEREG?", ok_match),
MODEM_CHAT_SCRIPT_CMD_RESP("AT+CGREG?", ok_match));

MODEM_CHAT_SCRIPT_DEFINE(quectel_bg95_periodic_chat_script,
quectel_bg95_periodic_chat_script_cmds, abort_matches,
MODEM_CHAT_SCRIPT_DEFINE(quectel_bg9x_periodic_chat_script,
quectel_bg9x_periodic_chat_script_cmds, abort_matches,
modem_cellular_chat_callback_handler, 4);
#endif

Expand Down Expand Up @@ -2652,7 +2652,7 @@ MODEM_CHAT_SCRIPT_DEFINE(sqn_gm02s_periodic_chat_script,
&MODEM_CELLULAR_INST_NAME(config, inst), POST_KERNEL, 99, \
&modem_cellular_api);

#define MODEM_CELLULAR_DEVICE_QUECTEL_BG95(inst) \
#define MODEM_CELLULAR_DEVICE_QUECTEL_BG9X(inst) \
MODEM_PPP_DEFINE(MODEM_CELLULAR_INST_NAME(ppp, inst), NULL, 98, 1500, 64); \
\
static struct modem_cellular_data MODEM_CELLULAR_INST_NAME(data, inst) = { \
Expand All @@ -2667,9 +2667,9 @@ MODEM_CHAT_SCRIPT_DEFINE(sqn_gm02s_periodic_chat_script,
\
MODEM_CELLULAR_DEFINE_INSTANCE(inst, 1500, 100, 10000, 5000, false, \
NULL, \
&quectel_bg95_init_chat_script, \
&quectel_bg95_dial_chat_script, \
&quectel_bg95_periodic_chat_script, NULL)
&quectel_bg9x_init_chat_script, \
&quectel_bg9x_dial_chat_script, \
&quectel_bg9x_periodic_chat_script, NULL)

#define MODEM_CELLULAR_DEVICE_QUECTEL_EG25_G(inst) \
MODEM_PPP_DEFINE(MODEM_CELLULAR_INST_NAME(ppp, inst), NULL, 98, 1500, 64); \
Expand Down Expand Up @@ -2899,8 +2899,8 @@ MODEM_CHAT_SCRIPT_DEFINE(sqn_gm02s_periodic_chat_script,
&sqn_gm02s_dial_chat_script, \
&sqn_gm02s_periodic_chat_script, NULL)

#define DT_DRV_COMPAT quectel_bg95
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_QUECTEL_BG95)
#define DT_DRV_COMPAT quectel_bg9x
DT_INST_FOREACH_STATUS_OKAY(MODEM_CELLULAR_DEVICE_QUECTEL_BG9X)
#undef DT_DRV_COMPAT

#define DT_DRV_COMPAT quectel_eg25_g
Expand Down
12 changes: 0 additions & 12 deletions dts/bindings/modem/quectel,bg95.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions dts/bindings/modem/quectel,bg9x.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2020 Analog Life LLC
# Copyright (c) 2023 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0

description: quectel BG9x modem
Expand All @@ -10,7 +10,6 @@ include: uart-device.yaml
properties:
mdm-power-gpios:
type: phandle-array
required: true

mdm-reset-gpios:
type: phandle-array
Expand Down
2 changes: 1 addition & 1 deletion samples/net/cellular_modem/boards/b_u585i_iot02a.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
status = "okay";

modem: modem {
compatible = "quectel,bg95";
compatible = "quectel,bg9x";
mdm-power-gpios = <&gpioe 2 GPIO_ACTIVE_HIGH>;
status = "okay";
};
Expand Down
2 changes: 1 addition & 1 deletion subsys/modem/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if MODEM_CMUX

config MODEM_CMUX_DEFAULT_MTU_127
bool
default y if (DT_HAS_QUECTEL_BG95_ENABLED || DT_HAS_QUECTEL_EG25_G_ENABLED || \
default y if (DT_HAS_QUECTEL_BG9X_ENABLED || DT_HAS_QUECTEL_EG25_G_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_TELIT_ME310G1_ENABLED || \
Expand Down
Loading