Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Synopsys DesignWare 8250 driver. |
| 3 | * |
| 4 | * Copyright 2011 Picochip, Jamie Iles. |
Heikki Krogerus | 6a7320c | 2013-01-10 11:25:10 +0200 | [diff] [blame] | 5 | * Copyright 2013 Intel Corporation |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * The Synopsys DesignWare 8250 has an extra feature whereby it detects if the |
| 13 | * LCR is written whilst busy. If it is, then a busy detect interrupt is |
| 14 | * raised, the LCR needs to be rewritten and the uart status register read. |
| 15 | */ |
| 16 | #include <linux/device.h> |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 17 | #include <linux/io.h> |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/serial_8250.h> |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 20 | #include <linux/serial_reg.h> |
| 21 | #include <linux/of.h> |
| 22 | #include <linux/of_irq.h> |
| 23 | #include <linux/of_platform.h> |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/slab.h> |
Heikki Krogerus | 6a7320c | 2013-01-10 11:25:10 +0200 | [diff] [blame] | 26 | #include <linux/acpi.h> |
Emilio López | e302cd9 | 2013-03-29 00:15:49 +0100 | [diff] [blame] | 27 | #include <linux/clk.h> |
Chen-Yu Tsai | 7fe090b | 2014-07-23 23:33:06 +0800 | [diff] [blame] | 28 | #include <linux/reset.h> |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 29 | #include <linux/pm_runtime.h> |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 30 | |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 31 | #include <asm/byteorder.h> |
| 32 | |
Heikki Krogerus | 7277b2a | 2013-01-10 11:25:12 +0200 | [diff] [blame] | 33 | #include "8250.h" |
| 34 | |
Heikki Krogerus | 30046df | 2013-01-10 11:25:09 +0200 | [diff] [blame] | 35 | /* Offsets for the DesignWare specific registers */ |
| 36 | #define DW_UART_USR 0x1f /* UART Status Register */ |
| 37 | #define DW_UART_CPR 0xf4 /* Component Parameter Register */ |
| 38 | #define DW_UART_UCV 0xf8 /* UART Component Version */ |
| 39 | |
| 40 | /* Component Parameter Register bits */ |
| 41 | #define DW_UART_CPR_ABP_DATA_WIDTH (3 << 0) |
| 42 | #define DW_UART_CPR_AFCE_MODE (1 << 4) |
| 43 | #define DW_UART_CPR_THRE_MODE (1 << 5) |
| 44 | #define DW_UART_CPR_SIR_MODE (1 << 6) |
| 45 | #define DW_UART_CPR_SIR_LP_MODE (1 << 7) |
| 46 | #define DW_UART_CPR_ADDITIONAL_FEATURES (1 << 8) |
| 47 | #define DW_UART_CPR_FIFO_ACCESS (1 << 9) |
| 48 | #define DW_UART_CPR_FIFO_STAT (1 << 10) |
| 49 | #define DW_UART_CPR_SHADOW (1 << 11) |
| 50 | #define DW_UART_CPR_ENCODED_PARMS (1 << 12) |
| 51 | #define DW_UART_CPR_DMA_EXTRA (1 << 13) |
| 52 | #define DW_UART_CPR_FIFO_MODE (0xff << 16) |
| 53 | /* Helper for fifo size calculation */ |
| 54 | #define DW_UART_CPR_FIFO_SIZE(a) (((a >> 16) & 0xff) * 16) |
| 55 | |
| 56 | |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 57 | struct dw8250_data { |
Heikki Krogerus | fe9585553 | 2013-09-05 17:34:53 +0300 | [diff] [blame] | 58 | u8 usr_reg; |
Heikki Krogerus | fe9585553 | 2013-09-05 17:34:53 +0300 | [diff] [blame] | 59 | int line; |
Desmond Liu | dfd3766 | 2015-02-26 16:35:57 -0800 | [diff] [blame] | 60 | int msr_mask_on; |
| 61 | int msr_mask_off; |
Heikki Krogerus | fe9585553 | 2013-09-05 17:34:53 +0300 | [diff] [blame] | 62 | struct clk *clk; |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 63 | struct clk *pclk; |
Chen-Yu Tsai | 7fe090b | 2014-07-23 23:33:06 +0800 | [diff] [blame] | 64 | struct reset_control *rst; |
Heikki Krogerus | fe9585553 | 2013-09-05 17:34:53 +0300 | [diff] [blame] | 65 | struct uart_8250_dma dma; |
Heikki Krogerus | 4f04205 | 2015-09-21 14:17:27 +0300 | [diff] [blame] | 66 | |
| 67 | unsigned int skip_autocfg:1; |
Heikki Krogerus | c73942e | 2015-09-21 14:17:29 +0300 | [diff] [blame] | 68 | unsigned int uart_16550_compatible:1; |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 69 | }; |
| 70 | |
Loic Poulain | c439c33 | 2014-04-24 11:46:14 +0200 | [diff] [blame] | 71 | #define BYT_PRV_CLK 0x800 |
| 72 | #define BYT_PRV_CLK_EN (1 << 0) |
| 73 | #define BYT_PRV_CLK_M_VAL_SHIFT 1 |
| 74 | #define BYT_PRV_CLK_N_VAL_SHIFT 16 |
| 75 | #define BYT_PRV_CLK_UPDATE (1 << 31) |
| 76 | |
Tim Kryger | 33acbb8 | 2013-08-16 13:50:15 -0700 | [diff] [blame] | 77 | static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value) |
| 78 | { |
| 79 | struct dw8250_data *d = p->private_data; |
| 80 | |
Desmond Liu | dfd3766 | 2015-02-26 16:35:57 -0800 | [diff] [blame] | 81 | /* Override any modem control signals if needed */ |
| 82 | if (offset == UART_MSR) { |
| 83 | value |= d->msr_mask_on; |
| 84 | value &= ~d->msr_mask_off; |
| 85 | } |
| 86 | |
Tim Kryger | 33acbb8 | 2013-08-16 13:50:15 -0700 | [diff] [blame] | 87 | return value; |
| 88 | } |
| 89 | |
Tim Kryger | c49436b | 2013-10-01 10:18:08 -0700 | [diff] [blame] | 90 | static void dw8250_force_idle(struct uart_port *p) |
| 91 | { |
Andy Shevchenko | b1261c8 | 2014-07-14 14:26:14 +0300 | [diff] [blame] | 92 | struct uart_8250_port *up = up_to_u8250p(p); |
| 93 | |
| 94 | serial8250_clear_and_reinit_fifos(up); |
Tim Kryger | c49436b | 2013-10-01 10:18:08 -0700 | [diff] [blame] | 95 | (void)p->serial_in(p, UART_RX); |
| 96 | } |
| 97 | |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 98 | static void dw8250_check_lcr(struct uart_port *p, int value) |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 99 | { |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 100 | void __iomem *offset = p->membase + (UART_LCR << p->regshift); |
| 101 | int tries = 1000; |
Tim Kryger | c49436b | 2013-10-01 10:18:08 -0700 | [diff] [blame] | 102 | |
| 103 | /* Make sure LCR write wasn't ignored */ |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 104 | while (tries--) { |
| 105 | unsigned int lcr = p->serial_in(p, UART_LCR); |
| 106 | |
| 107 | if ((value & ~UART_LCR_SPAR) == (lcr & ~UART_LCR_SPAR)) |
| 108 | return; |
| 109 | |
| 110 | dw8250_force_idle(p); |
| 111 | |
| 112 | #ifdef CONFIG_64BIT |
| 113 | __raw_writeq(value & 0xff, offset); |
| 114 | #else |
| 115 | if (p->iotype == UPIO_MEM32) |
| 116 | writel(value, offset); |
Noam Camus | 5a43140 | 2015-12-12 19:18:27 +0200 | [diff] [blame] | 117 | else if (p->iotype == UPIO_MEM32BE) |
| 118 | iowrite32be(value, offset); |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 119 | else |
| 120 | writeb(value, offset); |
| 121 | #endif |
Tim Kryger | c49436b | 2013-10-01 10:18:08 -0700 | [diff] [blame] | 122 | } |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 123 | /* |
| 124 | * FIXME: this deadlocks if port->lock is already held |
| 125 | * dev_err(p->dev, "Couldn't set LCR to %d\n", value); |
| 126 | */ |
| 127 | } |
| 128 | |
| 129 | static void dw8250_serial_out(struct uart_port *p, int offset, int value) |
| 130 | { |
| 131 | struct dw8250_data *d = p->private_data; |
| 132 | |
| 133 | writeb(value, p->membase + (offset << p->regshift)); |
| 134 | |
| 135 | if (offset == UART_LCR && !d->uart_16550_compatible) |
| 136 | dw8250_check_lcr(p, value); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | static unsigned int dw8250_serial_in(struct uart_port *p, int offset) |
| 140 | { |
Tim Kryger | 33acbb8 | 2013-08-16 13:50:15 -0700 | [diff] [blame] | 141 | unsigned int value = readb(p->membase + (offset << p->regshift)); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 142 | |
Tim Kryger | 33acbb8 | 2013-08-16 13:50:15 -0700 | [diff] [blame] | 143 | return dw8250_modify_msr(p, offset, value); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 144 | } |
| 145 | |
David Daney | bca2092 | 2014-11-14 17:26:19 +0300 | [diff] [blame] | 146 | #ifdef CONFIG_64BIT |
| 147 | static unsigned int dw8250_serial_inq(struct uart_port *p, int offset) |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 148 | { |
David Daney | bca2092 | 2014-11-14 17:26:19 +0300 | [diff] [blame] | 149 | unsigned int value; |
| 150 | |
| 151 | value = (u8)__raw_readq(p->membase + (offset << p->regshift)); |
| 152 | |
| 153 | return dw8250_modify_msr(p, offset, value); |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 154 | } |
| 155 | |
David Daney | bca2092 | 2014-11-14 17:26:19 +0300 | [diff] [blame] | 156 | static void dw8250_serial_outq(struct uart_port *p, int offset, int value) |
| 157 | { |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 158 | struct dw8250_data *d = p->private_data; |
| 159 | |
David Daney | bca2092 | 2014-11-14 17:26:19 +0300 | [diff] [blame] | 160 | value &= 0xff; |
| 161 | __raw_writeq(value, p->membase + (offset << p->regshift)); |
| 162 | /* Read back to ensure register write ordering. */ |
| 163 | __raw_readq(p->membase + (UART_LCR << p->regshift)); |
| 164 | |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 165 | if (offset == UART_LCR && !d->uart_16550_compatible) |
| 166 | dw8250_check_lcr(p, value); |
David Daney | bca2092 | 2014-11-14 17:26:19 +0300 | [diff] [blame] | 167 | } |
| 168 | #endif /* CONFIG_64BIT */ |
| 169 | |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 170 | static void dw8250_serial_out32(struct uart_port *p, int offset, int value) |
| 171 | { |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 172 | struct dw8250_data *d = p->private_data; |
| 173 | |
Tim Kryger | 33acbb8 | 2013-08-16 13:50:15 -0700 | [diff] [blame] | 174 | writel(value, p->membase + (offset << p->regshift)); |
Tim Kryger | c49436b | 2013-10-01 10:18:08 -0700 | [diff] [blame] | 175 | |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 176 | if (offset == UART_LCR && !d->uart_16550_compatible) |
| 177 | dw8250_check_lcr(p, value); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | static unsigned int dw8250_serial_in32(struct uart_port *p, int offset) |
| 181 | { |
Tim Kryger | 33acbb8 | 2013-08-16 13:50:15 -0700 | [diff] [blame] | 182 | unsigned int value = readl(p->membase + (offset << p->regshift)); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 183 | |
Tim Kryger | 33acbb8 | 2013-08-16 13:50:15 -0700 | [diff] [blame] | 184 | return dw8250_modify_msr(p, offset, value); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 185 | } |
| 186 | |
Noam Camus | 4625090 | 2015-12-12 19:18:26 +0200 | [diff] [blame] | 187 | static void dw8250_serial_out32be(struct uart_port *p, int offset, int value) |
| 188 | { |
| 189 | struct dw8250_data *d = p->private_data; |
| 190 | |
| 191 | iowrite32be(value, p->membase + (offset << p->regshift)); |
| 192 | |
| 193 | if (offset == UART_LCR && !d->uart_16550_compatible) |
| 194 | dw8250_check_lcr(p, value); |
| 195 | } |
| 196 | |
| 197 | static unsigned int dw8250_serial_in32be(struct uart_port *p, int offset) |
| 198 | { |
| 199 | unsigned int value = ioread32be(p->membase + (offset << p->regshift)); |
| 200 | |
| 201 | return dw8250_modify_msr(p, offset, value); |
| 202 | } |
| 203 | |
| 204 | |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 205 | static int dw8250_handle_irq(struct uart_port *p) |
| 206 | { |
| 207 | struct dw8250_data *d = p->private_data; |
| 208 | unsigned int iir = p->serial_in(p, UART_IIR); |
| 209 | |
Andy Shevchenko | 34eefb59 | 2016-02-15 17:38:45 +0200 | [diff] [blame^] | 210 | if (serial8250_handle_irq(p, iir)) |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 211 | return 1; |
Andy Shevchenko | 34eefb59 | 2016-02-15 17:38:45 +0200 | [diff] [blame^] | 212 | |
| 213 | if ((iir & UART_IIR_BUSY) == UART_IIR_BUSY) { |
Tim Kryger | c49436b | 2013-10-01 10:18:08 -0700 | [diff] [blame] | 214 | /* Clear the USR */ |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 215 | (void)p->serial_in(p, d->usr_reg); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 216 | |
| 217 | return 1; |
| 218 | } |
| 219 | |
| 220 | return 0; |
| 221 | } |
| 222 | |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 223 | static void |
| 224 | dw8250_do_pm(struct uart_port *port, unsigned int state, unsigned int old) |
| 225 | { |
| 226 | if (!state) |
| 227 | pm_runtime_get_sync(port->dev); |
| 228 | |
| 229 | serial8250_do_pm(port, state, old); |
| 230 | |
| 231 | if (state) |
| 232 | pm_runtime_put_sync_suspend(port->dev); |
| 233 | } |
| 234 | |
Heikki Krogerus | 4e26b13 | 2014-06-05 16:51:40 +0300 | [diff] [blame] | 235 | static void dw8250_set_termios(struct uart_port *p, struct ktermios *termios, |
| 236 | struct ktermios *old) |
| 237 | { |
| 238 | unsigned int baud = tty_termios_baud_rate(termios); |
| 239 | struct dw8250_data *d = p->private_data; |
| 240 | unsigned int rate; |
| 241 | int ret; |
| 242 | |
| 243 | if (IS_ERR(d->clk) || !old) |
| 244 | goto out; |
| 245 | |
Heikki Krogerus | 4e26b13 | 2014-06-05 16:51:40 +0300 | [diff] [blame] | 246 | clk_disable_unprepare(d->clk); |
| 247 | rate = clk_round_rate(d->clk, baud * 16); |
| 248 | ret = clk_set_rate(d->clk, rate); |
| 249 | clk_prepare_enable(d->clk); |
| 250 | |
| 251 | if (!ret) |
| 252 | p->uartclk = rate; |
Qipeng Zha | 0a6c301 | 2015-07-29 18:23:32 +0800 | [diff] [blame] | 253 | |
| 254 | p->status &= ~UPSTAT_AUTOCTS; |
| 255 | if (termios->c_cflag & CRTSCTS) |
| 256 | p->status |= UPSTAT_AUTOCTS; |
| 257 | |
Heikki Krogerus | 4e26b13 | 2014-06-05 16:51:40 +0300 | [diff] [blame] | 258 | out: |
| 259 | serial8250_do_set_termios(p, termios, old); |
| 260 | } |
| 261 | |
Heikki Krogerus | 1edb3cf | 2015-09-21 14:17:30 +0300 | [diff] [blame] | 262 | /* |
| 263 | * dw8250_fallback_dma_filter will prevent the UART from getting just any free |
| 264 | * channel on platforms that have DMA engines, but don't have any channels |
| 265 | * assigned to the UART. |
| 266 | * |
| 267 | * REVISIT: This is a work around for limitation in the DMA Engine API. Once the |
| 268 | * core problem is fixed, this function is no longer needed. |
| 269 | */ |
| 270 | static bool dw8250_fallback_dma_filter(struct dma_chan *chan, void *param) |
Heikki Krogerus | 7fb8c56 | 2013-09-05 17:34:54 +0300 | [diff] [blame] | 271 | { |
Andy Shevchenko | 9a1870c | 2014-08-19 20:29:22 +0300 | [diff] [blame] | 272 | return false; |
Heikki Krogerus | 7fb8c56 | 2013-09-05 17:34:54 +0300 | [diff] [blame] | 273 | } |
| 274 | |
Heikki Krogerus | 0788c39 | 2015-05-26 15:59:32 +0300 | [diff] [blame] | 275 | static bool dw8250_idma_filter(struct dma_chan *chan, void *param) |
| 276 | { |
Heikki Krogerus | 83ce95e | 2015-09-21 14:17:31 +0300 | [diff] [blame] | 277 | return param == chan->device->dev->parent; |
Heikki Krogerus | 0788c39 | 2015-05-26 15:59:32 +0300 | [diff] [blame] | 278 | } |
| 279 | |
Heikki Krogerus | 9e08fa5 | 2015-09-21 14:17:28 +0300 | [diff] [blame] | 280 | static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data) |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 281 | { |
Heikki Krogerus | 9e08fa5 | 2015-09-21 14:17:28 +0300 | [diff] [blame] | 282 | if (p->dev->of_node) { |
| 283 | struct device_node *np = p->dev->of_node; |
| 284 | int id; |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 285 | |
Heikki Krogerus | 9e08fa5 | 2015-09-21 14:17:28 +0300 | [diff] [blame] | 286 | /* get index of serial line, if found in DT aliases */ |
| 287 | id = of_alias_get_id(np, "serial"); |
| 288 | if (id >= 0) |
| 289 | p->line = id; |
| 290 | #ifdef CONFIG_64BIT |
| 291 | if (of_device_is_compatible(np, "cavium,octeon-3860-uart")) { |
| 292 | p->serial_in = dw8250_serial_inq; |
| 293 | p->serial_out = dw8250_serial_outq; |
| 294 | p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; |
| 295 | p->type = PORT_OCTEON; |
| 296 | data->usr_reg = 0x27; |
| 297 | data->skip_autocfg = true; |
| 298 | } |
| 299 | #endif |
Noam Camus | 4625090 | 2015-12-12 19:18:26 +0200 | [diff] [blame] | 300 | if (of_device_is_big_endian(p->dev->of_node)) { |
| 301 | p->iotype = UPIO_MEM32BE; |
| 302 | p->serial_in = dw8250_serial_in32be; |
| 303 | p->serial_out = dw8250_serial_out32be; |
| 304 | } |
Heikki Krogerus | 9e08fa5 | 2015-09-21 14:17:28 +0300 | [diff] [blame] | 305 | } else if (has_acpi_companion(p->dev)) { |
| 306 | p->iotype = UPIO_MEM32; |
| 307 | p->regshift = 2; |
| 308 | p->serial_in = dw8250_serial_in32; |
Heikki Krogerus | 9e08fa5 | 2015-09-21 14:17:28 +0300 | [diff] [blame] | 309 | p->set_termios = dw8250_set_termios; |
Heikki Krogerus | c73942e | 2015-09-21 14:17:29 +0300 | [diff] [blame] | 310 | /* So far none of there implement the Busy Functionality */ |
| 311 | data->uart_16550_compatible = true; |
Heikki Krogerus | 0788c39 | 2015-05-26 15:59:32 +0300 | [diff] [blame] | 312 | } |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 313 | |
Heikki Krogerus | 9e08fa5 | 2015-09-21 14:17:28 +0300 | [diff] [blame] | 314 | /* Platforms with iDMA */ |
| 315 | if (platform_get_resource_byname(to_platform_device(p->dev), |
| 316 | IORESOURCE_MEM, "lpss_priv")) { |
| 317 | p->set_termios = dw8250_set_termios; |
| 318 | data->dma.rx_param = p->dev->parent; |
| 319 | data->dma.tx_param = p->dev->parent; |
| 320 | data->dma.fn = dw8250_idma_filter; |
| 321 | } |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 322 | } |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 323 | |
Heikki Krogerus | 2338a75 | 2015-09-21 14:17:32 +0300 | [diff] [blame] | 324 | static void dw8250_setup_port(struct uart_port *p) |
| 325 | { |
| 326 | struct uart_8250_port *up = up_to_u8250p(p); |
| 327 | u32 reg; |
| 328 | |
| 329 | /* |
| 330 | * If the Component Version Register returns zero, we know that |
| 331 | * ADDITIONAL_FEATURES are not enabled. No need to go any further. |
| 332 | */ |
Noam Camus | 5a43140 | 2015-12-12 19:18:27 +0200 | [diff] [blame] | 333 | if (p->iotype == UPIO_MEM32BE) |
| 334 | reg = ioread32be(p->membase + DW_UART_UCV); |
| 335 | else |
| 336 | reg = readl(p->membase + DW_UART_UCV); |
Heikki Krogerus | 2338a75 | 2015-09-21 14:17:32 +0300 | [diff] [blame] | 337 | if (!reg) |
| 338 | return; |
| 339 | |
| 340 | dev_dbg(p->dev, "Designware UART version %c.%c%c\n", |
| 341 | (reg >> 24) & 0xff, (reg >> 16) & 0xff, (reg >> 8) & 0xff); |
| 342 | |
Noam Camus | 5a43140 | 2015-12-12 19:18:27 +0200 | [diff] [blame] | 343 | if (p->iotype == UPIO_MEM32BE) |
| 344 | reg = ioread32be(p->membase + DW_UART_CPR); |
| 345 | else |
| 346 | reg = readl(p->membase + DW_UART_CPR); |
Heikki Krogerus | 2338a75 | 2015-09-21 14:17:32 +0300 | [diff] [blame] | 347 | if (!reg) |
| 348 | return; |
| 349 | |
| 350 | /* Select the type based on fifo */ |
| 351 | if (reg & DW_UART_CPR_FIFO_MODE) { |
| 352 | p->type = PORT_16550A; |
| 353 | p->flags |= UPF_FIXED_TYPE; |
| 354 | p->fifosize = DW_UART_CPR_FIFO_SIZE(reg); |
| 355 | up->capabilities = UART_CAP_FIFO; |
| 356 | } |
| 357 | |
| 358 | if (reg & DW_UART_CPR_AFCE_MODE) |
| 359 | up->capabilities |= UART_CAP_AFE; |
| 360 | } |
| 361 | |
Bill Pemberton | 9671f09 | 2012-11-19 13:21:50 -0500 | [diff] [blame] | 362 | static int dw8250_probe(struct platform_device *pdev) |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 363 | { |
Alan Cox | 2655a2c | 2012-07-12 12:59:50 +0100 | [diff] [blame] | 364 | struct uart_8250_port uart = {}; |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 365 | struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
Alexey Brodkin | 833b1f7 | 2015-03-03 18:11:14 +0300 | [diff] [blame] | 366 | int irq = platform_get_irq(pdev, 0); |
Heikki Krogerus | 78d3da7 | 2015-09-21 14:17:24 +0300 | [diff] [blame] | 367 | struct uart_port *p = &uart.port; |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 368 | struct dw8250_data *data; |
Heikki Krogerus | a7260c8 | 2013-01-10 11:25:08 +0200 | [diff] [blame] | 369 | int err; |
Heikki Krogerus | 1bd8edb | 2015-09-21 14:17:25 +0300 | [diff] [blame] | 370 | u32 val; |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 371 | |
Alexey Brodkin | 833b1f7 | 2015-03-03 18:11:14 +0300 | [diff] [blame] | 372 | if (!regs) { |
| 373 | dev_err(&pdev->dev, "no registers defined\n"); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 374 | return -EINVAL; |
| 375 | } |
| 376 | |
Alexey Brodkin | 833b1f7 | 2015-03-03 18:11:14 +0300 | [diff] [blame] | 377 | if (irq < 0) { |
| 378 | if (irq != -EPROBE_DEFER) |
| 379 | dev_err(&pdev->dev, "cannot get irq\n"); |
| 380 | return irq; |
| 381 | } |
| 382 | |
Heikki Krogerus | 78d3da7 | 2015-09-21 14:17:24 +0300 | [diff] [blame] | 383 | spin_lock_init(&p->lock); |
| 384 | p->mapbase = regs->start; |
| 385 | p->irq = irq; |
| 386 | p->handle_irq = dw8250_handle_irq; |
| 387 | p->pm = dw8250_do_pm; |
| 388 | p->type = PORT_8250; |
Heikki Krogerus | 7693c79 | 2015-09-21 14:17:33 +0300 | [diff] [blame] | 389 | p->flags = UPF_SHARE_IRQ | UPF_FIXED_PORT; |
Heikki Krogerus | 78d3da7 | 2015-09-21 14:17:24 +0300 | [diff] [blame] | 390 | p->dev = &pdev->dev; |
| 391 | p->iotype = UPIO_MEM; |
| 392 | p->serial_in = dw8250_serial_in; |
| 393 | p->serial_out = dw8250_serial_out; |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 394 | |
Heikki Krogerus | 78d3da7 | 2015-09-21 14:17:24 +0300 | [diff] [blame] | 395 | p->membase = devm_ioremap(&pdev->dev, regs->start, resource_size(regs)); |
| 396 | if (!p->membase) |
Heikki Krogerus | f93366f | 2013-01-10 11:25:07 +0200 | [diff] [blame] | 397 | return -ENOMEM; |
| 398 | |
Emilio López | e302cd9 | 2013-03-29 00:15:49 +0100 | [diff] [blame] | 399 | data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL); |
| 400 | if (!data) |
| 401 | return -ENOMEM; |
| 402 | |
Heikki Krogerus | 1edb3cf | 2015-09-21 14:17:30 +0300 | [diff] [blame] | 403 | data->dma.fn = dw8250_fallback_dma_filter; |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 404 | data->usr_reg = DW_UART_USR; |
Heikki Krogerus | 78d3da7 | 2015-09-21 14:17:24 +0300 | [diff] [blame] | 405 | p->private_data = data; |
Heikki Krogerus | 23f5b3f | 2015-03-18 12:55:13 +0200 | [diff] [blame] | 406 | |
Heikki Krogerus | c73942e | 2015-09-21 14:17:29 +0300 | [diff] [blame] | 407 | data->uart_16550_compatible = device_property_read_bool(p->dev, |
| 408 | "snps,uart-16550-compatible"); |
| 409 | |
Heikki Krogerus | 1bd8edb | 2015-09-21 14:17:25 +0300 | [diff] [blame] | 410 | err = device_property_read_u32(p->dev, "reg-shift", &val); |
| 411 | if (!err) |
| 412 | p->regshift = val; |
| 413 | |
| 414 | err = device_property_read_u32(p->dev, "reg-io-width", &val); |
| 415 | if (!err && val == 4) { |
| 416 | p->iotype = UPIO_MEM32; |
| 417 | p->serial_in = dw8250_serial_in32; |
| 418 | p->serial_out = dw8250_serial_out32; |
| 419 | } |
| 420 | |
| 421 | if (device_property_read_bool(p->dev, "dcd-override")) { |
| 422 | /* Always report DCD as active */ |
| 423 | data->msr_mask_on |= UART_MSR_DCD; |
| 424 | data->msr_mask_off |= UART_MSR_DDCD; |
| 425 | } |
| 426 | |
| 427 | if (device_property_read_bool(p->dev, "dsr-override")) { |
| 428 | /* Always report DSR as active */ |
| 429 | data->msr_mask_on |= UART_MSR_DSR; |
| 430 | data->msr_mask_off |= UART_MSR_DDSR; |
| 431 | } |
| 432 | |
| 433 | if (device_property_read_bool(p->dev, "cts-override")) { |
| 434 | /* Always report CTS as active */ |
| 435 | data->msr_mask_on |= UART_MSR_CTS; |
| 436 | data->msr_mask_off |= UART_MSR_DCTS; |
| 437 | } |
| 438 | |
| 439 | if (device_property_read_bool(p->dev, "ri-override")) { |
| 440 | /* Always report Ring indicator as inactive */ |
| 441 | data->msr_mask_off |= UART_MSR_RI; |
| 442 | data->msr_mask_off |= UART_MSR_TERI; |
| 443 | } |
| 444 | |
Heikki Krogerus | 23f5b3f | 2015-03-18 12:55:13 +0200 | [diff] [blame] | 445 | /* Always ask for fixed clock rate from a property. */ |
Heikki Krogerus | 78d3da7 | 2015-09-21 14:17:24 +0300 | [diff] [blame] | 446 | device_property_read_u32(p->dev, "clock-frequency", &p->uartclk); |
Heikki Krogerus | 23f5b3f | 2015-03-18 12:55:13 +0200 | [diff] [blame] | 447 | |
| 448 | /* If there is separate baudclk, get the rate from it. */ |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 449 | data->clk = devm_clk_get(&pdev->dev, "baudclk"); |
Chen-Yu Tsai | c8ed99d | 2014-07-23 23:33:07 +0800 | [diff] [blame] | 450 | if (IS_ERR(data->clk) && PTR_ERR(data->clk) != -EPROBE_DEFER) |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 451 | data->clk = devm_clk_get(&pdev->dev, NULL); |
Chen-Yu Tsai | c8ed99d | 2014-07-23 23:33:07 +0800 | [diff] [blame] | 452 | if (IS_ERR(data->clk) && PTR_ERR(data->clk) == -EPROBE_DEFER) |
| 453 | return -EPROBE_DEFER; |
Heikki Krogerus | 23f5b3f | 2015-03-18 12:55:13 +0200 | [diff] [blame] | 454 | if (!IS_ERR_OR_NULL(data->clk)) { |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 455 | err = clk_prepare_enable(data->clk); |
| 456 | if (err) |
| 457 | dev_warn(&pdev->dev, "could not enable optional baudclk: %d\n", |
| 458 | err); |
| 459 | else |
Heikki Krogerus | 78d3da7 | 2015-09-21 14:17:24 +0300 | [diff] [blame] | 460 | p->uartclk = clk_get_rate(data->clk); |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 461 | } |
| 462 | |
Heikki Krogerus | 23f5b3f | 2015-03-18 12:55:13 +0200 | [diff] [blame] | 463 | /* If no clock rate is defined, fail. */ |
Heikki Krogerus | 78d3da7 | 2015-09-21 14:17:24 +0300 | [diff] [blame] | 464 | if (!p->uartclk) { |
Heikki Krogerus | 23f5b3f | 2015-03-18 12:55:13 +0200 | [diff] [blame] | 465 | dev_err(&pdev->dev, "clock rate not defined\n"); |
| 466 | return -EINVAL; |
| 467 | } |
| 468 | |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 469 | data->pclk = devm_clk_get(&pdev->dev, "apb_pclk"); |
Chen-Yu Tsai | c8ed99d | 2014-07-23 23:33:07 +0800 | [diff] [blame] | 470 | if (IS_ERR(data->clk) && PTR_ERR(data->clk) == -EPROBE_DEFER) { |
| 471 | err = -EPROBE_DEFER; |
| 472 | goto err_clk; |
| 473 | } |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 474 | if (!IS_ERR(data->pclk)) { |
| 475 | err = clk_prepare_enable(data->pclk); |
| 476 | if (err) { |
| 477 | dev_err(&pdev->dev, "could not enable apb_pclk\n"); |
Chen-Yu Tsai | c8ed99d | 2014-07-23 23:33:07 +0800 | [diff] [blame] | 478 | goto err_clk; |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 479 | } |
Emilio López | e302cd9 | 2013-03-29 00:15:49 +0100 | [diff] [blame] | 480 | } |
| 481 | |
Chen-Yu Tsai | 7fe090b | 2014-07-23 23:33:06 +0800 | [diff] [blame] | 482 | data->rst = devm_reset_control_get_optional(&pdev->dev, NULL); |
Chen-Yu Tsai | c8ed99d | 2014-07-23 23:33:07 +0800 | [diff] [blame] | 483 | if (IS_ERR(data->rst) && PTR_ERR(data->rst) == -EPROBE_DEFER) { |
| 484 | err = -EPROBE_DEFER; |
| 485 | goto err_pclk; |
| 486 | } |
Chen-Yu Tsai | 7fe090b | 2014-07-23 23:33:06 +0800 | [diff] [blame] | 487 | if (!IS_ERR(data->rst)) |
| 488 | reset_control_deassert(data->rst); |
| 489 | |
Heikki Krogerus | 9e08fa5 | 2015-09-21 14:17:28 +0300 | [diff] [blame] | 490 | dw8250_quirks(p, data); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 491 | |
Heikki Krogerus | c73942e | 2015-09-21 14:17:29 +0300 | [diff] [blame] | 492 | /* If the Busy Functionality is not implemented, don't handle it */ |
Noam Camus | cdcea05 | 2015-12-12 19:18:25 +0200 | [diff] [blame] | 493 | if (data->uart_16550_compatible) |
Heikki Krogerus | c73942e | 2015-09-21 14:17:29 +0300 | [diff] [blame] | 494 | p->handle_irq = NULL; |
Heikki Krogerus | c73942e | 2015-09-21 14:17:29 +0300 | [diff] [blame] | 495 | |
Heikki Krogerus | 4f04205 | 2015-09-21 14:17:27 +0300 | [diff] [blame] | 496 | if (!data->skip_autocfg) |
Heikki Krogerus | 2338a75 | 2015-09-21 14:17:32 +0300 | [diff] [blame] | 497 | dw8250_setup_port(p); |
Heikki Krogerus | 4f04205 | 2015-09-21 14:17:27 +0300 | [diff] [blame] | 498 | |
Heikki Krogerus | 2559318 | 2015-09-21 14:17:26 +0300 | [diff] [blame] | 499 | /* If we have a valid fifosize, try hooking up DMA */ |
| 500 | if (p->fifosize) { |
| 501 | data->dma.rxconf.src_maxburst = p->fifosize / 4; |
| 502 | data->dma.txconf.dst_maxburst = p->fifosize / 4; |
| 503 | uart.dma = &data->dma; |
| 504 | } |
| 505 | |
Alan Cox | 2655a2c | 2012-07-12 12:59:50 +0100 | [diff] [blame] | 506 | data->line = serial8250_register_8250_port(&uart); |
Chen-Yu Tsai | c8ed99d | 2014-07-23 23:33:07 +0800 | [diff] [blame] | 507 | if (data->line < 0) { |
| 508 | err = data->line; |
| 509 | goto err_reset; |
| 510 | } |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 511 | |
| 512 | platform_set_drvdata(pdev, data); |
| 513 | |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 514 | pm_runtime_set_active(&pdev->dev); |
| 515 | pm_runtime_enable(&pdev->dev); |
| 516 | |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 517 | return 0; |
Chen-Yu Tsai | c8ed99d | 2014-07-23 23:33:07 +0800 | [diff] [blame] | 518 | |
| 519 | err_reset: |
| 520 | if (!IS_ERR(data->rst)) |
| 521 | reset_control_assert(data->rst); |
| 522 | |
| 523 | err_pclk: |
| 524 | if (!IS_ERR(data->pclk)) |
| 525 | clk_disable_unprepare(data->pclk); |
| 526 | |
| 527 | err_clk: |
| 528 | if (!IS_ERR(data->clk)) |
| 529 | clk_disable_unprepare(data->clk); |
| 530 | |
| 531 | return err; |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 532 | } |
| 533 | |
Bill Pemberton | ae8d8a1 | 2012-11-19 13:26:18 -0500 | [diff] [blame] | 534 | static int dw8250_remove(struct platform_device *pdev) |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 535 | { |
| 536 | struct dw8250_data *data = platform_get_drvdata(pdev); |
| 537 | |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 538 | pm_runtime_get_sync(&pdev->dev); |
| 539 | |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 540 | serial8250_unregister_port(data->line); |
| 541 | |
Chen-Yu Tsai | 7fe090b | 2014-07-23 23:33:06 +0800 | [diff] [blame] | 542 | if (!IS_ERR(data->rst)) |
| 543 | reset_control_assert(data->rst); |
| 544 | |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 545 | if (!IS_ERR(data->pclk)) |
| 546 | clk_disable_unprepare(data->pclk); |
| 547 | |
Emilio López | e302cd9 | 2013-03-29 00:15:49 +0100 | [diff] [blame] | 548 | if (!IS_ERR(data->clk)) |
| 549 | clk_disable_unprepare(data->clk); |
| 550 | |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 551 | pm_runtime_disable(&pdev->dev); |
| 552 | pm_runtime_put_noidle(&pdev->dev); |
| 553 | |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 554 | return 0; |
| 555 | } |
| 556 | |
Mika Westerberg | 13b949f | 2014-01-16 14:55:57 +0200 | [diff] [blame] | 557 | #ifdef CONFIG_PM_SLEEP |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 558 | static int dw8250_suspend(struct device *dev) |
James Hogan | b61c5ed | 2012-10-15 10:25:58 +0100 | [diff] [blame] | 559 | { |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 560 | struct dw8250_data *data = dev_get_drvdata(dev); |
James Hogan | b61c5ed | 2012-10-15 10:25:58 +0100 | [diff] [blame] | 561 | |
| 562 | serial8250_suspend_port(data->line); |
| 563 | |
| 564 | return 0; |
| 565 | } |
| 566 | |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 567 | static int dw8250_resume(struct device *dev) |
James Hogan | b61c5ed | 2012-10-15 10:25:58 +0100 | [diff] [blame] | 568 | { |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 569 | struct dw8250_data *data = dev_get_drvdata(dev); |
James Hogan | b61c5ed | 2012-10-15 10:25:58 +0100 | [diff] [blame] | 570 | |
| 571 | serial8250_resume_port(data->line); |
| 572 | |
| 573 | return 0; |
| 574 | } |
Mika Westerberg | 13b949f | 2014-01-16 14:55:57 +0200 | [diff] [blame] | 575 | #endif /* CONFIG_PM_SLEEP */ |
James Hogan | b61c5ed | 2012-10-15 10:25:58 +0100 | [diff] [blame] | 576 | |
Rafael J. Wysocki | d39fe4e | 2014-12-13 00:41:36 +0100 | [diff] [blame] | 577 | #ifdef CONFIG_PM |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 578 | static int dw8250_runtime_suspend(struct device *dev) |
| 579 | { |
| 580 | struct dw8250_data *data = dev_get_drvdata(dev); |
| 581 | |
Ezequiel Garcia | dbd2df8 | 2013-05-07 08:27:16 -0300 | [diff] [blame] | 582 | if (!IS_ERR(data->clk)) |
| 583 | clk_disable_unprepare(data->clk); |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 584 | |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 585 | if (!IS_ERR(data->pclk)) |
| 586 | clk_disable_unprepare(data->pclk); |
| 587 | |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 588 | return 0; |
| 589 | } |
| 590 | |
| 591 | static int dw8250_runtime_resume(struct device *dev) |
| 592 | { |
| 593 | struct dw8250_data *data = dev_get_drvdata(dev); |
| 594 | |
Heiko Stübner | 7d78cbe | 2014-06-16 15:25:17 +0200 | [diff] [blame] | 595 | if (!IS_ERR(data->pclk)) |
| 596 | clk_prepare_enable(data->pclk); |
| 597 | |
Ezequiel Garcia | dbd2df8 | 2013-05-07 08:27:16 -0300 | [diff] [blame] | 598 | if (!IS_ERR(data->clk)) |
| 599 | clk_prepare_enable(data->clk); |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 600 | |
| 601 | return 0; |
| 602 | } |
| 603 | #endif |
| 604 | |
| 605 | static const struct dev_pm_ops dw8250_pm_ops = { |
| 606 | SET_SYSTEM_SLEEP_PM_OPS(dw8250_suspend, dw8250_resume) |
| 607 | SET_RUNTIME_PM_OPS(dw8250_runtime_suspend, dw8250_runtime_resume, NULL) |
| 608 | }; |
| 609 | |
Heikki Krogerus | a7260c8 | 2013-01-10 11:25:08 +0200 | [diff] [blame] | 610 | static const struct of_device_id dw8250_of_match[] = { |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 611 | { .compatible = "snps,dw-apb-uart" }, |
David Daney | d5f1af7 | 2013-06-19 20:37:27 +0000 | [diff] [blame] | 612 | { .compatible = "cavium,octeon-3860-uart" }, |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 613 | { /* Sentinel */ } |
| 614 | }; |
Heikki Krogerus | a7260c8 | 2013-01-10 11:25:08 +0200 | [diff] [blame] | 615 | MODULE_DEVICE_TABLE(of, dw8250_of_match); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 616 | |
Heikki Krogerus | 6a7320c | 2013-01-10 11:25:10 +0200 | [diff] [blame] | 617 | static const struct acpi_device_id dw8250_acpi_match[] = { |
Heikki Krogerus | aea02e8 | 2013-04-10 16:58:29 +0300 | [diff] [blame] | 618 | { "INT33C4", 0 }, |
| 619 | { "INT33C5", 0 }, |
Mika Westerberg | d24c195 | 2013-12-10 12:56:59 +0200 | [diff] [blame] | 620 | { "INT3434", 0 }, |
| 621 | { "INT3435", 0 }, |
Heikki Krogerus | 4e26b13 | 2014-06-05 16:51:40 +0300 | [diff] [blame] | 622 | { "80860F0A", 0 }, |
Alan Cox | f174442 | 2014-08-19 16:34:49 +0300 | [diff] [blame] | 623 | { "8086228A", 0 }, |
Feng Kan | 5e1aeea | 2014-12-05 17:45:57 -0800 | [diff] [blame] | 624 | { "APMC0D08", 0}, |
Ken Xue | 5ef86b7 | 2015-03-09 17:10:13 +0800 | [diff] [blame] | 625 | { "AMD0020", 0 }, |
Heikki Krogerus | 6a7320c | 2013-01-10 11:25:10 +0200 | [diff] [blame] | 626 | { }, |
| 627 | }; |
| 628 | MODULE_DEVICE_TABLE(acpi, dw8250_acpi_match); |
| 629 | |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 630 | static struct platform_driver dw8250_platform_driver = { |
| 631 | .driver = { |
| 632 | .name = "dw-apb-uart", |
Heikki Krogerus | ffc3ae6 | 2013-04-10 16:58:28 +0300 | [diff] [blame] | 633 | .pm = &dw8250_pm_ops, |
Heikki Krogerus | a7260c8 | 2013-01-10 11:25:08 +0200 | [diff] [blame] | 634 | .of_match_table = dw8250_of_match, |
Heikki Krogerus | 6a7320c | 2013-01-10 11:25:10 +0200 | [diff] [blame] | 635 | .acpi_match_table = ACPI_PTR(dw8250_acpi_match), |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 636 | }, |
| 637 | .probe = dw8250_probe, |
Bill Pemberton | 2d47b71 | 2012-11-19 13:21:34 -0500 | [diff] [blame] | 638 | .remove = dw8250_remove, |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 639 | }; |
| 640 | |
Axel Lin | c8381c15 | 2011-11-28 19:22:15 +0800 | [diff] [blame] | 641 | module_platform_driver(dw8250_platform_driver); |
Jamie Iles | 7d4008e | 2011-08-26 19:04:50 +0100 | [diff] [blame] | 642 | |
| 643 | MODULE_AUTHOR("Jamie Iles"); |
| 644 | MODULE_LICENSE("GPL"); |
| 645 | MODULE_DESCRIPTION("Synopsys DesignWare 8250 serial port driver"); |
Mika Westerberg | f3ac3fc | 2015-02-04 15:03:48 +0200 | [diff] [blame] | 646 | MODULE_ALIAS("platform:dw-apb-uart"); |