Lines Matching refs:spi
75 spi_to_spi_gpio(const struct spi_device *spi) in spi_to_spi_gpio() argument
80 bang = spi_controller_get_devdata(spi->controller); in spi_to_spi_gpio()
86 static inline void setsck(const struct spi_device *spi, int is_on) in setsck() argument
88 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); in setsck()
93 static inline void setmosi(const struct spi_device *spi, int is_on) in setmosi() argument
95 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); in setmosi()
100 static inline int getmiso(const struct spi_device *spi) in getmiso() argument
102 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); in getmiso()
104 if (spi->mode & SPI_3WIRE) in getmiso()
134 static u32 spi_gpio_txrx_word_mode0(struct spi_device *spi, in spi_gpio_txrx_word_mode0() argument
137 if (unlikely(spi->mode & SPI_LSB_FIRST)) in spi_gpio_txrx_word_mode0()
138 return bitbang_txrx_le_cpha0(spi, nsecs, 0, flags, word, bits); in spi_gpio_txrx_word_mode0()
140 return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits); in spi_gpio_txrx_word_mode0()
143 static u32 spi_gpio_txrx_word_mode1(struct spi_device *spi, in spi_gpio_txrx_word_mode1() argument
146 if (unlikely(spi->mode & SPI_LSB_FIRST)) in spi_gpio_txrx_word_mode1()
147 return bitbang_txrx_le_cpha1(spi, nsecs, 0, flags, word, bits); in spi_gpio_txrx_word_mode1()
149 return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits); in spi_gpio_txrx_word_mode1()
152 static u32 spi_gpio_txrx_word_mode2(struct spi_device *spi, in spi_gpio_txrx_word_mode2() argument
155 if (unlikely(spi->mode & SPI_LSB_FIRST)) in spi_gpio_txrx_word_mode2()
156 return bitbang_txrx_le_cpha0(spi, nsecs, 1, flags, word, bits); in spi_gpio_txrx_word_mode2()
158 return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits); in spi_gpio_txrx_word_mode2()
161 static u32 spi_gpio_txrx_word_mode3(struct spi_device *spi, in spi_gpio_txrx_word_mode3() argument
164 if (unlikely(spi->mode & SPI_LSB_FIRST)) in spi_gpio_txrx_word_mode3()
165 return bitbang_txrx_le_cpha1(spi, nsecs, 1, flags, word, bits); in spi_gpio_txrx_word_mode3()
167 return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits); in spi_gpio_txrx_word_mode3()
180 static u32 spi_gpio_spec_txrx_word_mode0(struct spi_device *spi, in spi_gpio_spec_txrx_word_mode0() argument
183 flags = spi->controller->flags; in spi_gpio_spec_txrx_word_mode0()
184 if (unlikely(spi->mode & SPI_LSB_FIRST)) in spi_gpio_spec_txrx_word_mode0()
185 return bitbang_txrx_le_cpha0(spi, nsecs, 0, flags, word, bits); in spi_gpio_spec_txrx_word_mode0()
187 return bitbang_txrx_be_cpha0(spi, nsecs, 0, flags, word, bits); in spi_gpio_spec_txrx_word_mode0()
190 static u32 spi_gpio_spec_txrx_word_mode1(struct spi_device *spi, in spi_gpio_spec_txrx_word_mode1() argument
193 flags = spi->controller->flags; in spi_gpio_spec_txrx_word_mode1()
194 if (unlikely(spi->mode & SPI_LSB_FIRST)) in spi_gpio_spec_txrx_word_mode1()
195 return bitbang_txrx_le_cpha1(spi, nsecs, 0, flags, word, bits); in spi_gpio_spec_txrx_word_mode1()
197 return bitbang_txrx_be_cpha1(spi, nsecs, 0, flags, word, bits); in spi_gpio_spec_txrx_word_mode1()
200 static u32 spi_gpio_spec_txrx_word_mode2(struct spi_device *spi, in spi_gpio_spec_txrx_word_mode2() argument
203 flags = spi->controller->flags; in spi_gpio_spec_txrx_word_mode2()
204 if (unlikely(spi->mode & SPI_LSB_FIRST)) in spi_gpio_spec_txrx_word_mode2()
205 return bitbang_txrx_le_cpha0(spi, nsecs, 1, flags, word, bits); in spi_gpio_spec_txrx_word_mode2()
207 return bitbang_txrx_be_cpha0(spi, nsecs, 1, flags, word, bits); in spi_gpio_spec_txrx_word_mode2()
210 static u32 spi_gpio_spec_txrx_word_mode3(struct spi_device *spi, in spi_gpio_spec_txrx_word_mode3() argument
213 flags = spi->controller->flags; in spi_gpio_spec_txrx_word_mode3()
214 if (unlikely(spi->mode & SPI_LSB_FIRST)) in spi_gpio_spec_txrx_word_mode3()
215 return bitbang_txrx_le_cpha1(spi, nsecs, 1, flags, word, bits); in spi_gpio_spec_txrx_word_mode3()
217 return bitbang_txrx_be_cpha1(spi, nsecs, 1, flags, word, bits); in spi_gpio_spec_txrx_word_mode3()
222 static void spi_gpio_chipselect(struct spi_device *spi, int is_active) in spi_gpio_chipselect() argument
224 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); in spi_gpio_chipselect()
228 gpiod_set_value_cansleep(spi_gpio->sck, spi->mode & SPI_CPOL); in spi_gpio_chipselect()
232 struct gpio_desc *cs = spi_gpio->cs_gpios[spi_get_chipselect(spi, 0)]; in spi_gpio_chipselect()
235 gpiod_set_value_cansleep(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active); in spi_gpio_chipselect()
239 static int spi_gpio_setup(struct spi_device *spi) in spi_gpio_setup() argument
243 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); in spi_gpio_setup()
250 cs = spi_gpio->cs_gpios[spi_get_chipselect(spi, 0)]; in spi_gpio_setup()
251 if (!spi->controller_state && cs) in spi_gpio_setup()
253 !(spi->mode & SPI_CS_HIGH)); in spi_gpio_setup()
257 status = spi_bitbang_setup(spi); in spi_gpio_setup()
262 static int spi_gpio_set_direction(struct spi_device *spi, bool output) in spi_gpio_set_direction() argument
264 struct spi_gpio *spi_gpio = spi_to_spi_gpio(spi); in spi_gpio_set_direction()
278 if (spi->mode & SPI_3WIRE) { in spi_gpio_set_direction()
291 if (spi->mode & SPI_3WIRE_HIZ) { in spi_gpio_set_direction()
293 !(spi->mode & SPI_CPOL)); in spi_gpio_set_direction()
295 !!(spi->mode & SPI_CPOL)); in spi_gpio_set_direction()
300 static void spi_gpio_cleanup(struct spi_device *spi) in spi_gpio_cleanup() argument
302 spi_bitbang_cleanup(spi); in spi_gpio_cleanup()