Lines Matching refs:aus

106 	struct at91_usart_spi   *aus = spi_controller_get_devdata(ctlr);  in dma_callback()  local
108 at91_usart_spi_writel(aus, IER, US_IR_RXRDY); in dma_callback()
109 aus->current_rx_remaining_bytes = 0; in dma_callback()
110 complete(&aus->xfer_completion); in dma_callback()
117 struct at91_usart_spi *aus = spi_controller_get_devdata(ctrl); in at91_usart_spi_can_dma() local
119 return aus->use_dma && xfer->len >= US_DMA_MIN_BYTES; in at91_usart_spi_can_dma()
123 struct at91_usart_spi *aus) in at91_usart_spi_configure_dma() argument
126 struct device *dev = &aus->mpdev->dev; in at91_usart_spi_configure_dma()
127 phys_addr_t phybase = aus->phybase; in at91_usart_spi_configure_dma()
170 aus->use_dma = true; in at91_usart_spi_configure_dma()
204 struct at91_usart_spi *aus = spi_controller_get_devdata(ctlr); in at91_usart_spi_dma_transfer() local
212 at91_usart_spi_writel(aus, IDR, US_IR_RXRDY); in at91_usart_spi_dma_transfer()
250 at91_usart_spi_writel(aus, IER, US_IR_RXRDY); in at91_usart_spi_dma_transfer()
256 static unsigned long at91_usart_spi_dma_timeout(struct at91_usart_spi *aus) in at91_usart_spi_dma_timeout() argument
258 return wait_for_completion_timeout(&aus->xfer_completion, in at91_usart_spi_dma_timeout()
262 static inline u32 at91_usart_spi_tx_ready(struct at91_usart_spi *aus) in at91_usart_spi_tx_ready() argument
264 return aus->status & US_IR_TXRDY; in at91_usart_spi_tx_ready()
267 static inline u32 at91_usart_spi_rx_ready(struct at91_usart_spi *aus) in at91_usart_spi_rx_ready() argument
269 return aus->status & US_IR_RXRDY; in at91_usart_spi_rx_ready()
272 static inline u32 at91_usart_spi_check_overrun(struct at91_usart_spi *aus) in at91_usart_spi_check_overrun() argument
274 return aus->status & US_IR_OVRE; in at91_usart_spi_check_overrun()
277 static inline u32 at91_usart_spi_read_status(struct at91_usart_spi *aus) in at91_usart_spi_read_status() argument
279 aus->status = at91_usart_spi_readl(aus, CSR); in at91_usart_spi_read_status()
280 return aus->status; in at91_usart_spi_read_status()
283 static inline void at91_usart_spi_tx(struct at91_usart_spi *aus) in at91_usart_spi_tx() argument
285 unsigned int len = aus->current_transfer->len; in at91_usart_spi_tx()
286 unsigned int remaining = aus->current_tx_remaining_bytes; in at91_usart_spi_tx()
287 const u8 *tx_buf = aus->current_transfer->tx_buf; in at91_usart_spi_tx()
292 if (at91_usart_spi_tx_ready(aus)) { in at91_usart_spi_tx()
293 at91_usart_spi_writeb(aus, THR, tx_buf[len - remaining]); in at91_usart_spi_tx()
294 aus->current_tx_remaining_bytes--; in at91_usart_spi_tx()
298 static inline void at91_usart_spi_rx(struct at91_usart_spi *aus) in at91_usart_spi_rx() argument
300 int len = aus->current_transfer->len; in at91_usart_spi_rx()
301 int remaining = aus->current_rx_remaining_bytes; in at91_usart_spi_rx()
302 u8 *rx_buf = aus->current_transfer->rx_buf; in at91_usart_spi_rx()
307 rx_buf[len - remaining] = at91_usart_spi_readb(aus, RHR); in at91_usart_spi_rx()
308 aus->current_rx_remaining_bytes--; in at91_usart_spi_rx()
312 at91_usart_spi_set_xfer_speed(struct at91_usart_spi *aus, in at91_usart_spi_set_xfer_speed() argument
315 at91_usart_spi_writel(aus, BRGR, in at91_usart_spi_set_xfer_speed()
316 DIV_ROUND_UP(aus->spi_clk, xfer->speed_hz)); in at91_usart_spi_set_xfer_speed()
322 struct at91_usart_spi *aus = spi_controller_get_devdata(controller); in at91_usart_spi_interrupt() local
324 spin_lock(&aus->lock); in at91_usart_spi_interrupt()
325 at91_usart_spi_read_status(aus); in at91_usart_spi_interrupt()
327 if (at91_usart_spi_check_overrun(aus)) { in at91_usart_spi_interrupt()
328 aus->xfer_failed = true; in at91_usart_spi_interrupt()
329 at91_usart_spi_writel(aus, IDR, US_IR_OVRE | US_IR_RXRDY); in at91_usart_spi_interrupt()
330 spin_unlock(&aus->lock); in at91_usart_spi_interrupt()
334 if (at91_usart_spi_rx_ready(aus)) { in at91_usart_spi_interrupt()
335 at91_usart_spi_rx(aus); in at91_usart_spi_interrupt()
336 spin_unlock(&aus->lock); in at91_usart_spi_interrupt()
340 spin_unlock(&aus->lock); in at91_usart_spi_interrupt()
347 struct at91_usart_spi *aus = spi_controller_get_devdata(spi->controller); in at91_usart_spi_setup() local
349 unsigned int mr = at91_usart_spi_readl(aus, MR); in at91_usart_spi_setup()
387 struct at91_usart_spi *aus = spi_controller_get_devdata(ctlr); in at91_usart_spi_transfer_one() local
391 at91_usart_spi_set_xfer_speed(aus, xfer); in at91_usart_spi_transfer_one()
392 aus->xfer_failed = false; in at91_usart_spi_transfer_one()
393 aus->current_transfer = xfer; in at91_usart_spi_transfer_one()
394 aus->current_tx_remaining_bytes = xfer->len; in at91_usart_spi_transfer_one()
395 aus->current_rx_remaining_bytes = xfer->len; in at91_usart_spi_transfer_one()
397 while ((aus->current_tx_remaining_bytes || in at91_usart_spi_transfer_one()
398 aus->current_rx_remaining_bytes) && !aus->xfer_failed) { in at91_usart_spi_transfer_one()
399 reinit_completion(&aus->xfer_completion); in at91_usart_spi_transfer_one()
406 dma_timeout = at91_usart_spi_dma_timeout(aus); in at91_usart_spi_transfer_one()
412 aus->current_tx_remaining_bytes = 0; in at91_usart_spi_transfer_one()
414 at91_usart_spi_read_status(aus); in at91_usart_spi_transfer_one()
415 at91_usart_spi_tx(aus); in at91_usart_spi_transfer_one()
421 if (aus->xfer_failed) { in at91_usart_spi_transfer_one()
422 dev_err(aus->dev, "Overrun!\n"); in at91_usart_spi_transfer_one()
432 struct at91_usart_spi *aus = spi_controller_get_devdata(ctlr); in at91_usart_spi_prepare_message() local
436 at91_usart_spi_writel(aus, CR, US_ENABLE); in at91_usart_spi_prepare_message()
437 at91_usart_spi_writel(aus, IER, US_OVRE_RXRDY_IRQS); in at91_usart_spi_prepare_message()
438 at91_usart_spi_writel(aus, MR, *ausd); in at91_usart_spi_prepare_message()
446 struct at91_usart_spi *aus = spi_controller_get_devdata(ctlr); in at91_usart_spi_unprepare_message() local
448 at91_usart_spi_writel(aus, CR, US_RESET | US_DISABLE); in at91_usart_spi_unprepare_message()
449 at91_usart_spi_writel(aus, IDR, US_OVRE_RXRDY_IRQS); in at91_usart_spi_unprepare_message()
462 static void at91_usart_spi_init(struct at91_usart_spi *aus) in at91_usart_spi_init() argument
464 at91_usart_spi_writel(aus, MR, US_INIT); in at91_usart_spi_init()
465 at91_usart_spi_writel(aus, CR, US_RESET | US_DISABLE); in at91_usart_spi_init()
481 struct at91_usart_spi *aus; in at91_usart_spi_probe() local
500 controller = spi_alloc_host(&pdev->dev, sizeof(*aus)); in at91_usart_spi_probe()
524 aus = spi_controller_get_devdata(controller); in at91_usart_spi_probe()
526 aus->dev = &pdev->dev; in at91_usart_spi_probe()
527 aus->regs = devm_ioremap_resource(&pdev->dev, regs); in at91_usart_spi_probe()
528 if (IS_ERR(aus->regs)) { in at91_usart_spi_probe()
529 ret = PTR_ERR(aus->regs); in at91_usart_spi_probe()
533 aus->irq = irq; in at91_usart_spi_probe()
534 aus->clk = clk; in at91_usart_spi_probe()
545 aus->spi_clk = clk_get_rate(clk); in at91_usart_spi_probe()
546 at91_usart_spi_init(aus); in at91_usart_spi_probe()
548 aus->phybase = regs->start; in at91_usart_spi_probe()
550 aus->mpdev = to_platform_device(pdev->dev.parent); in at91_usart_spi_probe()
552 ret = at91_usart_spi_configure_dma(controller, aus); in at91_usart_spi_probe()
556 spin_lock_init(&aus->lock); in at91_usart_spi_probe()
557 init_completion(&aus->xfer_completion); in at91_usart_spi_probe()
565 at91_usart_spi_readl(aus, VERSION), in at91_usart_spi_probe()
582 struct at91_usart_spi *aus = spi_controller_get_devdata(ctlr); in at91_usart_spi_runtime_suspend() local
584 clk_disable_unprepare(aus->clk); in at91_usart_spi_runtime_suspend()
593 struct at91_usart_spi *aus = spi_controller_get_devdata(ctrl); in at91_usart_spi_runtime_resume() local
597 return clk_prepare_enable(aus->clk); in at91_usart_spi_runtime_resume()
618 struct at91_usart_spi *aus = spi_controller_get_devdata(ctrl); in at91_usart_spi_resume() local
627 at91_usart_spi_init(aus); in at91_usart_spi_resume()
635 struct at91_usart_spi *aus = spi_controller_get_devdata(ctlr); in at91_usart_spi_remove() local
638 clk_disable_unprepare(aus->clk); in at91_usart_spi_remove()