| .. | .. |
|---|
| 7 | 7 | #include <linux/console.h> |
|---|
| 8 | 8 | #include <linux/module.h> |
|---|
| 9 | 9 | #include <linux/slab.h> |
|---|
| 10 | | -#include <linux/delay.h> |
|---|
| 11 | 10 | #include <linux/serial_core.h> |
|---|
| 12 | 11 | #include <linux/serial_reg.h> |
|---|
| 13 | 12 | #include <linux/of_address.h> |
|---|
| .. | .. |
|---|
| 26 | 25 | int line; |
|---|
| 27 | 26 | }; |
|---|
| 28 | 27 | |
|---|
| 29 | | -#ifdef CONFIG_ARCH_TEGRA |
|---|
| 30 | | -static void tegra_serial_handle_break(struct uart_port *p) |
|---|
| 31 | | -{ |
|---|
| 32 | | - unsigned int status, tmout = 10000; |
|---|
| 33 | | - |
|---|
| 34 | | - do { |
|---|
| 35 | | - status = p->serial_in(p, UART_LSR); |
|---|
| 36 | | - if (status & (UART_LSR_FIFOE | UART_LSR_BRK_ERROR_BITS)) |
|---|
| 37 | | - status = p->serial_in(p, UART_RX); |
|---|
| 38 | | - else |
|---|
| 39 | | - break; |
|---|
| 40 | | - if (--tmout == 0) |
|---|
| 41 | | - break; |
|---|
| 42 | | - udelay(1); |
|---|
| 43 | | - } while (1); |
|---|
| 44 | | -} |
|---|
| 45 | | -#else |
|---|
| 46 | | -static inline void tegra_serial_handle_break(struct uart_port *port) |
|---|
| 47 | | -{ |
|---|
| 48 | | -} |
|---|
| 49 | | -#endif |
|---|
| 50 | | - |
|---|
| 51 | 28 | /* |
|---|
| 52 | 29 | * Fill a struct uart_port for a given device node |
|---|
| 53 | 30 | */ |
|---|
| 54 | 31 | static int of_platform_serial_setup(struct platform_device *ofdev, |
|---|
| 55 | | - int type, struct uart_port *port, |
|---|
| 32 | + int type, struct uart_8250_port *up, |
|---|
| 56 | 33 | struct of_serial_info *info) |
|---|
| 57 | 34 | { |
|---|
| 58 | 35 | struct resource resource; |
|---|
| 59 | 36 | struct device_node *np = ofdev->dev.of_node; |
|---|
| 37 | + struct uart_port *port = &up->port; |
|---|
| 60 | 38 | u32 clk, spd, prop; |
|---|
| 61 | 39 | int ret, irq; |
|---|
| 62 | 40 | |
|---|
| .. | .. |
|---|
| 70 | 48 | /* Get clk rate through clk driver if present */ |
|---|
| 71 | 49 | info->clk = devm_clk_get(&ofdev->dev, NULL); |
|---|
| 72 | 50 | if (IS_ERR(info->clk)) { |
|---|
| 73 | | - dev_warn(&ofdev->dev, |
|---|
| 74 | | - "clk or clock-frequency not defined\n"); |
|---|
| 75 | 51 | ret = PTR_ERR(info->clk); |
|---|
| 52 | + if (ret != -EPROBE_DEFER) |
|---|
| 53 | + dev_warn(&ofdev->dev, |
|---|
| 54 | + "failed to get clock: %d\n", ret); |
|---|
| 76 | 55 | goto err_pmruntime; |
|---|
| 77 | 56 | } |
|---|
| 78 | 57 | |
|---|
| .. | .. |
|---|
| 185 | 164 | port->flags |= UPF_SKIP_TEST; |
|---|
| 186 | 165 | |
|---|
| 187 | 166 | port->dev = &ofdev->dev; |
|---|
| 167 | + port->rs485_config = serial8250_em485_config; |
|---|
| 168 | + up->rs485_start_tx = serial8250_em485_start_tx; |
|---|
| 169 | + up->rs485_stop_tx = serial8250_em485_stop_tx; |
|---|
| 188 | 170 | |
|---|
| 189 | 171 | switch (type) { |
|---|
| 190 | | - case PORT_TEGRA: |
|---|
| 191 | | - port->handle_break = tegra_serial_handle_break; |
|---|
| 192 | | - break; |
|---|
| 193 | | - |
|---|
| 194 | 172 | case PORT_RT2880: |
|---|
| 195 | 173 | port->iotype = UPIO_AU; |
|---|
| 196 | 174 | break; |
|---|
| .. | .. |
|---|
| 198 | 176 | |
|---|
| 199 | 177 | if (IS_ENABLED(CONFIG_SERIAL_8250_FSL) && |
|---|
| 200 | 178 | (of_device_is_compatible(np, "fsl,ns16550") || |
|---|
| 201 | | - of_device_is_compatible(np, "fsl,16550-FIFO64"))) |
|---|
| 179 | + of_device_is_compatible(np, "fsl,16550-FIFO64"))) { |
|---|
| 202 | 180 | port->handle_irq = fsl8250_handle_irq; |
|---|
| 181 | + port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_8250_CONSOLE); |
|---|
| 182 | + } |
|---|
| 203 | 183 | |
|---|
| 204 | 184 | return 0; |
|---|
| 205 | 185 | err_unprepare: |
|---|
| .. | .. |
|---|
| 213 | 193 | /* |
|---|
| 214 | 194 | * Try to register a serial port |
|---|
| 215 | 195 | */ |
|---|
| 216 | | -static const struct of_device_id of_platform_serial_table[]; |
|---|
| 217 | 196 | static int of_platform_serial_probe(struct platform_device *ofdev) |
|---|
| 218 | 197 | { |
|---|
| 219 | | - const struct of_device_id *match; |
|---|
| 220 | 198 | struct of_serial_info *info; |
|---|
| 221 | 199 | struct uart_8250_port port8250; |
|---|
| 200 | + unsigned int port_type; |
|---|
| 222 | 201 | u32 tx_threshold; |
|---|
| 223 | | - int port_type; |
|---|
| 224 | 202 | int ret; |
|---|
| 225 | 203 | |
|---|
| 226 | | - match = of_match_device(of_platform_serial_table, &ofdev->dev); |
|---|
| 227 | | - if (!match) |
|---|
| 204 | + port_type = (unsigned long)of_device_get_match_data(&ofdev->dev); |
|---|
| 205 | + if (port_type == PORT_UNKNOWN) |
|---|
| 228 | 206 | return -EINVAL; |
|---|
| 229 | 207 | |
|---|
| 230 | 208 | if (of_property_read_bool(ofdev->dev.of_node, "used-by-rtas")) |
|---|
| .. | .. |
|---|
| 234 | 212 | if (info == NULL) |
|---|
| 235 | 213 | return -ENOMEM; |
|---|
| 236 | 214 | |
|---|
| 237 | | - port_type = (unsigned long)match->data; |
|---|
| 238 | 215 | memset(&port8250, 0, sizeof(port8250)); |
|---|
| 239 | | - ret = of_platform_serial_setup(ofdev, port_type, &port8250.port, info); |
|---|
| 216 | + ret = of_platform_serial_setup(ofdev, port_type, &port8250, info); |
|---|
| 240 | 217 | if (ret) |
|---|
| 241 | 218 | goto err_free; |
|---|
| 242 | 219 | |
|---|
| .. | .. |
|---|
| 336 | 313 | { .compatible = "ns16550", .data = (void *)PORT_16550, }, |
|---|
| 337 | 314 | { .compatible = "ns16750", .data = (void *)PORT_16750, }, |
|---|
| 338 | 315 | { .compatible = "ns16850", .data = (void *)PORT_16850, }, |
|---|
| 339 | | - { .compatible = "nvidia,tegra20-uart", .data = (void *)PORT_TEGRA, }, |
|---|
| 340 | 316 | { .compatible = "nxp,lpc3220-uart", .data = (void *)PORT_LPC3220, }, |
|---|
| 341 | 317 | { .compatible = "ralink,rt2880-uart", .data = (void *)PORT_RT2880, }, |
|---|
| 318 | + { .compatible = "intel,xscale-uart", .data = (void *)PORT_XSCALE, }, |
|---|
| 342 | 319 | { .compatible = "altr,16550-FIFO32", |
|---|
| 343 | 320 | .data = (void *)PORT_ALTR_16550_F32, }, |
|---|
| 344 | 321 | { .compatible = "altr,16550-FIFO64", |
|---|