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