Skip to content

Commit cddc5e1

Browse files
committed
Add SLM optimized modem UART backend.
To be combined with 43b455c. Signed-off-by: Markus Lassila <[email protected]>
1 parent 43b455c commit cddc5e1

File tree

5 files changed

+551
-24
lines changed

5 files changed

+551
-24
lines changed

drivers/modem/Kconfig.cellular

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,4 @@ config MODEM_CELLULAR_NEW_BAUDRATE_DELAY
6464
default 100 if DT_HAS_U_BLOX_LARA_R6_ENABLED
6565
default 300
6666

67-
config MODEM_CELLULAR_USE_MODEM_BACKEND_UART_SLM
68-
bool "Use the SLM optimized modem UART backend"
69-
depends on MODEM_BACKEND_UART_SLM
70-
default y
71-
7267
endif

drivers/modem/modem_cellular.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
#include <zephyr/modem/pipe.h>
1515
#include <zephyr/modem/pipelink.h>
1616
#include <zephyr/modem/ppp.h>
17-
#if CONFIG_MODEM_CELLULAR_USE_MODEM_BACKEND_UART_SLM
18-
#include <zephyr/modem/backend/uart_slm.h>
19-
#else
2017
#include <zephyr/modem/backend/uart.h>
21-
#endif
2218
#include <zephyr/net/ppp.h>
2319
#include <zephyr/pm/device.h>
2420
#include <zephyr/sys/atomic.h>
@@ -90,13 +86,7 @@ enum modem_cellular_event {
9086
struct modem_cellular_data {
9187
/* UART backend */
9288
struct modem_pipe *uart_pipe;
93-
#if CONFIG_MODEM_CELLULAR_USE_MODEM_BACKEND_UART_SLM
94-
#include <zephyr/modem/backend/uart_slm.h>
95-
struct modem_backend_uart_slm uart_backend;
96-
#else
9789
struct modem_backend_uart uart_backend;
98-
#endif
99-
10090
uint8_t uart_backend_receive_buf[CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES];
10191
uint8_t uart_backend_transmit_buf[CONFIG_MODEM_CELLULAR_UART_BUFFER_SIZES];
10292

@@ -1826,11 +1816,6 @@ static int modem_cellular_init(const struct device *dev)
18261816
gpio_pin_configure_dt(&config->reset_gpio, GPIO_OUTPUT_ACTIVE);
18271817
}
18281818

1829-
#if CONFIG_MODEM_CELLULAR_USE_MODEM_BACKEND_UART_SLM
1830-
{
1831-
/* TODO modem_cellular_modem_backend_uart_slm_init() here */
1832-
}
1833-
#else
18341819
{
18351820
const struct modem_backend_uart_config uart_backend_config = {
18361821
.uart = config->uart,
@@ -1845,7 +1830,6 @@ static int modem_cellular_init(const struct device *dev)
18451830

18461831
data->cmd_pipe = NULL;
18471832
}
1848-
#endif
18491833

18501834
{
18511835
const struct modem_cmux_config cmux_config = {

include/zephyr/modem/backend/uart_slm.h

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,39 @@
1616
extern "C" {
1717
#endif
1818

19-
struct modem_backend_uart_slm {
19+
struct rx_queue_event {
20+
uint8_t *buf;
21+
size_t len;
22+
};
2023

24+
struct modem_backend_uart_slm {
25+
const struct device *uart;
26+
struct modem_pipe pipe;
27+
struct k_work_delayable receive_ready_work;
28+
struct k_work transmit_idle_work;
29+
30+
#if CONFIG_MODEM_STATS
31+
struct modem_stats_buffer receive_buf_stats;
32+
struct modem_stats_buffer transmit_buf_stats;
33+
#endif
34+
struct ring_buf transmit_rb;
35+
struct k_work rx_disabled_work;
36+
atomic_t state;
37+
38+
struct k_mem_slab rx_slab;
39+
struct k_msgq rx_queue;
40+
struct rx_queue_event rx_event;
41+
struct rx_queue_event rx_queue_buf[CONFIG_MODEM_BACKEND_UART_SLM_BUFFER_COUNT];
42+
uint32_t rx_buf_size;
43+
uint8_t rx_buf_count;
2144
};
2245

2346
struct modem_backend_uart_slm_config {
24-
47+
const struct device *uart;
48+
uint8_t *receive_buf; /* Address must be word-aligned. */
49+
uint32_t receive_buf_size;
50+
uint8_t *transmit_buf;
51+
uint32_t transmit_buf_size;
2552
};
2653

2754
struct modem_pipe *modem_backend_uart_slm_init(struct modem_backend_uart_slm *backend,

subsys/modem/backends/Kconfig

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,28 @@ endif # MODEM_BACKEND_UART_ASYNC_HWFC
6363

6464
endif # MODEM_BACKEND_UART_ASYNC
6565

66+
endif # MODEM_BACKEND_UART
67+
6668
config MODEM_BACKEND_UART_SLM
6769
bool "SLM optimized modem UART backend"
70+
default n
71+
select MODEM_PIPE
72+
select RING_BUFFER
6873
depends on UART_ASYNC_API
6974

70-
endif # MODEM_BACKEND_UART
75+
if MODEM_BACKEND_UART_SLM
76+
77+
config MODEM_BACKEND_UART_SLM_BUFFER_COUNT
78+
int "SLM modem UART backend buffer count"
79+
range 2 4
80+
default 3
81+
82+
config MODEM_BACKEND_UART_SLM_TRANSMIT_TIMEOUT_MS
83+
int "SLM modem UART transmit timeout in milliseconds"
84+
default 1000
85+
86+
config MODEM_BACKEND_UART_SLM_RECEIVE_IDLE_TIMEOUT_MS
87+
int "SLM modem UART receive idle timeout in milliseconds"
88+
default 30
89+
90+
endif # MODEM_BACKEND_UART_SLM

0 commit comments

Comments
 (0)