spi_bitbang.h 1.6 KB

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