[PATCH v4 1/5] serial: 8250_dw: select port setup through platform data

From: James Hilliard

Date: Tue Oct 27 2026 - 19:06:23 EST


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.

Replace skip_autocfg with the Octeon setup selection. On 64-bit builds,
Octeon continues to skip optional-register probing while retaining its DMA
setup; on 32-bit builds it retains the generic setup. Keep generic setup
for devices without matched platform data as well.

Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
---
drivers/tty/serial/8250/8250_dw.c | 44 +++++++++++++++++++++++++++++----------
1 file changed, 33 insertions(+), 11 deletions(-)

diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 9cbe076463e0..1351523f0c47 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;
+ void (*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,33 @@ static void dw8250_shutdown(struct uart_port *port)
d->no_int_count = 0;
}

+static void 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;
+
+ data->data.dma.rxconf.src_maxburst = p->fifosize / 4;
+ data->data.dma.txconf.dst_maxburst = p->fifosize / 4;
+ up->dma = &data->data.dma;
+}
+
+static void dw8250_setup(struct uart_port *p)
+{
+ dw8250_setup_port(p);
+ dw8250_setup_dma(p);
+}
+
+static void dw8250_octeon_setup(struct uart_port *p)
+{
+ if (!IS_ENABLED(CONFIG_64BIT))
+ dw8250_setup_port(p);
+ dw8250_setup_dma(p);
+}
+
static int dw8250_probe(struct platform_device *pdev)
{
struct uart_8250_port uart = {}, *up = &uart;
@@ -765,19 +791,14 @@ 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)
+ data->pdata->setup(p);
+ else
+ dw8250_setup(p);

/* 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 +881,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_octeon_setup,
};

static const struct dw8250_platform_data dw8250_armada_38x_data = {

--
2.53.0