Lines Matching defs:spi

17 #include <linux/spi/spi.h>
26 #include <trace/events/spi.h>
331 static void atmel_spi_send_dummy(struct atmel_spi *as, struct spi_device *spi, int chip_select)
364 * they assume that spi slave device state will not change on deselect, so
385 static void cs_activate(struct atmel_spi *as, struct spi_device *spi)
387 struct atmel_spi_device *asd = spi->controller_state;
392 if (spi_get_csgpiod(spi, 0))
395 chip_select = spi_get_chipselect(spi, 0);
421 * processed by the spi devices.
423 if (spi_get_csgpiod(spi, 0)) {
428 * message because it is already set by the spi core.
430 gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), 0);
431 atmel_spi_send_dummy(as, spi, chip_select);
433 gpiod_set_value_cansleep(spi_get_csgpiod(spi, 0), 1);
437 u32 cpol = (spi->mode & SPI_CPOL) ? SPI_BIT(CPOL) : 0;
442 for (i = 0; i < spi->controller->num_chipselect; i++) {
454 dev_dbg(&spi->dev, "activate NPCS, mr %08x\n", mr);
457 static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi)
462 if (spi_get_csgpiod(spi, 0))
465 chip_select = spi_get_chipselect(spi, 0);
476 dev_dbg(&spi->dev, "DEactivate NPCS, mr %08x\n", mr);
478 if (!spi_get_csgpiod(spi, 0))
504 struct spi_device *spi,
558 * This driver configures the spi controller for host mode (MSTR bit
877 struct spi_device *spi,
884 if (spi_get_csgpiod(spi, 0))
887 chip_select = spi_get_chipselect(spi, 0);
905 dev_err(&spi->dev,
911 dev_err(&spi->dev,
926 * lock is held, spi irq is blocked
1215 static int atmel_word_delay_csr(struct spi_device *spi, struct atmel_spi *as)
1217 struct spi_delay *delay = &spi->word_delay;
1261 static int atmel_spi_setup(struct spi_device *spi)
1266 unsigned int bits = spi->bits_per_word;
1270 as = spi_controller_get_devdata(spi->controller);
1273 if (!spi_get_csgpiod(spi, 0) && (spi->mode & SPI_CS_HIGH)) {
1274 dev_warn(&spi->dev, "setup: non GPIO CS can't be active-high\n");
1285 if (spi_get_csgpiod(spi, 0) && as->native_cs_free) {
1286 dev_err(&spi->dev,
1291 if (spi_get_csgpiod(spi, 0))
1294 chip_select = spi_get_chipselect(spi, 0);
1297 if (spi->mode & SPI_CPOL)
1299 if (!(spi->mode & SPI_CPHA))
1302 if (!spi_get_csgpiod(spi, 0))
1306 word_delay_csr = atmel_word_delay_csr(spi, as);
1315 asd = spi->controller_state;
1321 spi->controller_state = asd;
1326 dev_dbg(&spi->dev,
1328 bits, spi->mode, spi_get_chipselect(spi, 0), csr);
1336 static void atmel_spi_set_cs(struct spi_device *spi, bool enable)
1338 struct atmel_spi *as = spi_controller_get_devdata(spi->controller);
1343 enable = (!!(spi->mode & SPI_CS_HIGH) == enable);
1346 cs_activate(as, spi);
1348 cs_deactivate(as, spi);
1354 struct spi_device *spi,
1368 asd = spi->controller_state;
1371 dev_dbg(&spi->dev,
1386 atmel_spi_set_xfer_speed(as, spi, xfer);
1403 dev_err(&spi->dev,
1421 dev_err(&spi->dev, "spi transfer timeout\n");
1470 static void atmel_spi_cleanup(struct spi_device *spi)
1472 struct atmel_spi_device *asd = spi->controller_state;
1477 spi->controller_state = NULL;
1539 /* setup spi core then atmel-specific driver state */
1544 /* the spi->mode bits understood by this driver: */
1778 { .compatible = "atmel,at91rm9200-spi" },