Lines Matching refs:xfer

411 static inline bool atmel_spi_is_vmalloc_xfer(struct spi_transfer *xfer)  in atmel_spi_is_vmalloc_xfer()  argument
413 return is_vmalloc_addr(xfer->tx_buf) || is_vmalloc_addr(xfer->rx_buf); in atmel_spi_is_vmalloc_xfer()
417 struct spi_transfer *xfer) in atmel_spi_use_dma() argument
419 return as->use_dma && xfer->len >= DMA_MIN_BYTES; in atmel_spi_use_dma()
424 struct spi_transfer *xfer) in atmel_spi_can_dma() argument
429 return atmel_spi_use_dma(as, xfer) && in atmel_spi_can_dma()
430 !atmel_spi_is_vmalloc_xfer(xfer); in atmel_spi_can_dma()
432 return atmel_spi_use_dma(as, xfer); in atmel_spi_can_dma()
575 struct spi_transfer *xfer) in atmel_spi_next_xfer_single() argument
578 unsigned long xfer_pos = xfer->len - as->current_remaining_bytes; in atmel_spi_next_xfer_single()
589 if (xfer->bits_per_word > 8) in atmel_spi_next_xfer_single()
590 spi_writel(as, TDR, *(u16 *)(xfer->tx_buf + xfer_pos)); in atmel_spi_next_xfer_single()
592 spi_writel(as, TDR, *(u8 *)(xfer->tx_buf + xfer_pos)); in atmel_spi_next_xfer_single()
596 xfer, xfer->len, xfer->tx_buf, xfer->rx_buf, in atmel_spi_next_xfer_single()
597 xfer->bits_per_word); in atmel_spi_next_xfer_single()
607 struct spi_transfer *xfer) in atmel_spi_next_xfer_fifo() argument
611 u32 offset = xfer->len - as->current_remaining_bytes; in atmel_spi_next_xfer_fifo()
612 const u16 *words = (const u16 *)((u8 *)xfer->tx_buf + offset); in atmel_spi_next_xfer_fifo()
613 const u8 *bytes = (const u8 *)((u8 *)xfer->tx_buf + offset); in atmel_spi_next_xfer_fifo()
620 current_remaining_data = ((xfer->bits_per_word > 8) ? in atmel_spi_next_xfer_fifo()
639 if (xfer->bits_per_word > 8) { in atmel_spi_next_xfer_fifo()
652 if (xfer->bits_per_word > 8) in atmel_spi_next_xfer_fifo()
663 xfer, xfer->len, xfer->tx_buf, xfer->rx_buf, in atmel_spi_next_xfer_fifo()
664 xfer->bits_per_word); in atmel_spi_next_xfer_fifo()
677 struct spi_transfer *xfer) in atmel_spi_next_xfer_pio() argument
682 atmel_spi_next_xfer_fifo(host, xfer); in atmel_spi_next_xfer_pio()
684 atmel_spi_next_xfer_single(host, xfer); in atmel_spi_next_xfer_pio()
691 struct spi_transfer *xfer, in atmel_spi_next_xfer_dma_submit() argument
708 *plen = xfer->len; in atmel_spi_next_xfer_dma_submit()
710 if (atmel_spi_dma_slave_config(as, xfer->bits_per_word)) in atmel_spi_next_xfer_dma_submit()
714 if (atmel_spi_is_vmalloc_xfer(xfer) && in atmel_spi_next_xfer_dma_submit()
718 xfer->len, in atmel_spi_next_xfer_dma_submit()
724 xfer->rx_sg.sgl, in atmel_spi_next_xfer_dma_submit()
725 xfer->rx_sg.nents, in atmel_spi_next_xfer_dma_submit()
733 if (atmel_spi_is_vmalloc_xfer(xfer) && in atmel_spi_next_xfer_dma_submit()
735 memcpy(as->addr_tx_bbuf, xfer->tx_buf, xfer->len); in atmel_spi_next_xfer_dma_submit()
738 xfer->len, DMA_MEM_TO_DEV, in atmel_spi_next_xfer_dma_submit()
743 xfer->tx_sg.sgl, in atmel_spi_next_xfer_dma_submit()
744 xfer->tx_sg.nents, in atmel_spi_next_xfer_dma_submit()
754 xfer, xfer->len, xfer->tx_buf, (unsigned long long)xfer->tx_dma, in atmel_spi_next_xfer_dma_submit()
755 xfer->rx_buf, (unsigned long long)xfer->rx_dma); in atmel_spi_next_xfer_dma_submit()
784 struct spi_transfer *xfer, in atmel_spi_next_xfer_data() argument
789 *rx_dma = xfer->rx_dma + xfer->len - *plen; in atmel_spi_next_xfer_data()
790 *tx_dma = xfer->tx_dma + xfer->len - *plen; in atmel_spi_next_xfer_data()
797 struct spi_transfer *xfer) in atmel_spi_set_xfer_speed() argument
817 scbr = DIV_ROUND_UP(bus_hz, xfer->speed_hz); in atmel_spi_set_xfer_speed()
826 xfer->speed_hz, scbr, bus_hz/255); in atmel_spi_set_xfer_speed()
832 xfer->speed_hz, scbr, bus_hz); in atmel_spi_set_xfer_speed()
838 xfer->effective_speed_hz = bus_hz / scbr; in atmel_spi_set_xfer_speed()
848 struct spi_transfer *xfer) in atmel_spi_pdc_next_xfer() argument
857 atmel_spi_next_xfer_data(host, xfer, &tx_dma, &rx_dma, &len); in atmel_spi_pdc_next_xfer()
863 if (xfer->bits_per_word > 8) in atmel_spi_pdc_next_xfer()
870 xfer, xfer->len, xfer->tx_buf, in atmel_spi_pdc_next_xfer()
871 (unsigned long long)xfer->tx_dma, xfer->rx_buf, in atmel_spi_pdc_next_xfer()
872 (unsigned long long)xfer->rx_dma); in atmel_spi_pdc_next_xfer()
876 atmel_spi_next_xfer_data(host, xfer, &tx_dma, &rx_dma, &len); in atmel_spi_pdc_next_xfer()
882 if (xfer->bits_per_word > 8) in atmel_spi_pdc_next_xfer()
889 xfer, xfer->len, xfer->tx_buf, in atmel_spi_pdc_next_xfer()
890 (unsigned long long)xfer->tx_dma, xfer->rx_buf, in atmel_spi_pdc_next_xfer()
891 (unsigned long long)xfer->rx_dma); in atmel_spi_pdc_next_xfer()
916 atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer) in atmel_spi_dma_map_xfer() argument
920 xfer->tx_dma = xfer->rx_dma = INVALID_DMA_ADDRESS; in atmel_spi_dma_map_xfer()
921 if (xfer->tx_buf) { in atmel_spi_dma_map_xfer()
924 void *nonconst_tx = (void *)xfer->tx_buf; in atmel_spi_dma_map_xfer()
926 xfer->tx_dma = dma_map_single(dev, in atmel_spi_dma_map_xfer()
927 nonconst_tx, xfer->len, in atmel_spi_dma_map_xfer()
929 if (dma_mapping_error(dev, xfer->tx_dma)) in atmel_spi_dma_map_xfer()
932 if (xfer->rx_buf) { in atmel_spi_dma_map_xfer()
933 xfer->rx_dma = dma_map_single(dev, in atmel_spi_dma_map_xfer()
934 xfer->rx_buf, xfer->len, in atmel_spi_dma_map_xfer()
936 if (dma_mapping_error(dev, xfer->rx_dma)) { in atmel_spi_dma_map_xfer()
937 if (xfer->tx_buf) in atmel_spi_dma_map_xfer()
939 xfer->tx_dma, xfer->len, in atmel_spi_dma_map_xfer()
948 struct spi_transfer *xfer) in atmel_spi_dma_unmap_xfer() argument
950 if (xfer->tx_dma != INVALID_DMA_ADDRESS) in atmel_spi_dma_unmap_xfer()
951 dma_unmap_single(host->dev.parent, xfer->tx_dma, in atmel_spi_dma_unmap_xfer()
952 xfer->len, DMA_TO_DEVICE); in atmel_spi_dma_unmap_xfer()
953 if (xfer->rx_dma != INVALID_DMA_ADDRESS) in atmel_spi_dma_unmap_xfer()
954 dma_unmap_single(host->dev.parent, xfer->rx_dma, in atmel_spi_dma_unmap_xfer()
955 xfer->len, DMA_FROM_DEVICE); in atmel_spi_dma_unmap_xfer()
964 atmel_spi_pump_single_data(struct atmel_spi *as, struct spi_transfer *xfer) in atmel_spi_pump_single_data() argument
968 unsigned long xfer_pos = xfer->len - as->current_remaining_bytes; in atmel_spi_pump_single_data()
970 if (xfer->bits_per_word > 8) { in atmel_spi_pump_single_data()
971 rxp16 = (u16 *)(((u8 *)xfer->rx_buf) + xfer_pos); in atmel_spi_pump_single_data()
974 rxp = ((u8 *)xfer->rx_buf) + xfer_pos; in atmel_spi_pump_single_data()
977 if (xfer->bits_per_word > 8) { in atmel_spi_pump_single_data()
988 atmel_spi_pump_fifo_data(struct atmel_spi *as, struct spi_transfer *xfer) in atmel_spi_pump_fifo_data() argument
992 u32 offset = xfer->len - as->current_remaining_bytes; in atmel_spi_pump_fifo_data()
993 u16 *words = (u16 *)((u8 *)xfer->rx_buf + offset); in atmel_spi_pump_fifo_data()
994 u8 *bytes = (u8 *)((u8 *)xfer->rx_buf + offset); in atmel_spi_pump_fifo_data()
998 num_bytes = ((xfer->bits_per_word > 8) ? in atmel_spi_pump_fifo_data()
1008 if (xfer->bits_per_word > 8) in atmel_spi_pump_fifo_data()
1014 if (xfer->bits_per_word > 8) in atmel_spi_pump_fifo_data()
1028 atmel_spi_pump_pio_data(struct atmel_spi *as, struct spi_transfer *xfer) in atmel_spi_pump_pio_data() argument
1031 atmel_spi_pump_fifo_data(as, xfer); in atmel_spi_pump_pio_data()
1033 atmel_spi_pump_single_data(as, xfer); in atmel_spi_pump_pio_data()
1045 struct spi_transfer *xfer; in atmel_spi_pio_interrupt() local
1079 xfer = as->current_transfer; in atmel_spi_pio_interrupt()
1080 atmel_spi_pump_pio_data(as, xfer); in atmel_spi_pio_interrupt()
1274 struct spi_transfer *xfer) in atmel_spi_one_transfer() argument
1288 if (bits != xfer->bits_per_word - 8) { in atmel_spi_one_transfer()
1300 if (atmel_spi_dma_map_xfer(as, xfer) < 0) in atmel_spi_one_transfer()
1304 atmel_spi_set_xfer_speed(as, spi, xfer); in atmel_spi_one_transfer()
1307 as->current_transfer = xfer; in atmel_spi_one_transfer()
1308 as->current_remaining_bytes = xfer->len; in atmel_spi_one_transfer()
1314 atmel_spi_pdc_next_xfer(host, xfer); in atmel_spi_one_transfer()
1316 } else if (atmel_spi_use_dma(as, xfer)) { in atmel_spi_one_transfer()
1319 xfer, &len); in atmel_spi_one_transfer()
1332 atmel_spi_next_xfer_pio(host, xfer); in atmel_spi_one_transfer()
1373 } else if (atmel_spi_use_dma(as, xfer)) { in atmel_spi_one_transfer()
1380 atmel_spi_dma_unmap_xfer(host, xfer); in atmel_spi_one_transfer()