Commit graph

23353 commits

Author SHA1 Message Date
Adrien Ricciardi
4824e405cf drivers: i2c: i2c_dw: Fixed integer overflow in i2c_dw_data_ask().
The controller can implement a reception FIFO as deep as 256 bytes.
However, the computation made by the driver code to determine how many
bytes can be asked is stored in a signed 8-bit variable called rx_empty.

If the reception FIFO depth is greater or equal to 128 bytes and the FIFO
is currently empty, the rx_empty value will be 128 (or more), which
stands for a negative value as the variable is signed.

Thus, the later code checking if the FIFO is full will run while it should
not and exit from the i2c_dw_data_ask() function too early.

This hangs the controller in an infinite loop of interrupt storm because
the interrupt flags are never cleared.

Storing the rx_empty empty on a signed 32-bit variable instead of a 8-bit
one solves the issue and is compliant with the controller hardware
specifications of a maximum FIFO depth of 256 bytes.

It has been agreed with upstream maintainers to change the type of the
variables tx_empty, rx_empty, cnt, rx_buffer_depth and tx_buffer_depth to
plain int because it is most effectively handled by the CPUs. Using 8-bit
or 16-bit variables had no meaning here.

Signed-off-by: Adrien Ricciardi <aricciardi@baylibre.com>
2024-01-08 20:57:05 -06:00
Manuel Argüelles
fa0b1b5fe8 drivers: can: flexcan: add support for S32K1xx
Add message buffer allowed values for S32K1xx devices. Except S32K14xW
parts which supports 64 MBs, the rest of the parts support a maximum of
32 MBs.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2024-01-08 08:30:49 -06:00
Yuval Peress
5edc45421a icm42688: Capture the spi return value
Handle the return value of the spi transaction.

Fixes #58582

Signed-off-by: Yuval Peress <peress@google.com>
2024-01-08 15:09:42 +01:00
Yuval Peress
3f2d6efc9c icm42688: Remove unnecessary locks
The entire switch statement is already wrapped in a lock which is
acquired just before configuring the gpio pin.

Signed-off-by: Yuval Peress <peress@google.com>
2024-01-08 15:09:42 +01:00
Bartosz Bilas
7213e8e1f5 drivers: regulator: max20335: allow current limit operations only for BUCKs
LDOs don't have such possibility so add the extra checks.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2024-01-08 14:16:55 +01:00
Bryan Zhu
6a64bf6b4f drivers: counter: counter_ambiq_timer: Enable interrupt in set_alarm
Alarm interrupt is disabled in cancel_alarm, we should re-enable it
in set_alarm, at meanwhile, should reset the compare register in
cancel_alarm to avoid the contention condition in
cancel_alarm & set_alarm in short time.
This change fixes the test case failure at
zephyr\tests\drivers\counter\counter_basic_api.

Signed-off-by: Bryan Zhu <bzhu@ambiq.com>
2024-01-08 14:16:13 +01:00
Hudson C. Dalpra
410684c7b0 drivers: w1: add zephyr-gpio driver
The zephyr-gpio w1 driver introduced in this commit implements
all routines for the w1 api on top of the zephyr gpio driver.
W1 bit read, write, and reset operations are executed by
bit-banging the selected gpio.

Signed-off-by: Hudson C. Dalpra <hudson@bduncanltd.com>
2024-01-08 12:43:52 +01:00
Yong Cong Sin
dd7193e491 drivers: intc: plic: simplify the handling of the irq_count array
Store the compile-time computed length of the `irq_count` into
a variable so that we have less to do in runtime.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-01-08 12:35:52 +01:00
Yong Cong Sin
310c4539e9 drivers: intc: plic: fix compilation warning
Change the index variable type to `int` from `size_t` to compile
across 32bit and 64bit platforms without generating warnings.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
2024-01-08 12:35:52 +01:00
Dawid Niedzwiecki
164e4b6fa3 clock_control: stm32f4: add PLLR division factor
Some STM32F4xx chips have an R division factor in PLL. Add possibility
to configure that.

