Lines Matching refs:atmel_port
241 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_rx() local
243 return atmel_port->use_pdc_rx; in atmel_use_pdc_rx()
248 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_tx() local
250 return atmel_port->use_pdc_tx; in atmel_use_pdc_tx()
266 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_tx() local
268 return atmel_port->use_dma_tx; in atmel_use_dma_tx()
273 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_rx() local
275 return atmel_port->use_dma_rx; in atmel_use_dma_rx()
280 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_fifo() local
282 return atmel_port->fifo_size; in atmel_use_fifo()
285 static void atmel_tasklet_schedule(struct atmel_uart_port *atmel_port, in atmel_tasklet_schedule() argument
288 if (!atomic_read(&atmel_port->tasklet_shutdown)) in atmel_tasklet_schedule()
296 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_rs485() local
300 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_rs485()
307 atmel_port->tx_done_mask = ATMEL_US_TXRDY; in atmel_config_rs485()
309 atmel_port->tx_done_mask = ATMEL_US_TXEMPTY; in atmel_config_rs485()
318 atmel_port->tx_done_mask = ATMEL_US_ENDTX | in atmel_config_rs485()
321 atmel_port->tx_done_mask = ATMEL_US_TXRDY; in atmel_config_rs485()
326 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_rs485()
334 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_calc_cd() local
338 mck_rate = (u64)clk_get_rate(atmel_port->clk); in atmel_calc_cd()
361 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_iso7816() local
367 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_iso7816()
405 } else if (fidi < atmel_port->fidi_min in atmel_config_iso7816()
406 || fidi > atmel_port->fidi_max) { 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()
424 atmel_port->tx_done_mask = ATMEL_US_TXEMPTY | ATMEL_US_NACK | ATMEL_US_ITERATION; in atmel_config_iso7816()
428 mode = atmel_port->backup_mode; in atmel_config_iso7816()
431 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->backup_brgr); in atmel_config_iso7816()
435 atmel_port->tx_done_mask = ATMEL_US_ENDTX | in atmel_config_iso7816()
438 atmel_port->tx_done_mask = ATMEL_US_TXRDY; in atmel_config_iso7816()
447 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_iso7816()
457 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_empty() local
459 if (atmel_port->tx_stopped) in atmel_tx_empty()
474 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_mctrl() local
511 mctrl_gpio_set(atmel_port->gpios, mctrl); in atmel_set_mctrl()
528 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_mctrl() local
545 return mctrl_gpio_get(atmel_port->gpios, &ret); in atmel_get_mctrl()
553 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_stop_tx() local
569 atmel_port->tx_stopped = true; in atmel_stop_tx()
573 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_stop_tx()
576 if (!atomic_read(&atmel_port->tasklet_shutdown)) in atmel_stop_tx()
585 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_start_tx() local
604 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_start_tx()
609 atmel_port->tx_stopped = false; in atmel_start_tx()
657 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_enable_ms() local
663 if (atmel_port->ms_irq_enabled) in atmel_enable_ms()
666 atmel_port->ms_irq_enabled = true; in atmel_enable_ms()
668 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) in atmel_enable_ms()
671 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DSR)) in atmel_enable_ms()
674 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_RI)) in atmel_enable_ms()
677 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DCD)) in atmel_enable_ms()
682 mctrl_gpio_enable_ms(atmel_port->gpios); in atmel_enable_ms()
690 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_disable_ms() local
696 if (!atmel_port->ms_irq_enabled) in atmel_disable_ms()
699 atmel_port->ms_irq_enabled = false; in atmel_disable_ms()
701 mctrl_gpio_disable_ms(atmel_port->gpios); in atmel_disable_ms()
703 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) in atmel_disable_ms()
706 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DSR)) in atmel_disable_ms()
709 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_RI)) in atmel_disable_ms()
712 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DCD)) in atmel_disable_ms()
738 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_buffer_rx_char() local
739 struct circ_buf *ring = &atmel_port->rx_ring; in atmel_buffer_rx_char()
782 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_chars() local
795 || atmel_port->break_active)) { in atmel_rx_chars()
801 && !atmel_port->break_active) { in atmel_rx_chars()
802 atmel_port->break_active = 1; in atmel_rx_chars()
816 atmel_port->break_active = 0; in atmel_rx_chars()
824 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_rx); in atmel_rx_chars()
833 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_chars() local
845 atmel_port->tx_done_mask |= ATMEL_US_TXRDY; in atmel_tx_chars()
849 atmel_port->tx_done_mask); in atmel_tx_chars()
852 atmel_port->tx_done_mask &= ~ATMEL_US_TXRDY; in atmel_tx_chars()
858 struct atmel_uart_port *atmel_port = arg; in atmel_complete_tx_dma() local
859 struct uart_port *port = &atmel_port->uart; in atmel_complete_tx_dma()
861 struct dma_chan *chan = atmel_port->chan_tx; in atmel_complete_tx_dma()
868 uart_xmit_advance(port, atmel_port->tx_len); in atmel_complete_tx_dma()
870 spin_lock(&atmel_port->lock_tx); in atmel_complete_tx_dma()
871 async_tx_ack(atmel_port->desc_tx); in atmel_complete_tx_dma()
872 atmel_port->cookie_tx = -EINVAL; in atmel_complete_tx_dma()
873 atmel_port->desc_tx = NULL; in atmel_complete_tx_dma()
874 spin_unlock(&atmel_port->lock_tx); in atmel_complete_tx_dma()
885 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); in atmel_complete_tx_dma()
891 atmel_port->hd_start_rx = true; in atmel_complete_tx_dma()
893 atmel_port->tx_done_mask); in atmel_complete_tx_dma()
901 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_dma() local
902 struct dma_chan *chan = atmel_port->chan_tx; in atmel_release_tx_dma()
907 dma_unmap_sg(port->dev, &atmel_port->sg_tx, 1, in atmel_release_tx_dma()
911 atmel_port->desc_tx = NULL; in atmel_release_tx_dma()
912 atmel_port->chan_tx = NULL; in atmel_release_tx_dma()
913 atmel_port->cookie_tx = -EINVAL; in atmel_release_tx_dma()
921 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_dma() local
923 struct dma_chan *chan = atmel_port->chan_tx; in atmel_tx_dma()
925 struct scatterlist sgl[2], *sg, *sg_tx = &atmel_port->sg_tx; in atmel_tx_dma()
930 if (atmel_port->desc_tx != NULL) in atmel_tx_dma()
947 if (atmel_port->fifo_size) { in atmel_tx_dma()
978 atmel_port->tx_len = tx_len; in atmel_tx_dma()
993 atmel_port->desc_tx = desc; in atmel_tx_dma()
995 desc->callback_param = atmel_port; in atmel_tx_dma()
996 atmel_port->cookie_tx = dmaengine_submit(desc); in atmel_tx_dma()
997 if (dma_submit_error(atmel_port->cookie_tx)) { in atmel_tx_dma()
999 atmel_port->cookie_tx); in atmel_tx_dma()
1012 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_dma() local
1021 atmel_port->chan_tx = dma_request_slave_channel(mfd_dev, "tx"); in atmel_prepare_tx_dma()
1022 if (atmel_port->chan_tx == NULL) in atmel_prepare_tx_dma()
1025 dma_chan_name(atmel_port->chan_tx)); in atmel_prepare_tx_dma()
1027 spin_lock_init(&atmel_port->lock_tx); in atmel_prepare_tx_dma()
1028 sg_init_table(&atmel_port->sg_tx, 1); in atmel_prepare_tx_dma()
1031 sg_set_page(&atmel_port->sg_tx, in atmel_prepare_tx_dma()
1036 &atmel_port->sg_tx, in atmel_prepare_tx_dma()
1045 sg_dma_len(&atmel_port->sg_tx), in atmel_prepare_tx_dma()
1047 &sg_dma_address(&atmel_port->sg_tx)); in atmel_prepare_tx_dma()
1053 config.dst_addr_width = (atmel_port->fifo_size) ? in atmel_prepare_tx_dma()
1059 ret = dmaengine_slave_config(atmel_port->chan_tx, in atmel_prepare_tx_dma()
1070 atmel_port->use_dma_tx = false; in atmel_prepare_tx_dma()
1071 if (atmel_port->chan_tx) in atmel_prepare_tx_dma()
1079 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_complete_rx_dma() local
1081 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_rx); in atmel_complete_rx_dma()
1086 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_dma() local
1087 struct dma_chan *chan = atmel_port->chan_rx; in atmel_release_rx_dma()
1092 dma_unmap_sg(port->dev, &atmel_port->sg_rx, 1, in atmel_release_rx_dma()
1096 atmel_port->desc_rx = NULL; in atmel_release_rx_dma()
1097 atmel_port->chan_rx = NULL; in atmel_release_rx_dma()
1098 atmel_port->cookie_rx = -EINVAL; in atmel_release_rx_dma()
1103 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_dma() local
1105 struct circ_buf *ring = &atmel_port->rx_ring; in atmel_rx_from_dma()
1106 struct dma_chan *chan = atmel_port->chan_rx; in atmel_rx_from_dma()
1115 atmel_port->cookie_rx, in atmel_rx_from_dma()
1121 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_rx); in atmel_rx_from_dma()
1127 &atmel_port->sg_rx, in atmel_rx_from_dma()
1138 ring->head = sg_dma_len(&atmel_port->sg_rx) - state.residue; in atmel_rx_from_dma()
1139 BUG_ON(ring->head > sg_dma_len(&atmel_port->sg_rx)); in atmel_rx_from_dma()
1153 count = sg_dma_len(&atmel_port->sg_rx) - ring->tail; in atmel_rx_from_dma()
1166 if (ring->head >= sg_dma_len(&atmel_port->sg_rx)) in atmel_rx_from_dma()
1174 &atmel_port->sg_rx, in atmel_rx_from_dma()
1185 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_dma() local
1193 ring = &atmel_port->rx_ring; in atmel_prepare_rx_dma()
1198 atmel_port->chan_rx = dma_request_slave_channel(mfd_dev, "rx"); in atmel_prepare_rx_dma()
1199 if (atmel_port->chan_rx == NULL) in atmel_prepare_rx_dma()
1202 dma_chan_name(atmel_port->chan_rx)); in atmel_prepare_rx_dma()
1204 spin_lock_init(&atmel_port->lock_rx); in atmel_prepare_rx_dma()
1205 sg_init_table(&atmel_port->sg_rx, 1); in atmel_prepare_rx_dma()
1208 sg_set_page(&atmel_port->sg_rx, in atmel_prepare_rx_dma()
1213 &atmel_port->sg_rx, in atmel_prepare_rx_dma()
1222 sg_dma_len(&atmel_port->sg_rx), in atmel_prepare_rx_dma()
1224 &sg_dma_address(&atmel_port->sg_rx)); in atmel_prepare_rx_dma()
1234 ret = dmaengine_slave_config(atmel_port->chan_rx, in atmel_prepare_rx_dma()
1244 desc = dmaengine_prep_dma_cyclic(atmel_port->chan_rx, in atmel_prepare_rx_dma()
1245 sg_dma_address(&atmel_port->sg_rx), in atmel_prepare_rx_dma()
1246 sg_dma_len(&atmel_port->sg_rx), in atmel_prepare_rx_dma()
1247 sg_dma_len(&atmel_port->sg_rx)/2, in atmel_prepare_rx_dma()
1256 atmel_port->desc_rx = desc; in atmel_prepare_rx_dma()
1257 atmel_port->cookie_rx = dmaengine_submit(desc); in atmel_prepare_rx_dma()
1258 if (dma_submit_error(atmel_port->cookie_rx)) { in atmel_prepare_rx_dma()
1260 atmel_port->cookie_rx); in atmel_prepare_rx_dma()
1264 dma_async_issue_pending(atmel_port->chan_rx); in atmel_prepare_rx_dma()
1270 atmel_port->use_dma_rx = false; in atmel_prepare_rx_dma()
1271 if (atmel_port->chan_rx) in atmel_prepare_rx_dma()
1278 struct atmel_uart_port *atmel_port = from_timer(atmel_port, t, in atmel_uart_timer_callback() local
1280 struct uart_port *port = &atmel_port->uart; in atmel_uart_timer_callback()
1282 if (!atomic_read(&atmel_port->tasklet_shutdown)) { in atmel_uart_timer_callback()
1283 tasklet_schedule(&atmel_port->tasklet_rx); in atmel_uart_timer_callback()
1284 mod_timer(&atmel_port->uart_timer, in atmel_uart_timer_callback()
1295 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_receive() local
1308 atmel_tasklet_schedule(atmel_port, in atmel_handle_receive()
1309 &atmel_port->tasklet_rx); in atmel_handle_receive()
1321 atmel_tasklet_schedule(atmel_port, in atmel_handle_receive()
1322 &atmel_port->tasklet_rx); in atmel_handle_receive()
1336 atmel_port->break_active = 0; in atmel_handle_receive()
1346 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_transmit() local
1348 if (pending & atmel_port->tx_done_mask) { in atmel_handle_transmit()
1350 atmel_port->tx_done_mask); in atmel_handle_transmit()
1353 if (atmel_port->hd_start_rx) { in atmel_handle_transmit()
1358 atmel_port->hd_start_rx = false; in atmel_handle_transmit()
1362 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); in atmel_handle_transmit()
1373 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_status() local
1378 status_change = status ^ atmel_port->irq_status_prev; in atmel_handle_status()
1379 atmel_port->irq_status_prev = status; in atmel_handle_status()
1407 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_interrupt() local
1410 spin_lock(&atmel_port->lock_suspended); in atmel_interrupt()
1419 if (atmel_port->suspended) { in atmel_interrupt()
1420 atmel_port->pending |= pending; in atmel_interrupt()
1421 atmel_port->pending_status = status; in atmel_interrupt()
1432 spin_unlock(&atmel_port->lock_suspended); in atmel_interrupt()
1439 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_pdc() local
1440 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx; in atmel_release_tx_pdc()
1453 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_pdc() local
1455 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx; in atmel_tx_pdc()
1485 atmel_port->tx_done_mask); in atmel_tx_pdc()
1499 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_pdc() local
1500 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx; in atmel_prepare_tx_pdc()
1516 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_ring() local
1517 struct circ_buf *ring = &atmel_port->rx_ring; in atmel_rx_from_ring()
1578 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_pdc() local
1582 struct atmel_dma_buffer *pdc = &atmel_port->pdc_rx[i]; in atmel_release_rx_pdc()
1594 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_pdc() local
1597 int rx_idx = atmel_port->pdc_rx_idx; in atmel_rx_from_pdc()
1606 pdc = &atmel_port->pdc_rx[rx_idx]; in atmel_rx_from_pdc()
1654 atmel_port->pdc_rx_idx = rx_idx; in atmel_rx_from_pdc()
1666 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_pdc() local
1670 struct atmel_dma_buffer *pdc = &atmel_port->pdc_rx[i]; in atmel_prepare_rx_pdc()
1676 atmel_port->pdc_rx[0].dma_addr, in atmel_prepare_rx_pdc()
1679 kfree(atmel_port->pdc_rx[0].buf); in atmel_prepare_rx_pdc()
1681 atmel_port->use_pdc_rx = false; in atmel_prepare_rx_pdc()
1692 atmel_port->pdc_rx_idx = 0; 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()
1698 atmel_port->pdc_rx[1].dma_addr); in atmel_prepare_rx_pdc()
1709 struct atmel_uart_port *atmel_port = from_tasklet(atmel_port, t, in atmel_tasklet_rx_func() local
1711 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_rx_func()
1715 atmel_port->schedule_rx(port); in atmel_tasklet_rx_func()
1721 struct atmel_uart_port *atmel_port = from_tasklet(atmel_port, t, in atmel_tasklet_tx_func() local
1723 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_tx_func()
1727 atmel_port->schedule_tx(port); in atmel_tasklet_tx_func()
1731 static void atmel_init_property(struct atmel_uart_port *atmel_port, in atmel_init_property() argument
1739 atmel_port->use_dma_rx = true; in atmel_init_property()
1740 atmel_port->use_pdc_rx = false; in atmel_init_property()
1742 atmel_port->use_dma_rx = false; in atmel_init_property()
1743 atmel_port->use_pdc_rx = true; in atmel_init_property()
1746 atmel_port->use_dma_rx = false; in atmel_init_property()
1747 atmel_port->use_pdc_rx = false; in atmel_init_property()
1752 atmel_port->use_dma_tx = true; in atmel_init_property()
1753 atmel_port->use_pdc_tx = false; in atmel_init_property()
1755 atmel_port->use_dma_tx = false; in atmel_init_property()
1756 atmel_port->use_pdc_tx = true; in atmel_init_property()
1759 atmel_port->use_dma_tx = false; in atmel_init_property()
1760 atmel_port->use_pdc_tx = false; in atmel_init_property()
1766 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_ops() local
1769 atmel_port->prepare_rx = &atmel_prepare_rx_dma; in atmel_set_ops()
1770 atmel_port->schedule_rx = &atmel_rx_from_dma; in atmel_set_ops()
1771 atmel_port->release_rx = &atmel_release_rx_dma; in atmel_set_ops()
1773 atmel_port->prepare_rx = &atmel_prepare_rx_pdc; in atmel_set_ops()
1774 atmel_port->schedule_rx = &atmel_rx_from_pdc; in atmel_set_ops()
1775 atmel_port->release_rx = &atmel_release_rx_pdc; in atmel_set_ops()
1777 atmel_port->prepare_rx = NULL; in atmel_set_ops()
1778 atmel_port->schedule_rx = &atmel_rx_from_ring; in atmel_set_ops()
1779 atmel_port->release_rx = NULL; in atmel_set_ops()
1783 atmel_port->prepare_tx = &atmel_prepare_tx_dma; in atmel_set_ops()
1784 atmel_port->schedule_tx = &atmel_tx_dma; in atmel_set_ops()
1785 atmel_port->release_tx = &atmel_release_tx_dma; in atmel_set_ops()
1787 atmel_port->prepare_tx = &atmel_prepare_tx_pdc; in atmel_set_ops()
1788 atmel_port->schedule_tx = &atmel_tx_pdc; in atmel_set_ops()
1789 atmel_port->release_tx = &atmel_release_tx_pdc; in atmel_set_ops()
1791 atmel_port->prepare_tx = NULL; in atmel_set_ops()
1792 atmel_port->schedule_tx = &atmel_tx_chars; in atmel_set_ops()
1793 atmel_port->release_tx = NULL; in atmel_set_ops()
1802 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_ip_name() local
1817 atmel_port->has_frac_baudrate = false; in atmel_get_ip_name()
1818 atmel_port->has_hw_timer = false; in atmel_get_ip_name()
1819 atmel_port->is_usart = false; in atmel_get_ip_name()
1823 atmel_port->has_hw_timer = true; in atmel_get_ip_name()
1824 atmel_port->rtor = ATMEL_UA_RTOR; in atmel_get_ip_name()
1827 atmel_port->has_frac_baudrate = true; in atmel_get_ip_name()
1828 atmel_port->has_hw_timer = true; in atmel_get_ip_name()
1829 atmel_port->is_usart = true; in atmel_get_ip_name()
1830 atmel_port->rtor = ATMEL_US_RTOR; in atmel_get_ip_name()
1836 atmel_port->fidi_min = 3; in atmel_get_ip_name()
1837 atmel_port->fidi_max = 65535; in atmel_get_ip_name()
1840 atmel_port->fidi_min = 3; in atmel_get_ip_name()
1841 atmel_port->fidi_max = 2047; in atmel_get_ip_name()
1844 atmel_port->fidi_min = 1; in atmel_get_ip_name()
1845 atmel_port->fidi_max = 2047; in atmel_get_ip_name()
1857 atmel_port->has_frac_baudrate = true; in atmel_get_ip_name()
1858 atmel_port->has_hw_timer = true; in atmel_get_ip_name()
1859 atmel_port->is_usart = true; in atmel_get_ip_name()
1860 atmel_port->rtor = ATMEL_US_RTOR; in atmel_get_ip_name()
1878 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_startup() local
1887 atmel_port->ms_irq_enabled = false; in atmel_startup()
1900 atomic_set(&atmel_port->tasklet_shutdown, 0); in atmel_startup()
1901 tasklet_setup(&atmel_port->tasklet_rx, atmel_tasklet_rx_func); in atmel_startup()
1902 tasklet_setup(&atmel_port->tasklet_tx, atmel_tasklet_tx_func); in atmel_startup()
1907 atmel_init_property(atmel_port, pdev); in atmel_startup()
1910 if (atmel_port->prepare_rx) { in atmel_startup()
1911 retval = atmel_port->prepare_rx(port); in atmel_startup()
1916 if (atmel_port->prepare_tx) { in atmel_startup()
1917 retval = atmel_port->prepare_tx(port); in atmel_startup()
1925 if (atmel_port->fifo_size) { in atmel_startup()
1939 if (atmel_port->rts_high && in atmel_startup()
1940 atmel_port->rts_low) in atmel_startup()
1942 ATMEL_US_RXFTHRES(atmel_port->rts_high) | in atmel_startup()
1943 ATMEL_US_RXFTHRES2(atmel_port->rts_low); in atmel_startup()
1949 atmel_port->irq_status_prev = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_startup()
1957 atmel_port->tx_stopped = false; in atmel_startup()
1959 timer_setup(&atmel_port->uart_timer, atmel_uart_timer_callback, 0); in atmel_startup()
1963 if (!atmel_port->has_hw_timer) { in atmel_startup()
1964 mod_timer(&atmel_port->uart_timer, in atmel_startup()
1968 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1979 if (!atmel_port->has_hw_timer) { in atmel_startup()
1980 mod_timer(&atmel_port->uart_timer, in atmel_startup()
1984 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
2005 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_flush_buffer() local
2009 atmel_port->pdc_tx.ofs = 0; in atmel_flush_buffer()
2015 atmel_port->tx_len = 0; in atmel_flush_buffer()
2023 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_shutdown() local
2032 atomic_inc(&atmel_port->tasklet_shutdown); in atmel_shutdown()
2038 del_timer_sync(&atmel_port->uart_timer); in atmel_shutdown()
2047 tasklet_kill(&atmel_port->tasklet_rx); in atmel_shutdown()
2048 tasklet_kill(&atmel_port->tasklet_tx); in atmel_shutdown()
2062 if (atmel_port->release_rx) in atmel_shutdown()
2063 atmel_port->release_rx(port); in atmel_shutdown()
2064 if (atmel_port->release_tx) in atmel_shutdown()
2065 atmel_port->release_tx(port); in atmel_shutdown()
2070 atmel_port->rx_ring.head = 0; in atmel_shutdown()
2071 atmel_port->rx_ring.tail = 0; in atmel_shutdown()
2087 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_pm() local
2095 clk_prepare_enable(atmel_port->clk); 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()
2109 clk_disable_unprepare(atmel_port->clk); in atmel_serial_pm()
2110 if (__clk_is_enabled(atmel_port->gclk)) in atmel_serial_pm()
2111 clk_disable_unprepare(atmel_port->gclk); in atmel_serial_pm()
2125 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_termios() local
2135 if (atmel_port->is_usart) in atmel_set_termios()
2220 atmel_port->tx_stopped = true; in atmel_set_termios()
2241 !mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) { in atmel_set_termios()
2279 if (atmel_port->has_frac_baudrate) { in atmel_set_termios()
2295 if (atmel_port->is_usart && cd > ATMEL_US_CD) { in atmel_set_termios()
2308 if (!atmel_port->has_frac_baudrate) { in atmel_set_termios()
2309 if (__clk_is_enabled(atmel_port->gclk)) in atmel_set_termios()
2310 clk_disable_unprepare(atmel_port->gclk); in atmel_set_termios()
2311 gclk_rate = clk_round_rate(atmel_port->gclk, 16 * baud); in atmel_set_termios()
2312 actual_baud = clk_get_rate(atmel_port->clk) / (16 * cd); in atmel_set_termios()
2315 clk_set_rate(atmel_port->gclk, 16 * baud); in atmel_set_termios()
2316 ret = clk_prepare_enable(atmel_port->gclk); in atmel_set_termios()
2320 if (atmel_port->is_usart) { in atmel_set_termios()
2369 atmel_port->tx_stopped = false; in atmel_set_termios()
2533 static int atmel_init_port(struct atmel_uart_port *atmel_port, in atmel_init_port() argument
2537 struct uart_port *port = &atmel_port->uart; in atmel_init_port()
2540 atmel_init_property(atmel_port, pdev); in atmel_init_port()
2555 memset(&atmel_port->rx_ring, 0, sizeof(atmel_port->rx_ring)); in atmel_init_port()
2561 port->uartclk = clk_get_rate(atmel_port->clk); in atmel_init_port()
2568 atmel_port->tx_done_mask = ATMEL_US_TXEMPTY; in atmel_init_port()
2571 atmel_port->tx_done_mask = ATMEL_US_ENDTX | ATMEL_US_TXBUFE; in atmel_init_port()
2573 atmel_port->tx_done_mask = ATMEL_US_TXRDY; in atmel_init_port()
2593 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_write() local
2602 ATMEL_US_RXRDY | atmel_port->tx_done_mask); in atmel_console_write()
2610 atmel_port->tx_stopped = false; in atmel_console_write()
2665 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_setup() local
2679 atmel_port->tx_stopped = false; in atmel_console_setup()
2753 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_suspend() local
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()
2770 atmel_port->rtor); 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()
2777 atmel_port->may_wakeup = device_may_wakeup(dev); in atmel_serial_suspend()
2781 spin_lock_irqsave(&atmel_port->lock_suspended, flags); in atmel_serial_suspend()
2782 atmel_port->suspended = true; in atmel_serial_suspend()
2783 spin_unlock_irqrestore(&atmel_port->lock_suspended, flags); in atmel_serial_suspend()
2795 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_resume() local
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()
2803 atmel_port->cache.rtor); in atmel_serial_resume()
2804 atmel_uart_writel(port, ATMEL_US_TTGR, atmel_port->cache.ttgr); in atmel_serial_resume()
2806 if (atmel_port->fifo_size) { in atmel_serial_resume()
2810 atmel_port->cache.fmr); in atmel_serial_resume()
2812 atmel_port->cache.fimr); in atmel_serial_resume()
2817 spin_lock_irqsave(&atmel_port->lock_suspended, flags); in atmel_serial_resume()
2818 if (atmel_port->pending) { 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()
2821 atmel_port->pending_status); in atmel_serial_resume()
2822 atmel_handle_transmit(port, atmel_port->pending); in atmel_serial_resume()
2823 atmel_port->pending = 0; in atmel_serial_resume()
2825 atmel_port->suspended = false; in atmel_serial_resume()
2826 spin_unlock_irqrestore(&atmel_port->lock_suspended, flags); in atmel_serial_resume()
2829 device_set_wakeup_enable(dev, atmel_port->may_wakeup); in atmel_serial_resume()
2834 static void atmel_serial_probe_fifos(struct atmel_uart_port *atmel_port, in atmel_serial_probe_fifos() argument
2837 atmel_port->fifo_size = 0; in atmel_serial_probe_fifos()
2838 atmel_port->rts_low = 0; in atmel_serial_probe_fifos()
2839 atmel_port->rts_high = 0; in atmel_serial_probe_fifos()
2843 &atmel_port->fifo_size)) in atmel_serial_probe_fifos()
2846 if (!atmel_port->fifo_size) in atmel_serial_probe_fifos()
2849 if (atmel_port->fifo_size < ATMEL_MIN_FIFO_SIZE) { in atmel_serial_probe_fifos()
2850 atmel_port->fifo_size = 0; in atmel_serial_probe_fifos()
2863 atmel_port->rts_high = max_t(int, atmel_port->fifo_size >> 1, in atmel_serial_probe_fifos()
2864 atmel_port->fifo_size - ATMEL_RTS_HIGH_OFFSET); in atmel_serial_probe_fifos()
2865 atmel_port->rts_low = max_t(int, atmel_port->fifo_size >> 2, in atmel_serial_probe_fifos()
2866 atmel_port->fifo_size - ATMEL_RTS_LOW_OFFSET); in atmel_serial_probe_fifos()
2869 atmel_port->fifo_size); in atmel_serial_probe_fifos()
2871 atmel_port->rts_high); in atmel_serial_probe_fifos()
2873 atmel_port->rts_low); in atmel_serial_probe_fifos()
2878 struct atmel_uart_port *atmel_port; in atmel_serial_probe() local
2912 atmel_port = &atmel_ports[ret]; in atmel_serial_probe()
2913 atmel_port->backup_imr = 0; in atmel_serial_probe()
2914 atmel_port->uart.line = ret; in atmel_serial_probe()
2915 atmel_port->uart.has_sysrq = IS_ENABLED(CONFIG_SERIAL_ATMEL_CONSOLE); in atmel_serial_probe()
2916 atmel_serial_probe_fifos(atmel_port, pdev); in atmel_serial_probe()
2918 atomic_set(&atmel_port->tasklet_shutdown, 0); in atmel_serial_probe()
2919 spin_lock_init(&atmel_port->lock_suspended); in atmel_serial_probe()
2921 atmel_port->clk = devm_clk_get(&pdev->dev, "usart"); in atmel_serial_probe()
2922 if (IS_ERR(atmel_port->clk)) { in atmel_serial_probe()
2923 ret = PTR_ERR(atmel_port->clk); in atmel_serial_probe()
2926 ret = clk_prepare_enable(atmel_port->clk); in atmel_serial_probe()
2930 atmel_port->gclk = devm_clk_get_optional(&pdev->dev, "gclk"); in atmel_serial_probe()
2931 if (IS_ERR(atmel_port->gclk)) { in atmel_serial_probe()
2932 ret = PTR_ERR(atmel_port->gclk); in atmel_serial_probe()
2936 ret = atmel_init_port(atmel_port, pdev); in atmel_serial_probe()
2940 atmel_port->gpios = mctrl_gpio_init(&atmel_port->uart, 0); in atmel_serial_probe()
2941 if (IS_ERR(atmel_port->gpios)) { in atmel_serial_probe()
2942 ret = PTR_ERR(atmel_port->gpios); in atmel_serial_probe()
2946 if (!atmel_use_pdc_rx(&atmel_port->uart)) { in atmel_serial_probe()
2953 atmel_port->rx_ring.buf = data; in atmel_serial_probe()
2956 rs485_enabled = atmel_port->uart.rs485.flags & SER_RS485_ENABLED; in atmel_serial_probe()
2958 ret = uart_add_one_port(&atmel_uart, &atmel_port->uart); in atmel_serial_probe()
2963 platform_set_drvdata(pdev, atmel_port); in atmel_serial_probe()
2966 atmel_uart_writel(&atmel_port->uart, ATMEL_US_MR, in atmel_serial_probe()
2968 atmel_uart_writel(&atmel_port->uart, ATMEL_US_CR, in atmel_serial_probe()
2975 atmel_get_ip_name(&atmel_port->uart); in atmel_serial_probe()
2981 clk_disable_unprepare(atmel_port->clk); in atmel_serial_probe()
2986 kfree(atmel_port->rx_ring.buf); in atmel_serial_probe()
2987 atmel_port->rx_ring.buf = NULL; in atmel_serial_probe()
2989 clk_disable_unprepare(atmel_port->clk); in atmel_serial_probe()
2990 clear_bit(atmel_port->uart.line, atmel_ports_in_use); in atmel_serial_probe()
3007 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_remove() local
3009 tasklet_kill(&atmel_port->tasklet_rx); in atmel_serial_remove()
3010 tasklet_kill(&atmel_port->tasklet_tx); in atmel_serial_remove()
3016 kfree(atmel_port->rx_ring.buf); in atmel_serial_remove()