Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Serial Port driver for Open Firmware platform devices |
| 3 | * |
| 4 | * Copyright (C) 2006 Arnd Bergmann <arnd@arndb.de>, IBM Corp. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | */ |
Jingchang Lu | 8ad3b13 | 2014-11-11 15:09:05 +0800 | [diff] [blame] | 12 | #include <linux/console.h> |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 13 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 14 | #include <linux/slab.h> |
Dan Williams | bf03f65 | 2012-04-10 14:10:53 -0700 | [diff] [blame] | 15 | #include <linux/delay.h> |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 16 | #include <linux/serial_core.h> |
Dan Williams | bf03f65 | 2012-04-10 14:10:53 -0700 | [diff] [blame] | 17 | #include <linux/serial_reg.h> |
Grant Likely | f1ca09b | 2010-08-16 23:44:49 -0600 | [diff] [blame] | 18 | #include <linux/of_address.h> |
Rob Herring | 73930a8 | 2010-11-17 17:50:23 -0600 | [diff] [blame] | 19 | #include <linux/of_irq.h> |
Stephen Rothwell | c401b04 | 2008-05-23 16:32:54 +1000 | [diff] [blame] | 20 | #include <linux/of_platform.h> |
Benjamin Krill | 5886188d | 2009-01-07 10:32:38 +0100 | [diff] [blame] | 21 | #include <linux/nwpserial.h> |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 22 | #include <linux/clk.h> |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 23 | |
Martin Sperl | ed4492f | 2015-09-11 11:38:03 +0000 | [diff] [blame] | 24 | #ifdef CONFIG_SERIAL_8250_MODULE |
| 25 | #define CONFIG_SERIAL_8250 CONFIG_SERIAL_8250_MODULE |
| 26 | #endif |
| 27 | |
Heikki Krogerus | b0b8c84 | 2013-03-25 15:51:15 +0200 | [diff] [blame] | 28 | #include "8250/8250.h" |
| 29 | |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 30 | struct of_serial_info { |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 31 | struct clk *clk; |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 32 | int type; |
| 33 | int line; |
| 34 | }; |
| 35 | |
Dan Williams | bf03f65 | 2012-04-10 14:10:53 -0700 | [diff] [blame] | 36 | #ifdef CONFIG_ARCH_TEGRA |
| 37 | void tegra_serial_handle_break(struct uart_port *p) |
| 38 | { |
| 39 | unsigned int status, tmout = 10000; |
| 40 | |
| 41 | do { |
| 42 | status = p->serial_in(p, UART_LSR); |
| 43 | if (status & (UART_LSR_FIFOE | UART_LSR_BRK_ERROR_BITS)) |
| 44 | status = p->serial_in(p, UART_RX); |
| 45 | else |
| 46 | break; |
| 47 | if (--tmout == 0) |
| 48 | break; |
| 49 | udelay(1); |
| 50 | } while (1); |
| 51 | } |
Stephen Warren | f26402e | 2013-01-31 12:01:53 -0700 | [diff] [blame] | 52 | #else |
| 53 | static inline void tegra_serial_handle_break(struct uart_port *port) |
| 54 | { |
| 55 | } |
Dan Williams | bf03f65 | 2012-04-10 14:10:53 -0700 | [diff] [blame] | 56 | #endif |
| 57 | |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 58 | /* |
| 59 | * Fill a struct uart_port for a given device node |
| 60 | */ |
Bill Pemberton | 9671f09 | 2012-11-19 13:21:50 -0500 | [diff] [blame] | 61 | static int of_platform_serial_setup(struct platform_device *ofdev, |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 62 | int type, struct uart_port *port, |
| 63 | struct of_serial_info *info) |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 64 | { |
| 65 | struct resource resource; |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 66 | struct device_node *np = ofdev->dev.of_node; |
Grant Likely | b84e773 | 2011-06-30 12:39:12 -0600 | [diff] [blame] | 67 | u32 clk, spd, prop; |
| 68 | int ret; |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 69 | |
| 70 | memset(port, 0, sizeof *port); |
Grant Likely | b84e773 | 2011-06-30 12:39:12 -0600 | [diff] [blame] | 71 | if (of_property_read_u32(np, "clock-frequency", &clk)) { |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 72 | |
| 73 | /* Get clk rate through clk driver if present */ |
Masahiro Yamada | 3a63d22 | 2015-05-25 14:57:43 +0900 | [diff] [blame] | 74 | info->clk = devm_clk_get(&ofdev->dev, NULL); |
Wei Yongjun | 76cc438 | 2012-11-01 13:27:34 +0800 | [diff] [blame] | 75 | if (IS_ERR(info->clk)) { |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 76 | dev_warn(&ofdev->dev, |
| 77 | "clk or clock-frequency not defined\n"); |
Wei Yongjun | 76cc438 | 2012-11-01 13:27:34 +0800 | [diff] [blame] | 78 | return PTR_ERR(info->clk); |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 79 | } |
| 80 | |
Masahiro Yamada | 6f0c309 | 2015-05-25 15:03:32 +0900 | [diff] [blame] | 81 | ret = clk_prepare_enable(info->clk); |
| 82 | if (ret < 0) |
| 83 | return ret; |
| 84 | |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 85 | clk = clk_get_rate(info->clk); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 86 | } |
Grant Likely | b84e773 | 2011-06-30 12:39:12 -0600 | [diff] [blame] | 87 | /* If current-speed was set, then try not to change it. */ |
| 88 | if (of_property_read_u32(np, "current-speed", &spd) == 0) |
| 89 | port->custom_divisor = clk / (16 * spd); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 90 | |
| 91 | ret = of_address_to_resource(np, 0, &resource); |
| 92 | if (ret) { |
| 93 | dev_warn(&ofdev->dev, "invalid address\n"); |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 94 | goto out; |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | spin_lock_init(&port->lock); |
| 98 | port->mapbase = resource.start; |
Mans Rullgard | 0787691 | 2015-03-08 14:30:05 +0000 | [diff] [blame] | 99 | port->mapsize = resource_size(&resource); |
John Linn | b912b5e | 2008-04-03 10:22:19 +1100 | [diff] [blame] | 100 | |
| 101 | /* Check for shifted address mapping */ |
Grant Likely | b84e773 | 2011-06-30 12:39:12 -0600 | [diff] [blame] | 102 | if (of_property_read_u32(np, "reg-offset", &prop) == 0) |
| 103 | port->mapbase += prop; |
John Linn | b912b5e | 2008-04-03 10:22:19 +1100 | [diff] [blame] | 104 | |
| 105 | /* Check for registers offset within the devices address range */ |
Grant Likely | b84e773 | 2011-06-30 12:39:12 -0600 | [diff] [blame] | 106 | if (of_property_read_u32(np, "reg-shift", &prop) == 0) |
| 107 | port->regshift = prop; |
John Linn | b912b5e | 2008-04-03 10:22:19 +1100 | [diff] [blame] | 108 | |
Heikki Krogerus | 9f1ca06 | 2013-03-25 13:34:45 +0200 | [diff] [blame] | 109 | /* Check for fifo size */ |
| 110 | if (of_property_read_u32(np, "fifo-size", &prop) == 0) |
| 111 | port->fifosize = prop; |
| 112 | |
Lucas Stach | 3239fd3 | 2014-12-05 20:21:57 +0100 | [diff] [blame] | 113 | /* Check for a fixed line number */ |
| 114 | ret = of_alias_get_id(np, "serial"); |
| 115 | if (ret >= 0) |
| 116 | port->line = ret; |
| 117 | |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 118 | port->irq = irq_of_parse_and_map(np, 0); |
| 119 | port->iotype = UPIO_MEM; |
Grant Likely | b84e773 | 2011-06-30 12:39:12 -0600 | [diff] [blame] | 120 | if (of_property_read_u32(np, "reg-io-width", &prop) == 0) { |
| 121 | switch (prop) { |
Jamie Iles | 7423734 | 2011-06-27 13:32:34 +0100 | [diff] [blame] | 122 | case 1: |
| 123 | port->iotype = UPIO_MEM; |
| 124 | break; |
Masahiro Yamada | bd94c40 | 2015-10-28 12:46:05 +0900 | [diff] [blame] | 125 | case 2: |
| 126 | port->iotype = UPIO_MEM16; |
| 127 | break; |
Jamie Iles | 7423734 | 2011-06-27 13:32:34 +0100 | [diff] [blame] | 128 | case 4: |
Kevin Cernekee | ebc5e20 | 2015-04-09 13:05:18 -0700 | [diff] [blame] | 129 | port->iotype = of_device_is_big_endian(np) ? |
| 130 | UPIO_MEM32BE : UPIO_MEM32; |
Jamie Iles | 7423734 | 2011-06-27 13:32:34 +0100 | [diff] [blame] | 131 | break; |
| 132 | default: |
Grant Likely | b84e773 | 2011-06-30 12:39:12 -0600 | [diff] [blame] | 133 | dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n", |
| 134 | prop); |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 135 | ret = -EINVAL; |
| 136 | goto out; |
Jamie Iles | 7423734 | 2011-06-27 13:32:34 +0100 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 140 | port->type = type; |
Grant Likely | b84e773 | 2011-06-30 12:39:12 -0600 | [diff] [blame] | 141 | port->uartclk = clk; |
David Gibson | abb4a23 | 2007-05-06 14:48:49 -0700 | [diff] [blame] | 142 | port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP |
Dave Mitchell | eedacbf | 2009-06-09 13:39:47 +0000 | [diff] [blame] | 143 | | UPF_FIXED_PORT | UPF_FIXED_TYPE; |
Gabor Juhos | fde8be2 | 2012-07-17 17:08:31 +0100 | [diff] [blame] | 144 | |
| 145 | if (of_find_property(np, "no-loopback-test", NULL)) |
| 146 | port->flags |= UPF_SKIP_TEST; |
| 147 | |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 148 | port->dev = &ofdev->dev; |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 149 | |
John Crispin | 9b8777e | 2014-10-16 21:48:21 +0200 | [diff] [blame] | 150 | switch (type) { |
| 151 | case PORT_TEGRA: |
Dan Williams | bf03f65 | 2012-04-10 14:10:53 -0700 | [diff] [blame] | 152 | port->handle_break = tegra_serial_handle_break; |
John Crispin | 9b8777e | 2014-10-16 21:48:21 +0200 | [diff] [blame] | 153 | break; |
| 154 | |
| 155 | case PORT_RT2880: |
| 156 | port->iotype = UPIO_AU; |
| 157 | break; |
| 158 | } |
Dan Williams | bf03f65 | 2012-04-10 14:10:53 -0700 | [diff] [blame] | 159 | |
Scott Wood | d43b54d | 2015-10-07 17:31:21 -0500 | [diff] [blame] | 160 | if (IS_ENABLED(CONFIG_SERIAL_8250_FSL) && |
| 161 | (of_device_is_compatible(np, "fsl,ns16550") || |
| 162 | of_device_is_compatible(np, "fsl,16550-FIFO64"))) |
| 163 | port->handle_irq = fsl8250_handle_irq; |
| 164 | |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 165 | return 0; |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 166 | out: |
| 167 | if (info->clk) |
| 168 | clk_disable_unprepare(info->clk); |
| 169 | return ret; |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | /* |
| 173 | * Try to register a serial port |
| 174 | */ |
Fabian Frederick | ed0bb23 | 2015-03-16 20:17:11 +0100 | [diff] [blame] | 175 | static const struct of_device_id of_platform_serial_table[]; |
Bill Pemberton | 9671f09 | 2012-11-19 13:21:50 -0500 | [diff] [blame] | 176 | static int of_platform_serial_probe(struct platform_device *ofdev) |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 177 | { |
Grant Likely | b1608d6 | 2011-05-18 11:19:24 -0600 | [diff] [blame] | 178 | const struct of_device_id *match; |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 179 | struct of_serial_info *info; |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 180 | struct uart_port port; |
| 181 | int port_type; |
| 182 | int ret; |
| 183 | |
Grant Likely | b1608d6 | 2011-05-18 11:19:24 -0600 | [diff] [blame] | 184 | match = of_match_device(of_platform_serial_table, &ofdev->dev); |
| 185 | if (!match) |
Grant Likely | 793218d | 2011-02-22 21:10:26 -0700 | [diff] [blame] | 186 | return -EINVAL; |
| 187 | |
Grant Likely | 61c7a08 | 2010-04-13 16:12:29 -0700 | [diff] [blame] | 188 | if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 189 | return -EBUSY; |
| 190 | |
Jingchang Lu | 7e12e67 | 2014-10-21 16:50:21 +0800 | [diff] [blame] | 191 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 192 | if (info == NULL) |
| 193 | return -ENOMEM; |
| 194 | |
Grant Likely | b1608d6 | 2011-05-18 11:19:24 -0600 | [diff] [blame] | 195 | port_type = (unsigned long)match->data; |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 196 | ret = of_platform_serial_setup(ofdev, port_type, &port, info); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 197 | if (ret) |
| 198 | goto out; |
| 199 | |
| 200 | switch (port_type) { |
Benjamin Krill | 5886188d | 2009-01-07 10:32:38 +0100 | [diff] [blame] | 201 | #ifdef CONFIG_SERIAL_8250 |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 202 | case PORT_8250 ... PORT_MAX_8250: |
Alan Cox | ce7240e | 2012-07-17 17:06:20 +0100 | [diff] [blame] | 203 | { |
Alan Cox | ce7240e | 2012-07-17 17:06:20 +0100 | [diff] [blame] | 204 | struct uart_8250_port port8250; |
| 205 | memset(&port8250, 0, sizeof(port8250)); |
| 206 | port8250.port = port; |
Heikki Krogerus | b0b8c84 | 2013-03-25 15:51:15 +0200 | [diff] [blame] | 207 | |
| 208 | if (port.fifosize) |
| 209 | port8250.capabilities = UART_CAP_FIFO; |
| 210 | |
| 211 | if (of_property_read_bool(ofdev->dev.of_node, |
| 212 | "auto-flow-control")) |
| 213 | port8250.capabilities |= UART_CAP_AFE; |
| 214 | |
Alan Cox | ce7240e | 2012-07-17 17:06:20 +0100 | [diff] [blame] | 215 | ret = serial8250_register_8250_port(&port8250); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 216 | break; |
Alan Cox | ce7240e | 2012-07-17 17:06:20 +0100 | [diff] [blame] | 217 | } |
Benjamin Krill | 5886188d | 2009-01-07 10:32:38 +0100 | [diff] [blame] | 218 | #endif |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 219 | default: |
| 220 | /* need to add code for these */ |
Ishizaki Kou | 1558f9b | 2007-05-31 19:30:33 +1000 | [diff] [blame] | 221 | case PORT_UNKNOWN: |
| 222 | dev_info(&ofdev->dev, "Unknown serial port found, ignored\n"); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 223 | ret = -ENODEV; |
| 224 | break; |
| 225 | } |
| 226 | if (ret < 0) |
| 227 | goto out; |
| 228 | |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 229 | info->type = port_type; |
| 230 | info->line = ret; |
Jingoo Han | 696faed | 2013-05-23 19:39:36 +0900 | [diff] [blame] | 231 | platform_set_drvdata(ofdev, info); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 232 | return 0; |
| 233 | out: |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 234 | kfree(info); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 235 | irq_dispose_mapping(port.irq); |
| 236 | return ret; |
| 237 | } |
| 238 | |
| 239 | /* |
| 240 | * Release a line |
| 241 | */ |
Grant Likely | 2dc1158 | 2010-08-06 09:25:50 -0600 | [diff] [blame] | 242 | static int of_platform_serial_remove(struct platform_device *ofdev) |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 243 | { |
Jingoo Han | 696faed | 2013-05-23 19:39:36 +0900 | [diff] [blame] | 244 | struct of_serial_info *info = platform_get_drvdata(ofdev); |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 245 | switch (info->type) { |
Benjamin Krill | 5886188d | 2009-01-07 10:32:38 +0100 | [diff] [blame] | 246 | #ifdef CONFIG_SERIAL_8250 |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 247 | case PORT_8250 ... PORT_MAX_8250: |
| 248 | serial8250_unregister_port(info->line); |
| 249 | break; |
Benjamin Krill | 5886188d | 2009-01-07 10:32:38 +0100 | [diff] [blame] | 250 | #endif |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 251 | default: |
| 252 | /* need to add code for these */ |
| 253 | break; |
| 254 | } |
Murali Karicheri | 0bbeb3c | 2012-10-22 11:58:01 -0400 | [diff] [blame] | 255 | |
| 256 | if (info->clk) |
| 257 | clk_disable_unprepare(info->clk); |
Ishizaki Kou | e34b9c9 | 2007-05-31 19:33:04 +1000 | [diff] [blame] | 258 | kfree(info); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 259 | return 0; |
| 260 | } |
| 261 | |
Jingchang Lu | 8ad3b13 | 2014-11-11 15:09:05 +0800 | [diff] [blame] | 262 | #ifdef CONFIG_PM_SLEEP |
| 263 | #ifdef CONFIG_SERIAL_8250 |
| 264 | static void of_serial_suspend_8250(struct of_serial_info *info) |
| 265 | { |
| 266 | struct uart_8250_port *port8250 = serial8250_get_port(info->line); |
| 267 | struct uart_port *port = &port8250->port; |
| 268 | |
| 269 | serial8250_suspend_port(info->line); |
| 270 | if (info->clk && (!uart_console(port) || console_suspend_enabled)) |
| 271 | clk_disable_unprepare(info->clk); |
| 272 | } |
| 273 | |
| 274 | static void of_serial_resume_8250(struct of_serial_info *info) |
| 275 | { |
| 276 | struct uart_8250_port *port8250 = serial8250_get_port(info->line); |
| 277 | struct uart_port *port = &port8250->port; |
| 278 | |
| 279 | if (info->clk && (!uart_console(port) || console_suspend_enabled)) |
| 280 | clk_prepare_enable(info->clk); |
| 281 | |
| 282 | serial8250_resume_port(info->line); |
| 283 | } |
| 284 | #else |
| 285 | static inline void of_serial_suspend_8250(struct of_serial_info *info) |
| 286 | { |
| 287 | } |
| 288 | |
| 289 | static inline void of_serial_resume_8250(struct of_serial_info *info) |
| 290 | { |
| 291 | } |
| 292 | #endif |
| 293 | |
| 294 | static int of_serial_suspend(struct device *dev) |
| 295 | { |
| 296 | struct of_serial_info *info = dev_get_drvdata(dev); |
| 297 | |
| 298 | switch (info->type) { |
| 299 | case PORT_8250 ... PORT_MAX_8250: |
| 300 | of_serial_suspend_8250(info); |
| 301 | break; |
| 302 | default: |
| 303 | break; |
| 304 | } |
| 305 | |
| 306 | return 0; |
| 307 | } |
| 308 | |
| 309 | static int of_serial_resume(struct device *dev) |
| 310 | { |
| 311 | struct of_serial_info *info = dev_get_drvdata(dev); |
| 312 | |
| 313 | switch (info->type) { |
| 314 | case PORT_8250 ... PORT_MAX_8250: |
| 315 | of_serial_resume_8250(info); |
| 316 | break; |
| 317 | default: |
| 318 | break; |
| 319 | } |
| 320 | |
| 321 | return 0; |
| 322 | } |
| 323 | #endif |
| 324 | static SIMPLE_DEV_PM_OPS(of_serial_pm_ops, of_serial_suspend, of_serial_resume); |
| 325 | |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 326 | /* |
| 327 | * A few common types, add more as needed. |
| 328 | */ |
Fabian Frederick | ed0bb23 | 2015-03-16 20:17:11 +0100 | [diff] [blame] | 329 | static const struct of_device_id of_platform_serial_table[] = { |
Grant Likely | 8c6e911 | 2011-02-22 19:12:21 -0700 | [diff] [blame] | 330 | { .compatible = "ns8250", .data = (void *)PORT_8250, }, |
| 331 | { .compatible = "ns16450", .data = (void *)PORT_16450, }, |
| 332 | { .compatible = "ns16550a", .data = (void *)PORT_16550A, }, |
| 333 | { .compatible = "ns16550", .data = (void *)PORT_16550, }, |
| 334 | { .compatible = "ns16750", .data = (void *)PORT_16750, }, |
| 335 | { .compatible = "ns16850", .data = (void *)PORT_16850, }, |
Grant Likely | 2e39e5b | 2011-07-05 23:42:36 -0600 | [diff] [blame] | 336 | { .compatible = "nvidia,tegra20-uart", .data = (void *)PORT_TEGRA, }, |
Roland Stigge | e4305f0 | 2012-06-11 21:57:14 +0200 | [diff] [blame] | 337 | { .compatible = "nxp,lpc3220-uart", .data = (void *)PORT_LPC3220, }, |
John Crispin | 9b8777e | 2014-10-16 21:48:21 +0200 | [diff] [blame] | 338 | { .compatible = "ralink,rt2880-uart", .data = (void *)PORT_RT2880, }, |
Ley Foon Tan | e06c93c | 2013-03-07 10:28:37 +0800 | [diff] [blame] | 339 | { .compatible = "altr,16550-FIFO32", |
| 340 | .data = (void *)PORT_ALTR_16550_F32, }, |
| 341 | { .compatible = "altr,16550-FIFO64", |
| 342 | .data = (void *)PORT_ALTR_16550_F64, }, |
| 343 | { .compatible = "altr,16550-FIFO128", |
| 344 | .data = (void *)PORT_ALTR_16550_F128, }, |
Rob Herring | 6ad991b | 2015-01-26 22:50:08 -0600 | [diff] [blame] | 345 | { .compatible = "mrvl,mmp-uart", |
| 346 | .data = (void *)PORT_XSCALE, }, |
| 347 | { .compatible = "mrvl,pxa-uart", |
| 348 | .data = (void *)PORT_XSCALE, }, |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 349 | { /* end of list */ }, |
| 350 | }; |
Luis de Bethencourt | 8d58db1 | 2015-09-18 20:03:43 +0200 | [diff] [blame] | 351 | MODULE_DEVICE_TABLE(of, of_platform_serial_table); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 352 | |
Grant Likely | 793218d | 2011-02-22 21:10:26 -0700 | [diff] [blame] | 353 | static struct platform_driver of_platform_serial_driver = { |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 354 | .driver = { |
| 355 | .name = "of_serial", |
Grant Likely | 4018294 | 2010-04-13 16:13:02 -0700 | [diff] [blame] | 356 | .of_match_table = of_platform_serial_table, |
| 357 | }, |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 358 | .probe = of_platform_serial_probe, |
| 359 | .remove = of_platform_serial_remove, |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 360 | }; |
| 361 | |
Grant Likely | 940ab88 | 2011-10-05 11:29:49 -0600 | [diff] [blame] | 362 | module_platform_driver(of_platform_serial_driver); |
Arnd Bergmann | 8d38a5b | 2007-02-13 21:35:38 +0100 | [diff] [blame] | 363 | |
| 364 | MODULE_AUTHOR("Arnd Bergmann <arnd@arndb.de>"); |
| 365 | MODULE_LICENSE("GPL"); |
| 366 | MODULE_DESCRIPTION("Serial Port driver for Open Firmware platform devices"); |