Even though the output from the R division is not used, it can be
increased to reduce power consumption.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-01-08 12:33:36 +01:00
Chamira Perera
0d4b46f51c drivers: ethernet: stm32: Enabling HW checksum offloading for STM32H7.
This change adds support for enabling ethernet MAC hardware checksum
offloading for STM32H7 based devices.

In Section 58.5.9 of the STM32H7 reference manual it mentions that
the STM32H7 ethernet MAC supports a Checksum Offload Module (COE).

I have tested the changes on my end where I enabled
CONFIG_ETH_STM32_HW_CHECKSUM and ensured that an application that
runs Zephyr on the STM32H7 can interoperate with a device with a
completely different implementation. Also, I deliberately made
the software not populate the IPv4 and UDP header checksum fields
in their respective headers and the COE was able to populate the
IPv4 and UDP header checksums.

Given that CONFIG_ETH_STM32_HW_CHECKSUM is not enabled by default
application developers have the option to either enable it or
disable it.

Signed-off-by: Chamira Perera <chamira.perera@audinate.com>
2024-01-08 12:33:17 +01:00
Alexander Kozhinov
d6ebf1efa8 drivers: clock_control: clock_stm32_ll_h7.c
Reduce code-complexity of stm32_clock_control_init() function, which is
used and exists for both M4/M7 cores.
Replace dublicated code by proper preprocessor guarding.
This change shall reduce code-errors and copy-paste errors since same
functional code is present only once now.
Identify even more common code

Signed-off-by: Alexander Kozhinov <ak.alexander.kozhinov@gmail.com>
2024-01-08 11:49:04 +01:00
Dawid Niedzwiecki
1c0302d2fc drivers: gpio: stm32: fix init power state
Set suspended as initial power state, only when the
CONFIG_PM_DEVICE_RUNTIME config is enabled.

The initial state was incorrect, when CONFIG_PM_DEVICE=y and
CONFIG_PM_DEVICE_RUNTIME=n. In that case, the power state was SUSPENDED,
but the device was actually enabled.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
2024-01-08 11:48:58 +01:00
Jakub Zymelka
ade49f081d modules: hal_nordic: nrfx: update API version to 3.2.0
Updated API version enables multi-instance GPIOTE driver.
Additionally obsolete symbol that was used to specify
API version in the past was removed.
Affected drivers have been adjusted and appropriate changes
in affected files have been made.

Signed-off-by: Jakub Zymelka <jakub.zymelka@nordicsemi.no>
2024-01-08 11:19:37 +01:00
Francois Ramu
fff24fee14 drivers: usb: stm32U5 usb device controller
Like the stm32H5, stm32u5 usb device has an independent
power supply, but control bit is PWR_SVMCR_USV.
The control bit for the stm32H5 is PWR_USBSCR_USB33SV (no change)

Signed-off-by: Francois Ramu <francois.ramu@st.com>
2024-01-08 10:58:42 +01:00
Fabio Baltieri
bba517fa14 input: tweak actual-key-mask description
Tweak the actual-key-mask description, apply some leftover feedback from
the prevoius PR.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-08 10:23:53 +01:00
Bryan Zhu
a417392f76 timer: ambiq_stimer: Correct set_timeout's delta clock calculation
In sys_clock_set_timeout(), input "ticks" is used to compute next
timeout point, Ambiq's STimer API used to sets next timeout has input
parameter as ui32Delta, which inside the API is using
"this value to add to the STimer counter and load into the comparator
register" according to its spec, thus the this delta clock is
almost equivalent to input "ticks"'s concept, and is not related to
last_count, it should be computed directly from input "ticks".
This correction fixes the test case failure at
zephyr\tests\kernel\tickless\tickless_concept.

