Re: [PATCH v2 08/10] serial: ambarella: add Ambarella UART driver
Petr Mladek <[email protected]>
| Newsgroups | dev.linux.lists.soc,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-clk,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel,org.kernel.vger.linux-serial |
|---|---|
| Message-ID | <[email protected]> |
Added John Ogness into Cc.
Jiri asked me to look at the printk/nbcon related parts.
I am going to make just a quick look after I came back from vacation.
Maybe, the custom code won't be needed at all when the 8250
API is used in v3.
Anyway, please add me and John into Cc for v3, ...
On Thu 2026-08-06 17:34:16, Long Zhao wrote:
> Add an Ambarella UART driver with console support for early boot
> bring-up on CV75. Keep udelay() in wait_for_tx(); it runs under
> console/poll paths that may hold the port lock with IRQs disabled.
>
> --- /dev/null
> +++ b/drivers/tty/serial/ambarella_uart.c
[...]
> +static void serial_ambarella_console_putchar(struct uart_port *port,
> + unsigned char ch)
> +{
> + struct ambarella_uart_port *amb_port = to_ambarella_uart_port(port);
> +
> + serial_ambarella_putchar(port, ch);
> + amb_port->console_line_ended = (ch == '\n');
> +}
> +
> +static void serial_ambarella_console_device_lock(struct console *co,
> + unsigned long *flags)
> +{
> + __uart_port_lock_irqsave(&ambarella_port[co->index].port, flags);
> +}
> +
> +static void serial_ambarella_console_device_unlock(struct console *co,
> + unsigned long flags)
> +{
> + __uart_port_unlock_irqrestore(&ambarella_port[co->index].port, flags);
> +}
> +
> +static void serial_ambarella_console_write_atomic(struct console *co,
> + struct nbcon_write_context *wctxt)
> +{
> + struct ambarella_uart_port *amb_port = &ambarella_port[co->index];
> + struct uart_port *port = &amb_port->port;
> +
> + if (port->suspended)
> + return;
This should not be needed. The con->write*() callbacks should never get
called when the port is suspended. Otherwise, the message would get
skipped and never printed again.
I am not familiar with the low-level driver and suspend code.
I guess that you might need to implement suspend callbacks,
for example, see pl010_suspend()/resume() or
of_serial_suspend()/resume().
Note that the printk subsystem will stop writing to the console when
console_suspend() is called, see uart_suspend_port().
> + if (!nbcon_enter_unsafe(wctxt))
> + return;
We might need to store the control register and enable transmit here,
for example see pl011_console_write_atomic().
> +
> + if (!amb_port->console_line_ended)
> + uart_console_write(port, "\n", 1, serial_ambarella_console_putchar);
> + uart_console_write(port, wctxt->outbuf, wctxt->len,
> + serial_ambarella_console_putchar);
> + wait_for_tx(port);
We might need to restore the control register here so that
the serial port is usable for the original purpose again.
> + nbcon_exit_unsafe(wctxt);
> +}
> +
Best Regards,
Petr