Lines Matching refs:efm_port
85 #define efm_debug(efm_port, format, arg...) \ argument
86 dev_dbg(efm_port->port.dev, format, ##arg)
88 static void efm32_uart_write32(struct efm32_uart_port *efm_port, in efm32_uart_write32() argument
91 writel_relaxed(value, efm_port->port.membase + offset); in efm32_uart_write32()
94 static u32 efm32_uart_read32(struct efm32_uart_port *efm_port, in efm32_uart_read32() argument
97 return readl_relaxed(efm_port->port.membase + offset); in efm32_uart_read32()
102 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_tx_empty() local
103 u32 status = efm32_uart_read32(efm_port, UARTn_STATUS); in efm32_uart_tx_empty()
124 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_stop_tx() local
125 u32 ien = efm32_uart_read32(efm_port, UARTn_IEN); in efm32_uart_stop_tx()
127 efm32_uart_write32(efm_port, UARTn_CMD_TXDIS, UARTn_CMD); in efm32_uart_stop_tx()
129 efm32_uart_write32(efm_port, ien, UARTn_IEN); in efm32_uart_stop_tx()
132 static void efm32_uart_tx_chars(struct efm32_uart_port *efm_port) in efm32_uart_tx_chars() argument
134 struct uart_port *port = &efm_port->port; in efm32_uart_tx_chars()
137 while (efm32_uart_read32(efm_port, UARTn_STATUS) & in efm32_uart_tx_chars()
141 efm32_uart_write32(efm_port, port->x_char, in efm32_uart_tx_chars()
148 efm32_uart_write32(efm_port, xmit->buf[xmit->tail], in efm32_uart_tx_chars()
159 efm32_uart_read32(efm_port, UARTn_STATUS) & in efm32_uart_tx_chars()
166 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_start_tx() local
169 efm32_uart_write32(efm_port, in efm32_uart_start_tx()
171 ien = efm32_uart_read32(efm_port, UARTn_IEN); in efm32_uart_start_tx()
172 efm32_uart_write32(efm_port, in efm32_uart_start_tx()
174 efm32_uart_write32(efm_port, UARTn_CMD_TXEN, UARTn_CMD); in efm32_uart_start_tx()
176 efm32_uart_tx_chars(efm_port); in efm32_uart_start_tx()
181 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_stop_rx() local
183 efm32_uart_write32(efm_port, UARTn_CMD_RXDIS, UARTn_CMD); in efm32_uart_stop_rx()
191 static void efm32_uart_rx_chars(struct efm32_uart_port *efm_port) in efm32_uart_rx_chars() argument
193 struct uart_port *port = &efm_port->port; in efm32_uart_rx_chars()
195 while (efm32_uart_read32(efm_port, UARTn_STATUS) & in efm32_uart_rx_chars()
197 u32 rxdata = efm32_uart_read32(efm_port, UARTn_RXDATAX); in efm32_uart_rx_chars()
241 struct efm32_uart_port *efm_port = data; in efm32_uart_rxirq() local
242 u32 irqflag = efm32_uart_read32(efm_port, UARTn_IF); in efm32_uart_rxirq()
244 struct uart_port *port = &efm_port->port; in efm32_uart_rxirq()
250 efm32_uart_write32(efm_port, UARTn_IF_RXDATAV, UARTn_IFC); in efm32_uart_rxirq()
251 efm32_uart_rx_chars(efm_port); in efm32_uart_rxirq()
257 efm32_uart_write32(efm_port, UARTn_IF_RXOF, UARTn_IFC); in efm32_uart_rxirq()
273 struct efm32_uart_port *efm_port = data; in efm32_uart_txirq() local
274 u32 irqflag = efm32_uart_read32(efm_port, UARTn_IF); in efm32_uart_txirq()
278 efm32_uart_write32(efm_port, UARTn_IF_TXC, UARTn_IFC); in efm32_uart_txirq()
281 efm32_uart_tx_chars(efm_port); in efm32_uart_txirq()
289 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_startup() local
292 ret = clk_enable(efm_port->clk); in efm32_uart_startup()
294 efm_debug(efm_port, "failed to enable clk\n"); in efm32_uart_startup()
297 port->uartclk = clk_get_rate(efm_port->clk); in efm32_uart_startup()
300 efm32_uart_write32(efm_port, in efm32_uart_startup()
301 UARTn_ROUTE_LOCATION(efm_port->pdata.location) | in efm32_uart_startup()
306 DRIVER_NAME, efm_port); in efm32_uart_startup()
308 efm_debug(efm_port, "failed to register rxirq\n"); in efm32_uart_startup()
313 efm32_uart_write32(efm_port, 0, UARTn_IEN); in efm32_uart_startup()
315 ret = request_irq(efm_port->txirq, efm32_uart_txirq, 0, in efm32_uart_startup()
316 DRIVER_NAME, efm_port); in efm32_uart_startup()
318 efm_debug(efm_port, "failed to register txirq\n"); in efm32_uart_startup()
319 free_irq(port->irq, efm_port); in efm32_uart_startup()
322 clk_disable(efm_port->clk); in efm32_uart_startup()
324 efm32_uart_write32(efm_port, in efm32_uart_startup()
326 efm32_uart_write32(efm_port, UARTn_CMD_RXEN, UARTn_CMD); in efm32_uart_startup()
335 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_shutdown() local
337 efm32_uart_write32(efm_port, 0, UARTn_IEN); in efm32_uart_shutdown()
338 free_irq(port->irq, efm_port); in efm32_uart_shutdown()
340 clk_disable(efm_port->clk); in efm32_uart_shutdown()
346 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_set_termios() local
396 efm32_uart_write32(efm_port, in efm32_uart_set_termios()
415 efm32_uart_write32(efm_port, UARTn_CTRL_TXBIL, UARTn_CTRL); in efm32_uart_set_termios()
416 efm32_uart_write32(efm_port, frame, UARTn_FRAME); in efm32_uart_set_termios()
417 efm32_uart_write32(efm_port, clkdiv, UARTn_CLKDIV); in efm32_uart_set_termios()
419 efm32_uart_write32(efm_port, UARTn_CMD_TXEN | UARTn_CMD_RXEN, in efm32_uart_set_termios()
432 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_release_port() local
434 clk_unprepare(efm_port->clk); in efm32_uart_release_port()
435 clk_put(efm_port->clk); in efm32_uart_release_port()
441 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_request_port() local
445 if (!efm_port->port.membase) { in efm32_uart_request_port()
447 efm_debug(efm_port, "failed to remap\n"); in efm32_uart_request_port()
451 efm_port->clk = clk_get(port->dev, NULL); in efm32_uart_request_port()
452 if (IS_ERR(efm_port->clk)) { in efm32_uart_request_port()
453 ret = PTR_ERR(efm_port->clk); in efm32_uart_request_port()
454 efm_debug(efm_port, "failed to get clock\n"); in efm32_uart_request_port()
458 ret = clk_prepare(efm_port->clk); in efm32_uart_request_port()
460 clk_put(efm_port->clk); in efm32_uart_request_port()
511 struct efm32_uart_port *efm_port = to_efm_port(port); in efm32_uart_console_putchar() local
516 status = efm32_uart_read32(efm_port, UARTn_STATUS); in efm32_uart_console_putchar()
523 efm32_uart_write32(efm_port, ch, UARTn_TXDATA); in efm32_uart_console_putchar()
529 struct efm32_uart_port *efm_port = efm32_uart_ports[co->index]; in efm32_uart_console_write() local
530 u32 status = efm32_uart_read32(efm_port, UARTn_STATUS); in efm32_uart_console_write()
534 efm32_uart_write32(efm_port, UARTn_CMD_TXEN, UARTn_CMD); in efm32_uart_console_write()
536 uart_console_write(&efm_port->port, s, count, in efm32_uart_console_write()
541 u32 status = efm32_uart_read32(efm_port, UARTn_STATUS); in efm32_uart_console_write()
549 efm32_uart_write32(efm_port, UARTn_CMD_TXDIS, UARTn_CMD); in efm32_uart_console_write()
552 static void efm32_uart_console_get_options(struct efm32_uart_port *efm_port, in efm32_uart_console_get_options() argument
555 u32 ctrl = efm32_uart_read32(efm_port, UARTn_CTRL); in efm32_uart_console_get_options()
562 route = efm32_uart_read32(efm_port, UARTn_ROUTE); in efm32_uart_console_get_options()
567 clkdiv = efm32_uart_read32(efm_port, UARTn_CLKDIV); in efm32_uart_console_get_options()
569 *baud = DIV_ROUND_CLOSEST(4 * efm_port->port.uartclk, in efm32_uart_console_get_options()
572 frame = efm32_uart_read32(efm_port, UARTn_FRAME); in efm32_uart_console_get_options()
587 efm_debug(efm_port, "get_opts: options=%d%c%d\n", in efm32_uart_console_get_options()
593 struct efm32_uart_port *efm_port; in efm32_uart_console_setup() local
612 efm_port = efm32_uart_ports[co->index]; in efm32_uart_console_setup()
613 if (!efm_port) { in efm32_uart_console_setup()
618 ret = clk_prepare(efm_port->clk); in efm32_uart_console_setup()
620 dev_warn(efm_port->port.dev, in efm32_uart_console_setup()
625 efm_port->port.uartclk = clk_get_rate(efm_port->clk); in efm32_uart_console_setup()
630 efm32_uart_console_get_options(efm_port, in efm32_uart_console_setup()
633 return uart_set_options(&efm_port->port, co, baud, parity, bits, flow); in efm32_uart_console_setup()
661 struct efm32_uart_port *efm_port) in efm32_uart_probe_dt() argument
685 efm_debug(efm_port, "using location %u\n", location); in efm32_uart_probe_dt()
686 efm_port->pdata.location = location; in efm32_uart_probe_dt()
688 efm_debug(efm_port, "fall back to location 0\n"); in efm32_uart_probe_dt()
696 efm_port->port.line = ret; in efm32_uart_probe_dt()
704 struct efm32_uart_port *efm_port; in efm32_uart_probe() local
709 efm_port = kzalloc(sizeof(*efm_port), GFP_KERNEL); in efm32_uart_probe()
710 if (!efm_port) { in efm32_uart_probe()
734 efm_port->port.irq = ret; in efm32_uart_probe()
738 ret = efm_port->port.irq + 1; in efm32_uart_probe()
740 efm_port->txirq = ret; in efm32_uart_probe()
742 efm_port->port.dev = &pdev->dev; in efm32_uart_probe()
743 efm_port->port.mapbase = res->start; in efm32_uart_probe()
744 efm_port->port.type = PORT_EFMUART; in efm32_uart_probe()
745 efm_port->port.iotype = UPIO_MEM32; in efm32_uart_probe()
746 efm_port->port.fifosize = 2; in efm32_uart_probe()
747 efm_port->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_EFM32_UART_CONSOLE); in efm32_uart_probe()
748 efm_port->port.ops = &efm32_uart_pops; in efm32_uart_probe()
749 efm_port->port.flags = UPF_BOOT_AUTOCONF; in efm32_uart_probe()
751 ret = efm32_uart_probe_dt(pdev, efm_port); in efm32_uart_probe()
756 efm_port->port.line = pdev->id; in efm32_uart_probe()
759 efm_port->pdata = *pdata; in efm32_uart_probe()
763 line = efm_port->port.line; in efm32_uart_probe()
766 efm32_uart_ports[line] = efm_port; in efm32_uart_probe()
768 ret = uart_add_one_port(&efm32_uart_reg, &efm_port->port); in efm32_uart_probe()
778 kfree(efm_port); in efm32_uart_probe()
780 platform_set_drvdata(pdev, efm_port); in efm32_uart_probe()
789 struct efm32_uart_port *efm_port = platform_get_drvdata(pdev); in efm32_uart_remove() local
790 unsigned int line = efm_port->port.line; in efm32_uart_remove()
792 uart_remove_one_port(&efm32_uart_reg, &efm_port->port); in efm32_uart_remove()
797 kfree(efm_port); in efm32_uart_remove()