Signed-off-by: Bryan Zhu <bzhu@ambiq.com>
2024-01-08 10:07:46 +01:00
Jakob Krantz
ccd843ecbd driver: display: sdl: Fix input together with SDL_DISPLAY_ZOOM_PCT
Using SDL_DISPLAY_ZOOM_PCT would cause mouse pointer/touch input
to not click at the correct position.

Signed-off-by: Jakob Krantz <mail@jakobkrantz.se>
2024-01-07 20:08:13 -05:00
Bartosz Bilas
7ef10d0f71 drivers: regulator: add regulator-init-microamp property
It allows setting regulator current value during driver
initialization automatically.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2024-01-05 09:07:10 +01:00
Pisit Sawangvonganan
3ffcd75469 drivers: spi: set 'spi_driver_api' as 'static const'
This change marks each instance of the 'spi_driver_api' as 'static const'.
The rationale is that 'spi_driver_api' is used for declaring internal
module interfaces and is not intended to be modified at runtime.
By using 'static const', we ensure immutability, leading to usage of only
.rodata and a reduction in the .data area.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-05 09:04:51 +01:00
Pisit Sawangvonganan
80e1482ddd drivers: ieee802154: set 'ieee802154_radio_api' as 'static const'
This change marks each instance of the 'api' as 'static const'.
The rationale is that 'api' is used for declaring internal
module interfaces and is not intended to be modified at runtime.
By using 'static const', we ensure immutability, leading to usage of only
.rodata and a reduction in the .data area.

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
2024-01-05 09:04:28 +01:00
Eduardo Montoya
586eca8ad2 drivers: ieee802154: nrf5: add IEEE802154_RX_ON_WHEN_IDLE capability
Add `IEEE802154_RX_ON_WHEN_IDLE` capability.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
2024-01-05 09:04:17 +01:00
Eduardo Montoya
780b12854c drivers: ieee802154: nrf: cache radio channel
Cache configured radio channel and apply them only when a relevant
radio task is requested.

This allows to configure the channel in the transmit metadata, thus
avoiding unneeded `nrf_802154` API calls in some scenarios.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2024-01-05 09:04:17 +01:00
Eduardo Montoya
5767998d4f drivers: ieee802154: nrf: make selective tx power the default
Remove `IEEE802154_SELECTIVE_TXPOWER` option.

Cache the tx power value in nRF5 driver and make use of it on each
operation.

Signed-off-by: Eduardo Montoya <eduardo.montoya@nordicsemi.no>
Signed-off-by: Jędrzej Ciupis <jedrzej.ciupis@nordicsemi.no>
2024-01-05 09:04:17 +01:00
Manuel Argüelles
35e267d649 drivers: pwm: mcux_ftm: support multiple interrupts
Rework the interrupt handlers of the FTM driver to support SoCs on
which FTM channels and overflow are routed through individual
interrupts, as opposed to a single OR'ed interrupt.

Signed-off-by: Manuel Argüelles <manuel.arguelles@nxp.com>
2024-01-05 09:03:00 +01:00
Chekhov Ma
0ce4399a03 driver: mucx_lpspi: enable runtime mmio configuration
Enable runtime mmio configuration in mcux_lpspi driver. The fsl_lpspi
driver relies on physical address to determine instance number.
So mmap flag 'K_MEM_DIRECT_MAP' is required.

Signed-off-by: Chekhov Ma <chekhov.ma@nxp.com>
2024-01-05 09:01:55 +01:00
Chekhov Ma
734adf52c6 driver: mucx_lpi2c: enable runtime mmio configuration
Enable runtime mmio configuration in mcux_lpi2c driver. The fsl_lpi2c
driver relies on physical address to determine instance number.
So mmap flag 'K_MEM_DIRECT_MAP' is required.

