xref: /openbmc/linux/drivers/tty/serial/8250/8250_dw.c (revision 240e6d25)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Synopsys DesignWare 8250 driver.
4  *
5  * Copyright 2011 Picochip, Jamie Iles.
6  * Copyright 2013 Intel Corporation
7  *
8  * The Synopsys DesignWare 8250 has an extra feature whereby it detects if the
9  * LCR is written whilst busy.  If it is, then a busy detect interrupt is
10  * raised, the LCR needs to be rewritten and the uart status register read.
11  */
12 #include <linux/delay.h>
13 #include <linux/device.h>
14 #include <linux/io.h>
15 #include <linux/module.h>
16 #include <linux/serial_8250.h>
17 #include <linux/serial_reg.h>
18 #include <linux/of.h>
19 #include <linux/of_irq.h>
20 #include <linux/of_platform.h>
21 #include <linux/platform_device.h>
22 #include <linux/workqueue.h>
23 #include <linux/notifier.h>
24 #include <linux/slab.h>
25 #include <linux/acpi.h>
26 #include <linux/clk.h>
27 #include <linux/reset.h>
28 #include <linux/pm_runtime.h>
29 
30 #include <asm/byteorder.h>
31 
32 #include "8250_dwlib.h"
33 
34 /* Offsets for the DesignWare specific registers */
35 #define DW_UART_USR	0x1f /* UART Status Register */
36 
37 /* DesignWare specific register fields */
38 #define DW_UART_MCR_SIRE		BIT(6)
39 
40 struct dw8250_data {
41 	struct dw8250_port_data	data;
42 
43 	u8			usr_reg;
44 	int			msr_mask_on;
45 	int			msr_mask_off;
46 	struct clk		*clk;
47 	struct clk		*pclk;
48 	struct notifier_block	clk_notifier;
49 	struct work_struct	clk_work;
50 	struct reset_control	*rst;
51 
52 	unsigned int		skip_autocfg:1;
53 	unsigned int		uart_16550_compatible:1;
54 };
55 
56 static inline struct dw8250_data *to_dw8250_data(struct dw8250_port_data *data)
57 {
58 	return container_of(data, struct dw8250_data, data);
59 }
60 
61 static inline struct dw8250_data *clk_to_dw8250_data(struct notifier_block *nb)
62 {
63 	return container_of(nb, struct dw8250_data, clk_notifier);
64 }
65 
66 static inline struct dw8250_data *work_to_dw8250_data(struct work_struct *work)
67 {
68 	return container_of(work, struct dw8250_data, clk_work);
69 }
70 
71 static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
72 {
73 	struct dw8250_data *d = to_dw8250_data(p->private_data);
74 
75 	/* Override any modem control signals if needed */
76 	if (offset == UART_MSR) {
77 		value |= d->msr_mask_on;
78 		value &= ~d->msr_mask_off;
79 	}
80 
81 	return value;
82 }
83 
84 static void dw8250_force_idle(struct uart_port *p)
85 {
86 	struct uart_8250_port *up = up_to_u8250p(p);
87 
88 	serial8250_clear_and_reinit_fifos(up);
89 	(void)p->serial_in(p, UART_RX);
90 }
91 
92 static void dw8250_check_lcr(struct uart_port *p, int value)
93 {
94 	void __iomem *offset = p->membase + (UART_LCR << p->regshift);
95 	int tries = 1000;
96 
97 	/* Make sure LCR write wasn't ignored */
98 	while (tries--) {
99 		unsigned int lcr = p->serial_in(p, UART_LCR);
100 
101 		if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR))
102 			return;
103 
104 		dw8250_force_idle(p);
105 
106 #ifdef CONFIG_64BIT
107 		if (p->type == PORT_OCTEON)
108 			__raw_writeq(value & 0xff, offset);
109 		else
110 #endif
111 		if (p->iotype == UPIO_MEM32)
112 			writel(value, offset);
113 		else if (p->iotype == UPIO_MEM32BE)
114 			iowrite32be(value, offset);
115 		else
116 			writeb(value, offset);
117 	}
118 	/*
119 	 * FIXME: this deadlocks if port->lock is already held
120 	 * dev_err(p->dev, "Couldn't set LCR to %d\n", value);
121 	 */
122 }
123 
124 /* Returns once the transmitter is empty or we run out of retries */
125 static void dw8250_tx_wait_empty(struct uart_port *p)
126 {
127 	unsigned int tries = 20000;
128 	unsigned int delay_threshold = tries - 1000;
129 	unsigned int lsr;
130 
131 	while (tries--) {
132 		lsr = readb (p->membase + (UART_LSR << p->regshift));
133 		if (lsr & UART_LSR_TEMT)
134 			break;
135 
136 		/* The device is first given a chance to empty without delay,
137 		 * to avoid slowdowns at high bitrates. If after 1000 tries
138 		 * the buffer has still not emptied, allow more time for low-
139 		 * speed links. */
140 		if (tries < delay_threshold)
141 			udelay (1);
142 	}
143 }
144 
145 static void dw8250_serial_out38x(struct uart_port *p, int offset, int value)
146 {
147 	struct dw8250_data *d = to_dw8250_data(p->private_data);
148 
149 	/* Allow the TX to drain before we reconfigure */
150 	if (offset == UART_LCR)
151 		dw8250_tx_wait_empty(p);
152 
153 	writeb(value, p->membase + (offset << p->regshift));
154 
155 	if (offset == UART_LCR && !d->uart_16550_compatible)
156 		dw8250_check_lcr(p, value);
157 }
158 
159 
160 static void dw8250_serial_out(struct uart_port *p, int offset, int value)
161 {
162 	struct dw8250_data *d = to_dw8250_data(p->private_data);
163 
164 	writeb(value, p->membase + (offset << p->regshift));
165 
166 	if (offset == UART_LCR && !d->uart_16550_compatible)
167 		dw8250_check_lcr(p, value);
168 }
169 
170 static unsigned int dw8250_serial_in(struct uart_port *p, int offset)
171 {
172 	unsigned int value = readb(p->membase + (offset << p->regshift));
173 
174 	return dw8250_modify_msr(p, offset, value);
175 }
176 
177 #ifdef CONFIG_64BIT
178 static unsigned int dw8250_serial_inq(struct uart_port *p, int offset)
179 {
180 	unsigned int value;
181 
182 	value = (u8)__raw_readq(p->membase + (offset << p->regshift));
183 
184 	return dw8250_modify_msr(p, offset, value);
185 }
186 
187 static void dw8250_serial_outq(struct uart_port *p, int offset, int value)
188 {
189 	struct dw8250_data *d = to_dw8250_data(p->private_data);
190 
191 	value &= 0xff;
192 	__raw_writeq(value, p->membase + (offset << p->regshift));
193 	/* Read back to ensure register write ordering. */
194 	__raw_readq(p->membase + (UART_LCR << p->regshift));
195 
196 	if (offset == UART_LCR && !d->uart_16550_compatible)
197 		dw8250_check_lcr(p, value);
198 }
199 #endif /* CONFIG_64BIT */
200 
201 static void dw8250_serial_out32(struct uart_port *p, int offset, int value)
202 {
203 	struct dw8250_data *d = to_dw8250_data(p->private_data);
204 
205 	writel(value, p->membase + (offset << p->regshift));
206 
207 	if (offset == UART_LCR && !d->uart_16550_compatible)
208 		dw8250_check_lcr(p, value);
209 }
210 
211 static unsigned int dw8250_serial_in32(struct uart_port *p, int offset)
212 {
213 	unsigned int value = readl(p->membase + (offset << p->regshift));
214 
215 	return dw8250_modify_msr(p, offset, value);
216 }
217 
218 static void dw8250_serial_out32be(struct uart_port *p, int offset, int value)
219 {
220 	struct dw8250_data *d = to_dw8250_data(p->private_data);
221 
222 	iowrite32be(value, p->membase + (offset << p->regshift));
223 
224 	if (offset == UART_LCR && !d->uart_16550_compatible)
225 		dw8250_check_lcr(p, value);
226 }
227 
228 static unsigned int dw8250_serial_in32be(struct uart_port *p, int offset)
229 {
230        unsigned int value = ioread32be(p->membase + (offset << p->regshift));
231 
232        return dw8250_modify_msr(p, offset, value);
233 }
234 
235 
236 static int dw8250_handle_irq(struct uart_port *p)
237 {
238 	struct uart_8250_port *up = up_to_u8250p(p);
239 	struct dw8250_data *d = to_dw8250_data(p->private_data);
240 	unsigned int iir = p->serial_in(p, UART_IIR);
241 	unsigned int status;
242 	unsigned long flags;
243 
244 	/*
245 	 * There are ways to get Designware-based UARTs into a state where
246 	 * they are asserting UART_IIR_RX_TIMEOUT but there is no actual
247 	 * data available.  If we see such a case then we'll do a bogus
248 	 * read.  If we don't do this then the "RX TIMEOUT" interrupt will
249 	 * fire forever.
250 	 *
251 	 * This problem has only been observed so far when not in DMA mode
252 	 * so we limit the workaround only to non-DMA mode.
253 	 */
254 	if (!up->dma && ((iir & 0x3f) == UART_IIR_RX_TIMEOUT)) {
255 		spin_lock_irqsave(&p->lock, flags);
256 		status = p->serial_in(p, UART_LSR);
257 
258 		if (!(status & (UART_LSR_DR | UART_LSR_BI)))
259 			(void) p->serial_in(p, UART_RX);
260 
261 		spin_unlock_irqrestore(&p->lock, flags);
262 	}
263 
264 	if (serial8250_handle_irq(p, iir))
265 		return 1;
266 
267 	if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) {
268 		/* Clear the USR */
269 		(void)p->serial_in(p, d->usr_reg);
270 
271 		return 1;
272 	}
273 
274 	return 0;
275 }
276 
277 static void dw8250_clk_work_cb(struct work_struct *work)
278 {
279 	struct dw8250_data *d = work_to_dw8250_data(work);
280 	struct uart_8250_port *up;
281 	unsigned long rate;
282 
283 	rate = clk_get_rate(d->clk);
284 	if (rate <= 0)
285 		return;
286 
287 	up = serial8250_get_port(d->data.line);
288 
289 	serial8250_update_uartclk(&up->port, rate);
290 }
291 
292 static int dw8250_clk_notifier_cb(struct notifier_block *nb,
293 				  unsigned long event, void *data)
294 {
295 	struct dw8250_data *d = clk_to_dw8250_data(nb);
296 
297 	/*
298 	 * We have no choice but to defer the uartclk update due to two
299 	 * deadlocks. First one is caused by a recursive mutex lock which
300 	 * happens when clk_set_rate() is called from dw8250_set_termios().
301 	 * Second deadlock is more tricky and is caused by an inverted order of
302 	 * the clk and tty-port mutexes lock. It happens if clock rate change
303 	 * is requested asynchronously while set_termios() is executed between
304 	 * tty-port mutex lock and clk_set_rate() function invocation and
305 	 * vise-versa. Anyway if we didn't have the reference clock alteration
306 	 * in the dw8250_set_termios() method we wouldn't have needed this
307 	 * deferred event handling complication.
308 	 */
309 	if (event == POST_RATE_CHANGE) {
310 		queue_work(system_unbound_wq, &d->clk_work);
311 		return NOTIFY_OK;
312 	}
313 
314 	return NOTIFY_DONE;
315 }
316 
317 static void
318 dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old)
319 {
320 	if (!state)
321 		pm_runtime_get_sync(port->dev);
322 
323 	serial8250_do_pm(port, state, old);
324 
325 	if (state)
326 		pm_runtime_put_sync_suspend(port->dev);
327 }
328 
329 static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios,
330 			       struct ktermios *old)
331 {
332 	unsigned long newrate = tty_termios_baud_rate(termios) * 16;
333 	struct dw8250_data *d = to_dw8250_data(p->private_data);
334 	long rate;
335 	int ret;
336 
337 	clk_disable_unprepare(d->clk);
338 	rate = clk_round_rate(d->clk, newrate);
339 	if (rate > 0) {
340 		/*
341 		 * Note that any clock-notifer worker will block in
342 		 * serial8250_update_uartclk() until we are done.
343 		 */
344 		ret = clk_set_rate(d->clk, newrate);
345 		if (!ret)
346 			p->uartclk = rate;
347 	}
348 	clk_prepare_enable(d->clk);
349 
350 	dw8250_do_set_termios(p, termios, old);
351 }
352 
353 static void dw8250_set_ldisc(struct uart_port *p, struct ktermios *termios)
354 {
355 	struct uart_8250_port *up = up_to_u8250p(p);
356 	unsigned int mcr = p->serial_in(p, UART_MCR);
357 
358 	if (up->capabilities & UART_CAP_IRDA) {
359 		if (termios->c_line == N_IRDA)
360 			mcr |= DW_UART_MCR_SIRE;
361 		else
362 			mcr &= ~DW_UART_MCR_SIRE;
363 
364 		p->serial_out(p, UART_MCR, mcr);
365 	}
366 	serial8250_do_set_ldisc(p, termios);
367 }
368 
369 /*
370  * dw8250_fallback_dma_filter will prevent the UART from getting just any free
371  * channel on platforms that have DMA engines, but don't have any channels
372  * assigned to the UART.
373  *
374  * REVISIT: This is a work around for limitation in the DMA Engine API. Once the
375  * core problem is fixed, this function is no longer needed.
376  */
377 static bool dw8250_fallback_dma_filter(struct dma_chan *chan, void *param)
378 {
379 	return false;
380 }
381 
382 static bool dw8250_idma_filter(struct dma_chan *chan, void *param)
383 {
384 	return param == chan->device->dev;
385 }
386 
387 static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
388 {
389 	struct device_node *np = p->dev->of_node;
390 
391 	if (np) {
392 		int id;
393 
394 		/* get index of serial line, if found in DT aliases */
395 		id = of_alias_get_id(np, "serial");
396 		if (id >= 0)
397 			p->line = id;
398 #ifdef CONFIG_64BIT
399 		if (of_device_is_compatible(np, "cavium,octeon-3860-uart")) {
400 			p->serial_in = dw8250_serial_inq;
401 			p->serial_out = dw8250_serial_outq;
402 			p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
403 			p->type = PORT_OCTEON;
404 			data->usr_reg = 0x27;
405 			data->skip_autocfg = true;
406 		}
407 #endif
408 
409 		if (of_device_is_big_endian(np)) {
410 			p->iotype = UPIO_MEM32BE;
411 			p->serial_in = dw8250_serial_in32be;
412 			p->serial_out = dw8250_serial_out32be;
413 		}
414 
415 		if (of_device_is_compatible(np, "marvell,armada-38x-uart"))
416 			p->serial_out = dw8250_serial_out38x;
417 
418 	} else if (acpi_dev_present("APMC0D08", NULL, -1)) {
419 		p->iotype = UPIO_MEM32;
420 		p->regshift = 2;
421 		p->serial_in = dw8250_serial_in32;
422 		data->uart_16550_compatible = true;
423 	}
424 
425 	/* Platforms with iDMA 64-bit */
426 	if (platform_get_resource_byname(to_platform_device(p->dev),
427 					 IORESOURCE_MEM, "lpss_priv")) {
428 		data->data.dma.rx_param = p->dev->parent;
429 		data->data.dma.tx_param = p->dev->parent;
430 		data->data.dma.fn = dw8250_idma_filter;
431 	}
432 }
433 
434 static int dw8250_probe(struct platform_device *pdev)
435 {
436 	struct uart_8250_port uart = {}, *up = &uart;
437 	struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
438 	struct uart_port *p = &up->port;
439 	struct device *dev = &pdev->dev;
440 	struct dw8250_data *data;
441 	int irq;
442 	int err;
443 	u32 val;
444 
445 	if (!regs) {
446 		dev_err(dev, "no registers defined\n");
447 		return -EINVAL;
448 	}
449 
450 	irq = platform_get_irq(pdev, 0);
451 	if (irq < 0)
452 		return irq;
453 
454 	spin_lock_init(&p->lock);
455 	p->mapbase	= regs->start;
456 	p->irq		= irq;
457 	p->handle_irq	= dw8250_handle_irq;
458 	p->pm		= dw8250_do_pm;
459 	p->type		= PORT_8250;
460 	p->flags	= UPF_SHARE_IRQ | UPF_FIXED_PORT;
461 	p->dev		= dev;
462 	p->iotype	= UPIO_MEM;
463 	p->serial_in	= dw8250_serial_in;
464 	p->serial_out	= dw8250_serial_out;
465 	p->set_ldisc	= dw8250_set_ldisc;
466 	p->set_termios	= dw8250_set_termios;
467 
468 	p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
469 	if (!p->membase)
470 		return -ENOMEM;
471 
472 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
473 	if (!data)
474 		return -ENOMEM;
475 
476 	data->data.dma.fn = dw8250_fallback_dma_filter;
477 	data->usr_reg = DW_UART_USR;
478 	p->private_data = &data->data;
479 
480 	data->uart_16550_compatible = device_property_read_bool(dev,
481 						"snps,uart-16550-compatible");
482 
483 	err = device_property_read_u32(dev, "reg-shift", &val);
484 	if (!err)
485 		p->regshift = val;
486 
487 	err = device_property_read_u32(dev, "reg-io-width", &val);
488 	if (!err && val == 4) {
489 		p->iotype = UPIO_MEM32;
490 		p->serial_in = dw8250_serial_in32;
491 		p->serial_out = dw8250_serial_out32;
492 	}
493 
494 	if (device_property_read_bool(dev, "dcd-override")) {
495 		/* Always report DCD as active */
496 		data->msr_mask_on |= UART_MSR_DCD;
497 		data->msr_mask_off |= UART_MSR_DDCD;
498 	}
499 
500 	if (device_property_read_bool(dev, "dsr-override")) {
501 		/* Always report DSR as active */
502 		data->msr_mask_on |= UART_MSR_DSR;
503 		data->msr_mask_off |= UART_MSR_DDSR;
504 	}
505 
506 	if (device_property_read_bool(dev, "cts-override")) {
507 		/* Always report CTS as active */
508 		data->msr_mask_on |= UART_MSR_CTS;
509 		data->msr_mask_off |= UART_MSR_DCTS;
510 	}
511 
512 	if (device_property_read_bool(dev, "ri-override")) {
513 		/* Always report Ring indicator as inactive */
514 		data->msr_mask_off |= UART_MSR_RI;
515 		data->msr_mask_off |= UART_MSR_TERI;
516 	}
517 
518 	/* Always ask for fixed clock rate from a property. */
519 	device_property_read_u32(dev, "clock-frequency", &p->uartclk);
520 
521 	/* If there is separate baudclk, get the rate from it. */
522 	data->clk = devm_clk_get_optional(dev, "baudclk");
523 	if (data->clk == NULL)
524 		data->clk = devm_clk_get_optional(dev, NULL);
525 	if (IS_ERR(data->clk))
526 		return PTR_ERR(data->clk);
527 
528 	INIT_WORK(&data->clk_work, dw8250_clk_work_cb);
529 	data->clk_notifier.notifier_call = dw8250_clk_notifier_cb;
530 
531 	err = clk_prepare_enable(data->clk);
532 	if (err)
533 		dev_warn(dev, "could not enable optional baudclk: %d\n", err);
534 
535 	if (data->clk)
536 		p->uartclk = clk_get_rate(data->clk);
537 
538 	/* If no clock rate is defined, fail. */
539 	if (!p->uartclk) {
540 		dev_err(dev, "clock rate not defined\n");
541 		err = -EINVAL;
542 		goto err_clk;
543 	}
544 
545 	data->pclk = devm_clk_get_optional(dev, "apb_pclk");
546 	if (IS_ERR(data->pclk)) {
547 		err = PTR_ERR(data->pclk);
548 		goto err_clk;
549 	}
550 
551 	err = clk_prepare_enable(data->pclk);
552 	if (err) {
553 		dev_err(dev, "could not enable apb_pclk\n");
554 		goto err_clk;
555 	}
556 
557 	data->rst = devm_reset_control_get_optional_exclusive(dev, NULL);
558 	if (IS_ERR(data->rst)) {
559 		err = PTR_ERR(data->rst);
560 		goto err_pclk;
561 	}
562 	reset_control_deassert(data->rst);
563 
564 	dw8250_quirks(p, data);
565 
566 	/* If the Busy Functionality is not implemented, don't handle it */
567 	if (data->uart_16550_compatible)
568 		p->handle_irq = NULL;
569 
570 	if (!data->skip_autocfg)
571 		dw8250_setup_port(p);
572 
573 	/* If we have a valid fifosize, try hooking up DMA */
574 	if (p->fifosize) {
575 		data->data.dma.rxconf.src_maxburst = p->fifosize / 4;
576 		data->data.dma.txconf.dst_maxburst = p->fifosize / 4;
577 		up->dma = &data->data.dma;
578 	}
579 
580 	data->data.line = serial8250_register_8250_port(up);
581 	if (data->data.line < 0) {
582 		err = data->data.line;
583 		goto err_reset;
584 	}
585 
586 	/*
587 	 * Some platforms may provide a reference clock shared between several
588 	 * devices. In this case any clock state change must be known to the
589 	 * UART port at least post factum.
590 	 */
591 	if (data->clk) {
592 		err = clk_notifier_register(data->clk, &data->clk_notifier);
593 		if (err)
594 			dev_warn(p->dev, "Failed to set the clock notifier\n");
595 		else
596 			queue_work(system_unbound_wq, &data->clk_work);
597 	}
598 
599 	platform_set_drvdata(pdev, data);
600 
601 	pm_runtime_set_active(dev);
602 	pm_runtime_enable(dev);
603 
604 	return 0;
605 
606 err_reset:
607 	reset_control_assert(data->rst);
608 
609 err_pclk:
610 	clk_disable_unprepare(data->pclk);
611 
612 err_clk:
613 	clk_disable_unprepare(data->clk);
614 
615 	return err;
616 }
617 
618 static int dw8250_remove(struct platform_device *pdev)
619 {
620 	struct dw8250_data *data = platform_get_drvdata(pdev);
621 	struct device *dev = &pdev->dev;
622 
623 	pm_runtime_get_sync(dev);
624 
625 	if (data->clk) {
626 		clk_notifier_unregister(data->clk, &data->clk_notifier);
627 
628 		flush_work(&data->clk_work);
629 	}
630 
631 	serial8250_unregister_port(data->data.line);
632 
633 	reset_control_assert(data->rst);
634 
635 	clk_disable_unprepare(data->pclk);
636 
637 	clk_disable_unprepare(data->clk);
638 
639 	pm_runtime_disable(dev);
640 	pm_runtime_put_noidle(dev);
641 
642 	return 0;
643 }
644 
645 #ifdef CONFIG_PM_SLEEP
646 static int dw8250_suspend(struct device *dev)
647 {
648 	struct dw8250_data *data = dev_get_drvdata(dev);
649 
650 	serial8250_suspend_port(data->data.line);
651 
652 	return 0;
653 }
654 
655 static int dw8250_resume(struct device *dev)
656 {
657 	struct dw8250_data *data = dev_get_drvdata(dev);
658 
659 	serial8250_resume_port(data->data.line);
660 
661 	return 0;
662 }
663 #endif /* CONFIG_PM_SLEEP */
664 
665 #ifdef CONFIG_PM
666 static int dw8250_runtime_suspend(struct device *dev)
667 {
668 	struct dw8250_data *data = dev_get_drvdata(dev);
669 
670 	clk_disable_unprepare(data->clk);
671 
672 	clk_disable_unprepare(data->pclk);
673 
674 	return 0;
675 }
676 
677 static int dw8250_runtime_resume(struct device *dev)
678 {
679 	struct dw8250_data *data = dev_get_drvdata(dev);
680 
681 	clk_prepare_enable(data->pclk);
682 
683 	clk_prepare_enable(data->clk);
684 
685 	return 0;
686 }
687 #endif
688 
689 static const struct dev_pm_ops dw8250_pm_ops = {
690 	SET_SYSTEM_SLEEP_PM_OPS(dw8250_suspend, dw8250_resume)
691 	SET_RUNTIME_PM_OPS(dw8250_runtime_suspend, dw8250_runtime_resume, NULL)
692 };
693 
694 static const struct of_device_id dw8250_of_match[] = {
695 	{ .compatible = "snps,dw-apb-uart" },
696 	{ .compatible = "cavium,octeon-3860-uart" },
697 	{ .compatible = "marvell,armada-38x-uart" },
698 	{ .compatible = "renesas,rzn1-uart" },
699 	{ /* Sentinel */ }
700 };
701 MODULE_DEVICE_TABLE(of, dw8250_of_match);
702 
703 static const struct acpi_device_id dw8250_acpi_match[] = {
704 	{ "INT33C4", 0 },
705 	{ "INT33C5", 0 },
706 	{ "INT3434", 0 },
707 	{ "INT3435", 0 },
708 	{ "80860F0A", 0 },
709 	{ "8086228A", 0 },
710 	{ "APMC0D08", 0},
711 	{ "AMD0020", 0 },
712 	{ "AMDI0020", 0 },
713 	{ "AMDI0022", 0 },
714 	{ "BRCM2032", 0 },
715 	{ "HISI0031", 0 },
716 	{ },
717 };
718 MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match);
719 
720 static struct platform_driver dw8250_platform_driver = {
721 	.driver = {
722 		.name		= "dw-apb-uart",
723 		.pm		= &dw8250_pm_ops,
724 		.of_match_table	= dw8250_of_match,
725 		.acpi_match_table = dw8250_acpi_match,
726 	},
727 	.probe			= dw8250_probe,
728 	.remove			= dw8250_remove,
729 };
730 
731 module_platform_driver(dw8250_platform_driver);
732 
733 MODULE_AUTHOR("Jamie Iles");
734 MODULE_LICENSE("GPL");
735 MODULE_DESCRIPTION("Synopsys DesignWare 8250 serial port driver");
736 MODULE_ALIAS("platform:dw-apb-uart");
737