From 2f529f9b558ca1c1bd74be7437a84e4711743404 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Fri, 01 Nov 2024 02:11:33 +0000 Subject: [PATCH] add xenomai --- kernel/include/linux/spi/spi.h | 99 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 99 insertions(+), 0 deletions(-) diff --git a/kernel/include/linux/spi/spi.h b/kernel/include/linux/spi/spi.h index f50c766..04f35c4 100644 --- a/kernel/include/linux/spi/spi.h +++ b/kernel/include/linux/spi/spi.h @@ -9,6 +9,7 @@ #include <linux/device.h> #include <linux/mod_devicetable.h> #include <linux/slab.h> +#include <linux/dmaengine.h> #include <linux/kthread.h> #include <linux/completion.h> #include <linux/scatterlist.h> @@ -253,6 +254,7 @@ struct spi_message; struct spi_transfer; +struct spi_oob_transfer; /** * struct spi_driver - Host side "protocol" driver @@ -352,6 +354,7 @@ * @io_mutex: mutex for physical bus access * @bus_lock_spinlock: spinlock for SPI bus locking * @bus_lock_mutex: mutex for exclusion of multiple callers + * @bus_oob_lock_sem: semaphore for exclusion during oob operations * @bus_lock_flag: indicates that the SPI bus is locked for exclusive use * @setup: updates the device mode and clocking records used by a * device's SPI controller; protocol code may call this. This @@ -534,6 +537,10 @@ spinlock_t bus_lock_spinlock; struct mutex bus_lock_mutex; +#ifdef CONFIG_SPI_OOB + struct semaphore bus_oob_lock_sem; +#endif + /* flag indicating that the SPI bus is locked for exclusive use */ bool bus_lock_flag; @@ -626,6 +633,14 @@ int (*unprepare_message)(struct spi_controller *ctlr, struct spi_message *message); int (*slave_abort)(struct spi_controller *ctlr); + int (*prepare_oob_transfer)(struct spi_controller *ctlr, + struct spi_oob_transfer *xfer); + void (*start_oob_transfer)(struct spi_controller *ctlr, + struct spi_oob_transfer *xfer); + void (*pulse_oob_transfer)(struct spi_controller *ctlr, + struct spi_oob_transfer *xfer); + void (*terminate_oob_transfer)(struct spi_controller *ctlr, + struct spi_oob_transfer *xfer); /* * These hooks are for drivers that use a generic implementation @@ -1137,6 +1152,90 @@ kfree(m); } +struct spi_oob_transfer { + struct spi_device *spi; + dma_addr_t dma_addr; + size_t aligned_frame_len; + void *io_buffer; /* 2 x aligned_frame_len */ + struct dma_async_tx_descriptor *txd; + struct dma_async_tx_descriptor *rxd; + u32 effective_speed_hz; + /* + * Caller-defined settings for the transfer. + */ + struct spi_oob_setup { + u32 frame_len; + u32 speed_hz; + u8 bits_per_word; + dma_async_tx_callback xfer_done; + } setup; +}; + +static inline off_t spi_get_oob_rxoff(struct spi_oob_transfer *xfer) +{ + /* RX area is in first half of the I/O buffer. */ + return 0; +} + +static inline off_t spi_get_oob_txoff(struct spi_oob_transfer *xfer) +{ + /* TX area is in second half of the I/O buffer. */ + return xfer->aligned_frame_len; +} + +static inline size_t spi_get_oob_iolen(struct spi_oob_transfer *xfer) +{ + return xfer->aligned_frame_len * 2; +} + +#ifdef CONFIG_SPI_OOB + +struct vm_area_struct; + +int spi_prepare_oob_transfer(struct spi_device *spi, + struct spi_oob_transfer *xfer); + +void spi_start_oob_transfer(struct spi_oob_transfer *xfer); + +int spi_pulse_oob_transfer(struct spi_oob_transfer *xfer); + +void spi_terminate_oob_transfer(struct spi_oob_transfer *xfer); + +int spi_mmap_oob_transfer(struct vm_area_struct *vma, + struct spi_oob_transfer *xfer); + +#else + +static inline +int spi_prepare_oob_transfer(struct spi_device *spi, + struct spi_oob_transfer *xfer) +{ + return -ENOTSUPP; +} + +static inline +void spi_start_oob_transfer(struct spi_oob_transfer *xfer) +{ } + +static inline +int spi_pulse_oob_transfer(struct spi_oob_transfer *xfer) +{ + return -EIO; +} + +static inline +void spi_terminate_oob_transfer(struct spi_oob_transfer *xfer) +{ } + +static inline +int spi_mmap_oob_transfer(struct vm_area_struct *vma, + struct spi_oob_transfer *xfer) +{ + return -ENXIO; +} + +#endif + extern int spi_set_cs_timing(struct spi_device *spi, struct spi_delay *setup, struct spi_delay *hold, -- Gitblit v1.6.2