Signed-off-by: Chekhov Ma <chekhov.ma@nxp.com>
2024-01-05 09:01:55 +01:00
Jeppe Odgaard
ef867e4c7e drivers: spi: align dspi and lpspi spi_mcux_transfer_next_packet
Add return code to lpspi spi_mcux_transfer_next_packet and print the
kStatus_* return code since it information is lost when translated to
errno.

Signed-off-by: Jeppe Odgaard <jeppe.odgaard@prevas.dk>
2024-01-05 09:01:35 +01:00
Fabio Baltieri
e517af4cff charger: add a driver for bq25180
Add a driver for the TI BQ25180. Implement enable/disable and current
set/get.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-05 09:00:21 +01:00
Fabio Baltieri
2a99432695 input: kbd_matrix: fail gracefully if changing an undefined key mask
Add a check to input_kbd_matrix_actual_key_mask_set() to return an error
if trying to change a key mask but the device does not define a keymask
in the first place.

Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
2024-01-04 18:40:10 +00:00
George Beckstein
603c3af895 drivers: flash : stm32: STM32L4P5xx fix page calculation from offset
This fix adds the STM32L4P5xx to the list of devices that have an
offset-to-page shift calculation of 12 bits. Previously, the driver
would only shift the offset by 11 bits when calculating the page to
erase.

This would prevent the driver from erasing the correct page.

Signed-off-by: George Beckstein <george.beckstein@ampaworks.com>
2024-01-04 15:33:42 +01:00
Petr Hlineny
0ed8f10d8a drivers: rtc: stm32: Updated scope of hsem
This commit updates the scope of  hsem.

Signed-off-by: Petr Hlineny <development@hlineny.cz>
2024-01-04 15:32:47 +01:00
Petr Hlineny
784a5b82e7 drivers: rtc: stm32: Replaces Enter init mode function with LL function
Use LL_RTC_EnterInitMode and LL_RTC_DisableInitMode instead
of rtc_stm32_enter_initialization_mode and
rtc_stm32_leave_initialization_mode.

Signed-off-by: Petr Hlineny <development@hlineny.cz>
2024-01-04 15:32:47 +01:00
Petr Hlineny
4a4543569e drivers: rtc: stm32: Fixes RTC issues related to device runtime pm
When device runtime pm is enabled, Backup Domain protection is active
most of the time. RTC driver need this protection to be disabled in
order to set the time or calibration. This fix disable the protection in
set time and set calibration functions.

Fixes: 62843
Signed-off-by: Petr Hlineny <development@hlineny.cz>
2024-01-04 15:32:47 +01:00
Bartosz Bilas
cafe9a5632 drivers: regulator: max20335: fix unused-const-variable warnings
There can be a case where not all regulators are being used,
resulting in an unused-const-variable warning,
so let's add a __maybe_unused keyword to suppress it.

Signed-off-by: Bartosz Bilas <b.bilas@grinn-global.com>
2024-01-04 13:52:02 +01:00
Emil Lindqvist
ed6da68f5b i2s: stm32h7: add i2s support for stm32h7 mcu family
This commit modifies the I2S driver to work for STM32H7
family of MCU's. Currently only TX is working.

Tested on nucleo_stm32h743zi. Requires dma1 & dmamux1 to be enabled.

Signed-off-by: Emil Lindqvist <emil@lindq.gr>
2024-01-04 13:48:28 +01:00
Ali Hozhabri
ccc97125f8 drivers: bluetooth: hci: Fix uninitialized array index, issue #66806
Fix issue #66806, caused by PR #65172.

Return -EINVAL from bt_spi_get_header if op is neither SPI_READ nor
SPI_WRITE.

Signed-off-by: Ali Hozhabri <ali.hozhabri@st.com>
2024-01-04 09:42:50 +01:00
Tomas Galbicka
89bd024a1c drivers: mbox: Add nxp mbox multi-channel support
Current implementation of NXP mbox driver mbox_nxp_imx_mu
is using only one channel 0.
This commit adds support for multiple mbox channels as is
indented by mbox drivers.

