drivers: spi: add dummy driver for vnd,spi
We will need this to be able to DEVICE_DT_GET() bus devices from tests/drivers/build_all in an upcoming commit. Signed-off-by: Martí Bolívar <marti.bolivar@nordicsemi.no>
This commit is contained in:
parent
d6cfa10b8f
commit
63471ba93b
4 changed files with 73 additions and 0 deletions
|
@ -22,5 +22,6 @@ zephyr_library_sources_ifdef(CONFIG_SPI_XEC_QMSPI spi_xec_qmspi.c)
|
|||
zephyr_library_sources_ifdef(CONFIG_SPI_GECKO spi_gecko.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_SPI_XLNX_AXI_QUADSPI spi_xlnx_axi_quadspi.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_ESP32_SPIM spi_esp32_spim.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_SPI_TEST spi_test.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_USERSPACE spi_handlers.c)
|
||||
|
|
|
@ -225,4 +225,6 @@ source "drivers/spi/Kconfig.xlnx"
|
|||
|
||||
source "drivers/spi/Kconfig.esp32"
|
||||
|
||||
source "drivers/spi/Kconfig.test"
|
||||
|
||||
endif # SPI
|
||||
|
|
9
drivers/spi/Kconfig.test
Normal file
9
drivers/spi/Kconfig.test
Normal file
|
@ -0,0 +1,9 @@
|
|||
# Copyright (c) 2021, Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
DT_COMPAT_VND_SPI := vnd,spi
|
||||
|
||||
# Hidden option for turning on the dummy driver for vnd,spi devices
|
||||
# used in testing.
|
||||
config SPI_TEST
|
||||
def_bool $(dt_compat_enabled,$(DT_COMPAT_VND_SPI))
|
61
drivers/spi/spi_test.c
Normal file
61
drivers/spi/spi_test.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is not a real SPI driver. It is used to instantiate struct
|
||||
* devices for the "vnd,spi" devicetree compatible used in test code.
|
||||
*/
|
||||
|
||||
#include <zephyr.h>
|
||||
#include <drivers/spi.h>
|
||||
|
||||
#define DT_DRV_COMPAT vnd_spi
|
||||
|
||||
static int vnd_spi_transceive(const struct device *dev,
|
||||
const struct spi_config *spi_cfg,
|
||||
const struct spi_buf_set *tx_bufs,
|
||||
const struct spi_buf_set *rx_bufs)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SPI_ASYNC
|
||||
static int vnd_spi_transceive_async(const struct device *dev,
|
||||
const struct spi_config *spi_cfg,
|
||||
const struct spi_buf_set *tx_bufs,
|
||||
const struct spi_buf_set *rx_bufs,
|
||||
struct k_poll_signal *async)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int vnd_spi_release(const struct device *dev,
|
||||
const struct spi_config *spi_cfg)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
static const struct spi_driver_api vnd_spi_api = {
|
||||
.transceive = vnd_spi_transceive,
|
||||
#ifdef CONFIG_SPI_ASYNC
|
||||
.transceive_async = vnd_spi_transceive_async,
|
||||
#endif
|
||||
.release = vnd_spi_release,
|
||||
};
|
||||
|
||||
static int vnd_spi_init(const struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define VND_SPI_INIT(n) \
|
||||
DEVICE_DT_INST_DEFINE(n, &vnd_spi_init, device_pm_control_nop, \
|
||||
NULL, NULL, POST_KERNEL, \
|
||||
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
||||
&vnd_spi_api);
|
||||
|
||||
DT_INST_FOREACH_STATUS_OKAY(VND_SPI_INIT)
|
Loading…
Add table
Add a link
Reference in a new issue