• Home
  • Raw
  • Download

Lines Matching refs:port

56 static void atmel_start_rx(struct uart_port *port);
57 static void atmel_stop_rx(struct uart_port *port);
181 int (*prepare_rx)(struct uart_port *port);
182 int (*prepare_tx)(struct uart_port *port);
183 void (*schedule_rx)(struct uart_port *port);
184 void (*schedule_tx)(struct uart_port *port);
185 void (*release_rx)(struct uart_port *port);
186 void (*release_tx)(struct uart_port *port);
205 static inline u32 atmel_uart_readl(struct uart_port *port, u32 reg) in atmel_uart_readl() argument
207 return __raw_readl(port->membase + reg); in atmel_uart_readl()
210 static inline void atmel_uart_writel(struct uart_port *port, u32 reg, u32 value) in atmel_uart_writel() argument
212 __raw_writel(value, port->membase + reg); in atmel_uart_writel()
215 static inline u8 atmel_uart_read_char(struct uart_port *port) in atmel_uart_read_char() argument
217 return __raw_readb(port->membase + ATMEL_US_RHR); in atmel_uart_read_char()
220 static inline void atmel_uart_write_char(struct uart_port *port, u8 value) in atmel_uart_write_char() argument
222 __raw_writeb(value, port->membase + ATMEL_US_THR); in atmel_uart_write_char()
225 static inline int atmel_uart_is_half_duplex(struct uart_port *port) in atmel_uart_is_half_duplex() argument
227 return ((port->rs485.flags & SER_RS485_ENABLED) && in atmel_uart_is_half_duplex()
228 !(port->rs485.flags & SER_RS485_RX_DURING_TX)) || in atmel_uart_is_half_duplex()
229 (port->iso7816.flags & SER_ISO7816_ENABLED); in atmel_uart_is_half_duplex()
233 static bool atmel_use_pdc_rx(struct uart_port *port) in atmel_use_pdc_rx() argument
235 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_rx()
240 static bool atmel_use_pdc_tx(struct uart_port *port) in atmel_use_pdc_tx() argument
242 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_tx()
247 static bool atmel_use_pdc_rx(struct uart_port *port) in atmel_use_pdc_rx() argument
252 static bool atmel_use_pdc_tx(struct uart_port *port) in atmel_use_pdc_tx() argument
258 static bool atmel_use_dma_tx(struct uart_port *port) in atmel_use_dma_tx() argument
260 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_tx()
265 static bool atmel_use_dma_rx(struct uart_port *port) in atmel_use_dma_rx() argument
267 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_rx()
272 static bool atmel_use_fifo(struct uart_port *port) in atmel_use_fifo() argument
274 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_fifo()
287 static int atmel_config_rs485(struct uart_port *port, in atmel_config_rs485() argument
290 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_rs485()
294 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_rs485()
296 mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_rs485()
299 dev_dbg(port->dev, "Setting UART to RS485\n"); in atmel_config_rs485()
305 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_config_rs485()
310 dev_dbg(port->dev, "Setting UART to RS232\n"); in atmel_config_rs485()
311 if (atmel_use_pdc_tx(port)) in atmel_config_rs485()
317 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_config_rs485()
320 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_rs485()
325 static unsigned int atmel_calc_cd(struct uart_port *port, in atmel_calc_cd() argument
328 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_calc_cd()
338 static unsigned int atmel_calc_fidi(struct uart_port *port, in atmel_calc_fidi() argument
352 static int atmel_config_iso7816(struct uart_port *port, in atmel_config_iso7816() argument
355 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_iso7816()
361 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_iso7816()
363 mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_iso7816()
369 dev_err(port->dev, "ISO7816: Timeguard exceeding 255\n"); in atmel_config_iso7816()
382 dev_err(port->dev, "ISO7816: Type not supported\n"); in atmel_config_iso7816()
395 cd = atmel_calc_cd(port, iso7816conf); in atmel_config_iso7816()
396 fidi = atmel_calc_fidi(port, iso7816conf); in atmel_config_iso7816()
398 dev_warn(port->dev, "ISO7816 fidi = 0, Generator generates no signal\n"); in atmel_config_iso7816()
401 dev_err(port->dev, "ISO7816 fidi = %u, value not supported\n", fidi); in atmel_config_iso7816()
407 if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) { in atmel_config_iso7816()
409 atmel_port->backup_mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_config_iso7816()
410 atmel_port->backup_brgr = atmel_uart_readl(port, ATMEL_US_BRGR); in atmel_config_iso7816()
413 atmel_uart_writel(port, ATMEL_US_TTGR, iso7816conf->tg); in atmel_config_iso7816()
414 atmel_uart_writel(port, ATMEL_US_BRGR, cd); in atmel_config_iso7816()
415 atmel_uart_writel(port, ATMEL_US_FIDI, fidi); in atmel_config_iso7816()
417 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXEN); in atmel_config_iso7816()
420 dev_dbg(port->dev, "Setting UART back to RS232\n"); in atmel_config_iso7816()
424 atmel_uart_writel(port, ATMEL_US_TTGR, 0); in atmel_config_iso7816()
425 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->backup_brgr); in atmel_config_iso7816()
426 atmel_uart_writel(port, ATMEL_US_FIDI, 0x174); in atmel_config_iso7816()
428 if (atmel_use_pdc_tx(port)) in atmel_config_iso7816()
435 port->iso7816 = *iso7816conf; in atmel_config_iso7816()
437 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_config_iso7816()
441 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_iso7816()
449 static u_int atmel_tx_empty(struct uart_port *port) in atmel_tx_empty() argument
451 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_empty()
455 return (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXEMPTY) ? in atmel_tx_empty()
463 static void atmel_set_mctrl(struct uart_port *port, u_int mctrl) in atmel_set_mctrl() argument
466 unsigned int mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_set_mctrl()
468 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_mctrl()
471 if (port->rs485.flags & SER_RS485_ENABLED) { in atmel_set_mctrl()
472 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_set_mctrl()
473 port->rs485.delay_rts_after_send); in atmel_set_mctrl()
503 atmel_uart_writel(port, ATMEL_US_CR, control); in atmel_set_mctrl()
514 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_set_mctrl()
520 static u_int atmel_get_mctrl(struct uart_port *port) in atmel_get_mctrl() argument
522 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_mctrl()
525 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_get_mctrl()
545 static void atmel_stop_tx(struct uart_port *port) in atmel_stop_tx() argument
547 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_stop_tx()
549 if (atmel_use_pdc_tx(port)) { in atmel_stop_tx()
551 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_stop_tx()
559 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS); in atmel_stop_tx()
563 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_stop_tx()
565 if (atmel_uart_is_half_duplex(port)) in atmel_stop_tx()
567 atmel_start_rx(port); in atmel_stop_tx()
574 static void atmel_start_tx(struct uart_port *port) in atmel_start_tx() argument
576 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_start_tx()
578 if (atmel_use_pdc_tx(port) && (atmel_uart_readl(port, ATMEL_PDC_PTSR) in atmel_start_tx()
584 if (atmel_use_pdc_tx(port) || atmel_use_dma_tx(port)) in atmel_start_tx()
585 if (atmel_uart_is_half_duplex(port)) in atmel_start_tx()
586 atmel_stop_rx(port); in atmel_start_tx()
588 if (atmel_use_pdc_tx(port)) in atmel_start_tx()
590 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_start_tx()
593 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_start_tx()
596 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); in atmel_start_tx()
603 static void atmel_start_rx(struct uart_port *port) in atmel_start_rx() argument
606 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_start_rx()
608 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RXEN); in atmel_start_rx()
610 if (atmel_use_pdc_rx(port)) { in atmel_start_rx()
612 atmel_uart_writel(port, ATMEL_US_IER, in atmel_start_rx()
614 port->read_status_mask); in atmel_start_rx()
615 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN); in atmel_start_rx()
617 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_RXRDY); in atmel_start_rx()
624 static void atmel_stop_rx(struct uart_port *port) in atmel_stop_rx() argument
626 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RXDIS); in atmel_stop_rx()
628 if (atmel_use_pdc_rx(port)) { in atmel_stop_rx()
630 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTDIS); in atmel_stop_rx()
631 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_stop_rx()
633 port->read_status_mask); in atmel_stop_rx()
635 atmel_uart_writel(port, ATMEL_US_IDR, ATMEL_US_RXRDY); in atmel_stop_rx()
642 static void atmel_enable_ms(struct uart_port *port) in atmel_enable_ms() argument
644 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_enable_ms()
667 atmel_uart_writel(port, ATMEL_US_IER, ier); in atmel_enable_ms()
675 static void atmel_disable_ms(struct uart_port *port) in atmel_disable_ms() argument
677 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_disable_ms()
702 atmel_uart_writel(port, ATMEL_US_IDR, idr); in atmel_disable_ms()
708 static void atmel_break_ctl(struct uart_port *port, int break_state) in atmel_break_ctl() argument
712 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTBRK); in atmel_break_ctl()
715 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STPBRK); in atmel_break_ctl()
722 atmel_buffer_rx_char(struct uart_port *port, unsigned int status, in atmel_buffer_rx_char() argument
725 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_buffer_rx_char()
746 static void atmel_pdc_rxerr(struct uart_port *port, unsigned int status) in atmel_pdc_rxerr() argument
749 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_pdc_rxerr()
754 port->icount.brk++; in atmel_pdc_rxerr()
757 port->icount.parity++; in atmel_pdc_rxerr()
759 port->icount.frame++; in atmel_pdc_rxerr()
761 port->icount.overrun++; in atmel_pdc_rxerr()
767 static void atmel_rx_chars(struct uart_port *port) in atmel_rx_chars() argument
769 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_chars()
772 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_rx_chars()
774 ch = atmel_uart_read_char(port); in atmel_rx_chars()
785 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_rx_chars()
790 atmel_uart_writel(port, ATMEL_US_IER, in atmel_rx_chars()
800 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_rx_chars()
807 atmel_buffer_rx_char(port, status, ch); in atmel_rx_chars()
808 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_rx_chars()
818 static void atmel_tx_chars(struct uart_port *port) in atmel_tx_chars() argument
820 struct circ_buf *xmit = &port->state->xmit; in atmel_tx_chars()
821 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_chars()
823 if (port->x_char && in atmel_tx_chars()
824 (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) { in atmel_tx_chars()
825 atmel_uart_write_char(port, port->x_char); in atmel_tx_chars()
826 port->icount.tx++; in atmel_tx_chars()
827 port->x_char = 0; in atmel_tx_chars()
829 if (uart_circ_empty(xmit) || uart_tx_stopped(port)) in atmel_tx_chars()
832 while (atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY) { in atmel_tx_chars()
833 atmel_uart_write_char(port, xmit->buf[xmit->tail]); in atmel_tx_chars()
835 port->icount.tx++; in atmel_tx_chars()
841 uart_write_wakeup(port); in atmel_tx_chars()
851 atmel_uart_writel(port, ATMEL_US_IER, in atmel_tx_chars()
854 if (atmel_uart_is_half_duplex(port)) in atmel_tx_chars()
862 struct uart_port *port = &atmel_port->uart; in atmel_complete_tx_dma() local
863 struct circ_buf *xmit = &port->state->xmit; in atmel_complete_tx_dma()
867 spin_lock_irqsave(&port->lock, flags); in atmel_complete_tx_dma()
874 port->icount.tx += atmel_port->tx_len; in atmel_complete_tx_dma()
883 uart_write_wakeup(port); in atmel_complete_tx_dma()
892 else if (atmel_uart_is_half_duplex(port)) { in atmel_complete_tx_dma()
898 atmel_uart_writel(port, ATMEL_US_IER, in atmel_complete_tx_dma()
902 spin_unlock_irqrestore(&port->lock, flags); in atmel_complete_tx_dma()
905 static void atmel_release_tx_dma(struct uart_port *port) in atmel_release_tx_dma() argument
907 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_dma()
913 dma_unmap_sg(port->dev, &atmel_port->sg_tx, 1, in atmel_release_tx_dma()
925 static void atmel_tx_dma(struct uart_port *port) in atmel_tx_dma() argument
927 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_dma()
928 struct circ_buf *xmit = &port->state->xmit; in atmel_tx_dma()
939 if (!uart_circ_empty(xmit) && !uart_tx_stopped(port)) { in atmel_tx_dma()
993 dev_err(port->dev, "Failed to send via dma!\n"); in atmel_tx_dma()
997 dma_sync_sg_for_device(port->dev, sg_tx, 1, DMA_TO_DEVICE); in atmel_tx_dma()
1004 dev_err(port->dev, "dma_submit_error %d\n", in atmel_tx_dma()
1013 uart_write_wakeup(port); in atmel_tx_dma()
1016 static int atmel_prepare_tx_dma(struct uart_port *port) in atmel_prepare_tx_dma() argument
1018 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_dma()
1019 struct device *mfd_dev = port->dev->parent; in atmel_prepare_tx_dma()
1030 dev_info(port->dev, "using %s for tx DMA transfers\n", in atmel_prepare_tx_dma()
1036 BUG_ON(!PAGE_ALIGNED(port->state->xmit.buf)); in atmel_prepare_tx_dma()
1038 virt_to_page(port->state->xmit.buf), in atmel_prepare_tx_dma()
1040 offset_in_page(port->state->xmit.buf)); in atmel_prepare_tx_dma()
1041 nent = dma_map_sg(port->dev, in atmel_prepare_tx_dma()
1047 dev_dbg(port->dev, "need to release resource of dma\n"); in atmel_prepare_tx_dma()
1050 dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__, in atmel_prepare_tx_dma()
1052 port->state->xmit.buf, in atmel_prepare_tx_dma()
1062 config.dst_addr = port->mapbase + ATMEL_US_THR; in atmel_prepare_tx_dma()
1068 dev_err(port->dev, "DMA tx slave configuration failed\n"); in atmel_prepare_tx_dma()
1075 dev_err(port->dev, "TX channel not available, switch to pio\n"); in atmel_prepare_tx_dma()
1078 atmel_release_tx_dma(port); in atmel_prepare_tx_dma()
1084 struct uart_port *port = arg; in atmel_complete_rx_dma() local
1085 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_complete_rx_dma()
1090 static void atmel_release_rx_dma(struct uart_port *port) in atmel_release_rx_dma() argument
1092 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_dma()
1098 dma_unmap_sg(port->dev, &atmel_port->sg_rx, 1, in atmel_release_rx_dma()
1107 static void atmel_rx_from_dma(struct uart_port *port) in atmel_rx_from_dma() argument
1109 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_dma()
1110 struct tty_port *tport = &port->state->port; in atmel_rx_from_dma()
1119 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_rx_from_dma()
1125 dev_dbg(port->dev, "Get residue error, restart tasklet\n"); in atmel_rx_from_dma()
1126 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_TIMEOUT); in atmel_rx_from_dma()
1132 dma_sync_sg_for_cpu(port->dev, in atmel_rx_from_dma()
1163 port->icount.rx += count; in atmel_rx_from_dma()
1175 port->icount.rx += count; in atmel_rx_from_dma()
1179 dma_sync_sg_for_device(port->dev, in atmel_rx_from_dma()
1186 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_TIMEOUT); in atmel_rx_from_dma()
1189 static int atmel_prepare_rx_dma(struct uart_port *port) in atmel_prepare_rx_dma() argument
1191 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_dma()
1192 struct device *mfd_dev = port->dev->parent; in atmel_prepare_rx_dma()
1207 dev_info(port->dev, "using %s for rx DMA transfers\n", in atmel_prepare_rx_dma()
1218 nent = dma_map_sg(port->dev, in atmel_prepare_rx_dma()
1224 dev_dbg(port->dev, "need to release resource of dma\n"); in atmel_prepare_rx_dma()
1227 dev_dbg(port->dev, "%s: mapped %d@%p to %pad\n", __func__, in atmel_prepare_rx_dma()
1237 config.src_addr = port->mapbase + ATMEL_US_RHR; in atmel_prepare_rx_dma()
1243 dev_err(port->dev, "DMA rx slave configuration failed\n"); in atmel_prepare_rx_dma()
1257 dev_err(port->dev, "Preparing DMA cyclic failed\n"); in atmel_prepare_rx_dma()
1261 desc->callback_param = port; in atmel_prepare_rx_dma()
1265 dev_err(port->dev, "dma_submit_error %d\n", in atmel_prepare_rx_dma()
1275 dev_err(port->dev, "RX channel not available, switch to pio\n"); in atmel_prepare_rx_dma()
1278 atmel_release_rx_dma(port); in atmel_prepare_rx_dma()
1286 struct uart_port *port = &atmel_port->uart; in atmel_uart_timer_callback() local
1291 jiffies + uart_poll_timeout(port)); in atmel_uart_timer_callback()
1299 atmel_handle_receive(struct uart_port *port, unsigned int pending) in atmel_handle_receive() argument
1301 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_receive()
1303 if (atmel_use_pdc_rx(port)) { in atmel_handle_receive()
1312 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_receive()
1320 atmel_pdc_rxerr(port, pending); in atmel_handle_receive()
1323 if (atmel_use_dma_rx(port)) { in atmel_handle_receive()
1325 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_receive()
1334 atmel_rx_chars(port); in atmel_handle_receive()
1340 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_handle_receive()
1341 atmel_uart_writel(port, ATMEL_US_IDR, ATMEL_US_RXBRK); in atmel_handle_receive()
1350 atmel_handle_transmit(struct uart_port *port, unsigned int pending) in atmel_handle_transmit() argument
1352 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_transmit()
1355 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_handle_transmit()
1360 if (!(atmel_uart_readl(port, ATMEL_US_CSR) in atmel_handle_transmit()
1362 dev_warn(port->dev, "Should start RX, but TX fifo is not empty\n"); in atmel_handle_transmit()
1365 atmel_start_rx(port); in atmel_handle_transmit()
1376 atmel_handle_status(struct uart_port *port, unsigned int pending, in atmel_handle_status() argument
1379 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_status()
1391 port->icount.rng++; in atmel_handle_status()
1393 port->icount.dsr++; in atmel_handle_status()
1395 uart_handle_dcd_change(port, !(status & ATMEL_US_DCD)); in atmel_handle_status()
1397 uart_handle_cts_change(port, !(status & ATMEL_US_CTS)); in atmel_handle_status()
1399 wake_up_interruptible(&port->state->port.delta_msr_wait); in atmel_handle_status()
1404 dev_dbg(port->dev, "ISO7816 ERROR (0x%08x)\n", pending); in atmel_handle_status()
1412 struct uart_port *port = dev_id; in atmel_interrupt() local
1413 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_interrupt()
1419 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_interrupt()
1420 mask = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_interrupt()
1428 atmel_uart_writel(port, ATMEL_US_IDR, mask); in atmel_interrupt()
1433 atmel_handle_receive(port, pending); in atmel_interrupt()
1434 atmel_handle_status(port, pending, status); in atmel_interrupt()
1435 atmel_handle_transmit(port, pending); in atmel_interrupt()
1443 static void atmel_release_tx_pdc(struct uart_port *port) in atmel_release_tx_pdc() argument
1445 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_pdc()
1448 dma_unmap_single(port->dev, in atmel_release_tx_pdc()
1457 static void atmel_tx_pdc(struct uart_port *port) in atmel_tx_pdc() argument
1459 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_pdc()
1460 struct circ_buf *xmit = &port->state->xmit; in atmel_tx_pdc()
1465 if (atmel_uart_readl(port, ATMEL_PDC_TCR)) in atmel_tx_pdc()
1471 port->icount.tx += pdc->ofs; in atmel_tx_pdc()
1477 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_tx_pdc()
1479 if (!uart_circ_empty(xmit) && !uart_tx_stopped(port)) { in atmel_tx_pdc()
1480 dma_sync_single_for_device(port->dev, in atmel_tx_pdc()
1488 atmel_uart_writel(port, ATMEL_PDC_TPR, in atmel_tx_pdc()
1490 atmel_uart_writel(port, ATMEL_PDC_TCR, count); in atmel_tx_pdc()
1492 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_tx_pdc()
1494 atmel_uart_writel(port, ATMEL_US_IER, in atmel_tx_pdc()
1497 if (atmel_uart_is_half_duplex(port)) { in atmel_tx_pdc()
1499 atmel_start_rx(port); in atmel_tx_pdc()
1504 uart_write_wakeup(port); in atmel_tx_pdc()
1507 static int atmel_prepare_tx_pdc(struct uart_port *port) in atmel_prepare_tx_pdc() argument
1509 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_pdc()
1511 struct circ_buf *xmit = &port->state->xmit; in atmel_prepare_tx_pdc()
1514 pdc->dma_addr = dma_map_single(port->dev, in atmel_prepare_tx_pdc()
1524 static void atmel_rx_from_ring(struct uart_port *port) in atmel_rx_from_ring() argument
1526 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_ring()
1541 port->icount.rx++; in atmel_rx_from_ring()
1555 port->icount.brk++; in atmel_rx_from_ring()
1556 if (uart_handle_break(port)) in atmel_rx_from_ring()
1560 port->icount.parity++; in atmel_rx_from_ring()
1562 port->icount.frame++; in atmel_rx_from_ring()
1564 port->icount.overrun++; in atmel_rx_from_ring()
1566 status &= port->read_status_mask; in atmel_rx_from_ring()
1577 if (uart_handle_sysrq_char(port, c.ch)) in atmel_rx_from_ring()
1580 uart_insert_char(port, status, ATMEL_US_OVRE, c.ch, flg); in atmel_rx_from_ring()
1583 tty_flip_buffer_push(&port->state->port); in atmel_rx_from_ring()
1586 static void atmel_release_rx_pdc(struct uart_port *port) in atmel_release_rx_pdc() argument
1588 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_pdc()
1594 dma_unmap_single(port->dev, in atmel_release_rx_pdc()
1602 static void atmel_rx_from_pdc(struct uart_port *port) in atmel_rx_from_pdc() argument
1604 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_pdc()
1605 struct tty_port *tport = &port->state->port; in atmel_rx_from_pdc()
1614 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_rx_from_pdc()
1617 head = atmel_uart_readl(port, ATMEL_PDC_RPR) - pdc->dma_addr; in atmel_rx_from_pdc()
1633 dma_sync_single_for_cpu(port->dev, pdc->dma_addr, in atmel_rx_from_pdc()
1647 dma_sync_single_for_device(port->dev, pdc->dma_addr, in atmel_rx_from_pdc()
1650 port->icount.rx += count; in atmel_rx_from_pdc()
1660 atmel_uart_writel(port, ATMEL_PDC_RNPR, pdc->dma_addr); in atmel_rx_from_pdc()
1661 atmel_uart_writel(port, ATMEL_PDC_RNCR, pdc->dma_size); in atmel_rx_from_pdc()
1670 atmel_uart_writel(port, ATMEL_US_IER, in atmel_rx_from_pdc()
1674 static int atmel_prepare_rx_pdc(struct uart_port *port) in atmel_prepare_rx_pdc() argument
1676 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_pdc()
1685 dma_unmap_single(port->dev, in atmel_prepare_rx_pdc()
1694 pdc->dma_addr = dma_map_single(port->dev, in atmel_prepare_rx_pdc()
1704 atmel_uart_writel(port, ATMEL_PDC_RPR, atmel_port->pdc_rx[0].dma_addr); in atmel_prepare_rx_pdc()
1705 atmel_uart_writel(port, ATMEL_PDC_RCR, PDC_BUFFER_SIZE); in atmel_prepare_rx_pdc()
1707 atmel_uart_writel(port, ATMEL_PDC_RNPR, in atmel_prepare_rx_pdc()
1709 atmel_uart_writel(port, ATMEL_PDC_RNCR, PDC_BUFFER_SIZE); in atmel_prepare_rx_pdc()
1721 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_rx_func() local
1724 spin_lock(&port->lock); in atmel_tasklet_rx_func()
1725 atmel_port->schedule_rx(port); in atmel_tasklet_rx_func()
1726 spin_unlock(&port->lock); in atmel_tasklet_rx_func()
1733 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_tx_func() local
1736 spin_lock(&port->lock); in atmel_tasklet_tx_func()
1737 atmel_port->schedule_tx(port); in atmel_tasklet_tx_func()
1738 spin_unlock(&port->lock); in atmel_tasklet_tx_func()
1774 static void atmel_set_ops(struct uart_port *port) in atmel_set_ops() argument
1776 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_ops()
1778 if (atmel_use_dma_rx(port)) { in atmel_set_ops()
1782 } else if (atmel_use_pdc_rx(port)) { in atmel_set_ops()
1792 if (atmel_use_dma_tx(port)) { in atmel_set_ops()
1796 } else if (atmel_use_pdc_tx(port)) { in atmel_set_ops()
1810 static void atmel_get_ip_name(struct uart_port *port) in atmel_get_ip_name() argument
1812 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_ip_name()
1813 int name = atmel_uart_readl(port, ATMEL_US_NAME); in atmel_get_ip_name()
1831 dev_dbg(port->dev, "Uart with hw timer"); in atmel_get_ip_name()
1835 dev_dbg(port->dev, "Usart\n"); in atmel_get_ip_name()
1839 version = atmel_uart_readl(port, ATMEL_US_VERSION); in atmel_get_ip_name()
1856 dev_dbg(port->dev, "Dbgu or uart without hw timer\n"); in atmel_get_ip_name()
1859 version = atmel_uart_readl(port, ATMEL_US_VERSION); in atmel_get_ip_name()
1864 dev_dbg(port->dev, "This version is usart\n"); in atmel_get_ip_name()
1871 dev_dbg(port->dev, "This version is uart\n"); in atmel_get_ip_name()
1874 dev_err(port->dev, "Not supported ip name nor version, set to uart\n"); in atmel_get_ip_name()
1882 static int atmel_startup(struct uart_port *port) in atmel_startup() argument
1884 struct platform_device *pdev = to_platform_device(port->dev); in atmel_startup()
1885 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_startup()
1893 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_startup()
1899 retval = request_irq(port->irq, atmel_interrupt, in atmel_startup()
1901 dev_name(&pdev->dev), port); in atmel_startup()
1903 dev_err(port->dev, "atmel_startup - Can't get irq\n"); in atmel_startup()
1915 atmel_set_ops(port); in atmel_startup()
1918 retval = atmel_port->prepare_rx(port); in atmel_startup()
1920 atmel_set_ops(port); in atmel_startup()
1924 retval = atmel_port->prepare_tx(port); in atmel_startup()
1926 atmel_set_ops(port); in atmel_startup()
1937 atmel_uart_writel(port, ATMEL_US_CR, in atmel_startup()
1942 if (atmel_use_dma_tx(port)) in atmel_startup()
1952 atmel_uart_writel(port, ATMEL_US_FMR, fmr); in atmel_startup()
1956 atmel_port->irq_status_prev = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_startup()
1961 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_startup()
1963 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_startup()
1968 if (atmel_use_pdc_rx(port)) { in atmel_startup()
1972 jiffies + uart_poll_timeout(port)); in atmel_startup()
1975 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1977 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_startup()
1979 atmel_uart_writel(port, ATMEL_US_IER, in atmel_startup()
1983 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_RXTEN); in atmel_startup()
1984 } else if (atmel_use_dma_rx(port)) { in atmel_startup()
1988 jiffies + uart_poll_timeout(port)); in atmel_startup()
1991 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1993 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_STTTO); in atmel_startup()
1995 atmel_uart_writel(port, ATMEL_US_IER, in atmel_startup()
2000 atmel_uart_writel(port, ATMEL_US_IER, ATMEL_US_RXRDY); in atmel_startup()
2010 static void atmel_flush_buffer(struct uart_port *port) in atmel_flush_buffer() argument
2012 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_flush_buffer()
2014 if (atmel_use_pdc_tx(port)) { in atmel_flush_buffer()
2015 atmel_uart_writel(port, ATMEL_PDC_TCR, 0); in atmel_flush_buffer()
2028 static void atmel_shutdown(struct uart_port *port) in atmel_shutdown() argument
2030 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_shutdown()
2033 atmel_disable_ms(port); in atmel_shutdown()
2036 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_shutdown()
2048 synchronize_irq(port->irq); in atmel_shutdown()
2061 atmel_stop_rx(port); in atmel_shutdown()
2062 atmel_stop_tx(port); in atmel_shutdown()
2064 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA); in atmel_shutdown()
2070 atmel_port->release_rx(port); in atmel_shutdown()
2072 atmel_port->release_tx(port); in atmel_shutdown()
2083 free_irq(port->irq, port); in atmel_shutdown()
2085 atmel_flush_buffer(port); in atmel_shutdown()
2091 static void atmel_serial_pm(struct uart_port *port, unsigned int state, in atmel_serial_pm() argument
2094 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_pm()
2105 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->backup_imr); in atmel_serial_pm()
2109 atmel_port->backup_imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_serial_pm()
2110 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_serial_pm()
2119 dev_err(port->dev, "atmel_serial: unknown pm %d\n", state); in atmel_serial_pm()
2126 static void atmel_set_termios(struct uart_port *port, struct ktermios *termios, in atmel_set_termios() argument
2129 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_termios()
2134 mode = old_mode = atmel_uart_readl(port, ATMEL_US_MR); in atmel_set_termios()
2140 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); in atmel_set_termios()
2177 spin_lock_irqsave(&port->lock, flags); in atmel_set_termios()
2179 port->read_status_mask = ATMEL_US_OVRE; in atmel_set_termios()
2181 port->read_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE); in atmel_set_termios()
2183 port->read_status_mask |= ATMEL_US_RXBRK; in atmel_set_termios()
2185 if (atmel_use_pdc_rx(port)) in atmel_set_termios()
2187 atmel_uart_writel(port, ATMEL_US_IER, port->read_status_mask); in atmel_set_termios()
2192 port->ignore_status_mask = 0; in atmel_set_termios()
2194 port->ignore_status_mask |= (ATMEL_US_FRAME | ATMEL_US_PARE); in atmel_set_termios()
2196 port->ignore_status_mask |= ATMEL_US_RXBRK; in atmel_set_termios()
2202 port->ignore_status_mask |= ATMEL_US_OVRE; in atmel_set_termios()
2207 uart_update_timeout(port, termios->c_cflag, baud); in atmel_set_termios()
2214 imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_set_termios()
2215 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_set_termios()
2218 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXDIS | ATMEL_US_RXDIS); in atmel_set_termios()
2222 if (port->rs485.flags & SER_RS485_ENABLED) { in atmel_set_termios()
2223 atmel_uart_writel(port, ATMEL_US_TTGR, in atmel_set_termios()
2224 port->rs485.delay_rts_after_send); in atmel_set_termios()
2226 } else if (port->iso7816.flags & SER_ISO7816_ENABLED) { in atmel_set_termios()
2227 atmel_uart_writel(port, ATMEL_US_TTGR, port->iso7816.tg); in atmel_set_termios()
2232 if ((port->iso7816.flags & SER_ISO7816_T_PARAM) in atmel_set_termios()
2239 if (atmel_use_fifo(port) && in atmel_set_termios()
2279 div = DIV_ROUND_CLOSEST(port->uartclk, baud * 2); in atmel_set_termios()
2283 cd = uart_get_divisor(port, baud); in atmel_set_termios()
2292 if (!(port->iso7816.flags & SER_ISO7816_ENABLED)) in atmel_set_termios()
2293 atmel_uart_writel(port, ATMEL_US_BRGR, quot); in atmel_set_termios()
2296 atmel_uart_writel(port, ATMEL_US_MR, mode); in atmel_set_termios()
2313 atmel_uart_writel(port, ATMEL_US_CR, rts_state); in atmel_set_termios()
2316 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_set_termios()
2317 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_set_termios()
2321 atmel_uart_writel(port, ATMEL_US_IER, imr); in atmel_set_termios()
2324 if (UART_ENABLE_MS(port, termios->c_cflag)) in atmel_set_termios()
2325 atmel_enable_ms(port); in atmel_set_termios()
2327 atmel_disable_ms(port); in atmel_set_termios()
2329 spin_unlock_irqrestore(&port->lock, flags); in atmel_set_termios()
2332 static void atmel_set_ldisc(struct uart_port *port, struct ktermios *termios) in atmel_set_ldisc() argument
2335 port->flags |= UPF_HARDPPS_CD; in atmel_set_ldisc()
2336 spin_lock_irq(&port->lock); in atmel_set_ldisc()
2337 atmel_enable_ms(port); in atmel_set_ldisc()
2338 spin_unlock_irq(&port->lock); in atmel_set_ldisc()
2340 port->flags &= ~UPF_HARDPPS_CD; in atmel_set_ldisc()
2341 if (!UART_ENABLE_MS(port, termios->c_cflag)) { in atmel_set_ldisc()
2342 spin_lock_irq(&port->lock); in atmel_set_ldisc()
2343 atmel_disable_ms(port); in atmel_set_ldisc()
2344 spin_unlock_irq(&port->lock); in atmel_set_ldisc()
2352 static const char *atmel_type(struct uart_port *port) in atmel_type() argument
2354 return (port->type == PORT_ATMEL) ? "ATMEL_SERIAL" : NULL; in atmel_type()
2360 static void atmel_release_port(struct uart_port *port) in atmel_release_port() argument
2362 struct platform_device *mpdev = to_platform_device(port->dev->parent); in atmel_release_port()
2365 release_mem_region(port->mapbase, size); in atmel_release_port()
2367 if (port->flags & UPF_IOREMAP) { in atmel_release_port()
2368 iounmap(port->membase); in atmel_release_port()
2369 port->membase = NULL; in atmel_release_port()
2376 static int atmel_request_port(struct uart_port *port) in atmel_request_port() argument
2378 struct platform_device *mpdev = to_platform_device(port->dev->parent); in atmel_request_port()
2381 if (!request_mem_region(port->mapbase, size, "atmel_serial")) in atmel_request_port()
2384 if (port->flags & UPF_IOREMAP) { in atmel_request_port()
2385 port->membase = ioremap(port->mapbase, size); in atmel_request_port()
2386 if (port->membase == NULL) { in atmel_request_port()
2387 release_mem_region(port->mapbase, size); in atmel_request_port()
2398 static void atmel_config_port(struct uart_port *port, int flags) in atmel_config_port() argument
2401 port->type = PORT_ATMEL; in atmel_config_port()
2402 atmel_request_port(port); in atmel_config_port()
2409 static int atmel_verify_port(struct uart_port *port, struct serial_struct *ser) in atmel_verify_port() argument
2414 if (port->irq != ser->irq) in atmel_verify_port()
2418 if (port->uartclk / 16 != ser->baud_base) in atmel_verify_port()
2420 if (port->mapbase != (unsigned long)ser->iomem_base) in atmel_verify_port()
2422 if (port->iobase != ser->port) in atmel_verify_port()
2430 static int atmel_poll_get_char(struct uart_port *port) in atmel_poll_get_char() argument
2432 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_RXRDY)) in atmel_poll_get_char()
2435 return atmel_uart_read_char(port); in atmel_poll_get_char()
2438 static void atmel_poll_put_char(struct uart_port *port, unsigned char ch) in atmel_poll_put_char() argument
2440 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) in atmel_poll_put_char()
2443 atmel_uart_write_char(port, ch); in atmel_poll_put_char()
2480 struct uart_port *port = &atmel_port->uart; in atmel_init_port() local
2484 atmel_set_ops(port); in atmel_init_port()
2486 port->iotype = UPIO_MEM; in atmel_init_port()
2487 port->flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP; in atmel_init_port()
2488 port->ops = &atmel_pops; in atmel_init_port()
2489 port->fifosize = 1; in atmel_init_port()
2490 port->dev = &pdev->dev; in atmel_init_port()
2491 port->mapbase = mpdev->resource[0].start; in atmel_init_port()
2492 port->irq = mpdev->resource[1].start; in atmel_init_port()
2493 port->rs485_config = atmel_config_rs485; in atmel_init_port()
2494 port->iso7816_config = atmel_config_iso7816; in atmel_init_port()
2495 port->membase = NULL; in atmel_init_port()
2499 ret = uart_get_rs485_mode(port); in atmel_init_port()
2517 port->uartclk = clk_get_rate(atmel_port->clk); in atmel_init_port()
2526 if (atmel_uart_is_half_duplex(port)) in atmel_init_port()
2528 else if (atmel_use_pdc_tx(port)) { in atmel_init_port()
2529 port->fifosize = PDC_BUFFER_SIZE; in atmel_init_port()
2539 static void atmel_console_putchar(struct uart_port *port, int ch) in atmel_console_putchar() argument
2541 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & ATMEL_US_TXRDY)) in atmel_console_putchar()
2543 atmel_uart_write_char(port, ch); in atmel_console_putchar()
2551 struct uart_port *port = &atmel_ports[co->index].uart; in atmel_console_write() local
2552 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_write()
2559 imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_console_write()
2560 atmel_uart_writel(port, ATMEL_US_IDR, in atmel_console_write()
2564 pdc_tx = atmel_uart_readl(port, ATMEL_PDC_PTSR) & ATMEL_PDC_TXTEN; in atmel_console_write()
2565 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTDIS); in atmel_console_write()
2568 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN); in atmel_console_write()
2571 uart_console_write(port, s, count, atmel_console_putchar); in atmel_console_write()
2578 status = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_console_write()
2583 atmel_uart_writel(port, ATMEL_PDC_PTCR, ATMEL_PDC_TXTEN); in atmel_console_write()
2586 atmel_uart_writel(port, ATMEL_US_IER, imr); in atmel_console_write()
2593 static void __init atmel_console_get_options(struct uart_port *port, int *baud, in atmel_console_get_options() argument
2602 quot = atmel_uart_readl(port, ATMEL_US_BRGR) & ATMEL_US_CD; in atmel_console_get_options()
2606 mr = atmel_uart_readl(port, ATMEL_US_MR) & ATMEL_US_CHRL; in atmel_console_get_options()
2612 mr = atmel_uart_readl(port, ATMEL_US_MR) & ATMEL_US_PAR; in atmel_console_get_options()
2618 *baud = port->uartclk / (16 * quot); in atmel_console_get_options()
2624 struct uart_port *port = &atmel_ports[co->index].uart; in atmel_console_setup() local
2625 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_setup()
2631 if (port->membase == NULL) { in atmel_console_setup()
2640 atmel_uart_writel(port, ATMEL_US_IDR, -1); in atmel_console_setup()
2641 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_RSTSTA | ATMEL_US_RSTRX); in atmel_console_setup()
2642 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_TXEN | ATMEL_US_RXEN); in atmel_console_setup()
2648 atmel_console_get_options(port, &baud, &parity, &bits); in atmel_console_setup()
2650 return uart_set_options(port, co, baud, parity, bits, flow); in atmel_console_setup()
2694 struct uart_port *port = platform_get_drvdata(pdev); in atmel_serial_suspend() local
2695 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_suspend()
2697 if (uart_console(port) && console_suspend_enabled) { in atmel_serial_suspend()
2699 while (!(atmel_uart_readl(port, ATMEL_US_CSR) & in atmel_serial_suspend()
2704 if (uart_console(port) && !console_suspend_enabled) { in atmel_serial_suspend()
2708 atmel_port->cache.mr = atmel_uart_readl(port, ATMEL_US_MR); in atmel_serial_suspend()
2709 atmel_port->cache.imr = atmel_uart_readl(port, ATMEL_US_IMR); in atmel_serial_suspend()
2710 atmel_port->cache.brgr = atmel_uart_readl(port, ATMEL_US_BRGR); in atmel_serial_suspend()
2711 atmel_port->cache.rtor = atmel_uart_readl(port, in atmel_serial_suspend()
2713 atmel_port->cache.ttgr = atmel_uart_readl(port, ATMEL_US_TTGR); in atmel_serial_suspend()
2714 atmel_port->cache.fmr = atmel_uart_readl(port, ATMEL_US_FMR); in atmel_serial_suspend()
2715 atmel_port->cache.fimr = atmel_uart_readl(port, ATMEL_US_FIMR); in atmel_serial_suspend()
2729 uart_suspend_port(&atmel_uart, port); in atmel_serial_suspend()
2736 struct uart_port *port = platform_get_drvdata(pdev); in atmel_serial_resume() local
2737 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_resume()
2740 if (uart_console(port) && !console_suspend_enabled) { in atmel_serial_resume()
2741 atmel_uart_writel(port, ATMEL_US_MR, atmel_port->cache.mr); in atmel_serial_resume()
2742 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->cache.imr); in atmel_serial_resume()
2743 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->cache.brgr); in atmel_serial_resume()
2744 atmel_uart_writel(port, atmel_port->rtor, in atmel_serial_resume()
2746 atmel_uart_writel(port, ATMEL_US_TTGR, atmel_port->cache.ttgr); in atmel_serial_resume()
2749 atmel_uart_writel(port, ATMEL_US_CR, ATMEL_US_FIFOEN | in atmel_serial_resume()
2751 atmel_uart_writel(port, ATMEL_US_FMR, in atmel_serial_resume()
2753 atmel_uart_writel(port, ATMEL_US_FIER, in atmel_serial_resume()
2756 atmel_start_rx(port); in atmel_serial_resume()
2761 atmel_handle_receive(port, atmel_port->pending); in atmel_serial_resume()
2762 atmel_handle_status(port, atmel_port->pending, in atmel_serial_resume()
2764 atmel_handle_transmit(port, atmel_port->pending); in atmel_serial_resume()
2770 uart_resume_port(&atmel_uart, port); in atmel_serial_resume()
2958 struct uart_port *port = platform_get_drvdata(pdev); in atmel_serial_remove() local
2959 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_remove()
2967 ret = uart_remove_one_port(&atmel_uart, port); in atmel_serial_remove()
2973 clear_bit(port->line, atmel_ports_in_use); in atmel_serial_remove()