Lines Matching refs:as
340 static bool atmel_spi_is_v2(struct atmel_spi *as) in atmel_spi_is_v2() argument
342 return as->caps.is_spi2; in atmel_spi_is_v2()
365 static void cs_activate(struct atmel_spi *as, struct spi_device *spi) in cs_activate() argument
371 if (atmel_spi_is_v2(as)) { in cs_activate()
372 spi_writel(as, CSR0 + 4 * spi->chip_select, asd->csr); in cs_activate()
376 spi_writel(as, CSR0, asd->csr); in cs_activate()
377 if (as->caps.has_wdrbt) { in cs_activate()
378 spi_writel(as, MR, in cs_activate()
384 spi_writel(as, MR, in cs_activate()
390 mr = spi_readl(as, MR); in cs_activate()
391 if (as->use_cs_gpios) in cs_activate()
400 csr = spi_readl(as, CSR0 + 4 * i); in cs_activate()
402 spi_writel(as, CSR0 + 4 * i, in cs_activate()
406 mr = spi_readl(as, MR); in cs_activate()
408 if (as->use_cs_gpios && spi->chip_select != 0) in cs_activate()
410 spi_writel(as, MR, mr); in cs_activate()
418 static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi) in cs_deactivate() argument
427 mr = spi_readl(as, MR); in cs_deactivate()
430 spi_writel(as, MR, mr); in cs_deactivate()
437 if (!as->use_cs_gpios) in cs_deactivate()
438 spi_writel(as, CR, SPI_BIT(LASTXFER)); in cs_deactivate()
439 else if (atmel_spi_is_v2(as) || spi->chip_select != 0) in cs_deactivate()
443 static void atmel_spi_lock(struct atmel_spi *as) __acquires(&as->lock) in atmel_spi_lock() argument
445 spin_lock_irqsave(&as->lock, as->flags); in atmel_spi_lock()
448 static void atmel_spi_unlock(struct atmel_spi *as) __releases(&as->lock) in atmel_spi_unlock() argument
450 spin_unlock_irqrestore(&as->lock, as->flags); in atmel_spi_unlock()
453 static inline bool atmel_spi_use_dma(struct atmel_spi *as, in atmel_spi_use_dma() argument
456 return as->use_dma && xfer->len >= DMA_MIN_BYTES; in atmel_spi_use_dma()
459 static int atmel_spi_dma_slave_config(struct atmel_spi *as, in atmel_spi_dma_slave_config() argument
473 slave_config->dst_addr = (dma_addr_t)as->phybase + SPI_TDR; in atmel_spi_dma_slave_config()
474 slave_config->src_addr = (dma_addr_t)as->phybase + SPI_RDR; in atmel_spi_dma_slave_config()
494 if (dmaengine_slave_config(as->dma.chan_tx, slave_config)) { in atmel_spi_dma_slave_config()
495 dev_err(&as->pdev->dev, in atmel_spi_dma_slave_config()
509 if (dmaengine_slave_config(as->dma.chan_rx, slave_config)) { in atmel_spi_dma_slave_config()
510 dev_err(&as->pdev->dev, in atmel_spi_dma_slave_config()
518 static int atmel_spi_configure_dma(struct atmel_spi *as) in atmel_spi_configure_dma() argument
521 struct device *dev = &as->pdev->dev; in atmel_spi_configure_dma()
528 as->dma.chan_tx = dma_request_slave_channel_reason(dev, "tx"); in atmel_spi_configure_dma()
529 if (IS_ERR(as->dma.chan_tx)) { in atmel_spi_configure_dma()
530 err = PTR_ERR(as->dma.chan_tx); in atmel_spi_configure_dma()
545 as->dma.chan_rx = dma_request_slave_channel(dev, "rx"); in atmel_spi_configure_dma()
547 if (!as->dma.chan_rx) { in atmel_spi_configure_dma()
554 err = atmel_spi_dma_slave_config(as, &slave_config, 8); in atmel_spi_configure_dma()
558 dev_info(&as->pdev->dev, in atmel_spi_configure_dma()
560 dma_chan_name(as->dma.chan_tx), in atmel_spi_configure_dma()
561 dma_chan_name(as->dma.chan_rx)); in atmel_spi_configure_dma()
564 if (as->dma.chan_rx) in atmel_spi_configure_dma()
565 dma_release_channel(as->dma.chan_rx); in atmel_spi_configure_dma()
566 if (!IS_ERR(as->dma.chan_tx)) in atmel_spi_configure_dma()
567 dma_release_channel(as->dma.chan_tx); in atmel_spi_configure_dma()
571 static void atmel_spi_stop_dma(struct atmel_spi *as) in atmel_spi_stop_dma() argument
573 if (as->dma.chan_rx) in atmel_spi_stop_dma()
574 dmaengine_terminate_all(as->dma.chan_rx); in atmel_spi_stop_dma()
575 if (as->dma.chan_tx) in atmel_spi_stop_dma()
576 dmaengine_terminate_all(as->dma.chan_tx); in atmel_spi_stop_dma()
579 static void atmel_spi_release_dma(struct atmel_spi *as) in atmel_spi_release_dma() argument
581 if (as->dma.chan_rx) in atmel_spi_release_dma()
582 dma_release_channel(as->dma.chan_rx); in atmel_spi_release_dma()
583 if (as->dma.chan_tx) in atmel_spi_release_dma()
584 dma_release_channel(as->dma.chan_tx); in atmel_spi_release_dma()
591 struct atmel_spi *as = spi_master_get_devdata(master); in dma_callback() local
593 complete(&as->xfer_completion); in dma_callback()
602 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_next_xfer_single() local
603 unsigned long xfer_pos = xfer->len - as->current_remaining_bytes; in atmel_spi_next_xfer_single()
608 spi_readl(as, RDR); in atmel_spi_next_xfer_single()
609 while (spi_readl(as, SR) & SPI_BIT(RDRF)) { in atmel_spi_next_xfer_single()
610 spi_readl(as, RDR); in atmel_spi_next_xfer_single()
616 spi_writel(as, TDR, *(u16 *)(xfer->tx_buf + xfer_pos)); in atmel_spi_next_xfer_single()
618 spi_writel(as, TDR, *(u8 *)(xfer->tx_buf + xfer_pos)); in atmel_spi_next_xfer_single()
620 spi_writel(as, TDR, 0); in atmel_spi_next_xfer_single()
629 spi_writel(as, IER, SPI_BIT(RDRF) | SPI_BIT(OVRES)); in atmel_spi_next_xfer_single()
638 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_next_xfer_fifo() local
640 u32 offset = xfer->len - as->current_remaining_bytes; in atmel_spi_next_xfer_fifo()
650 ((u32)as->current_remaining_bytes >> 1) : in atmel_spi_next_xfer_fifo()
651 (u32)as->current_remaining_bytes); in atmel_spi_next_xfer_fifo()
652 num_data = min(current_remaining_data, as->fifo_size); in atmel_spi_next_xfer_fifo()
655 spi_writel(as, CR, SPI_BIT(RXFCLR) | SPI_BIT(TXFCLR)); in atmel_spi_next_xfer_fifo()
656 while (spi_readl(as, FLR)) in atmel_spi_next_xfer_fifo()
660 fifomr = spi_readl(as, FMR); in atmel_spi_next_xfer_fifo()
661 spi_writel(as, FMR, SPI_BFINS(RXFTHRES, num_data, fifomr)); in atmel_spi_next_xfer_fifo()
664 (void)spi_readl(as, SR); in atmel_spi_next_xfer_fifo()
681 spi_writel(as, TDR, (td1 << 16) | td0); in atmel_spi_next_xfer_fifo()
695 spi_writew(as, TDR, td0); in atmel_spi_next_xfer_fifo()
708 spi_writel(as, IER, SPI_BIT(RXFTHF) | SPI_BIT(OVRES)); in atmel_spi_next_xfer_fifo()
717 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_next_xfer_pio() local
719 if (as->fifo_size) in atmel_spi_next_xfer_pio()
732 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_next_xfer_dma_submit() local
733 struct dma_chan *rxchan = as->dma.chan_rx; in atmel_spi_next_xfer_dma_submit()
734 struct dma_chan *txchan = as->dma.chan_tx; in atmel_spi_next_xfer_dma_submit()
748 atmel_spi_unlock(as); in atmel_spi_next_xfer_dma_submit()
751 sg_init_table(&as->dma.sgrx, 1); in atmel_spi_next_xfer_dma_submit()
753 as->dma.sgrx.dma_address = xfer->rx_dma + xfer->len - *plen; in atmel_spi_next_xfer_dma_submit()
755 as->dma.sgrx.dma_address = as->buffer_dma; in atmel_spi_next_xfer_dma_submit()
761 sg_init_table(&as->dma.sgtx, 1); in atmel_spi_next_xfer_dma_submit()
763 as->dma.sgtx.dma_address = xfer->tx_dma + xfer->len - *plen; in atmel_spi_next_xfer_dma_submit()
765 as->dma.sgtx.dma_address = as->buffer_dma; in atmel_spi_next_xfer_dma_submit()
768 memset(as->buffer, 0, len); in atmel_spi_next_xfer_dma_submit()
771 sg_dma_len(&as->dma.sgtx) = len; in atmel_spi_next_xfer_dma_submit()
772 sg_dma_len(&as->dma.sgrx) = len; in atmel_spi_next_xfer_dma_submit()
776 if (atmel_spi_dma_slave_config(as, &slave_config, in atmel_spi_next_xfer_dma_submit()
781 rxdesc = dmaengine_prep_slave_sg(rxchan, &as->dma.sgrx, 1, in atmel_spi_next_xfer_dma_submit()
787 txdesc = dmaengine_prep_slave_sg(txchan, &as->dma.sgtx, 1, in atmel_spi_next_xfer_dma_submit()
799 spi_writel(as, IER, SPI_BIT(OVRES)); in atmel_spi_next_xfer_dma_submit()
816 atmel_spi_lock(as); in atmel_spi_next_xfer_dma_submit()
820 spi_writel(as, IDR, SPI_BIT(OVRES)); in atmel_spi_next_xfer_dma_submit()
821 atmel_spi_stop_dma(as); in atmel_spi_next_xfer_dma_submit()
823 atmel_spi_lock(as); in atmel_spi_next_xfer_dma_submit()
833 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_next_xfer_data() local
840 *rx_dma = as->buffer_dma; in atmel_spi_next_xfer_data()
848 *tx_dma = as->buffer_dma; in atmel_spi_next_xfer_data()
851 memset(as->buffer, 0, len); in atmel_spi_next_xfer_data()
852 dma_sync_single_for_device(&as->pdev->dev, in atmel_spi_next_xfer_data()
853 as->buffer_dma, len, DMA_TO_DEVICE); in atmel_spi_next_xfer_data()
859 static int atmel_spi_set_xfer_speed(struct atmel_spi *as, in atmel_spi_set_xfer_speed() argument
867 bus_hz = clk_get_rate(as->clk); in atmel_spi_set_xfer_speed()
868 if (!atmel_spi_is_v2(as)) in atmel_spi_set_xfer_speed()
893 csr = spi_readl(as, CSR0 + 4 * spi->chip_select); in atmel_spi_set_xfer_speed()
895 spi_writel(as, CSR0 + 4 * spi->chip_select, csr); in atmel_spi_set_xfer_speed()
908 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_pdc_next_xfer() local
912 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); in atmel_spi_pdc_next_xfer()
914 len = as->current_remaining_bytes; in atmel_spi_pdc_next_xfer()
916 as->current_remaining_bytes -= len; in atmel_spi_pdc_next_xfer()
918 spi_writel(as, RPR, rx_dma); in atmel_spi_pdc_next_xfer()
919 spi_writel(as, TPR, tx_dma); in atmel_spi_pdc_next_xfer()
923 spi_writel(as, RCR, len); in atmel_spi_pdc_next_xfer()
924 spi_writel(as, TCR, len); in atmel_spi_pdc_next_xfer()
932 if (as->current_remaining_bytes) { in atmel_spi_pdc_next_xfer()
933 len = as->current_remaining_bytes; in atmel_spi_pdc_next_xfer()
935 as->current_remaining_bytes -= len; in atmel_spi_pdc_next_xfer()
937 spi_writel(as, RNPR, rx_dma); in atmel_spi_pdc_next_xfer()
938 spi_writel(as, TNPR, tx_dma); in atmel_spi_pdc_next_xfer()
942 spi_writel(as, RNCR, len); in atmel_spi_pdc_next_xfer()
943 spi_writel(as, TNCR, len); in atmel_spi_pdc_next_xfer()
962 spi_writel(as, IER, SPI_BIT(RXBUFF) | SPI_BIT(OVRES)); in atmel_spi_pdc_next_xfer()
963 spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN)); in atmel_spi_pdc_next_xfer()
974 atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer) in atmel_spi_dma_map_xfer() argument
976 struct device *dev = &as->pdev->dev; in atmel_spi_dma_map_xfer()
1016 static void atmel_spi_disable_pdc_transfer(struct atmel_spi *as) in atmel_spi_disable_pdc_transfer() argument
1018 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); in atmel_spi_disable_pdc_transfer()
1022 atmel_spi_pump_single_data(struct atmel_spi *as, struct spi_transfer *xfer) in atmel_spi_pump_single_data() argument
1026 unsigned long xfer_pos = xfer->len - as->current_remaining_bytes; in atmel_spi_pump_single_data()
1031 *rxp16 = spi_readl(as, RDR); in atmel_spi_pump_single_data()
1034 *rxp = spi_readl(as, RDR); in atmel_spi_pump_single_data()
1037 spi_readl(as, RDR); in atmel_spi_pump_single_data()
1040 if (as->current_remaining_bytes > 2) in atmel_spi_pump_single_data()
1041 as->current_remaining_bytes -= 2; in atmel_spi_pump_single_data()
1043 as->current_remaining_bytes = 0; in atmel_spi_pump_single_data()
1045 as->current_remaining_bytes--; in atmel_spi_pump_single_data()
1050 atmel_spi_pump_fifo_data(struct atmel_spi *as, struct spi_transfer *xfer) in atmel_spi_pump_fifo_data() argument
1052 u32 fifolr = spi_readl(as, FLR); in atmel_spi_pump_fifo_data()
1054 u32 offset = xfer->len - as->current_remaining_bytes; in atmel_spi_pump_fifo_data()
1064 if (as->current_remaining_bytes > num_bytes) in atmel_spi_pump_fifo_data()
1065 as->current_remaining_bytes -= num_bytes; in atmel_spi_pump_fifo_data()
1067 as->current_remaining_bytes = 0; in atmel_spi_pump_fifo_data()
1071 as->current_remaining_bytes &= ~0x1; in atmel_spi_pump_fifo_data()
1075 rd = spi_readl(as, RDR); in atmel_spi_pump_fifo_data()
1092 atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer) in atmel_spi_pump_pio_data() argument
1094 if (as->fifo_size) in atmel_spi_pump_pio_data()
1095 atmel_spi_pump_fifo_data(as, xfer); in atmel_spi_pump_pio_data()
1097 atmel_spi_pump_single_data(as, xfer); in atmel_spi_pump_pio_data()
1109 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_pio_interrupt() local
1114 imr = spi_readl(as, IMR); in atmel_spi_pio_interrupt()
1115 status = spi_readl(as, SR); in atmel_spi_pio_interrupt()
1120 spi_writel(as, IDR, SPI_BIT(OVRES)); in atmel_spi_pio_interrupt()
1132 as->done_status = -EIO; in atmel_spi_pio_interrupt()
1136 spi_readl(as, SR); in atmel_spi_pio_interrupt()
1138 complete(&as->xfer_completion); in atmel_spi_pio_interrupt()
1141 atmel_spi_lock(as); in atmel_spi_pio_interrupt()
1143 if (as->current_remaining_bytes) { in atmel_spi_pio_interrupt()
1145 xfer = as->current_transfer; in atmel_spi_pio_interrupt()
1146 atmel_spi_pump_pio_data(as, xfer); in atmel_spi_pio_interrupt()
1147 if (!as->current_remaining_bytes) in atmel_spi_pio_interrupt()
1148 spi_writel(as, IDR, pending); in atmel_spi_pio_interrupt()
1150 complete(&as->xfer_completion); in atmel_spi_pio_interrupt()
1153 atmel_spi_unlock(as); in atmel_spi_pio_interrupt()
1157 spi_writel(as, IDR, pending); in atmel_spi_pio_interrupt()
1167 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_pdc_interrupt() local
1171 imr = spi_readl(as, IMR); in atmel_spi_pdc_interrupt()
1172 status = spi_readl(as, SR); in atmel_spi_pdc_interrupt()
1179 spi_writel(as, IDR, (SPI_BIT(RXBUFF) | SPI_BIT(ENDRX) in atmel_spi_pdc_interrupt()
1183 spi_readl(as, SR); in atmel_spi_pdc_interrupt()
1185 as->done_status = -EIO; in atmel_spi_pdc_interrupt()
1187 complete(&as->xfer_completion); in atmel_spi_pdc_interrupt()
1192 spi_writel(as, IDR, pending); in atmel_spi_pdc_interrupt()
1194 complete(&as->xfer_completion); in atmel_spi_pdc_interrupt()
1202 struct atmel_spi *as; in atmel_spi_setup() local
1209 as = spi_master_get_devdata(spi->master); in atmel_spi_setup()
1212 if (!atmel_spi_is_v2(as) in atmel_spi_setup()
1224 if (!as->use_cs_gpios) in atmel_spi_setup()
1239 if (!as->use_cs_gpios) in atmel_spi_setup()
1250 if (as->use_cs_gpios) { in atmel_spi_setup()
1271 if (!atmel_spi_is_v2(as)) in atmel_spi_setup()
1272 spi_writel(as, CSR0 + 4 * spi->chip_select, csr); in atmel_spi_setup()
1281 struct atmel_spi *as; in atmel_spi_one_transfer() local
1290 as = spi_master_get_devdata(master); in atmel_spi_one_transfer()
1310 && (atmel_spi_use_dma(as, xfer) || as->use_pdc)) { in atmel_spi_one_transfer()
1311 if (atmel_spi_dma_map_xfer(as, xfer) < 0) in atmel_spi_one_transfer()
1315 atmel_spi_set_xfer_speed(as, msg->spi, xfer); in atmel_spi_one_transfer()
1317 as->done_status = 0; in atmel_spi_one_transfer()
1318 as->current_transfer = xfer; in atmel_spi_one_transfer()
1319 as->current_remaining_bytes = xfer->len; in atmel_spi_one_transfer()
1320 while (as->current_remaining_bytes) { in atmel_spi_one_transfer()
1321 reinit_completion(&as->xfer_completion); in atmel_spi_one_transfer()
1323 if (as->use_pdc) { in atmel_spi_one_transfer()
1325 } else if (atmel_spi_use_dma(as, xfer)) { in atmel_spi_one_transfer()
1326 len = as->current_remaining_bytes; in atmel_spi_one_transfer()
1334 as->current_remaining_bytes -= len; in atmel_spi_one_transfer()
1335 if (as->current_remaining_bytes < 0) in atmel_spi_one_transfer()
1336 as->current_remaining_bytes = 0; in atmel_spi_one_transfer()
1343 atmel_spi_unlock(as); in atmel_spi_one_transfer()
1344 dma_timeout = wait_for_completion_timeout(&as->xfer_completion, in atmel_spi_one_transfer()
1346 atmel_spi_lock(as); in atmel_spi_one_transfer()
1349 as->done_status = -EIO; in atmel_spi_one_transfer()
1352 if (as->done_status) in atmel_spi_one_transfer()
1356 if (as->done_status) { in atmel_spi_one_transfer()
1357 if (as->use_pdc) { in atmel_spi_one_transfer()
1360 spi_readl(as, TCR), spi_readl(as, RCR)); in atmel_spi_one_transfer()
1366 spi_writel(as, RNCR, 0); in atmel_spi_one_transfer()
1367 spi_writel(as, TNCR, 0); in atmel_spi_one_transfer()
1368 spi_writel(as, RCR, 0); in atmel_spi_one_transfer()
1369 spi_writel(as, TCR, 0); in atmel_spi_one_transfer()
1371 if (spi_readl(as, SR) & SPI_BIT(TXEMPTY)) in atmel_spi_one_transfer()
1376 while (spi_readl(as, SR) & SPI_BIT(RDRF)) in atmel_spi_one_transfer()
1377 spi_readl(as, RDR); in atmel_spi_one_transfer()
1380 spi_readl(as, SR); in atmel_spi_one_transfer()
1382 } else if (atmel_spi_use_dma(as, xfer)) { in atmel_spi_one_transfer()
1383 atmel_spi_stop_dma(as); in atmel_spi_one_transfer()
1387 && (atmel_spi_use_dma(as, xfer) || as->use_pdc)) in atmel_spi_one_transfer()
1398 && (atmel_spi_use_dma(as, xfer) || as->use_pdc)) in atmel_spi_one_transfer()
1407 as->keep_cs = true; in atmel_spi_one_transfer()
1409 as->cs_active = !as->cs_active; in atmel_spi_one_transfer()
1410 if (as->cs_active) in atmel_spi_one_transfer()
1411 cs_activate(as, msg->spi); in atmel_spi_one_transfer()
1413 cs_deactivate(as, msg->spi); in atmel_spi_one_transfer()
1423 struct atmel_spi *as; in atmel_spi_transfer_one_message() local
1428 as = spi_master_get_devdata(master); in atmel_spi_transfer_one_message()
1433 atmel_spi_lock(as); in atmel_spi_transfer_one_message()
1434 cs_activate(as, spi); in atmel_spi_transfer_one_message()
1436 as->cs_active = true; in atmel_spi_transfer_one_message()
1437 as->keep_cs = false; in atmel_spi_transfer_one_message()
1448 if (as->use_pdc) in atmel_spi_transfer_one_message()
1449 atmel_spi_disable_pdc_transfer(as); in atmel_spi_transfer_one_message()
1460 if (!as->keep_cs) in atmel_spi_transfer_one_message()
1461 cs_deactivate(as, msg->spi); in atmel_spi_transfer_one_message()
1463 atmel_spi_unlock(as); in atmel_spi_transfer_one_message()
1465 msg->status = as->done_status; in atmel_spi_transfer_one_message()
1484 static inline unsigned int atmel_get_version(struct atmel_spi *as) in atmel_get_version() argument
1486 return spi_readl(as, VERSION) & 0x00000fff; in atmel_get_version()
1489 static void atmel_get_caps(struct atmel_spi *as) in atmel_get_caps() argument
1493 version = atmel_get_version(as); in atmel_get_caps()
1494 dev_info(&as->pdev->dev, "version: 0x%x\n", version); in atmel_get_caps()
1496 as->caps.is_spi2 = version > 0x121; in atmel_get_caps()
1497 as->caps.has_wdrbt = version >= 0x210; in atmel_get_caps()
1498 as->caps.has_dma_support = version >= 0x212; in atmel_get_caps()
1510 struct atmel_spi *as; in atmel_spi_probe() local
1529 master = spi_alloc_master(&pdev->dev, sizeof(*as)); in atmel_spi_probe()
1545 as = spi_master_get_devdata(master); in atmel_spi_probe()
1551 as->buffer = dma_alloc_coherent(&pdev->dev, BUFFER_SIZE, in atmel_spi_probe()
1552 &as->buffer_dma, GFP_KERNEL); in atmel_spi_probe()
1553 if (!as->buffer) in atmel_spi_probe()
1556 spin_lock_init(&as->lock); in atmel_spi_probe()
1558 as->pdev = pdev; in atmel_spi_probe()
1559 as->regs = devm_ioremap_resource(&pdev->dev, regs); in atmel_spi_probe()
1560 if (IS_ERR(as->regs)) { in atmel_spi_probe()
1561 ret = PTR_ERR(as->regs); in atmel_spi_probe()
1564 as->phybase = regs->start; in atmel_spi_probe()
1565 as->irq = irq; in atmel_spi_probe()
1566 as->clk = clk; in atmel_spi_probe()
1568 init_completion(&as->xfer_completion); in atmel_spi_probe()
1570 atmel_get_caps(as); in atmel_spi_probe()
1572 as->use_cs_gpios = true; in atmel_spi_probe()
1573 if (atmel_spi_is_v2(as) && in atmel_spi_probe()
1576 as->use_cs_gpios = false; in atmel_spi_probe()
1580 as->use_dma = false; in atmel_spi_probe()
1581 as->use_pdc = false; in atmel_spi_probe()
1582 if (as->caps.has_dma_support) { in atmel_spi_probe()
1583 ret = atmel_spi_configure_dma(as); in atmel_spi_probe()
1585 as->use_dma = true; in atmel_spi_probe()
1589 as->use_pdc = true; in atmel_spi_probe()
1592 if (as->caps.has_dma_support && !as->use_dma) in atmel_spi_probe()
1595 if (as->use_pdc) { in atmel_spi_probe()
1609 spi_writel(as, CR, SPI_BIT(SWRST)); in atmel_spi_probe()
1610 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ in atmel_spi_probe()
1611 if (as->caps.has_wdrbt) { in atmel_spi_probe()
1612 spi_writel(as, MR, SPI_BIT(WDRBT) | SPI_BIT(MODFDIS) in atmel_spi_probe()
1615 spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS)); in atmel_spi_probe()
1618 if (as->use_pdc) in atmel_spi_probe()
1619 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); in atmel_spi_probe()
1620 spi_writel(as, CR, SPI_BIT(SPIEN)); in atmel_spi_probe()
1622 as->fifo_size = 0; in atmel_spi_probe()
1624 &as->fifo_size)) { in atmel_spi_probe()
1625 dev_info(&pdev->dev, "Using FIFO (%u data)\n", as->fifo_size); in atmel_spi_probe()
1626 spi_writel(as, CR, SPI_BIT(FIFOEN)); in atmel_spi_probe()
1648 if (as->use_dma) in atmel_spi_probe()
1649 atmel_spi_release_dma(as); in atmel_spi_probe()
1651 spi_writel(as, CR, SPI_BIT(SWRST)); in atmel_spi_probe()
1652 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ in atmel_spi_probe()
1657 dma_free_coherent(&pdev->dev, BUFFER_SIZE, as->buffer, in atmel_spi_probe()
1658 as->buffer_dma); in atmel_spi_probe()
1667 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_remove() local
1672 if (as->use_dma) { in atmel_spi_remove()
1673 atmel_spi_stop_dma(as); in atmel_spi_remove()
1674 atmel_spi_release_dma(as); in atmel_spi_remove()
1677 spin_lock_irq(&as->lock); in atmel_spi_remove()
1678 spi_writel(as, CR, SPI_BIT(SWRST)); in atmel_spi_remove()
1679 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ in atmel_spi_remove()
1680 spi_readl(as, SR); in atmel_spi_remove()
1681 spin_unlock_irq(&as->lock); in atmel_spi_remove()
1683 dma_free_coherent(&pdev->dev, BUFFER_SIZE, as->buffer, in atmel_spi_remove()
1684 as->buffer_dma); in atmel_spi_remove()
1686 clk_disable_unprepare(as->clk); in atmel_spi_remove()
1698 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_runtime_suspend() local
1700 clk_disable_unprepare(as->clk); in atmel_spi_runtime_suspend()
1709 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_runtime_resume() local
1713 return clk_prepare_enable(as->clk); in atmel_spi_runtime_resume()