DMA is only supported for full-duplex controller mode. Add an error
message and return an error if DMA is asked while in peripheral mode
or in half-duplex.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
In non-H7 full-duplex controller mode, using independent TXE/RXNE
handling in interrupt context can trigger RX overruns.
Switch this path to an RXNE-driven pipeline: seed one initial TX frame
at transfer start, then in each RXNE ISR read one frame and queue the
next TX frame. After the last TX frame, re-enable TXE once so transfer
completion is still detected when BSY clears.
Keep H7 behavior unchanged, and keep the existing non-full-duplex logic
unchanged.
This avoids ISR busy-wait loops while maintaining TX/RX synchronization
on non-H7 full-duplex transfers.
Assisted-by: GitHub Copilot:GPT-5.3-Codex
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
For the SPI devices with st,stm32-spi-fifo compatible, when configured
as master in half duplex RX mode, the clock is output non-stop on the
SCK line (the clock can't be started explicitly by filling the TX FIFO
since we're in half duplex RX), and the device has no way to know when to
stop (there is no TSIZE-like register like on st,stm32h7-spi compatible).
So, to prevent reception of unwanted extra data, the SPI must be disabled
as soon as all data have been received.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Add support of half duplex transfers on peripheral side.
This adds the support for all STM32.
Signed-off-by: Guillaume Gautier <guillaume.gautier-ext@st.com>
Introduce polling-based SPI driver for the NXP Kinetis-L series.
The driver implements spi_context and utilizes standard Zephyr
Clock Control and Pinctrl subsystems.
Signed-off-by: Gabriel Ivo <gabriel.bozi@usp.br>
Now that all in-tree users have been migrated to the inclusive SPI
terminology, formally deprecate the old names:
- SPI_OP_MODE_MASTER, SPI_OP_MODE_SLAVE and the SPI_MOSI_OVERRUN_*
compatibility aliases now emit a deprecation warning through
__DEPRECATED_MACRO.
- The "slave" member of struct spi_config and the
spi_context_is_slave() compatibility wrapper are marked
__deprecated.
- The SPI_CTX_RUNTIME_OP_MODE_MASTER/SLAVE aliases now emit a
deprecation warning through __DEPRECATED_MACRO.
- The SPI_SLAVE Kconfig shim now selects DEPRECATED.
Document the renames in the v4.5 migration guide and release notes.
Per the API lifecycle policy the deprecated names are kept for two
releases, and are scheduled for removal in Zephyr v5.0.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Realtek RTS5817 SPI
driver, following coding guideline rule A.2: switch to the renamed
core symbols and update comments, log messages and Kconfig help
prose.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral and SDO/SDI terminology in the remaining
SPI drivers, following coding guideline rule A.2. These changes are
limited to uses of the renamed core symbols (SPI_OP_MODE_CONTROLLER/
PERIPHERAL, spi_config.peripheral, spi_context_is_peripheral(),
SPI_SDO_OVERRUN_DT), driver-local identifiers (e.g. the silabs
mosi_overrun config members renamed to sdo_overrun), comments and
log messages. The Kconfig.renesas_ra8 hardware chip-select prompt
and help prose are reworded as well.
Vendor HAL/SDK and datasheet register identifiers keep their names,
notably: Ambiq IOSLAVE* base macros, Telink spi_master_* HAL calls,
TI driverlib SSI_MODE_MASTER, GD32 SPI_MASTER register bit, Nuvoton
BSP SPI_MASTER/SPI_SLAVE/QSPI_*/USPI_MASTER/SPI_CTL_SLAVE_Msk,
Microchip MSS_QSPI_CONTROL_MASTER and XEC CHPA_MOSI/CHPA_MISO
register bits, Silabs emlib EUSART/USART init symbols, and the
Zephyr PCIe core PCIE_CONF_CMDSTAT_MASTER bus-master bit referenced
by spi_pw.c (out of scope for this migration).
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Infineon CAT1 (PDL and
HAL based), PSoC-6 and XMC4xxx SPI drivers, following coding
guideline rule A.2: switch to the renamed core symbols, rename
driver-local identifiers (is_slave, spi_psoc6_master_get_defaults),
and update comments and log messages.
All Cypress/Infineon PDL identifiers (CY_SCB_SPI_MASTER/SLAVE,
Cy_SCB_*Master* APIs, enableMisoLateSample, masterSlaveIntEnableMask)
keep their vendor names, along with the devicetree property tokens
that mirror them (enable-miso-late-sample,
master-slave-int-enable-mask, miso-src).
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the NXP MCUX SPI drivers
(flexcomm, dspi, ecspi, flexio, rv32m1 lpspi and nxp lpspi),
following coding guideline rule A.2: switch to the renamed core
symbols, rename driver-local callbacks, helpers and variables
(spi_mcux_master_transfer_callback, spi_flexio_master_init,
lpspi_master_setup_native_cs, master_config/slave_config locals),
and update comments and log messages.
All NXP MCUX SDK API names, types and enum flags (SPI_Master*,
DSPI_Master*, kDSPI_*, ECSPI_*, FLEXIO_SPI_Master*, LPSPI_Master*,
*_master_config_t, *_master_handle_t, enableMaster) and CMSIS
register field macros (LPSPI_CFGR1_MASTER_MASK, *_MASTER_PCS_SHIFT)
keep their vendor names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Nordic nrfx SPI/SPIM/
SPIS shim drivers, following coding guideline rule A.2: switch to the
renamed core symbols, make SPI_NRFX_SPIS select SPI_PERIPHERAL
instead of the deprecated SPI_SLAVE, and reword Kconfig prose,
comments and log messages.
The nrfx HAL API names keep their vendor names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the ESP32 SPI driver,
following coding guideline rule A.2: switch to the renamed core
symbols, make ESP32_SPI_TARGET select SPI_PERIPHERAL instead of the
deprecated SPI_SLAVE, reword the Kconfig prompt/help, and update
comments.
All ESP-IDF HAL names (spi_slave_hal_* API and types,
hal/spi_slave_hal.h, SPI_MASTER_FREQ_* macros) keep their vendor
names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the TI OMAP MCSPI driver,
following coding guideline rule A.2: switch to the renamed core
symbols and the CONFIG_SPI_PERIPHERAL guard, and update comments and
log messages.
The ti,d1-miso-d0-mosi devicetree property and its matching code
tokens keep their names, as the property is defined by the TI binding
and mirrors the TI TRM signal naming.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the ITE IT8xxx2 SPI driver,
following coding guideline rule A.2: switch to the renamed core
symbols and update log messages.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the ITE IT51xxx SPI driver,
following coding guideline rule A.2: switch to the renamed core
symbols and update log messages.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Xilinx AXI Quad SPI
driver, following coding guideline rule A.2: switch to the renamed
core symbols and the CONFIG_SPI_PERIPHERAL guard, and update comments
and log messages.
The SPICR_MASTER*, SPISR_SLAVE_* and IPIXR_SLAVE_* register bit
macros mirror the Xilinx PG153 datasheet register field names and
keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the STM32 SPI driver,
following coding guideline rule A.2: rename the Zephyr-owned
ll_spi_swap_mosi_miso() wrapper to ll_spi_swap_sdo_sdi(), rename
local variables, switch to the renamed core symbols and the
CONFIG_SPI_PERIPHERAL guard, and update comments, log messages and
Kconfig help prose.
All ST LL/HAL API names (LL_SPI_MODE_MASTER/SLAVE,
LL_SPI_StartMasterTransfer, LL_SPI_EnableMosiMisoSwap,
LL_SPI_SetMasterSSIdleness, ...) keep their vendor names, and the
verbatim errata sheet quote in Kconfig.stm32 is left intact.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the LiteX SPI and LiteSPI
drivers, following coding guideline rule A.2: switch to the renamed
core symbols and update comments and log messages.
All master_*/mosi_*/miso_* identifiers tied to LiteX
gateware-generated CSR register names or devicetree reg-names
(master_cs, master_rxtx, master_phyconfig, master_status,
master_ev_*, master_clk_divisor, SPIFLASH_MASTER_*, reg-names
"mosi"/"miso") keep their names, as they must match the LiteX
gateware and devicetree definitions.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Microchip PolarFire MSS
SPI driver, following coding guideline rule A.2: rename the
driver-local mss_spi_select_slave() helper and the
MSS_SPI_MIN/MAX_SLAVE bounds macros, switch to the renamed core
symbols, and update comments.
The MSS_SPI_CONTROL_MASTER register bit macro mirrors the PolarFire
MSS SPI datasheet and keeps its name.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the ADI MAX32 SPI driver,
following coding guideline rule A.2: rename driver-local variables,
switch to the renamed core symbols and the CONFIG_SPI_PERIPHERAL
guard, and update comments.
The MXC_SPI_SetSlave() HAL function and the
ADI_MAX32_SPI_CTRL_MASTER_MODE register bit macro come from the ADI
MSDK and keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Bouffalo Lab SPI driver,
following coding guideline rule A.2: rename the driver-local
spi_bflb_trigger_master()/spi_bflb_detrigger_master() helpers, switch
to the renamed core symbols, and update comments.
The GLB_REG_SPI_*_MASTER_MODE_POS register field macros come from the
Bouffalo Lab HAL and keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Atmel SAM0 SERCOM SPI
driver, following coding guideline rule A.2: rename
spi_sam0_shift_master() to spi_sam0_shift_controller(), switch to the
renamed core symbols, and update comments.
The SERCOM_SPI_CTRLA_MODE_SPI_MASTER_Val register field value macro
mirrors the Microchip SERCOM header and keeps its name.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Microchip FLEXCOM G1 SPI
driver, following coding guideline rule A.2: rename the driver-local
helpers spi_slave_to_mr_pcs() and spi_sam_shift_master(), switch to
the renamed core symbols, and update comments and log messages.
The SPI_MR_MSTR_Msk register field macro comes from the Microchip SoC
header and keeps its name.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Atmel SAM SPI driver,
following coding guideline rule A.2: rename the driver-local helpers
spi_slave_to_mr_pcs() and spi_sam_shift_master(), switch to the
renamed core symbols, and update comments and log messages.
The Atmel SPI_MR/SPI_CSR register field macros keep their vendor
names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Renesas RZ SPI and RSPI
drivers, following coding guideline rule A.2: switch to the renamed
core symbols and the CONFIG_SPI_PERIPHERAL guard, and update comments
and log messages.
Renesas FSP identifiers (SPI_MODE_MASTER/SLAVE, mosi_idle,
*_MOSI_IDLE_VALUE_FIXING_DISABLE, BSP_FEATURE_BSP_MASTER_MPU_*) keep
their names, and the RZ_MASTER_MPU_* macros and related comments keep
theirs as they designate the Renesas RZ "Master MPU" bus-master
hardware block.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Renesas RX RSPI driver,
following coding guideline rule A.2: rename the driver-internal
transceive helpers, switch to the renamed core symbols and the
CONFIG_SPI_PERIPHERAL guard, update comments, and reword the
hardware chip-select Kconfig prompt and help text.
The rspi_chnl_settings_t.master_slave_mode member, the
RSPI_MS_MODE_MASTER/SLAVE enum constants (Renesas RDP r_rspi_rx_if.h)
and the SPCR.MSTR register bit field (iodefine.h) come from the
vendor HAL/datasheet and keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Renesas RA8 SPI-B
driver, following coding guideline rule A.2: rename the
driver-internal transceive helpers, switch to the renamed core
symbols and the CONFIG_SPI_PERIPHERAL guard.
The SPI_MODE_MASTER/SPI_MODE_SLAVE operating mode constants come from
the Renesas FSP HAL and keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Renesas RA SCI-B SPI
driver, following coding guideline rule A.2: switch to the renamed
core symbols and the CONFIG_SPI_PERIPHERAL guard, and update comments
and log messages.
The SPI_MODE_MASTER/SPI_MODE_SLAVE operating mode constants come from
the Renesas FSP HAL and keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Renesas RA SCI SPI
driver, following coding guideline rule A.2: switch to the renamed
core symbols and the CONFIG_SPI_PERIPHERAL guard, and update comments
and log messages.
The SPI_MODE_MASTER/SPI_MODE_SLAVE operating mode constants come from
the Renesas FSP HAL and keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Renesas RA SPI driver,
following coding guideline rule A.2: rename the driver-internal
transceive helpers, switch to the renamed core symbols and the
CONFIG_SPI_PERIPHERAL guard.
The SPI_MODE_MASTER/SPI_MODE_SLAVE operating mode constants come from
the Renesas FSP HAL and keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Microchip SERCOM G1 SPI
driver, following coding guideline rule A.2: rename the
driver-internal peripheral/controller helper functions and ISRs,
switch to the renamed core symbols and the CONFIG_SPI_PERIPHERAL
guard (including the SPI_MCHP_INTER_CHARACTER_SPACE default), and
update comments and log messages.
The SERCOM_SPI_CTRLA_MODE_SPI_MASTER/SLAVE register field macros come
from the Microchip device family pack headers and keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Realtek Ameba SPI
driver, following coding guideline rule A.2: rename
spi_ameba_is_slave() to spi_ameba_is_peripheral(), switch to the
renamed core symbols and the CONFIG_SPI_PERIPHERAL guard, and update
comments and log messages.
The SSI_MASTER/SSI_SLAVE role constants come from the Realtek Ameba
HAL and keep their names; the debug messages that print which HAL
role constant is selected keep referring to them verbatim.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the NXP S32 SPI driver,
following coding guideline rule A.2:
- Add a "peripheral" boolean devicetree property; the old "slave"
property is still accepted, marked as deprecated in the binding,
and used as a fallback when the new one is not set.
- Rename driver-internal identifiers, guards, comments and log
messages accordingly.
The SPI_MCR_MSTR register field macros and the SlaveMode member of
the SPI configuration structure come from the NXP S32 RTD HAL and
keep their names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Realtek Bee SPI driver,
following coding guideline rule A.2:
- Add an is-peripheral devicetree property; the old is-slave property
is still accepted, marked as deprecated in the binding, and used as
a fallback when the new one is not set.
- Rename driver-internal identifiers, guards, comments and log
messages accordingly.
The SPI0_SLAVE_TX/RX_FIFO_SIZE and SPI_Mode_Slave identifiers come
from the Realtek Bee SDK/HAL and keep their names, and the spi0_slave
devicetree node label keeps its name as it designates the dedicated
SPI0 slave-mode hardware instance of the SoC.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the Cadence SPI driver,
following coding guideline rule A.2: switch to the renamed core
symbols and the CONFIG_SPI_PERIPHERAL guard, and update comments and
log messages.
The SPI_SLAVE_IDLE_COUNT register offset macro keeps its name as it
mirrors the "Slave_Idle_count" register of the Cadence SPI controller
datasheet.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the DesignWare SPI driver,
following coding guideline rule A.2: rename spi_dw_is_slave() to
spi_dw_is_peripheral(), switch to the CONFIG_SPI_PERIPHERAL guard and
the renamed core symbols, and update comments and log messages.
The DW_SPI_CTRLR0_SLV_OE register bit macro keeps its name as it
mirrors the "Slave Output Enable" field of the Synopsys DesignWare
SSI databook.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use SDO/SDI and controller/peripheral terminology in the Raspberry Pi
Pico PIO SPI driver, following coding guideline rule A.2:
- Rename the sdo-gpios/sdi-gpios devicetree properties from
mosi-gpios/miso-gpios. The old property names are still accepted,
marked as deprecated in the binding, and used as a fallback by the
driver when the new ones are not set.
- Rename driver-internal identifiers and log messages accordingly.
- Migrate all in-tree boards, samples and test overlays to the new
property names.
The pico-sdk PIO helper APIs used by the driver keep their vendor
names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use SDO/SDI and controller/peripheral terminology in the SPI bitbang
driver, following coding guideline rule A.2:
- Rename the sdo-gpios/sdi-gpios devicetree properties from
mosi-gpios/miso-gpios. The old property names are still accepted,
marked as deprecated in the binding, and used as a fallback by the
driver when the new ones are not set.
- Rename driver-internal identifiers and log messages accordingly.
- Migrate all in-tree boards and sample overlays to the new property
names.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Use controller/peripheral terminology in the SPI driver context
helpers, following coding guideline rule A.2:
- Rename spi_context_is_slave() to spi_context_is_peripheral(),
keeping the old name as a compatibility wrapper for out-of-tree
drivers.
- Rename the spi_ctx_runtime_op_mode enumerators to
SPI_CTX_RUNTIME_OP_MODE_CONTROLLER/PERIPHERAL, keeping the old
names as compatibility aliases.
- Guard peripheral-mode code with CONFIG_SPI_PERIPHERAL. The
deprecated CONFIG_SPI_SLAVE option selects SPI_PERIPHERAL, so
drivers that still test CONFIG_SPI_SLAVE keep working unchanged.
- Update comments accordingly.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Rename the SPI_SLAVE Kconfig option to SPI_PERIPHERAL, following
coding guideline rule A.2. The old option is kept as a compatibility
shim that selects SPI_PERIPHERAL, so existing configurations keep
working and both CONFIG macros are defined whenever either option is
enabled. This lets drivers migrate their guards independently.
The shim will additionally select DEPRECATED once all in-tree users
have been migrated.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Two-line copyright notices were wrapped in the SPDX "<text>...</text>"
construct, which is only valid in an SPDX document, not a file header.
The REUSE tool then folds the literal "<text>" into the holder name
and drops the second line from the SBOM.
Remove the markers and tag the continuation line. Holder, year and
e-mail are left unchanged; only the syntax is fixed.
Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
The RTIO path updated the transfer command with read-modify-writes of
TCR while the transmit FIFO held queued entries: clearing CONT and
CONTC when the last data word enters the FIFO, in the DMA TX complete
callback, and in the end-of-transfer touch. TCR reads are not reliable
in that state. The reference manual advises reading TCR only with an
empty transmit FIFO or reading it twice and comparing, and ERR050606
adds that a polled TCR read can return a stale value. A stale or torn
readback written back is queued as a command word and silently alters
the frame for the remaining words with no error flag raised.
On a 17 byte half duplex probe read of an AFBR-S50 on MCXN947 LPSPI
with its 8 word RX FIFO the transfer completes reporting success while
the payload arrives displaced: the device's 0x00..0x10 test ramp
returns ten 0x00 bytes with the values 0x01..0x07 landing at offsets
10..16. Reads at or below the FIFO size are unaffected.
Compose the transfer command once at start of transfer, while the
transmit FIFO is empty and the read is defined, cache it per instance,
and write the cached value with CONT and CONTC cleared at every later
command write instead of reading TCR back.
For transmit only transfers on the interrupt path, mask RX in the
cached command before the first FIFO fill rather than after it, so no
unread words collect in the RX FIFO behind the queued data. The DMA
path keeps RX unmasked since it drains every received word and its
completion is signaled by the RX channel. Skip the RX drain pass when
the receive data flag is clear, keeping the receive interrupt armed,
so transmit and completion interrupts no longer run empty drain loops.
The watermark scheme, FIFO tuning, and DMA support are unchanged.
Signed-off-by: Benjamin Perseghetti <bperseghetti@rudislabs.com>
spi_config() stored the config in the context before calling
am_hal_ios_configure(), so a failed HAL configure left the context
marked as configured. The next transceive then passed the
spi_context_configured() check and ran on unconfigured hardware, and
the raw HAL status leaked through the SPI API as a positive value.
Only publish the new config once the HAL accepts it and map a configure
failure to -EIO.
Fixes#116324
Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
spi_ambiq_transceive() returned early when spi_config() failed, skipping
the runtime PM put and leaking the usage count taken by the get; the
device could then never runtime-suspend again. It also overwrote the
transfer status with the return of pm_device_runtime_put_async(), hiding
transfer errors from the caller, and continued into the HAL after a
failed get.
Route the config-failure path through the common exit, keep the put
status in its own variable, and bail out when the get fails.
Fixes#116324
Signed-off-by: Richard Wheatley <richard.wheatley@ambiq.com>
spi_esp32_get_line_mode() takes the SPI operation as a uint16_t, but the
line-mode bits SPI_LINES_DUAL/QUAD/OCTAL live at bit 16 and above of the
spi_operation_t type, which is widened to uint32_t when
CONFIG_SPI_EXTENDED_MODES is enabled. Passing the full operation into the
uint16_t parameter truncates those bits, so operation & SPI_LINES_MASK is
always 0 and the function always reports single-line mode. Any request for
dual, quad or octal lines is silently downgraded to single-line, driving
only the D0 data line.
Widen the parameter to uint32_t so the line-mode bits survive, matching
how every other SPI driver reads the operation. Verified on an
ESP32-S3-Touch-AMOLED-1.8 QSPI panel, where quad transfers only produced
correct colors with this fix.
Signed-off-by: Dylan Rowe <dylanthomasrowe@gmail.com>
The AHB GDMA path passed dma-host, the SPI host index, as
the DMA peripheral trigger. That happens to match on SoCs
where the SPI2 trigger is zero, but on esp32c5 and esp32c61
the SPI2 trigger is 1, so RX and TX were connected to the
wrong peripheral and no data was transferred. Derive the
trigger from the SPI2 base as the AXI path already does.
spi_loopback DMA mode passes on esp32c5 and esp32c61.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>