spi_bitbang.h 1.4 KB

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