2021-01-16 08:34:55 +08:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2022-05-06 16:25:46 +08:00
|
|
|
#include <zephyr/zephyr.h>
|
|
|
|
#include <zephyr/drivers/spi.h>
|
2021-01-16 08:34:55 +08:00
|
|
|
|
|
|
|
#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) \
|
2021-04-28 18:04:51 +08:00
|
|
|
DEVICE_DT_INST_DEFINE(n, &vnd_spi_init, NULL, \
|
2021-01-16 08:34:55 +08:00
|
|
|
NULL, NULL, POST_KERNEL, \
|
|
|
|
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, \
|
|
|
|
&vnd_spi_api);
|
|
|
|
|
|
|
|
DT_INST_FOREACH_STATUS_OKAY(VND_SPI_INIT)
|