Lines Matching refs:port
57 static void atmel_start_rx(struct uart_port *port);
58 static void atmel_stop_rx(struct uart_port *port);
182 int (*prepare_rx)(struct uart_port *port);
183 int (*prepare_tx)(struct uart_port *port);
184 void (*schedule_rx)(struct uart_port *port);
185 void (*schedule_tx)(struct uart_port *port);
186 void (*release_rx)(struct uart_port *port);
187 void (*release_tx)(struct uart_port *port);
206 static inline u32 atmel_uart_readl(struct uart_port *port, u32 reg) in atmel_uart_readl() argument
208 return __raw_readl(port->membase + reg); in atmel_uart_readl()
211 static inline void atmel_uart_writel(struct uart_port *port, u32 reg, u32 value) in atmel_uart_writel() argument
213 __raw_writel(value, port->membase + reg); in atmel_uart_writel()
216 static inline u8 atmel_uart_read_char(struct uart_port *port) in atmel_uart_read_char() argument
218 return __raw_readb(port->membase + ATMEL_US_RHR); in atmel_uart_read_char()
221 static inline void atmel_uart_write_char(struct uart_port *port, u8 value) in atmel_uart_write_char() argument
223 __raw_writeb(value, port->membase + ATMEL_US_THR); in atmel_uart_write_char()
226 static inline int atmel_uart_is_half_duplex(struct uart_port *port) in atmel_uart_is_half_duplex() argument
228 return ((port->rs485.flags & SER_RS485_ENABLED) && in atmel_uart_is_half_duplex()
229 !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || in atmel_uart_is_half_duplex()
230 (port->iso7816.flags & SER_ISO7816_ENABLED); in atmel_uart_is_half_duplex()
239 static bool atmel_use_pdc_rx(struct uart_port *port) in atmel_use_pdc_rx() argument
241 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_rx()
246 static bool atmel_use_pdc_tx(struct uart_port *port) in atmel_use_pdc_tx() argument
248 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_tx()
253 static bool atmel_use_pdc_rx(struct uart_port *port) in atmel_use_pdc_rx() argument
258 static bool atmel_use_pdc_tx(struct uart_port *port) in atmel_use_pdc_tx() argument
264 static bool atmel_use_dma_tx(struct uart_port *port) in atmel_use_dma_tx() argument
266 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_tx()
271 static bool atmel_use_dma_rx(struct uart_port *port) in atmel_use_dma_rx() argument
273 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_rx()
278 static bool atmel_use_fifo(struct uart_port *port) in atmel_use_fifo() argument
280 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_fifo()
293 static int atmel_config_rs485(struct uart_port *port, struct ktermios *termios, in atmel_config_rs485() argument
296 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_rs485()
300 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_rs485()
302 mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_rs485()
305 dev_dbg(port->dev, "Setting UART to RS485\n"); in atmel_config_rs485()
311 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_config_rs485()
316 dev_dbg(port->dev, "Setting UART to RS232\n"); in atmel_config_rs485()
317 if (atmel_use_pdc_tx(port)) in atmel_config_rs485()
323 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_config_rs485()
326 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_rs485()
331 static unsigned int atmel_calc_cd(struct uart_port *port, in atmel_calc_cd() argument
334 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_calc_cd()
344 static unsigned int atmel_calc_fidi(struct uart_port *port, in atmel_calc_fidi() argument
358 static int atmel_config_iso7816(struct uart_port *port, in atmel_config_iso7816() argument
361 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_iso7816()
367 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_iso7816()
369 mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_iso7816()
375 dev_err(port->dev, "ISO7816: Timeguard exceeding 255\n"); in atmel_config_iso7816()
388 dev_err(port->dev, "ISO7816: Type not supported\n"); in atmel_config_iso7816()
401 cd = atmel_calc_cd(port, iso7816conf); in atmel_config_iso7816()
402 fidi = atmel_calc_fidi(port, iso7816conf); in atmel_config_iso7816()
404 dev_warn(port->dev, "ISO7816 fidi = 0, Generator generates no signal\n"); in atmel_config_iso7816()
407 dev_err(port->dev, "ISO7816 fidi = %u, value not supported\n", fidi); in atmel_config_iso7816()
413 if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) { in atmel_config_iso7816()
415 atmel_port->backup_mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_iso7816()
416 atmel_port->backup_brgr = atmel_uart_readl(port, ATMEL_US_BRGR); in atmel_config_iso7816()
419 atmel_uart_writel(port, ATMEL_US_TTGR, iso7816conf->tg); in atmel_config_iso7816()
420 atmel_uart_writel(port, ATMEL_US_BRGR, cd); in atmel_config_iso7816()
421 atmel_uart_writel(port, ATMEL_US_FIDI, fidi); in atmel_config_iso7816()
423 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXEN); in atmel_config_iso7816()
426 dev_dbg(port->dev, "Setting UART back to RS232\n"); in atmel_config_iso7816()
430 atmel_uart_writel(port, ATMEL_US_TTGR, 0); in atmel_config_iso7816()
431 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->backup_brgr); in atmel_config_iso7816()
432 atmel_uart_writel(port, ATMEL_US_FIDI, 0x174); in atmel_config_iso7816()
434 if (atmel_use_pdc_tx(port)) in atmel_config_iso7816()
441 port->iso7816 = *iso7816conf; in atmel_config_iso7816()
443 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_config_iso7816()
447 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_iso7816()
455 static u_int atmel_tx_empty(struct uart_port *port) in atmel_tx_empty() argument
457 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_empty()
461 return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ? in atmel_tx_empty()
469 static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) in atmel_set_mctrl() argument
472 unsigned int mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_set_mctrl()
474 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_mctrl()
477 if (port->rs485.flags & SER_RS485_ENABLED) { in atmel_set_mctrl()
478 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_set_mctrl()
479 port->rs485.delay_rts_after_send); in atmel_set_mctrl()
509 atmel_uart_writel(port, ATMEL_US_CR, control); in atmel_set_mctrl()
520 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_set_mctrl()
526 static u_int atmel_get_mctrl(struct uart_port *port) in atmel_get_mctrl() argument
528 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_mctrl()
531 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_get_mctrl()
551 static void atmel_stop_tx(struct uart_port *port) in atmel_stop_tx() argument
553 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_stop_tx()
554 bool is_pdc = atmel_use_pdc_tx(port); in atmel_stop_tx()
555 bool is_dma = is_pdc || atmel_use_dma_tx(port); in atmel_stop_tx()
559 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_stop_tx()
568 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS); in atmel_stop_tx()
573 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_stop_tx()
575 if (atmel_uart_is_half_duplex(port)) in atmel_stop_tx()
577 atmel_start_rx(port); in atmel_stop_tx()
583 static void atmel_start_tx(struct uart_port *port) in atmel_start_tx() argument
585 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_start_tx()
586 bool is_pdc = atmel_use_pdc_tx(port); in atmel_start_tx()
587 bool is_dma = is_pdc || atmel_use_dma_tx(port); in atmel_start_tx()
589 if (is_pdc && (atmel_uart_readl(port, ATMEL_PDC_PTSR) in atmel_start_tx()
595 if (is_dma && atmel_uart_is_half_duplex(port)) in atmel_start_tx()
596 atmel_stop_rx(port); in atmel_start_tx()
600 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_start_tx()
604 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_start_tx()
608 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); in atmel_start_tx()
616 static void atmel_start_rx(struct uart_port *port) in atmel_start_rx() argument
619 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_start_rx()
621 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RXEN); in atmel_start_rx()
623 if (atmel_use_pdc_rx(port)) { in atmel_start_rx()
625 atmel_uart_writel(port, ATMEL_US_IER, in atmel_start_rx()
627 port->read_status_mask); in atmel_start_rx()
628 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN); in atmel_start_rx()
630 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_RXRDY); in atmel_start_rx()
637 static void atmel_stop_rx(struct uart_port *port) in atmel_stop_rx() argument
639 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RXDIS); in atmel_stop_rx()
641 if (atmel_use_pdc_rx(port)) { in atmel_stop_rx()
643 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTDIS); in atmel_stop_rx()
644 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_stop_rx()
646 port->read_status_mask); in atmel_stop_rx()
648 atmel_uart_writel(port, ATMEL_US_IDR, ATMEL_US_RXRDY); in atmel_stop_rx()
655 static void atmel_enable_ms(struct uart_port *port) in atmel_enable_ms() argument
657 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_enable_ms()
680 atmel_uart_writel(port, ATMEL_US_IER, ier); in atmel_enable_ms()
688 static void atmel_disable_ms(struct uart_port *port) in atmel_disable_ms() argument
690 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_disable_ms()
715 atmel_uart_writel(port, ATMEL_US_IDR, idr); in atmel_disable_ms()
721 static void atmel_break_ctl(struct uart_port *port, int break_state) in atmel_break_ctl() argument
725 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTBRK); in atmel_break_ctl()
728 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STPBRK); in atmel_break_ctl()
735 atmel_buffer_rx_char(struct uart_port *port, unsigned int status, in atmel_buffer_rx_char() argument
738 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_buffer_rx_char()
759 static void atmel_pdc_rxerr(struct uart_port *port, unsigned int status) in atmel_pdc_rxerr() argument
762 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_pdc_rxerr()
767 port->icount.brk++; in atmel_pdc_rxerr()
770 port->icount.parity++; in atmel_pdc_rxerr()
772 port->icount.frame++; in atmel_pdc_rxerr()
774 port->icount.overrun++; in atmel_pdc_rxerr()
780 static void atmel_rx_chars(struct uart_port *port) in atmel_rx_chars() argument
782 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_chars()
785 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_rx_chars()
787 ch = atmel_uart_read_char(port); in atmel_rx_chars()
798 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_rx_chars()
803 atmel_uart_writel(port, ATMEL_US_IER, in atmel_rx_chars()
813 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_rx_chars()
820 atmel_buffer_rx_char(port, status, ch); in atmel_rx_chars()
821 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_rx_chars()
831 static void atmel_tx_chars(struct uart_port *port) in atmel_tx_chars() argument
833 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_chars()
837 pending = uart_port_tx(port, ch, in atmel_tx_chars()
838 atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY, in atmel_tx_chars()
839 atmel_uart_write_char(port, ch)); in atmel_tx_chars()
848 atmel_uart_writel(port, ATMEL_US_IER, in atmel_tx_chars()
851 if (atmel_uart_is_half_duplex(port)) in atmel_tx_chars()
859 struct uart_port *port = &atmel_port->uart; in atmel_complete_tx_dma() local
860 struct circ_buf *xmit = &port->state->xmit; in atmel_complete_tx_dma()
864 spin_lock_irqsave(&port->lock, flags); in atmel_complete_tx_dma()
868 uart_xmit_advance(port, atmel_port->tx_len); in atmel_complete_tx_dma()
877 uart_write_wakeup(port); in atmel_complete_tx_dma()
886 else if (atmel_uart_is_half_duplex(port)) { in atmel_complete_tx_dma()
892 atmel_uart_writel(port, ATMEL_US_IER, in atmel_complete_tx_dma()
896 spin_unlock_irqrestore(&port->lock, flags); in atmel_complete_tx_dma()
899 static void atmel_release_tx_dma(struct uart_port *port) in atmel_release_tx_dma() argument
901 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_dma()
907 dma_unmap_sg(port->dev, &atmel_port->sg_tx, 1, in atmel_release_tx_dma()
919 static void atmel_tx_dma(struct uart_port *port) in atmel_tx_dma() argument
921 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_dma()
922 struct circ_buf *xmit = &port->state->xmit; in atmel_tx_dma()
933 if (!uart_circ_empty(xmit) && !uart_tx_stopped(port)) { in atmel_tx_dma()
987 dev_err(port->dev, "Failed to send via dma!\n"); in atmel_tx_dma()
991 dma_sync_sg_for_device(port->dev, sg_tx, 1, DMA_TO_DEVICE); in atmel_tx_dma()
998 dev_err(port->dev, "dma_submit_error %d\n", in atmel_tx_dma()
1007 uart_write_wakeup(port); in atmel_tx_dma()
1010 static int atmel_prepare_tx_dma(struct uart_port *port) in atmel_prepare_tx_dma() argument
1012 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_dma()
1013 struct device *mfd_dev = port->dev->parent; in atmel_prepare_tx_dma()
1024 dev_info(port->dev, "using %s for tx DMA transfers\n", in atmel_prepare_tx_dma()
1030 BUG_ON(!PAGE_ALIGNED(port->state->xmit.buf)); in atmel_prepare_tx_dma()
1032 virt_to_page(port->state->xmit.buf), in atmel_prepare_tx_dma()
1034 offset_in_page(port->state->xmit.buf)); in atmel_prepare_tx_dma()
1035 nent = dma_map_sg(port->dev, in atmel_prepare_tx_dma()
1041 dev_dbg(port->dev, "need to release resource of dma\n"); in atmel_prepare_tx_dma()
1044 dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__, in atmel_prepare_tx_dma()
1046 port->state->xmit.buf, in atmel_prepare_tx_dma()
1056 config.dst_addr = port->mapbase + ATMEL_US_THR; in atmel_prepare_tx_dma()
1062 dev_err(port->dev, "DMA tx slave configuration failed\n"); in atmel_prepare_tx_dma()
1069 dev_err(port->dev, "TX channel not available, switch to pio\n"); in atmel_prepare_tx_dma()
1072 atmel_release_tx_dma(port); in atmel_prepare_tx_dma()
1078 struct uart_port *port = arg; in atmel_complete_rx_dma() local
1079 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_complete_rx_dma()
1084 static void atmel_release_rx_dma(struct uart_port *port) in atmel_release_rx_dma() argument
1086 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_dma()
1092 dma_unmap_sg(port->dev, &atmel_port->sg_rx, 1, in atmel_release_rx_dma()
1101 static void atmel_rx_from_dma(struct uart_port *port) in atmel_rx_from_dma() argument
1103 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_dma()
1104 struct tty_port *tport = &port->state->port; in atmel_rx_from_dma()
1113 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_rx_from_dma()
1119 dev_dbg(port->dev, "Get residue error, restart tasklet\n"); in atmel_rx_from_dma()
1120 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_TIMEOUT); in atmel_rx_from_dma()
1126 dma_sync_sg_for_cpu(port->dev, in atmel_rx_from_dma()
1157 port->icount.rx += count; in atmel_rx_from_dma()
1169 port->icount.rx += count; in atmel_rx_from_dma()
1173 dma_sync_sg_for_device(port->dev, in atmel_rx_from_dma()
1180 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_TIMEOUT); in atmel_rx_from_dma()
1183 static int atmel_prepare_rx_dma(struct uart_port *port) in atmel_prepare_rx_dma() argument
1185 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_dma()
1186 struct device *mfd_dev = port->dev->parent; in atmel_prepare_rx_dma()
1201 dev_info(port->dev, "using %s for rx DMA transfers\n", in atmel_prepare_rx_dma()
1212 nent = dma_map_sg(port->dev, in atmel_prepare_rx_dma()
1218 dev_dbg(port->dev, "need to release resource of dma\n"); in atmel_prepare_rx_dma()
1221 dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__, in atmel_prepare_rx_dma()
1231 config.src_addr = port->mapbase + ATMEL_US_RHR; in atmel_prepare_rx_dma()
1237 dev_err(port->dev, "DMA rx slave configuration failed\n"); in atmel_prepare_rx_dma()
1251 dev_err(port->dev, "Preparing DMA cyclic failed\n"); in atmel_prepare_rx_dma()
1255 desc->callback_param = port; in atmel_prepare_rx_dma()
1259 dev_err(port->dev, "dma_submit_error %d\n", in atmel_prepare_rx_dma()
1269 dev_err(port->dev, "RX channel not available, switch to pio\n"); in atmel_prepare_rx_dma()
1272 atmel_release_rx_dma(port); in atmel_prepare_rx_dma()
1280 struct uart_port *port = &atmel_port->uart; in atmel_uart_timer_callback() local
1285 jiffies + uart_poll_timeout(port)); in atmel_uart_timer_callback()
1293 atmel_handle_receive(struct uart_port *port, unsigned int pending) in atmel_handle_receive() argument
1295 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_receive()
1297 if (atmel_use_pdc_rx(port)) { in atmel_handle_receive()
1306 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_receive()
1314 atmel_pdc_rxerr(port, pending); in atmel_handle_receive()
1317 if (atmel_use_dma_rx(port)) { in atmel_handle_receive()
1319 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_receive()
1328 atmel_rx_chars(port); in atmel_handle_receive()
1334 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_handle_receive()
1335 atmel_uart_writel(port, ATMEL_US_IDR, ATMEL_US_RXBRK); in atmel_handle_receive()
1344 atmel_handle_transmit(struct uart_port *port, unsigned int pending) in atmel_handle_transmit() argument
1346 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_transmit()
1349 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_transmit()
1354 if (!(atmel_uart_readl(port, ATMEL_US_CSR) in atmel_handle_transmit()
1356 dev_warn(port->dev, "Should start RX, but TX fifo is not empty\n"); in atmel_handle_transmit()
1359 atmel_start_rx(port); in atmel_handle_transmit()
1370 atmel_handle_status(struct uart_port *port, unsigned int pending, in atmel_handle_status() argument
1373 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_status()
1385 port->icount.rng++; in atmel_handle_status()
1387 port->icount.dsr++; in atmel_handle_status()
1389 uart_handle_dcd_change(port, !(status & ATMEL_US_DCD)); in atmel_handle_status()
1391 uart_handle_cts_change(port, !(status & ATMEL_US_CTS)); in atmel_handle_status()
1393 wake_up_interruptible(&port->state->port.delta_msr_wait); in atmel_handle_status()
1398 dev_dbg(port->dev, "ISO7816 ERROR (0x%08x)\n", pending); in atmel_handle_status()
1406 struct uart_port *port = dev_id; in atmel_interrupt() local
1407 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_interrupt()
1413 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_interrupt()
1414 mask = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_interrupt()
1422 atmel_uart_writel(port, ATMEL_US_IDR, mask); in atmel_interrupt()
1427 atmel_handle_receive(port, pending); in atmel_interrupt()
1428 atmel_handle_status(port, pending, status); in atmel_interrupt()
1429 atmel_handle_transmit(port, pending); in atmel_interrupt()
1437 static void atmel_release_tx_pdc(struct uart_port *port) in atmel_release_tx_pdc() argument
1439 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_pdc()
1442 dma_unmap_single(port->dev, in atmel_release_tx_pdc()
1451 static void atmel_tx_pdc(struct uart_port *port) in atmel_tx_pdc() argument
1453 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_pdc()
1454 struct circ_buf *xmit = &port->state->xmit; in atmel_tx_pdc()
1459 if (atmel_uart_readl(port, ATMEL_PDC_TCR)) in atmel_tx_pdc()
1461 uart_xmit_advance(port, pdc->ofs); in atmel_tx_pdc()
1467 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_tx_pdc()
1469 if (!uart_circ_empty(xmit) && !uart_tx_stopped(port)) { in atmel_tx_pdc()
1470 dma_sync_single_for_device(port->dev, in atmel_tx_pdc()
1478 atmel_uart_writel(port, ATMEL_PDC_TPR, in atmel_tx_pdc()
1480 atmel_uart_writel(port, ATMEL_PDC_TCR, count); in atmel_tx_pdc()
1482 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_tx_pdc()
1484 atmel_uart_writel(port, ATMEL_US_IER, in atmel_tx_pdc()
1487 if (atmel_uart_is_half_duplex(port)) { in atmel_tx_pdc()
1489 atmel_start_rx(port); in atmel_tx_pdc()
1494 uart_write_wakeup(port); in atmel_tx_pdc()
1497 static int atmel_prepare_tx_pdc(struct uart_port *port) in atmel_prepare_tx_pdc() argument
1499 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_pdc()
1501 struct circ_buf *xmit = &port->state->xmit; in atmel_prepare_tx_pdc()
1504 pdc->dma_addr = dma_map_single(port->dev, in atmel_prepare_tx_pdc()
1514 static void atmel_rx_from_ring(struct uart_port *port) in atmel_rx_from_ring() argument
1516 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_ring()
1531 port->icount.rx++; in atmel_rx_from_ring()
1545 port->icount.brk++; in atmel_rx_from_ring()
1546 if (uart_handle_break(port)) in atmel_rx_from_ring()
1550 port->icount.parity++; in atmel_rx_from_ring()
1552 port->icount.frame++; in atmel_rx_from_ring()
1554 port->icount.overrun++; in atmel_rx_from_ring()
1556 status &= port->read_status_mask; in atmel_rx_from_ring()
1567 if (uart_handle_sysrq_char(port, c.ch)) in atmel_rx_from_ring()
1570 uart_insert_char(port, status, ATMEL_US_OVRE, c.ch, flg); in atmel_rx_from_ring()
1573 tty_flip_buffer_push(&port->state->port); in atmel_rx_from_ring()
1576 static void atmel_release_rx_pdc(struct uart_port *port) in atmel_release_rx_pdc() argument
1578 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_pdc()
1584 dma_unmap_single(port->dev, in atmel_release_rx_pdc()
1592 static void atmel_rx_from_pdc(struct uart_port *port) in atmel_rx_from_pdc() argument
1594 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_pdc()
1595 struct tty_port *tport = &port->state->port; in atmel_rx_from_pdc()
1604 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_rx_from_pdc()
1607 head = atmel_uart_readl(port, ATMEL_PDC_RPR) - pdc->dma_addr; in atmel_rx_from_pdc()
1623 dma_sync_single_for_cpu(port->dev, pdc->dma_addr, in atmel_rx_from_pdc()
1637 dma_sync_single_for_device(port->dev, pdc->dma_addr, in atmel_rx_from_pdc()
1640 port->icount.rx += count; in atmel_rx_from_pdc()
1650 atmel_uart_writel(port, ATMEL_PDC_RNPR, pdc->dma_addr); in atmel_rx_from_pdc()
1651 atmel_uart_writel(port, ATMEL_PDC_RNCR, pdc->dma_size); in atmel_rx_from_pdc()
1660 atmel_uart_writel(port, ATMEL_US_IER, in atmel_rx_from_pdc()
1664 static int atmel_prepare_rx_pdc(struct uart_port *port) in atmel_prepare_rx_pdc() argument
1666 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_pdc()
1675 dma_unmap_single(port->dev, in atmel_prepare_rx_pdc()
1684 pdc->dma_addr = dma_map_single(port->dev, in atmel_prepare_rx_pdc()
1694 atmel_uart_writel(port, ATMEL_PDC_RPR, atmel_port->pdc_rx[0].dma_addr); in atmel_prepare_rx_pdc()
1695 atmel_uart_writel(port, ATMEL_PDC_RCR, PDC_BUFFER_SIZE); in atmel_prepare_rx_pdc()
1697 atmel_uart_writel(port, ATMEL_PDC_RNPR, in atmel_prepare_rx_pdc()
1699 atmel_uart_writel(port, ATMEL_PDC_RNCR, PDC_BUFFER_SIZE); in atmel_prepare_rx_pdc()
1711 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_rx_func() local
1714 spin_lock(&port->lock); in atmel_tasklet_rx_func()
1715 atmel_port->schedule_rx(port); in atmel_tasklet_rx_func()
1716 spin_unlock(&port->lock); in atmel_tasklet_rx_func()
1723 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_tx_func() local
1726 spin_lock(&port->lock); in atmel_tasklet_tx_func()
1727 atmel_port->schedule_tx(port); in atmel_tasklet_tx_func()
1728 spin_unlock(&port->lock); in atmel_tasklet_tx_func()
1764 static void atmel_set_ops(struct uart_port *port) in atmel_set_ops() argument
1766 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_ops()
1768 if (atmel_use_dma_rx(port)) { in atmel_set_ops()
1772 } else if (atmel_use_pdc_rx(port)) { in atmel_set_ops()
1782 if (atmel_use_dma_tx(port)) { in atmel_set_ops()
1786 } else if (atmel_use_pdc_tx(port)) { in atmel_set_ops()
1800 static void atmel_get_ip_name(struct uart_port *port) in atmel_get_ip_name() argument
1802 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_ip_name()
1803 int name = atmel_uart_readl(port, ATMEL_US_NAME); in atmel_get_ip_name()
1822 dev_dbg(port->dev, "Uart with hw timer"); in atmel_get_ip_name()
1826 dev_dbg(port->dev, "Usart\n"); in atmel_get_ip_name()
1831 version = atmel_uart_readl(port, ATMEL_US_VERSION); in atmel_get_ip_name()
1848 dev_dbg(port->dev, "Dbgu or uart without hw timer\n"); in atmel_get_ip_name()
1851 version = atmel_uart_readl(port, ATMEL_US_VERSION); in atmel_get_ip_name()
1856 dev_dbg(port->dev, "This version is usart\n"); in atmel_get_ip_name()
1864 dev_dbg(port->dev, "This version is uart\n"); in atmel_get_ip_name()
1867 dev_err(port->dev, "Not supported ip name nor version, set to uart\n"); in atmel_get_ip_name()
1875 static int atmel_startup(struct uart_port *port) in atmel_startup() argument
1877 struct platform_device *pdev = to_platform_device(port->dev); in atmel_startup()
1878 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_startup()
1886 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_startup()
1892 retval = request_irq(port->irq, atmel_interrupt, in atmel_startup()
1894 dev_name(&pdev->dev), port); in atmel_startup()
1896 dev_err(port->dev, "atmel_startup - Can't get irq\n"); in atmel_startup()
1908 atmel_set_ops(port); in atmel_startup()
1911 retval = atmel_port->prepare_rx(port); in atmel_startup()
1913 atmel_set_ops(port); in atmel_startup()
1917 retval = atmel_port->prepare_tx(port); in atmel_startup()
1919 atmel_set_ops(port); in atmel_startup()
1930 atmel_uart_writel(port, ATMEL_US_CR, in atmel_startup()
1935 if (atmel_use_dma_tx(port)) in atmel_startup()
1945 atmel_uart_writel(port, ATMEL_US_FMR, fmr); in atmel_startup()
1949 atmel_port->irq_status_prev = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_startup()
1954 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_startup()
1956 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_startup()
1961 if (atmel_use_pdc_rx(port)) { in atmel_startup()
1965 jiffies + uart_poll_timeout(port)); in atmel_startup()
1968 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1970 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_startup()
1972 atmel_uart_writel(port, ATMEL_US_IER, in atmel_startup()
1976 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN); in atmel_startup()
1977 } else if (atmel_use_dma_rx(port)) { in atmel_startup()
1981 jiffies + uart_poll_timeout(port)); in atmel_startup()
1984 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1986 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_startup()
1988 atmel_uart_writel(port, ATMEL_US_IER, in atmel_startup()
1993 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_RXRDY); in atmel_startup()
2003 static void atmel_flush_buffer(struct uart_port *port) in atmel_flush_buffer() argument
2005 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_flush_buffer()
2007 if (atmel_use_pdc_tx(port)) { in atmel_flush_buffer()
2008 atmel_uart_writel(port, ATMEL_PDC_TCR, 0); in atmel_flush_buffer()
2021 static void atmel_shutdown(struct uart_port *port) in atmel_shutdown() argument
2023 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_shutdown()
2026 atmel_disable_ms(port); in atmel_shutdown()
2029 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_shutdown()
2041 synchronize_irq(port->irq); in atmel_shutdown()
2054 atmel_stop_rx(port); in atmel_shutdown()
2055 atmel_stop_tx(port); in atmel_shutdown()
2057 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_shutdown()
2063 atmel_port->release_rx(port); in atmel_shutdown()
2065 atmel_port->release_tx(port); in atmel_shutdown()
2076 free_irq(port->irq, port); in atmel_shutdown()
2078 atmel_flush_buffer(port); in atmel_shutdown()
2084 static void atmel_serial_pm(struct uart_port *port, unsigned int state, in atmel_serial_pm() argument
2087 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_pm()
2098 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->backup_imr); in atmel_serial_pm()
2102 atmel_port->backup_imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_serial_pm()
2103 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_serial_pm()
2114 dev_err(port->dev, "atmel_serial: unknown pm %d\n", state); in atmel_serial_pm()
2121 static void atmel_set_termios(struct uart_port *port, in atmel_set_termios() argument
2125 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_termios()
2132 mode = old_mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_set_termios()
2141 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); in atmel_set_termios()
2178 spin_lock_irqsave(&port->lock, flags); in atmel_set_termios()
2180 port->read_status_mask = ATMEL_US_OVRE; in atmel_set_termios()
2182 port->read_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE); in atmel_set_termios()
2184 port->read_status_mask |= ATMEL_US_RXBRK; in atmel_set_termios()
2186 if (atmel_use_pdc_rx(port)) in atmel_set_termios()
2188 atmel_uart_writel(port, ATMEL_US_IER, port->read_status_mask); in atmel_set_termios()
2193 port->ignore_status_mask = 0; in atmel_set_termios()
2195 port->ignore_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE); in atmel_set_termios()
2197 port->ignore_status_mask |= ATMEL_US_RXBRK; in atmel_set_termios()
2203 port->ignore_status_mask |= ATMEL_US_OVRE; in atmel_set_termios()
2208 uart_update_timeout(port, termios->c_cflag, baud); in atmel_set_termios()
2215 imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_set_termios()
2216 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_set_termios()
2219 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS); in atmel_set_termios()
2223 if (port->rs485.flags & SER_RS485_ENABLED) { in atmel_set_termios()
2224 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_set_termios()
2225 port->rs485.delay_rts_after_send); in atmel_set_termios()
2227 } else if (port->iso7816.flags & SER_ISO7816_ENABLED) { in atmel_set_termios()
2228 atmel_uart_writel(port, ATMEL_US_TTGR, port->iso7816.tg); in atmel_set_termios()
2233 if ((port->iso7816.flags & SER_ISO7816_T_PARAM) in atmel_set_termios()
2240 if (atmel_use_fifo(port) && in atmel_set_termios()
2280 div = DIV_ROUND_CLOSEST(port->uartclk, baud * 2); in atmel_set_termios()
2284 cd = uart_get_divisor(port, baud); in atmel_set_termios()
2343 if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) in atmel_set_termios()
2344 atmel_uart_writel(port, ATMEL_US_BRGR, quot); in atmel_set_termios()
2347 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_set_termios()
2364 atmel_uart_writel(port, ATMEL_US_CR, rts_state); in atmel_set_termios()
2367 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_set_termios()
2368 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_set_termios()
2372 atmel_uart_writel(port, ATMEL_US_IER, imr); in atmel_set_termios()
2375 if (UART_ENABLE_MS(port, termios->c_cflag)) in atmel_set_termios()
2376 atmel_enable_ms(port); in atmel_set_termios()
2378 atmel_disable_ms(port); in atmel_set_termios()
2380 spin_unlock_irqrestore(&port->lock, flags); in atmel_set_termios()
2383 static void atmel_set_ldisc(struct uart_port *port, struct ktermios *termios) in atmel_set_ldisc() argument
2386 port->flags |= UPF_HARDPPS_CD; in atmel_set_ldisc()
2387 spin_lock_irq(&port->lock); in atmel_set_ldisc()
2388 atmel_enable_ms(port); in atmel_set_ldisc()
2389 spin_unlock_irq(&port->lock); in atmel_set_ldisc()
2391 port->flags &= ~UPF_HARDPPS_CD; in atmel_set_ldisc()
2392 if (!UART_ENABLE_MS(port, termios->c_cflag)) { in atmel_set_ldisc()
2393 spin_lock_irq(&port->lock); in atmel_set_ldisc()
2394 atmel_disable_ms(port); in atmel_set_ldisc()
2395 spin_unlock_irq(&port->lock); in atmel_set_ldisc()
2403 static const char *atmel_type(struct uart_port *port) in atmel_type() argument
2405 return (port->type == PORT_ATMEL) ? "ATMEL_SERIAL" : NULL; in atmel_type()
2411 static void atmel_release_port(struct uart_port *port) in atmel_release_port() argument
2413 struct platform_device *mpdev = to_platform_device(port->dev->parent); in atmel_release_port()
2416 release_mem_region(port->mapbase, size); in atmel_release_port()
2418 if (port->flags & UPF_IOREMAP) { in atmel_release_port()
2419 iounmap(port->membase); in atmel_release_port()
2420 port->membase = NULL; in atmel_release_port()
2427 static int atmel_request_port(struct uart_port *port) in atmel_request_port() argument
2429 struct platform_device *mpdev = to_platform_device(port->dev->parent); in atmel_request_port()
2432 if (!request_mem_region(port->mapbase, size, "atmel_serial")) in atmel_request_port()
2435 if (port->flags & UPF_IOREMAP) { in atmel_request_port()
2436 port->membase = ioremap(port->mapbase, size); in atmel_request_port()
2437 if (port->membase == NULL) { in atmel_request_port()
2438 release_mem_region(port->mapbase, size); in atmel_request_port()
2449 static void atmel_config_port(struct uart_port *port, int flags) in atmel_config_port() argument
2452 port->type = PORT_ATMEL; in atmel_config_port()
2453 atmel_request_port(port); in atmel_config_port()
2460 static int atmel_verify_port(struct uart_port *port, struct serial_struct *ser) in atmel_verify_port() argument
2465 if (port->irq != ser->irq) in atmel_verify_port()
2469 if (port->uartclk / 16 != ser->baud_base) in atmel_verify_port()
2471 if (port->mapbase != (unsigned long)ser->iomem_base) in atmel_verify_port()
2473 if (port->iobase != ser->port) in atmel_verify_port()
2481 static int atmel_poll_get_char(struct uart_port *port) in atmel_poll_get_char() argument
2483 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_RXRDY)) in atmel_poll_get_char()
2486 return atmel_uart_read_char(port); in atmel_poll_get_char()
2489 static void atmel_poll_put_char(struct uart_port *port, unsigned char ch) in atmel_poll_put_char() argument
2491 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) in atmel_poll_put_char()
2494 atmel_uart_write_char(port, ch); in atmel_poll_put_char()
2537 struct uart_port *port = &atmel_port->uart; in atmel_init_port() local
2541 atmel_set_ops(port); in atmel_init_port()
2543 port->iotype = UPIO_MEM; in atmel_init_port()
2544 port->flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP; in atmel_init_port()
2545 port->ops = &atmel_pops; in atmel_init_port()
2546 port->fifosize = 1; in atmel_init_port()
2547 port->dev = &pdev->dev; in atmel_init_port()
2548 port->mapbase = mpdev->resource[0].start; in atmel_init_port()
2549 port->irq = platform_get_irq(mpdev, 0); in atmel_init_port()
2550 port->rs485_config = atmel_config_rs485; in atmel_init_port()
2551 port->rs485_supported = atmel_rs485_supported; in atmel_init_port()
2552 port->iso7816_config = atmel_config_iso7816; in atmel_init_port()
2553 port->membase = NULL; in atmel_init_port()
2557 ret = uart_get_rs485_mode(port); in atmel_init_port()
2561 port->uartclk = clk_get_rate(atmel_port->clk); in atmel_init_port()
2567 if (atmel_uart_is_half_duplex(port)) in atmel_init_port()
2569 else if (atmel_use_pdc_tx(port)) { in atmel_init_port()
2570 port->fifosize = PDC_BUFFER_SIZE; in atmel_init_port()
2580 static void atmel_console_putchar(struct uart_port *port, unsigned char ch) in atmel_console_putchar() argument
2582 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) in atmel_console_putchar()
2584 atmel_uart_write_char(port, ch); in atmel_console_putchar()
2592 struct uart_port *port = &atmel_ports[co->index].uart; in atmel_console_write() local
2593 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_write()
2600 imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_console_write()
2601 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_console_write()
2605 pdc_tx = atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN; in atmel_console_write()
2606 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_console_write()
2609 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); in atmel_console_write()
2612 uart_console_write(port, s, count, atmel_console_putchar); in atmel_console_write()
2619 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_console_write()
2624 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_console_write()
2627 atmel_uart_writel(port, ATMEL_US_IER, imr); in atmel_console_write()
2634 static void __init atmel_console_get_options(struct uart_port *port, int *baud, in atmel_console_get_options() argument
2643 quot = atmel_uart_readl(port, ATMEL_US_BRGR) & ATMEL_US_CD; in atmel_console_get_options()
2647 mr = atmel_uart_readl(port, ATMEL_US_MR) & ATMEL_US_CHRL; in atmel_console_get_options()
2653 mr = atmel_uart_readl(port, ATMEL_US_MR) & ATMEL_US_PAR; in atmel_console_get_options()
2659 *baud = port->uartclk / (16 * quot); in atmel_console_get_options()
2664 struct uart_port *port = &atmel_ports[co->index].uart; in atmel_console_setup() local
2665 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_setup()
2671 if (port->membase == NULL) { in atmel_console_setup()
2676 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_console_setup()
2677 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_console_setup()
2678 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_console_setup()
2684 atmel_console_get_options(port, &baud, &parity, &bits); in atmel_console_setup()
2686 return uart_set_options(port, co, baud, parity, bits, flow); in atmel_console_setup()
2706 uart_console_write(&dev->port, s, n, atmel_console_putchar); in atmel_serial_early_write()
2712 if (!device->port.membase) in atmel_early_console_setup()
2752 struct uart_port *port = dev_get_drvdata(dev); in atmel_serial_suspend() local
2753 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_suspend()
2755 if (uart_console(port) && console_suspend_enabled) { in atmel_serial_suspend()
2757 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & in atmel_serial_suspend()
2762 if (uart_console(port) && !console_suspend_enabled) { in atmel_serial_suspend()
2766 atmel_port->cache.mr = atmel_uart_readl(port, ATMEL_US_MR); in atmel_serial_suspend()
2767 atmel_port->cache.imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_serial_suspend()
2768 atmel_port->cache.brgr = atmel_uart_readl(port, ATMEL_US_BRGR); in atmel_serial_suspend()
2769 atmel_port->cache.rtor = atmel_uart_readl(port, in atmel_serial_suspend()
2771 atmel_port->cache.ttgr = atmel_uart_readl(port, ATMEL_US_TTGR); in atmel_serial_suspend()
2772 atmel_port->cache.fmr = atmel_uart_readl(port, ATMEL_US_FMR); in atmel_serial_suspend()
2773 atmel_port->cache.fimr = atmel_uart_readl(port, ATMEL_US_FIMR); in atmel_serial_suspend()
2787 uart_suspend_port(&atmel_uart, port); in atmel_serial_suspend()
2794 struct uart_port *port = dev_get_drvdata(dev); in atmel_serial_resume() local
2795 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_resume()
2798 if (uart_console(port) && !console_suspend_enabled) { in atmel_serial_resume()
2799 atmel_uart_writel(port, ATMEL_US_MR, atmel_port->cache.mr); in atmel_serial_resume()
2800 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->cache.imr); in atmel_serial_resume()
2801 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->cache.brgr); in atmel_serial_resume()
2802 atmel_uart_writel(port, atmel_port->rtor, in atmel_serial_resume()
2804 atmel_uart_writel(port, ATMEL_US_TTGR, atmel_port->cache.ttgr); in atmel_serial_resume()
2807 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_FIFOEN | in atmel_serial_resume()
2809 atmel_uart_writel(port, ATMEL_US_FMR, in atmel_serial_resume()
2811 atmel_uart_writel(port, ATMEL_US_FIER, in atmel_serial_resume()
2814 atmel_start_rx(port); in atmel_serial_resume()
2819 atmel_handle_receive(port, atmel_port->pending); in atmel_serial_resume()
2820 atmel_handle_status(port, atmel_port->pending, in atmel_serial_resume()
2822 atmel_handle_transmit(port, atmel_port->pending); in atmel_serial_resume()
2828 uart_resume_port(&atmel_uart, port); in atmel_serial_resume()
3006 struct uart_port *port = platform_get_drvdata(pdev); in atmel_serial_remove() local
3007 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_remove()
3014 uart_remove_one_port(&atmel_uart, port); in atmel_serial_remove()
3020 clear_bit(port->line, atmel_ports_in_use); in atmel_serial_remove()