Lines Matching +full:spi +full:- +full:cpol

1 /* SPDX-License-Identifier: GPL-2.0 */
4 * simple SPI master driver. Two do polled word-at-a-time I/O:
6 * - GPIO/parport bitbangers. Provide chipselect() and txrx_word[](),
7 * expanding the per-word routines from the inline templates below.
9 * - Drivers for controllers resembling bare shift registers. Provide
15 * - Drivers leveraging smarter hardware, with fifos or DMA; or for half
36 * A non-inlined routine would call bitbang_txrx_*() routines. The
49 bitbang_txrx_be_cpha0(struct spi_device *spi, in bitbang_txrx_be_cpha0() argument
50 unsigned nsecs, unsigned cpol, unsigned flags, in bitbang_txrx_be_cpha0() argument
53 /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */ in bitbang_txrx_be_cpha0()
55 u32 oldbit = (!(word & (1<<(bits-1)))) << 31; in bitbang_txrx_be_cpha0()
57 for (word <<= (32 - bits); likely(bits); bits--) { in bitbang_txrx_be_cpha0()
62 setmosi(spi, word & (1 << 31)); in bitbang_txrx_be_cpha0()
68 setsck(spi, !cpol); in bitbang_txrx_be_cpha0()
74 word |= getmiso(spi); in bitbang_txrx_be_cpha0()
75 setsck(spi, cpol); in bitbang_txrx_be_cpha0()
81 bitbang_txrx_be_cpha1(struct spi_device *spi, in bitbang_txrx_be_cpha1() argument
82 unsigned nsecs, unsigned cpol, unsigned flags, in bitbang_txrx_be_cpha1() argument
85 /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */ in bitbang_txrx_be_cpha1()
87 u32 oldbit = (!(word & (1<<(bits-1)))) << 31; in bitbang_txrx_be_cpha1()
89 for (word <<= (32 - bits); likely(bits); bits--) { in bitbang_txrx_be_cpha1()
92 setsck(spi, !cpol); in bitbang_txrx_be_cpha1()
95 setmosi(spi, word & (1 << 31)); in bitbang_txrx_be_cpha1()
101 setsck(spi, cpol); in bitbang_txrx_be_cpha1()
107 word |= getmiso(spi); in bitbang_txrx_be_cpha1()
113 bitbang_txrx_le_cpha0(struct spi_device *spi, in bitbang_txrx_le_cpha0() argument
114 unsigned int nsecs, unsigned int cpol, unsigned int flags, in bitbang_txrx_le_cpha0() argument
117 /* if (cpol == 0) this is SPI_MODE_0; else this is SPI_MODE_2 */ in bitbang_txrx_le_cpha0()
119 u8 rxbit = bits - 1; in bitbang_txrx_le_cpha0()
122 for (; likely(bits); bits--) { in bitbang_txrx_le_cpha0()
127 setmosi(spi, word & 1); in bitbang_txrx_le_cpha0()
133 setsck(spi, !cpol); in bitbang_txrx_le_cpha0()
139 word |= getmiso(spi) << rxbit; in bitbang_txrx_le_cpha0()
140 setsck(spi, cpol); in bitbang_txrx_le_cpha0()
146 bitbang_txrx_le_cpha1(struct spi_device *spi, in bitbang_txrx_le_cpha1() argument
147 unsigned int nsecs, unsigned int cpol, unsigned int flags, in bitbang_txrx_le_cpha1() argument
150 /* if (cpol == 0) this is SPI_MODE_1; else this is SPI_MODE_3 */ in bitbang_txrx_le_cpha1()
152 u8 rxbit = bits - 1; in bitbang_txrx_le_cpha1()
155 for (; likely(bits); bits--) { in bitbang_txrx_le_cpha1()
158 setsck(spi, !cpol); in bitbang_txrx_le_cpha1()
161 setmosi(spi, word & 1); in bitbang_txrx_le_cpha1()
167 setsck(spi, cpol); in bitbang_txrx_le_cpha1()
173 word |= getmiso(spi) << rxbit; in bitbang_txrx_le_cpha1()