static void efm32_uart_stop_tx(struct uart_port *port) { struct efm32_uart_port *efm_port = to_efm_port(port); u32 ien = efm32_uart_read32(efm_port, UARTn_IEN); efm32_uart_write32(efm_port, UARTn_CMD_TXDIS, UARTn_CMD); ien &= ~(UARTn_IF_TXC | UARTn_IF_TXBL); efm32_uart_write32(efm_port, ien, UARTn_IEN); }
static void efm32_uart_shutdown(struct uart_port *port) { struct efm32_uart_port *efm_port = to_efm_port(port); efm32_uart_write32(efm_port, 0, UARTn_IEN); free_irq(port->irq, efm_port); clk_disable(efm_port->clk); }
static unsigned int efm32_uart_tx_empty(struct uart_port *port) { struct efm32_uart_port *efm_port = to_efm_port(port); u32 status = efm32_uart_read32(efm_port, UARTn_STATUS); if (status & UARTn_STATUS_TXC) return TIOCSER_TEMT; else return 0; }
static void efm32_uart_start_tx(struct uart_port *port) { struct efm32_uart_port *efm_port = to_efm_port(port); u32 ien; efm32_uart_write32(efm_port, UARTn_IF_TXBL | UARTn_IF_TXC, UARTn_IFC); ien = efm32_uart_read32(efm_port, UARTn_IEN); efm32_uart_write32(efm_port, ien | UARTn_IF_TXBL | UARTn_IF_TXC, UARTn_IEN); efm32_uart_write32(efm_port, UARTn_CMD_TXEN, UARTn_CMD); efm32_uart_tx_chars(efm_port); }
static int efm32_uart_startup(struct uart_port *port) { struct efm32_uart_port *efm_port = to_efm_port(port); u32 location = 0; struct efm32_uart_pdata *pdata = dev_get_platdata(port->dev); int ret; if (pdata) location = UARTn_ROUTE_LOCATION(pdata->location); ret = clk_enable(efm_port->clk); if (ret) { efm_debug(efm_port, "failed to enable clk\n"); goto err_clk_enable; } port->uartclk = clk_get_rate(efm_port->clk); /* Enable pins at configured location */ efm32_uart_write32(efm_port, location | UARTn_ROUTE_RXPEN | UARTn_ROUTE_TXPEN, UARTn_ROUTE); ret = request_irq(port->irq, efm32_uart_rxirq, 0, DRIVER_NAME, efm_port); if (ret) { efm_debug(efm_port, "failed to register rxirq\n"); goto err_request_irq_rx; } /* disable all irqs */ efm32_uart_write32(efm_port, 0, UARTn_IEN); ret = request_irq(efm_port->txirq, efm32_uart_txirq, 0, DRIVER_NAME, efm_port); if (ret) { efm_debug(efm_port, "failed to register txirq\n"); free_irq(port->irq, efm_port); err_request_irq_rx: clk_disable(efm_port->clk); } else { efm32_uart_write32(efm_port, UARTn_IF_RXDATAV | UARTn_IF_RXOF, UARTn_IEN); efm32_uart_write32(efm_port, UARTn_CMD_RXEN, UARTn_CMD); } err_clk_enable: return ret; }
static void efm32_uart_stop_rx(struct uart_port *port) { struct efm32_uart_port *efm_port = to_efm_port(port); efm32_uart_write32(efm_port, UARTn_CMD_RXDIS, UARTn_CMD); }
} static void efm32_uart_shutdown(struct uart_port *port) { struct efm32_uart_port *efm_port = to_efm_port(port); efm32_uart_write32(efm_port, 0, UARTn_IEN); free_irq(port->irq, efm_port); clk_disable(efm_port->clk); } static void efm32_uart_set_termios(struct uart_port *port, struct ktermios *new, struct ktermios *old) { struct efm32_uart_port *efm_port = to_efm_port(port); unsigned long flags; unsigned baud; u32 clkdiv; u32 frame = 0; /* no modem control lines */ new->c_cflag &= ~(CRTSCTS | CMSPAR); baud = uart_get_baud_rate(port, new, old, DIV_ROUND_CLOSEST(port->uartclk, 16 * 8192), DIV_ROUND_CLOSEST(port->uartclk, 16)); switch (new->c_cflag & CSIZE) { case CS5: frame |= UARTn_FRAME_DATABITS(5);