Lines Matching refs:port

58 static void atmel_start_rx(struct uart_port *port);
59 static void atmel_stop_rx(struct uart_port *port);
183 int (*prepare_rx)(struct uart_port *port);
184 int (*prepare_tx)(struct uart_port *port);
185 void (*schedule_rx)(struct uart_port *port);
186 void (*schedule_tx)(struct uart_port *port);
187 void (*release_rx)(struct uart_port *port);
188 void (*release_tx)(struct uart_port *port);
207 static inline u32 atmel_uart_readl(struct uart_port *port, u32 reg) in atmel_uart_readl() argument
209 return __raw_readl(port->membase + reg); in atmel_uart_readl()
212 static inline void atmel_uart_writel(struct uart_port *port, u32 reg, u32 value) in atmel_uart_writel() argument
214 __raw_writel(value, port->membase + reg); in atmel_uart_writel()
217 static inline u8 atmel_uart_read_char(struct uart_port *port) in atmel_uart_read_char() argument
219 return __raw_readb(port->membase + ATMEL_US_RHR); in atmel_uart_read_char()
222 static inline void atmel_uart_write_char(struct uart_port *port, u8 value) in atmel_uart_write_char() argument
224 __raw_writeb(value, port->membase + ATMEL_US_THR); in atmel_uart_write_char()
227 static inline int atmel_uart_is_half_duplex(struct uart_port *port) in atmel_uart_is_half_duplex() argument
229 return ((port->rs485.flags & SER_RS485_ENABLED) && in atmel_uart_is_half_duplex()
230 !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || in atmel_uart_is_half_duplex()
231 (port->iso7816.flags & SER_ISO7816_ENABLED); in atmel_uart_is_half_duplex()
240 static bool atmel_use_pdc_rx(struct uart_port *port) in atmel_use_pdc_rx() argument
242 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_rx()
247 static bool atmel_use_pdc_tx(struct uart_port *port) in atmel_use_pdc_tx() argument
249 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_tx()
254 static bool atmel_use_pdc_rx(struct uart_port *port) in atmel_use_pdc_rx() argument
259 static bool atmel_use_pdc_tx(struct uart_port *port) in atmel_use_pdc_tx() argument
265 static bool atmel_use_dma_tx(struct uart_port *port) in atmel_use_dma_tx() argument
267 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_tx()
272 static bool atmel_use_dma_rx(struct uart_port *port) in atmel_use_dma_rx() argument
274 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_rx()
279 static bool atmel_use_fifo(struct uart_port *port) in atmel_use_fifo() argument
281 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_fifo()
294 static int atmel_config_rs485(struct uart_port *port, struct ktermios *termios, in atmel_config_rs485() argument
297 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_rs485()
301 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_rs485()
303 mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_rs485()
306 dev_dbg(port->dev, "Setting UART to RS485\n"); in atmel_config_rs485()
312 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_config_rs485()
317 dev_dbg(port->dev, "Setting UART to RS232\n"); in atmel_config_rs485()
318 if (atmel_use_pdc_tx(port)) in atmel_config_rs485()
324 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_config_rs485()
327 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_rs485()
332 static unsigned int atmel_calc_cd(struct uart_port *port, in atmel_calc_cd() argument
335 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_calc_cd()
345 static unsigned int atmel_calc_fidi(struct uart_port *port, in atmel_calc_fidi() argument
359 static int atmel_config_iso7816(struct uart_port *port, in atmel_config_iso7816() argument
362 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_iso7816()
368 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_iso7816()
370 mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_iso7816()
376 dev_err(port->dev, "ISO7816: Timeguard exceeding 255\n"); in atmel_config_iso7816()
389 dev_err(port->dev, "ISO7816: Type not supported\n"); in atmel_config_iso7816()
402 cd = atmel_calc_cd(port, iso7816conf); in atmel_config_iso7816()
403 fidi = atmel_calc_fidi(port, iso7816conf); in atmel_config_iso7816()
405 dev_warn(port->dev, "ISO7816 fidi = 0, Generator generates no signal\n"); in atmel_config_iso7816()
408 dev_err(port->dev, "ISO7816 fidi = %u, value not supported\n", fidi); in atmel_config_iso7816()
414 if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) { in atmel_config_iso7816()
416 atmel_port->backup_mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_iso7816()
417 atmel_port->backup_brgr = atmel_uart_readl(port, ATMEL_US_BRGR); in atmel_config_iso7816()
420 atmel_uart_writel(port, ATMEL_US_TTGR, iso7816conf->tg); in atmel_config_iso7816()
421 atmel_uart_writel(port, ATMEL_US_BRGR, cd); in atmel_config_iso7816()
422 atmel_uart_writel(port, ATMEL_US_FIDI, fidi); in atmel_config_iso7816()
424 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXEN); in atmel_config_iso7816()
427 dev_dbg(port->dev, "Setting UART back to RS232\n"); in atmel_config_iso7816()
431 atmel_uart_writel(port, ATMEL_US_TTGR, 0); in atmel_config_iso7816()
432 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->backup_brgr); in atmel_config_iso7816()
433 atmel_uart_writel(port, ATMEL_US_FIDI, 0x174); in atmel_config_iso7816()
435 if (atmel_use_pdc_tx(port)) in atmel_config_iso7816()
442 port->iso7816 = *iso7816conf; in atmel_config_iso7816()
444 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_config_iso7816()
448 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_iso7816()
456 static u_int atmel_tx_empty(struct uart_port *port) in atmel_tx_empty() argument
458 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_empty()
462 return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ? in atmel_tx_empty()
470 static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) in atmel_set_mctrl() argument
473 unsigned int mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_set_mctrl()
475 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_mctrl()
478 if (port->rs485.flags & SER_RS485_ENABLED) { in atmel_set_mctrl()
479 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_set_mctrl()
480 port->rs485.delay_rts_after_send); in atmel_set_mctrl()
510 atmel_uart_writel(port, ATMEL_US_CR, control); in atmel_set_mctrl()
521 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_set_mctrl()
527 static u_int atmel_get_mctrl(struct uart_port *port) in atmel_get_mctrl() argument
529 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_mctrl()
532 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_get_mctrl()
552 static void atmel_stop_tx(struct uart_port *port) in atmel_stop_tx() argument
554 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_stop_tx()
556 if (atmel_use_pdc_tx(port)) { in atmel_stop_tx()
558 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_stop_tx()
566 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS); in atmel_stop_tx()
570 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_stop_tx()
572 if (atmel_uart_is_half_duplex(port)) in atmel_stop_tx()
574 atmel_start_rx(port); in atmel_stop_tx()
581 static void atmel_start_tx(struct uart_port *port) in atmel_start_tx() argument
583 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_start_tx()
585 if (atmel_use_pdc_tx(port) && (atmel_uart_readl(port, ATMEL_PDC_PTSR) in atmel_start_tx()
591 if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port)) in atmel_start_tx()
592 if (atmel_uart_is_half_duplex(port)) in atmel_start_tx()
593 atmel_stop_rx(port); in atmel_start_tx()
595 if (atmel_use_pdc_tx(port)) in atmel_start_tx()
597 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_start_tx()
600 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_start_tx()
603 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); in atmel_start_tx()
610 static void atmel_start_rx(struct uart_port *port) in atmel_start_rx() argument
613 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_start_rx()
615 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RXEN); in atmel_start_rx()
617 if (atmel_use_pdc_rx(port)) { in atmel_start_rx()
619 atmel_uart_writel(port, ATMEL_US_IER, in atmel_start_rx()
621 port->read_status_mask); in atmel_start_rx()
622 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN); in atmel_start_rx()
624 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_RXRDY); in atmel_start_rx()
631 static void atmel_stop_rx(struct uart_port *port) in atmel_stop_rx() argument
633 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RXDIS); in atmel_stop_rx()
635 if (atmel_use_pdc_rx(port)) { in atmel_stop_rx()
637 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTDIS); in atmel_stop_rx()
638 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_stop_rx()
640 port->read_status_mask); in atmel_stop_rx()
642 atmel_uart_writel(port, ATMEL_US_IDR, ATMEL_US_RXRDY); in atmel_stop_rx()
649 static void atmel_enable_ms(struct uart_port *port) in atmel_enable_ms() argument
651 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_enable_ms()
674 atmel_uart_writel(port, ATMEL_US_IER, ier); in atmel_enable_ms()
682 static void atmel_disable_ms(struct uart_port *port) in atmel_disable_ms() argument
684 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_disable_ms()
709 atmel_uart_writel(port, ATMEL_US_IDR, idr); in atmel_disable_ms()
715 static void atmel_break_ctl(struct uart_port *port, int break_state) in atmel_break_ctl() argument
719 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTBRK); in atmel_break_ctl()
722 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STPBRK); in atmel_break_ctl()
729 atmel_buffer_rx_char(struct uart_port *port, unsigned int status, in atmel_buffer_rx_char() argument
732 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_buffer_rx_char()
753 static void atmel_pdc_rxerr(struct uart_port *port, unsigned int status) in atmel_pdc_rxerr() argument
756 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_pdc_rxerr()
761 port->icount.brk++; in atmel_pdc_rxerr()
764 port->icount.parity++; in atmel_pdc_rxerr()
766 port->icount.frame++; in atmel_pdc_rxerr()
768 port->icount.overrun++; in atmel_pdc_rxerr()
774 static void atmel_rx_chars(struct uart_port *port) in atmel_rx_chars() argument
776 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_chars()
779 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_rx_chars()
781 ch = atmel_uart_read_char(port); in atmel_rx_chars()
792 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_rx_chars()
797 atmel_uart_writel(port, ATMEL_US_IER, in atmel_rx_chars()
807 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_rx_chars()
814 atmel_buffer_rx_char(port, status, ch); in atmel_rx_chars()
815 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_rx_chars()
825 static void atmel_tx_chars(struct uart_port *port) in atmel_tx_chars() argument
827 struct circ_buf *xmit = &port->state->xmit; in atmel_tx_chars()
828 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_chars()
830 if (port->x_char && in atmel_tx_chars()
831 (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) { in atmel_tx_chars()
832 atmel_uart_write_char(port, port->x_char); in atmel_tx_chars()
833 port->icount.tx++; in atmel_tx_chars()
834 port->x_char = 0; in atmel_tx_chars()
836 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) in atmel_tx_chars()
839 while (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY) { in atmel_tx_chars()
840 atmel_uart_write_char(port, xmit->buf[xmit->tail]); in atmel_tx_chars()
842 port->icount.tx++; in atmel_tx_chars()
848 uart_write_wakeup(port); in atmel_tx_chars()
858 atmel_uart_writel(port, ATMEL_US_IER, in atmel_tx_chars()
861 if (atmel_uart_is_half_duplex(port)) in atmel_tx_chars()
869 struct uart_port *port = &atmel_port->uart; in atmel_complete_tx_dma() local
870 struct circ_buf *xmit = &port->state->xmit; in atmel_complete_tx_dma()
874 spin_lock_irqsave(&port->lock, flags); in atmel_complete_tx_dma()
881 port->icount.tx += atmel_port->tx_len; in atmel_complete_tx_dma()
890 uart_write_wakeup(port); in atmel_complete_tx_dma()
899 else if (atmel_uart_is_half_duplex(port)) { in atmel_complete_tx_dma()
905 atmel_uart_writel(port, ATMEL_US_IER, in atmel_complete_tx_dma()
909 spin_unlock_irqrestore(&port->lock, flags); in atmel_complete_tx_dma()
912 static void atmel_release_tx_dma(struct uart_port *port) in atmel_release_tx_dma() argument
914 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_dma()
920 dma_unmap_sg(port->dev, &atmel_port->sg_tx, 1, in atmel_release_tx_dma()
932 static void atmel_tx_dma(struct uart_port *port) in atmel_tx_dma() argument
934 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_dma()
935 struct circ_buf *xmit = &port->state->xmit; in atmel_tx_dma()
946 if (!uart_circ_empty(xmit) && !uart_tx_stopped(port)) { in atmel_tx_dma()
1000 dev_err(port->dev, "Failed to send via dma!\n"); in atmel_tx_dma()
1004 dma_sync_sg_for_device(port->dev, sg_tx, 1, DMA_TO_DEVICE); in atmel_tx_dma()
1011 dev_err(port->dev, "dma_submit_error %d\n", in atmel_tx_dma()
1020 uart_write_wakeup(port); in atmel_tx_dma()
1023 static int atmel_prepare_tx_dma(struct uart_port *port) in atmel_prepare_tx_dma() argument
1025 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_dma()
1026 struct device *mfd_dev = port->dev->parent; in atmel_prepare_tx_dma()
1037 dev_info(port->dev, "using %s for tx DMA transfers\n", in atmel_prepare_tx_dma()
1043 BUG_ON(!PAGE_ALIGNED(port->state->xmit.buf)); in atmel_prepare_tx_dma()
1045 virt_to_page(port->state->xmit.buf), in atmel_prepare_tx_dma()
1047 offset_in_page(port->state->xmit.buf)); in atmel_prepare_tx_dma()
1048 nent = dma_map_sg(port->dev, in atmel_prepare_tx_dma()
1054 dev_dbg(port->dev, "need to release resource of dma\n"); in atmel_prepare_tx_dma()
1057 dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__, in atmel_prepare_tx_dma()
1059 port->state->xmit.buf, in atmel_prepare_tx_dma()
1069 config.dst_addr = port->mapbase + ATMEL_US_THR; in atmel_prepare_tx_dma()
1075 dev_err(port->dev, "DMA tx slave configuration failed\n"); in atmel_prepare_tx_dma()
1082 dev_err(port->dev, "TX channel not available, switch to pio\n"); in atmel_prepare_tx_dma()
1085 atmel_release_tx_dma(port); in atmel_prepare_tx_dma()
1091 struct uart_port *port = arg; in atmel_complete_rx_dma() local
1092 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_complete_rx_dma()
1097 static void atmel_release_rx_dma(struct uart_port *port) in atmel_release_rx_dma() argument
1099 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_dma()
1105 dma_unmap_sg(port->dev, &atmel_port->sg_rx, 1, in atmel_release_rx_dma()
1114 static void atmel_rx_from_dma(struct uart_port *port) in atmel_rx_from_dma() argument
1116 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_dma()
1117 struct tty_port *tport = &port->state->port; in atmel_rx_from_dma()
1126 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_rx_from_dma()
1132 dev_dbg(port->dev, "Get residue error, restart tasklet\n"); in atmel_rx_from_dma()
1133 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_TIMEOUT); in atmel_rx_from_dma()
1139 dma_sync_sg_for_cpu(port->dev, in atmel_rx_from_dma()
1170 port->icount.rx += count; in atmel_rx_from_dma()
1182 port->icount.rx += count; in atmel_rx_from_dma()
1186 dma_sync_sg_for_device(port->dev, in atmel_rx_from_dma()
1193 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_TIMEOUT); in atmel_rx_from_dma()
1196 static int atmel_prepare_rx_dma(struct uart_port *port) in atmel_prepare_rx_dma() argument
1198 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_dma()
1199 struct device *mfd_dev = port->dev->parent; in atmel_prepare_rx_dma()
1214 dev_info(port->dev, "using %s for rx DMA transfers\n", in atmel_prepare_rx_dma()
1225 nent = dma_map_sg(port->dev, in atmel_prepare_rx_dma()
1231 dev_dbg(port->dev, "need to release resource of dma\n"); in atmel_prepare_rx_dma()
1234 dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__, in atmel_prepare_rx_dma()
1244 config.src_addr = port->mapbase + ATMEL_US_RHR; in atmel_prepare_rx_dma()
1250 dev_err(port->dev, "DMA rx slave configuration failed\n"); in atmel_prepare_rx_dma()
1264 dev_err(port->dev, "Preparing DMA cyclic failed\n"); in atmel_prepare_rx_dma()
1268 desc->callback_param = port; in atmel_prepare_rx_dma()
1272 dev_err(port->dev, "dma_submit_error %d\n", in atmel_prepare_rx_dma()
1282 dev_err(port->dev, "RX channel not available, switch to pio\n"); in atmel_prepare_rx_dma()
1285 atmel_release_rx_dma(port); in atmel_prepare_rx_dma()
1293 struct uart_port *port = &atmel_port->uart; in atmel_uart_timer_callback() local
1298 jiffies + uart_poll_timeout(port)); in atmel_uart_timer_callback()
1306 atmel_handle_receive(struct uart_port *port, unsigned int pending) in atmel_handle_receive() argument
1308 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_receive()
1310 if (atmel_use_pdc_rx(port)) { in atmel_handle_receive()
1319 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_receive()
1327 atmel_pdc_rxerr(port, pending); in atmel_handle_receive()
1330 if (atmel_use_dma_rx(port)) { in atmel_handle_receive()
1332 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_receive()
1341 atmel_rx_chars(port); in atmel_handle_receive()
1347 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_handle_receive()
1348 atmel_uart_writel(port, ATMEL_US_IDR, ATMEL_US_RXBRK); in atmel_handle_receive()
1357 atmel_handle_transmit(struct uart_port *port, unsigned int pending) in atmel_handle_transmit() argument
1359 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_transmit()
1362 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_transmit()
1367 if (!(atmel_uart_readl(port, ATMEL_US_CSR) in atmel_handle_transmit()
1369 dev_warn(port->dev, "Should start RX, but TX fifo is not empty\n"); in atmel_handle_transmit()
1372 atmel_start_rx(port); in atmel_handle_transmit()
1383 atmel_handle_status(struct uart_port *port, unsigned int pending, in atmel_handle_status() argument
1386 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_status()
1398 port->icount.rng++; in atmel_handle_status()
1400 port->icount.dsr++; in atmel_handle_status()
1402 uart_handle_dcd_change(port, !(status & ATMEL_US_DCD)); in atmel_handle_status()
1404 uart_handle_cts_change(port, !(status & ATMEL_US_CTS)); in atmel_handle_status()
1406 wake_up_interruptible(&port->state->port.delta_msr_wait); in atmel_handle_status()
1411 dev_dbg(port->dev, "ISO7816 ERROR (0x%08x)\n", pending); in atmel_handle_status()
1419 struct uart_port *port = dev_id; in atmel_interrupt() local
1420 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_interrupt()
1426 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_interrupt()
1427 mask = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_interrupt()
1435 atmel_uart_writel(port, ATMEL_US_IDR, mask); in atmel_interrupt()
1440 atmel_handle_receive(port, pending); in atmel_interrupt()
1441 atmel_handle_status(port, pending, status); in atmel_interrupt()
1442 atmel_handle_transmit(port, pending); in atmel_interrupt()
1450 static void atmel_release_tx_pdc(struct uart_port *port) in atmel_release_tx_pdc() argument
1452 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_pdc()
1455 dma_unmap_single(port->dev, in atmel_release_tx_pdc()
1464 static void atmel_tx_pdc(struct uart_port *port) in atmel_tx_pdc() argument
1466 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_pdc()
1467 struct circ_buf *xmit = &port->state->xmit; in atmel_tx_pdc()
1472 if (atmel_uart_readl(port, ATMEL_PDC_TCR)) in atmel_tx_pdc()
1478 port->icount.tx += pdc->ofs; in atmel_tx_pdc()
1484 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_tx_pdc()
1486 if (!uart_circ_empty(xmit) && !uart_tx_stopped(port)) { in atmel_tx_pdc()
1487 dma_sync_single_for_device(port->dev, in atmel_tx_pdc()
1495 atmel_uart_writel(port, ATMEL_PDC_TPR, in atmel_tx_pdc()
1497 atmel_uart_writel(port, ATMEL_PDC_TCR, count); in atmel_tx_pdc()
1499 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_tx_pdc()
1501 atmel_uart_writel(port, ATMEL_US_IER, in atmel_tx_pdc()
1504 if (atmel_uart_is_half_duplex(port)) { in atmel_tx_pdc()
1506 atmel_start_rx(port); in atmel_tx_pdc()
1511 uart_write_wakeup(port); in atmel_tx_pdc()
1514 static int atmel_prepare_tx_pdc(struct uart_port *port) in atmel_prepare_tx_pdc() argument
1516 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_pdc()
1518 struct circ_buf *xmit = &port->state->xmit; in atmel_prepare_tx_pdc()
1521 pdc->dma_addr = dma_map_single(port->dev, in atmel_prepare_tx_pdc()
1531 static void atmel_rx_from_ring(struct uart_port *port) in atmel_rx_from_ring() argument
1533 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_ring()
1548 port->icount.rx++; in atmel_rx_from_ring()
1562 port->icount.brk++; in atmel_rx_from_ring()
1563 if (uart_handle_break(port)) in atmel_rx_from_ring()
1567 port->icount.parity++; in atmel_rx_from_ring()
1569 port->icount.frame++; in atmel_rx_from_ring()
1571 port->icount.overrun++; in atmel_rx_from_ring()
1573 status &= port->read_status_mask; in atmel_rx_from_ring()
1584 if (uart_handle_sysrq_char(port, c.ch)) in atmel_rx_from_ring()
1587 uart_insert_char(port, status, ATMEL_US_OVRE, c.ch, flg); in atmel_rx_from_ring()
1590 tty_flip_buffer_push(&port->state->port); in atmel_rx_from_ring()
1593 static void atmel_release_rx_pdc(struct uart_port *port) in atmel_release_rx_pdc() argument
1595 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_pdc()
1601 dma_unmap_single(port->dev, in atmel_release_rx_pdc()
1609 static void atmel_rx_from_pdc(struct uart_port *port) in atmel_rx_from_pdc() argument
1611 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_pdc()
1612 struct tty_port *tport = &port->state->port; in atmel_rx_from_pdc()
1621 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_rx_from_pdc()
1624 head = atmel_uart_readl(port, ATMEL_PDC_RPR) - pdc->dma_addr; in atmel_rx_from_pdc()
1640 dma_sync_single_for_cpu(port->dev, pdc->dma_addr, in atmel_rx_from_pdc()
1654 dma_sync_single_for_device(port->dev, pdc->dma_addr, in atmel_rx_from_pdc()
1657 port->icount.rx += count; in atmel_rx_from_pdc()
1667 atmel_uart_writel(port, ATMEL_PDC_RNPR, pdc->dma_addr); in atmel_rx_from_pdc()
1668 atmel_uart_writel(port, ATMEL_PDC_RNCR, pdc->dma_size); in atmel_rx_from_pdc()
1677 atmel_uart_writel(port, ATMEL_US_IER, in atmel_rx_from_pdc()
1681 static int atmel_prepare_rx_pdc(struct uart_port *port) in atmel_prepare_rx_pdc() argument
1683 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_pdc()
1692 dma_unmap_single(port->dev, in atmel_prepare_rx_pdc()
1701 pdc->dma_addr = dma_map_single(port->dev, in atmel_prepare_rx_pdc()
1711 atmel_uart_writel(port, ATMEL_PDC_RPR, atmel_port->pdc_rx[0].dma_addr); in atmel_prepare_rx_pdc()
1712 atmel_uart_writel(port, ATMEL_PDC_RCR, PDC_BUFFER_SIZE); in atmel_prepare_rx_pdc()
1714 atmel_uart_writel(port, ATMEL_PDC_RNPR, in atmel_prepare_rx_pdc()
1716 atmel_uart_writel(port, ATMEL_PDC_RNCR, PDC_BUFFER_SIZE); in atmel_prepare_rx_pdc()
1728 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_rx_func() local
1731 spin_lock(&port->lock); in atmel_tasklet_rx_func()
1732 atmel_port->schedule_rx(port); in atmel_tasklet_rx_func()
1733 spin_unlock(&port->lock); in atmel_tasklet_rx_func()
1740 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_tx_func() local
1743 spin_lock(&port->lock); in atmel_tasklet_tx_func()
1744 atmel_port->schedule_tx(port); in atmel_tasklet_tx_func()
1745 spin_unlock(&port->lock); in atmel_tasklet_tx_func()
1781 static void atmel_set_ops(struct uart_port *port) in atmel_set_ops() argument
1783 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_ops()
1785 if (atmel_use_dma_rx(port)) { in atmel_set_ops()
1789 } else if (atmel_use_pdc_rx(port)) { in atmel_set_ops()
1799 if (atmel_use_dma_tx(port)) { in atmel_set_ops()
1803 } else if (atmel_use_pdc_tx(port)) { in atmel_set_ops()
1817 static void atmel_get_ip_name(struct uart_port *port) in atmel_get_ip_name() argument
1819 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_ip_name()
1820 int name = atmel_uart_readl(port, ATMEL_US_NAME); in atmel_get_ip_name()
1839 dev_dbg(port->dev, "Uart with hw timer"); in atmel_get_ip_name()
1843 dev_dbg(port->dev, "Usart\n"); in atmel_get_ip_name()
1848 version = atmel_uart_readl(port, ATMEL_US_VERSION); in atmel_get_ip_name()
1865 dev_dbg(port->dev, "Dbgu or uart without hw timer\n"); in atmel_get_ip_name()
1868 version = atmel_uart_readl(port, ATMEL_US_VERSION); in atmel_get_ip_name()
1873 dev_dbg(port->dev, "This version is usart\n"); in atmel_get_ip_name()
1881 dev_dbg(port->dev, "This version is uart\n"); in atmel_get_ip_name()
1884 dev_err(port->dev, "Not supported ip name nor version, set to uart\n"); in atmel_get_ip_name()
1892 static int atmel_startup(struct uart_port *port) in atmel_startup() argument
1894 struct platform_device *pdev = to_platform_device(port->dev); in atmel_startup()
1895 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_startup()
1903 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_startup()
1909 retval = request_irq(port->irq, atmel_interrupt, in atmel_startup()
1911 dev_name(&pdev->dev), port); in atmel_startup()
1913 dev_err(port->dev, "atmel_startup - Can't get irq\n"); in atmel_startup()
1925 atmel_set_ops(port); in atmel_startup()
1928 retval = atmel_port->prepare_rx(port); in atmel_startup()
1930 atmel_set_ops(port); in atmel_startup()
1934 retval = atmel_port->prepare_tx(port); in atmel_startup()
1936 atmel_set_ops(port); in atmel_startup()
1947 atmel_uart_writel(port, ATMEL_US_CR, in atmel_startup()
1952 if (atmel_use_dma_tx(port)) in atmel_startup()
1962 atmel_uart_writel(port, ATMEL_US_FMR, fmr); in atmel_startup()
1966 atmel_port->irq_status_prev = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_startup()
1971 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_startup()
1973 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_startup()
1978 if (atmel_use_pdc_rx(port)) { in atmel_startup()
1982 jiffies + uart_poll_timeout(port)); in atmel_startup()
1985 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1987 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_startup()
1989 atmel_uart_writel(port, ATMEL_US_IER, in atmel_startup()
1993 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN); in atmel_startup()
1994 } else if (atmel_use_dma_rx(port)) { in atmel_startup()
1998 jiffies + uart_poll_timeout(port)); in atmel_startup()
2001 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
2003 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_startup()
2005 atmel_uart_writel(port, ATMEL_US_IER, in atmel_startup()
2010 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_RXRDY); in atmel_startup()
2020 static void atmel_flush_buffer(struct uart_port *port) in atmel_flush_buffer() argument
2022 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_flush_buffer()
2024 if (atmel_use_pdc_tx(port)) { in atmel_flush_buffer()
2025 atmel_uart_writel(port, ATMEL_PDC_TCR, 0); in atmel_flush_buffer()
2038 static void atmel_shutdown(struct uart_port *port) in atmel_shutdown() argument
2040 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_shutdown()
2043 atmel_disable_ms(port); in atmel_shutdown()
2046 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_shutdown()
2058 synchronize_irq(port->irq); in atmel_shutdown()
2071 atmel_stop_rx(port); in atmel_shutdown()
2072 atmel_stop_tx(port); in atmel_shutdown()
2074 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_shutdown()
2080 atmel_port->release_rx(port); in atmel_shutdown()
2082 atmel_port->release_tx(port); in atmel_shutdown()
2093 free_irq(port->irq, port); in atmel_shutdown()
2095 atmel_flush_buffer(port); in atmel_shutdown()
2101 static void atmel_serial_pm(struct uart_port *port, unsigned int state, in atmel_serial_pm() argument
2104 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_pm()
2115 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->backup_imr); in atmel_serial_pm()
2119 atmel_port->backup_imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_serial_pm()
2120 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_serial_pm()
2131 dev_err(port->dev, "atmel_serial: unknown pm %d\n", state); in atmel_serial_pm()
2138 static void atmel_set_termios(struct uart_port *port, in atmel_set_termios() argument
2142 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_termios()
2149 mode = old_mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_set_termios()
2158 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); in atmel_set_termios()
2195 spin_lock_irqsave(&port->lock, flags); in atmel_set_termios()
2197 port->read_status_mask = ATMEL_US_OVRE; in atmel_set_termios()
2199 port->read_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE); in atmel_set_termios()
2201 port->read_status_mask |= ATMEL_US_RXBRK; in atmel_set_termios()
2203 if (atmel_use_pdc_rx(port)) in atmel_set_termios()
2205 atmel_uart_writel(port, ATMEL_US_IER, port->read_status_mask); in atmel_set_termios()
2210 port->ignore_status_mask = 0; in atmel_set_termios()
2212 port->ignore_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE); in atmel_set_termios()
2214 port->ignore_status_mask |= ATMEL_US_RXBRK; in atmel_set_termios()
2220 port->ignore_status_mask |= ATMEL_US_OVRE; in atmel_set_termios()
2225 uart_update_timeout(port, termios->c_cflag, baud); in atmel_set_termios()
2232 imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_set_termios()
2233 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_set_termios()
2236 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS); in atmel_set_termios()
2240 if (port->rs485.flags & SER_RS485_ENABLED) { in atmel_set_termios()
2241 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_set_termios()
2242 port->rs485.delay_rts_after_send); in atmel_set_termios()
2244 } else if (port->iso7816.flags & SER_ISO7816_ENABLED) { in atmel_set_termios()
2245 atmel_uart_writel(port, ATMEL_US_TTGR, port->iso7816.tg); in atmel_set_termios()
2250 if ((port->iso7816.flags & SER_ISO7816_T_PARAM) in atmel_set_termios()
2257 if (atmel_use_fifo(port) && in atmel_set_termios()
2297 div = DIV_ROUND_CLOSEST(port->uartclk, baud * 2); in atmel_set_termios()
2301 cd = uart_get_divisor(port, baud); in atmel_set_termios()
2360 if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) in atmel_set_termios()
2361 atmel_uart_writel(port, ATMEL_US_BRGR, quot); in atmel_set_termios()
2364 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_set_termios()
2381 atmel_uart_writel(port, ATMEL_US_CR, rts_state); in atmel_set_termios()
2384 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_set_termios()
2385 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_set_termios()
2389 atmel_uart_writel(port, ATMEL_US_IER, imr); in atmel_set_termios()
2392 if (UART_ENABLE_MS(port, termios->c_cflag)) in atmel_set_termios()
2393 atmel_enable_ms(port); in atmel_set_termios()
2395 atmel_disable_ms(port); in atmel_set_termios()
2397 spin_unlock_irqrestore(&port->lock, flags); in atmel_set_termios()
2400 static void atmel_set_ldisc(struct uart_port *port, struct ktermios *termios) in atmel_set_ldisc() argument
2403 port->flags |= UPF_HARDPPS_CD; in atmel_set_ldisc()
2404 spin_lock_irq(&port->lock); in atmel_set_ldisc()
2405 atmel_enable_ms(port); in atmel_set_ldisc()
2406 spin_unlock_irq(&port->lock); in atmel_set_ldisc()
2408 port->flags &= ~UPF_HARDPPS_CD; in atmel_set_ldisc()
2409 if (!UART_ENABLE_MS(port, termios->c_cflag)) { in atmel_set_ldisc()
2410 spin_lock_irq(&port->lock); in atmel_set_ldisc()
2411 atmel_disable_ms(port); in atmel_set_ldisc()
2412 spin_unlock_irq(&port->lock); in atmel_set_ldisc()
2420 static const char *atmel_type(struct uart_port *port) in atmel_type() argument
2422 return (port->type == PORT_ATMEL) ? "ATMEL_SERIAL" : NULL; in atmel_type()
2428 static void atmel_release_port(struct uart_port *port) in atmel_release_port() argument
2430 struct platform_device *mpdev = to_platform_device(port->dev->parent); in atmel_release_port()
2433 release_mem_region(port->mapbase, size); in atmel_release_port()
2435 if (port->flags & UPF_IOREMAP) { in atmel_release_port()
2436 iounmap(port->membase); in atmel_release_port()
2437 port->membase = NULL; in atmel_release_port()
2444 static int atmel_request_port(struct uart_port *port) in atmel_request_port() argument
2446 struct platform_device *mpdev = to_platform_device(port->dev->parent); in atmel_request_port()
2449 if (!request_mem_region(port->mapbase, size, "atmel_serial")) in atmel_request_port()
2452 if (port->flags & UPF_IOREMAP) { in atmel_request_port()
2453 port->membase = ioremap(port->mapbase, size); in atmel_request_port()
2454 if (port->membase == NULL) { in atmel_request_port()
2455 release_mem_region(port->mapbase, size); in atmel_request_port()
2466 static void atmel_config_port(struct uart_port *port, int flags) in atmel_config_port() argument
2469 port->type = PORT_ATMEL; in atmel_config_port()
2470 atmel_request_port(port); in atmel_config_port()
2477 static int atmel_verify_port(struct uart_port *port, struct serial_struct *ser) in atmel_verify_port() argument
2482 if (port->irq != ser->irq) in atmel_verify_port()
2486 if (port->uartclk / 16 != ser->baud_base) in atmel_verify_port()
2488 if (port->mapbase != (unsigned long)ser->iomem_base) in atmel_verify_port()
2490 if (port->iobase != ser->port) in atmel_verify_port()
2498 static int atmel_poll_get_char(struct uart_port *port) in atmel_poll_get_char() argument
2500 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_RXRDY)) in atmel_poll_get_char()
2503 return atmel_uart_read_char(port); in atmel_poll_get_char()
2506 static void atmel_poll_put_char(struct uart_port *port, unsigned char ch) in atmel_poll_put_char() argument
2508 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) in atmel_poll_put_char()
2511 atmel_uart_write_char(port, ch); in atmel_poll_put_char()
2554 struct uart_port *port = &atmel_port->uart; in atmel_init_port() local
2558 atmel_set_ops(port); in atmel_init_port()
2560 port->iotype = UPIO_MEM; in atmel_init_port()
2561 port->flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP; in atmel_init_port()
2562 port->ops = &atmel_pops; in atmel_init_port()
2563 port->fifosize = 1; in atmel_init_port()
2564 port->dev = &pdev->dev; in atmel_init_port()
2565 port->mapbase = mpdev->resource[0].start; in atmel_init_port()
2566 port->irq = platform_get_irq(mpdev, 0); in atmel_init_port()
2567 port->rs485_config = atmel_config_rs485; in atmel_init_port()
2568 port->rs485_supported = atmel_rs485_supported; in atmel_init_port()
2569 port->iso7816_config = atmel_config_iso7816; in atmel_init_port()
2570 port->membase = NULL; in atmel_init_port()
2574 ret = uart_get_rs485_mode(port); in atmel_init_port()
2578 port->uartclk = clk_get_rate(atmel_port->clk); in atmel_init_port()
2584 if (atmel_uart_is_half_duplex(port)) in atmel_init_port()
2586 else if (atmel_use_pdc_tx(port)) { in atmel_init_port()
2587 port->fifosize = PDC_BUFFER_SIZE; in atmel_init_port()
2597 static void atmel_console_putchar(struct uart_port *port, unsigned char ch) in atmel_console_putchar() argument
2599 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) in atmel_console_putchar()
2601 atmel_uart_write_char(port, ch); in atmel_console_putchar()
2609 struct uart_port *port = &atmel_ports[co->index].uart; in atmel_console_write() local
2610 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_write()
2617 imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_console_write()
2618 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_console_write()
2622 pdc_tx = atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN; in atmel_console_write()
2623 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_console_write()
2626 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); in atmel_console_write()
2629 uart_console_write(port, s, count, atmel_console_putchar); in atmel_console_write()
2636 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_console_write()
2641 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_console_write()
2644 atmel_uart_writel(port, ATMEL_US_IER, imr); in atmel_console_write()
2651 static void __init atmel_console_get_options(struct uart_port *port, int *baud, in atmel_console_get_options() argument
2660 quot = atmel_uart_readl(port, ATMEL_US_BRGR) & ATMEL_US_CD; in atmel_console_get_options()
2664 mr = atmel_uart_readl(port, ATMEL_US_MR) & ATMEL_US_CHRL; in atmel_console_get_options()
2670 mr = atmel_uart_readl(port, ATMEL_US_MR) & ATMEL_US_PAR; in atmel_console_get_options()
2676 *baud = port->uartclk / (16 * quot); in atmel_console_get_options()
2681 struct uart_port *port = &atmel_ports[co->index].uart; in atmel_console_setup() local
2682 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_setup()
2688 if (port->membase == NULL) { in atmel_console_setup()
2693 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_console_setup()
2694 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_console_setup()
2695 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_console_setup()
2701 atmel_console_get_options(port, &baud, &parity, &bits); in atmel_console_setup()
2703 return uart_set_options(port, co, baud, parity, bits, flow); in atmel_console_setup()
2723 uart_console_write(&dev->port, s, n, atmel_console_putchar); in atmel_serial_early_write()
2729 if (!device->port.membase) in atmel_early_console_setup()
2769 struct uart_port *port = dev_get_drvdata(dev); in atmel_serial_suspend() local
2770 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_suspend()
2772 if (uart_console(port) && console_suspend_enabled) { in atmel_serial_suspend()
2774 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & in atmel_serial_suspend()
2779 if (uart_console(port) && !console_suspend_enabled) { in atmel_serial_suspend()
2783 atmel_port->cache.mr = atmel_uart_readl(port, ATMEL_US_MR); in atmel_serial_suspend()
2784 atmel_port->cache.imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_serial_suspend()
2785 atmel_port->cache.brgr = atmel_uart_readl(port, ATMEL_US_BRGR); in atmel_serial_suspend()
2786 atmel_port->cache.rtor = atmel_uart_readl(port, in atmel_serial_suspend()
2788 atmel_port->cache.ttgr = atmel_uart_readl(port, ATMEL_US_TTGR); in atmel_serial_suspend()
2789 atmel_port->cache.fmr = atmel_uart_readl(port, ATMEL_US_FMR); in atmel_serial_suspend()
2790 atmel_port->cache.fimr = atmel_uart_readl(port, ATMEL_US_FIMR); in atmel_serial_suspend()
2804 uart_suspend_port(&atmel_uart, port); in atmel_serial_suspend()
2811 struct uart_port *port = dev_get_drvdata(dev); in atmel_serial_resume() local
2812 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_resume()
2815 if (uart_console(port) && !console_suspend_enabled) { in atmel_serial_resume()
2816 atmel_uart_writel(port, ATMEL_US_MR, atmel_port->cache.mr); in atmel_serial_resume()
2817 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->cache.imr); in atmel_serial_resume()
2818 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->cache.brgr); in atmel_serial_resume()
2819 atmel_uart_writel(port, atmel_port->rtor, in atmel_serial_resume()
2821 atmel_uart_writel(port, ATMEL_US_TTGR, atmel_port->cache.ttgr); in atmel_serial_resume()
2824 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_FIFOEN | in atmel_serial_resume()
2826 atmel_uart_writel(port, ATMEL_US_FMR, in atmel_serial_resume()
2828 atmel_uart_writel(port, ATMEL_US_FIER, in atmel_serial_resume()
2831 atmel_start_rx(port); in atmel_serial_resume()
2836 atmel_handle_receive(port, atmel_port->pending); in atmel_serial_resume()
2837 atmel_handle_status(port, atmel_port->pending, in atmel_serial_resume()
2839 atmel_handle_transmit(port, atmel_port->pending); in atmel_serial_resume()
2845 uart_resume_port(&atmel_uart, port); in atmel_serial_resume()
3023 struct uart_port *port = platform_get_drvdata(pdev); in atmel_serial_remove() local
3024 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_remove()
3032 ret = uart_remove_one_port(&atmel_uart, port); in atmel_serial_remove()
3038 clear_bit(port->line, atmel_ports_in_use); in atmel_serial_remove()