xref: /openbmc/linux/drivers/tty/serial/8250/8250_dw.c (revision 31eeb6b0)
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 		if (of_device_is_compatible(np, "starfive,jh7100-uart"))
418 			p->set_termios = dw8250_do_set_termios;
419 
420 	} else if (acpi_dev_present("APMC0D08", NULL, -1)) {
421 		p->iotype = UPIO_MEM32;
422 		p->regshift = 2;
423 		p->serial_in = dw8250_serial_in32;
424 		data->uart_16550_compatible = true;
425 	}
426 
427 	/* Platforms with iDMA 64-bit */
428 	if (platform_get_resource_byname(to_platform_device(p->dev),
429 					 IORESOURCE_MEM, "lpss_priv")) {
430 		data->data.dma.rx_param = p->dev->parent;
431 		data->data.dma.tx_param = p->dev->parent;
432 		data->data.dma.fn = dw8250_idma_filter;
433 	}
434 }
435 
436 static int dw8250_probe(struct platform_device *pdev)
437 {
438 	struct uart_8250_port uart = {}, *up = &uart;
439 	struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
440 	struct uart_port *p = &up->port;
441 	struct device *dev = &pdev->dev;
442 	struct dw8250_data *data;
443 	int irq;
444 	int err;
445 	u32 val;
446 
447 	if (!regs) {
448 		dev_err(dev, "no registers defined\n");
449 		return -EINVAL;
450 	}
451 
452 	irq = platform_get_irq(pdev, 0);
453 	if (irq < 0)
454 		return irq;
455 
456 	spin_lock_init(&p->lock);
457 	p->mapbase	= regs->start;
458 	p->irq		= irq;
459 	p->handle_irq	= dw8250_handle_irq;
460 	p->pm		= dw8250_do_pm;
461 	p->type		= PORT_8250;
462 	p->flags	= UPF_SHARE_IRQ | UPF_FIXED_PORT;
463 	p->dev		= dev;
464 	p->iotype	= UPIO_MEM;
465 	p->serial_in	= dw8250_serial_in;
466 	p->serial_out	= dw8250_serial_out;
467 	p->set_ldisc	= dw8250_set_ldisc;
468 	p->set_termios	= dw8250_set_termios;
469 
470 	p->membase = devm_ioremap(dev, regs->start, resource_size(regs));
471 	if (!p->membase)
472 		return -ENOMEM;
473 
474 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
475 	if (!data)
476 		return -ENOMEM;
477 
478 	data->data.dma.fn = dw8250_fallback_dma_filter;
479 	data->usr_reg = DW_UART_USR;
480 	p->private_data = &data->data;
481 
482 	data->uart_16550_compatible = device_property_read_bool(dev,
483 						"snps,uart-16550-compatible");
484 
485 	err = device_property_read_u32(dev, "reg-shift", &val);
486 	if (!err)
487 		p->regshift = val;
488 
489 	err = device_property_read_u32(dev, "reg-io-width", &val);
490 	if (!err && val == 4) {
491 		p->iotype = UPIO_MEM32;
492 		p->serial_in = dw8250_serial_in32;
493 		p->serial_out = dw8250_serial_out32;
494 	}
495 
496 	if (device_property_read_bool(dev, "dcd-override")) {
497 		/* Always report DCD as active */
498 		data->msr_mask_on |= UART_MSR_DCD;
499 		data->msr_mask_off |= UART_MSR_DDCD;
500 	}
501 
502 	if (device_property_read_bool(dev, "dsr-override")) {
503 		/* Always report DSR as active */
504 		data->msr_mask_on |= UART_MSR_DSR;
505 		data->msr_mask_off |= UART_MSR_DDSR;
506 	}
507 
508 	if (device_property_read_bool(dev, "cts-override")) {
509 		/* Always report CTS as active */
510 		data->msr_mask_on |= UART_MSR_CTS;
511 		data->msr_mask_off |= UART_MSR_DCTS;
512 	}
513 
514 	if (device_property_read_bool(dev, "ri-override")) {
515 		/* Always report Ring indicator as inactive */
516 		data->msr_mask_off |= UART_MSR_RI;
517 		data->msr_mask_off |= UART_MSR_TERI;
518 	}
519 
520 	/* Always ask for fixed clock rate from a property. */
521 	device_property_read_u32(dev, "clock-frequency", &p->uartclk);
522 
523 	/* If there is separate baudclk, get the rate from it. */
524 	data->clk = devm_clk_get_optional(dev, "baudclk");
525 	if (data->clk == NULL)
526 		data->clk = devm_clk_get_optional(dev, NULL);
527 	if (IS_ERR(data->clk))
528 		return PTR_ERR(data->clk);
529 
530 	INIT_WORK(&data->clk_work, dw8250_clk_work_cb);
531 	data->clk_notifier.notifier_call = dw8250_clk_notifier_cb;
532 
533 	err = clk_prepare_enable(data->clk);
534 	if (err)
535 		dev_warn(dev, "could not enable optional baudclk: %d\n", err);
536 
537 	if (data->clk)
538 		p->uartclk = clk_get_rate(data->clk);
539 
540 	/* If no clock rate is defined, fail. */
541 	if (!p->uartclk) {
542 		dev_err(dev, "clock rate not defined\n");
543 		err = -EINVAL;
544 		goto err_clk;
545 	}
546 
547 	data->pclk = devm_clk_get_optional(dev, "apb_pclk");
548 	if (IS_ERR(data->pclk)) {
549 		err = PTR_ERR(data->pclk);
550 		goto err_clk;
551 	}
552 
553 	err = clk_prepare_enable(data->pclk);
554 	if (err) {
555 		dev_err(dev, "could not enable apb_pclk\n");
556 		goto err_clk;
557 	}
558 
559 	data->rst = devm_reset_control_get_optional_exclusive(dev, NULL);
560 	if (IS_ERR(data->rst)) {
561 		err = PTR_ERR(data->rst);
562 		goto err_pclk;
563 	}
564 	reset_control_deassert(data->rst);
565 
566 	dw8250_quirks(p, data);
567 
568 	/* If the Busy Functionality is not implemented, don't handle it */
569 	if (data->uart_16550_compatible)
570 		p->handle_irq = NULL;
571 
572 	if (!data->skip_autocfg)
573 		dw8250_setup_port(p);
574 
575 	/* If we have a valid fifosize, try hooking up DMA */
576 	if (p->fifosize) {
577 		data->data.dma.rxconf.src_maxburst = p->fifosize / 4;
578 		data->data.dma.txconf.dst_maxburst = p->fifosize / 4;
579 		up->dma = &data->data.dma;
580 	}
581 
582 	data->data.line = serial8250_register_8250_port(up);
583 	if (data->data.line < 0) {
584 		err = data->data.line;
585 		goto err_reset;
586 	}
587 
588 	/*
589 	 * Some platforms may provide a reference clock shared between several
590 	 * devices. In this case any clock state change must be known to the
591 	 * UART port at least post factum.
592 	 */
593 	if (data->clk) {
594 		err = clk_notifier_register(data->clk, &data->clk_notifier);
595 		if (err)
596 			dev_warn(p->dev, "Failed to set the clock notifier\n");
597 		else
598 			queue_work(system_unbound_wq, &data->clk_work);
599 	}
600 
601 	platform_set_drvdata(pdev, data);
602 
603 	pm_runtime_set_active(dev);
604 	pm_runtime_enable(dev);
605 
606 	return 0;
607 
608 err_reset:
609 	reset_control_assert(data->rst);
610 
611 err_pclk:
612 	clk_disable_unprepare(data->pclk);
613 
614 err_clk:
615 	clk_disable_unprepare(data->clk);
616 
617 	return err;
618 }
619 
620 static int dw8250_remove(struct platform_device *pdev)
621 {
622 	struct dw8250_data *data = platform_get_drvdata(pdev);
623 	struct device *dev = &pdev->dev;
624 
625 	pm_runtime_get_sync(dev);
626 
627 	if (data->clk) {
628 		clk_notifier_unregister(data->clk, &data->clk_notifier);
629 
630 		flush_work(&data->clk_work);
631 	}
632 
633 	serial8250_unregister_port(data->data.line);
634 
635 	reset_control_assert(data->rst);
636 
637 	clk_disable_unprepare(data->pclk);
638 
639 	clk_disable_unprepare(data->clk);
640 
641 	pm_runtime_disable(dev);
642 	pm_runtime_put_noidle(dev);
643 
644 	return 0;
645 }
646 
647 #ifdef CONFIG_PM_SLEEP
648 static int dw8250_suspend(struct device *dev)
649 {
650 	struct dw8250_data *data = dev_get_drvdata(dev);
651 
652 	serial8250_suspend_port(data->data.line);
653 
654 	return 0;
655 }
656 
657 static int dw8250_resume(struct device *dev)
658 {
659 	struct dw8250_data *data = dev_get_drvdata(dev);
660 
661 	serial8250_resume_port(data->data.line);
662 
663 	return 0;
664 }
665 #endif /* CONFIG_PM_SLEEP */
666 
667 #ifdef CONFIG_PM
668 static int dw8250_runtime_suspend(struct device *dev)
669 {
670 	struct dw8250_data *data = dev_get_drvdata(dev);
671 
672 	clk_disable_unprepare(data->clk);
673 
674 	clk_disable_unprepare(data->pclk);
675 
676 	return 0;
677 }
678 
679 static int dw8250_runtime_resume(struct device *dev)
680 {
681 	struct dw8250_data *data = dev_get_drvdata(dev);
682 
683 	clk_prepare_enable(data->pclk);
684 
685 	clk_prepare_enable(data->clk);
686 
687 	return 0;
688 }
689 #endif
690 
691 static const struct dev_pm_ops dw8250_pm_ops = {
692 	SET_SYSTEM_SLEEP_PM_OPS(dw8250_suspend, dw8250_resume)
693 	SET_RUNTIME_PM_OPS(dw8250_runtime_suspend, dw8250_runtime_resume, NULL)
694 };
695 
696 static const struct of_device_id dw8250_of_match[] = {
697 	{ .compatible = "snps,dw-apb-uart" },
698 	{ .compatible = "cavium,octeon-3860-uart" },
699 	{ .compatible = "marvell,armada-38x-uart" },
700 	{ .compatible = "renesas,rzn1-uart" },
701 	{ .compatible = "starfive,jh7100-uart" },
702 	{ /* Sentinel */ }
703 };
704 MODULE_DEVICE_TABLE(of, dw8250_of_match);
705 
706 static const struct acpi_device_id dw8250_acpi_match[] = {
707 	{ "INT33C4", 0 },
708 	{ "INT33C5", 0 },
709 	{ "INT3434", 0 },
710 	{ "INT3435", 0 },
711 	{ "80860F0A", 0 },
712 	{ "8086228A", 0 },
713 	{ "APMC0D08", 0},
714 	{ "AMD0020", 0 },
715 	{ "AMDI0020", 0 },
716 	{ "AMDI0022", 0 },
717 	{ "BRCM2032", 0 },
718 	{ "HISI0031", 0 },
719 	{ },
720 };
721 MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match);
722 
723 static struct platform_driver dw8250_platform_driver = {
724 	.driver = {
725 		.name		= "dw-apb-uart",
726 		.pm		= &dw8250_pm_ops,
727 		.of_match_table	= dw8250_of_match,
728 		.acpi_match_table = dw8250_acpi_match,
729 	},
730 	.probe			= dw8250_probe,
731 	.remove			= dw8250_remove,
732 };
733 
734 module_platform_driver(dw8250_platform_driver);
735 
736 MODULE_AUTHOR("Jamie Iles");
737 MODULE_LICENSE("GPL");
738 MODULE_DESCRIPTION("Synopsys DesignWare 8250 serial port driver");
739 MODULE_ALIAS("platform:dw-apb-uart");
740