Commit Graph

11 Commits

Author SHA1 Message Date
Guillaume Lager ec0d5b6e8d driver: modem: Fix mux device name comparison
CONFIG_UART_MUX_DEVICE_NAME is used as a prefix for the uart muxes
name. Pointer comparison will always return false

Fix #39774

Signed-off-by: Guillaume Lager <g.lager@innoseis.com>
2021-11-06 10:20:42 -04:00
Marcin Niestroj 26bd4fb45e drivers: modem: operate on device pointers instead of names
So far modem API used UART device names / labels. Change API to operate
on device pointers instead, so that we stop using device_get_binding()
in modem core and in some DT compatible modem drivers.

Signed-off-by: Marcin Niestroj <m.niestroj@emb.dev>
2021-07-15 11:48:00 -04:00
Benjamin Lindqvist 449fc7bb1c net: ppp: Avoid wrapping each byte in muxing headers
When PPP is muxed, using uart_poll_out resulted in each byte getting
wrapped in a muxing header. This led to UART bombardment which
can quickly cause some modems to hang and panic. This was observed
regularly using a SIMCOM7600E modem.

A perfect fix would involve rewriting ppp.c, uart_mux.c and
modem_iface_uart.c to all use another UART API, but that would be more
invasive by several orders of magnitude than this one, which utilizes
the fact that the uart_mux implementation of uart_fifo_fill does NOT
require ISR context. Since the Zephyr UART API states that the behavior
of uart_fifo_fill outside of ISR context is implementation defined, this
should be kosher.

Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
2020-10-19 18:29:02 +02:00
Benjamin Lindqvist 54cb2bcd41 drivers: modem: gsm_ppp: Enable start/stop
These changes enable applications to restart the networking stack which
was previously not possible without rebooting the device. This was a
major show-stopper because it made power management impossible, and
furthermore made it impossible to recover from a bad modem state without
rebooting.

This has been verified to work on a SIMCOM7600E modem, both with and
without CONFIG_GSM_MUX enabled.

Signed-off-by: Benjamin Lindqvist <benjamin.lindqvist@endian.se>
2020-10-19 18:29:02 +02:00
Marcin Niestroj 05eb9644dc modem: iface_uart: improve RX flow with HW flow control
So far all received bytes over UART where blindly drained and pushed to
ring_buf. This approach is okay for UART devices without configured HW
flow control, as it basically decouples data processing from ISR handler
and gives more time before data overrun. However when HW flow control
is enabled, such behavior somehow suppresses UART flow control
advantage, because data can overrun when pushing to ring_buf.

Allow drivers utilizing modem_context framework to pass information
about whether HW flow control is enabled or not. If it is enabled, then
read data from UART FIFO to the point when RX ring_buf is totally filled
and follow such situation by disabling RX interrupt. Incoming data will
be paused on HW level, so there is lots of time for RX thread to process
ring_buf content. Reenable RX interrupts after all data in ring_buf is
processed, so that number of context switches is kept at minimum level.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-05 17:04:52 +03:00
Marcin Niestroj 763bd27c75 modem: iface_uart: use ring_buf_{claim,finish} API
This API allows to drop use of preallocated isr_buf. Most importantly as
a result RAM usage is reduced for each driver utilizing modem_context
framework. Additionally there is less copying done in ISR context, as
data is direcly read from UART FIFO to ring_buf.

Signed-off-by: Marcin Niestroj <m.niestroj@grinn-global.com>
2020-10-05 17:04:52 +03:00
Tomasz Bursztyka e18fcbba5a device: Const-ify all device driver instance pointers
Now that device_api attribute is unmodified at runtime, as well as all
the other attributes, it is possible to switch all device driver
instance to be constant.

A coccinelle rule is used for this:

@r_const_dev_1
  disable optional_qualifier
@
@@
-struct device *
+const struct device *

@r_const_dev_2
 disable optional_qualifier
@
@@
-struct device * const
+const struct device *

Fixes #27399

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-09-02 13:48:13 +02:00
Tomasz Bursztyka 7d1af02410 uart: Fix uart_irq_callback_set usage
It was already using uart_irq_callback_user_data_set below, now it also
uses uart_irq_callback_user_data_t as callback type, so let's normalize
the callbacks.

Fixes #26923

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-07-30 09:43:12 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Jukka Rissanen 775dcb222e modem: gsm: Initialize the modem UART separately
This is needed if muxing is enabled in which case we must
change the UART to muxing UART after the AT+CMUX command
has succeed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
2020-04-17 10:15:54 +03:00
Michael Scott d56a05f7a7 drivers: modem: interface: introduce UART interface driver layer
The UART-based modem interface layer implements the modem context
interface for Zephyr's UART APIs.  This driver closely resembles
the existing modem receiver, but conforming to the modem interface
agreements.

Example modem driver setup code looks like this:

/* create modem context object */
static struct modem_context mctx;

/* create uart interface data object and buffers */
static struct modem_iface_uart_data iface_data;
static u8_t iface_isr_buf[MDM_RECV_BUF_SIZE];
static u8_t iface_rb_buf[MDM_MAX_DATA_LENGTH];

iface_data.isr_buf = &iface_isr_buf[0];
iface_data.isr_buf_len = sizeof(iface_isr_buf);
iface_data.rx_rb_buf = &iface_rb_buf[0];
iface_data.rx_rb_buf_len = sizeof(iface_rb_buf);
ret = modem_iface_uart_init(&mctx.iface, &iface_data,
			    UART_DEV_NAME);

Signed-off-by: Michael Scott <mike@foundries.io>
2019-08-10 00:03:39 +02:00