Change done in .send api signaling mode leveraging provided
channel id to select correct General Purpose Interrupt.
Another change done in IRQHandler to check and handle all
channels.

Signed-off-by: Tomas Galbicka <tomas.galbicka@nxp.com>
2024-01-04 09:42:04 +01:00
Andy Sinclair
b3fdb7477b drivers: regulator: fixed: Removed pin state setting from init
The setting of initial state in handled by the common driver,
which calls the enable function for any regulator that has
regulator-boot-on set, and is not already enabled.

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
2024-01-03 18:59:12 +00:00
Fabian Pflug
3c0a6058b5 drivers: pwm: stm32: Catch overflows in 2-channel capture
When not using 4 channel capture, overflows were never reported
to the application, because the check was in the
four_channel_capture_support branch.

Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
2024-01-03 12:55:50 +01:00
Henrik Brix Andersen
bc2826c1cb drivers: gpio: pca953x: check return values from I2C API functions
Check the return values from the I2C API functions called in init() and
fail driver initialization if unsuccessful.

Fixes: #66827

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
2024-01-03 10:21:28 +01:00
Bjarki Arge Andreasen
1ee092673a modem: modem_cellular.c: Remove non standard QCCID handler
The QCCID handler is Quectel specific and as such may not be part
of the modem cellular driver which only supports commands defined
in 3GPP TS 27.007

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Bjarki Arge Andreasen
572c5e6d5a modem: modem_cellular: Rework cellular_get_signal implementation
The modem_cellular.c driver now uses a common script to get
signal strenght, which is run on demand. This is more efficient
than polling it, and simpler since every modem doesn't have to
define their own variant of the script.

Additionally, the CSQ handler now stores the "raw" rssi value
returned from AT+CSQ to be parsed by the cellular_modem_get_signal
implementation.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Bjarki Arge Andreasen
f9491034be modem: modem_cellular: Update driver to implement cellular API
Move the implementations of the cellular API in modem_cellular.c
to an cellular_driver_structure, and implement this API structure
withing the device drivers.

Signed-off-by: Bjarki Arge Andreasen <bjarki@arge-andreasen.me>
2024-01-03 10:21:18 +01:00
Chun-Chieh Li
173e4983fd drivers: wifi: esp_at: fix last rx data loss in Passive Receive mode
In Passive Receive mode, ESP modem will buffer rx data.
This fix makes the data still available to user,
even though the peer has closed the socket.
Otherwise, user will fail to get the last rx data,
when the socket is closed by the peer.

Signed-off-by: Chun-Chieh Li <ccli8@nuvoton.com>
2024-01-03 10:21:09 +01:00
TOKITA Hiroshi
89982b711b drivers: serial: ra: minor cleanups
- Corrected indentation with clang-format

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00
TOKITA Hiroshi
e6486bf598 drivers: interrupt_controller: ra_icu: minor cleanups
- Corrected indentation with clang-format

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00
TOKITA Hiroshi
b1172d812d drivers: serial: ra: adding support interrupt driven mode
Add support interrupt driven mode for Renesas RA UART driver.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00
TOKITA Hiroshi
2de161ce4e drivers: interrupt_controller: ra_icu: Don't enable on irq connecting
Don't execute `irq_enable` in process of the `ra_icu_irq_connect_dynamic`.

The caller of `ra_icu_irq_connect_dynamic` is only `gpio_ra_pin_configure`
at this time. `gpio_ra_pin_configure` calls `irq_enable` just after called
`ra_icu_irq_connect_dynamic`.
So removing 'irq_enable' from 'ra_icu_irq_connect_dynamic' has no effect
on behavior.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00
TOKITA Hiroshi
bccd281b3d drivers: interrupt_controller: ra_icu: Adding disconnect_dynamic
Adding `ra_icu_irq_disconnect_dynamic()` corresponds with
`ra_icu_irq_connect_dynamic()`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
2024-01-02 19:12:46 +00:00