common:
  depends_on: spi
  tags:
    - drivers
    - spi
    - dma
  filter: dt_compat_enabled("test-spi-loopback-slow") and
          dt_compat_enabled("test-spi-loopback-fast")
  harness: ztest
  harness_config:
    fixture: spi_loopback
tests:
  drivers.spi.loopback: {}
  drivers.spi.loopback.internal:
    filter: CONFIG_SPI_LOOPBACK_MODE_LOOP
  drivers.spi.loopback.lpspi.dma:
    filter: CONFIG_HAS_MCUX_LPSPI and CONFIG_HAS_MCUX_EDMA
    extra_configs:
      - CONFIG_SPI_MCUX_LPSPI_DMA=y
  drivers.spi.loopback.lpspi.async.unset:
    filter: CONFIG_HAS_MCUX_LPSPI and CONFIG_HAS_MCUX_EDMA
    extra_configs:
      - CONFIG_SPI_MCUX_LPSPI_DMA=n
      - CONFIG_SPI_ASYNC=n
  drivers.spi.loopback.lpspi.dma.async.unset:
    filter: CONFIG_HAS_MCUX_LPSPI and CONFIG_HAS_MCUX_EDMA
    extra_configs:
      - CONFIG_SPI_MCUX_LPSPI_DMA=y
      - CONFIG_SPI_ASYNC=n
  drivers.spi.loopback.rtio:
    extra_configs:
      - CONFIG_SPI_RTIO=y
    platform_allow:
      - robokit1
      - mimxrt1170_evk/mimxrt1176/cm7
      - vmu_rt1170/mimxrt1176/cm7
  drivers.spi.mcux_dspi_dma.loopback:
    extra_args:
      - OVERLAY_CONFIG="overlay-mcux-dspi-dma.conf"
      - DTC_OVERLAY_FILE="overlay-mcux-dspi-dma.overlay"
    platform_allow: frdm_k64f
  drivers.spi.sam_spi_dma.loopback:
    extra_args:
      - OVERLAY_CONFIG="overlay-sam-spi-dma.conf"
      - DTC_OVERLAY_FILE="overlay-sam-spi-dma.overlay"
    platform_allow:
      - sam_e70_xplained/same70q21
      - sam_v71_xult/samv71q21
      - robokit1
    integration_platforms:
      - sam_e70_xplained/same70q21
  drivers.spi.stm32_spi_16bits_frames.loopback:
    extra_args:
      - OVERLAY_CONFIG="overlay-stm32-spi-16bits.conf"
      - DTC_OVERLAY_FILE="overlay-stm32-spi-16bits.overlay"
    filter: CONFIG_SOC_FAMILY_STM32
    platform_allow:
      - nucleo_h743zi
      - nucleo_h753zi
  drivers.spi.stm32_spi_dma.loopback:
    extra_args: OVERLAY_CONFIG="overlay-stm32-spi-dma.conf"
    filter: CONFIG_SOC_FAMILY_STM32
    platform_allow:
      - nucleo_g474re
      - nucleo_f207zg
      - nucleo_f429zi
      - nucleo_f746zg
      - nucleo_f767zi
      - nucleo_wb55rg
      - nucleo_l152re
      - nucleo_wl55jc
      - nucleo_h743zi
      - nucleo_h753zi
      - stm32h573i_dk
    integration_platforms:
      - nucleo_g474re
  drivers.spi.stm32_spi_dma_dt_nocache_mem.loopback:
    # this test case is for when nocache memory region is defined in DT
    # using `zephyr,memory-attr = < DT_MEM_ARM_MPU_RAM_NOCACHE)>`
    extra_args:
      - OVERLAY_CONFIG="overlay-stm32-spi-dma-dt-nocache-mem.conf"
    filter: CONFIG_SOC_FAMILY_STM32 and CONFIG_CPU_HAS_DCACHE
    platform_allow:
      - nucleo_h743zi
      - nucleo_h753zi
  drivers.spi.stm32_spi_16bits_frames_dma.loopback:
    extra_args:
      - OVERLAY_CONFIG="overlay-stm32-spi-16bits-dma.conf"
      - DTC_OVERLAY_FILE="overlay-stm32-spi-16bits.overlay"
    filter: CONFIG_SOC_FAMILY_STM32
    platform_allow:
      - nucleo_h743zi
      - nucleo_h753zi
  drivers.spi.stm32_spi_16bits_frames_dma_dt_nocache_mem.loopback:
    extra_args:
      - OVERLAY_CONFIG="overlay-stm32-spi-16bits-dma-dt-nocache-mem.conf"
      - DTC_OVERLAY_FILE="overlay-stm32-spi-16bits.overlay"
    filter: CONFIG_SOC_FAMILY_STM32 and CONFIG_CPU_HAS_DCACHE
    platform_allow:
      - nucleo_h743zi
      - nucleo_h753zi
  drivers.spi.stm32_spi_interrupt.loopback:
    extra_args: OVERLAY_CONFIG="overlay-stm32-spi-interrupt.conf"
    filter: CONFIG_SOC_FAMILY_STM32
    platform_allow:
      - nucleo_f746zg
      - nucleo_f767zi
      - nucleo_h743zi
      - nucleo_h753zi
  drivers.spi.gd32_spi_interrupt.loopback:
    extra_args: OVERLAY_CONFIG="overlay-gd32-spi-interrupt.conf"
    platform_allow:
      - gd32f403z_eval
      - gd32f407v_start
      - gd32f450i_eval
      - gd32f450v_start
      - gd32f450z_eval
      - gd32f470i_eval
      - gd32vf103c_starter
      - gd32vf103v_eval
      - longan_nano
      - longan_nano/gd32vf103/lite
  drivers.spi.gd32_spi_dma.loopback:
    extra_args: OVERLAY_CONFIG="overlay-gd32-spi-dma.conf"
    platform_allow:
      - gd32f403z_eval
      - gd32f407v_start
      - gd32f450i_eval
      - gd32f450v_start
      - gd32f450z_eval
      - gd32f470i_eval
      - gd32vf103c_starter
      - gd32vf103v_eval
      - longan_nano
      - longan_nano/gd32vf103/lite
  drivers.spi.pl022_spi_interrupt.loopback:
    extra_configs:
      - CONFIG_SPI_PL022_INTERRUPT=y
      - CONFIG_SPI_PL022_DMA=n
    platform_allow: rpi_pico
  drivers.spi.pl022_spi_dma.loopback:
    extra_configs:
      - CONFIG_SPI_PL022_INTERRUPT=n
      - CONFIG_SPI_PL022_DMA=y
      - CONFIG_DMA=y
    platform_allow: rpi_pico
  drivers.spi.pl022_spi_dma_and_interrupt.loopback:
    extra_configs:
      - CONFIG_SPI_PL022_INTERRUPT=y
      - CONFIG_SPI_PL022_DMA=y
      - CONFIG_DMA=y
    platform_allow: rpi_pico
  drivers.spi.pl022_spi_dma_no_dma_props.loopback:
    extra_args: DTC_OVERLAY_FILE="boards/rpi_pico_delete_dma_props.overlay"
    extra_configs:
      - CONFIG_SPI_PL022_INTERRUPT=n
      - CONFIG_SPI_PL022_DMA=y
      - CONFIG_DMA=y
    platform_allow: rpi_pico
  drivers.spi.pl022_spi_dma_and_interrupt_no_dma_props.loopback:
    extra_args: DTC_OVERLAY_FILE="boards/rpi_pico_delete_dma_props.overlay"
    extra_configs:
      - CONFIG_SPI_PL022_INTERRUPT=y
      - CONFIG_SPI_PL022_DMA=y
      - CONFIG_DMA=y
    platform_allow: rpi_pico
  drivers.spi.mcux_flexio_spi.loopback:
    extra_args: DTC_OVERLAY_FILE="overlay-mcux-flexio-spi.overlay"
    filter: CONFIG_DT_HAS_NXP_FLEXIO_ENABLED and
            CONFIG_DT_HAS_NXP_FLEXIO_SPI_ENABLED
    platform_allow: mimxrt1064_evk
