1#ifndef __SPI_BITBANG_H 2#define __SPI_BITBANG_H 3 4#include <linux/workqueue.h> 5 6struct spi_bitbang { 7 struct mutex lock; 8 u8 busy; 9 u8 use_dma; 10 u8 flags; /* extra spi->mode support */ 11 12 struct spi_master *master; 13 14 /* setup_transfer() changes clock and/or wordsize to match settings 15 * for this transfer; zeroes restore defaults from spi_device. 16 */ 17 int (*setup_transfer)(struct spi_device *spi, 18 struct spi_transfer *t); 19 20 void (*chipselect)(struct spi_device *spi, int is_on); 21#define BITBANG_CS_ACTIVE 1 /* normally nCS, active low */ 22#define BITBANG_CS_INACTIVE 0 23 24 /* txrx_bufs() may handle dma mapping for transfers that don't 25 * already have one (transfer.{tx,rx}_dma is zero), or use PIO 26 */ 27 int (*txrx_bufs)(struct spi_device *spi, struct spi_transfer *t); 28 29 /* txrx_word[SPI_MODE_*]() just looks like a shift register */ 30 u32 (*txrx_word[4])(struct spi_device *spi, 31 unsigned nsecs, 32 u32 word, u8 bits); 33}; 34 35/* you can call these default bitbang->master methods from your custom 36 * methods, if you like. 37 */ 38extern int spi_bitbang_setup(struct spi_device *spi); 39extern void spi_bitbang_cleanup(struct spi_device *spi); 40extern int spi_bitbang_setup_transfer(struct spi_device *spi, 41 struct spi_transfer *t); 42 43/* start or stop queue processing */ 44extern int spi_bitbang_start(struct spi_bitbang *spi); 45extern void spi_bitbang_stop(struct spi_bitbang *spi); 46 47#endif /* __SPI_BITBANG_H */ 48