Lines Matching refs:port

57 static void atmel_start_rx(struct uart_port *port);
58 static void atmel_stop_rx(struct uart_port *port);
184 int (*prepare_rx)(struct uart_port *port);
185 int (*prepare_tx)(struct uart_port *port);
186 void (*schedule_rx)(struct uart_port *port);
187 void (*schedule_tx)(struct uart_port *port);
188 void (*release_rx)(struct uart_port *port);
189 void (*release_tx)(struct uart_port *port);
208 static inline u32 atmel_uart_readl(struct uart_port *port, u32 reg) in atmel_uart_readl() argument
210 return __raw_readl(port->membase + reg); in atmel_uart_readl()
213 static inline void atmel_uart_writel(struct uart_port *port, u32 reg, u32 value) in atmel_uart_writel() argument
215 __raw_writel(value, port->membase + reg); in atmel_uart_writel()
218 static inline u8 atmel_uart_read_char(struct uart_port *port) in atmel_uart_read_char() argument
220 return __raw_readb(port->membase + ATMEL_US_RHR); in atmel_uart_read_char()
223 static inline void atmel_uart_write_char(struct uart_port *port, u8 value) in atmel_uart_write_char() argument
225 __raw_writeb(value, port->membase + ATMEL_US_THR); in atmel_uart_write_char()
228 static inline int atmel_uart_is_half_duplex(struct uart_port *port) in atmel_uart_is_half_duplex() argument
230 return ((port->rs485.flags & SER_RS485_ENABLED) && in atmel_uart_is_half_duplex()
231 !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || in atmel_uart_is_half_duplex()
232 (port->iso7816.flags & SER_ISO7816_ENABLED); in atmel_uart_is_half_duplex()
241 static bool atmel_use_pdc_rx(struct uart_port *port) in atmel_use_pdc_rx() argument
243 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_rx()
248 static bool atmel_use_pdc_tx(struct uart_port *port) in atmel_use_pdc_tx() argument
250 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_tx()
255 static bool atmel_use_pdc_rx(struct uart_port *port) in atmel_use_pdc_rx() argument
260 static bool atmel_use_pdc_tx(struct uart_port *port) in atmel_use_pdc_tx() argument
266 static bool atmel_use_dma_tx(struct uart_port *port) in atmel_use_dma_tx() argument
268 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_tx()
273 static bool atmel_use_dma_rx(struct uart_port *port) in atmel_use_dma_rx() argument
275 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_rx()
280 static bool atmel_use_fifo(struct uart_port *port) in atmel_use_fifo() argument
282 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_fifo()
295 static int atmel_config_rs485(struct uart_port *port, struct ktermios *termios, in atmel_config_rs485() argument
298 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_rs485()
302 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_rs485()
304 mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_rs485()
307 dev_dbg(port->dev, "Setting UART to RS485\n"); in atmel_config_rs485()
313 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_config_rs485()
318 dev_dbg(port->dev, "Setting UART to RS232\n"); in atmel_config_rs485()
319 if (atmel_use_pdc_tx(port)) in atmel_config_rs485()
325 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_config_rs485()
328 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_rs485()
333 static unsigned int atmel_calc_cd(struct uart_port *port, in atmel_calc_cd() argument
336 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_calc_cd()
346 static unsigned int atmel_calc_fidi(struct uart_port *port, in atmel_calc_fidi() argument
360 static int atmel_config_iso7816(struct uart_port *port, in atmel_config_iso7816() argument
363 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_iso7816()
369 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_iso7816()
371 mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_iso7816()
377 dev_err(port->dev, "ISO7816: Timeguard exceeding 255\n"); in atmel_config_iso7816()
390 dev_err(port->dev, "ISO7816: Type not supported\n"); in atmel_config_iso7816()
403 cd = atmel_calc_cd(port, iso7816conf); in atmel_config_iso7816()
404 fidi = atmel_calc_fidi(port, iso7816conf); in atmel_config_iso7816()
406 dev_warn(port->dev, "ISO7816 fidi = 0, Generator generates no signal\n"); in atmel_config_iso7816()
409 dev_err(port->dev, "ISO7816 fidi = %u, value not supported\n", fidi); in atmel_config_iso7816()
415 if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) { in atmel_config_iso7816()
417 atmel_port->backup_mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_iso7816()
418 atmel_port->backup_brgr = atmel_uart_readl(port, ATMEL_US_BRGR); in atmel_config_iso7816()
421 atmel_uart_writel(port, ATMEL_US_TTGR, iso7816conf->tg); in atmel_config_iso7816()
422 atmel_uart_writel(port, ATMEL_US_BRGR, cd); in atmel_config_iso7816()
423 atmel_uart_writel(port, ATMEL_US_FIDI, fidi); in atmel_config_iso7816()
425 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXEN); in atmel_config_iso7816()
428 dev_dbg(port->dev, "Setting UART back to RS232\n"); in atmel_config_iso7816()
432 atmel_uart_writel(port, ATMEL_US_TTGR, 0); in atmel_config_iso7816()
433 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->backup_brgr); in atmel_config_iso7816()
434 atmel_uart_writel(port, ATMEL_US_FIDI, 0x174); in atmel_config_iso7816()
436 if (atmel_use_pdc_tx(port)) in atmel_config_iso7816()
443 port->iso7816 = *iso7816conf; in atmel_config_iso7816()
445 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_config_iso7816()
449 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_iso7816()
457 static u_int atmel_tx_empty(struct uart_port *port) in atmel_tx_empty() argument
459 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_empty()
463 return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ? in atmel_tx_empty()
471 static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) in atmel_set_mctrl() argument
474 unsigned int mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_set_mctrl()
476 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_mctrl()
479 if (port->rs485.flags & SER_RS485_ENABLED) { in atmel_set_mctrl()
480 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_set_mctrl()
481 port->rs485.delay_rts_after_send); in atmel_set_mctrl()
511 atmel_uart_writel(port, ATMEL_US_CR, control); in atmel_set_mctrl()
522 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_set_mctrl()
528 static u_int atmel_get_mctrl(struct uart_port *port) in atmel_get_mctrl() argument
530 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_mctrl()
533 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_get_mctrl()
553 static void atmel_stop_tx(struct uart_port *port) in atmel_stop_tx() argument
555 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_stop_tx()
556 bool is_pdc = atmel_use_pdc_tx(port); in atmel_stop_tx()
557 bool is_dma = is_pdc || atmel_use_dma_tx(port); in atmel_stop_tx()
561 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_stop_tx()
570 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS); in atmel_stop_tx()
575 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_stop_tx()
577 if (atmel_uart_is_half_duplex(port)) in atmel_stop_tx()
579 atmel_start_rx(port); in atmel_stop_tx()
585 static void atmel_start_tx(struct uart_port *port) in atmel_start_tx() argument
587 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_start_tx()
588 bool is_pdc = atmel_use_pdc_tx(port); in atmel_start_tx()
589 bool is_dma = is_pdc || atmel_use_dma_tx(port); in atmel_start_tx()
591 if (is_pdc && (atmel_uart_readl(port, ATMEL_PDC_PTSR) in atmel_start_tx()
597 if (is_dma && atmel_uart_is_half_duplex(port)) in atmel_start_tx()
598 atmel_stop_rx(port); in atmel_start_tx()
602 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_start_tx()
606 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_start_tx()
610 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); in atmel_start_tx()
618 static void atmel_start_rx(struct uart_port *port) in atmel_start_rx() argument
621 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_start_rx()
623 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RXEN); in atmel_start_rx()
625 if (atmel_use_pdc_rx(port)) { in atmel_start_rx()
627 atmel_uart_writel(port, ATMEL_US_IER, in atmel_start_rx()
629 port->read_status_mask); in atmel_start_rx()
630 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN); in atmel_start_rx()
632 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_RXRDY); in atmel_start_rx()
639 static void atmel_stop_rx(struct uart_port *port) in atmel_stop_rx() argument
641 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RXDIS); in atmel_stop_rx()
643 if (atmel_use_pdc_rx(port)) { in atmel_stop_rx()
645 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTDIS); in atmel_stop_rx()
646 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_stop_rx()
648 port->read_status_mask); in atmel_stop_rx()
650 atmel_uart_writel(port, ATMEL_US_IDR, ATMEL_US_RXRDY); in atmel_stop_rx()
657 static void atmel_enable_ms(struct uart_port *port) in atmel_enable_ms() argument
659 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_enable_ms()
682 atmel_uart_writel(port, ATMEL_US_IER, ier); in atmel_enable_ms()
690 static void atmel_disable_ms(struct uart_port *port) in atmel_disable_ms() argument
692 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_disable_ms()
717 atmel_uart_writel(port, ATMEL_US_IDR, idr); in atmel_disable_ms()
723 static void atmel_break_ctl(struct uart_port *port, int break_state) in atmel_break_ctl() argument
727 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTBRK); in atmel_break_ctl()
730 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STPBRK); in atmel_break_ctl()
737 atmel_buffer_rx_char(struct uart_port *port, unsigned int status, in atmel_buffer_rx_char() argument
740 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_buffer_rx_char()
761 static void atmel_pdc_rxerr(struct uart_port *port, unsigned int status) in atmel_pdc_rxerr() argument
764 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_pdc_rxerr()
769 port->icount.brk++; in atmel_pdc_rxerr()
772 port->icount.parity++; in atmel_pdc_rxerr()
774 port->icount.frame++; in atmel_pdc_rxerr()
776 port->icount.overrun++; in atmel_pdc_rxerr()
782 static void atmel_rx_chars(struct uart_port *port) in atmel_rx_chars() argument
784 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_chars()
787 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_rx_chars()
789 ch = atmel_uart_read_char(port); in atmel_rx_chars()
800 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_rx_chars()
805 atmel_uart_writel(port, ATMEL_US_IER, in atmel_rx_chars()
815 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_rx_chars()
822 atmel_buffer_rx_char(port, status, ch); in atmel_rx_chars()
823 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_rx_chars()
833 static void atmel_tx_chars(struct uart_port *port) in atmel_tx_chars() argument
835 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_chars()
839 pending = uart_port_tx(port, ch, in atmel_tx_chars()
840 atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY, in atmel_tx_chars()
841 atmel_uart_write_char(port, ch)); in atmel_tx_chars()
850 atmel_uart_writel(port, ATMEL_US_IER, in atmel_tx_chars()
853 if (atmel_uart_is_half_duplex(port)) in atmel_tx_chars()
861 struct uart_port *port = &atmel_port->uart; in atmel_complete_tx_dma() local
862 struct tty_port *tport = &port->state->port; in atmel_complete_tx_dma()
866 uart_port_lock_irqsave(port, &flags); in atmel_complete_tx_dma()
870 uart_xmit_advance(port, atmel_port->tx_len); in atmel_complete_tx_dma()
879 uart_write_wakeup(port); in atmel_complete_tx_dma()
888 else if (atmel_uart_is_half_duplex(port)) { in atmel_complete_tx_dma()
894 atmel_uart_writel(port, ATMEL_US_IER, in atmel_complete_tx_dma()
898 uart_port_unlock_irqrestore(port, flags); in atmel_complete_tx_dma()
901 static void atmel_release_tx_dma(struct uart_port *port) in atmel_release_tx_dma() argument
903 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_dma()
909 dma_unmap_single(port->dev, atmel_port->tx_phys, in atmel_release_tx_dma()
921 static void atmel_tx_dma(struct uart_port *port) in atmel_tx_dma() argument
923 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_dma()
924 struct tty_port *tport = &port->state->port; in atmel_tx_dma()
935 if (!kfifo_is_empty(&tport->xmit_fifo) && !uart_tx_stopped(port)) { in atmel_tx_dma()
988 dev_err(port->dev, "Failed to send via dma!\n"); in atmel_tx_dma()
992 dma_sync_single_for_device(port->dev, atmel_port->tx_phys, in atmel_tx_dma()
1000 dev_err(port->dev, "dma_submit_error %d\n", in atmel_tx_dma()
1009 uart_write_wakeup(port); in atmel_tx_dma()
1012 static int atmel_prepare_tx_dma(struct uart_port *port) in atmel_prepare_tx_dma() argument
1014 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_dma()
1015 struct tty_port *tport = &port->state->port; in atmel_prepare_tx_dma()
1016 struct device *mfd_dev = port->dev->parent; in atmel_prepare_tx_dma()
1031 dev_info(port->dev, "using %s for tx DMA transfers\n", in atmel_prepare_tx_dma()
1037 atmel_port->tx_phys = dma_map_single(port->dev, tport->xmit_buf, in atmel_prepare_tx_dma()
1040 if (dma_mapping_error(port->dev, atmel_port->tx_phys)) { 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 %lu@%p to %pad\n", __func__, in atmel_prepare_tx_dma()
1055 config.dst_addr = port->mapbase + ATMEL_US_THR; in atmel_prepare_tx_dma()
1061 dev_err(port->dev, "DMA tx slave configuration failed\n"); in atmel_prepare_tx_dma()
1068 dev_err(port->dev, "TX channel not available, switch to pio\n"); in atmel_prepare_tx_dma()
1071 atmel_release_tx_dma(port); in atmel_prepare_tx_dma()
1077 struct uart_port *port = arg; in atmel_complete_rx_dma() local
1078 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_complete_rx_dma()
1083 static void atmel_release_rx_dma(struct uart_port *port) in atmel_release_rx_dma() argument
1085 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_dma()
1091 dma_unmap_single(port->dev, atmel_port->rx_phys, in atmel_release_rx_dma()
1100 static void atmel_rx_from_dma(struct uart_port *port) in atmel_rx_from_dma() argument
1102 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_dma()
1103 struct tty_port *tport = &port->state->port; in atmel_rx_from_dma()
1112 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_rx_from_dma()
1118 dev_dbg(port->dev, "Get residue error, restart tasklet\n"); in atmel_rx_from_dma()
1119 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_TIMEOUT); in atmel_rx_from_dma()
1125 dma_sync_single_for_cpu(port->dev, atmel_port->rx_phys, in atmel_rx_from_dma()
1154 port->icount.rx += count; in atmel_rx_from_dma()
1166 port->icount.rx += count; in atmel_rx_from_dma()
1170 dma_sync_single_for_device(port->dev, atmel_port->rx_phys, in atmel_rx_from_dma()
1175 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_TIMEOUT); in atmel_rx_from_dma()
1178 static int atmel_prepare_rx_dma(struct uart_port *port) in atmel_prepare_rx_dma() argument
1180 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_dma()
1181 struct device *mfd_dev = port->dev->parent; in atmel_prepare_rx_dma()
1200 dev_info(port->dev, "using %s for rx DMA transfers\n", in atmel_prepare_rx_dma()
1206 atmel_port->rx_phys = dma_map_single(port->dev, ring->buf, in atmel_prepare_rx_dma()
1210 if (dma_mapping_error(port->dev, atmel_port->rx_phys)) { in atmel_prepare_rx_dma()
1211 dev_dbg(port->dev, "need to release resource of dma\n"); in atmel_prepare_rx_dma()
1214 dev_dbg(port->dev, "%s: mapped %zu@%p to %pad\n", __func__, in atmel_prepare_rx_dma()
1222 config.src_addr = port->mapbase + ATMEL_US_RHR; in atmel_prepare_rx_dma()
1228 dev_err(port->dev, "DMA rx slave configuration failed\n"); in atmel_prepare_rx_dma()
1242 dev_err(port->dev, "Preparing DMA cyclic failed\n"); in atmel_prepare_rx_dma()
1246 desc->callback_param = port; in atmel_prepare_rx_dma()
1250 dev_err(port->dev, "dma_submit_error %d\n", in atmel_prepare_rx_dma()
1260 dev_err(port->dev, "RX channel not available, switch to pio\n"); in atmel_prepare_rx_dma()
1263 atmel_release_rx_dma(port); in atmel_prepare_rx_dma()
1271 struct uart_port *port = &atmel_port->uart; in atmel_uart_timer_callback() local
1276 jiffies + uart_poll_timeout(port)); in atmel_uart_timer_callback()
1284 atmel_handle_receive(struct uart_port *port, unsigned int pending) in atmel_handle_receive() argument
1286 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_receive()
1288 if (atmel_use_pdc_rx(port)) { in atmel_handle_receive()
1297 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_receive()
1305 atmel_pdc_rxerr(port, pending); in atmel_handle_receive()
1308 if (atmel_use_dma_rx(port)) { in atmel_handle_receive()
1310 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_receive()
1319 atmel_rx_chars(port); in atmel_handle_receive()
1325 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_handle_receive()
1326 atmel_uart_writel(port, ATMEL_US_IDR, ATMEL_US_RXBRK); in atmel_handle_receive()
1335 atmel_handle_transmit(struct uart_port *port, unsigned int pending) in atmel_handle_transmit() argument
1337 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_transmit()
1340 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_transmit()
1345 if (!(atmel_uart_readl(port, ATMEL_US_CSR) in atmel_handle_transmit()
1347 dev_warn(port->dev, "Should start RX, but TX fifo is not empty\n"); in atmel_handle_transmit()
1350 atmel_start_rx(port); in atmel_handle_transmit()
1361 atmel_handle_status(struct uart_port *port, unsigned int pending, in atmel_handle_status() argument
1364 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_status()
1376 port->icount.rng++; in atmel_handle_status()
1378 port->icount.dsr++; in atmel_handle_status()
1380 uart_handle_dcd_change(port, !(status & ATMEL_US_DCD)); in atmel_handle_status()
1382 uart_handle_cts_change(port, !(status & ATMEL_US_CTS)); in atmel_handle_status()
1384 wake_up_interruptible(&port->state->port.delta_msr_wait); in atmel_handle_status()
1389 dev_dbg(port->dev, "ISO7816 ERROR (0x%08x)\n", pending); in atmel_handle_status()
1397 struct uart_port *port = dev_id; in atmel_interrupt() local
1398 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_interrupt()
1404 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_interrupt()
1405 mask = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_interrupt()
1413 atmel_uart_writel(port, ATMEL_US_IDR, mask); in atmel_interrupt()
1418 atmel_handle_receive(port, pending); in atmel_interrupt()
1419 atmel_handle_status(port, pending, status); in atmel_interrupt()
1420 atmel_handle_transmit(port, pending); in atmel_interrupt()
1428 static void atmel_release_tx_pdc(struct uart_port *port) in atmel_release_tx_pdc() argument
1430 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_pdc()
1433 dma_unmap_single(port->dev, in atmel_release_tx_pdc()
1442 static void atmel_tx_pdc(struct uart_port *port) in atmel_tx_pdc() argument
1444 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_pdc()
1445 struct tty_port *tport = &port->state->port; in atmel_tx_pdc()
1449 if (atmel_uart_readl(port, ATMEL_PDC_TCR)) in atmel_tx_pdc()
1451 uart_xmit_advance(port, pdc->ofs); in atmel_tx_pdc()
1457 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_tx_pdc()
1459 if (!kfifo_is_empty(&tport->xmit_fifo) && !uart_tx_stopped(port)) { in atmel_tx_pdc()
1462 dma_sync_single_for_device(port->dev, in atmel_tx_pdc()
1471 atmel_uart_writel(port, ATMEL_PDC_TPR, pdc->dma_addr + tail); in atmel_tx_pdc()
1472 atmel_uart_writel(port, ATMEL_PDC_TCR, count); in atmel_tx_pdc()
1474 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_tx_pdc()
1476 atmel_uart_writel(port, ATMEL_US_IER, in atmel_tx_pdc()
1479 if (atmel_uart_is_half_duplex(port)) { in atmel_tx_pdc()
1481 atmel_start_rx(port); in atmel_tx_pdc()
1486 uart_write_wakeup(port); in atmel_tx_pdc()
1489 static int atmel_prepare_tx_pdc(struct uart_port *port) in atmel_prepare_tx_pdc() argument
1491 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_pdc()
1493 struct tty_port *tport = &port->state->port; in atmel_prepare_tx_pdc()
1496 pdc->dma_addr = dma_map_single(port->dev, in atmel_prepare_tx_pdc()
1506 static void atmel_rx_from_ring(struct uart_port *port) in atmel_rx_from_ring() argument
1508 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_ring()
1523 port->icount.rx++; in atmel_rx_from_ring()
1537 port->icount.brk++; in atmel_rx_from_ring()
1538 if (uart_handle_break(port)) in atmel_rx_from_ring()
1542 port->icount.parity++; in atmel_rx_from_ring()
1544 port->icount.frame++; in atmel_rx_from_ring()
1546 port->icount.overrun++; in atmel_rx_from_ring()
1548 status &= port->read_status_mask; in atmel_rx_from_ring()
1559 if (uart_handle_sysrq_char(port, c.ch)) in atmel_rx_from_ring()
1562 uart_insert_char(port, status, ATMEL_US_OVRE, c.ch, flg); in atmel_rx_from_ring()
1565 tty_flip_buffer_push(&port->state->port); in atmel_rx_from_ring()
1568 static void atmel_release_rx_pdc(struct uart_port *port) in atmel_release_rx_pdc() argument
1570 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_pdc()
1576 dma_unmap_single(port->dev, in atmel_release_rx_pdc()
1584 static void atmel_rx_from_pdc(struct uart_port *port) in atmel_rx_from_pdc() argument
1586 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_pdc()
1587 struct tty_port *tport = &port->state->port; in atmel_rx_from_pdc()
1596 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_rx_from_pdc()
1599 head = atmel_uart_readl(port, ATMEL_PDC_RPR) - pdc->dma_addr; in atmel_rx_from_pdc()
1615 dma_sync_single_for_cpu(port->dev, pdc->dma_addr, in atmel_rx_from_pdc()
1629 dma_sync_single_for_device(port->dev, pdc->dma_addr, in atmel_rx_from_pdc()
1632 port->icount.rx += count; in atmel_rx_from_pdc()
1642 atmel_uart_writel(port, ATMEL_PDC_RNPR, pdc->dma_addr); in atmel_rx_from_pdc()
1643 atmel_uart_writel(port, ATMEL_PDC_RNCR, pdc->dma_size); in atmel_rx_from_pdc()
1652 atmel_uart_writel(port, ATMEL_US_IER, in atmel_rx_from_pdc()
1656 static int atmel_prepare_rx_pdc(struct uart_port *port) in atmel_prepare_rx_pdc() argument
1658 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_pdc()
1667 dma_unmap_single(port->dev, in atmel_prepare_rx_pdc()
1676 pdc->dma_addr = dma_map_single(port->dev, in atmel_prepare_rx_pdc()
1686 atmel_uart_writel(port, ATMEL_PDC_RPR, atmel_port->pdc_rx[0].dma_addr); in atmel_prepare_rx_pdc()
1687 atmel_uart_writel(port, ATMEL_PDC_RCR, PDC_BUFFER_SIZE); in atmel_prepare_rx_pdc()
1689 atmel_uart_writel(port, ATMEL_PDC_RNPR, in atmel_prepare_rx_pdc()
1691 atmel_uart_writel(port, ATMEL_PDC_RNCR, PDC_BUFFER_SIZE); in atmel_prepare_rx_pdc()
1703 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_rx_func() local
1706 uart_port_lock(port); in atmel_tasklet_rx_func()
1707 atmel_port->schedule_rx(port); in atmel_tasklet_rx_func()
1708 uart_port_unlock(port); in atmel_tasklet_rx_func()
1715 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_tx_func() local
1718 uart_port_lock(port); in atmel_tasklet_tx_func()
1719 atmel_port->schedule_tx(port); in atmel_tasklet_tx_func()
1720 uart_port_unlock(port); in atmel_tasklet_tx_func()
1756 static void atmel_set_ops(struct uart_port *port) in atmel_set_ops() argument
1758 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_ops()
1760 if (atmel_use_dma_rx(port)) { in atmel_set_ops()
1764 } else if (atmel_use_pdc_rx(port)) { in atmel_set_ops()
1774 if (atmel_use_dma_tx(port)) { in atmel_set_ops()
1778 } else if (atmel_use_pdc_tx(port)) { in atmel_set_ops()
1792 static void atmel_get_ip_name(struct uart_port *port) in atmel_get_ip_name() argument
1794 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_ip_name()
1795 int name = atmel_uart_readl(port, ATMEL_US_NAME); in atmel_get_ip_name()
1814 dev_dbg(port->dev, "Uart with hw timer"); in atmel_get_ip_name()
1818 dev_dbg(port->dev, "Usart\n"); in atmel_get_ip_name()
1823 version = atmel_uart_readl(port, ATMEL_US_VERSION); in atmel_get_ip_name()
1840 dev_dbg(port->dev, "Dbgu or uart without hw timer\n"); in atmel_get_ip_name()
1843 version = atmel_uart_readl(port, ATMEL_US_VERSION); in atmel_get_ip_name()
1848 dev_dbg(port->dev, "This version is usart\n"); in atmel_get_ip_name()
1856 dev_dbg(port->dev, "This version is uart\n"); in atmel_get_ip_name()
1859 dev_err(port->dev, "Not supported ip name nor version, set to uart\n"); in atmel_get_ip_name()
1867 static int atmel_startup(struct uart_port *port) in atmel_startup() argument
1869 struct platform_device *pdev = to_platform_device(port->dev); in atmel_startup()
1870 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_startup()
1878 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_startup()
1884 retval = request_irq(port->irq, atmel_interrupt, in atmel_startup()
1886 dev_name(&pdev->dev), port); in atmel_startup()
1888 dev_err(port->dev, "atmel_startup - Can't get irq\n"); in atmel_startup()
1900 atmel_set_ops(port); in atmel_startup()
1903 retval = atmel_port->prepare_rx(port); in atmel_startup()
1905 atmel_set_ops(port); in atmel_startup()
1909 retval = atmel_port->prepare_tx(port); in atmel_startup()
1911 atmel_set_ops(port); in atmel_startup()
1922 atmel_uart_writel(port, ATMEL_US_CR, in atmel_startup()
1927 if (atmel_use_dma_tx(port)) in atmel_startup()
1937 atmel_uart_writel(port, ATMEL_US_FMR, fmr); in atmel_startup()
1941 atmel_port->irq_status_prev = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_startup()
1946 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_startup()
1948 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_startup()
1953 if (atmel_use_pdc_rx(port)) { in atmel_startup()
1957 jiffies + uart_poll_timeout(port)); in atmel_startup()
1960 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1962 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_startup()
1964 atmel_uart_writel(port, ATMEL_US_IER, in atmel_startup()
1968 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN); in atmel_startup()
1969 } else if (atmel_use_dma_rx(port)) { in atmel_startup()
1973 jiffies + uart_poll_timeout(port)); in atmel_startup()
1976 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1978 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_startup()
1980 atmel_uart_writel(port, ATMEL_US_IER, in atmel_startup()
1985 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_RXRDY); in atmel_startup()
1995 static void atmel_flush_buffer(struct uart_port *port) in atmel_flush_buffer() argument
1997 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_flush_buffer()
1999 if (atmel_use_pdc_tx(port)) { in atmel_flush_buffer()
2000 atmel_uart_writel(port, ATMEL_PDC_TCR, 0); in atmel_flush_buffer()
2013 static void atmel_shutdown(struct uart_port *port) in atmel_shutdown() argument
2015 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_shutdown()
2018 atmel_disable_ms(port); in atmel_shutdown()
2021 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_shutdown()
2033 synchronize_irq(port->irq); in atmel_shutdown()
2046 atmel_stop_rx(port); in atmel_shutdown()
2047 atmel_stop_tx(port); in atmel_shutdown()
2049 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_shutdown()
2055 atmel_port->release_rx(port); in atmel_shutdown()
2057 atmel_port->release_tx(port); in atmel_shutdown()
2068 free_irq(port->irq, port); in atmel_shutdown()
2070 atmel_flush_buffer(port); in atmel_shutdown()
2076 static void atmel_serial_pm(struct uart_port *port, unsigned int state, in atmel_serial_pm() argument
2079 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_pm()
2090 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->backup_imr); in atmel_serial_pm()
2094 atmel_port->backup_imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_serial_pm()
2095 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_serial_pm()
2106 dev_err(port->dev, "atmel_serial: unknown pm %d\n", state); in atmel_serial_pm()
2113 static void atmel_set_termios(struct uart_port *port, in atmel_set_termios() argument
2117 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_termios()
2124 mode = old_mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_set_termios()
2133 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); in atmel_set_termios()
2170 uart_port_lock_irqsave(port, &flags); in atmel_set_termios()
2172 port->read_status_mask = ATMEL_US_OVRE; in atmel_set_termios()
2174 port->read_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE); in atmel_set_termios()
2176 port->read_status_mask |= ATMEL_US_RXBRK; in atmel_set_termios()
2178 if (atmel_use_pdc_rx(port)) in atmel_set_termios()
2180 atmel_uart_writel(port, ATMEL_US_IER, port->read_status_mask); in atmel_set_termios()
2185 port->ignore_status_mask = 0; in atmel_set_termios()
2187 port->ignore_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE); in atmel_set_termios()
2189 port->ignore_status_mask |= ATMEL_US_RXBRK; in atmel_set_termios()
2195 port->ignore_status_mask |= ATMEL_US_OVRE; in atmel_set_termios()
2200 uart_update_timeout(port, termios->c_cflag, baud); in atmel_set_termios()
2207 imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_set_termios()
2208 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_set_termios()
2211 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS); in atmel_set_termios()
2215 if (port->rs485.flags & SER_RS485_ENABLED) { in atmel_set_termios()
2216 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_set_termios()
2217 port->rs485.delay_rts_after_send); in atmel_set_termios()
2219 } else if (port->iso7816.flags & SER_ISO7816_ENABLED) { in atmel_set_termios()
2220 atmel_uart_writel(port, ATMEL_US_TTGR, port->iso7816.tg); in atmel_set_termios()
2225 if ((port->iso7816.flags & SER_ISO7816_T_PARAM) in atmel_set_termios()
2232 if (atmel_use_fifo(port) && in atmel_set_termios()
2272 div = DIV_ROUND_CLOSEST(port->uartclk, baud * 2); in atmel_set_termios()
2276 cd = uart_get_divisor(port, baud); in atmel_set_termios()
2335 if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) in atmel_set_termios()
2336 atmel_uart_writel(port, ATMEL_US_BRGR, quot); in atmel_set_termios()
2339 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_set_termios()
2356 atmel_uart_writel(port, ATMEL_US_CR, rts_state); in atmel_set_termios()
2359 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_set_termios()
2360 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_set_termios()
2364 atmel_uart_writel(port, ATMEL_US_IER, imr); in atmel_set_termios()
2367 if (UART_ENABLE_MS(port, termios->c_cflag)) in atmel_set_termios()
2368 atmel_enable_ms(port); in atmel_set_termios()
2370 atmel_disable_ms(port); in atmel_set_termios()
2372 uart_port_unlock_irqrestore(port, flags); in atmel_set_termios()
2375 static void atmel_set_ldisc(struct uart_port *port, struct ktermios *termios) in atmel_set_ldisc() argument
2378 port->flags |= UPF_HARDPPS_CD; in atmel_set_ldisc()
2379 uart_port_lock_irq(port); in atmel_set_ldisc()
2380 atmel_enable_ms(port); in atmel_set_ldisc()
2381 uart_port_unlock_irq(port); in atmel_set_ldisc()
2383 port->flags &= ~UPF_HARDPPS_CD; in atmel_set_ldisc()
2384 if (!UART_ENABLE_MS(port, termios->c_cflag)) { in atmel_set_ldisc()
2385 uart_port_lock_irq(port); in atmel_set_ldisc()
2386 atmel_disable_ms(port); in atmel_set_ldisc()
2387 uart_port_unlock_irq(port); in atmel_set_ldisc()
2395 static const char *atmel_type(struct uart_port *port) in atmel_type() argument
2397 return (port->type == PORT_ATMEL) ? "ATMEL_SERIAL" : NULL; in atmel_type()
2403 static void atmel_release_port(struct uart_port *port) in atmel_release_port() argument
2405 struct platform_device *mpdev = to_platform_device(port->dev->parent); in atmel_release_port()
2408 release_mem_region(port->mapbase, size); in atmel_release_port()
2410 if (port->flags & UPF_IOREMAP) { in atmel_release_port()
2411 iounmap(port->membase); in atmel_release_port()
2412 port->membase = NULL; in atmel_release_port()
2419 static int atmel_request_port(struct uart_port *port) in atmel_request_port() argument
2421 struct platform_device *mpdev = to_platform_device(port->dev->parent); in atmel_request_port()
2424 if (!request_mem_region(port->mapbase, size, "atmel_serial")) in atmel_request_port()
2427 if (port->flags & UPF_IOREMAP) { in atmel_request_port()
2428 port->membase = ioremap(port->mapbase, size); in atmel_request_port()
2429 if (port->membase == NULL) { in atmel_request_port()
2430 release_mem_region(port->mapbase, size); in atmel_request_port()
2441 static void atmel_config_port(struct uart_port *port, int flags) in atmel_config_port() argument
2444 port->type = PORT_ATMEL; in atmel_config_port()
2445 atmel_request_port(port); in atmel_config_port()
2452 static int atmel_verify_port(struct uart_port *port, struct serial_struct *ser) in atmel_verify_port() argument
2457 if (port->irq != ser->irq) in atmel_verify_port()
2461 if (port->uartclk / 16 != ser->baud_base) in atmel_verify_port()
2463 if (port->mapbase != (unsigned long)ser->iomem_base) in atmel_verify_port()
2465 if (port->iobase != ser->port) in atmel_verify_port()
2473 static int atmel_poll_get_char(struct uart_port *port) in atmel_poll_get_char() argument
2475 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_RXRDY)) in atmel_poll_get_char()
2478 return atmel_uart_read_char(port); in atmel_poll_get_char()
2481 static void atmel_poll_put_char(struct uart_port *port, unsigned char ch) in atmel_poll_put_char() argument
2483 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) in atmel_poll_put_char()
2486 atmel_uart_write_char(port, ch); in atmel_poll_put_char()
2529 struct uart_port *port = &atmel_port->uart; in atmel_init_port() local
2533 atmel_set_ops(port); in atmel_init_port()
2535 port->iotype = UPIO_MEM; in atmel_init_port()
2536 port->flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP; in atmel_init_port()
2537 port->ops = &atmel_pops; in atmel_init_port()
2538 port->fifosize = 1; in atmel_init_port()
2539 port->dev = &pdev->dev; in atmel_init_port()
2540 port->mapbase = mpdev->resource[0].start; in atmel_init_port()
2541 port->irq = platform_get_irq(mpdev, 0); in atmel_init_port()
2542 port->rs485_config = atmel_config_rs485; in atmel_init_port()
2543 port->rs485_supported = atmel_rs485_supported; in atmel_init_port()
2544 port->iso7816_config = atmel_config_iso7816; in atmel_init_port()
2545 port->membase = NULL; in atmel_init_port()
2549 ret = uart_get_rs485_mode(port); in atmel_init_port()
2553 port->uartclk = clk_get_rate(atmel_port->clk); in atmel_init_port()
2559 if (atmel_uart_is_half_duplex(port)) in atmel_init_port()
2561 else if (atmel_use_pdc_tx(port)) { in atmel_init_port()
2562 port->fifosize = PDC_BUFFER_SIZE; in atmel_init_port()
2572 static void atmel_console_putchar(struct uart_port *port, unsigned char ch) in atmel_console_putchar() argument
2574 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) in atmel_console_putchar()
2576 atmel_uart_write_char(port, ch); in atmel_console_putchar()
2584 struct uart_port *port = &atmel_ports[co->index].uart; in atmel_console_write() local
2585 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_write()
2592 imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_console_write()
2593 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_console_write()
2597 pdc_tx = atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN; in atmel_console_write()
2598 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_console_write()
2601 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); in atmel_console_write()
2604 uart_console_write(port, s, count, atmel_console_putchar); in atmel_console_write()
2611 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_console_write()
2616 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_console_write()
2619 atmel_uart_writel(port, ATMEL_US_IER, imr); in atmel_console_write()
2626 static void __init atmel_console_get_options(struct uart_port *port, int *baud, in atmel_console_get_options() argument
2635 quot = atmel_uart_readl(port, ATMEL_US_BRGR) & ATMEL_US_CD; in atmel_console_get_options()
2639 mr = atmel_uart_readl(port, ATMEL_US_MR) & ATMEL_US_CHRL; in atmel_console_get_options()
2645 mr = atmel_uart_readl(port, ATMEL_US_MR) & ATMEL_US_PAR; in atmel_console_get_options()
2651 *baud = port->uartclk / (16 * quot); in atmel_console_get_options()
2656 struct uart_port *port = &atmel_ports[co->index].uart; in atmel_console_setup() local
2657 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_setup()
2663 if (port->membase == NULL) { in atmel_console_setup()
2668 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_console_setup()
2669 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_console_setup()
2670 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_console_setup()
2676 atmel_console_get_options(port, &baud, &parity, &bits); in atmel_console_setup()
2678 return uart_set_options(port, co, baud, parity, bits, flow); in atmel_console_setup()
2698 uart_console_write(&dev->port, s, n, atmel_console_putchar); in atmel_serial_early_write()
2704 if (!device->port.membase) in atmel_early_console_setup()
2744 struct uart_port *port = dev_get_drvdata(dev); in atmel_serial_suspend() local
2745 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_suspend()
2747 if (uart_console(port) && console_suspend_enabled) { in atmel_serial_suspend()
2749 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & in atmel_serial_suspend()
2754 if (uart_console(port) && !console_suspend_enabled) { in atmel_serial_suspend()
2758 atmel_port->cache.mr = atmel_uart_readl(port, ATMEL_US_MR); in atmel_serial_suspend()
2759 atmel_port->cache.imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_serial_suspend()
2760 atmel_port->cache.brgr = atmel_uart_readl(port, ATMEL_US_BRGR); in atmel_serial_suspend()
2761 atmel_port->cache.rtor = atmel_uart_readl(port, in atmel_serial_suspend()
2763 atmel_port->cache.ttgr = atmel_uart_readl(port, ATMEL_US_TTGR); in atmel_serial_suspend()
2764 atmel_port->cache.fmr = atmel_uart_readl(port, ATMEL_US_FMR); in atmel_serial_suspend()
2765 atmel_port->cache.fimr = atmel_uart_readl(port, ATMEL_US_FIMR); in atmel_serial_suspend()
2779 uart_suspend_port(&atmel_uart, port); in atmel_serial_suspend()
2786 struct uart_port *port = dev_get_drvdata(dev); in atmel_serial_resume() local
2787 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_resume()
2790 if (uart_console(port) && !console_suspend_enabled) { in atmel_serial_resume()
2791 atmel_uart_writel(port, ATMEL_US_MR, atmel_port->cache.mr); in atmel_serial_resume()
2792 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->cache.imr); in atmel_serial_resume()
2793 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->cache.brgr); in atmel_serial_resume()
2794 atmel_uart_writel(port, atmel_port->rtor, in atmel_serial_resume()
2796 atmel_uart_writel(port, ATMEL_US_TTGR, atmel_port->cache.ttgr); in atmel_serial_resume()
2799 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_FIFOEN | in atmel_serial_resume()
2801 atmel_uart_writel(port, ATMEL_US_FMR, in atmel_serial_resume()
2803 atmel_uart_writel(port, ATMEL_US_FIER, in atmel_serial_resume()
2806 atmel_start_rx(port); in atmel_serial_resume()
2811 atmel_handle_receive(port, atmel_port->pending); in atmel_serial_resume()
2812 atmel_handle_status(port, atmel_port->pending, in atmel_serial_resume()
2814 atmel_handle_transmit(port, atmel_port->pending); in atmel_serial_resume()
2820 uart_resume_port(&atmel_uart, port); in atmel_serial_resume()
2996 struct uart_port *port = platform_get_drvdata(pdev); in atmel_serial_remove() local
2997 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_remove()
3004 uart_remove_one_port(&atmel_uart, port); in atmel_serial_remove()
3010 clear_bit(port->line, atmel_ports_in_use); in atmel_serial_remove()