• Home
  • Raw
  • Download

Lines Matching refs:as

259 static void cs_activate(struct atmel_spi *as, struct spi_device *spi)  in cs_activate()  argument
271 spi_writel(as, CSR0, asd->csr); in cs_activate()
272 spi_writel(as, MR, SPI_BF(PCS, 0x0e) | SPI_BIT(MODFDIS) in cs_activate()
274 mr = spi_readl(as, MR); in cs_activate()
283 csr = spi_readl(as, CSR0 + 4 * i); in cs_activate()
285 spi_writel(as, CSR0 + 4 * i, in cs_activate()
289 mr = spi_readl(as, MR); in cs_activate()
293 spi_writel(as, MR, mr); in cs_activate()
301 static void cs_deactivate(struct atmel_spi *as, struct spi_device *spi) in cs_deactivate() argument
310 mr = spi_readl(as, MR); in cs_deactivate()
313 spi_writel(as, MR, mr); in cs_deactivate()
341 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_next_xfer_data() local
348 *rx_dma = as->buffer_dma; in atmel_spi_next_xfer_data()
355 *tx_dma = as->buffer_dma; in atmel_spi_next_xfer_data()
358 memset(as->buffer, 0, len); in atmel_spi_next_xfer_data()
359 dma_sync_single_for_device(&as->pdev->dev, in atmel_spi_next_xfer_data()
360 as->buffer_dma, len, DMA_TO_DEVICE); in atmel_spi_next_xfer_data()
373 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_next_xfer() local
379 if (!as->current_transfer) in atmel_spi_next_xfer()
382 else if (!as->next_transfer) in atmel_spi_next_xfer()
383 xfer = list_entry(as->current_transfer->transfer_list.next, in atmel_spi_next_xfer()
389 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); in atmel_spi_next_xfer()
395 spi_writel(as, RPR, rx_dma); in atmel_spi_next_xfer()
396 spi_writel(as, TPR, tx_dma); in atmel_spi_next_xfer()
400 spi_writel(as, RCR, len); in atmel_spi_next_xfer()
401 spi_writel(as, TCR, len); in atmel_spi_next_xfer()
408 xfer = as->next_transfer; in atmel_spi_next_xfer()
409 remaining = as->next_remaining_bytes; in atmel_spi_next_xfer()
412 as->current_transfer = xfer; in atmel_spi_next_xfer()
413 as->current_remaining_bytes = remaining; in atmel_spi_next_xfer()
425 as->next_transfer = xfer; in atmel_spi_next_xfer()
432 as->next_remaining_bytes = total - len; in atmel_spi_next_xfer()
434 spi_writel(as, RNPR, rx_dma); in atmel_spi_next_xfer()
435 spi_writel(as, TNPR, tx_dma); in atmel_spi_next_xfer()
439 spi_writel(as, RNCR, len); in atmel_spi_next_xfer()
440 spi_writel(as, TNCR, len); in atmel_spi_next_xfer()
448 spi_writel(as, RNCR, 0); in atmel_spi_next_xfer()
449 spi_writel(as, TNCR, 0); in atmel_spi_next_xfer()
463 spi_writel(as, IER, ieval); in atmel_spi_next_xfer()
464 spi_writel(as, PTCR, SPI_BIT(TXTEN) | SPI_BIT(RXTEN)); in atmel_spi_next_xfer()
469 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_next_message() local
473 BUG_ON(as->current_transfer); in atmel_spi_next_message()
475 msg = list_entry(as->queue.next, struct spi_message, queue); in atmel_spi_next_message()
482 if (as->stay) { in atmel_spi_next_message()
483 if (as->stay != spi) { in atmel_spi_next_message()
484 cs_deactivate(as, as->stay); in atmel_spi_next_message()
485 cs_activate(as, spi); in atmel_spi_next_message()
487 as->stay = NULL; in atmel_spi_next_message()
489 cs_activate(as, spi); in atmel_spi_next_message()
502 atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer) in atmel_spi_dma_map_xfer() argument
504 struct device *dev = &as->pdev->dev; in atmel_spi_dma_map_xfer()
545 atmel_spi_msg_done(struct spi_master *master, struct atmel_spi *as, in atmel_spi_msg_done() argument
549 cs_deactivate(as, msg->spi); in atmel_spi_msg_done()
551 as->stay = msg->spi; in atmel_spi_msg_done()
560 spin_unlock(&as->lock); in atmel_spi_msg_done()
562 spin_lock(&as->lock); in atmel_spi_msg_done()
564 as->current_transfer = NULL; in atmel_spi_msg_done()
565 as->next_transfer = NULL; in atmel_spi_msg_done()
568 if (list_empty(&as->queue) || as->stopping) in atmel_spi_msg_done()
569 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); in atmel_spi_msg_done()
578 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_interrupt() local
584 spin_lock(&as->lock); in atmel_spi_interrupt()
586 xfer = as->current_transfer; in atmel_spi_interrupt()
587 msg = list_entry(as->queue.next, struct spi_message, queue); in atmel_spi_interrupt()
589 imr = spi_readl(as, IMR); in atmel_spi_interrupt()
590 status = spi_readl(as, SR); in atmel_spi_interrupt()
598 spi_writel(as, IDR, (SPI_BIT(RXBUFF) | SPI_BIT(ENDRX) in atmel_spi_interrupt()
612 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); in atmel_spi_interrupt()
621 spi_readl(as, TCR), spi_readl(as, RCR)); in atmel_spi_interrupt()
627 spi_writel(as, RNCR, 0); in atmel_spi_interrupt()
628 spi_writel(as, TNCR, 0); in atmel_spi_interrupt()
629 spi_writel(as, RCR, 0); in atmel_spi_interrupt()
630 spi_writel(as, TCR, 0); in atmel_spi_interrupt()
632 if (spi_readl(as, SR) & SPI_BIT(TXEMPTY)) in atmel_spi_interrupt()
637 while (spi_readl(as, SR) & SPI_BIT(RDRF)) in atmel_spi_interrupt()
638 spi_readl(as, RDR); in atmel_spi_interrupt()
641 spi_readl(as, SR); in atmel_spi_interrupt()
643 atmel_spi_msg_done(master, as, msg, -EIO, 0); in atmel_spi_interrupt()
647 spi_writel(as, IDR, pending); in atmel_spi_interrupt()
649 if (as->current_remaining_bytes == 0) { in atmel_spi_interrupt()
661 atmel_spi_msg_done(master, as, msg, 0, in atmel_spi_interrupt()
665 cs_deactivate(as, msg->spi); in atmel_spi_interrupt()
667 cs_activate(as, msg->spi); in atmel_spi_interrupt()
686 spin_unlock(&as->lock); in atmel_spi_interrupt()
693 struct atmel_spi *as; in atmel_spi_setup() local
701 as = spi_master_get_devdata(spi->master); in atmel_spi_setup()
703 if (as->stopping) in atmel_spi_setup()
729 bus_hz = clk_get_rate(as->clk); in atmel_spi_setup()
789 spin_lock_irqsave(&as->lock, flags); in atmel_spi_setup()
790 if (as->stay == spi) in atmel_spi_setup()
791 as->stay = NULL; in atmel_spi_setup()
792 cs_deactivate(as, spi); in atmel_spi_setup()
793 spin_unlock_irqrestore(&as->lock, flags); in atmel_spi_setup()
803 spi_writel(as, CSR0 + 4 * spi->chip_select, csr); in atmel_spi_setup()
810 struct atmel_spi *as; in atmel_spi_transfer() local
817 as = spi_master_get_devdata(spi->master); in atmel_spi_transfer()
825 if (as->stopping) in atmel_spi_transfer()
859 if (atmel_spi_dma_map_xfer(as, xfer) < 0) in atmel_spi_transfer()
877 spin_lock_irqsave(&as->lock, flags); in atmel_spi_transfer()
878 list_add_tail(&msg->queue, &as->queue); in atmel_spi_transfer()
879 if (!as->current_transfer) in atmel_spi_transfer()
881 spin_unlock_irqrestore(&as->lock, flags); in atmel_spi_transfer()
888 struct atmel_spi *as = spi_master_get_devdata(spi->master); in atmel_spi_cleanup() local
896 spin_lock_irqsave(&as->lock, flags); in atmel_spi_cleanup()
897 if (as->stay == spi) { in atmel_spi_cleanup()
898 as->stay = NULL; in atmel_spi_cleanup()
899 cs_deactivate(as, spi); in atmel_spi_cleanup()
901 spin_unlock_irqrestore(&as->lock, flags); in atmel_spi_cleanup()
917 struct atmel_spi *as; in atmel_spi_probe() local
933 master = spi_alloc_master(&pdev->dev, sizeof *as); in atmel_spi_probe()
947 as = spi_master_get_devdata(master); in atmel_spi_probe()
953 as->buffer = dma_alloc_coherent(&pdev->dev, BUFFER_SIZE, in atmel_spi_probe()
954 &as->buffer_dma, GFP_KERNEL); in atmel_spi_probe()
955 if (!as->buffer) in atmel_spi_probe()
958 spin_lock_init(&as->lock); in atmel_spi_probe()
959 INIT_LIST_HEAD(&as->queue); in atmel_spi_probe()
960 as->pdev = pdev; in atmel_spi_probe()
961 as->regs = ioremap(regs->start, resource_size(regs)); in atmel_spi_probe()
962 if (!as->regs) in atmel_spi_probe()
964 as->irq = irq; in atmel_spi_probe()
965 as->clk = clk; in atmel_spi_probe()
974 spi_writel(as, CR, SPI_BIT(SWRST)); in atmel_spi_probe()
975 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ in atmel_spi_probe()
976 spi_writel(as, MR, SPI_BIT(MSTR) | SPI_BIT(MODFDIS)); in atmel_spi_probe()
977 spi_writel(as, PTCR, SPI_BIT(RXTDIS) | SPI_BIT(TXTDIS)); in atmel_spi_probe()
978 spi_writel(as, CR, SPI_BIT(SPIEN)); in atmel_spi_probe()
991 spi_writel(as, CR, SPI_BIT(SWRST)); in atmel_spi_probe()
992 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ in atmel_spi_probe()
996 iounmap(as->regs); in atmel_spi_probe()
998 dma_free_coherent(&pdev->dev, BUFFER_SIZE, as->buffer, in atmel_spi_probe()
999 as->buffer_dma); in atmel_spi_probe()
1009 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_remove() local
1013 spin_lock_irq(&as->lock); in atmel_spi_remove()
1014 as->stopping = 1; in atmel_spi_remove()
1015 spi_writel(as, CR, SPI_BIT(SWRST)); in atmel_spi_remove()
1016 spi_writel(as, CR, SPI_BIT(SWRST)); /* AT91SAM9263 Rev B workaround */ in atmel_spi_remove()
1017 spi_readl(as, SR); in atmel_spi_remove()
1018 spin_unlock_irq(&as->lock); in atmel_spi_remove()
1021 list_for_each_entry(msg, &as->queue, queue) { in atmel_spi_remove()
1029 dma_free_coherent(&pdev->dev, BUFFER_SIZE, as->buffer, in atmel_spi_remove()
1030 as->buffer_dma); in atmel_spi_remove()
1032 clk_disable(as->clk); in atmel_spi_remove()
1033 clk_put(as->clk); in atmel_spi_remove()
1034 free_irq(as->irq, master); in atmel_spi_remove()
1035 iounmap(as->regs); in atmel_spi_remove()
1047 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_suspend() local
1049 clk_disable(as->clk); in atmel_spi_suspend()
1056 struct atmel_spi *as = spi_master_get_devdata(master); in atmel_spi_resume() local
1058 clk_enable(as->clk); in atmel_spi_resume()