Lines Matching refs:atmel_port
243 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_rx() local
245 return atmel_port->use_pdc_rx; in atmel_use_pdc_rx()
250 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_pdc_tx() local
252 return atmel_port->use_pdc_tx; in atmel_use_pdc_tx()
268 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_tx() local
270 return atmel_port->use_dma_tx; in atmel_use_dma_tx()
275 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_dma_rx() local
277 return atmel_port->use_dma_rx; in atmel_use_dma_rx()
282 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_use_fifo() local
284 return atmel_port->fifo_size; in atmel_use_fifo()
287 static void atmel_tasklet_schedule(struct atmel_uart_port *atmel_port, in atmel_tasklet_schedule() argument
290 if (!atomic_read(&atmel_port->tasklet_shutdown)) in atmel_tasklet_schedule()
298 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_rs485() local
302 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_rs485()
309 atmel_port->tx_done_mask = ATMEL_US_TXRDY; in atmel_config_rs485()
311 atmel_port->tx_done_mask = ATMEL_US_TXEMPTY; in atmel_config_rs485()
320 atmel_port->tx_done_mask = ATMEL_US_ENDTX | in atmel_config_rs485()
323 atmel_port->tx_done_mask = ATMEL_US_TXRDY; in atmel_config_rs485()
328 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_rs485()
336 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_calc_cd() local
340 mck_rate = (u64)clk_get_rate(atmel_port->clk); in atmel_calc_cd()
363 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_config_iso7816() local
369 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_config_iso7816()
407 } else if (fidi < atmel_port->fidi_min in atmel_config_iso7816()
408 || fidi > atmel_port->fidi_max) { 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()
426 atmel_port->tx_done_mask = ATMEL_US_TXEMPTY | ATMEL_US_NACK | ATMEL_US_ITERATION; in atmel_config_iso7816()
430 mode = atmel_port->backup_mode; in atmel_config_iso7816()
433 atmel_uart_writel(port, ATMEL_US_BRGR, atmel_port->backup_brgr); in atmel_config_iso7816()
437 atmel_port->tx_done_mask = ATMEL_US_ENDTX | in atmel_config_iso7816()
440 atmel_port->tx_done_mask = ATMEL_US_TXRDY; in atmel_config_iso7816()
449 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_config_iso7816()
459 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_empty() local
461 if (atmel_port->tx_stopped) in atmel_tx_empty()
476 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_mctrl() local
513 mctrl_gpio_set(atmel_port->gpios, mctrl); in atmel_set_mctrl()
530 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_mctrl() local
547 return mctrl_gpio_get(atmel_port->gpios, &ret); in atmel_get_mctrl()
555 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_stop_tx() local
571 atmel_port->tx_stopped = true; in atmel_stop_tx()
575 atmel_uart_writel(port, ATMEL_US_IDR, atmel_port->tx_done_mask); in atmel_stop_tx()
578 if (!atomic_read(&atmel_port->tasklet_shutdown)) in atmel_stop_tx()
587 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_start_tx() local
606 atmel_uart_writel(port, ATMEL_US_IER, atmel_port->tx_done_mask); in atmel_start_tx()
611 atmel_port->tx_stopped = false; in atmel_start_tx()
659 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_enable_ms() local
665 if (atmel_port->ms_irq_enabled) in atmel_enable_ms()
668 atmel_port->ms_irq_enabled = true; in atmel_enable_ms()
670 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) in atmel_enable_ms()
673 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DSR)) in atmel_enable_ms()
676 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_RI)) in atmel_enable_ms()
679 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DCD)) in atmel_enable_ms()
684 mctrl_gpio_enable_ms(atmel_port->gpios); in atmel_enable_ms()
692 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_disable_ms() local
698 if (!atmel_port->ms_irq_enabled) in atmel_disable_ms()
701 atmel_port->ms_irq_enabled = false; in atmel_disable_ms()
703 mctrl_gpio_disable_ms(atmel_port->gpios); in atmel_disable_ms()
705 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) in atmel_disable_ms()
708 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DSR)) in atmel_disable_ms()
711 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_RI)) in atmel_disable_ms()
714 if (!mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_DCD)) in atmel_disable_ms()
740 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_buffer_rx_char() local
741 struct circ_buf *ring = &atmel_port->rx_ring; in atmel_buffer_rx_char()
784 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_chars() local
797 || atmel_port->break_active)) { in atmel_rx_chars()
803 && !atmel_port->break_active) { in atmel_rx_chars()
804 atmel_port->break_active = 1; in atmel_rx_chars()
818 atmel_port->break_active = 0; in atmel_rx_chars()
826 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_rx); in atmel_rx_chars()
835 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_chars() local
847 atmel_port->tx_done_mask |= ATMEL_US_TXRDY; in atmel_tx_chars()
851 atmel_port->tx_done_mask); in atmel_tx_chars()
854 atmel_port->tx_done_mask &= ~ATMEL_US_TXRDY; in atmel_tx_chars()
860 struct atmel_uart_port *atmel_port = arg; in atmel_complete_tx_dma() local
861 struct uart_port *port = &atmel_port->uart; in atmel_complete_tx_dma()
863 struct dma_chan *chan = atmel_port->chan_tx; in atmel_complete_tx_dma()
870 uart_xmit_advance(port, atmel_port->tx_len); in atmel_complete_tx_dma()
872 spin_lock(&atmel_port->lock_tx); in atmel_complete_tx_dma()
873 async_tx_ack(atmel_port->desc_tx); in atmel_complete_tx_dma()
874 atmel_port->cookie_tx = -EINVAL; in atmel_complete_tx_dma()
875 atmel_port->desc_tx = NULL; in atmel_complete_tx_dma()
876 spin_unlock(&atmel_port->lock_tx); in atmel_complete_tx_dma()
887 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); in atmel_complete_tx_dma()
893 atmel_port->hd_start_rx = true; in atmel_complete_tx_dma()
895 atmel_port->tx_done_mask); in atmel_complete_tx_dma()
903 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_dma() local
904 struct dma_chan *chan = atmel_port->chan_tx; in atmel_release_tx_dma()
909 dma_unmap_single(port->dev, atmel_port->tx_phys, in atmel_release_tx_dma()
913 atmel_port->desc_tx = NULL; in atmel_release_tx_dma()
914 atmel_port->chan_tx = NULL; in atmel_release_tx_dma()
915 atmel_port->cookie_tx = -EINVAL; in atmel_release_tx_dma()
923 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_dma() local
925 struct dma_chan *chan = atmel_port->chan_tx; in atmel_tx_dma()
932 if (atmel_port->desc_tx != NULL) in atmel_tx_dma()
948 if (atmel_port->fifo_size) { in atmel_tx_dma()
960 phys_addr = atmel_port->tx_phys + tail; in atmel_tx_dma()
979 atmel_port->tx_len = tx_len; in atmel_tx_dma()
992 dma_sync_single_for_device(port->dev, atmel_port->tx_phys, in atmel_tx_dma()
995 atmel_port->desc_tx = desc; in atmel_tx_dma()
997 desc->callback_param = atmel_port; in atmel_tx_dma()
998 atmel_port->cookie_tx = dmaengine_submit(desc); in atmel_tx_dma()
999 if (dma_submit_error(atmel_port->cookie_tx)) { in atmel_tx_dma()
1001 atmel_port->cookie_tx); in atmel_tx_dma()
1014 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_dma() local
1027 atmel_port->chan_tx = NULL; in atmel_prepare_tx_dma()
1030 atmel_port->chan_tx = chan; in atmel_prepare_tx_dma()
1032 dma_chan_name(atmel_port->chan_tx)); in atmel_prepare_tx_dma()
1034 spin_lock_init(&atmel_port->lock_tx); 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()
1046 &atmel_port->tx_phys); in atmel_prepare_tx_dma()
1052 config.dst_addr_width = (atmel_port->fifo_size) ? in atmel_prepare_tx_dma()
1058 ret = dmaengine_slave_config(atmel_port->chan_tx, in atmel_prepare_tx_dma()
1069 atmel_port->use_dma_tx = false; in atmel_prepare_tx_dma()
1070 if (atmel_port->chan_tx) in atmel_prepare_tx_dma()
1078 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_complete_rx_dma() local
1080 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_rx); in atmel_complete_rx_dma()
1085 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_dma() local
1086 struct dma_chan *chan = atmel_port->chan_rx; in atmel_release_rx_dma()
1091 dma_unmap_single(port->dev, atmel_port->rx_phys, in atmel_release_rx_dma()
1095 atmel_port->desc_rx = NULL; in atmel_release_rx_dma()
1096 atmel_port->chan_rx = NULL; in atmel_release_rx_dma()
1097 atmel_port->cookie_rx = -EINVAL; in atmel_release_rx_dma()
1102 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_dma() local
1104 struct circ_buf *ring = &atmel_port->rx_ring; in atmel_rx_from_dma()
1105 struct dma_chan *chan = atmel_port->chan_rx; in atmel_rx_from_dma()
1114 atmel_port->cookie_rx, in atmel_rx_from_dma()
1120 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_rx); in atmel_rx_from_dma()
1125 dma_sync_single_for_cpu(port->dev, atmel_port->rx_phys, in atmel_rx_from_dma()
1170 dma_sync_single_for_device(port->dev, atmel_port->rx_phys, in atmel_rx_from_dma()
1180 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_dma() local
1189 ring = &atmel_port->rx_ring; in atmel_prepare_rx_dma()
1196 atmel_port->chan_rx = NULL; in atmel_prepare_rx_dma()
1199 atmel_port->chan_rx = chan; in atmel_prepare_rx_dma()
1201 dma_chan_name(atmel_port->chan_rx)); in atmel_prepare_rx_dma()
1203 spin_lock_init(&atmel_port->lock_rx); 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()
1215 ATMEL_SERIAL_RX_SIZE, ring->buf, &atmel_port->rx_phys); in atmel_prepare_rx_dma()
1225 ret = dmaengine_slave_config(atmel_port->chan_rx, in atmel_prepare_rx_dma()
1235 desc = dmaengine_prep_dma_cyclic(atmel_port->chan_rx, in atmel_prepare_rx_dma()
1236 atmel_port->rx_phys, in atmel_prepare_rx_dma()
1247 atmel_port->desc_rx = desc; in atmel_prepare_rx_dma()
1248 atmel_port->cookie_rx = dmaengine_submit(desc); in atmel_prepare_rx_dma()
1249 if (dma_submit_error(atmel_port->cookie_rx)) { in atmel_prepare_rx_dma()
1251 atmel_port->cookie_rx); in atmel_prepare_rx_dma()
1255 dma_async_issue_pending(atmel_port->chan_rx); in atmel_prepare_rx_dma()
1261 atmel_port->use_dma_rx = false; in atmel_prepare_rx_dma()
1262 if (atmel_port->chan_rx) in atmel_prepare_rx_dma()
1269 struct atmel_uart_port *atmel_port = from_timer(atmel_port, t, in atmel_uart_timer_callback() local
1271 struct uart_port *port = &atmel_port->uart; in atmel_uart_timer_callback()
1273 if (!atomic_read(&atmel_port->tasklet_shutdown)) { in atmel_uart_timer_callback()
1274 tasklet_schedule(&atmel_port->tasklet_rx); in atmel_uart_timer_callback()
1275 mod_timer(&atmel_port->uart_timer, in atmel_uart_timer_callback()
1286 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_receive() local
1299 atmel_tasklet_schedule(atmel_port, in atmel_handle_receive()
1300 &atmel_port->tasklet_rx); in atmel_handle_receive()
1312 atmel_tasklet_schedule(atmel_port, in atmel_handle_receive()
1313 &atmel_port->tasklet_rx); in atmel_handle_receive()
1327 atmel_port->break_active = 0; in atmel_handle_receive()
1337 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_transmit() local
1339 if (pending & atmel_port->tx_done_mask) { in atmel_handle_transmit()
1341 atmel_port->tx_done_mask); in atmel_handle_transmit()
1344 if (atmel_port->hd_start_rx) { in atmel_handle_transmit()
1349 atmel_port->hd_start_rx = false; in atmel_handle_transmit()
1353 atmel_tasklet_schedule(atmel_port, &atmel_port->tasklet_tx); in atmel_handle_transmit()
1364 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_handle_status() local
1369 status_change = status ^ atmel_port->irq_status_prev; in atmel_handle_status()
1370 atmel_port->irq_status_prev = status; in atmel_handle_status()
1398 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_interrupt() local
1401 spin_lock(&atmel_port->lock_suspended); in atmel_interrupt()
1410 if (atmel_port->suspended) { in atmel_interrupt()
1411 atmel_port->pending |= pending; in atmel_interrupt()
1412 atmel_port->pending_status = status; in atmel_interrupt()
1423 spin_unlock(&atmel_port->lock_suspended); in atmel_interrupt()
1430 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_tx_pdc() local
1431 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx; in atmel_release_tx_pdc()
1444 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_tx_pdc() local
1446 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx; in atmel_tx_pdc()
1477 atmel_port->tx_done_mask); in atmel_tx_pdc()
1491 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_tx_pdc() local
1492 struct atmel_dma_buffer *pdc = &atmel_port->pdc_tx; in atmel_prepare_tx_pdc()
1508 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_ring() local
1509 struct circ_buf *ring = &atmel_port->rx_ring; in atmel_rx_from_ring()
1570 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_release_rx_pdc() local
1574 struct atmel_dma_buffer *pdc = &atmel_port->pdc_rx[i]; in atmel_release_rx_pdc()
1586 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_rx_from_pdc() local
1589 int rx_idx = atmel_port->pdc_rx_idx; in atmel_rx_from_pdc()
1598 pdc = &atmel_port->pdc_rx[rx_idx]; in atmel_rx_from_pdc()
1646 atmel_port->pdc_rx_idx = rx_idx; in atmel_rx_from_pdc()
1658 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_prepare_rx_pdc() local
1662 struct atmel_dma_buffer *pdc = &atmel_port->pdc_rx[i]; in atmel_prepare_rx_pdc()
1668 atmel_port->pdc_rx[0].dma_addr, in atmel_prepare_rx_pdc()
1671 kfree(atmel_port->pdc_rx[0].buf); in atmel_prepare_rx_pdc()
1673 atmel_port->use_pdc_rx = false; in atmel_prepare_rx_pdc()
1684 atmel_port->pdc_rx_idx = 0; 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()
1690 atmel_port->pdc_rx[1].dma_addr); in atmel_prepare_rx_pdc()
1701 struct atmel_uart_port *atmel_port = from_tasklet(atmel_port, t, in atmel_tasklet_rx_func() local
1703 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_rx_func()
1707 atmel_port->schedule_rx(port); in atmel_tasklet_rx_func()
1713 struct atmel_uart_port *atmel_port = from_tasklet(atmel_port, t, in atmel_tasklet_tx_func() local
1715 struct uart_port *port = &atmel_port->uart; in atmel_tasklet_tx_func()
1719 atmel_port->schedule_tx(port); in atmel_tasklet_tx_func()
1723 static void atmel_init_property(struct atmel_uart_port *atmel_port, in atmel_init_property() argument
1731 atmel_port->use_dma_rx = true; in atmel_init_property()
1732 atmel_port->use_pdc_rx = false; in atmel_init_property()
1734 atmel_port->use_dma_rx = false; in atmel_init_property()
1735 atmel_port->use_pdc_rx = true; in atmel_init_property()
1738 atmel_port->use_dma_rx = false; in atmel_init_property()
1739 atmel_port->use_pdc_rx = false; in atmel_init_property()
1744 atmel_port->use_dma_tx = true; in atmel_init_property()
1745 atmel_port->use_pdc_tx = false; in atmel_init_property()
1747 atmel_port->use_dma_tx = false; in atmel_init_property()
1748 atmel_port->use_pdc_tx = true; in atmel_init_property()
1751 atmel_port->use_dma_tx = false; in atmel_init_property()
1752 atmel_port->use_pdc_tx = false; in atmel_init_property()
1758 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_ops() local
1761 atmel_port->prepare_rx = &atmel_prepare_rx_dma; in atmel_set_ops()
1762 atmel_port->schedule_rx = &atmel_rx_from_dma; in atmel_set_ops()
1763 atmel_port->release_rx = &atmel_release_rx_dma; in atmel_set_ops()
1765 atmel_port->prepare_rx = &atmel_prepare_rx_pdc; in atmel_set_ops()
1766 atmel_port->schedule_rx = &atmel_rx_from_pdc; in atmel_set_ops()
1767 atmel_port->release_rx = &atmel_release_rx_pdc; in atmel_set_ops()
1769 atmel_port->prepare_rx = NULL; in atmel_set_ops()
1770 atmel_port->schedule_rx = &atmel_rx_from_ring; in atmel_set_ops()
1771 atmel_port->release_rx = NULL; in atmel_set_ops()
1775 atmel_port->prepare_tx = &atmel_prepare_tx_dma; in atmel_set_ops()
1776 atmel_port->schedule_tx = &atmel_tx_dma; in atmel_set_ops()
1777 atmel_port->release_tx = &atmel_release_tx_dma; in atmel_set_ops()
1779 atmel_port->prepare_tx = &atmel_prepare_tx_pdc; in atmel_set_ops()
1780 atmel_port->schedule_tx = &atmel_tx_pdc; in atmel_set_ops()
1781 atmel_port->release_tx = &atmel_release_tx_pdc; in atmel_set_ops()
1783 atmel_port->prepare_tx = NULL; in atmel_set_ops()
1784 atmel_port->schedule_tx = &atmel_tx_chars; in atmel_set_ops()
1785 atmel_port->release_tx = NULL; in atmel_set_ops()
1794 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_get_ip_name() local
1809 atmel_port->has_frac_baudrate = false; in atmel_get_ip_name()
1810 atmel_port->has_hw_timer = false; in atmel_get_ip_name()
1811 atmel_port->is_usart = false; in atmel_get_ip_name()
1815 atmel_port->has_hw_timer = true; in atmel_get_ip_name()
1816 atmel_port->rtor = ATMEL_UA_RTOR; in atmel_get_ip_name()
1819 atmel_port->has_frac_baudrate = true; in atmel_get_ip_name()
1820 atmel_port->has_hw_timer = true; in atmel_get_ip_name()
1821 atmel_port->is_usart = true; in atmel_get_ip_name()
1822 atmel_port->rtor = ATMEL_US_RTOR; in atmel_get_ip_name()
1828 atmel_port->fidi_min = 3; in atmel_get_ip_name()
1829 atmel_port->fidi_max = 65535; in atmel_get_ip_name()
1832 atmel_port->fidi_min = 3; in atmel_get_ip_name()
1833 atmel_port->fidi_max = 2047; in atmel_get_ip_name()
1836 atmel_port->fidi_min = 1; in atmel_get_ip_name()
1837 atmel_port->fidi_max = 2047; in atmel_get_ip_name()
1849 atmel_port->has_frac_baudrate = true; in atmel_get_ip_name()
1850 atmel_port->has_hw_timer = true; in atmel_get_ip_name()
1851 atmel_port->is_usart = true; in atmel_get_ip_name()
1852 atmel_port->rtor = ATMEL_US_RTOR; in atmel_get_ip_name()
1870 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_startup() local
1879 atmel_port->ms_irq_enabled = false; in atmel_startup()
1892 atomic_set(&atmel_port->tasklet_shutdown, 0); in atmel_startup()
1893 tasklet_setup(&atmel_port->tasklet_rx, atmel_tasklet_rx_func); in atmel_startup()
1894 tasklet_setup(&atmel_port->tasklet_tx, atmel_tasklet_tx_func); in atmel_startup()
1899 atmel_init_property(atmel_port, pdev); in atmel_startup()
1902 if (atmel_port->prepare_rx) { in atmel_startup()
1903 retval = atmel_port->prepare_rx(port); in atmel_startup()
1908 if (atmel_port->prepare_tx) { in atmel_startup()
1909 retval = atmel_port->prepare_tx(port); in atmel_startup()
1917 if (atmel_port->fifo_size) { in atmel_startup()
1931 if (atmel_port->rts_high && in atmel_startup()
1932 atmel_port->rts_low) in atmel_startup()
1934 ATMEL_US_RXFTHRES(atmel_port->rts_high) | in atmel_startup()
1935 ATMEL_US_RXFTHRES2(atmel_port->rts_low); in atmel_startup()
1941 atmel_port->irq_status_prev = atmel_uart_readl(port, ATMEL_US_CSR); in atmel_startup()
1949 atmel_port->tx_stopped = false; in atmel_startup()
1951 timer_setup(&atmel_port->uart_timer, atmel_uart_timer_callback, 0); in atmel_startup()
1955 if (!atmel_port->has_hw_timer) { in atmel_startup()
1956 mod_timer(&atmel_port->uart_timer, in atmel_startup()
1960 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1971 if (!atmel_port->has_hw_timer) { in atmel_startup()
1972 mod_timer(&atmel_port->uart_timer, in atmel_startup()
1976 atmel_uart_writel(port, atmel_port->rtor, in atmel_startup()
1997 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_flush_buffer() local
2001 atmel_port->pdc_tx.ofs = 0; in atmel_flush_buffer()
2007 atmel_port->tx_len = 0; in atmel_flush_buffer()
2015 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_shutdown() local
2024 atomic_inc(&atmel_port->tasklet_shutdown); in atmel_shutdown()
2030 del_timer_sync(&atmel_port->uart_timer); in atmel_shutdown()
2039 tasklet_kill(&atmel_port->tasklet_rx); in atmel_shutdown()
2040 tasklet_kill(&atmel_port->tasklet_tx); in atmel_shutdown()
2054 if (atmel_port->release_rx) in atmel_shutdown()
2055 atmel_port->release_rx(port); in atmel_shutdown()
2056 if (atmel_port->release_tx) in atmel_shutdown()
2057 atmel_port->release_tx(port); in atmel_shutdown()
2062 atmel_port->rx_ring.head = 0; in atmel_shutdown()
2063 atmel_port->rx_ring.tail = 0; in atmel_shutdown()
2079 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_pm() local
2087 clk_prepare_enable(atmel_port->clk); 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()
2101 clk_disable_unprepare(atmel_port->clk); in atmel_serial_pm()
2102 if (__clk_is_enabled(atmel_port->gclk)) in atmel_serial_pm()
2103 clk_disable_unprepare(atmel_port->gclk); in atmel_serial_pm()
2117 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_set_termios() local
2127 if (atmel_port->is_usart) in atmel_set_termios()
2212 atmel_port->tx_stopped = true; in atmel_set_termios()
2233 !mctrl_gpio_to_gpiod(atmel_port->gpios, UART_GPIO_CTS)) { in atmel_set_termios()
2271 if (atmel_port->has_frac_baudrate) { in atmel_set_termios()
2287 if (atmel_port->is_usart && cd > ATMEL_US_CD) { in atmel_set_termios()
2300 if (!atmel_port->has_frac_baudrate) { in atmel_set_termios()
2301 if (__clk_is_enabled(atmel_port->gclk)) in atmel_set_termios()
2302 clk_disable_unprepare(atmel_port->gclk); in atmel_set_termios()
2303 gclk_rate = clk_round_rate(atmel_port->gclk, 16 * baud); in atmel_set_termios()
2304 actual_baud = clk_get_rate(atmel_port->clk) / (16 * cd); in atmel_set_termios()
2307 clk_set_rate(atmel_port->gclk, 16 * baud); in atmel_set_termios()
2308 ret = clk_prepare_enable(atmel_port->gclk); in atmel_set_termios()
2312 if (atmel_port->is_usart) { in atmel_set_termios()
2361 atmel_port->tx_stopped = false; in atmel_set_termios()
2525 static int atmel_init_port(struct atmel_uart_port *atmel_port, in atmel_init_port() argument
2529 struct uart_port *port = &atmel_port->uart; in atmel_init_port()
2532 atmel_init_property(atmel_port, pdev); in atmel_init_port()
2547 memset(&atmel_port->rx_ring, 0, sizeof(atmel_port->rx_ring)); in atmel_init_port()
2553 port->uartclk = clk_get_rate(atmel_port->clk); in atmel_init_port()
2560 atmel_port->tx_done_mask = ATMEL_US_TXEMPTY; in atmel_init_port()
2563 atmel_port->tx_done_mask = ATMEL_US_ENDTX | ATMEL_US_TXBUFE; in atmel_init_port()
2565 atmel_port->tx_done_mask = ATMEL_US_TXRDY; in atmel_init_port()
2585 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_write() local
2594 ATMEL_US_RXRDY | atmel_port->tx_done_mask); in atmel_console_write()
2602 atmel_port->tx_stopped = false; in atmel_console_write()
2657 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_console_setup() local
2671 atmel_port->tx_stopped = false; in atmel_console_setup()
2745 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_suspend() local
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()
2762 atmel_port->rtor); 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()
2769 atmel_port->may_wakeup = device_may_wakeup(dev); in atmel_serial_suspend()
2773 spin_lock_irqsave(&atmel_port->lock_suspended, flags); in atmel_serial_suspend()
2774 atmel_port->suspended = true; in atmel_serial_suspend()
2775 spin_unlock_irqrestore(&atmel_port->lock_suspended, flags); in atmel_serial_suspend()
2787 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_resume() local
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()
2795 atmel_port->cache.rtor); in atmel_serial_resume()
2796 atmel_uart_writel(port, ATMEL_US_TTGR, atmel_port->cache.ttgr); in atmel_serial_resume()
2798 if (atmel_port->fifo_size) { in atmel_serial_resume()
2802 atmel_port->cache.fmr); in atmel_serial_resume()
2804 atmel_port->cache.fimr); in atmel_serial_resume()
2809 spin_lock_irqsave(&atmel_port->lock_suspended, flags); in atmel_serial_resume()
2810 if (atmel_port->pending) { 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()
2813 atmel_port->pending_status); in atmel_serial_resume()
2814 atmel_handle_transmit(port, atmel_port->pending); in atmel_serial_resume()
2815 atmel_port->pending = 0; in atmel_serial_resume()
2817 atmel_port->suspended = false; in atmel_serial_resume()
2818 spin_unlock_irqrestore(&atmel_port->lock_suspended, flags); in atmel_serial_resume()
2821 device_set_wakeup_enable(dev, atmel_port->may_wakeup); in atmel_serial_resume()
2826 static void atmel_serial_probe_fifos(struct atmel_uart_port *atmel_port, in atmel_serial_probe_fifos() argument
2829 atmel_port->fifo_size = 0; in atmel_serial_probe_fifos()
2830 atmel_port->rts_low = 0; in atmel_serial_probe_fifos()
2831 atmel_port->rts_high = 0; in atmel_serial_probe_fifos()
2835 &atmel_port->fifo_size)) in atmel_serial_probe_fifos()
2838 if (!atmel_port->fifo_size) in atmel_serial_probe_fifos()
2841 if (atmel_port->fifo_size < ATMEL_MIN_FIFO_SIZE) { in atmel_serial_probe_fifos()
2842 atmel_port->fifo_size = 0; in atmel_serial_probe_fifos()
2855 atmel_port->rts_high = max_t(int, atmel_port->fifo_size >> 1, in atmel_serial_probe_fifos()
2856 atmel_port->fifo_size - ATMEL_RTS_HIGH_OFFSET); in atmel_serial_probe_fifos()
2857 atmel_port->rts_low = max_t(int, atmel_port->fifo_size >> 2, in atmel_serial_probe_fifos()
2858 atmel_port->fifo_size - ATMEL_RTS_LOW_OFFSET); in atmel_serial_probe_fifos()
2861 atmel_port->fifo_size); in atmel_serial_probe_fifos()
2863 atmel_port->rts_high); in atmel_serial_probe_fifos()
2865 atmel_port->rts_low); in atmel_serial_probe_fifos()
2870 struct atmel_uart_port *atmel_port; in atmel_serial_probe() local
2904 atmel_port = &atmel_ports[ret]; in atmel_serial_probe()
2905 atmel_port->backup_imr = 0; in atmel_serial_probe()
2906 atmel_port->uart.line = ret; in atmel_serial_probe()
2907 atmel_port->uart.has_sysrq = IS_ENABLED(CONFIG_SERIAL_ATMEL_CONSOLE); in atmel_serial_probe()
2908 atmel_serial_probe_fifos(atmel_port, pdev); in atmel_serial_probe()
2910 atomic_set(&atmel_port->tasklet_shutdown, 0); in atmel_serial_probe()
2911 spin_lock_init(&atmel_port->lock_suspended); in atmel_serial_probe()
2913 atmel_port->clk = devm_clk_get(&pdev->dev, "usart"); in atmel_serial_probe()
2914 if (IS_ERR(atmel_port->clk)) { in atmel_serial_probe()
2915 ret = PTR_ERR(atmel_port->clk); in atmel_serial_probe()
2918 ret = clk_prepare_enable(atmel_port->clk); in atmel_serial_probe()
2922 atmel_port->gclk = devm_clk_get_optional(&pdev->dev, "gclk"); in atmel_serial_probe()
2923 if (IS_ERR(atmel_port->gclk)) { in atmel_serial_probe()
2924 ret = PTR_ERR(atmel_port->gclk); in atmel_serial_probe()
2928 ret = atmel_init_port(atmel_port, pdev); in atmel_serial_probe()
2932 atmel_port->gpios = mctrl_gpio_init(&atmel_port->uart, 0); in atmel_serial_probe()
2933 if (IS_ERR(atmel_port->gpios)) { in atmel_serial_probe()
2934 ret = PTR_ERR(atmel_port->gpios); in atmel_serial_probe()
2938 if (!atmel_use_pdc_rx(&atmel_port->uart)) { in atmel_serial_probe()
2943 atmel_port->rx_ring.buf = data; in atmel_serial_probe()
2946 rs485_enabled = atmel_port->uart.rs485.flags & SER_RS485_ENABLED; in atmel_serial_probe()
2948 ret = uart_add_one_port(&atmel_uart, &atmel_port->uart); in atmel_serial_probe()
2953 platform_set_drvdata(pdev, atmel_port); in atmel_serial_probe()
2956 atmel_uart_writel(&atmel_port->uart, ATMEL_US_MR, in atmel_serial_probe()
2958 atmel_uart_writel(&atmel_port->uart, ATMEL_US_CR, in atmel_serial_probe()
2965 atmel_get_ip_name(&atmel_port->uart); in atmel_serial_probe()
2971 clk_disable_unprepare(atmel_port->clk); in atmel_serial_probe()
2976 kfree(atmel_port->rx_ring.buf); in atmel_serial_probe()
2977 atmel_port->rx_ring.buf = NULL; in atmel_serial_probe()
2979 clk_disable_unprepare(atmel_port->clk); in atmel_serial_probe()
2980 clear_bit(atmel_port->uart.line, atmel_ports_in_use); in atmel_serial_probe()
2997 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); in atmel_serial_remove() local
2999 tasklet_kill(&atmel_port->tasklet_rx); in atmel_serial_remove()
3000 tasklet_kill(&atmel_port->tasklet_tx); in atmel_serial_remove()
3006 kfree(atmel_port->rx_ring.buf); in atmel_serial_remove()