[PATCH v5 1/8] serial: 8250_dw: select port setup through platform data
Ilpo Järvinen
ilpo.jarvinen at linux.intel.com
Fri Oct 30 02:28:09 PDT 2026
On Thu, 29 Oct 2026, James Hilliard wrote:
> Select feature discovery and DMA attachment through a platform-data setup
> callback. The generic callback probes the optional registers and attaches
> DMA when a FIFO size is available. Integrations with a fixed configuration
> can supply their own setup before the port is registered. Allow setup to
> return an error so integrations can reject invalid configuration before
> registration.
>
> Replace skip_autocfg with the Octeon setup selection. Octeon is a 64-bit
> platform and continues to skip optional-register probing while retaining
> its DMA setup. Select the DMA setup helper directly for this integration.
> Keep generic setup for devices without matched platform data as well.
>
> Signed-off-by: James Hilliard <james.hilliard1 at gmail.com>
> ---
> drivers/tty/serial/8250/8250_dw.c | 41 ++++++++++++++++++++++++++++-----------
> 1 file changed, 30 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
> index 9cbe076463e0..a546cf2de7b6 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
> @@ -64,6 +64,7 @@ struct dw8250_platform_data {
> u8 usr_reg;
> u32 cpr_value;
> unsigned int quirks;
> + int (*setup)(struct uart_port *p);
> };
>
> struct dw8250_data {
> @@ -76,7 +77,6 @@ struct dw8250_data {
> struct clk *pclk;
> struct reset_control *rst;
>
> - unsigned int skip_autocfg:1;
> unsigned int uart_16550_compatible:1;
> unsigned int in_idle:1;
>
> @@ -596,7 +596,6 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
> p->serial_out = dw8250_serial_outq;
> p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
> p->type = PORT_OCTEON;
> - data->skip_autocfg = true;
> }
> #endif
>
> @@ -631,6 +630,28 @@ static void dw8250_shutdown(struct uart_port *port)
> d->no_int_count = 0;
> }
>
> +static int dw8250_setup_dma(struct uart_port *p)
> +{
> + struct dw8250_data *data = to_dw8250_data(p->private_data);
> + struct uart_8250_port *up = up_to_u8250p(p);
> +
> + /* DMA setup requires a FIFO */
> + if (!p->fifosize)
> + return 0;
> +
> + data->data.dma.rxconf.src_maxburst = p->fifosize / 4;
> + data->data.dma.txconf.dst_maxburst = p->fifosize / 4;
> + up->dma = &data->data.dma;
> +
> + return 0;
> +}
> +
> +static int dw8250_setup(struct uart_port *p)
> +{
> + dw8250_setup_port(p);
> + return dw8250_setup_dma(p);
> +}
> +
> static int dw8250_probe(struct platform_device *pdev)
> {
> struct uart_8250_port uart = {}, *up = &uart;
> @@ -765,19 +786,16 @@ static int dw8250_probe(struct platform_device *pdev)
>
> dw8250_setup_dma_filter(p, data);
>
> - if (!data->skip_autocfg)
> - dw8250_setup_port(p);
> + if (data->pdata && data->pdata->setup)
> + err = data->pdata->setup(p);
> + else
> + err = dw8250_setup(p);
> + if (err)
> + return err;
>
> /* Use the BUSY-safe sequence for both integer and fractional divisors. */
> p->set_divisor = dw8250_set_divisor;
>
> - /* If we have a valid fifosize, try hooking up DMA */
> - if (p->fifosize) {
> - data->data.dma.rxconf.src_maxburst = p->fifosize / 4;
> - data->data.dma.txconf.dst_maxburst = p->fifosize / 4;
> - up->dma = &data->data.dma;
> - }
> -
> data->data.uport = serial8250_register_8250_port(up);
> if (IS_ERR(data->data.uport))
> return PTR_ERR(data->data.uport);
> @@ -860,6 +878,7 @@ static const struct dw8250_platform_data dw8250_dw_apb = {
> static const struct dw8250_platform_data dw8250_octeon_3860_data = {
> .usr_reg = OCTEON_UART_USR,
> .quirks = DW_UART_QUIRK_OCTEON,
> + .setup = dw8250_setup_dma,
> };
>
> static const struct dw8250_platform_data dw8250_armada_38x_data = {
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen at linux.intel.com>
--
i.
More information about the linux-arm-kernel
mailing list