diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-05 13:30:48 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-09-05 13:30:48 -0400 |
commit | e63a94f12b5fc67b2b92a89d4058e7a9021e900e (patch) | |
tree | 9fddf35df3289bd41c2310937bf2faed4d036603 | |
parent | 1a3b85ea36d38d5732fdd86b321b10bcaeb53512 (diff) | |
parent | 3840ed9548f778717aaab5eab744da798c3ea055 (diff) |
Merge tag 'tty-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
Pull tty/serial updates from Greg KH:
"Here is the big tty/serial driver update for 4.14-rc1.
Well, not all that big, just a number of small serial driver fixes,
and a new serial driver. Also in here are some much needed goldfish
tty driver (emulator) fixes to try to get that codebase under control.
All of these have been in linux-next for a while with no reported
issues"
* tag 'tty-4.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (94 commits)
tty: goldfish: Implement support for kernel 'earlycon' parameter
tty: goldfish: Use streaming DMA for r/w operations on Ranchu platforms
tty: goldfish: Refactor constants to better reflect their nature
serial: 8250_port: Remove useless NULL checks
earlycon: initialise baud field of earlycon device structure
tty: hvcs: make ktermios const
pty: show associative slave of ptmx in fdinfo
tty: n_gsm: Add compat_ioctl
tty: hvcs: constify vio_device_id
tty: hvc_vio: constify vio_device_id
tty: mips_ejtag_fdc: constify mips_cdmm_device_id
Introduce 8250_men_mcb
mcb: introduce mcb_get_resource()
serial: imx: Avoid post-PIO cleanup if TX DMA is started
tty: serial: imx: disable irq after suspend
serial: 8250_uniphier: add suspend/resume support
serial: 8250_uniphier: use CHAR register for canary to detect power-off
serial: 8250_uniphier: fix serial port index in private data
serial: 8250: of: Add new port type for MediaTek BTIF controller on MT7622/23 SoC
dt-bindings: serial: 8250: Add MediaTek BTIF controller bindings
...
74 files changed, 1630 insertions, 308 deletions
diff --git a/Documentation/devicetree/bindings/serial/8250.txt b/Documentation/devicetree/bindings/serial/8250.txt index 419ff6c0a47f..dad3b2ec66d4 100644 --- a/Documentation/devicetree/bindings/serial/8250.txt +++ b/Documentation/devicetree/bindings/serial/8250.txt | |||
@@ -14,6 +14,8 @@ Required properties: | |||
14 | tegra132, or tegra210. | 14 | tegra132, or tegra210. |
15 | - "nxp,lpc3220-uart" | 15 | - "nxp,lpc3220-uart" |
16 | - "ralink,rt2880-uart" | 16 | - "ralink,rt2880-uart" |
17 | - For MediaTek BTIF, must contain '"mediatek,<chip>-btif", | ||
18 | "mediatek,mtk-btif"' where <chip> is mt7622, mt7623. | ||
17 | - "altr,16550-FIFO32" | 19 | - "altr,16550-FIFO32" |
18 | - "altr,16550-FIFO64" | 20 | - "altr,16550-FIFO64" |
19 | - "altr,16550-FIFO128" | 21 | - "altr,16550-FIFO128" |
diff --git a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt index 8d27d1a603e7..4fc96946f81d 100644 --- a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt +++ b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt | |||
@@ -41,6 +41,8 @@ Required properties: | |||
41 | - "renesas,hscif-r8a7795" for R8A7795 (R-Car H3) HSCIF compatible UART. | 41 | - "renesas,hscif-r8a7795" for R8A7795 (R-Car H3) HSCIF compatible UART. |
42 | - "renesas,scif-r8a7796" for R8A7796 (R-Car M3-W) SCIF compatible UART. | 42 | - "renesas,scif-r8a7796" for R8A7796 (R-Car M3-W) SCIF compatible UART. |
43 | - "renesas,hscif-r8a7796" for R8A7796 (R-Car M3-W) HSCIF compatible UART. | 43 | - "renesas,hscif-r8a7796" for R8A7796 (R-Car M3-W) HSCIF compatible UART. |
44 | - "renesas,scif-r8a77995" for R8A77995 (R-Car D3) SCIF compatible UART. | ||
45 | - "renesas,hscif-r8a77995" for R8A77995 (R-Car D3) HSCIF compatible UART. | ||
44 | - "renesas,scifa-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFA compatible UART. | 46 | - "renesas,scifa-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFA compatible UART. |
45 | - "renesas,scifb-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFB compatible UART. | 47 | - "renesas,scifb-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFB compatible UART. |
46 | - "renesas,rcar-gen1-scif" for R-Car Gen1 SCIF compatible UART, | 48 | - "renesas,rcar-gen1-scif" for R-Car Gen1 SCIF compatible UART, |
diff --git a/Documentation/devicetree/bindings/serial/rs485.txt b/Documentation/devicetree/bindings/serial/rs485.txt index 32b1fa1f2a5b..b8415936dfdb 100644 --- a/Documentation/devicetree/bindings/serial/rs485.txt +++ b/Documentation/devicetree/bindings/serial/rs485.txt | |||
@@ -5,14 +5,13 @@ the built-in half-duplex mode. | |||
5 | The properties described hereafter shall be given to a half-duplex capable | 5 | The properties described hereafter shall be given to a half-duplex capable |
6 | UART node. | 6 | UART node. |
7 | 7 | ||
8 | Required properties: | 8 | Optional properties: |
9 | - rs485-rts-delay: prop-encoded-array <a b> where: | 9 | - rs485-rts-delay: prop-encoded-array <a b> where: |
10 | * a is the delay between rts signal and beginning of data sent in milliseconds. | 10 | * a is the delay between rts signal and beginning of data sent in milliseconds. |
11 | it corresponds to the delay before sending data. | 11 | it corresponds to the delay before sending data. |
12 | * b is the delay between end of data sent and rts signal in milliseconds | 12 | * b is the delay between end of data sent and rts signal in milliseconds |
13 | it corresponds to the delay after sending data and actual release of the line. | 13 | it corresponds to the delay after sending data and actual release of the line. |
14 | 14 | If this property is not specified, <0 0> is assumed. | |
15 | Optional properties: | ||
16 | - linux,rs485-enabled-at-boot-time: empty property telling to enable the rs485 | 15 | - linux,rs485-enabled-at-boot-time: empty property telling to enable the rs485 |
17 | feature at boot time. It can be disabled later with proper ioctl. | 16 | feature at boot time. It can be disabled later with proper ioctl. |
18 | - rs485-rx-during-tx: empty property that enables the receiving of data even | 17 | - rs485-rx-during-tx: empty property that enables the receiving of data even |
diff --git a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt index 85ec5f2b1996..3657f9f9d17a 100644 --- a/Documentation/devicetree/bindings/serial/st,stm32-usart.txt +++ b/Documentation/devicetree/bindings/serial/st,stm32-usart.txt | |||
@@ -1,12 +1,19 @@ | |||
1 | * STMicroelectronics STM32 USART | 1 | * STMicroelectronics STM32 USART |
2 | 2 | ||
3 | Required properties: | 3 | Required properties: |
4 | - compatible: Can be either "st,stm32-usart", "st,stm32-uart", | 4 | - compatible: can be either: |
5 | "st,stm32f7-usart" or "st,stm32f7-uart" depending on whether | 5 | - "st,stm32-usart", |
6 | the device supports synchronous mode and is compatible with | 6 | - "st,stm32-uart", |
7 | stm32(f4) or stm32f7. | 7 | - "st,stm32f7-usart", |
8 | - "st,stm32f7-uart", | ||
9 | - "st,stm32h7-usart" | ||
10 | - "st,stm32h7-uart". | ||
11 | depending on whether the device supports synchronous mode | ||
12 | and is compatible with stm32(f4), stm32f7 or stm32h7. | ||
8 | - reg: The address and length of the peripheral registers space | 13 | - reg: The address and length of the peripheral registers space |
9 | - interrupts: The interrupt line of the USART instance | 14 | - interrupts: |
15 | - The interrupt line for the USART instance, | ||
16 | - An optional wake-up interrupt. | ||
10 | - clocks: The input clock of the USART instance | 17 | - clocks: The input clock of the USART instance |
11 | 18 | ||
12 | Optional properties: | 19 | Optional properties: |
diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c index 921a5d2a802b..bb5c5692dedc 100644 --- a/drivers/mcb/mcb-core.c +++ b/drivers/mcb/mcb-core.c | |||
@@ -418,6 +418,22 @@ void mcb_bus_add_devices(const struct mcb_bus *bus) | |||
418 | EXPORT_SYMBOL_GPL(mcb_bus_add_devices); | 418 | EXPORT_SYMBOL_GPL(mcb_bus_add_devices); |
419 | 419 | ||
420 | /** | 420 | /** |
421 | * mcb_get_resource() - get a resource for a mcb device | ||
422 | * @dev: the mcb device | ||
423 | * @type: the type of resource | ||
424 | */ | ||
425 | struct resource *mcb_get_resource(struct mcb_device *dev, unsigned int type) | ||
426 | { | ||
427 | if (type == IORESOURCE_MEM) | ||
428 | return &dev->mem; | ||
429 | else if (type == IORESOURCE_IRQ) | ||
430 | return &dev->irq; | ||
431 | else | ||
432 | return NULL; | ||
433 | } | ||
434 | EXPORT_SYMBOL_GPL(mcb_get_resource); | ||
435 | |||
436 | /** | ||
421 | * mcb_request_mem() - Request memory | 437 | * mcb_request_mem() - Request memory |
422 | * @dev: The @mcb_device the memory is for | 438 | * @dev: The @mcb_device the memory is for |
423 | * @name: The name for the memory reference. | 439 | * @name: The name for the memory reference. |
@@ -460,7 +476,9 @@ EXPORT_SYMBOL_GPL(mcb_release_mem); | |||
460 | 476 | ||
461 | static int __mcb_get_irq(struct mcb_device *dev) | 477 | static int __mcb_get_irq(struct mcb_device *dev) |
462 | { | 478 | { |
463 | struct resource *irq = &dev->irq; | 479 | struct resource *irq; |
480 | |||
481 | irq = mcb_get_resource(dev, IORESOURCE_IRQ); | ||
464 | 482 | ||
465 | return irq->start; | 483 | return irq->start; |
466 | } | 484 | } |
diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig index 95103054c0e4..873e0ba89737 100644 --- a/drivers/tty/Kconfig +++ b/drivers/tty/Kconfig | |||
@@ -392,6 +392,9 @@ config PPC_EARLY_DEBUG_EHV_BC_HANDLE | |||
392 | config GOLDFISH_TTY | 392 | config GOLDFISH_TTY |
393 | tristate "Goldfish TTY Driver" | 393 | tristate "Goldfish TTY Driver" |
394 | depends on GOLDFISH | 394 | depends on GOLDFISH |
395 | select SERIAL_CORE | ||
396 | select SERIAL_CORE_CONSOLE | ||
397 | select SERIAL_EARLYCON | ||
395 | help | 398 | help |
396 | Console and system TTY driver for the Goldfish virtual platform. | 399 | Console and system TTY driver for the Goldfish virtual platform. |
397 | 400 | ||
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index 61fe8d6fd24e..a1c7125cb968 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c | |||
@@ -122,7 +122,7 @@ static int find_console_handle(void) | |||
122 | 122 | ||
123 | stdout_irq = irq_of_parse_and_map(np, 0); | 123 | stdout_irq = irq_of_parse_and_map(np, 0); |
124 | if (stdout_irq == NO_IRQ) { | 124 | if (stdout_irq == NO_IRQ) { |
125 | pr_err("ehv-bc: no 'interrupts' property in %s node\n", np->full_name); | 125 | pr_err("ehv-bc: no 'interrupts' property in %pOF node\n", np); |
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
128 | 128 | ||
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index 996bd473dd03..381e981dee06 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c | |||
@@ -1,6 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2007 Google, Inc. | 2 | * Copyright (C) 2007 Google, Inc. |
3 | * Copyright (C) 2012 Intel, Inc. | 3 | * Copyright (C) 2012 Intel, Inc. |
4 | * Copyright (C) 2017 Imagination Technologies Ltd. | ||
4 | * | 5 | * |
5 | * This software is licensed under the terms of the GNU General Public | 6 | * This software is licensed under the terms of the GNU General Public |
6 | * License version 2, as published by the Free Software Foundation, and | 7 | * License version 2, as published by the Free Software Foundation, and |
@@ -22,21 +23,23 @@ | |||
22 | #include <linux/io.h> | 23 | #include <linux/io.h> |
23 | #include <linux/module.h> | 24 | #include <linux/module.h> |
24 | #include <linux/goldfish.h> | 25 | #include <linux/goldfish.h> |
25 | 26 | #include <linux/mm.h> | |
26 | enum { | 27 | #include <linux/dma-mapping.h> |
27 | GOLDFISH_TTY_PUT_CHAR = 0x00, | 28 | #include <linux/serial_core.h> |
28 | GOLDFISH_TTY_BYTES_READY = 0x04, | 29 | |
29 | GOLDFISH_TTY_CMD = 0x08, | 30 | /* Goldfish tty register's offsets */ |
30 | 31 | #define GOLDFISH_TTY_REG_BYTES_READY 0x04 | |
31 | GOLDFISH_TTY_DATA_PTR = 0x10, | 32 | #define GOLDFISH_TTY_REG_CMD 0x08 |
32 | GOLDFISH_TTY_DATA_LEN = 0x14, | 33 | #define GOLDFISH_TTY_REG_DATA_PTR 0x10 |
33 | GOLDFISH_TTY_DATA_PTR_HIGH = 0x18, | 34 | #define GOLDFISH_TTY_REG_DATA_LEN 0x14 |
34 | 35 | #define GOLDFISH_TTY_REG_DATA_PTR_HIGH 0x18 | |
35 | GOLDFISH_TTY_CMD_INT_DISABLE = 0, | 36 | #define GOLDFISH_TTY_REG_VERSION 0x20 |
36 | GOLDFISH_TTY_CMD_INT_ENABLE = 1, | 37 | |
37 | GOLDFISH_TTY_CMD_WRITE_BUFFER = 2, | 38 | /* Goldfish tty commands */ |
38 | GOLDFISH_TTY_CMD_READ_BUFFER = 3, | 39 | #define GOLDFISH_TTY_CMD_INT_DISABLE 0 |
39 | }; | 40 | #define GOLDFISH_TTY_CMD_INT_ENABLE 1 |
41 | #define GOLDFISH_TTY_CMD_WRITE_BUFFER 2 | ||
42 | #define GOLDFISH_TTY_CMD_READ_BUFFER 3 | ||
40 | 43 | ||
41 | struct goldfish_tty { | 44 | struct goldfish_tty { |
42 | struct tty_port port; | 45 | struct tty_port port; |
@@ -45,6 +48,8 @@ struct goldfish_tty { | |||
45 | u32 irq; | 48 | u32 irq; |
46 | int opencount; | 49 | int opencount; |
47 | struct console console; | 50 | struct console console; |
51 | u32 version; | ||
52 | struct device *dev; | ||
48 | }; | 53 | }; |
49 | 54 | ||
50 | static DEFINE_MUTEX(goldfish_tty_lock); | 55 | static DEFINE_MUTEX(goldfish_tty_lock); |
@@ -53,38 +58,107 @@ static u32 goldfish_tty_line_count = 8; | |||
53 | static u32 goldfish_tty_current_line_count; | 58 | static u32 goldfish_tty_current_line_count; |
54 | static struct goldfish_tty *goldfish_ttys; | 59 | static struct goldfish_tty *goldfish_ttys; |
55 | 60 | ||
56 | static void goldfish_tty_do_write(int line, const char *buf, unsigned count) | 61 | static void do_rw_io(struct goldfish_tty *qtty, |
62 | unsigned long address, | ||
63 | unsigned int count, | ||
64 | int is_write) | ||
57 | { | 65 | { |
58 | unsigned long irq_flags; | 66 | unsigned long irq_flags; |
59 | struct goldfish_tty *qtty = &goldfish_ttys[line]; | ||
60 | void __iomem *base = qtty->base; | 67 | void __iomem *base = qtty->base; |
68 | |||
61 | spin_lock_irqsave(&qtty->lock, irq_flags); | 69 | spin_lock_irqsave(&qtty->lock, irq_flags); |
62 | gf_write_ptr(buf, base + GOLDFISH_TTY_DATA_PTR, | 70 | gf_write_ptr((void *)address, base + GOLDFISH_TTY_REG_DATA_PTR, |
63 | base + GOLDFISH_TTY_DATA_PTR_HIGH); | 71 | base + GOLDFISH_TTY_REG_DATA_PTR_HIGH); |
64 | writel(count, base + GOLDFISH_TTY_DATA_LEN); | 72 | writel(count, base + GOLDFISH_TTY_REG_DATA_LEN); |
65 | writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD); | 73 | |
74 | if (is_write) | ||
75 | writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, | ||
76 | base + GOLDFISH_TTY_REG_CMD); | ||
77 | else | ||
78 | writel(GOLDFISH_TTY_CMD_READ_BUFFER, | ||
79 | base + GOLDFISH_TTY_REG_CMD); | ||
80 | |||
66 | spin_unlock_irqrestore(&qtty->lock, irq_flags); | 81 | spin_unlock_irqrestore(&qtty->lock, irq_flags); |
67 | } | 82 | } |
68 | 83 | ||
84 | static void goldfish_tty_rw(struct goldfish_tty *qtty, | ||
85 | unsigned long addr, | ||
86 | unsigned int count, | ||
87 | int is_write) | ||
88 | { | ||
89 | dma_addr_t dma_handle; | ||
90 | enum dma_data_direction dma_dir; | ||
91 | |||
92 | dma_dir = (is_write ? DMA_TO_DEVICE : DMA_FROM_DEVICE); | ||
93 | if (qtty->version > 0) { | ||
94 | /* | ||
95 | * Goldfish TTY for Ranchu platform uses | ||
96 | * physical addresses and DMA for read/write operations | ||
97 | */ | ||
98 | unsigned long addr_end = addr + count; | ||
99 | |||
100 | while (addr < addr_end) { | ||
101 | unsigned long pg_end = (addr & PAGE_MASK) + PAGE_SIZE; | ||
102 | unsigned long next = | ||
103 | pg_end < addr_end ? pg_end : addr_end; | ||
104 | unsigned long avail = next - addr; | ||
105 | |||
106 | /* | ||
107 | * Map the buffer's virtual address to the DMA address | ||
108 | * so the buffer can be accessed by the device. | ||
109 | */ | ||
110 | dma_handle = dma_map_single(qtty->dev, (void *)addr, | ||
111 | avail, dma_dir); | ||
112 | |||
113 | if (dma_mapping_error(qtty->dev, dma_handle)) { | ||
114 | dev_err(qtty->dev, "tty: DMA mapping error.\n"); | ||
115 | return; | ||
116 | } | ||
117 | do_rw_io(qtty, dma_handle, avail, is_write); | ||
118 | |||
119 | /* | ||
120 | * Unmap the previously mapped region after | ||
121 | * the completion of the read/write operation. | ||
122 | */ | ||
123 | dma_unmap_single(qtty->dev, dma_handle, avail, dma_dir); | ||
124 | |||
125 | addr += avail; | ||
126 | } | ||
127 | } else { | ||
128 | /* | ||
129 | * Old style Goldfish TTY used on the Goldfish platform | ||
130 | * uses virtual addresses. | ||
131 | */ | ||
132 | do_rw_io(qtty, addr, count, is_write); | ||
133 | } | ||
134 | } | ||
135 | |||
136 | static void goldfish_tty_do_write(int line, const char *buf, | ||
137 | unsigned int count) | ||
138 | { | ||
139 | struct goldfish_tty *qtty = &goldfish_ttys[line]; | ||
140 | unsigned long address = (unsigned long)(void *)buf; | ||
141 | |||
142 | goldfish_tty_rw(qtty, address, count, 1); | ||
143 | } | ||
144 | |||
69 | static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) | 145 | static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) |
70 | { | 146 | { |
71 | struct goldfish_tty *qtty = dev_id; | 147 | struct goldfish_tty *qtty = dev_id; |
72 | void __iomem *base = qtty->base; | 148 | void __iomem *base = qtty->base; |
73 | unsigned long irq_flags; | 149 | unsigned long address; |
74 | unsigned char *buf; | 150 | unsigned char *buf; |
75 | u32 count; | 151 | u32 count; |
76 | 152 | ||
77 | count = readl(base + GOLDFISH_TTY_BYTES_READY); | 153 | count = readl(base + GOLDFISH_TTY_REG_BYTES_READY); |
78 | if (count == 0) | 154 | if (count == 0) |
79 | return IRQ_NONE; | 155 | return IRQ_NONE; |
80 | 156 | ||
81 | count = tty_prepare_flip_string(&qtty->port, &buf, count); | 157 | count = tty_prepare_flip_string(&qtty->port, &buf, count); |
82 | spin_lock_irqsave(&qtty->lock, irq_flags); | 158 | |
83 | gf_write_ptr(buf, base + GOLDFISH_TTY_DATA_PTR, | 159 | address = (unsigned long)(void *)buf; |
84 | base + GOLDFISH_TTY_DATA_PTR_HIGH); | 160 | goldfish_tty_rw(qtty, address, count, 0); |
85 | writel(count, base + GOLDFISH_TTY_DATA_LEN); | 161 | |
86 | writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD); | ||
87 | spin_unlock_irqrestore(&qtty->lock, irq_flags); | ||
88 | tty_schedule_flip(&qtty->port); | 162 | tty_schedule_flip(&qtty->port); |
89 | return IRQ_HANDLED; | 163 | return IRQ_HANDLED; |
90 | } | 164 | } |
@@ -93,7 +167,7 @@ static int goldfish_tty_activate(struct tty_port *port, struct tty_struct *tty) | |||
93 | { | 167 | { |
94 | struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, | 168 | struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, |
95 | port); | 169 | port); |
96 | writel(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_CMD); | 170 | writel(GOLDFISH_TTY_CMD_INT_ENABLE, qtty->base + GOLDFISH_TTY_REG_CMD); |
97 | return 0; | 171 | return 0; |
98 | } | 172 | } |
99 | 173 | ||
@@ -101,7 +175,7 @@ static void goldfish_tty_shutdown(struct tty_port *port) | |||
101 | { | 175 | { |
102 | struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, | 176 | struct goldfish_tty *qtty = container_of(port, struct goldfish_tty, |
103 | port); | 177 | port); |
104 | writel(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_CMD); | 178 | writel(GOLDFISH_TTY_CMD_INT_DISABLE, qtty->base + GOLDFISH_TTY_REG_CMD); |
105 | } | 179 | } |
106 | 180 | ||
107 | static int goldfish_tty_open(struct tty_struct *tty, struct file *filp) | 181 | static int goldfish_tty_open(struct tty_struct *tty, struct file *filp) |
@@ -136,7 +210,7 @@ static int goldfish_tty_chars_in_buffer(struct tty_struct *tty) | |||
136 | { | 210 | { |
137 | struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; | 211 | struct goldfish_tty *qtty = &goldfish_ttys[tty->index]; |
138 | void __iomem *base = qtty->base; | 212 | void __iomem *base = qtty->base; |
139 | return readl(base + GOLDFISH_TTY_BYTES_READY); | 213 | return readl(base + GOLDFISH_TTY_REG_BYTES_READY); |
140 | } | 214 | } |
141 | 215 | ||
142 | static void goldfish_tty_console_write(struct console *co, const char *b, | 216 | static void goldfish_tty_console_write(struct console *co, const char *b, |
@@ -227,7 +301,7 @@ static void goldfish_tty_delete_driver(void) | |||
227 | static int goldfish_tty_probe(struct platform_device *pdev) | 301 | static int goldfish_tty_probe(struct platform_device *pdev) |
228 | { | 302 | { |
229 | struct goldfish_tty *qtty; | 303 | struct goldfish_tty *qtty; |
230 | int ret = -EINVAL; | 304 | int ret = -ENODEV; |
231 | struct resource *r; | 305 | struct resource *r; |
232 | struct device *ttydev; | 306 | struct device *ttydev; |
233 | void __iomem *base; | 307 | void __iomem *base; |
@@ -235,16 +309,22 @@ static int goldfish_tty_probe(struct platform_device *pdev) | |||
235 | unsigned int line; | 309 | unsigned int line; |
236 | 310 | ||
237 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 311 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
238 | if (r == NULL) | 312 | if (!r) { |
239 | return -EINVAL; | 313 | pr_err("goldfish_tty: No MEM resource available!\n"); |
314 | return -ENOMEM; | ||
315 | } | ||
240 | 316 | ||
241 | base = ioremap(r->start, 0x1000); | 317 | base = ioremap(r->start, 0x1000); |
242 | if (base == NULL) | 318 | if (!base) { |
243 | pr_err("goldfish_tty: unable to remap base\n"); | 319 | pr_err("goldfish_tty: Unable to ioremap base!\n"); |
320 | return -ENOMEM; | ||
321 | } | ||
244 | 322 | ||
245 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); | 323 | r = platform_get_resource(pdev, IORESOURCE_IRQ, 0); |
246 | if (r == NULL) | 324 | if (!r) { |
325 | pr_err("goldfish_tty: No IRQ resource available!\n"); | ||
247 | goto err_unmap; | 326 | goto err_unmap; |
327 | } | ||
248 | 328 | ||
249 | irq = r->start; | 329 | irq = r->start; |
250 | 330 | ||
@@ -255,13 +335,17 @@ static int goldfish_tty_probe(struct platform_device *pdev) | |||
255 | else | 335 | else |
256 | line = pdev->id; | 336 | line = pdev->id; |
257 | 337 | ||
258 | if (line >= goldfish_tty_line_count) | 338 | if (line >= goldfish_tty_line_count) { |
259 | goto err_create_driver_failed; | 339 | pr_err("goldfish_tty: Reached maximum tty number of %d.\n", |
340 | goldfish_tty_current_line_count); | ||
341 | ret = -ENOMEM; | ||
342 | goto err_unlock; | ||
343 | } | ||
260 | 344 | ||
261 | if (goldfish_tty_current_line_count == 0) { | 345 | if (goldfish_tty_current_line_count == 0) { |
262 | ret = goldfish_tty_create_driver(); | 346 | ret = goldfish_tty_create_driver(); |
263 | if (ret) | 347 | if (ret) |
264 | goto err_create_driver_failed; | 348 | goto err_unlock; |
265 | } | 349 | } |
266 | goldfish_tty_current_line_count++; | 350 | goldfish_tty_current_line_count++; |
267 | 351 | ||
@@ -271,17 +355,45 @@ static int goldfish_tty_probe(struct platform_device *pdev) | |||
271 | qtty->port.ops = &goldfish_port_ops; | 355 | qtty->port.ops = &goldfish_port_ops; |
272 | qtty->base = base; | 356 | qtty->base = base; |
273 | qtty->irq = irq; | 357 | qtty->irq = irq; |
358 | qtty->dev = &pdev->dev; | ||
359 | |||
360 | /* | ||
361 | * Goldfish TTY device used by the Goldfish emulator | ||
362 | * should identify itself with 0, forcing the driver | ||
363 | * to use virtual addresses. Goldfish TTY device | ||
364 | * on Ranchu emulator (qemu2) returns 1 here and | ||
365 | * driver will use physical addresses. | ||
366 | */ | ||
367 | qtty->version = readl(base + GOLDFISH_TTY_REG_VERSION); | ||
368 | |||
369 | /* | ||
370 | * Goldfish TTY device on Ranchu emulator (qemu2) | ||
371 | * will use DMA for read/write IO operations. | ||
372 | */ | ||
373 | if (qtty->version > 0) { | ||
374 | /* | ||
375 | * Initialize dma_mask to 32-bits. | ||
376 | */ | ||
377 | if (!pdev->dev.dma_mask) | ||
378 | pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; | ||
379 | ret = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)); | ||
380 | if (ret) { | ||
381 | dev_err(&pdev->dev, "No suitable DMA available.\n"); | ||
382 | goto err_dec_line_count; | ||
383 | } | ||
384 | } | ||
274 | 385 | ||
275 | writel(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_CMD); | 386 | writel(GOLDFISH_TTY_CMD_INT_DISABLE, base + GOLDFISH_TTY_REG_CMD); |
276 | 387 | ||
277 | ret = request_irq(irq, goldfish_tty_interrupt, IRQF_SHARED, | 388 | ret = request_irq(irq, goldfish_tty_interrupt, IRQF_SHARED, |
278 | "goldfish_tty", qtty); | 389 | "goldfish_tty", qtty); |
279 | if (ret) | 390 | if (ret) { |
280 | goto err_request_irq_failed; | 391 | pr_err("goldfish_tty: No IRQ available!\n"); |
281 | 392 | goto err_dec_line_count; | |
393 | } | ||
282 | 394 | ||
283 | ttydev = tty_port_register_device(&qtty->port, goldfish_tty_driver, | 395 | ttydev = tty_port_register_device(&qtty->port, goldfish_tty_driver, |
284 | line, &pdev->dev); | 396 | line, &pdev->dev); |
285 | if (IS_ERR(ttydev)) { | 397 | if (IS_ERR(ttydev)) { |
286 | ret = PTR_ERR(ttydev); | 398 | ret = PTR_ERR(ttydev); |
287 | goto err_tty_register_device_failed; | 399 | goto err_tty_register_device_failed; |
@@ -301,11 +413,11 @@ static int goldfish_tty_probe(struct platform_device *pdev) | |||
301 | 413 | ||
302 | err_tty_register_device_failed: | 414 | err_tty_register_device_failed: |
303 | free_irq(irq, qtty); | 415 | free_irq(irq, qtty); |
304 | err_request_irq_failed: | 416 | err_dec_line_count: |
305 | goldfish_tty_current_line_count--; | 417 | goldfish_tty_current_line_count--; |
306 | if (goldfish_tty_current_line_count == 0) | 418 | if (goldfish_tty_current_line_count == 0) |
307 | goldfish_tty_delete_driver(); | 419 | goldfish_tty_delete_driver(); |
308 | err_create_driver_failed: | 420 | err_unlock: |
309 | mutex_unlock(&goldfish_tty_lock); | 421 | mutex_unlock(&goldfish_tty_lock); |
310 | err_unmap: | 422 | err_unmap: |
311 | iounmap(base); | 423 | iounmap(base); |
@@ -330,6 +442,30 @@ static int goldfish_tty_remove(struct platform_device *pdev) | |||
330 | return 0; | 442 | return 0; |
331 | } | 443 | } |
332 | 444 | ||
445 | static void gf_early_console_putchar(struct uart_port *port, int ch) | ||
446 | { | ||
447 | __raw_writel(ch, port->membase); | ||
448 | } | ||
449 | |||
450 | static void gf_early_write(struct console *con, const char *s, unsigned int n) | ||
451 | { | ||
452 | struct earlycon_device *dev = con->data; | ||
453 | |||
454 | uart_console_write(&dev->port, s, n, gf_early_console_putchar); | ||
455 | } | ||
456 | |||
457 | static int __init gf_earlycon_setup(struct earlycon_device *device, | ||
458 | const char *opt) | ||
459 | { | ||
460 | if (!device->port.membase) | ||
461 | return -ENODEV; | ||
462 | |||
463 | device->con->write = gf_early_write; | ||
464 | return 0; | ||
465 | } | ||
466 | |||
467 | OF_EARLYCON_DECLARE(early_gf_tty, "google,goldfish-tty", gf_earlycon_setup); | ||
468 | |||
333 | static const struct of_device_id goldfish_tty_of_match[] = { | 469 | static const struct of_device_id goldfish_tty_of_match[] = { |
334 | { .compatible = "google,goldfish-tty", }, | 470 | { .compatible = "google,goldfish-tty", }, |
335 | {}, | 471 | {}, |
diff --git a/drivers/tty/hvc/hvc_opal.c b/drivers/tty/hvc/hvc_opal.c index 510799311099..16331a90c1e8 100644 --- a/drivers/tty/hvc/hvc_opal.c +++ b/drivers/tty/hvc/hvc_opal.c | |||
@@ -179,8 +179,8 @@ static int hvc_opal_probe(struct platform_device *dev) | |||
179 | proto = HV_PROTOCOL_HVSI; | 179 | proto = HV_PROTOCOL_HVSI; |
180 | ops = &hvc_opal_hvsi_ops; | 180 | ops = &hvc_opal_hvsi_ops; |
181 | } else { | 181 | } else { |
182 | pr_err("hvc_opal: Unknown protocol for %s\n", | 182 | pr_err("hvc_opal: Unknown protocol for %pOF\n", |
183 | dev->dev.of_node->full_name); | 183 | dev->dev.of_node); |
184 | return -ENXIO; | 184 | return -ENXIO; |
185 | } | 185 | } |
186 | 186 | ||
@@ -204,14 +204,14 @@ static int hvc_opal_probe(struct platform_device *dev) | |||
204 | /* Instanciate now to establish a mapping index==vtermno */ | 204 | /* Instanciate now to establish a mapping index==vtermno */ |
205 | hvc_instantiate(termno, termno, ops); | 205 | hvc_instantiate(termno, termno, ops); |
206 | } else { | 206 | } else { |
207 | pr_err("hvc_opal: Device %s has duplicate terminal number #%d\n", | 207 | pr_err("hvc_opal: Device %pOF has duplicate terminal number #%d\n", |
208 | dev->dev.of_node->full_name, termno); | 208 | dev->dev.of_node, termno); |
209 | return -ENXIO; | 209 | return -ENXIO; |
210 | } | 210 | } |
211 | 211 | ||
212 | pr_info("hvc%d: %s protocol on %s%s\n", termno, | 212 | pr_info("hvc%d: %s protocol on %pOF%s\n", termno, |
213 | proto == HV_PROTOCOL_RAW ? "raw" : "hvsi", | 213 | proto == HV_PROTOCOL_RAW ? "raw" : "hvsi", |
214 | dev->dev.of_node->full_name, | 214 | dev->dev.of_node, |
215 | boot ? " (boot console)" : ""); | 215 | boot ? " (boot console)" : ""); |
216 | 216 | ||
217 | irq = irq_of_parse_and_map(dev->dev.of_node, 0); | 217 | irq = irq_of_parse_and_map(dev->dev.of_node, 0); |
@@ -222,8 +222,8 @@ static int hvc_opal_probe(struct platform_device *dev) | |||
222 | } | 222 | } |
223 | 223 | ||
224 | if (!irq) { | 224 | if (!irq) { |
225 | pr_err("hvc_opal: Unable to map interrupt for device %s\n", | 225 | pr_err("hvc_opal: Unable to map interrupt for device %pOF\n", |
226 | dev->dev.of_node->full_name); | 226 | dev->dev.of_node); |
227 | return irq; | 227 | return irq; |
228 | } | 228 | } |
229 | 229 | ||
diff --git a/drivers/tty/hvc/hvc_vio.c b/drivers/tty/hvc/hvc_vio.c index b05dc5086627..653f99271865 100644 --- a/drivers/tty/hvc/hvc_vio.c +++ b/drivers/tty/hvc/hvc_vio.c | |||
@@ -53,7 +53,7 @@ | |||
53 | 53 | ||
54 | static const char hvc_driver_name[] = "hvc_console"; | 54 | static const char hvc_driver_name[] = "hvc_console"; |
55 | 55 | ||
56 | static struct vio_device_id hvc_driver_table[] = { | 56 | static const struct vio_device_id hvc_driver_table[] = { |
57 | {"serial", "hvterm1"}, | 57 | {"serial", "hvterm1"}, |
58 | #ifndef HVC_OLD_HVSI | 58 | #ifndef HVC_OLD_HVSI |
59 | {"serial", "hvterm-protocol"}, | 59 | {"serial", "hvterm-protocol"}, |
@@ -312,12 +312,12 @@ static int hvc_vio_probe(struct vio_dev *vdev, | |||
312 | proto = HV_PROTOCOL_HVSI; | 312 | proto = HV_PROTOCOL_HVSI; |
313 | ops = &hvterm_hvsi_ops; | 313 | ops = &hvterm_hvsi_ops; |
314 | } else { | 314 | } else { |
315 | pr_err("hvc_vio: Unknown protocol for %s\n", vdev->dev.of_node->full_name); | 315 | pr_err("hvc_vio: Unknown protocol for %pOF\n", vdev->dev.of_node); |
316 | return -ENXIO; | 316 | return -ENXIO; |
317 | } | 317 | } |
318 | 318 | ||
319 | pr_devel("hvc_vio_probe() device %s, using %s protocol\n", | 319 | pr_devel("hvc_vio_probe() device %pOF, using %s protocol\n", |
320 | vdev->dev.of_node->full_name, | 320 | vdev->dev.of_node, |
321 | proto == HV_PROTOCOL_RAW ? "raw" : "hvsi"); | 321 | proto == HV_PROTOCOL_RAW ? "raw" : "hvsi"); |
322 | 322 | ||
323 | /* Is it our boot one ? */ | 323 | /* Is it our boot one ? */ |
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 79cc5beea2da..63c29fe9d21f 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c | |||
@@ -189,7 +189,7 @@ MODULE_VERSION(HVCS_DRIVER_VERSION); | |||
189 | * that will cause echoing or we'll go into recursive loop echoing chars back | 189 | * that will cause echoing or we'll go into recursive loop echoing chars back |
190 | * and forth with the console drivers. | 190 | * and forth with the console drivers. |
191 | */ | 191 | */ |
192 | static struct ktermios hvcs_tty_termios = { | 192 | static const struct ktermios hvcs_tty_termios = { |
193 | .c_iflag = IGNBRK | IGNPAR, | 193 | .c_iflag = IGNBRK | IGNPAR, |
194 | .c_oflag = OPOST, | 194 | .c_oflag = OPOST, |
195 | .c_cflag = B38400 | CS8 | CREAD | HUPCL, | 195 | .c_cflag = B38400 | CS8 | CREAD | HUPCL, |
@@ -675,7 +675,7 @@ static int khvcsd(void *unused) | |||
675 | return 0; | 675 | return 0; |
676 | } | 676 | } |
677 | 677 | ||
678 | static struct vio_device_id hvcs_driver_table[] = { | 678 | static const struct vio_device_id hvcs_driver_table[] = { |
679 | {"serial-server", "hvterm2"}, | 679 | {"serial-server", "hvterm2"}, |
680 | { "", "" } | 680 | { "", "" } |
681 | }; | 681 | }; |
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index b70187b46d9d..61ecdd6b2fc2 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c | |||
@@ -150,7 +150,7 @@ | |||
150 | static int isicom_probe(struct pci_dev *, const struct pci_device_id *); | 150 | static int isicom_probe(struct pci_dev *, const struct pci_device_id *); |
151 | static void isicom_remove(struct pci_dev *); | 151 | static void isicom_remove(struct pci_dev *); |
152 | 152 | ||
153 | static struct pci_device_id isicom_pci_tbl[] = { | 153 | static const struct pci_device_id isicom_pci_tbl[] = { |
154 | { PCI_DEVICE(VENDOR_ID, 0x2028) }, | 154 | { PCI_DEVICE(VENDOR_ID, 0x2028) }, |
155 | { PCI_DEVICE(VENDOR_ID, 0x2051) }, | 155 | { PCI_DEVICE(VENDOR_ID, 0x2051) }, |
156 | { PCI_DEVICE(VENDOR_ID, 0x2052) }, | 156 | { PCI_DEVICE(VENDOR_ID, 0x2052) }, |
diff --git a/drivers/tty/mips_ejtag_fdc.c b/drivers/tty/mips_ejtag_fdc.c index 234123b0c642..a2dab3fb8751 100644 --- a/drivers/tty/mips_ejtag_fdc.c +++ b/drivers/tty/mips_ejtag_fdc.c | |||
@@ -1110,7 +1110,7 @@ out: | |||
1110 | return ret; | 1110 | return ret; |
1111 | } | 1111 | } |
1112 | 1112 | ||
1113 | static struct mips_cdmm_device_id mips_ejtag_fdc_tty_ids[] = { | 1113 | static const struct mips_cdmm_device_id mips_ejtag_fdc_tty_ids[] = { |
1114 | { .type = 0xfd }, | 1114 | { .type = 0xfd }, |
1115 | { } | 1115 | { } |
1116 | }; | 1116 | }; |
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c index 3b251f4e5df0..7f3d4cb0341b 100644 --- a/drivers/tty/moxa.c +++ b/drivers/tty/moxa.c | |||
@@ -88,7 +88,7 @@ static char *moxa_brdname[] = | |||
88 | }; | 88 | }; |
89 | 89 | ||
90 | #ifdef CONFIG_PCI | 90 | #ifdef CONFIG_PCI |
91 | static struct pci_device_id moxa_pcibrds[] = { | 91 | static const struct pci_device_id moxa_pcibrds[] = { |
92 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218), | 92 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C218), |
93 | .driver_data = MOXA_BOARD_C218_PCI }, | 93 | .driver_data = MOXA_BOARD_C218_PCI }, |
94 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C320), | 94 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C320), |
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c index 8bd6fb6d9391..1c0c9553bc05 100644 --- a/drivers/tty/mxser.c +++ b/drivers/tty/mxser.c | |||
@@ -145,7 +145,7 @@ static const struct mxser_cardinfo mxser_cards[] = { | |||
145 | 145 | ||
146 | /* driver_data correspond to the lines in the structure above | 146 | /* driver_data correspond to the lines in the structure above |
147 | see also ISA probe function before you change something */ | 147 | see also ISA probe function before you change something */ |
148 | static struct pci_device_id mxser_pcibrds[] = { | 148 | static const struct pci_device_id mxser_pcibrds[] = { |
149 | { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168), .driver_data = 3 }, | 149 | { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C168), .driver_data = 3 }, |
150 | { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104), .driver_data = 4 }, | 150 | { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_C104), .driver_data = 4 }, |
151 | { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132), .driver_data = 8 }, | 151 | { PCI_VDEVICE(MOXA, PCI_DEVICE_ID_MOXA_CP132), .driver_data = 8 }, |
diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c index 2afe5fce68e3..0a3c9665e015 100644 --- a/drivers/tty/n_gsm.c +++ b/drivers/tty/n_gsm.c | |||
@@ -2607,6 +2607,14 @@ static int gsmld_ioctl(struct tty_struct *tty, struct file *file, | |||
2607 | } | 2607 | } |
2608 | } | 2608 | } |
2609 | 2609 | ||
2610 | #ifdef CONFIG_COMPAT | ||
2611 | static long gsmld_compat_ioctl(struct tty_struct *tty, struct file *file, | ||
2612 | unsigned int cmd, unsigned long arg) | ||
2613 | { | ||
2614 | return gsmld_ioctl(tty, file, cmd, arg); | ||
2615 | } | ||
2616 | #endif | ||
2617 | |||
2610 | /* | 2618 | /* |
2611 | * Network interface | 2619 | * Network interface |
2612 | * | 2620 | * |
@@ -2818,6 +2826,9 @@ static struct tty_ldisc_ops tty_ldisc_packet = { | |||
2818 | .flush_buffer = gsmld_flush_buffer, | 2826 | .flush_buffer = gsmld_flush_buffer, |
2819 | .read = gsmld_read, | 2827 | .read = gsmld_read, |
2820 | .write = gsmld_write, | 2828 | .write = gsmld_write, |
2829 | #ifdef CONFIG_COMPAT | ||
2830 | .compat_ioctl = gsmld_compat_ioctl, | ||
2831 | #endif | ||
2821 | .ioctl = gsmld_ioctl, | 2832 | .ioctl = gsmld_ioctl, |
2822 | .poll = gsmld_poll, | 2833 | .poll = gsmld_poll, |
2823 | .receive_buf = gsmld_receive_buf, | 2834 | .receive_buf = gsmld_receive_buf, |
diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c index a6d5164c33a9..26dcb3b60fb9 100644 --- a/drivers/tty/pty.c +++ b/drivers/tty/pty.c | |||
@@ -742,6 +742,11 @@ static void pty_unix98_remove(struct tty_driver *driver, struct tty_struct *tty) | |||
742 | } | 742 | } |
743 | } | 743 | } |
744 | 744 | ||
745 | static void pty_show_fdinfo(struct tty_struct *tty, struct seq_file *m) | ||
746 | { | ||
747 | seq_printf(m, "tty-index:\t%d\n", tty->index); | ||
748 | } | ||
749 | |||
745 | static const struct tty_operations ptm_unix98_ops = { | 750 | static const struct tty_operations ptm_unix98_ops = { |
746 | .lookup = ptm_unix98_lookup, | 751 | .lookup = ptm_unix98_lookup, |
747 | .install = pty_unix98_install, | 752 | .install = pty_unix98_install, |
@@ -756,7 +761,8 @@ static const struct tty_operations ptm_unix98_ops = { | |||
756 | .ioctl = pty_unix98_ioctl, | 761 | .ioctl = pty_unix98_ioctl, |
757 | .compat_ioctl = pty_unix98_compat_ioctl, | 762 | .compat_ioctl = pty_unix98_compat_ioctl, |
758 | .resize = pty_resize, | 763 | .resize = pty_resize, |
759 | .cleanup = pty_cleanup | 764 | .cleanup = pty_cleanup, |
765 | .show_fdinfo = pty_show_fdinfo, | ||
760 | }; | 766 | }; |
761 | 767 | ||
762 | static const struct tty_operations pty_unix98_ops = { | 768 | static const struct tty_operations pty_unix98_ops = { |
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c index ae1aaa0075d1..c68fb3a8ea1c 100644 --- a/drivers/tty/serdev/core.c +++ b/drivers/tty/serdev/core.c | |||
@@ -363,7 +363,7 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl) | |||
363 | if (!of_get_property(node, "compatible", NULL)) | 363 | if (!of_get_property(node, "compatible", NULL)) |
364 | continue; | 364 | continue; |
365 | 365 | ||
366 | dev_dbg(&ctrl->dev, "adding child %s\n", node->full_name); | 366 | dev_dbg(&ctrl->dev, "adding child %pOF\n", node); |
367 | 367 | ||
368 | serdev = serdev_device_alloc(ctrl); | 368 | serdev = serdev_device_alloc(ctrl); |
369 | if (!serdev) | 369 | if (!serdev) |
diff --git a/drivers/tty/serial/21285.c b/drivers/tty/serial/21285.c index 9b208bd686e6..804632b4a929 100644 --- a/drivers/tty/serial/21285.c +++ b/drivers/tty/serial/21285.c | |||
@@ -334,7 +334,7 @@ static int serial21285_verify_port(struct uart_port *port, struct serial_struct | |||
334 | return ret; | 334 | return ret; |
335 | } | 335 | } |
336 | 336 | ||
337 | static struct uart_ops serial21285_ops = { | 337 | static const struct uart_ops serial21285_ops = { |
338 | .tx_empty = serial21285_tx_empty, | 338 | .tx_empty = serial21285_tx_empty, |
339 | .get_mctrl = serial21285_get_mctrl, | 339 | .get_mctrl = serial21285_get_mctrl, |
340 | .set_mctrl = serial21285_set_mctrl, | 340 | .set_mctrl = serial21285_set_mctrl, |
diff --git a/drivers/tty/serial/8250/8250_aspeed_vuart.c b/drivers/tty/serial/8250/8250_aspeed_vuart.c index 822be4906763..33a801353114 100644 --- a/drivers/tty/serial/8250/8250_aspeed_vuart.c +++ b/drivers/tty/serial/8250/8250_aspeed_vuart.c | |||
@@ -223,12 +223,13 @@ static int aspeed_vuart_probe(struct platform_device *pdev) | |||
223 | if (IS_ERR(vuart->clk)) { | 223 | if (IS_ERR(vuart->clk)) { |
224 | dev_warn(&pdev->dev, | 224 | dev_warn(&pdev->dev, |
225 | "clk or clock-frequency not defined\n"); | 225 | "clk or clock-frequency not defined\n"); |
226 | return PTR_ERR(vuart->clk); | 226 | rc = PTR_ERR(vuart->clk); |
227 | goto err_sysfs_remove; | ||
227 | } | 228 | } |
228 | 229 | ||
229 | rc = clk_prepare_enable(vuart->clk); | 230 | rc = clk_prepare_enable(vuart->clk); |
230 | if (rc < 0) | 231 | if (rc < 0) |
231 | return rc; | 232 | goto err_sysfs_remove; |
232 | 233 | ||
233 | clk = clk_get_rate(vuart->clk); | 234 | clk = clk_get_rate(vuart->clk); |
234 | } | 235 | } |
@@ -286,6 +287,8 @@ static int aspeed_vuart_probe(struct platform_device *pdev) | |||
286 | err_clk_disable: | 287 | err_clk_disable: |
287 | clk_disable_unprepare(vuart->clk); | 288 | clk_disable_unprepare(vuart->clk); |
288 | irq_dispose_mapping(port.port.irq); | 289 | irq_dispose_mapping(port.port.irq); |
290 | err_sysfs_remove: | ||
291 | sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); | ||
289 | return rc; | 292 | return rc; |
290 | } | 293 | } |
291 | 294 | ||
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c index 1aab3010fbfa..d29b512a7d9f 100644 --- a/drivers/tty/serial/8250/8250_core.c +++ b/drivers/tty/serial/8250/8250_core.c | |||
@@ -497,6 +497,11 @@ static void univ8250_rsa_support(struct uart_ops *ops) | |||
497 | #define univ8250_rsa_support(x) do { } while (0) | 497 | #define univ8250_rsa_support(x) do { } while (0) |
498 | #endif /* CONFIG_SERIAL_8250_RSA */ | 498 | #endif /* CONFIG_SERIAL_8250_RSA */ |
499 | 499 | ||
500 | static inline void serial8250_apply_quirks(struct uart_8250_port *up) | ||
501 | { | ||
502 | up->port.quirks |= skip_txen_test ? UPQ_NO_TXEN_TEST : 0; | ||
503 | } | ||
504 | |||
500 | static void __init serial8250_isa_init_ports(void) | 505 | static void __init serial8250_isa_init_ports(void) |
501 | { | 506 | { |
502 | struct uart_8250_port *up; | 507 | struct uart_8250_port *up; |
@@ -577,9 +582,7 @@ serial8250_register_ports(struct uart_driver *drv, struct device *dev) | |||
577 | 582 | ||
578 | up->port.dev = dev; | 583 | up->port.dev = dev; |
579 | 584 | ||
580 | if (skip_txen_test) | 585 | serial8250_apply_quirks(up); |
581 | up->port.flags |= UPF_NO_TXEN_TEST; | ||
582 | |||
583 | uart_add_one_port(drv, &up->port); | 586 | uart_add_one_port(drv, &up->port); |
584 | } | 587 | } |
585 | } | 588 | } |
@@ -1006,9 +1009,6 @@ int serial8250_register_8250_port(struct uart_8250_port *up) | |||
1006 | if (up->port.dev) | 1009 | if (up->port.dev) |
1007 | uart->port.dev = up->port.dev; | 1010 | uart->port.dev = up->port.dev; |
1008 | 1011 | ||
1009 | if (skip_txen_test) | ||
1010 | uart->port.flags |= UPF_NO_TXEN_TEST; | ||
1011 | |||
1012 | if (up->port.flags & UPF_FIXED_TYPE) | 1012 | if (up->port.flags & UPF_FIXED_TYPE) |
1013 | uart->port.type = up->port.type; | 1013 | uart->port.type = up->port.type; |
1014 | 1014 | ||
@@ -1048,6 +1048,7 @@ int serial8250_register_8250_port(struct uart_8250_port *up) | |||
1048 | serial8250_isa_config(0, &uart->port, | 1048 | serial8250_isa_config(0, &uart->port, |
1049 | &uart->capabilities); | 1049 | &uart->capabilities); |
1050 | 1050 | ||
1051 | serial8250_apply_quirks(uart); | ||
1051 | ret = uart_add_one_port(&serial8250_reg, | 1052 | ret = uart_add_one_port(&serial8250_reg, |
1052 | &uart->port); | 1053 | &uart->port); |
1053 | if (ret == 0) | 1054 | if (ret == 0) |
@@ -1092,11 +1093,10 @@ void serial8250_unregister_port(int line) | |||
1092 | uart_remove_one_port(&serial8250_reg, &uart->port); | 1093 | uart_remove_one_port(&serial8250_reg, &uart->port); |
1093 | if (serial8250_isa_devs) { | 1094 | if (serial8250_isa_devs) { |
1094 | uart->port.flags &= ~UPF_BOOT_AUTOCONF; | 1095 | uart->port.flags &= ~UPF_BOOT_AUTOCONF; |
1095 | if (skip_txen_test) | ||
1096 | uart->port.flags |= UPF_NO_TXEN_TEST; | ||
1097 | uart->port.type = PORT_UNKNOWN; | 1096 | uart->port.type = PORT_UNKNOWN; |
1098 | uart->port.dev = &serial8250_isa_devs->dev; | 1097 | uart->port.dev = &serial8250_isa_devs->dev; |
1099 | uart->capabilities = 0; | 1098 | uart->capabilities = 0; |
1099 | serial8250_apply_quirks(uart); | ||
1100 | uart_add_one_port(&serial8250_reg, &uart->port); | 1100 | uart_add_one_port(&serial8250_reg, &uart->port); |
1101 | } else { | 1101 | } else { |
1102 | uart->port.dev = NULL; | 1102 | uart->port.dev = NULL; |
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c index 787b1160d3a5..7e638997bfc2 100644 --- a/drivers/tty/serial/8250/8250_dw.c +++ b/drivers/tty/serial/8250/8250_dw.c | |||
@@ -529,7 +529,7 @@ static int dw8250_probe(struct platform_device *pdev) | |||
529 | } | 529 | } |
530 | } | 530 | } |
531 | 531 | ||
532 | data->rst = devm_reset_control_get_optional(dev, NULL); | 532 | data->rst = devm_reset_control_get_optional_exclusive(dev, NULL); |
533 | if (IS_ERR(data->rst)) { | 533 | if (IS_ERR(data->rst)) { |
534 | err = PTR_ERR(data->rst); | 534 | err = PTR_ERR(data->rst); |
535 | goto err_pclk; | 535 | goto err_pclk; |
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c index 82fc48eca1df..af72ec32e404 100644 --- a/drivers/tty/serial/8250/8250_early.c +++ b/drivers/tty/serial/8250/8250_early.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <asm/io.h> | 37 | #include <asm/io.h> |
38 | #include <asm/serial.h> | 38 | #include <asm/serial.h> |
39 | 39 | ||
40 | static unsigned int __init serial8250_early_in(struct uart_port *port, int offset) | 40 | static unsigned int serial8250_early_in(struct uart_port *port, int offset) |
41 | { | 41 | { |
42 | int reg_offset = offset; | 42 | int reg_offset = offset; |
43 | offset <<= port->regshift; | 43 | offset <<= port->regshift; |
@@ -60,7 +60,7 @@ static unsigned int __init serial8250_early_in(struct uart_port *port, int offse | |||
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | static void __init serial8250_early_out(struct uart_port *port, int offset, int value) | 63 | static void serial8250_early_out(struct uart_port *port, int offset, int value) |
64 | { | 64 | { |
65 | int reg_offset = offset; | 65 | int reg_offset = offset; |
66 | offset <<= port->regshift; | 66 | offset <<= port->regshift; |
@@ -89,7 +89,7 @@ static void __init serial8250_early_out(struct uart_port *port, int offset, int | |||
89 | 89 | ||
90 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) | 90 | #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE) |
91 | 91 | ||
92 | static void __init serial_putc(struct uart_port *port, int c) | 92 | static void serial_putc(struct uart_port *port, int c) |
93 | { | 93 | { |
94 | unsigned int status; | 94 | unsigned int status; |
95 | 95 | ||
@@ -103,7 +103,7 @@ static void __init serial_putc(struct uart_port *port, int c) | |||
103 | } | 103 | } |
104 | } | 104 | } |
105 | 105 | ||
106 | static void __init early_serial8250_write(struct console *console, | 106 | static void early_serial8250_write(struct console *console, |
107 | const char *s, unsigned int count) | 107 | const char *s, unsigned int count) |
108 | { | 108 | { |
109 | struct earlycon_device *device = console->data; | 109 | struct earlycon_device *device = console->data; |
diff --git a/drivers/tty/serial/8250/8250_exar.c b/drivers/tty/serial/8250/8250_exar.c index c6360fbdf808..c55624703fdf 100644 --- a/drivers/tty/serial/8250/8250_exar.c +++ b/drivers/tty/serial/8250/8250_exar.c | |||
@@ -601,7 +601,7 @@ static const struct exar8250_board pbn_exar_XR17V8358 = { | |||
601 | (kernel_ulong_t)&bd \ | 601 | (kernel_ulong_t)&bd \ |
602 | } | 602 | } |
603 | 603 | ||
604 | static struct pci_device_id exar_pci_tbl[] = { | 604 | static const struct pci_device_id exar_pci_tbl[] = { |
605 | CONNECT_DEVICE(XR17C152, UART_2_232, pbn_connect), | 605 | CONNECT_DEVICE(XR17C152, UART_2_232, pbn_connect), |
606 | CONNECT_DEVICE(XR17C154, UART_4_232, pbn_connect), | 606 | CONNECT_DEVICE(XR17C154, UART_4_232, pbn_connect), |
607 | CONNECT_DEVICE(XR17C158, UART_8_232, pbn_connect), | 607 | CONNECT_DEVICE(XR17C158, UART_8_232, pbn_connect), |
diff --git a/drivers/tty/serial/8250/8250_ingenic.c b/drivers/tty/serial/8250/8250_ingenic.c index 4d9dc10e265c..464389b28900 100644 --- a/drivers/tty/serial/8250/8250_ingenic.c +++ b/drivers/tty/serial/8250/8250_ingenic.c | |||
@@ -50,17 +50,17 @@ static const struct of_device_id of_match[]; | |||
50 | 50 | ||
51 | static struct earlycon_device *early_device; | 51 | static struct earlycon_device *early_device; |
52 | 52 | ||
53 | static uint8_t __init early_in(struct uart_port *port, int offset) | 53 | static uint8_t early_in(struct uart_port *port, int offset) |
54 | { | 54 | { |
55 | return readl(port->membase + (offset << 2)); | 55 | return readl(port->membase + (offset << 2)); |
56 | } | 56 | } |
57 | 57 | ||
58 | static void __init early_out(struct uart_port *port, int offset, uint8_t value) | 58 | static void early_out(struct uart_port *port, int offset, uint8_t value) |
59 | { | 59 | { |
60 | writel(value, port->membase + (offset << 2)); | 60 | writel(value, port->membase + (offset << 2)); |
61 | } | 61 | } |
62 | 62 | ||
63 | static void __init ingenic_early_console_putc(struct uart_port *port, int c) | 63 | static void ingenic_early_console_putc(struct uart_port *port, int c) |
64 | { | 64 | { |
65 | uint8_t lsr; | 65 | uint8_t lsr; |
66 | 66 | ||
@@ -71,7 +71,7 @@ static void __init ingenic_early_console_putc(struct uart_port *port, int c) | |||
71 | early_out(port, UART_TX, c); | 71 | early_out(port, UART_TX, c); |
72 | } | 72 | } |
73 | 73 | ||
74 | static void __init ingenic_early_console_write(struct console *console, | 74 | static void ingenic_early_console_write(struct console *console, |
75 | const char *s, unsigned int count) | 75 | const char *s, unsigned int count) |
76 | { | 76 | { |
77 | uart_console_write(&early_device->port, s, count, | 77 | uart_console_write(&early_device->port, s, count, |
diff --git a/drivers/tty/serial/8250/8250_men_mcb.c b/drivers/tty/serial/8250/8250_men_mcb.c new file mode 100644 index 000000000000..308977807994 --- /dev/null +++ b/drivers/tty/serial/8250/8250_men_mcb.c | |||
@@ -0,0 +1,118 @@ | |||
1 | #include <linux/device.h> | ||
2 | #include <linux/kernel.h> | ||
3 | #include <linux/module.h> | ||
4 | #include <linux/mcb.h> | ||
5 | #include <linux/serial.h> | ||
6 | #include <linux/serial_core.h> | ||
7 | #include <linux/serial_8250.h> | ||
8 | #include <uapi/linux/serial_core.h> | ||
9 | |||
10 | struct serial_8250_men_mcb_data { | ||
11 | struct uart_8250_port uart; | ||
12 | int line; | ||
13 | }; | ||
14 | |||
15 | /* | ||
16 | * The Z125 16550-compatible UART has no fixed base clock assigned | ||
17 | * So, depending on the board we're on, we need to adjust the | ||
18 | * parameter in order to really set the correct baudrate, and | ||
19 | * do so if possible without user interaction | ||
20 | */ | ||
21 | static u32 men_z125_lookup_uartclk(struct mcb_device *mdev) | ||
22 | { | ||
23 | /* use default value if board is not available below */ | ||
24 | u32 clkval = 1041666; | ||
25 | |||
26 | dev_info(&mdev->dev, "%s on board %s\n", | ||
27 | dev_name(&mdev->dev), | ||
28 | mdev->bus->name); | ||
29 | if (strncmp(mdev->bus->name, "F075", 4) == 0) | ||
30 | clkval = 1041666; | ||
31 | else if (strncmp(mdev->bus->name, "F216", 4) == 0) | ||
32 | clkval = 1843200; | ||
33 | else if (strncmp(mdev->bus->name, "G215", 4) == 0) | ||
34 | clkval = 1843200; | ||
35 | else | ||
36 | dev_info(&mdev->dev, | ||
37 | "board not detected, using default uartclk\n"); | ||
38 | |||
39 | clkval = clkval << 4; | ||
40 | |||
41 | return clkval; | ||
42 | } | ||
43 | |||
44 | static int serial_8250_men_mcb_probe(struct mcb_device *mdev, | ||
45 | const struct mcb_device_id *id) | ||
46 | { | ||
47 | struct serial_8250_men_mcb_data *data; | ||
48 | struct resource *mem; | ||
49 | |||
50 | data = devm_kzalloc(&mdev->dev, | ||
51 | sizeof(struct serial_8250_men_mcb_data), | ||
52 | GFP_KERNEL); | ||
53 | if (!data) | ||
54 | return -ENOMEM; | ||
55 | |||
56 | mcb_set_drvdata(mdev, data); | ||
57 | data->uart.port.dev = mdev->dma_dev; | ||
58 | spin_lock_init(&data->uart.port.lock); | ||
59 | |||
60 | data->uart.port.type = PORT_16550; | ||
61 | data->uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE; | ||
62 | data->uart.port.iotype = UPIO_MEM; | ||
63 | data->uart.port.uartclk = men_z125_lookup_uartclk(mdev); | ||
64 | data->uart.port.regshift = 0; | ||
65 | data->uart.port.fifosize = 60; | ||
66 | |||
67 | mem = mcb_get_resource(mdev, IORESOURCE_MEM); | ||
68 | if (mem == NULL) | ||
69 | return -ENXIO; | ||
70 | |||
71 | data->uart.port.irq = mcb_get_irq(mdev); | ||
72 | |||
73 | data->uart.port.membase = devm_ioremap_resource(&mdev->dev, mem); | ||
74 | if (IS_ERR(data->uart.port.membase)) | ||
75 | return PTR_ERR_OR_ZERO(data->uart.port.membase); | ||
76 | |||
77 | data->uart.port.mapbase = (unsigned long) mem->start; | ||
78 | data->uart.port.iobase = data->uart.port.mapbase; | ||
79 | |||
80 | /* ok, register the port */ | ||
81 | data->line = serial8250_register_8250_port(&data->uart); | ||
82 | if (data->line < 0) | ||
83 | return data->line; | ||
84 | |||
85 | dev_info(&mdev->dev, "found 16Z125 UART: ttyS%d\n", data->line); | ||
86 | |||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | static void serial_8250_men_mcb_remove(struct mcb_device *mdev) | ||
91 | { | ||
92 | struct serial_8250_men_mcb_data *data = mcb_get_drvdata(mdev); | ||
93 | |||
94 | if (data) | ||
95 | serial8250_unregister_port(data->line); | ||
96 | } | ||
97 | |||
98 | static const struct mcb_device_id serial_8250_men_mcb_ids[] = { | ||
99 | { .device = 0x7d }, | ||
100 | { } | ||
101 | }; | ||
102 | MODULE_DEVICE_TABLE(mcb, serial_8250_men_mcb_ids); | ||
103 | |||
104 | static struct mcb_driver mcb_driver = { | ||
105 | .driver = { | ||
106 | .name = "8250_men_mcb", | ||
107 | .owner = THIS_MODULE, | ||
108 | }, | ||
109 | .probe = serial_8250_men_mcb_probe, | ||
110 | .remove = serial_8250_men_mcb_remove, | ||
111 | .id_table = serial_8250_men_mcb_ids, | ||
112 | }; | ||
113 | module_mcb_driver(mcb_driver); | ||
114 | |||
115 | MODULE_LICENSE("GPL v2"); | ||
116 | MODULE_DESCRIPTION("MEN 16z125 8250 UART driver"); | ||
117 | MODULE_AUTHOR("Michael Moese <michael.moese@men.de"); | ||
118 | MODULE_ALIAS("mcb:16z125"); | ||
diff --git a/drivers/tty/serial/8250/8250_mtk.c b/drivers/tty/serial/8250/8250_mtk.c index ce0cc471bfc3..fb45770d47aa 100644 --- a/drivers/tty/serial/8250/8250_mtk.c +++ b/drivers/tty/serial/8250/8250_mtk.c | |||
@@ -171,10 +171,7 @@ static int mtk8250_probe_of(struct platform_device *pdev, struct uart_port *p, | |||
171 | } | 171 | } |
172 | 172 | ||
173 | data->bus_clk = devm_clk_get(&pdev->dev, "bus"); | 173 | data->bus_clk = devm_clk_get(&pdev->dev, "bus"); |
174 | if (IS_ERR(data->bus_clk)) | 174 | return PTR_ERR_OR_ZERO(data->bus_clk); |
175 | return PTR_ERR(data->bus_clk); | ||
176 | |||
177 | return 0; | ||
178 | } | 175 | } |
179 | 176 | ||
180 | static int mtk8250_probe(struct platform_device *pdev) | 177 | static int mtk8250_probe(struct platform_device *pdev) |
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c index 0cf95fddccfc..1222c005fb98 100644 --- a/drivers/tty/serial/8250/8250_of.c +++ b/drivers/tty/serial/8250/8250_of.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/of_address.h> | 18 | #include <linux/of_address.h> |
19 | #include <linux/of_irq.h> | 19 | #include <linux/of_irq.h> |
20 | #include <linux/of_platform.h> | 20 | #include <linux/of_platform.h> |
21 | #include <linux/pm_runtime.h> | ||
21 | #include <linux/clk.h> | 22 | #include <linux/clk.h> |
22 | #include <linux/reset.h> | 23 | #include <linux/reset.h> |
23 | 24 | ||
@@ -65,6 +66,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev, | |||
65 | int ret; | 66 | int ret; |
66 | 67 | ||
67 | memset(port, 0, sizeof *port); | 68 | memset(port, 0, sizeof *port); |
69 | |||
70 | pm_runtime_enable(&ofdev->dev); | ||
71 | pm_runtime_get_sync(&ofdev->dev); | ||
72 | |||
68 | if (of_property_read_u32(np, "clock-frequency", &clk)) { | 73 | if (of_property_read_u32(np, "clock-frequency", &clk)) { |
69 | 74 | ||
70 | /* Get clk rate through clk driver if present */ | 75 | /* Get clk rate through clk driver if present */ |
@@ -72,12 +77,13 @@ static int of_platform_serial_setup(struct platform_device *ofdev, | |||
72 | if (IS_ERR(info->clk)) { | 77 | if (IS_ERR(info->clk)) { |
73 | dev_warn(&ofdev->dev, | 78 | dev_warn(&ofdev->dev, |
74 | "clk or clock-frequency not defined\n"); | 79 | "clk or clock-frequency not defined\n"); |
75 | return PTR_ERR(info->clk); | 80 | ret = PTR_ERR(info->clk); |
81 | goto err_pmruntime; | ||
76 | } | 82 | } |
77 | 83 | ||
78 | ret = clk_prepare_enable(info->clk); | 84 | ret = clk_prepare_enable(info->clk); |
79 | if (ret < 0) | 85 | if (ret < 0) |
80 | return ret; | 86 | goto err_pmruntime; |
81 | 87 | ||
82 | clk = clk_get_rate(info->clk); | 88 | clk = clk_get_rate(info->clk); |
83 | } | 89 | } |
@@ -88,7 +94,7 @@ static int of_platform_serial_setup(struct platform_device *ofdev, | |||
88 | ret = of_address_to_resource(np, 0, &resource); | 94 | ret = of_address_to_resource(np, 0, &resource); |
89 | if (ret) { | 95 | if (ret) { |
90 | dev_warn(&ofdev->dev, "invalid address\n"); | 96 | dev_warn(&ofdev->dev, "invalid address\n"); |
91 | goto out; | 97 | goto err_unprepare; |
92 | } | 98 | } |
93 | 99 | ||
94 | spin_lock_init(&port->lock); | 100 | spin_lock_init(&port->lock); |
@@ -130,23 +136,23 @@ static int of_platform_serial_setup(struct platform_device *ofdev, | |||
130 | dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n", | 136 | dev_warn(&ofdev->dev, "unsupported reg-io-width (%d)\n", |
131 | prop); | 137 | prop); |
132 | ret = -EINVAL; | 138 | ret = -EINVAL; |
133 | goto out; | 139 | goto err_dispose; |
134 | } | 140 | } |
135 | } | 141 | } |
136 | 142 | ||
137 | info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL); | 143 | info->rst = devm_reset_control_get_optional_shared(&ofdev->dev, NULL); |
138 | if (IS_ERR(info->rst)) | 144 | if (IS_ERR(info->rst)) |
139 | goto out; | 145 | goto err_dispose; |
140 | ret = reset_control_deassert(info->rst); | 146 | ret = reset_control_deassert(info->rst); |
141 | if (ret) | 147 | if (ret) |
142 | goto out; | 148 | goto err_dispose; |
143 | 149 | ||
144 | port->type = type; | 150 | port->type = type; |
145 | port->uartclk = clk; | 151 | port->uartclk = clk; |
146 | port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP | 152 | port->flags = UPF_SHARE_IRQ | UPF_BOOT_AUTOCONF | UPF_IOREMAP |
147 | | UPF_FIXED_PORT | UPF_FIXED_TYPE; | 153 | | UPF_FIXED_PORT | UPF_FIXED_TYPE; |
148 | 154 | ||
149 | if (of_find_property(np, "no-loopback-test", NULL)) | 155 | if (of_property_read_bool(np, "no-loopback-test")) |
150 | port->flags |= UPF_SKIP_TEST; | 156 | port->flags |= UPF_SKIP_TEST; |
151 | 157 | ||
152 | port->dev = &ofdev->dev; | 158 | port->dev = &ofdev->dev; |
@@ -167,9 +173,13 @@ static int of_platform_serial_setup(struct platform_device *ofdev, | |||
167 | port->handle_irq = fsl8250_handle_irq; | 173 | port->handle_irq = fsl8250_handle_irq; |
168 | 174 | ||
169 | return 0; | 175 | return 0; |
170 | out: | 176 | err_dispose: |
171 | if (info->clk) | 177 | irq_dispose_mapping(port->irq); |
172 | clk_disable_unprepare(info->clk); | 178 | err_unprepare: |
179 | clk_disable_unprepare(info->clk); | ||
180 | err_pmruntime: | ||
181 | pm_runtime_put_sync(&ofdev->dev); | ||
182 | pm_runtime_disable(&ofdev->dev); | ||
173 | return ret; | 183 | return ret; |
174 | } | 184 | } |
175 | 185 | ||
@@ -190,7 +200,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev) | |||
190 | if (!match) | 200 | if (!match) |
191 | return -EINVAL; | 201 | return -EINVAL; |
192 | 202 | ||
193 | if (of_find_property(ofdev->dev.of_node, "used-by-rtas", NULL)) | 203 | if (of_property_read_bool(ofdev->dev.of_node, "used-by-rtas")) |
194 | return -EBUSY; | 204 | return -EBUSY; |
195 | 205 | ||
196 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 206 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
@@ -201,7 +211,7 @@ static int of_platform_serial_probe(struct platform_device *ofdev) | |||
201 | memset(&port8250, 0, sizeof(port8250)); | 211 | memset(&port8250, 0, sizeof(port8250)); |
202 | ret = of_platform_serial_setup(ofdev, port_type, &port8250.port, info); | 212 | ret = of_platform_serial_setup(ofdev, port_type, &port8250.port, info); |
203 | if (ret) | 213 | if (ret) |
204 | goto out; | 214 | goto err_free; |
205 | 215 | ||
206 | if (port8250.port.fifosize) | 216 | if (port8250.port.fifosize) |
207 | port8250.capabilities = UART_CAP_FIFO; | 217 | port8250.capabilities = UART_CAP_FIFO; |
@@ -217,15 +227,19 @@ static int of_platform_serial_probe(struct platform_device *ofdev) | |||
217 | 227 | ||
218 | ret = serial8250_register_8250_port(&port8250); | 228 | ret = serial8250_register_8250_port(&port8250); |
219 | if (ret < 0) | 229 | if (ret < 0) |
220 | goto out; | 230 | goto err_dispose; |
221 | 231 | ||
222 | info->type = port_type; | 232 | info->type = port_type; |
223 | info->line = ret; | 233 | info->line = ret; |
224 | platform_set_drvdata(ofdev, info); | 234 | platform_set_drvdata(ofdev, info); |
225 | return 0; | 235 | return 0; |
226 | out: | 236 | err_dispose: |
227 | kfree(info); | ||
228 | irq_dispose_mapping(port8250.port.irq); | 237 | irq_dispose_mapping(port8250.port.irq); |
238 | pm_runtime_put_sync(&ofdev->dev); | ||
239 | pm_runtime_disable(&ofdev->dev); | ||
240 | clk_disable_unprepare(info->clk); | ||
241 | err_free: | ||
242 | kfree(info); | ||
229 | return ret; | 243 | return ret; |
230 | } | 244 | } |
231 | 245 | ||
@@ -239,8 +253,9 @@ static int of_platform_serial_remove(struct platform_device *ofdev) | |||
239 | serial8250_unregister_port(info->line); | 253 | serial8250_unregister_port(info->line); |
240 | 254 | ||
241 | reset_control_assert(info->rst); | 255 | reset_control_assert(info->rst); |
242 | if (info->clk) | 256 | pm_runtime_put_sync(&ofdev->dev); |
243 | clk_disable_unprepare(info->clk); | 257 | pm_runtime_disable(&ofdev->dev); |
258 | clk_disable_unprepare(info->clk); | ||
244 | kfree(info); | 259 | kfree(info); |
245 | return 0; | 260 | return 0; |
246 | } | 261 | } |
@@ -254,9 +269,10 @@ static int of_serial_suspend(struct device *dev) | |||
254 | 269 | ||
255 | serial8250_suspend_port(info->line); | 270 | serial8250_suspend_port(info->line); |
256 | 271 | ||
257 | if (info->clk && (!uart_console(port) || console_suspend_enabled)) | 272 | if (!uart_console(port) || console_suspend_enabled) { |
273 | pm_runtime_put_sync(dev); | ||
258 | clk_disable_unprepare(info->clk); | 274 | clk_disable_unprepare(info->clk); |
259 | 275 | } | |
260 | return 0; | 276 | return 0; |
261 | } | 277 | } |
262 | 278 | ||
@@ -266,8 +282,10 @@ static int of_serial_resume(struct device *dev) | |||
266 | struct uart_8250_port *port8250 = serial8250_get_port(info->line); | 282 | struct uart_8250_port *port8250 = serial8250_get_port(info->line); |
267 | struct uart_port *port = &port8250->port; | 283 | struct uart_port *port = &port8250->port; |
268 | 284 | ||
269 | if (info->clk && (!uart_console(port) || console_suspend_enabled)) | 285 | if (!uart_console(port) || console_suspend_enabled) { |
286 | pm_runtime_get_sync(dev); | ||
270 | clk_prepare_enable(info->clk); | 287 | clk_prepare_enable(info->clk); |
288 | } | ||
271 | 289 | ||
272 | serial8250_resume_port(info->line); | 290 | serial8250_resume_port(info->line); |
273 | 291 | ||
@@ -295,6 +313,8 @@ static const struct of_device_id of_platform_serial_table[] = { | |||
295 | .data = (void *)PORT_ALTR_16550_F64, }, | 313 | .data = (void *)PORT_ALTR_16550_F64, }, |
296 | { .compatible = "altr,16550-FIFO128", | 314 | { .compatible = "altr,16550-FIFO128", |
297 | .data = (void *)PORT_ALTR_16550_F128, }, | 315 | .data = (void *)PORT_ALTR_16550_F128, }, |
316 | { .compatible = "mediatek,mtk-btif", | ||
317 | .data = (void *)PORT_MTK_BTIF, }, | ||
298 | { .compatible = "mrvl,mmp-uart", | 318 | { .compatible = "mrvl,mmp-uart", |
299 | .data = (void *)PORT_XSCALE, }, | 319 | .data = (void *)PORT_XSCALE, }, |
300 | { .compatible = "ti,da830-uart", .data = (void *)PORT_DA830, }, | 320 | { .compatible = "ti,da830-uart", .data = (void *)PORT_DA830, }, |
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c index 00e51a064388..0c101a7470b0 100644 --- a/drivers/tty/serial/8250/8250_pci.c +++ b/drivers/tty/serial/8250/8250_pci.c | |||
@@ -1548,7 +1548,7 @@ static int skip_tx_en_setup(struct serial_private *priv, | |||
1548 | const struct pciserial_board *board, | 1548 | const struct pciserial_board *board, |
1549 | struct uart_8250_port *port, int idx) | 1549 | struct uart_8250_port *port, int idx) |
1550 | { | 1550 | { |
1551 | port->port.flags |= UPF_NO_TXEN_TEST; | 1551 | port->port.quirks |= UPQ_NO_TXEN_TEST; |
1552 | dev_dbg(&priv->dev->dev, | 1552 | dev_dbg(&priv->dev->dev, |
1553 | "serial8250: skipping TxEn test for device [%04x:%04x] subsystem [%04x:%04x]\n", | 1553 | "serial8250: skipping TxEn test for device [%04x:%04x] subsystem [%04x:%04x]\n", |
1554 | priv->dev->vendor, priv->dev->device, | 1554 | priv->dev->vendor, priv->dev->device, |
@@ -3384,17 +3384,8 @@ static const struct pci_device_id blacklist[] = { | |||
3384 | { PCI_VDEVICE(COMMTECH, PCI_ANY_ID), }, | 3384 | { PCI_VDEVICE(COMMTECH, PCI_ANY_ID), }, |
3385 | }; | 3385 | }; |
3386 | 3386 | ||
3387 | /* | 3387 | static int serial_pci_is_class_communication(struct pci_dev *dev) |
3388 | * Given a complete unknown PCI device, try to use some heuristics to | ||
3389 | * guess what the configuration might be, based on the pitiful PCI | ||
3390 | * serial specs. Returns 0 on success, 1 on failure. | ||
3391 | */ | ||
3392 | static int | ||
3393 | serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) | ||
3394 | { | 3388 | { |
3395 | const struct pci_device_id *bldev; | ||
3396 | int num_iomem, num_port, first_port = -1, i; | ||
3397 | |||
3398 | /* | 3389 | /* |
3399 | * If it is not a communications device or the programming | 3390 | * If it is not a communications device or the programming |
3400 | * interface is greater than 6, give up. | 3391 | * interface is greater than 6, give up. |
@@ -3407,6 +3398,13 @@ serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) | |||
3407 | (dev->class & 0xff) > 6) | 3398 | (dev->class & 0xff) > 6) |
3408 | return -ENODEV; | 3399 | return -ENODEV; |
3409 | 3400 | ||
3401 | return 0; | ||
3402 | } | ||
3403 | |||
3404 | static int serial_pci_is_blacklisted(struct pci_dev *dev) | ||
3405 | { | ||
3406 | const struct pci_device_id *bldev; | ||
3407 | |||
3410 | /* | 3408 | /* |
3411 | * Do not access blacklisted devices that are known not to | 3409 | * Do not access blacklisted devices that are known not to |
3412 | * feature serial ports or are handled by other modules. | 3410 | * feature serial ports or are handled by other modules. |
@@ -3419,6 +3417,19 @@ serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) | |||
3419 | return -ENODEV; | 3417 | return -ENODEV; |
3420 | } | 3418 | } |
3421 | 3419 | ||
3420 | return 0; | ||
3421 | } | ||
3422 | |||
3423 | /* | ||
3424 | * Given a complete unknown PCI device, try to use some heuristics to | ||
3425 | * guess what the configuration might be, based on the pitiful PCI | ||
3426 | * serial specs. Returns 0 on success, -ENODEV on failure. | ||
3427 | */ | ||
3428 | static int | ||
3429 | serial_pci_guess_board(struct pci_dev *dev, struct pciserial_board *board) | ||
3430 | { | ||
3431 | int num_iomem, num_port, first_port = -1, i; | ||
3432 | |||
3422 | num_iomem = num_port = 0; | 3433 | num_iomem = num_port = 0; |
3423 | for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { | 3434 | for (i = 0; i < PCI_NUM_BAR_RESOURCES; i++) { |
3424 | if (pci_resource_flags(dev, i) & IORESOURCE_IO) { | 3435 | if (pci_resource_flags(dev, i) & IORESOURCE_IO) { |
@@ -3639,6 +3650,14 @@ pciserial_init_one(struct pci_dev *dev, const struct pci_device_id *ent) | |||
3639 | 3650 | ||
3640 | board = &pci_boards[ent->driver_data]; | 3651 | board = &pci_boards[ent->driver_data]; |
3641 | 3652 | ||
3653 | rc = serial_pci_is_class_communication(dev); | ||
3654 | if (rc) | ||
3655 | return rc; | ||
3656 | |||
3657 | rc = serial_pci_is_blacklisted(dev); | ||
3658 | if (rc) | ||
3659 | return rc; | ||
3660 | |||
3642 | rc = pcim_enable_device(dev); | 3661 | rc = pcim_enable_device(dev); |
3643 | pci_save_state(dev); | 3662 | pci_save_state(dev); |
3644 | if (rc) | 3663 | if (rc) |
@@ -3723,7 +3742,7 @@ static int pciserial_resume_one(struct device *dev) | |||
3723 | static SIMPLE_DEV_PM_OPS(pciserial_pm_ops, pciserial_suspend_one, | 3742 | static SIMPLE_DEV_PM_OPS(pciserial_pm_ops, pciserial_suspend_one, |
3724 | pciserial_resume_one); | 3743 | pciserial_resume_one); |
3725 | 3744 | ||
3726 | static struct pci_device_id serial_pci_tbl[] = { | 3745 | static const struct pci_device_id serial_pci_tbl[] = { |
3727 | /* Advantech use PCI_DEVICE_ID_ADVANTECH_PCI3620 (0x3620) as 'PCI_SUBVENDOR_ID' */ | 3746 | /* Advantech use PCI_DEVICE_ID_ADVANTECH_PCI3620 (0x3620) as 'PCI_SUBVENDOR_ID' */ |
3728 | { PCI_VENDOR_ID_ADVANTECH, PCI_DEVICE_ID_ADVANTECH_PCI3620, | 3747 | { PCI_VENDOR_ID_ADVANTECH, PCI_DEVICE_ID_ADVANTECH_PCI3620, |
3729 | PCI_DEVICE_ID_ADVANTECH_PCI3620, 0x0001, 0, 0, | 3748 | PCI_DEVICE_ID_ADVANTECH_PCI3620, 0x0001, 0, 0, |
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c index a5fe0e66c607..f0cc04f62b67 100644 --- a/drivers/tty/serial/8250/8250_port.c +++ b/drivers/tty/serial/8250/8250_port.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <linux/uaccess.h> | 38 | #include <linux/uaccess.h> |
39 | #include <linux/pm_runtime.h> | 39 | #include <linux/pm_runtime.h> |
40 | #include <linux/timer.h> | 40 | #include <linux/ktime.h> |
41 | 41 | ||
42 | #include <asm/io.h> | 42 | #include <asm/io.h> |
43 | #include <asm/irq.h> | 43 | #include <asm/irq.h> |
@@ -289,6 +289,14 @@ static const struct serial8250_config uart_config[] = { | |||
289 | .rxtrig_bytes = {1, 4, 8, 14}, | 289 | .rxtrig_bytes = {1, 4, 8, 14}, |
290 | .flags = UART_CAP_FIFO | UART_CAP_AFE, | 290 | .flags = UART_CAP_FIFO | UART_CAP_AFE, |
291 | }, | 291 | }, |
292 | [PORT_MTK_BTIF] = { | ||
293 | .name = "MediaTek BTIF", | ||
294 | .fifo_size = 16, | ||
295 | .tx_loadsz = 16, | ||
296 | .fcr = UART_FCR_ENABLE_FIFO | | ||
297 | UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT, | ||
298 | .flags = UART_CAP_FIFO, | ||
299 | }, | ||
292 | }; | 300 | }; |
293 | 301 | ||
294 | /* Uart divisor latch read */ | 302 | /* Uart divisor latch read */ |
@@ -553,8 +561,8 @@ static inline void serial8250_em485_rts_after_send(struct uart_8250_port *p) | |||
553 | serial8250_out_MCR(p, mcr); | 561 | serial8250_out_MCR(p, mcr); |
554 | } | 562 | } |
555 | 563 | ||
556 | static void serial8250_em485_handle_start_tx(unsigned long arg); | 564 | static enum hrtimer_restart serial8250_em485_handle_start_tx(struct hrtimer *t); |
557 | static void serial8250_em485_handle_stop_tx(unsigned long arg); | 565 | static enum hrtimer_restart serial8250_em485_handle_stop_tx(struct hrtimer *t); |
558 | 566 | ||
559 | void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p) | 567 | void serial8250_clear_and_reinit_fifos(struct uart_8250_port *p) |
560 | { | 568 | { |
@@ -609,12 +617,14 @@ int serial8250_em485_init(struct uart_8250_port *p) | |||
609 | if (!p->em485) | 617 | if (!p->em485) |
610 | return -ENOMEM; | 618 | return -ENOMEM; |
611 | 619 | ||
612 | setup_timer(&p->em485->stop_tx_timer, | 620 | hrtimer_init(&p->em485->stop_tx_timer, CLOCK_MONOTONIC, |
613 | serial8250_em485_handle_stop_tx, (unsigned long)p); | 621 | HRTIMER_MODE_REL); |
614 | setup_timer(&p->em485->start_tx_timer, | 622 | hrtimer_init(&p->em485->start_tx_timer, CLOCK_MONOTONIC, |
615 | serial8250_em485_handle_start_tx, (unsigned long)p); | 623 | HRTIMER_MODE_REL); |
624 | p->em485->stop_tx_timer.function = &serial8250_em485_handle_stop_tx; | ||
625 | p->em485->start_tx_timer.function = &serial8250_em485_handle_start_tx; | ||
626 | p->em485->port = p; | ||
616 | p->em485->active_timer = NULL; | 627 | p->em485->active_timer = NULL; |
617 | |||
618 | serial8250_em485_rts_after_send(p); | 628 | serial8250_em485_rts_after_send(p); |
619 | 629 | ||
620 | return 0; | 630 | return 0; |
@@ -639,8 +649,8 @@ void serial8250_em485_destroy(struct uart_8250_port *p) | |||
639 | if (!p->em485) | 649 | if (!p->em485) |
640 | return; | 650 | return; |
641 | 651 | ||
642 | del_timer(&p->em485->start_tx_timer); | 652 | hrtimer_cancel(&p->em485->start_tx_timer); |
643 | del_timer(&p->em485->stop_tx_timer); | 653 | hrtimer_cancel(&p->em485->stop_tx_timer); |
644 | 654 | ||
645 | kfree(p->em485); | 655 | kfree(p->em485); |
646 | p->em485 = NULL; | 656 | p->em485 = NULL; |
@@ -1435,22 +1445,33 @@ static void __do_stop_tx_rs485(struct uart_8250_port *p) | |||
1435 | serial_port_out(&p->port, UART_IER, p->ier); | 1445 | serial_port_out(&p->port, UART_IER, p->ier); |
1436 | } | 1446 | } |
1437 | } | 1447 | } |
1438 | 1448 | static enum hrtimer_restart serial8250_em485_handle_stop_tx(struct hrtimer *t) | |
1439 | static void serial8250_em485_handle_stop_tx(unsigned long arg) | ||
1440 | { | 1449 | { |
1441 | struct uart_8250_port *p = (struct uart_8250_port *)arg; | 1450 | struct uart_8250_em485 *em485; |
1442 | struct uart_8250_em485 *em485 = p->em485; | 1451 | struct uart_8250_port *p; |
1443 | unsigned long flags; | 1452 | unsigned long flags; |
1444 | 1453 | ||
1454 | em485 = container_of(t, struct uart_8250_em485, stop_tx_timer); | ||
1455 | p = em485->port; | ||
1456 | |||
1445 | serial8250_rpm_get(p); | 1457 | serial8250_rpm_get(p); |
1446 | spin_lock_irqsave(&p->port.lock, flags); | 1458 | spin_lock_irqsave(&p->port.lock, flags); |
1447 | if (em485 && | 1459 | if (em485->active_timer == &em485->stop_tx_timer) { |
1448 | em485->active_timer == &em485->stop_tx_timer) { | ||
1449 | __do_stop_tx_rs485(p); | 1460 | __do_stop_tx_rs485(p); |
1450 | em485->active_timer = NULL; | 1461 | em485->active_timer = NULL; |
1451 | } | 1462 | } |
1452 | spin_unlock_irqrestore(&p->port.lock, flags); | 1463 | spin_unlock_irqrestore(&p->port.lock, flags); |
1453 | serial8250_rpm_put(p); | 1464 | serial8250_rpm_put(p); |
1465 | return HRTIMER_NORESTART; | ||
1466 | } | ||
1467 | |||
1468 | static void start_hrtimer_ms(struct hrtimer *hrt, unsigned long msec) | ||
1469 | { | ||
1470 | long sec = msec / 1000; | ||
1471 | long nsec = (msec % 1000) * 1000000; | ||
1472 | ktime_t t = ktime_set(sec, nsec); | ||
1473 | |||
1474 | hrtimer_start(hrt, t, HRTIMER_MODE_REL); | ||
1454 | } | 1475 | } |
1455 | 1476 | ||
1456 | static void __stop_tx_rs485(struct uart_8250_port *p) | 1477 | static void __stop_tx_rs485(struct uart_8250_port *p) |
@@ -1463,8 +1484,8 @@ static void __stop_tx_rs485(struct uart_8250_port *p) | |||
1463 | */ | 1484 | */ |
1464 | if (p->port.rs485.delay_rts_after_send > 0) { | 1485 | if (p->port.rs485.delay_rts_after_send > 0) { |
1465 | em485->active_timer = &em485->stop_tx_timer; | 1486 | em485->active_timer = &em485->stop_tx_timer; |
1466 | mod_timer(&em485->stop_tx_timer, jiffies + | 1487 | start_hrtimer_ms(&em485->stop_tx_timer, |
1467 | p->port.rs485.delay_rts_after_send * HZ / 1000); | 1488 | p->port.rs485.delay_rts_after_send); |
1468 | } else { | 1489 | } else { |
1469 | __do_stop_tx_rs485(p); | 1490 | __do_stop_tx_rs485(p); |
1470 | } | 1491 | } |
@@ -1494,8 +1515,8 @@ static inline void __stop_tx(struct uart_8250_port *p) | |||
1494 | if ((lsr & BOTH_EMPTY) != BOTH_EMPTY) | 1515 | if ((lsr & BOTH_EMPTY) != BOTH_EMPTY) |
1495 | return; | 1516 | return; |
1496 | 1517 | ||
1497 | del_timer(&em485->start_tx_timer); | ||
1498 | em485->active_timer = NULL; | 1518 | em485->active_timer = NULL; |
1519 | hrtimer_cancel(&em485->start_tx_timer); | ||
1499 | 1520 | ||
1500 | __stop_tx_rs485(p); | 1521 | __stop_tx_rs485(p); |
1501 | } | 1522 | } |
@@ -1558,8 +1579,9 @@ static inline void start_tx_rs485(struct uart_port *port) | |||
1558 | if (!(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) | 1579 | if (!(up->port.rs485.flags & SER_RS485_RX_DURING_TX)) |
1559 | serial8250_stop_rx(&up->port); | 1580 | serial8250_stop_rx(&up->port); |
1560 | 1581 | ||
1561 | del_timer(&em485->stop_tx_timer); | ||
1562 | em485->active_timer = NULL; | 1582 | em485->active_timer = NULL; |
1583 | if (hrtimer_is_queued(&em485->stop_tx_timer)) | ||
1584 | hrtimer_cancel(&em485->stop_tx_timer); | ||
1563 | 1585 | ||
1564 | mcr = serial8250_in_MCR(up); | 1586 | mcr = serial8250_in_MCR(up); |
1565 | if (!!(up->port.rs485.flags & SER_RS485_RTS_ON_SEND) != | 1587 | if (!!(up->port.rs485.flags & SER_RS485_RTS_ON_SEND) != |
@@ -1572,8 +1594,8 @@ static inline void start_tx_rs485(struct uart_port *port) | |||
1572 | 1594 | ||
1573 | if (up->port.rs485.delay_rts_before_send > 0) { | 1595 | if (up->port.rs485.delay_rts_before_send > 0) { |
1574 | em485->active_timer = &em485->start_tx_timer; | 1596 | em485->active_timer = &em485->start_tx_timer; |
1575 | mod_timer(&em485->start_tx_timer, jiffies + | 1597 | start_hrtimer_ms(&em485->start_tx_timer, |
1576 | up->port.rs485.delay_rts_before_send * HZ / 1000); | 1598 | up->port.rs485.delay_rts_before_send); |
1577 | return; | 1599 | return; |
1578 | } | 1600 | } |
1579 | } | 1601 | } |
@@ -1581,19 +1603,22 @@ static inline void start_tx_rs485(struct uart_port *port) | |||
1581 | __start_tx(port); | 1603 | __start_tx(port); |
1582 | } | 1604 | } |
1583 | 1605 | ||
1584 | static void serial8250_em485_handle_start_tx(unsigned long arg) | 1606 | static enum hrtimer_restart serial8250_em485_handle_start_tx(struct hrtimer *t) |
1585 | { | 1607 | { |
1586 | struct uart_8250_port *p = (struct uart_8250_port *)arg; | 1608 | struct uart_8250_em485 *em485; |
1587 | struct uart_8250_em485 *em485 = p->em485; | 1609 | struct uart_8250_port *p; |
1588 | unsigned long flags; | 1610 | unsigned long flags; |
1589 | 1611 | ||
1612 | em485 = container_of(t, struct uart_8250_em485, start_tx_timer); | ||
1613 | p = em485->port; | ||
1614 | |||
1590 | spin_lock_irqsave(&p->port.lock, flags); | 1615 | spin_lock_irqsave(&p->port.lock, flags); |
1591 | if (em485 && | 1616 | if (em485->active_timer == &em485->start_tx_timer) { |
1592 | em485->active_timer == &em485->start_tx_timer) { | ||
1593 | __start_tx(&p->port); | 1617 | __start_tx(&p->port); |
1594 | em485->active_timer = NULL; | 1618 | em485->active_timer = NULL; |
1595 | } | 1619 | } |
1596 | spin_unlock_irqrestore(&p->port.lock, flags); | 1620 | spin_unlock_irqrestore(&p->port.lock, flags); |
1621 | return HRTIMER_NORESTART; | ||
1597 | } | 1622 | } |
1598 | 1623 | ||
1599 | static void serial8250_start_tx(struct uart_port *port) | 1624 | static void serial8250_start_tx(struct uart_port *port) |
@@ -2304,7 +2329,7 @@ int serial8250_do_startup(struct uart_port *port) | |||
2304 | * test if we receive TX irq. This way, we'll never enable | 2329 | * test if we receive TX irq. This way, we'll never enable |
2305 | * UART_BUG_TXEN. | 2330 | * UART_BUG_TXEN. |
2306 | */ | 2331 | */ |
2307 | if (up->port.flags & UPF_NO_TXEN_TEST) | 2332 | if (up->port.quirks & UPQ_NO_TXEN_TEST) |
2308 | goto dont_test_tx_en; | 2333 | goto dont_test_tx_en; |
2309 | 2334 | ||
2310 | /* | 2335 | /* |
diff --git a/drivers/tty/serial/8250/8250_uniphier.c b/drivers/tty/serial/8250/8250_uniphier.c index 746680ebf90c..8a10b10e27aa 100644 --- a/drivers/tty/serial/8250/8250_uniphier.c +++ b/drivers/tty/serial/8250/8250_uniphier.c | |||
@@ -29,12 +29,13 @@ | |||
29 | * - MMIO32 (regshift = 2) | 29 | * - MMIO32 (regshift = 2) |
30 | * - FCR is not at 2, but 3 | 30 | * - FCR is not at 2, but 3 |
31 | * - LCR and MCR are not at 3 and 4, they share 4 | 31 | * - LCR and MCR are not at 3 and 4, they share 4 |
32 | * - No SCR (Instead, CHAR can be used as a scratch register) | ||
32 | * - Divisor latch at 9, no divisor latch access bit | 33 | * - Divisor latch at 9, no divisor latch access bit |
33 | */ | 34 | */ |
34 | 35 | ||
35 | #define UNIPHIER_UART_REGSHIFT 2 | 36 | #define UNIPHIER_UART_REGSHIFT 2 |
36 | 37 | ||
37 | /* bit[15:8] = CHAR (not used), bit[7:0] = FCR */ | 38 | /* bit[15:8] = CHAR, bit[7:0] = FCR */ |
38 | #define UNIPHIER_UART_CHAR_FCR (3 << (UNIPHIER_UART_REGSHIFT)) | 39 | #define UNIPHIER_UART_CHAR_FCR (3 << (UNIPHIER_UART_REGSHIFT)) |
39 | /* bit[15:8] = LCR, bit[7:0] = MCR */ | 40 | /* bit[15:8] = LCR, bit[7:0] = MCR */ |
40 | #define UNIPHIER_UART_LCR_MCR (4 << (UNIPHIER_UART_REGSHIFT)) | 41 | #define UNIPHIER_UART_LCR_MCR (4 << (UNIPHIER_UART_REGSHIFT)) |
@@ -72,13 +73,18 @@ OF_EARLYCON_DECLARE(uniphier, "socionext,uniphier-uart", | |||
72 | 73 | ||
73 | /* | 74 | /* |
74 | * The register map is slightly different from that of 8250. | 75 | * The register map is slightly different from that of 8250. |
75 | * IO callbacks must be overridden for correct access to FCR, LCR, and MCR. | 76 | * IO callbacks must be overridden for correct access to FCR, LCR, MCR and SCR. |
76 | */ | 77 | */ |
77 | static unsigned int uniphier_serial_in(struct uart_port *p, int offset) | 78 | static unsigned int uniphier_serial_in(struct uart_port *p, int offset) |
78 | { | 79 | { |
79 | unsigned int valshift = 0; | 80 | unsigned int valshift = 0; |
80 | 81 | ||
81 | switch (offset) { | 82 | switch (offset) { |
83 | case UART_SCR: | ||
84 | /* No SCR for this hardware. Use CHAR as a scratch register */ | ||
85 | valshift = 8; | ||
86 | offset = UNIPHIER_UART_CHAR_FCR; | ||
87 | break; | ||
82 | case UART_LCR: | 88 | case UART_LCR: |
83 | valshift = 8; | 89 | valshift = 8; |
84 | /* fall through */ | 90 | /* fall through */ |
@@ -91,8 +97,8 @@ static unsigned int uniphier_serial_in(struct uart_port *p, int offset) | |||
91 | } | 97 | } |
92 | 98 | ||
93 | /* | 99 | /* |
94 | * The return value must be masked with 0xff because LCR and MCR reside | 100 | * The return value must be masked with 0xff because some registers |
95 | * in the same register that must be accessed by 32-bit write/read. | 101 | * share the same offset that must be accessed by 32-bit write/read. |
96 | * 8 or 16 bit access to this hardware result in unexpected behavior. | 102 | * 8 or 16 bit access to this hardware result in unexpected behavior. |
97 | */ | 103 | */ |
98 | return (readl(p->membase + offset) >> valshift) & 0xff; | 104 | return (readl(p->membase + offset) >> valshift) & 0xff; |
@@ -101,9 +107,13 @@ static unsigned int uniphier_serial_in(struct uart_port *p, int offset) | |||
101 | static void uniphier_serial_out(struct uart_port *p, int offset, int value) | 107 | static void uniphier_serial_out(struct uart_port *p, int offset, int value) |
102 | { | 108 | { |
103 | unsigned int valshift = 0; | 109 | unsigned int valshift = 0; |
104 | bool normal = true; | 110 | bool normal = false; |
105 | 111 | ||
106 | switch (offset) { | 112 | switch (offset) { |
113 | case UART_SCR: | ||
114 | /* No SCR for this hardware. Use CHAR as a scratch register */ | ||
115 | valshift = 8; | ||
116 | /* fall through */ | ||
107 | case UART_FCR: | 117 | case UART_FCR: |
108 | offset = UNIPHIER_UART_CHAR_FCR; | 118 | offset = UNIPHIER_UART_CHAR_FCR; |
109 | break; | 119 | break; |
@@ -114,10 +124,10 @@ static void uniphier_serial_out(struct uart_port *p, int offset, int value) | |||
114 | /* fall through */ | 124 | /* fall through */ |
115 | case UART_MCR: | 125 | case UART_MCR: |
116 | offset = UNIPHIER_UART_LCR_MCR; | 126 | offset = UNIPHIER_UART_LCR_MCR; |
117 | normal = false; | ||
118 | break; | 127 | break; |
119 | default: | 128 | default: |
120 | offset <<= UNIPHIER_UART_REGSHIFT; | 129 | offset <<= UNIPHIER_UART_REGSHIFT; |
130 | normal = true; | ||
121 | break; | 131 | break; |
122 | } | 132 | } |
123 | 133 | ||
@@ -169,7 +179,7 @@ static int uniphier_of_serial_setup(struct device *dev, struct uart_port *port, | |||
169 | dev_err(dev, "failed to get alias id\n"); | 179 | dev_err(dev, "failed to get alias id\n"); |
170 | return ret; | 180 | return ret; |
171 | } | 181 | } |
172 | port->line = priv->line = ret; | 182 | port->line = ret; |
173 | 183 | ||
174 | /* Get clk rate through clk driver */ | 184 | /* Get clk rate through clk driver */ |
175 | priv->clk = devm_clk_get(dev, NULL); | 185 | priv->clk = devm_clk_get(dev, NULL); |
@@ -249,8 +259,8 @@ static int uniphier_uart_probe(struct platform_device *pdev) | |||
249 | up.dl_read = uniphier_serial_dl_read; | 259 | up.dl_read = uniphier_serial_dl_read; |
250 | up.dl_write = uniphier_serial_dl_write; | 260 | up.dl_write = uniphier_serial_dl_write; |
251 | 261 | ||
252 | ret = serial8250_register_8250_port(&up); | 262 | priv->line = serial8250_register_8250_port(&up); |
253 | if (ret < 0) { | 263 | if (priv->line < 0) { |
254 | dev_err(dev, "failed to register 8250 port\n"); | 264 | dev_err(dev, "failed to register 8250 port\n"); |
255 | clk_disable_unprepare(priv->clk); | 265 | clk_disable_unprepare(priv->clk); |
256 | return ret; | 266 | return ret; |
@@ -271,6 +281,40 @@ static int uniphier_uart_remove(struct platform_device *pdev) | |||
271 | return 0; | 281 | return 0; |
272 | } | 282 | } |
273 | 283 | ||
284 | static int __maybe_unused uniphier_uart_suspend(struct device *dev) | ||
285 | { | ||
286 | struct uniphier8250_priv *priv = dev_get_drvdata(dev); | ||
287 | struct uart_8250_port *up = serial8250_get_port(priv->line); | ||
288 | |||
289 | serial8250_suspend_port(priv->line); | ||
290 | |||
291 | if (!uart_console(&up->port) || console_suspend_enabled) | ||
292 | clk_disable_unprepare(priv->clk); | ||
293 | |||
294 | return 0; | ||
295 | } | ||
296 | |||
297 | static int __maybe_unused uniphier_uart_resume(struct device *dev) | ||
298 | { | ||
299 | struct uniphier8250_priv *priv = dev_get_drvdata(dev); | ||
300 | struct uart_8250_port *up = serial8250_get_port(priv->line); | ||
301 | int ret; | ||
302 | |||
303 | if (!uart_console(&up->port) || console_suspend_enabled) { | ||
304 | ret = clk_prepare_enable(priv->clk); | ||
305 | if (ret) | ||
306 | return ret; | ||
307 | } | ||
308 | |||
309 | serial8250_resume_port(priv->line); | ||
310 | |||
311 | return 0; | ||
312 | } | ||
313 | |||
314 | static const struct dev_pm_ops uniphier_uart_pm_ops = { | ||
315 | SET_SYSTEM_SLEEP_PM_OPS(uniphier_uart_suspend, uniphier_uart_resume) | ||
316 | }; | ||
317 | |||
274 | static const struct of_device_id uniphier_uart_match[] = { | 318 | static const struct of_device_id uniphier_uart_match[] = { |
275 | { .compatible = "socionext,uniphier-uart" }, | 319 | { .compatible = "socionext,uniphier-uart" }, |
276 | { /* sentinel */ } | 320 | { /* sentinel */ } |
@@ -283,6 +327,7 @@ static struct platform_driver uniphier_uart_platform_driver = { | |||
283 | .driver = { | 327 | .driver = { |
284 | .name = "uniphier-uart", | 328 | .name = "uniphier-uart", |
285 | .of_match_table = uniphier_uart_match, | 329 | .of_match_table = uniphier_uart_match, |
330 | .pm = &uniphier_uart_pm_ops, | ||
286 | }, | 331 | }, |
287 | }; | 332 | }; |
288 | module_platform_driver(uniphier_uart_platform_driver); | 333 | module_platform_driver(uniphier_uart_platform_driver); |
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig index a1161ec0256f..a5c0ef1e7695 100644 --- a/drivers/tty/serial/8250/Kconfig +++ b/drivers/tty/serial/8250/Kconfig | |||
@@ -155,6 +155,17 @@ config SERIAL_8250_CS | |||
155 | 155 | ||
156 | If unsure, say N. | 156 | If unsure, say N. |
157 | 157 | ||
158 | config SERIAL_8250_MEN_MCB | ||
159 | tristate "MEN Z125 UART device support" | ||
160 | depends on MCB && SERIAL_8250 | ||
161 | help | ||
162 | This enables support for FPGA based UARTs found on many MEN | ||
163 | boards. This driver enables support for the Z125 UARTs. | ||
164 | |||
165 | To compile this driver as a module, chose M here: the | ||
166 | module will be called 8250_men_mcb. | ||
167 | |||
168 | |||
158 | config SERIAL_8250_NR_UARTS | 169 | config SERIAL_8250_NR_UARTS |
159 | int "Maximum number of 8250/16550 serial ports" | 170 | int "Maximum number of 8250/16550 serial ports" |
160 | depends on SERIAL_8250 | 171 | depends on SERIAL_8250 |
diff --git a/drivers/tty/serial/8250/Makefile b/drivers/tty/serial/8250/Makefile index a44a99a3e623..6a18d2d768fe 100644 --- a/drivers/tty/serial/8250/Makefile +++ b/drivers/tty/serial/8250/Makefile | |||
@@ -23,6 +23,7 @@ obj-$(CONFIG_SERIAL_8250_BOCA) += 8250_boca.o | |||
23 | obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o | 23 | obj-$(CONFIG_SERIAL_8250_EXAR_ST16C554) += 8250_exar_st16c554.o |
24 | obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o | 24 | obj-$(CONFIG_SERIAL_8250_HUB6) += 8250_hub6.o |
25 | obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o | 25 | obj-$(CONFIG_SERIAL_8250_FSL) += 8250_fsl.o |
26 | obj-$(CONFIG_SERIAL_8250_MEN_MCB) += 8250_men_mcb.o | ||
26 | obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o | 27 | obj-$(CONFIG_SERIAL_8250_DW) += 8250_dw.o |
27 | obj-$(CONFIG_SERIAL_8250_EM) += 8250_em.o | 28 | obj-$(CONFIG_SERIAL_8250_EM) += 8250_em.o |
28 | obj-$(CONFIG_SERIAL_8250_OMAP) += 8250_omap.o | 29 | obj-$(CONFIG_SERIAL_8250_OMAP) += 8250_omap.o |
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 1f096e2bb398..b788fee54249 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig | |||
@@ -1689,7 +1689,7 @@ config SERIAL_MVEBU_CONSOLE | |||
1689 | Otherwise, say 'N'. | 1689 | Otherwise, say 'N'. |
1690 | 1690 | ||
1691 | config SERIAL_OWL | 1691 | config SERIAL_OWL |
1692 | bool "Actions Semi Owl serial port support" | 1692 | tristate "Actions Semi Owl serial port support" |
1693 | depends on ARCH_ACTIONS || COMPILE_TEST | 1693 | depends on ARCH_ACTIONS || COMPILE_TEST |
1694 | select SERIAL_CORE | 1694 | select SERIAL_CORE |
1695 | help | 1695 | help |
@@ -1705,7 +1705,7 @@ config SERIAL_OWL_CONSOLE | |||
1705 | default y | 1705 | default y |
1706 | help | 1706 | help |
1707 | Say 'Y' here if you wish to use Actions Semiconductor S500/S900 UART | 1707 | Say 'Y' here if you wish to use Actions Semiconductor S500/S900 UART |
1708 | as the system console. Only earlycon is implemented currently. | 1708 | as the system console. |
1709 | 1709 | ||
1710 | endmenu | 1710 | endmenu |
1711 | 1711 | ||
diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c index 24180adb1cbb..9ec4b8d2879f 100644 --- a/drivers/tty/serial/amba-pl010.c +++ b/drivers/tty/serial/amba-pl010.c | |||
@@ -814,7 +814,7 @@ static int pl010_resume(struct device *dev) | |||
814 | 814 | ||
815 | static SIMPLE_DEV_PM_OPS(pl010_dev_pm_ops, pl010_suspend, pl010_resume); | 815 | static SIMPLE_DEV_PM_OPS(pl010_dev_pm_ops, pl010_suspend, pl010_resume); |
816 | 816 | ||
817 | static struct amba_id pl010_ids[] = { | 817 | static const struct amba_id pl010_ids[] = { |
818 | { | 818 | { |
819 | .id = 0x00041010, | 819 | .id = 0x00041010, |
820 | .mask = 0x000fffff, | 820 | .mask = 0x000fffff, |
diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c index 1888d168a41c..111e6a950779 100644 --- a/drivers/tty/serial/amba-pl011.c +++ b/drivers/tty/serial/amba-pl011.c | |||
@@ -128,7 +128,7 @@ static struct vendor_data vendor_arm = { | |||
128 | .get_fifosize = get_fifosize_arm, | 128 | .get_fifosize = get_fifosize_arm, |
129 | }; | 129 | }; |
130 | 130 | ||
131 | static struct vendor_data vendor_sbsa = { | 131 | static const struct vendor_data vendor_sbsa = { |
132 | .reg_offset = pl011_std_offsets, | 132 | .reg_offset = pl011_std_offsets, |
133 | .fr_busy = UART01x_FR_BUSY, | 133 | .fr_busy = UART01x_FR_BUSY, |
134 | .fr_dsr = UART01x_FR_DSR, | 134 | .fr_dsr = UART01x_FR_DSR, |
@@ -143,7 +143,7 @@ static struct vendor_data vendor_sbsa = { | |||
143 | }; | 143 | }; |
144 | 144 | ||
145 | #ifdef CONFIG_ACPI_SPCR_TABLE | 145 | #ifdef CONFIG_ACPI_SPCR_TABLE |
146 | static struct vendor_data vendor_qdt_qdf2400_e44 = { | 146 | static const struct vendor_data vendor_qdt_qdf2400_e44 = { |
147 | .reg_offset = pl011_std_offsets, | 147 | .reg_offset = pl011_std_offsets, |
148 | .fr_busy = UART011_FR_TXFE, | 148 | .fr_busy = UART011_FR_TXFE, |
149 | .fr_dsr = UART01x_FR_DSR, | 149 | .fr_dsr = UART01x_FR_DSR, |
@@ -2787,7 +2787,7 @@ static struct platform_driver arm_sbsa_uart_platform_driver = { | |||
2787 | }, | 2787 | }, |
2788 | }; | 2788 | }; |
2789 | 2789 | ||
2790 | static struct amba_id pl011_ids[] = { | 2790 | static const struct amba_id pl011_ids[] = { |
2791 | { | 2791 | { |
2792 | .id = 0x00041011, | 2792 | .id = 0x00041011, |
2793 | .mask = 0x000fffff, | 2793 | .mask = 0x000fffff, |
diff --git a/drivers/tty/serial/apbuart.c b/drivers/tty/serial/apbuart.c index 75eb083b3361..dd60ed96a0ad 100644 --- a/drivers/tty/serial/apbuart.c +++ b/drivers/tty/serial/apbuart.c | |||
@@ -325,7 +325,7 @@ static int apbuart_verify_port(struct uart_port *port, | |||
325 | return ret; | 325 | return ret; |
326 | } | 326 | } |
327 | 327 | ||
328 | static struct uart_ops grlib_apbuart_ops = { | 328 | static const struct uart_ops grlib_apbuart_ops = { |
329 | .tx_empty = apbuart_tx_empty, | 329 | .tx_empty = apbuart_tx_empty, |
330 | .set_mctrl = apbuart_set_mctrl, | 330 | .set_mctrl = apbuart_set_mctrl, |
331 | .get_mctrl = apbuart_get_mctrl, | 331 | .get_mctrl = apbuart_get_mctrl, |
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index 5ac06fcaa9c6..77fe306690c4 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c | |||
@@ -549,8 +549,8 @@ static struct console arc_console = { | |||
549 | .data = &arc_uart_driver | 549 | .data = &arc_uart_driver |
550 | }; | 550 | }; |
551 | 551 | ||
552 | static __init void arc_early_serial_write(struct console *con, const char *s, | 552 | static void arc_early_serial_write(struct console *con, const char *s, |
553 | unsigned int n) | 553 | unsigned int n) |
554 | { | 554 | { |
555 | struct earlycon_device *dev = con->data; | 555 | struct earlycon_device *dev = con->data; |
556 | 556 | ||
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c index f6bcc19c99d5..9ac142cfc1f1 100644 --- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c | |||
@@ -1123,7 +1123,7 @@ static void cpm_put_poll_char(struct uart_port *port, | |||
1123 | } | 1123 | } |
1124 | #endif /* CONFIG_CONSOLE_POLL */ | 1124 | #endif /* CONFIG_CONSOLE_POLL */ |
1125 | 1125 | ||
1126 | static struct uart_ops cpm_uart_pops = { | 1126 | static const struct uart_ops cpm_uart_pops = { |
1127 | .tx_empty = cpm_uart_tx_empty, | 1127 | .tx_empty = cpm_uart_tx_empty, |
1128 | .set_mctrl = cpm_uart_set_mctrl, | 1128 | .set_mctrl = cpm_uart_set_mctrl, |
1129 | .get_mctrl = cpm_uart_get_mctrl, | 1129 | .get_mctrl = cpm_uart_get_mctrl, |
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c index c3651540e1ba..98928f082d87 100644 --- a/drivers/tty/serial/earlycon.c +++ b/drivers/tty/serial/earlycon.c | |||
@@ -220,7 +220,7 @@ static int __init param_setup_earlycon(char *buf) | |||
220 | if (IS_ENABLED(CONFIG_ACPI_SPCR_TABLE)) { | 220 | if (IS_ENABLED(CONFIG_ACPI_SPCR_TABLE)) { |
221 | earlycon_init_is_deferred = true; | 221 | earlycon_init_is_deferred = true; |
222 | return 0; | 222 | return 0; |
223 | } else { | 223 | } else if (!buf) { |
224 | return early_init_dt_scan_chosen_stdout(); | 224 | return early_init_dt_scan_chosen_stdout(); |
225 | } | 225 | } |
226 | } | 226 | } |
@@ -282,7 +282,12 @@ int __init of_setup_earlycon(const struct earlycon_id *match, | |||
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | val = of_get_flat_dt_prop(node, "current-speed", NULL); | ||
286 | if (val) | ||
287 | early_console_dev.baud = be32_to_cpu(*val); | ||
288 | |||
285 | if (options) { | 289 | if (options) { |
290 | early_console_dev.baud = simple_strtoul(options, NULL, 0); | ||
286 | strlcpy(early_console_dev.options, options, | 291 | strlcpy(early_console_dev.options, options, |
287 | sizeof(early_console_dev.options)); | 292 | sizeof(early_console_dev.options)); |
288 | } | 293 | } |
diff --git a/drivers/tty/serial/fsl_lpuart.c b/drivers/tty/serial/fsl_lpuart.c index 898dcb091a27..849c1f9991ce 100644 --- a/drivers/tty/serial/fsl_lpuart.c +++ b/drivers/tty/serial/fsl_lpuart.c | |||
@@ -117,7 +117,7 @@ | |||
117 | #define UARTSFIFO_TXOF 0x02 | 117 | #define UARTSFIFO_TXOF 0x02 |
118 | #define UARTSFIFO_RXUF 0x01 | 118 | #define UARTSFIFO_RXUF 0x01 |
119 | 119 | ||
120 | /* 32-bit register defination */ | 120 | /* 32-bit register definition */ |
121 | #define UARTBAUD 0x00 | 121 | #define UARTBAUD 0x00 |
122 | #define UARTSTAT 0x04 | 122 | #define UARTSTAT 0x04 |
123 | #define UARTCTRL 0x08 | 123 | #define UARTCTRL 0x08 |
@@ -521,6 +521,57 @@ static int lpuart_poll_get_char(struct uart_port *port) | |||
521 | return readb(port->membase + UARTDR); | 521 | return readb(port->membase + UARTDR); |
522 | } | 522 | } |
523 | 523 | ||
524 | static int lpuart32_poll_init(struct uart_port *port) | ||
525 | { | ||
526 | unsigned long flags; | ||
527 | struct lpuart_port *sport = container_of(port, struct lpuart_port, port); | ||
528 | u32 temp; | ||
529 | |||
530 | sport->port.fifosize = 0; | ||
531 | |||
532 | spin_lock_irqsave(&sport->port.lock, flags); | ||
533 | |||
534 | /* Disable Rx & Tx */ | ||
535 | writel(0, sport->port.membase + UARTCTRL); | ||
536 | |||
537 | temp = readl(sport->port.membase + UARTFIFO); | ||
538 | |||
539 | /* Enable Rx and Tx FIFO */ | ||
540 | writel(temp | UARTFIFO_RXFE | UARTFIFO_TXFE, | ||
541 | sport->port.membase + UARTFIFO); | ||
542 | |||
543 | /* flush Tx and Rx FIFO */ | ||
544 | writel(UARTFIFO_TXFLUSH | UARTFIFO_RXFLUSH, | ||
545 | sport->port.membase + UARTFIFO); | ||
546 | |||
547 | /* explicitly clear RDRF */ | ||
548 | if (readl(sport->port.membase + UARTSTAT) & UARTSTAT_RDRF) { | ||
549 | readl(sport->port.membase + UARTDATA); | ||
550 | writel(UARTFIFO_RXUF, sport->port.membase + UARTFIFO); | ||
551 | } | ||
552 | |||
553 | /* Enable Rx and Tx */ | ||
554 | writel(UARTCTRL_RE | UARTCTRL_TE, sport->port.membase + UARTCTRL); | ||
555 | spin_unlock_irqrestore(&sport->port.lock, flags); | ||
556 | |||
557 | return 0; | ||
558 | } | ||
559 | |||
560 | static void lpuart32_poll_put_char(struct uart_port *port, unsigned char c) | ||
561 | { | ||
562 | while (!(readl(port->membase + UARTSTAT) & UARTSTAT_TDRE)) | ||
563 | barrier(); | ||
564 | |||
565 | writel(c, port->membase + UARTDATA); | ||
566 | } | ||
567 | |||
568 | static int lpuart32_poll_get_char(struct uart_port *port) | ||
569 | { | ||
570 | if (!(readl(port->membase + UARTSTAT) & UARTSTAT_RDRF)) | ||
571 | return NO_POLL_CHAR; | ||
572 | |||
573 | return readl(port->membase + UARTDATA); | ||
574 | } | ||
524 | #endif | 575 | #endif |
525 | 576 | ||
526 | static inline void lpuart_transmit_buffer(struct lpuart_port *sport) | 577 | static inline void lpuart_transmit_buffer(struct lpuart_port *sport) |
@@ -1025,6 +1076,11 @@ static int lpuart_config_rs485(struct uart_port *port, | |||
1025 | ~(UARTMODEM_TXRTSPOL | UARTMODEM_TXRTSE); | 1076 | ~(UARTMODEM_TXRTSPOL | UARTMODEM_TXRTSE); |
1026 | writeb(modem, sport->port.membase + UARTMODEM); | 1077 | writeb(modem, sport->port.membase + UARTMODEM); |
1027 | 1078 | ||
1079 | /* clear unsupported configurations */ | ||
1080 | rs485->delay_rts_before_send = 0; | ||
1081 | rs485->delay_rts_after_send = 0; | ||
1082 | rs485->flags &= ~SER_RS485_RX_DURING_TX; | ||
1083 | |||
1028 | if (rs485->flags & SER_RS485_ENABLED) { | 1084 | if (rs485->flags & SER_RS485_ENABLED) { |
1029 | /* Enable auto RS-485 RTS mode */ | 1085 | /* Enable auto RS-485 RTS mode */ |
1030 | modem |= UARTMODEM_TXRTSE; | 1086 | modem |= UARTMODEM_TXRTSE; |
@@ -1782,6 +1838,11 @@ static const struct uart_ops lpuart32_pops = { | |||
1782 | .config_port = lpuart_config_port, | 1838 | .config_port = lpuart_config_port, |
1783 | .verify_port = lpuart_verify_port, | 1839 | .verify_port = lpuart_verify_port, |
1784 | .flush_buffer = lpuart_flush_buffer, | 1840 | .flush_buffer = lpuart_flush_buffer, |
1841 | #if defined(CONFIG_CONSOLE_POLL) | ||
1842 | .poll_init = lpuart32_poll_init, | ||
1843 | .poll_get_char = lpuart32_poll_get_char, | ||
1844 | .poll_put_char = lpuart32_poll_put_char, | ||
1845 | #endif | ||
1785 | }; | 1846 | }; |
1786 | 1847 | ||
1787 | static struct lpuart_port *lpuart_ports[UART_NR]; | 1848 | static struct lpuart_port *lpuart_ports[UART_NR]; |
@@ -2203,6 +2264,7 @@ static int lpuart_suspend(struct device *dev) | |||
2203 | { | 2264 | { |
2204 | struct lpuart_port *sport = dev_get_drvdata(dev); | 2265 | struct lpuart_port *sport = dev_get_drvdata(dev); |
2205 | unsigned long temp; | 2266 | unsigned long temp; |
2267 | bool irq_wake; | ||
2206 | 2268 | ||
2207 | if (lpuart_is_32(sport)) { | 2269 | if (lpuart_is_32(sport)) { |
2208 | /* disable Rx/Tx and interrupts */ | 2270 | /* disable Rx/Tx and interrupts */ |
@@ -2218,6 +2280,9 @@ static int lpuart_suspend(struct device *dev) | |||
2218 | 2280 | ||
2219 | uart_suspend_port(&lpuart_reg, &sport->port); | 2281 | uart_suspend_port(&lpuart_reg, &sport->port); |
2220 | 2282 | ||
2283 | /* uart_suspend_port() might set wakeup flag */ | ||
2284 | irq_wake = irqd_is_wakeup_set(irq_get_irq_data(sport->port.irq)); | ||
2285 | |||
2221 | if (sport->lpuart_dma_rx_use) { | 2286 | if (sport->lpuart_dma_rx_use) { |
2222 | /* | 2287 | /* |
2223 | * EDMA driver during suspend will forcefully release any | 2288 | * EDMA driver during suspend will forcefully release any |
@@ -2226,7 +2291,7 @@ static int lpuart_suspend(struct device *dev) | |||
2226 | * cannot resume as as expected, hence gracefully release the | 2291 | * cannot resume as as expected, hence gracefully release the |
2227 | * Rx DMA path before suspend and start Rx DMA path on resume. | 2292 | * Rx DMA path before suspend and start Rx DMA path on resume. |
2228 | */ | 2293 | */ |
2229 | if (sport->port.irq_wake) { | 2294 | if (irq_wake) { |
2230 | del_timer_sync(&sport->lpuart_timer); | 2295 | del_timer_sync(&sport->lpuart_timer); |
2231 | lpuart_dma_rx_free(&sport->port); | 2296 | lpuart_dma_rx_free(&sport->port); |
2232 | } | 2297 | } |
@@ -2241,7 +2306,7 @@ static int lpuart_suspend(struct device *dev) | |||
2241 | dmaengine_terminate_all(sport->dma_tx_chan); | 2306 | dmaengine_terminate_all(sport->dma_tx_chan); |
2242 | } | 2307 | } |
2243 | 2308 | ||
2244 | if (sport->port.suspended && !sport->port.irq_wake) | 2309 | if (sport->port.suspended && !irq_wake) |
2245 | clk_disable_unprepare(sport->clk); | 2310 | clk_disable_unprepare(sport->clk); |
2246 | 2311 | ||
2247 | return 0; | 2312 | return 0; |
@@ -2250,9 +2315,10 @@ static int lpuart_suspend(struct device *dev) | |||
2250 | static int lpuart_resume(struct device *dev) | 2315 | static int lpuart_resume(struct device *dev) |
2251 | { | 2316 | { |
2252 | struct lpuart_port *sport = dev_get_drvdata(dev); | 2317 | struct lpuart_port *sport = dev_get_drvdata(dev); |
2318 | bool irq_wake = irqd_is_wakeup_set(irq_get_irq_data(sport->port.irq)); | ||
2253 | unsigned long temp; | 2319 | unsigned long temp; |
2254 | 2320 | ||
2255 | if (sport->port.suspended && !sport->port.irq_wake) | 2321 | if (sport->port.suspended && !irq_wake) |
2256 | clk_prepare_enable(sport->clk); | 2322 | clk_prepare_enable(sport->clk); |
2257 | 2323 | ||
2258 | if (lpuart_is_32(sport)) { | 2324 | if (lpuart_is_32(sport)) { |
@@ -2269,7 +2335,7 @@ static int lpuart_resume(struct device *dev) | |||
2269 | } | 2335 | } |
2270 | 2336 | ||
2271 | if (sport->lpuart_dma_rx_use) { | 2337 | if (sport->lpuart_dma_rx_use) { |
2272 | if (sport->port.irq_wake) { | 2338 | if (irq_wake) { |
2273 | if (!lpuart_start_rx_dma(sport)) | 2339 | if (!lpuart_start_rx_dma(sport)) |
2274 | rx_dma_timer_init(sport); | 2340 | rx_dma_timer_init(sport); |
2275 | else | 2341 | else |
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index 80934e7bd67f..dfeff3951f93 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c | |||
@@ -226,7 +226,6 @@ struct imx_port { | |||
226 | dma_cookie_t rx_cookie; | 226 | dma_cookie_t rx_cookie; |
227 | unsigned int tx_bytes; | 227 | unsigned int tx_bytes; |
228 | unsigned int dma_tx_nents; | 228 | unsigned int dma_tx_nents; |
229 | wait_queue_head_t dma_wait; | ||
230 | unsigned int saved_reg[10]; | 229 | unsigned int saved_reg[10]; |
231 | bool context_saved; | 230 | bool context_saved; |
232 | }; | 231 | }; |
@@ -458,7 +457,10 @@ static inline void imx_transmit_buffer(struct imx_port *sport) | |||
458 | } | 457 | } |
459 | } | 458 | } |
460 | 459 | ||
461 | while (!uart_circ_empty(xmit) && !sport->dma_is_txing && | 460 | if (sport->dma_is_txing) |
461 | return; | ||
462 | |||
463 | while (!uart_circ_empty(xmit) && | ||
462 | !(readl(sport->port.membase + uts_reg(sport)) & UTS_TXFULL)) { | 464 | !(readl(sport->port.membase + uts_reg(sport)) & UTS_TXFULL)) { |
463 | /* send xmit->buf[xmit->tail] | 465 | /* send xmit->buf[xmit->tail] |
464 | * out the port here */ | 466 | * out the port here */ |
@@ -498,20 +500,12 @@ static void dma_tx_callback(void *data) | |||
498 | 500 | ||
499 | sport->dma_is_txing = 0; | 501 | sport->dma_is_txing = 0; |
500 | 502 | ||
501 | spin_unlock_irqrestore(&sport->port.lock, flags); | ||
502 | |||
503 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 503 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
504 | uart_write_wakeup(&sport->port); | 504 | uart_write_wakeup(&sport->port); |
505 | 505 | ||
506 | if (waitqueue_active(&sport->dma_wait)) { | ||
507 | wake_up(&sport->dma_wait); | ||
508 | dev_dbg(sport->port.dev, "exit in %s.\n", __func__); | ||
509 | return; | ||
510 | } | ||
511 | |||
512 | spin_lock_irqsave(&sport->port.lock, flags); | ||
513 | if (!uart_circ_empty(xmit) && !uart_tx_stopped(&sport->port)) | 506 | if (!uart_circ_empty(xmit) && !uart_tx_stopped(&sport->port)) |
514 | imx_dma_tx(sport); | 507 | imx_dma_tx(sport); |
508 | |||
515 | spin_unlock_irqrestore(&sport->port.lock, flags); | 509 | spin_unlock_irqrestore(&sport->port.lock, flags); |
516 | } | 510 | } |
517 | 511 | ||
@@ -1208,8 +1202,6 @@ static void imx_enable_dma(struct imx_port *sport) | |||
1208 | { | 1202 | { |
1209 | unsigned long temp; | 1203 | unsigned long temp; |
1210 | 1204 | ||
1211 | init_waitqueue_head(&sport->dma_wait); | ||
1212 | |||
1213 | /* set UCR1 */ | 1205 | /* set UCR1 */ |
1214 | temp = readl(sport->port.membase + UCR1); | 1206 | temp = readl(sport->port.membase + UCR1); |
1215 | temp |= UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN; | 1207 | temp |= UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN; |
@@ -2332,6 +2324,7 @@ static int imx_serial_port_suspend(struct device *dev) | |||
2332 | serial_imx_enable_wakeup(sport, true); | 2324 | serial_imx_enable_wakeup(sport, true); |
2333 | 2325 | ||
2334 | uart_suspend_port(&imx_reg, &sport->port); | 2326 | uart_suspend_port(&imx_reg, &sport->port); |
2327 | disable_irq(sport->port.irq); | ||
2335 | 2328 | ||
2336 | /* Needed to enable clock in suspend_noirq */ | 2329 | /* Needed to enable clock in suspend_noirq */ |
2337 | return clk_prepare(sport->clk_ipg); | 2330 | return clk_prepare(sport->clk_ipg); |
@@ -2346,6 +2339,7 @@ static int imx_serial_port_resume(struct device *dev) | |||
2346 | serial_imx_enable_wakeup(sport, false); | 2339 | serial_imx_enable_wakeup(sport, false); |
2347 | 2340 | ||
2348 | uart_resume_port(&imx_reg, &sport->port); | 2341 | uart_resume_port(&imx_reg, &sport->port); |
2342 | enable_irq(sport->port.irq); | ||
2349 | 2343 | ||
2350 | clk_unprepare(sport->clk_ipg); | 2344 | clk_unprepare(sport->clk_ipg); |
2351 | 2345 | ||
diff --git a/drivers/tty/serial/jsm/jsm_driver.c b/drivers/tty/serial/jsm/jsm_driver.c index a119f11bf2f4..102d499814ac 100644 --- a/drivers/tty/serial/jsm/jsm_driver.c +++ b/drivers/tty/serial/jsm/jsm_driver.c | |||
@@ -304,7 +304,7 @@ static void jsm_remove_one(struct pci_dev *pdev) | |||
304 | kfree(brd); | 304 | kfree(brd); |
305 | } | 305 | } |
306 | 306 | ||
307 | static struct pci_device_id jsm_pci_tbl[] = { | 307 | static const struct pci_device_id jsm_pci_tbl[] = { |
308 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2DB9), 0, 0, 0 }, | 308 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2DB9), 0, 0, 0 }, |
309 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2DB9PRI), 0, 0, 1 }, | 309 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2DB9PRI), 0, 0, 1 }, |
310 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45), 0, 0, 2 }, | 310 | { PCI_DEVICE(PCI_VENDOR_ID_DIGI, PCI_DEVICE_ID_NEO_2RJ45), 0, 0, 2 }, |
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c index 218b7118e85d..5b3bd9511993 100644 --- a/drivers/tty/serial/m32r_sio.c +++ b/drivers/tty/serial/m32r_sio.c | |||
@@ -854,7 +854,7 @@ m32r_sio_verify_port(struct uart_port *port, struct serial_struct *ser) | |||
854 | return 0; | 854 | return 0; |
855 | } | 855 | } |
856 | 856 | ||
857 | static struct uart_ops m32r_sio_pops = { | 857 | static const struct uart_ops m32r_sio_pops = { |
858 | .tx_empty = m32r_sio_tx_empty, | 858 | .tx_empty = m32r_sio_tx_empty, |
859 | .set_mctrl = m32r_sio_set_mctrl, | 859 | .set_mctrl = m32r_sio_set_mctrl, |
860 | .get_mctrl = m32r_sio_get_mctrl, | 860 | .get_mctrl = m32r_sio_get_mctrl, |
diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c index 42e4a4c7597f..07c0f98be3ac 100644 --- a/drivers/tty/serial/meson_uart.c +++ b/drivers/tty/serial/meson_uart.c | |||
@@ -424,7 +424,7 @@ static void meson_uart_config_port(struct uart_port *port, int flags) | |||
424 | } | 424 | } |
425 | } | 425 | } |
426 | 426 | ||
427 | static struct uart_ops meson_uart_ops = { | 427 | static const struct uart_ops meson_uart_ops = { |
428 | .set_mctrl = meson_uart_set_mctrl, | 428 | .set_mctrl = meson_uart_set_mctrl, |
429 | .get_mctrl = meson_uart_get_mctrl, | 429 | .get_mctrl = meson_uart_get_mctrl, |
430 | .tx_empty = meson_uart_tx_empty, | 430 | .tx_empty = meson_uart_tx_empty, |
diff --git a/drivers/tty/serial/mpc52xx_uart.c b/drivers/tty/serial/mpc52xx_uart.c index 3970d6a9aaca..791c4c74f6d6 100644 --- a/drivers/tty/serial/mpc52xx_uart.c +++ b/drivers/tty/serial/mpc52xx_uart.c | |||
@@ -1347,7 +1347,7 @@ mpc52xx_uart_verify_port(struct uart_port *port, struct serial_struct *ser) | |||
1347 | } | 1347 | } |
1348 | 1348 | ||
1349 | 1349 | ||
1350 | static struct uart_ops mpc52xx_uart_ops = { | 1350 | static const struct uart_ops mpc52xx_uart_ops = { |
1351 | .tx_empty = mpc52xx_uart_tx_empty, | 1351 | .tx_empty = mpc52xx_uart_tx_empty, |
1352 | .set_mctrl = mpc52xx_uart_set_mctrl, | 1352 | .set_mctrl = mpc52xx_uart_set_mctrl, |
1353 | .get_mctrl = mpc52xx_uart_get_mctrl, | 1353 | .get_mctrl = mpc52xx_uart_get_mctrl, |
@@ -1634,8 +1634,8 @@ mpc52xx_console_setup(struct console *co, char *options) | |||
1634 | return -EINVAL; | 1634 | return -EINVAL; |
1635 | } | 1635 | } |
1636 | 1636 | ||
1637 | pr_debug("Console on ttyPSC%x is %s\n", | 1637 | pr_debug("Console on ttyPSC%x is %pOF\n", |
1638 | co->index, mpc52xx_uart_nodes[co->index]->full_name); | 1638 | co->index, mpc52xx_uart_nodes[co->index]); |
1639 | 1639 | ||
1640 | /* Fetch register locations */ | 1640 | /* Fetch register locations */ |
1641 | ret = of_address_to_resource(np, 0, &res); | 1641 | ret = of_address_to_resource(np, 0, &res); |
@@ -1755,8 +1755,8 @@ static int mpc52xx_uart_of_probe(struct platform_device *op) | |||
1755 | break; | 1755 | break; |
1756 | if (idx >= MPC52xx_PSC_MAXNUM) | 1756 | if (idx >= MPC52xx_PSC_MAXNUM) |
1757 | return -EINVAL; | 1757 | return -EINVAL; |
1758 | pr_debug("Found %s assigned to ttyPSC%x\n", | 1758 | pr_debug("Found %pOF assigned to ttyPSC%x\n", |
1759 | mpc52xx_uart_nodes[idx]->full_name, idx); | 1759 | mpc52xx_uart_nodes[idx], idx); |
1760 | 1760 | ||
1761 | /* set the uart clock to the input clock of the psc, the different | 1761 | /* set the uart clock to the input clock of the psc, the different |
1762 | * prescalers are taken into account in the set_baudrate() methods | 1762 | * prescalers are taken into account in the set_baudrate() methods |
@@ -1881,8 +1881,8 @@ mpc52xx_uart_of_enumerate(void) | |||
1881 | 1881 | ||
1882 | for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) { | 1882 | for (i = 0; i < MPC52xx_PSC_MAXNUM; i++) { |
1883 | if (mpc52xx_uart_nodes[i]) | 1883 | if (mpc52xx_uart_nodes[i]) |
1884 | pr_debug("%s assigned to ttyPSC%x\n", | 1884 | pr_debug("%pOF assigned to ttyPSC%x\n", |
1885 | mpc52xx_uart_nodes[i]->full_name, i); | 1885 | mpc52xx_uart_nodes[i], i); |
1886 | } | 1886 | } |
1887 | } | 1887 | } |
1888 | 1888 | ||
diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c index 6788e7532dff..1db79ee8a886 100644 --- a/drivers/tty/serial/msm_serial.c +++ b/drivers/tty/serial/msm_serial.c | |||
@@ -1175,11 +1175,6 @@ static int msm_startup(struct uart_port *port) | |||
1175 | snprintf(msm_port->name, sizeof(msm_port->name), | 1175 | snprintf(msm_port->name, sizeof(msm_port->name), |
1176 | "msm_serial%d", port->line); | 1176 | "msm_serial%d", port->line); |
1177 | 1177 | ||
1178 | ret = request_irq(port->irq, msm_uart_irq, IRQF_TRIGGER_HIGH, | ||
1179 | msm_port->name, port); | ||
1180 | if (unlikely(ret)) | ||
1181 | return ret; | ||
1182 | |||
1183 | msm_init_clock(port); | 1178 | msm_init_clock(port); |
1184 | 1179 | ||
1185 | if (likely(port->fifosize > 12)) | 1180 | if (likely(port->fifosize > 12)) |
@@ -1206,7 +1201,21 @@ static int msm_startup(struct uart_port *port) | |||
1206 | msm_request_rx_dma(msm_port, msm_port->uart.mapbase); | 1201 | msm_request_rx_dma(msm_port, msm_port->uart.mapbase); |
1207 | } | 1202 | } |
1208 | 1203 | ||
1204 | ret = request_irq(port->irq, msm_uart_irq, IRQF_TRIGGER_HIGH, | ||
1205 | msm_port->name, port); | ||
1206 | if (unlikely(ret)) | ||
1207 | goto err_irq; | ||
1208 | |||
1209 | return 0; | 1209 | return 0; |
1210 | |||
1211 | err_irq: | ||
1212 | if (msm_port->is_uartdm) | ||
1213 | msm_release_dma(msm_port); | ||
1214 | |||
1215 | clk_disable_unprepare(msm_port->pclk); | ||
1216 | clk_disable_unprepare(msm_port->clk); | ||
1217 | |||
1218 | return ret; | ||
1210 | } | 1219 | } |
1211 | 1220 | ||
1212 | static void msm_shutdown(struct uart_port *port) | 1221 | static void msm_shutdown(struct uart_port *port) |
diff --git a/drivers/tty/serial/mux.c b/drivers/tty/serial/mux.c index 6f14d2a547c4..2bff69e70e4b 100644 --- a/drivers/tty/serial/mux.c +++ b/drivers/tty/serial/mux.c | |||
@@ -427,7 +427,7 @@ static struct console mux_console = { | |||
427 | #define MUX_CONSOLE NULL | 427 | #define MUX_CONSOLE NULL |
428 | #endif | 428 | #endif |
429 | 429 | ||
430 | static struct uart_ops mux_pops = { | 430 | static const struct uart_ops mux_pops = { |
431 | .tx_empty = mux_tx_empty, | 431 | .tx_empty = mux_tx_empty, |
432 | .set_mctrl = mux_set_mctrl, | 432 | .set_mctrl = mux_set_mctrl, |
433 | .get_mctrl = mux_get_mctrl, | 433 | .get_mctrl = mux_get_mctrl, |
diff --git a/drivers/tty/serial/omap-serial.c b/drivers/tty/serial/omap-serial.c index 1ea05ac57aa7..7754053deeda 100644 --- a/drivers/tty/serial/omap-serial.c +++ b/drivers/tty/serial/omap-serial.c | |||
@@ -1235,21 +1235,20 @@ out: | |||
1235 | #ifdef CONFIG_SERIAL_OMAP_CONSOLE | 1235 | #ifdef CONFIG_SERIAL_OMAP_CONSOLE |
1236 | 1236 | ||
1237 | #ifdef CONFIG_SERIAL_EARLYCON | 1237 | #ifdef CONFIG_SERIAL_EARLYCON |
1238 | static unsigned int __init omap_serial_early_in(struct uart_port *port, | 1238 | static unsigned int omap_serial_early_in(struct uart_port *port, int offset) |
1239 | int offset) | ||
1240 | { | 1239 | { |
1241 | offset <<= port->regshift; | 1240 | offset <<= port->regshift; |
1242 | return readw(port->membase + offset); | 1241 | return readw(port->membase + offset); |
1243 | } | 1242 | } |
1244 | 1243 | ||
1245 | static void __init omap_serial_early_out(struct uart_port *port, int offset, | 1244 | static void omap_serial_early_out(struct uart_port *port, int offset, |
1246 | int value) | 1245 | int value) |
1247 | { | 1246 | { |
1248 | offset <<= port->regshift; | 1247 | offset <<= port->regshift; |
1249 | writew(value, port->membase + offset); | 1248 | writew(value, port->membase + offset); |
1250 | } | 1249 | } |
1251 | 1250 | ||
1252 | static void __init omap_serial_early_putc(struct uart_port *port, int c) | 1251 | static void omap_serial_early_putc(struct uart_port *port, int c) |
1253 | { | 1252 | { |
1254 | unsigned int status; | 1253 | unsigned int status; |
1255 | 1254 | ||
@@ -1262,8 +1261,8 @@ static void __init omap_serial_early_putc(struct uart_port *port, int c) | |||
1262 | omap_serial_early_out(port, UART_TX, c); | 1261 | omap_serial_early_out(port, UART_TX, c); |
1263 | } | 1262 | } |
1264 | 1263 | ||
1265 | static void __init early_omap_serial_write(struct console *console, | 1264 | static void early_omap_serial_write(struct console *console, const char *s, |
1266 | const char *s, unsigned int count) | 1265 | unsigned int count) |
1267 | { | 1266 | { |
1268 | struct earlycon_device *device = console->data; | 1267 | struct earlycon_device *device = console->data; |
1269 | struct uart_port *port = &device->port; | 1268 | struct uart_port *port = &device->port; |
diff --git a/drivers/tty/serial/owl-uart.c b/drivers/tty/serial/owl-uart.c index 1b8008797a1b..b9c859365334 100644 --- a/drivers/tty/serial/owl-uart.c +++ b/drivers/tty/serial/owl-uart.c | |||
@@ -20,6 +20,7 @@ | |||
20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 20 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 | */ | 21 | */ |
22 | 22 | ||
23 | #include <linux/clk.h> | ||
23 | #include <linux/console.h> | 24 | #include <linux/console.h> |
24 | #include <linux/delay.h> | 25 | #include <linux/delay.h> |
25 | #include <linux/io.h> | 26 | #include <linux/io.h> |
@@ -28,22 +29,66 @@ | |||
28 | #include <linux/platform_device.h> | 29 | #include <linux/platform_device.h> |
29 | #include <linux/serial.h> | 30 | #include <linux/serial.h> |
30 | #include <linux/serial_core.h> | 31 | #include <linux/serial_core.h> |
32 | #include <linux/tty.h> | ||
33 | #include <linux/tty_flip.h> | ||
34 | |||
35 | #define OWL_UART_PORT_NUM 7 | ||
36 | #define OWL_UART_DEV_NAME "ttyOWL" | ||
31 | 37 | ||
32 | #define OWL_UART_CTL 0x000 | 38 | #define OWL_UART_CTL 0x000 |
39 | #define OWL_UART_RXDAT 0x004 | ||
33 | #define OWL_UART_TXDAT 0x008 | 40 | #define OWL_UART_TXDAT 0x008 |
34 | #define OWL_UART_STAT 0x00c | 41 | #define OWL_UART_STAT 0x00c |
35 | 42 | ||
43 | #define OWL_UART_CTL_DWLS_MASK GENMASK(1, 0) | ||
44 | #define OWL_UART_CTL_DWLS_5BITS (0x0 << 0) | ||
45 | #define OWL_UART_CTL_DWLS_6BITS (0x1 << 0) | ||
46 | #define OWL_UART_CTL_DWLS_7BITS (0x2 << 0) | ||
47 | #define OWL_UART_CTL_DWLS_8BITS (0x3 << 0) | ||
48 | #define OWL_UART_CTL_STPS_2BITS BIT(2) | ||
49 | #define OWL_UART_CTL_PRS_MASK GENMASK(6, 4) | ||
50 | #define OWL_UART_CTL_PRS_NONE (0x0 << 4) | ||
51 | #define OWL_UART_CTL_PRS_ODD (0x4 << 4) | ||
52 | #define OWL_UART_CTL_PRS_MARK (0x5 << 4) | ||
53 | #define OWL_UART_CTL_PRS_EVEN (0x6 << 4) | ||
54 | #define OWL_UART_CTL_PRS_SPACE (0x7 << 4) | ||
55 | #define OWL_UART_CTL_AFE BIT(12) | ||
36 | #define OWL_UART_CTL_TRFS_TX BIT(14) | 56 | #define OWL_UART_CTL_TRFS_TX BIT(14) |
37 | #define OWL_UART_CTL_EN BIT(15) | 57 | #define OWL_UART_CTL_EN BIT(15) |
58 | #define OWL_UART_CTL_RXDE BIT(16) | ||
59 | #define OWL_UART_CTL_TXDE BIT(17) | ||
38 | #define OWL_UART_CTL_RXIE BIT(18) | 60 | #define OWL_UART_CTL_RXIE BIT(18) |
39 | #define OWL_UART_CTL_TXIE BIT(19) | 61 | #define OWL_UART_CTL_TXIE BIT(19) |
62 | #define OWL_UART_CTL_LBEN BIT(20) | ||
40 | 63 | ||
41 | #define OWL_UART_STAT_RIP BIT(0) | 64 | #define OWL_UART_STAT_RIP BIT(0) |
42 | #define OWL_UART_STAT_TIP BIT(1) | 65 | #define OWL_UART_STAT_TIP BIT(1) |
66 | #define OWL_UART_STAT_RXER BIT(2) | ||
67 | #define OWL_UART_STAT_TFER BIT(3) | ||
68 | #define OWL_UART_STAT_RXST BIT(4) | ||
69 | #define OWL_UART_STAT_RFEM BIT(5) | ||
43 | #define OWL_UART_STAT_TFFU BIT(6) | 70 | #define OWL_UART_STAT_TFFU BIT(6) |
44 | #define OWL_UART_STAT_TRFL_MASK (0x1f << 11) | 71 | #define OWL_UART_STAT_CTSS BIT(7) |
72 | #define OWL_UART_STAT_RTSS BIT(8) | ||
73 | #define OWL_UART_STAT_TFES BIT(10) | ||
74 | #define OWL_UART_STAT_TRFL_MASK GENMASK(16, 11) | ||
45 | #define OWL_UART_STAT_UTBB BIT(17) | 75 | #define OWL_UART_STAT_UTBB BIT(17) |
46 | 76 | ||
77 | static struct uart_driver owl_uart_driver; | ||
78 | |||
79 | struct owl_uart_info { | ||
80 | unsigned int tx_fifosize; | ||
81 | }; | ||
82 | |||
83 | struct owl_uart_port { | ||
84 | struct uart_port port; | ||
85 | struct clk *clk; | ||
86 | }; | ||
87 | |||
88 | #define to_owl_uart_port(prt) container_of(prt, struct owl_uart_port, prt) | ||
89 | |||
90 | static struct owl_uart_port *owl_uart_ports[OWL_UART_PORT_NUM]; | ||
91 | |||
47 | static inline void owl_uart_write(struct uart_port *port, u32 val, unsigned int off) | 92 | static inline void owl_uart_write(struct uart_port *port, u32 val, unsigned int off) |
48 | { | 93 | { |
49 | writel(val, port->membase + off); | 94 | writel(val, port->membase + off); |
@@ -54,6 +99,397 @@ static inline u32 owl_uart_read(struct uart_port *port, unsigned int off) | |||
54 | return readl(port->membase + off); | 99 | return readl(port->membase + off); |
55 | } | 100 | } |
56 | 101 | ||
102 | static void owl_uart_set_mctrl(struct uart_port *port, unsigned int mctrl) | ||
103 | { | ||
104 | u32 ctl; | ||
105 | |||
106 | ctl = owl_uart_read(port, OWL_UART_CTL); | ||
107 | |||
108 | if (mctrl & TIOCM_LOOP) | ||
109 | ctl |= OWL_UART_CTL_LBEN; | ||
110 | else | ||
111 | ctl &= ~OWL_UART_CTL_LBEN; | ||
112 | |||
113 | owl_uart_write(port, ctl, OWL_UART_CTL); | ||
114 | } | ||
115 | |||
116 | static unsigned int owl_uart_get_mctrl(struct uart_port *port) | ||
117 | { | ||
118 | unsigned int mctrl = TIOCM_CAR | TIOCM_DSR; | ||
119 | u32 stat, ctl; | ||
120 | |||
121 | ctl = owl_uart_read(port, OWL_UART_CTL); | ||
122 | stat = owl_uart_read(port, OWL_UART_STAT); | ||
123 | if (stat & OWL_UART_STAT_RTSS) | ||
124 | mctrl |= TIOCM_RTS; | ||
125 | if ((stat & OWL_UART_STAT_CTSS) || !(ctl & OWL_UART_CTL_AFE)) | ||
126 | mctrl |= TIOCM_CTS; | ||
127 | return mctrl; | ||
128 | } | ||
129 | |||
130 | static unsigned int owl_uart_tx_empty(struct uart_port *port) | ||
131 | { | ||
132 | unsigned long flags; | ||
133 | u32 val; | ||
134 | unsigned int ret; | ||
135 | |||
136 | spin_lock_irqsave(&port->lock, flags); | ||
137 | |||
138 | val = owl_uart_read(port, OWL_UART_STAT); | ||
139 | ret = (val & OWL_UART_STAT_TFES) ? TIOCSER_TEMT : 0; | ||
140 | |||
141 | spin_unlock_irqrestore(&port->lock, flags); | ||
142 | |||
143 | return ret; | ||
144 | } | ||
145 | |||
146 | static void owl_uart_stop_rx(struct uart_port *port) | ||
147 | { | ||
148 | u32 val; | ||
149 | |||
150 | val = owl_uart_read(port, OWL_UART_CTL); | ||
151 | val &= ~(OWL_UART_CTL_RXIE | OWL_UART_CTL_RXDE); | ||
152 | owl_uart_write(port, val, OWL_UART_CTL); | ||
153 | |||
154 | val = owl_uart_read(port, OWL_UART_STAT); | ||
155 | val |= OWL_UART_STAT_RIP; | ||
156 | owl_uart_write(port, val, OWL_UART_STAT); | ||
157 | } | ||
158 | |||
159 | static void owl_uart_stop_tx(struct uart_port *port) | ||
160 | { | ||
161 | u32 val; | ||
162 | |||
163 | val = owl_uart_read(port, OWL_UART_CTL); | ||
164 | val &= ~(OWL_UART_CTL_TXIE | OWL_UART_CTL_TXDE); | ||
165 | owl_uart_write(port, val, OWL_UART_CTL); | ||
166 | |||
167 | val = owl_uart_read(port, OWL_UART_STAT); | ||
168 | val |= OWL_UART_STAT_TIP; | ||
169 | owl_uart_write(port, val, OWL_UART_STAT); | ||
170 | } | ||
171 | |||
172 | static void owl_uart_start_tx(struct uart_port *port) | ||
173 | { | ||
174 | u32 val; | ||
175 | |||
176 | if (uart_tx_stopped(port)) { | ||
177 | owl_uart_stop_tx(port); | ||
178 | return; | ||
179 | } | ||
180 | |||
181 | val = owl_uart_read(port, OWL_UART_STAT); | ||
182 | val |= OWL_UART_STAT_TIP; | ||
183 | owl_uart_write(port, val, OWL_UART_STAT); | ||
184 | |||
185 | val = owl_uart_read(port, OWL_UART_CTL); | ||
186 | val |= OWL_UART_CTL_TXIE; | ||
187 | owl_uart_write(port, val, OWL_UART_CTL); | ||
188 | } | ||
189 | |||
190 | static void owl_uart_send_chars(struct uart_port *port) | ||
191 | { | ||
192 | struct circ_buf *xmit = &port->state->xmit; | ||
193 | unsigned int ch; | ||
194 | |||
195 | if (uart_tx_stopped(port)) | ||
196 | return; | ||
197 | |||
198 | if (port->x_char) { | ||
199 | while (!(owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)) | ||
200 | cpu_relax(); | ||
201 | owl_uart_write(port, port->x_char, OWL_UART_TXDAT); | ||
202 | port->icount.tx++; | ||
203 | port->x_char = 0; | ||
204 | } | ||
205 | |||
206 | while (!(owl_uart_read(port, OWL_UART_STAT) & OWL_UART_STAT_TFFU)) { | ||
207 | if (uart_circ_empty(xmit)) | ||
208 | break; | ||
209 | |||
210 | ch = xmit->buf[xmit->tail]; | ||
211 | owl_uart_write(port, ch, OWL_UART_TXDAT); | ||
212 | xmit->tail = (xmit->tail + 1) & (SERIAL_XMIT_SIZE - 1); | ||
213 | port->icount.tx++; | ||
214 | } | ||
215 | |||
216 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | ||
217 | uart_write_wakeup(port); | ||
218 | |||
219 | if (uart_circ_empty(xmit)) | ||
220 | owl_uart_stop_tx(port); | ||
221 | } | ||
222 | |||
223 | static void owl_uart_receive_chars(struct uart_port *port) | ||
224 | { | ||
225 | u32 stat, val; | ||
226 | |||
227 | val = owl_uart_read(port, OWL_UART_CTL); | ||
228 | val &= ~OWL_UART_CTL_TRFS_TX; | ||
229 | owl_uart_write(port, val, OWL_UART_CTL); | ||
230 | |||
231 | stat = owl_uart_read(port, OWL_UART_STAT); | ||
232 | while (!(stat & OWL_UART_STAT_RFEM)) { | ||
233 | char flag = TTY_NORMAL; | ||
234 | |||
235 | if (stat & OWL_UART_STAT_RXER) | ||
236 | port->icount.overrun++; | ||
237 | |||
238 | if (stat & OWL_UART_STAT_RXST) { | ||
239 | /* We are not able to distinguish the error type. */ | ||
240 | port->icount.brk++; | ||
241 | port->icount.frame++; | ||
242 | |||
243 | stat &= port->read_status_mask; | ||
244 | if (stat & OWL_UART_STAT_RXST) | ||
245 | flag = TTY_PARITY; | ||
246 | } else | ||
247 | port->icount.rx++; | ||
248 | |||
249 | val = owl_uart_read(port, OWL_UART_RXDAT); | ||
250 | val &= 0xff; | ||
251 | |||
252 | if ((stat & port->ignore_status_mask) == 0) | ||
253 | tty_insert_flip_char(&port->state->port, val, flag); | ||
254 | |||
255 | stat = owl_uart_read(port, OWL_UART_STAT); | ||
256 | } | ||
257 | |||
258 | spin_unlock(&port->lock); | ||
259 | tty_flip_buffer_push(&port->state->port); | ||
260 | spin_lock(&port->lock); | ||
261 | } | ||
262 | |||
263 | static irqreturn_t owl_uart_irq(int irq, void *dev_id) | ||
264 | { | ||
265 | struct uart_port *port = dev_id; | ||
266 | unsigned long flags; | ||
267 | u32 stat; | ||
268 | |||
269 | spin_lock_irqsave(&port->lock, flags); | ||
270 | |||
271 | stat = owl_uart_read(port, OWL_UART_STAT); | ||
272 | |||
273 | if (stat & OWL_UART_STAT_RIP) | ||
274 | owl_uart_receive_chars(port); | ||
275 | |||
276 | if (stat & OWL_UART_STAT_TIP) | ||
277 | owl_uart_send_chars(port); | ||
278 | |||
279 | stat = owl_uart_read(port, OWL_UART_STAT); | ||
280 | stat |= OWL_UART_STAT_RIP | OWL_UART_STAT_TIP; | ||
281 | owl_uart_write(port, stat, OWL_UART_STAT); | ||
282 | |||
283 | spin_unlock_irqrestore(&port->lock, flags); | ||
284 | |||
285 | return IRQ_HANDLED; | ||
286 | } | ||
287 | |||
288 | static void owl_uart_shutdown(struct uart_port *port) | ||
289 | { | ||
290 | u32 val; | ||
291 | unsigned long flags; | ||
292 | |||
293 | spin_lock_irqsave(&port->lock, flags); | ||
294 | |||
295 | val = owl_uart_read(port, OWL_UART_CTL); | ||
296 | val &= ~(OWL_UART_CTL_TXIE | OWL_UART_CTL_RXIE | ||
297 | | OWL_UART_CTL_TXDE | OWL_UART_CTL_RXDE | OWL_UART_CTL_EN); | ||
298 | owl_uart_write(port, val, OWL_UART_CTL); | ||
299 | |||
300 | spin_unlock_irqrestore(&port->lock, flags); | ||
301 | |||
302 | free_irq(port->irq, port); | ||
303 | } | ||
304 | |||
305 | static int owl_uart_startup(struct uart_port *port) | ||
306 | { | ||
307 | u32 val; | ||
308 | unsigned long flags; | ||
309 | int ret; | ||
310 | |||
311 | ret = request_irq(port->irq, owl_uart_irq, IRQF_TRIGGER_HIGH, | ||
312 | "owl-uart", port); | ||
313 | if (ret) | ||
314 | return ret; | ||
315 | |||
316 | spin_lock_irqsave(&port->lock, flags); | ||
317 | |||
318 | val = owl_uart_read(port, OWL_UART_STAT); | ||
319 | val |= OWL_UART_STAT_RIP | OWL_UART_STAT_TIP | ||
320 | | OWL_UART_STAT_RXER | OWL_UART_STAT_TFER | OWL_UART_STAT_RXST; | ||
321 | owl_uart_write(port, val, OWL_UART_STAT); | ||
322 | |||
323 | val = owl_uart_read(port, OWL_UART_CTL); | ||
324 | val |= OWL_UART_CTL_RXIE | OWL_UART_CTL_TXIE; | ||
325 | val |= OWL_UART_CTL_EN; | ||
326 | owl_uart_write(port, val, OWL_UART_CTL); | ||
327 | |||
328 | spin_unlock_irqrestore(&port->lock, flags); | ||
329 | |||
330 | return 0; | ||
331 | } | ||
332 | |||
333 | static void owl_uart_change_baudrate(struct owl_uart_port *owl_port, | ||
334 | unsigned long baud) | ||
335 | { | ||
336 | clk_set_rate(owl_port->clk, baud * 8); | ||
337 | } | ||
338 | |||
339 | static void owl_uart_set_termios(struct uart_port *port, | ||
340 | struct ktermios *termios, | ||
341 | struct ktermios *old) | ||
342 | { | ||
343 | struct owl_uart_port *owl_port = to_owl_uart_port(port); | ||
344 | unsigned int baud; | ||
345 | u32 ctl; | ||
346 | unsigned long flags; | ||
347 | |||
348 | spin_lock_irqsave(&port->lock, flags); | ||
349 | |||
350 | ctl = owl_uart_read(port, OWL_UART_CTL); | ||
351 | |||
352 | ctl &= ~OWL_UART_CTL_DWLS_MASK; | ||
353 | switch (termios->c_cflag & CSIZE) { | ||
354 | case CS5: | ||
355 | ctl |= OWL_UART_CTL_DWLS_5BITS; | ||
356 | break; | ||
357 | case CS6: | ||
358 | ctl |= OWL_UART_CTL_DWLS_6BITS; | ||
359 | break; | ||
360 | case CS7: | ||
361 | ctl |= OWL_UART_CTL_DWLS_7BITS; | ||
362 | break; | ||
363 | case CS8: | ||
364 | default: | ||
365 | ctl |= OWL_UART_CTL_DWLS_8BITS; | ||
366 | break; | ||
367 | } | ||
368 | |||
369 | if (termios->c_cflag & CSTOPB) | ||
370 | ctl |= OWL_UART_CTL_STPS_2BITS; | ||
371 | else | ||
372 | ctl &= ~OWL_UART_CTL_STPS_2BITS; | ||
373 | |||
374 | ctl &= ~OWL_UART_CTL_PRS_MASK; | ||
375 | if (termios->c_cflag & PARENB) { | ||
376 | if (termios->c_cflag & CMSPAR) { | ||
377 | if (termios->c_cflag & PARODD) | ||
378 | ctl |= OWL_UART_CTL_PRS_MARK; | ||
379 | else | ||
380 | ctl |= OWL_UART_CTL_PRS_SPACE; | ||
381 | } else if (termios->c_cflag & PARODD) | ||
382 | ctl |= OWL_UART_CTL_PRS_ODD; | ||
383 | else | ||
384 | ctl |= OWL_UART_CTL_PRS_EVEN; | ||
385 | } else | ||
386 | ctl |= OWL_UART_CTL_PRS_NONE; | ||
387 | |||
388 | if (termios->c_cflag & CRTSCTS) | ||
389 | ctl |= OWL_UART_CTL_AFE; | ||
390 | else | ||
391 | ctl &= ~OWL_UART_CTL_AFE; | ||
392 | |||
393 | owl_uart_write(port, ctl, OWL_UART_CTL); | ||
394 | |||
395 | baud = uart_get_baud_rate(port, termios, old, 9600, 3200000); | ||
396 | owl_uart_change_baudrate(owl_port, baud); | ||
397 | |||
398 | /* Don't rewrite B0 */ | ||
399 | if (tty_termios_baud_rate(termios)) | ||
400 | tty_termios_encode_baud_rate(termios, baud, baud); | ||
401 | |||
402 | port->read_status_mask |= OWL_UART_STAT_RXER; | ||
403 | if (termios->c_iflag & INPCK) | ||
404 | port->read_status_mask |= OWL_UART_STAT_RXST; | ||
405 | |||
406 | uart_update_timeout(port, termios->c_cflag, baud); | ||
407 | |||
408 | spin_unlock_irqrestore(&port->lock, flags); | ||
409 | } | ||
410 | |||
411 | static void owl_uart_release_port(struct uart_port *port) | ||
412 | { | ||
413 | struct platform_device *pdev = to_platform_device(port->dev); | ||
414 | struct resource *res; | ||
415 | |||
416 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
417 | if (!res) | ||
418 | return; | ||
419 | |||
420 | if (port->flags & UPF_IOREMAP) { | ||
421 | devm_release_mem_region(port->dev, port->mapbase, | ||
422 | resource_size(res)); | ||
423 | devm_iounmap(port->dev, port->membase); | ||
424 | port->membase = NULL; | ||
425 | } | ||
426 | } | ||
427 | |||
428 | static int owl_uart_request_port(struct uart_port *port) | ||
429 | { | ||
430 | struct platform_device *pdev = to_platform_device(port->dev); | ||
431 | struct resource *res; | ||
432 | |||
433 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
434 | if (!res) | ||
435 | return -ENXIO; | ||
436 | |||
437 | if (!devm_request_mem_region(port->dev, port->mapbase, | ||
438 | resource_size(res), dev_name(port->dev))) | ||
439 | return -EBUSY; | ||
440 | |||
441 | if (port->flags & UPF_IOREMAP) { | ||
442 | port->membase = devm_ioremap_nocache(port->dev, port->mapbase, | ||
443 | resource_size(res)); | ||
444 | if (!port->membase) | ||
445 | return -EBUSY; | ||
446 | } | ||
447 | |||
448 | return 0; | ||
449 | } | ||
450 | |||
451 | static const char *owl_uart_type(struct uart_port *port) | ||
452 | { | ||
453 | return (port->type == PORT_OWL) ? "owl-uart" : NULL; | ||
454 | } | ||
455 | |||
456 | static int owl_uart_verify_port(struct uart_port *port, | ||
457 | struct serial_struct *ser) | ||
458 | { | ||
459 | if (port->type != PORT_OWL) | ||
460 | return -EINVAL; | ||
461 | |||
462 | if (port->irq != ser->irq) | ||
463 | return -EINVAL; | ||
464 | |||
465 | return 0; | ||
466 | } | ||
467 | |||
468 | static void owl_uart_config_port(struct uart_port *port, int flags) | ||
469 | { | ||
470 | if (flags & UART_CONFIG_TYPE) { | ||
471 | port->type = PORT_OWL; | ||
472 | owl_uart_request_port(port); | ||
473 | } | ||
474 | } | ||
475 | |||
476 | static const struct uart_ops owl_uart_ops = { | ||
477 | .set_mctrl = owl_uart_set_mctrl, | ||
478 | .get_mctrl = owl_uart_get_mctrl, | ||
479 | .tx_empty = owl_uart_tx_empty, | ||
480 | .start_tx = owl_uart_start_tx, | ||
481 | .stop_rx = owl_uart_stop_rx, | ||
482 | .stop_tx = owl_uart_stop_tx, | ||
483 | .startup = owl_uart_startup, | ||
484 | .shutdown = owl_uart_shutdown, | ||
485 | .set_termios = owl_uart_set_termios, | ||
486 | .type = owl_uart_type, | ||
487 | .config_port = owl_uart_config_port, | ||
488 | .request_port = owl_uart_request_port, | ||
489 | .release_port = owl_uart_release_port, | ||
490 | .verify_port = owl_uart_verify_port, | ||
491 | }; | ||
492 | |||
57 | #ifdef CONFIG_SERIAL_OWL_CONSOLE | 493 | #ifdef CONFIG_SERIAL_OWL_CONSOLE |
58 | 494 | ||
59 | static void owl_console_putchar(struct uart_port *port, int ch) | 495 | static void owl_console_putchar(struct uart_port *port, int ch) |
@@ -110,6 +546,57 @@ static void owl_uart_port_write(struct uart_port *port, const char *s, | |||
110 | local_irq_restore(flags); | 546 | local_irq_restore(flags); |
111 | } | 547 | } |
112 | 548 | ||
549 | static void owl_uart_console_write(struct console *co, const char *s, | ||
550 | u_int count) | ||
551 | { | ||
552 | struct owl_uart_port *owl_port; | ||
553 | |||
554 | owl_port = owl_uart_ports[co->index]; | ||
555 | if (!owl_port) | ||
556 | return; | ||
557 | |||
558 | owl_uart_port_write(&owl_port->port, s, count); | ||
559 | } | ||
560 | |||
561 | static int owl_uart_console_setup(struct console *co, char *options) | ||
562 | { | ||
563 | struct owl_uart_port *owl_port; | ||
564 | int baud = 115200; | ||
565 | int bits = 8; | ||
566 | int parity = 'n'; | ||
567 | int flow = 'n'; | ||
568 | |||
569 | if (co->index < 0 || co->index >= OWL_UART_PORT_NUM) | ||
570 | return -EINVAL; | ||
571 | |||
572 | owl_port = owl_uart_ports[co->index]; | ||
573 | if (!owl_port || !owl_port->port.membase) | ||
574 | return -ENODEV; | ||
575 | |||
576 | if (options) | ||
577 | uart_parse_options(options, &baud, &parity, &bits, &flow); | ||
578 | |||
579 | return uart_set_options(&owl_port->port, co, baud, parity, bits, flow); | ||
580 | } | ||
581 | |||
582 | static struct console owl_uart_console = { | ||
583 | .name = OWL_UART_DEV_NAME, | ||
584 | .write = owl_uart_console_write, | ||
585 | .device = uart_console_device, | ||
586 | .setup = owl_uart_console_setup, | ||
587 | .flags = CON_PRINTBUFFER, | ||
588 | .index = -1, | ||
589 | .data = &owl_uart_driver, | ||
590 | }; | ||
591 | |||
592 | static int __init owl_uart_console_init(void) | ||
593 | { | ||
594 | register_console(&owl_uart_console); | ||
595 | |||
596 | return 0; | ||
597 | } | ||
598 | console_initcall(owl_uart_console_init); | ||
599 | |||
113 | static void owl_uart_early_console_write(struct console *co, | 600 | static void owl_uart_early_console_write(struct console *co, |
114 | const char *s, | 601 | const char *s, |
115 | u_int count) | 602 | u_int count) |
@@ -132,4 +619,148 @@ owl_uart_early_console_setup(struct earlycon_device *device, const char *opt) | |||
132 | OF_EARLYCON_DECLARE(owl, "actions,owl-uart", | 619 | OF_EARLYCON_DECLARE(owl, "actions,owl-uart", |
133 | owl_uart_early_console_setup); | 620 | owl_uart_early_console_setup); |
134 | 621 | ||
135 | #endif /* CONFIG_SERIAL_OWL_CONSOLE */ | 622 | #define OWL_UART_CONSOLE (&owl_uart_console) |
623 | #else | ||
624 | #define OWL_UART_CONSOLE NULL | ||
625 | #endif | ||
626 | |||
627 | static struct uart_driver owl_uart_driver = { | ||
628 | .owner = THIS_MODULE, | ||
629 | .driver_name = "owl-uart", | ||
630 | .dev_name = OWL_UART_DEV_NAME, | ||
631 | .nr = OWL_UART_PORT_NUM, | ||
632 | .cons = OWL_UART_CONSOLE, | ||
633 | }; | ||
634 | |||
635 | static const struct owl_uart_info owl_s500_info = { | ||
636 | .tx_fifosize = 16, | ||
637 | }; | ||
638 | |||
639 | static const struct owl_uart_info owl_s900_info = { | ||
640 | .tx_fifosize = 32, | ||
641 | }; | ||
642 | |||
643 | static const struct of_device_id owl_uart_dt_matches[] = { | ||
644 | { .compatible = "actions,s500-uart", .data = &owl_s500_info }, | ||
645 | { .compatible = "actions,s900-uart", .data = &owl_s900_info }, | ||
646 | { } | ||
647 | }; | ||
648 | MODULE_DEVICE_TABLE(of, owl_uart_dt_matches); | ||
649 | |||
650 | static int owl_uart_probe(struct platform_device *pdev) | ||
651 | { | ||
652 | const struct of_device_id *match; | ||
653 | const struct owl_uart_info *info = NULL; | ||
654 | struct resource *res_mem; | ||
655 | struct owl_uart_port *owl_port; | ||
656 | int ret, irq; | ||
657 | |||
658 | if (pdev->dev.of_node) { | ||
659 | pdev->id = of_alias_get_id(pdev->dev.of_node, "serial"); | ||
660 | match = of_match_node(owl_uart_dt_matches, pdev->dev.of_node); | ||
661 | if (match) | ||
662 | info = match->data; | ||
663 | } | ||
664 | |||
665 | if (pdev->id < 0 || pdev->id >= OWL_UART_PORT_NUM) { | ||
666 | dev_err(&pdev->dev, "id %d out of range\n", pdev->id); | ||
667 | return -EINVAL; | ||
668 | } | ||
669 | |||
670 | res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
671 | if (!res_mem) { | ||
672 | dev_err(&pdev->dev, "could not get mem\n"); | ||
673 | return -ENODEV; | ||
674 | } | ||
675 | |||
676 | irq = platform_get_irq(pdev, 0); | ||
677 | if (irq < 0) { | ||
678 | dev_err(&pdev->dev, "could not get irq\n"); | ||
679 | return irq; | ||
680 | } | ||
681 | |||
682 | if (owl_uart_ports[pdev->id]) { | ||
683 | dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); | ||
684 | return -EBUSY; | ||
685 | } | ||
686 | |||
687 | owl_port = devm_kzalloc(&pdev->dev, sizeof(*owl_port), GFP_KERNEL); | ||
688 | if (!owl_port) | ||
689 | return -ENOMEM; | ||
690 | |||
691 | owl_port->clk = devm_clk_get(&pdev->dev, NULL); | ||
692 | if (IS_ERR(owl_port->clk)) { | ||
693 | dev_err(&pdev->dev, "could not get clk\n"); | ||
694 | return PTR_ERR(owl_port->clk); | ||
695 | } | ||
696 | |||
697 | owl_port->port.dev = &pdev->dev; | ||
698 | owl_port->port.line = pdev->id; | ||
699 | owl_port->port.type = PORT_OWL; | ||
700 | owl_port->port.iotype = UPIO_MEM; | ||
701 | owl_port->port.mapbase = res_mem->start; | ||
702 | owl_port->port.irq = irq; | ||
703 | owl_port->port.uartclk = clk_get_rate(owl_port->clk); | ||
704 | if (owl_port->port.uartclk == 0) { | ||
705 | dev_err(&pdev->dev, "clock rate is zero\n"); | ||
706 | return -EINVAL; | ||
707 | } | ||
708 | owl_port->port.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_LOW_LATENCY; | ||
709 | owl_port->port.x_char = 0; | ||
710 | owl_port->port.fifosize = (info) ? info->tx_fifosize : 16; | ||
711 | owl_port->port.ops = &owl_uart_ops; | ||
712 | |||
713 | owl_uart_ports[pdev->id] = owl_port; | ||
714 | platform_set_drvdata(pdev, owl_port); | ||
715 | |||
716 | ret = uart_add_one_port(&owl_uart_driver, &owl_port->port); | ||
717 | if (ret) | ||
718 | owl_uart_ports[pdev->id] = NULL; | ||
719 | |||
720 | return ret; | ||
721 | } | ||
722 | |||
723 | static int owl_uart_remove(struct platform_device *pdev) | ||
724 | { | ||
725 | struct owl_uart_port *owl_port = platform_get_drvdata(pdev); | ||
726 | |||
727 | uart_remove_one_port(&owl_uart_driver, &owl_port->port); | ||
728 | owl_uart_ports[pdev->id] = NULL; | ||
729 | |||
730 | return 0; | ||
731 | } | ||
732 | |||
733 | static struct platform_driver owl_uart_platform_driver = { | ||
734 | .probe = owl_uart_probe, | ||
735 | .remove = owl_uart_remove, | ||
736 | .driver = { | ||
737 | .name = "owl-uart", | ||
738 | .of_match_table = owl_uart_dt_matches, | ||
739 | }, | ||
740 | }; | ||
741 | |||
742 | static int __init owl_uart_init(void) | ||
743 | { | ||
744 | int ret; | ||
745 | |||
746 | ret = uart_register_driver(&owl_uart_driver); | ||
747 | if (ret) | ||
748 | return ret; | ||
749 | |||
750 | ret = platform_driver_register(&owl_uart_platform_driver); | ||
751 | if (ret) | ||
752 | uart_unregister_driver(&owl_uart_driver); | ||
753 | |||
754 | return ret; | ||
755 | } | ||
756 | |||
757 | static void __init owl_uart_exit(void) | ||
758 | { | ||
759 | platform_driver_unregister(&owl_uart_platform_driver); | ||
760 | uart_unregister_driver(&owl_uart_driver); | ||
761 | } | ||
762 | |||
763 | module_init(owl_uart_init); | ||
764 | module_exit(owl_uart_exit); | ||
765 | |||
766 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index d3796dc26fa9..ae8cfc81ffc5 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c | |||
@@ -46,11 +46,6 @@ enum { | |||
46 | PCH_UART_HANDLED_LS_INT_SHIFT, | 46 | PCH_UART_HANDLED_LS_INT_SHIFT, |
47 | }; | 47 | }; |
48 | 48 | ||
49 | enum { | ||
50 | PCH_UART_8LINE, | ||
51 | PCH_UART_2LINE, | ||
52 | }; | ||
53 | |||
54 | #define PCH_UART_DRIVER_DEVICE "ttyPCH" | 49 | #define PCH_UART_DRIVER_DEVICE "ttyPCH" |
55 | 50 | ||
56 | /* Set the max number of UART port | 51 | /* Set the max number of UART port |
@@ -267,7 +262,7 @@ struct eg20t_port { | |||
267 | 262 | ||
268 | /** | 263 | /** |
269 | * struct pch_uart_driver_data - private data structure for UART-DMA | 264 | * struct pch_uart_driver_data - private data structure for UART-DMA |
270 | * @port_type: The number of DMA channel | 265 | * @port_type: The type of UART port |
271 | * @line_no: UART port line number (0, 1, 2...) | 266 | * @line_no: UART port line number (0, 1, 2...) |
272 | */ | 267 | */ |
273 | struct pch_uart_driver_data { | 268 | struct pch_uart_driver_data { |
@@ -290,17 +285,17 @@ enum pch_uart_num_t { | |||
290 | }; | 285 | }; |
291 | 286 | ||
292 | static struct pch_uart_driver_data drv_dat[] = { | 287 | static struct pch_uart_driver_data drv_dat[] = { |
293 | [pch_et20t_uart0] = {PCH_UART_8LINE, 0}, | 288 | [pch_et20t_uart0] = {PORT_PCH_8LINE, 0}, |
294 | [pch_et20t_uart1] = {PCH_UART_2LINE, 1}, | 289 | [pch_et20t_uart1] = {PORT_PCH_2LINE, 1}, |
295 | [pch_et20t_uart2] = {PCH_UART_2LINE, 2}, | 290 | [pch_et20t_uart2] = {PORT_PCH_2LINE, 2}, |
296 | [pch_et20t_uart3] = {PCH_UART_2LINE, 3}, | 291 | [pch_et20t_uart3] = {PORT_PCH_2LINE, 3}, |
297 | [pch_ml7213_uart0] = {PCH_UART_8LINE, 0}, | 292 | [pch_ml7213_uart0] = {PORT_PCH_8LINE, 0}, |
298 | [pch_ml7213_uart1] = {PCH_UART_2LINE, 1}, | 293 | [pch_ml7213_uart1] = {PORT_PCH_2LINE, 1}, |
299 | [pch_ml7213_uart2] = {PCH_UART_2LINE, 2}, | 294 | [pch_ml7213_uart2] = {PORT_PCH_2LINE, 2}, |
300 | [pch_ml7223_uart0] = {PCH_UART_8LINE, 0}, | 295 | [pch_ml7223_uart0] = {PORT_PCH_8LINE, 0}, |
301 | [pch_ml7223_uart1] = {PCH_UART_2LINE, 1}, | 296 | [pch_ml7223_uart1] = {PORT_PCH_2LINE, 1}, |
302 | [pch_ml7831_uart0] = {PCH_UART_8LINE, 0}, | 297 | [pch_ml7831_uart0] = {PORT_PCH_8LINE, 0}, |
303 | [pch_ml7831_uart1] = {PCH_UART_2LINE, 1}, | 298 | [pch_ml7831_uart1] = {PORT_PCH_2LINE, 1}, |
304 | }; | 299 | }; |
305 | 300 | ||
306 | #ifdef CONFIG_SERIAL_PCH_UART_CONSOLE | 301 | #ifdef CONFIG_SERIAL_PCH_UART_CONSOLE |
@@ -1777,10 +1772,10 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev, | |||
1777 | goto init_port_free_txbuf; | 1772 | goto init_port_free_txbuf; |
1778 | 1773 | ||
1779 | switch (port_type) { | 1774 | switch (port_type) { |
1780 | case PORT_UNKNOWN: | 1775 | case PORT_PCH_8LINE: |
1781 | fifosize = 256; /* EG20T/ML7213: UART0 */ | 1776 | fifosize = 256; /* EG20T/ML7213: UART0 */ |
1782 | break; | 1777 | break; |
1783 | case PORT_8250: | 1778 | case PORT_PCH_2LINE: |
1784 | fifosize = 64; /* EG20T:UART1~3 ML7213: UART1~2*/ | 1779 | fifosize = 64; /* EG20T:UART1~3 ML7213: UART1~2*/ |
1785 | break; | 1780 | break; |
1786 | default: | 1781 | default: |
@@ -1804,7 +1799,7 @@ static struct eg20t_port *pch_uart_init_port(struct pci_dev *pdev, | |||
1804 | 1799 | ||
1805 | priv->fifo_size = fifosize; | 1800 | priv->fifo_size = fifosize; |
1806 | priv->uartclk = pch_uart_get_uartclk(); | 1801 | priv->uartclk = pch_uart_get_uartclk(); |
1807 | priv->port_type = PORT_MAX_8250 + port_type + 1; | 1802 | priv->port_type = port_type; |
1808 | priv->port.dev = &pdev->dev; | 1803 | priv->port.dev = &pdev->dev; |
1809 | priv->port.iobase = iobase; | 1804 | priv->port.iobase = iobase; |
1810 | priv->port.membase = NULL; | 1805 | priv->port.membase = NULL; |
@@ -1862,8 +1857,7 @@ static void pch_uart_exit_port(struct eg20t_port *priv) | |||
1862 | { | 1857 | { |
1863 | 1858 | ||
1864 | #ifdef CONFIG_DEBUG_FS | 1859 | #ifdef CONFIG_DEBUG_FS |
1865 | if (priv->debugfs) | 1860 | debugfs_remove(priv->debugfs); |
1866 | debugfs_remove(priv->debugfs); | ||
1867 | #endif | 1861 | #endif |
1868 | uart_remove_one_port(&pch_uart_driver, &priv->port); | 1862 | uart_remove_one_port(&pch_uart_driver, &priv->port); |
1869 | free_page((unsigned long)priv->rxbuf.buf); | 1863 | free_page((unsigned long)priv->rxbuf.buf); |
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c index 0da52947e59e..6ccdd018fb45 100644 --- a/drivers/tty/serial/pmac_zilog.c +++ b/drivers/tty/serial/pmac_zilog.c | |||
@@ -1671,8 +1671,8 @@ static int __init pmz_probe(void) | |||
1671 | if (!node_a && !node_b) { | 1671 | if (!node_a && !node_b) { |
1672 | of_node_put(node_a); | 1672 | of_node_put(node_a); |
1673 | of_node_put(node_b); | 1673 | of_node_put(node_b); |
1674 | printk(KERN_ERR "pmac_zilog: missing node %c for escc %s\n", | 1674 | printk(KERN_ERR "pmac_zilog: missing node %c for escc %pOF\n", |
1675 | (!node_a) ? 'a' : 'b', node_p->full_name); | 1675 | (!node_a) ? 'a' : 'b', node_p); |
1676 | continue; | 1676 | continue; |
1677 | } | 1677 | } |
1678 | 1678 | ||
diff --git a/drivers/tty/serial/serial-tegra.c b/drivers/tty/serial/serial-tegra.c index d92a150c8733..cf9b736f26f8 100644 --- a/drivers/tty/serial/serial-tegra.c +++ b/drivers/tty/serial/serial-tegra.c | |||
@@ -1310,7 +1310,7 @@ static int tegra_uart_probe(struct platform_device *pdev) | |||
1310 | return PTR_ERR(tup->uart_clk); | 1310 | return PTR_ERR(tup->uart_clk); |
1311 | } | 1311 | } |
1312 | 1312 | ||
1313 | tup->rst = devm_reset_control_get(&pdev->dev, "serial"); | 1313 | tup->rst = devm_reset_control_get_exclusive(&pdev->dev, "serial"); |
1314 | if (IS_ERR(tup->rst)) { | 1314 | if (IS_ERR(tup->rst)) { |
1315 | dev_err(&pdev->dev, "Couldn't get the reset\n"); | 1315 | dev_err(&pdev->dev, "Couldn't get the reset\n"); |
1316 | return PTR_ERR(tup->rst); | 1316 | return PTR_ERR(tup->rst); |
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index f534a40aebde..3a14cccbd7ff 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
@@ -36,7 +36,7 @@ | |||
36 | #include <linux/delay.h> | 36 | #include <linux/delay.h> |
37 | #include <linux/mutex.h> | 37 | #include <linux/mutex.h> |
38 | 38 | ||
39 | #include <asm/irq.h> | 39 | #include <linux/irq.h> |
40 | #include <linux/uaccess.h> | 40 | #include <linux/uaccess.h> |
41 | 41 | ||
42 | /* | 42 | /* |
@@ -165,6 +165,27 @@ uart_update_mctrl(struct uart_port *port, unsigned int set, unsigned int clear) | |||
165 | #define uart_set_mctrl(port, set) uart_update_mctrl(port, set, 0) | 165 | #define uart_set_mctrl(port, set) uart_update_mctrl(port, set, 0) |
166 | #define uart_clear_mctrl(port, clear) uart_update_mctrl(port, 0, clear) | 166 | #define uart_clear_mctrl(port, clear) uart_update_mctrl(port, 0, clear) |
167 | 167 | ||
168 | static void uart_port_dtr_rts(struct uart_port *uport, int raise) | ||
169 | { | ||
170 | int rs485_on = uport->rs485_config && | ||
171 | (uport->rs485.flags & SER_RS485_ENABLED); | ||
172 | int RTS_after_send = !!(uport->rs485.flags & SER_RS485_RTS_AFTER_SEND); | ||
173 | |||
174 | if (raise) { | ||
175 | if (rs485_on && !RTS_after_send) { | ||
176 | uart_set_mctrl(uport, TIOCM_DTR); | ||
177 | uart_clear_mctrl(uport, TIOCM_RTS); | ||
178 | } else { | ||
179 | uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS); | ||
180 | } | ||
181 | } else { | ||
182 | unsigned int clear = TIOCM_DTR; | ||
183 | |||
184 | clear |= (!rs485_on || !RTS_after_send) ? TIOCM_RTS : 0; | ||
185 | uart_clear_mctrl(uport, clear); | ||
186 | } | ||
187 | } | ||
188 | |||
168 | /* | 189 | /* |
169 | * Startup the port. This will be called once per open. All calls | 190 | * Startup the port. This will be called once per open. All calls |
170 | * will be serialised by the per-port mutex. | 191 | * will be serialised by the per-port mutex. |
@@ -214,7 +235,7 @@ static int uart_port_startup(struct tty_struct *tty, struct uart_state *state, | |||
214 | * port is open and ready to respond. | 235 | * port is open and ready to respond. |
215 | */ | 236 | */ |
216 | if (init_hw && C_BAUD(tty)) | 237 | if (init_hw && C_BAUD(tty)) |
217 | uart_set_mctrl(uport, TIOCM_RTS | TIOCM_DTR); | 238 | uart_port_dtr_rts(uport, 1); |
218 | } | 239 | } |
219 | 240 | ||
220 | /* | 241 | /* |
@@ -272,7 +293,7 @@ static void uart_shutdown(struct tty_struct *tty, struct uart_state *state) | |||
272 | uport->cons->cflag = tty->termios.c_cflag; | 293 | uport->cons->cflag = tty->termios.c_cflag; |
273 | 294 | ||
274 | if (!tty || C_HUPCL(tty)) | 295 | if (!tty || C_HUPCL(tty)) |
275 | uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS); | 296 | uart_port_dtr_rts(uport, 0); |
276 | 297 | ||
277 | uart_port_shutdown(port); | 298 | uart_port_shutdown(port); |
278 | } | 299 | } |
@@ -744,7 +765,7 @@ static int uart_get_info(struct tty_port *port, struct serial_struct *retinfo) | |||
744 | if (HIGH_BITS_OFFSET) | 765 | if (HIGH_BITS_OFFSET) |
745 | retinfo->port_high = (long) uport->iobase >> HIGH_BITS_OFFSET; | 766 | retinfo->port_high = (long) uport->iobase >> HIGH_BITS_OFFSET; |
746 | retinfo->irq = uport->irq; | 767 | retinfo->irq = uport->irq; |
747 | retinfo->flags = uport->flags; | 768 | retinfo->flags = (__force int)uport->flags; |
748 | retinfo->xmit_fifo_size = uport->fifosize; | 769 | retinfo->xmit_fifo_size = uport->fifosize; |
749 | retinfo->baud_base = uport->uartclk / 16; | 770 | retinfo->baud_base = uport->uartclk / 16; |
750 | retinfo->close_delay = jiffies_to_msecs(port->close_delay) / 10; | 771 | retinfo->close_delay = jiffies_to_msecs(port->close_delay) / 10; |
@@ -818,7 +839,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, | |||
818 | new_info->type != uport->type); | 839 | new_info->type != uport->type); |
819 | 840 | ||
820 | old_flags = uport->flags; | 841 | old_flags = uport->flags; |
821 | new_flags = new_info->flags; | 842 | new_flags = (__force upf_t)new_info->flags; |
822 | old_custom_divisor = uport->custom_divisor; | 843 | old_custom_divisor = uport->custom_divisor; |
823 | 844 | ||
824 | if (!capable(CAP_SYS_ADMIN)) { | 845 | if (!capable(CAP_SYS_ADMIN)) { |
@@ -1658,7 +1679,7 @@ static int uart_carrier_raised(struct tty_port *port) | |||
1658 | return 0; | 1679 | return 0; |
1659 | } | 1680 | } |
1660 | 1681 | ||
1661 | static void uart_dtr_rts(struct tty_port *port, int onoff) | 1682 | static void uart_dtr_rts(struct tty_port *port, int raise) |
1662 | { | 1683 | { |
1663 | struct uart_state *state = container_of(port, struct uart_state, port); | 1684 | struct uart_state *state = container_of(port, struct uart_state, port); |
1664 | struct uart_port *uport; | 1685 | struct uart_port *uport; |
@@ -1666,12 +1687,7 @@ static void uart_dtr_rts(struct tty_port *port, int onoff) | |||
1666 | uport = uart_port_ref(state); | 1687 | uport = uart_port_ref(state); |
1667 | if (!uport) | 1688 | if (!uport) |
1668 | return; | 1689 | return; |
1669 | 1690 | uart_port_dtr_rts(uport, raise); | |
1670 | if (onoff) | ||
1671 | uart_set_mctrl(uport, TIOCM_DTR | TIOCM_RTS); | ||
1672 | else | ||
1673 | uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS); | ||
1674 | |||
1675 | uart_port_deref(uport); | 1691 | uart_port_deref(uport); |
1676 | } | 1692 | } |
1677 | 1693 | ||
@@ -2083,8 +2099,7 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport) | |||
2083 | 2099 | ||
2084 | tty_dev = device_find_child(uport->dev, &match, serial_match_port); | 2100 | tty_dev = device_find_child(uport->dev, &match, serial_match_port); |
2085 | if (tty_dev && device_may_wakeup(tty_dev)) { | 2101 | if (tty_dev && device_may_wakeup(tty_dev)) { |
2086 | if (!enable_irq_wake(uport->irq)) | 2102 | enable_irq_wake(uport->irq); |
2087 | uport->irq_wake = 1; | ||
2088 | put_device(tty_dev); | 2103 | put_device(tty_dev); |
2089 | mutex_unlock(&port->mutex); | 2104 | mutex_unlock(&port->mutex); |
2090 | return 0; | 2105 | return 0; |
@@ -2147,10 +2162,8 @@ int uart_resume_port(struct uart_driver *drv, struct uart_port *uport) | |||
2147 | 2162 | ||
2148 | tty_dev = device_find_child(uport->dev, &match, serial_match_port); | 2163 | tty_dev = device_find_child(uport->dev, &match, serial_match_port); |
2149 | if (!uport->suspended && device_may_wakeup(tty_dev)) { | 2164 | if (!uport->suspended && device_may_wakeup(tty_dev)) { |
2150 | if (uport->irq_wake) { | 2165 | if (irqd_is_wakeup_set(irq_get_irq_data((uport->irq)))) |
2151 | disable_irq_wake(uport->irq); | 2166 | disable_irq_wake(uport->irq); |
2152 | uport->irq_wake = 0; | ||
2153 | } | ||
2154 | put_device(tty_dev); | 2167 | put_device(tty_dev); |
2155 | mutex_unlock(&port->mutex); | 2168 | mutex_unlock(&port->mutex); |
2156 | return 0; | 2169 | return 0; |
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c index e08b16b070c0..784dd42002ea 100644 --- a/drivers/tty/serial/sh-sci.c +++ b/drivers/tty/serial/sh-sci.c | |||
@@ -3073,8 +3073,7 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev, | |||
3073 | p->type = SCI_OF_TYPE(match->data); | 3073 | p->type = SCI_OF_TYPE(match->data); |
3074 | p->regtype = SCI_OF_REGTYPE(match->data); | 3074 | p->regtype = SCI_OF_REGTYPE(match->data); |
3075 | 3075 | ||
3076 | if (of_find_property(np, "uart-has-rtscts", NULL)) | 3076 | sp->has_rtscts = of_property_read_bool(np, "uart-has-rtscts"); |
3077 | sp->has_rtscts = true; | ||
3078 | 3077 | ||
3079 | return p; | 3078 | return p; |
3080 | } | 3079 | } |
diff --git a/drivers/tty/serial/sprd_serial.c b/drivers/tty/serial/sprd_serial.c index 90996ad97b37..e902494ebbd5 100644 --- a/drivers/tty/serial/sprd_serial.c +++ b/drivers/tty/serial/sprd_serial.c | |||
@@ -63,6 +63,7 @@ | |||
63 | 63 | ||
64 | /* interrupt clear register */ | 64 | /* interrupt clear register */ |
65 | #define SPRD_ICLR 0x0014 | 65 | #define SPRD_ICLR 0x0014 |
66 | #define SPRD_ICLR_TIMEOUT BIT(13) | ||
66 | 67 | ||
67 | /* line control register */ | 68 | /* line control register */ |
68 | #define SPRD_LCR 0x0018 | 69 | #define SPRD_LCR 0x0018 |
@@ -298,7 +299,8 @@ static irqreturn_t sprd_handle_irq(int irq, void *dev_id) | |||
298 | return IRQ_NONE; | 299 | return IRQ_NONE; |
299 | } | 300 | } |
300 | 301 | ||
301 | serial_out(port, SPRD_ICLR, ~0); | 302 | if (ims & SPRD_IMSR_TIMEOUT) |
303 | serial_out(port, SPRD_ICLR, SPRD_ICLR_TIMEOUT); | ||
302 | 304 | ||
303 | if (ims & (SPRD_IMSR_RX_FIFO_FULL | | 305 | if (ims & (SPRD_IMSR_RX_FIFO_FULL | |
304 | SPRD_IMSR_BREAK_DETECT | SPRD_IMSR_TIMEOUT)) | 306 | SPRD_IMSR_BREAK_DETECT | SPRD_IMSR_TIMEOUT)) |
@@ -729,8 +731,8 @@ static int sprd_probe(struct platform_device *pdev) | |||
729 | 731 | ||
730 | irq = platform_get_irq(pdev, 0); | 732 | irq = platform_get_irq(pdev, 0); |
731 | if (irq < 0) { | 733 | if (irq < 0) { |
732 | dev_err(&pdev->dev, "not provide irq resource\n"); | 734 | dev_err(&pdev->dev, "not provide irq resource: %d\n", irq); |
733 | return -ENODEV; | 735 | return irq; |
734 | } | 736 | } |
735 | up->irq = irq; | 737 | up->irq = irq; |
736 | 738 | ||
diff --git a/drivers/tty/serial/st-asc.c b/drivers/tty/serial/st-asc.c index 6b0ca65027d0..b313a792b149 100644 --- a/drivers/tty/serial/st-asc.c +++ b/drivers/tty/serial/st-asc.c | |||
@@ -310,7 +310,7 @@ static void asc_receive_chars(struct uart_port *port) | |||
310 | if (mode == ASC_CTL_MODE_8BIT || mode == ASC_CTL_MODE_8BIT_PAR) | 310 | if (mode == ASC_CTL_MODE_8BIT || mode == ASC_CTL_MODE_8BIT_PAR) |
311 | ignore_pe = true; | 311 | ignore_pe = true; |
312 | 312 | ||
313 | if (port->irq_wake) | 313 | if (irqd_is_wakeup_set(irq_get_irq_data(port->irq))) |
314 | pm_wakeup_event(tport->tty->dev, 0); | 314 | pm_wakeup_event(tport->tty->dev, 0); |
315 | 315 | ||
316 | while ((status = asc_in(port, ASC_STA)) & ASC_STA_RBF) { | 316 | while ((status = asc_in(port, ASC_STA)) & ASC_STA_RBF) { |
diff --git a/drivers/tty/serial/stm32-usart.c b/drivers/tty/serial/stm32-usart.c index 033856287ca2..03a583264d9e 100644 --- a/drivers/tty/serial/stm32-usart.c +++ b/drivers/tty/serial/stm32-usart.c | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) Maxime Coquelin 2015 | 2 | * Copyright (C) Maxime Coquelin 2015 |
3 | * Copyright (C) STMicroelectronics SA 2017 | ||
3 | * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com> | 4 | * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com> |
4 | * Gerald Baeza <gerald.baeza@st.com> | 5 | * Gerald Baeza <gerald.baeza@st.com> |
5 | * License terms: GNU General Public License (GPL), version 2 | 6 | * License terms: GNU General Public License (GPL), version 2 |
@@ -25,6 +26,7 @@ | |||
25 | #include <linux/of_platform.h> | 26 | #include <linux/of_platform.h> |
26 | #include <linux/platform_device.h> | 27 | #include <linux/platform_device.h> |
27 | #include <linux/pm_runtime.h> | 28 | #include <linux/pm_runtime.h> |
29 | #include <linux/pm_wakeirq.h> | ||
28 | #include <linux/serial_core.h> | 30 | #include <linux/serial_core.h> |
29 | #include <linux/serial.h> | 31 | #include <linux/serial.h> |
30 | #include <linux/spinlock.h> | 32 | #include <linux/spinlock.h> |
@@ -110,14 +112,13 @@ static void stm32_receive_chars(struct uart_port *port, bool threaded) | |||
110 | unsigned long c; | 112 | unsigned long c; |
111 | u32 sr; | 113 | u32 sr; |
112 | char flag; | 114 | char flag; |
113 | static int last_res = RX_BUF_L; | ||
114 | 115 | ||
115 | if (port->irq_wake) | 116 | if (irqd_is_wakeup_set(irq_get_irq_data(port->irq))) |
116 | pm_wakeup_event(tport->tty->dev, 0); | 117 | pm_wakeup_event(tport->tty->dev, 0); |
117 | 118 | ||
118 | while (stm32_pending_rx(port, &sr, &last_res, threaded)) { | 119 | while (stm32_pending_rx(port, &sr, &stm32_port->last_res, threaded)) { |
119 | sr |= USART_SR_DUMMY_RX; | 120 | sr |= USART_SR_DUMMY_RX; |
120 | c = stm32_get_char(port, &sr, &last_res); | 121 | c = stm32_get_char(port, &sr, &stm32_port->last_res); |
121 | flag = TTY_NORMAL; | 122 | flag = TTY_NORMAL; |
122 | port->icount.rx++; | 123 | port->icount.rx++; |
123 | 124 | ||
@@ -202,7 +203,7 @@ static void stm32_transmit_chars_pio(struct uart_port *port) | |||
202 | ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, | 203 | ret = readl_relaxed_poll_timeout_atomic(port->membase + ofs->isr, |
203 | isr, | 204 | isr, |
204 | (isr & USART_SR_TXE), | 205 | (isr & USART_SR_TXE), |
205 | 10, 100); | 206 | 10, 100000); |
206 | 207 | ||
207 | if (ret) | 208 | if (ret) |
208 | dev_err(port->dev, "tx empty not set\n"); | 209 | dev_err(port->dev, "tx empty not set\n"); |
@@ -326,6 +327,10 @@ static irqreturn_t stm32_interrupt(int irq, void *ptr) | |||
326 | 327 | ||
327 | sr = readl_relaxed(port->membase + ofs->isr); | 328 | sr = readl_relaxed(port->membase + ofs->isr); |
328 | 329 | ||
330 | if ((sr & USART_SR_WUF) && (ofs->icr != UNDEF_REG)) | ||
331 | writel_relaxed(USART_ICR_WUCF, | ||
332 | port->membase + ofs->icr); | ||
333 | |||
329 | if ((sr & USART_SR_RXNE) && !(stm32_port->rx_ch)) | 334 | if ((sr & USART_SR_RXNE) && !(stm32_port->rx_ch)) |
330 | stm32_receive_chars(port, false); | 335 | stm32_receive_chars(port, false); |
331 | 336 | ||
@@ -442,6 +447,7 @@ static int stm32_startup(struct uart_port *port) | |||
442 | { | 447 | { |
443 | struct stm32_port *stm32_port = to_stm32_port(port); | 448 | struct stm32_port *stm32_port = to_stm32_port(port); |
444 | struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; | 449 | struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; |
450 | struct stm32_usart_config *cfg = &stm32_port->info->cfg; | ||
445 | const char *name = to_platform_device(port->dev)->name; | 451 | const char *name = to_platform_device(port->dev)->name; |
446 | u32 val; | 452 | u32 val; |
447 | int ret; | 453 | int ret; |
@@ -452,7 +458,18 @@ static int stm32_startup(struct uart_port *port) | |||
452 | if (ret) | 458 | if (ret) |
453 | return ret; | 459 | return ret; |
454 | 460 | ||
461 | if (cfg->has_wakeup && stm32_port->wakeirq >= 0) { | ||
462 | ret = dev_pm_set_dedicated_wake_irq(port->dev, | ||
463 | stm32_port->wakeirq); | ||
464 | if (ret) { | ||
465 | free_irq(port->irq, port); | ||
466 | return ret; | ||
467 | } | ||
468 | } | ||
469 | |||
455 | val = USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE; | 470 | val = USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE; |
471 | if (stm32_port->fifoen) | ||
472 | val |= USART_CR1_FIFOEN; | ||
456 | stm32_set_bits(port, ofs->cr1, val); | 473 | stm32_set_bits(port, ofs->cr1, val); |
457 | 474 | ||
458 | return 0; | 475 | return 0; |
@@ -467,8 +484,11 @@ static void stm32_shutdown(struct uart_port *port) | |||
467 | 484 | ||
468 | val = USART_CR1_TXEIE | USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE; | 485 | val = USART_CR1_TXEIE | USART_CR1_RXNEIE | USART_CR1_TE | USART_CR1_RE; |
469 | val |= BIT(cfg->uart_enable_bit); | 486 | val |= BIT(cfg->uart_enable_bit); |
487 | if (stm32_port->fifoen) | ||
488 | val |= USART_CR1_FIFOEN; | ||
470 | stm32_clr_bits(port, ofs->cr1, val); | 489 | stm32_clr_bits(port, ofs->cr1, val); |
471 | 490 | ||
491 | dev_pm_clear_wake_irq(port->dev); | ||
472 | free_irq(port->irq, port); | 492 | free_irq(port->irq, port); |
473 | } | 493 | } |
474 | 494 | ||
@@ -496,6 +516,8 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios, | |||
496 | 516 | ||
497 | cr1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE; | 517 | cr1 = USART_CR1_TE | USART_CR1_RE | USART_CR1_RXNEIE; |
498 | cr1 |= BIT(cfg->uart_enable_bit); | 518 | cr1 |= BIT(cfg->uart_enable_bit); |
519 | if (stm32_port->fifoen) | ||
520 | cr1 |= USART_CR1_FIFOEN; | ||
499 | cr2 = 0; | 521 | cr2 = 0; |
500 | cr3 = 0; | 522 | cr3 = 0; |
501 | 523 | ||
@@ -518,7 +540,7 @@ static void stm32_set_termios(struct uart_port *port, struct ktermios *termios, | |||
518 | port->status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS); | 540 | port->status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS); |
519 | if (cflag & CRTSCTS) { | 541 | if (cflag & CRTSCTS) { |
520 | port->status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS; | 542 | port->status |= UPSTAT_AUTOCTS | UPSTAT_AUTORTS; |
521 | cr3 |= USART_CR3_CTSE; | 543 | cr3 |= USART_CR3_CTSE | USART_CR3_RTSE; |
522 | } | 544 | } |
523 | 545 | ||
524 | usartdiv = DIV_ROUND_CLOSEST(port->uartclk, baud); | 546 | usartdiv = DIV_ROUND_CLOSEST(port->uartclk, baud); |
@@ -659,6 +681,8 @@ static int stm32_init_port(struct stm32_port *stm32port, | |||
659 | port->ops = &stm32_uart_ops; | 681 | port->ops = &stm32_uart_ops; |
660 | port->dev = &pdev->dev; | 682 | port->dev = &pdev->dev; |
661 | port->irq = platform_get_irq(pdev, 0); | 683 | port->irq = platform_get_irq(pdev, 0); |
684 | stm32port->wakeirq = platform_get_irq(pdev, 1); | ||
685 | stm32port->fifoen = stm32port->info->cfg.has_fifo; | ||
662 | 686 | ||
663 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 687 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
664 | port->membase = devm_ioremap_resource(&pdev->dev, res); | 688 | port->membase = devm_ioremap_resource(&pdev->dev, res); |
@@ -678,8 +702,10 @@ static int stm32_init_port(struct stm32_port *stm32port, | |||
678 | return ret; | 702 | return ret; |
679 | 703 | ||
680 | stm32port->port.uartclk = clk_get_rate(stm32port->clk); | 704 | stm32port->port.uartclk = clk_get_rate(stm32port->clk); |
681 | if (!stm32port->port.uartclk) | 705 | if (!stm32port->port.uartclk) { |
706 | clk_disable_unprepare(stm32port->clk); | ||
682 | ret = -EINVAL; | 707 | ret = -EINVAL; |
708 | } | ||
683 | 709 | ||
684 | return ret; | 710 | return ret; |
685 | } | 711 | } |
@@ -693,8 +719,10 @@ static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev) | |||
693 | return NULL; | 719 | return NULL; |
694 | 720 | ||
695 | id = of_alias_get_id(np, "serial"); | 721 | id = of_alias_get_id(np, "serial"); |
696 | if (id < 0) | 722 | if (id < 0) { |
697 | id = 0; | 723 | dev_err(&pdev->dev, "failed to get alias id, errno %d\n", id); |
724 | return NULL; | ||
725 | } | ||
698 | 726 | ||
699 | if (WARN_ON(id >= STM32_MAX_PORTS)) | 727 | if (WARN_ON(id >= STM32_MAX_PORTS)) |
700 | return NULL; | 728 | return NULL; |
@@ -702,6 +730,7 @@ static struct stm32_port *stm32_of_get_stm32_port(struct platform_device *pdev) | |||
702 | stm32_ports[id].hw_flow_control = of_property_read_bool(np, | 730 | stm32_ports[id].hw_flow_control = of_property_read_bool(np, |
703 | "st,hw-flow-ctrl"); | 731 | "st,hw-flow-ctrl"); |
704 | stm32_ports[id].port.line = id; | 732 | stm32_ports[id].port.line = id; |
733 | stm32_ports[id].last_res = RX_BUF_L; | ||
705 | return &stm32_ports[id]; | 734 | return &stm32_ports[id]; |
706 | } | 735 | } |
707 | 736 | ||
@@ -711,6 +740,8 @@ static const struct of_device_id stm32_match[] = { | |||
711 | { .compatible = "st,stm32-uart", .data = &stm32f4_info}, | 740 | { .compatible = "st,stm32-uart", .data = &stm32f4_info}, |
712 | { .compatible = "st,stm32f7-usart", .data = &stm32f7_info}, | 741 | { .compatible = "st,stm32f7-usart", .data = &stm32f7_info}, |
713 | { .compatible = "st,stm32f7-uart", .data = &stm32f7_info}, | 742 | { .compatible = "st,stm32f7-uart", .data = &stm32f7_info}, |
743 | { .compatible = "st,stm32h7-usart", .data = &stm32h7_info}, | ||
744 | { .compatible = "st,stm32h7-uart", .data = &stm32h7_info}, | ||
714 | {}, | 745 | {}, |
715 | }; | 746 | }; |
716 | 747 | ||
@@ -860,9 +891,15 @@ static int stm32_serial_probe(struct platform_device *pdev) | |||
860 | if (ret) | 891 | if (ret) |
861 | return ret; | 892 | return ret; |
862 | 893 | ||
894 | if (stm32port->info->cfg.has_wakeup && stm32port->wakeirq >= 0) { | ||
895 | ret = device_init_wakeup(&pdev->dev, true); | ||
896 | if (ret) | ||
897 | goto err_uninit; | ||
898 | } | ||
899 | |||
863 | ret = uart_add_one_port(&stm32_usart_driver, &stm32port->port); | 900 | ret = uart_add_one_port(&stm32_usart_driver, &stm32port->port); |
864 | if (ret) | 901 | if (ret) |
865 | return ret; | 902 | goto err_nowup; |
866 | 903 | ||
867 | ret = stm32_of_dma_rx_probe(stm32port, pdev); | 904 | ret = stm32_of_dma_rx_probe(stm32port, pdev); |
868 | if (ret) | 905 | if (ret) |
@@ -875,6 +912,15 @@ static int stm32_serial_probe(struct platform_device *pdev) | |||
875 | platform_set_drvdata(pdev, &stm32port->port); | 912 | platform_set_drvdata(pdev, &stm32port->port); |
876 | 913 | ||
877 | return 0; | 914 | return 0; |
915 | |||
916 | err_nowup: | ||
917 | if (stm32port->info->cfg.has_wakeup && stm32port->wakeirq >= 0) | ||
918 | device_init_wakeup(&pdev->dev, false); | ||
919 | |||
920 | err_uninit: | ||
921 | clk_disable_unprepare(stm32port->clk); | ||
922 | |||
923 | return ret; | ||
878 | } | 924 | } |
879 | 925 | ||
880 | static int stm32_serial_remove(struct platform_device *pdev) | 926 | static int stm32_serial_remove(struct platform_device *pdev) |
@@ -882,6 +928,7 @@ static int stm32_serial_remove(struct platform_device *pdev) | |||
882 | struct uart_port *port = platform_get_drvdata(pdev); | 928 | struct uart_port *port = platform_get_drvdata(pdev); |
883 | struct stm32_port *stm32_port = to_stm32_port(port); | 929 | struct stm32_port *stm32_port = to_stm32_port(port); |
884 | struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; | 930 | struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; |
931 | struct stm32_usart_config *cfg = &stm32_port->info->cfg; | ||
885 | 932 | ||
886 | stm32_clr_bits(port, ofs->cr3, USART_CR3_DMAR); | 933 | stm32_clr_bits(port, ofs->cr3, USART_CR3_DMAR); |
887 | 934 | ||
@@ -903,6 +950,9 @@ static int stm32_serial_remove(struct platform_device *pdev) | |||
903 | TX_BUF_L, stm32_port->tx_buf, | 950 | TX_BUF_L, stm32_port->tx_buf, |
904 | stm32_port->tx_dma_buf); | 951 | stm32_port->tx_dma_buf); |
905 | 952 | ||
953 | if (cfg->has_wakeup && stm32_port->wakeirq >= 0) | ||
954 | device_init_wakeup(&pdev->dev, false); | ||
955 | |||
906 | clk_disable_unprepare(stm32_port->clk); | 956 | clk_disable_unprepare(stm32_port->clk); |
907 | 957 | ||
908 | return uart_remove_one_port(&stm32_usart_driver, port); | 958 | return uart_remove_one_port(&stm32_usart_driver, port); |
@@ -1008,11 +1058,66 @@ static struct uart_driver stm32_usart_driver = { | |||
1008 | .cons = STM32_SERIAL_CONSOLE, | 1058 | .cons = STM32_SERIAL_CONSOLE, |
1009 | }; | 1059 | }; |
1010 | 1060 | ||
1061 | #ifdef CONFIG_PM_SLEEP | ||
1062 | static void stm32_serial_enable_wakeup(struct uart_port *port, bool enable) | ||
1063 | { | ||
1064 | struct stm32_port *stm32_port = to_stm32_port(port); | ||
1065 | struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; | ||
1066 | struct stm32_usart_config *cfg = &stm32_port->info->cfg; | ||
1067 | u32 val; | ||
1068 | |||
1069 | if (!cfg->has_wakeup || stm32_port->wakeirq < 0) | ||
1070 | return; | ||
1071 | |||
1072 | if (enable) { | ||
1073 | stm32_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); | ||
1074 | stm32_set_bits(port, ofs->cr1, USART_CR1_UESM); | ||
1075 | val = readl_relaxed(port->membase + ofs->cr3); | ||
1076 | val &= ~USART_CR3_WUS_MASK; | ||
1077 | /* Enable Wake up interrupt from low power on start bit */ | ||
1078 | val |= USART_CR3_WUS_START_BIT | USART_CR3_WUFIE; | ||
1079 | writel_relaxed(val, port->membase + ofs->cr3); | ||
1080 | stm32_set_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); | ||
1081 | } else { | ||
1082 | stm32_clr_bits(port, ofs->cr1, USART_CR1_UESM); | ||
1083 | } | ||
1084 | } | ||
1085 | |||
1086 | static int stm32_serial_suspend(struct device *dev) | ||
1087 | { | ||
1088 | struct uart_port *port = dev_get_drvdata(dev); | ||
1089 | |||
1090 | uart_suspend_port(&stm32_usart_driver, port); | ||
1091 | |||
1092 | if (device_may_wakeup(dev)) | ||
1093 | stm32_serial_enable_wakeup(port, true); | ||
1094 | else | ||
1095 | stm32_serial_enable_wakeup(port, false); | ||
1096 | |||
1097 | return 0; | ||
1098 | } | ||
1099 | |||
1100 | static int stm32_serial_resume(struct device *dev) | ||
1101 | { | ||
1102 | struct uart_port *port = dev_get_drvdata(dev); | ||
1103 | |||
1104 | if (device_may_wakeup(dev)) | ||
1105 | stm32_serial_enable_wakeup(port, false); | ||
1106 | |||
1107 | return uart_resume_port(&stm32_usart_driver, port); | ||
1108 | } | ||
1109 | #endif /* CONFIG_PM_SLEEP */ | ||
1110 | |||
1111 | static const struct dev_pm_ops stm32_serial_pm_ops = { | ||
1112 | SET_SYSTEM_SLEEP_PM_OPS(stm32_serial_suspend, stm32_serial_resume) | ||
1113 | }; | ||
1114 | |||
1011 | static struct platform_driver stm32_serial_driver = { | 1115 | static struct platform_driver stm32_serial_driver = { |
1012 | .probe = stm32_serial_probe, | 1116 | .probe = stm32_serial_probe, |
1013 | .remove = stm32_serial_remove, | 1117 | .remove = stm32_serial_remove, |
1014 | .driver = { | 1118 | .driver = { |
1015 | .name = DRIVER_NAME, | 1119 | .name = DRIVER_NAME, |
1120 | .pm = &stm32_serial_pm_ops, | ||
1016 | .of_match_table = of_match_ptr(stm32_match), | 1121 | .of_match_table = of_match_ptr(stm32_match), |
1017 | }, | 1122 | }, |
1018 | }; | 1123 | }; |
diff --git a/drivers/tty/serial/stm32-usart.h b/drivers/tty/serial/stm32-usart.h index cd97ceb76e4f..ffc0c5285e51 100644 --- a/drivers/tty/serial/stm32-usart.h +++ b/drivers/tty/serial/stm32-usart.h | |||
@@ -1,5 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) Maxime Coquelin 2015 | 2 | * Copyright (C) Maxime Coquelin 2015 |
3 | * Copyright (C) STMicroelectronics SA 2017 | ||
3 | * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com> | 4 | * Authors: Maxime Coquelin <mcoquelin.stm32@gmail.com> |
4 | * Gerald Baeza <gerald_baeza@yahoo.fr> | 5 | * Gerald Baeza <gerald_baeza@yahoo.fr> |
5 | * License terms: GNU General Public License (GPL), version 2 | 6 | * License terms: GNU General Public License (GPL), version 2 |
@@ -24,6 +25,8 @@ struct stm32_usart_offsets { | |||
24 | struct stm32_usart_config { | 25 | struct stm32_usart_config { |
25 | u8 uart_enable_bit; /* USART_CR1_UE */ | 26 | u8 uart_enable_bit; /* USART_CR1_UE */ |
26 | bool has_7bits_data; | 27 | bool has_7bits_data; |
28 | bool has_wakeup; | ||
29 | bool has_fifo; | ||
27 | }; | 30 | }; |
28 | 31 | ||
29 | struct stm32_usart_info { | 32 | struct stm32_usart_info { |
@@ -74,6 +77,28 @@ struct stm32_usart_info stm32f7_info = { | |||
74 | } | 77 | } |
75 | }; | 78 | }; |
76 | 79 | ||
80 | struct stm32_usart_info stm32h7_info = { | ||
81 | .ofs = { | ||
82 | .cr1 = 0x00, | ||
83 | .cr2 = 0x04, | ||
84 | .cr3 = 0x08, | ||
85 | .brr = 0x0c, | ||
86 | .gtpr = 0x10, | ||
87 | .rtor = 0x14, | ||
88 | .rqr = 0x18, | ||
89 | .isr = 0x1c, | ||
90 | .icr = 0x20, | ||
91 | .rdr = 0x24, | ||
92 | .tdr = 0x28, | ||
93 | }, | ||
94 | .cfg = { | ||
95 | .uart_enable_bit = 0, | ||
96 | .has_7bits_data = true, | ||
97 | .has_wakeup = true, | ||
98 | .has_fifo = true, | ||
99 | } | ||
100 | }; | ||
101 | |||
77 | /* USART_SR (F4) / USART_ISR (F7) */ | 102 | /* USART_SR (F4) / USART_ISR (F7) */ |
78 | #define USART_SR_PE BIT(0) | 103 | #define USART_SR_PE BIT(0) |
79 | #define USART_SR_FE BIT(1) | 104 | #define USART_SR_FE BIT(1) |
@@ -93,6 +118,7 @@ struct stm32_usart_info stm32f7_info = { | |||
93 | #define USART_SR_BUSY BIT(16) /* F7 */ | 118 | #define USART_SR_BUSY BIT(16) /* F7 */ |
94 | #define USART_SR_CMF BIT(17) /* F7 */ | 119 | #define USART_SR_CMF BIT(17) /* F7 */ |
95 | #define USART_SR_SBKF BIT(18) /* F7 */ | 120 | #define USART_SR_SBKF BIT(18) /* F7 */ |
121 | #define USART_SR_WUF BIT(20) /* H7 */ | ||
96 | #define USART_SR_TEACK BIT(21) /* F7 */ | 122 | #define USART_SR_TEACK BIT(21) /* F7 */ |
97 | #define USART_SR_ERR_MASK (USART_SR_LBD | USART_SR_ORE | \ | 123 | #define USART_SR_ERR_MASK (USART_SR_LBD | USART_SR_ORE | \ |
98 | USART_SR_FE | USART_SR_PE) | 124 | USART_SR_FE | USART_SR_PE) |
@@ -113,6 +139,7 @@ struct stm32_usart_info stm32f7_info = { | |||
113 | /* USART_CR1 */ | 139 | /* USART_CR1 */ |
114 | #define USART_CR1_SBK BIT(0) | 140 | #define USART_CR1_SBK BIT(0) |
115 | #define USART_CR1_RWU BIT(1) /* F4 */ | 141 | #define USART_CR1_RWU BIT(1) /* F4 */ |
142 | #define USART_CR1_UESM BIT(1) /* H7 */ | ||
116 | #define USART_CR1_RE BIT(2) | 143 | #define USART_CR1_RE BIT(2) |
117 | #define USART_CR1_TE BIT(3) | 144 | #define USART_CR1_TE BIT(3) |
118 | #define USART_CR1_IDLEIE BIT(4) | 145 | #define USART_CR1_IDLEIE BIT(4) |
@@ -134,6 +161,7 @@ struct stm32_usart_info stm32f7_info = { | |||
134 | #define USART_CR1_EOBIE BIT(27) /* F7 */ | 161 | #define USART_CR1_EOBIE BIT(27) /* F7 */ |
135 | #define USART_CR1_M1 BIT(28) /* F7 */ | 162 | #define USART_CR1_M1 BIT(28) /* F7 */ |
136 | #define USART_CR1_IE_MASK (GENMASK(8, 4) | BIT(14) | BIT(26) | BIT(27)) | 163 | #define USART_CR1_IE_MASK (GENMASK(8, 4) | BIT(14) | BIT(26) | BIT(27)) |
164 | #define USART_CR1_FIFOEN BIT(29) /* H7 */ | ||
137 | 165 | ||
138 | /* USART_CR2 */ | 166 | /* USART_CR2 */ |
139 | #define USART_CR2_ADD_MASK GENMASK(3, 0) /* F4 */ | 167 | #define USART_CR2_ADD_MASK GENMASK(3, 0) /* F4 */ |
@@ -175,6 +203,9 @@ struct stm32_usart_info stm32f7_info = { | |||
175 | #define USART_CR3_DEM BIT(14) /* F7 */ | 203 | #define USART_CR3_DEM BIT(14) /* F7 */ |
176 | #define USART_CR3_DEP BIT(15) /* F7 */ | 204 | #define USART_CR3_DEP BIT(15) /* F7 */ |
177 | #define USART_CR3_SCARCNT_MASK GENMASK(19, 17) /* F7 */ | 205 | #define USART_CR3_SCARCNT_MASK GENMASK(19, 17) /* F7 */ |
206 | #define USART_CR3_WUS_MASK GENMASK(21, 20) /* H7 */ | ||
207 | #define USART_CR3_WUS_START_BIT BIT(21) /* H7 */ | ||
208 | #define USART_CR3_WUFIE BIT(22) /* H7 */ | ||
178 | 209 | ||
179 | /* USART_GTPR */ | 210 | /* USART_GTPR */ |
180 | #define USART_GTPR_PSC_MASK GENMASK(7, 0) | 211 | #define USART_GTPR_PSC_MASK GENMASK(7, 0) |
@@ -203,9 +234,10 @@ struct stm32_usart_info stm32f7_info = { | |||
203 | #define USART_ICR_RTOCF BIT(11) /* F7 */ | 234 | #define USART_ICR_RTOCF BIT(11) /* F7 */ |
204 | #define USART_ICR_EOBCF BIT(12) /* F7 */ | 235 | #define USART_ICR_EOBCF BIT(12) /* F7 */ |
205 | #define USART_ICR_CMCF BIT(17) /* F7 */ | 236 | #define USART_ICR_CMCF BIT(17) /* F7 */ |
237 | #define USART_ICR_WUCF BIT(20) /* H7 */ | ||
206 | 238 | ||
207 | #define STM32_SERIAL_NAME "ttyS" | 239 | #define STM32_SERIAL_NAME "ttyS" |
208 | #define STM32_MAX_PORTS 6 | 240 | #define STM32_MAX_PORTS 8 |
209 | 241 | ||
210 | #define RX_BUF_L 200 /* dma rx buffer length */ | 242 | #define RX_BUF_L 200 /* dma rx buffer length */ |
211 | #define RX_BUF_P RX_BUF_L /* dma rx buffer period */ | 243 | #define RX_BUF_P RX_BUF_L /* dma rx buffer period */ |
@@ -221,8 +253,11 @@ struct stm32_port { | |||
221 | struct dma_chan *tx_ch; /* dma tx channel */ | 253 | struct dma_chan *tx_ch; /* dma tx channel */ |
222 | dma_addr_t tx_dma_buf; /* dma tx buffer bus address */ | 254 | dma_addr_t tx_dma_buf; /* dma tx buffer bus address */ |
223 | unsigned char *tx_buf; /* dma tx buffer cpu address */ | 255 | unsigned char *tx_buf; /* dma tx buffer cpu address */ |
256 | int last_res; | ||
224 | bool tx_dma_busy; /* dma tx busy */ | 257 | bool tx_dma_busy; /* dma tx busy */ |
225 | bool hw_flow_control; | 258 | bool hw_flow_control; |
259 | bool fifoen; | ||
260 | int wakeirq; | ||
226 | }; | 261 | }; |
227 | 262 | ||
228 | static struct stm32_port stm32_ports[STM32_MAX_PORTS]; | 263 | static struct stm32_port stm32_ports[STM32_MAX_PORTS]; |
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index b5e3195b3697..653a076d89d3 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c | |||
@@ -819,7 +819,7 @@ static int sunsab_verify_port(struct uart_port *port, struct serial_struct *ser) | |||
819 | return -EINVAL; | 819 | return -EINVAL; |
820 | } | 820 | } |
821 | 821 | ||
822 | static struct uart_ops sunsab_pops = { | 822 | static const struct uart_ops sunsab_pops = { |
823 | .tx_empty = sunsab_tx_empty, | 823 | .tx_empty = sunsab_tx_empty, |
824 | .set_mctrl = sunsab_set_mctrl, | 824 | .set_mctrl = sunsab_set_mctrl, |
825 | .get_mctrl = sunsab_get_mctrl, | 825 | .get_mctrl = sunsab_get_mctrl, |
diff --git a/drivers/tty/serial/sunsu.c b/drivers/tty/serial/sunsu.c index 72df2e1b88af..95d34d7565c9 100644 --- a/drivers/tty/serial/sunsu.c +++ b/drivers/tty/serial/sunsu.c | |||
@@ -958,7 +958,7 @@ sunsu_type(struct uart_port *port) | |||
958 | return uart_config[type].name; | 958 | return uart_config[type].name; |
959 | } | 959 | } |
960 | 960 | ||
961 | static struct uart_ops sunsu_pops = { | 961 | static const struct uart_ops sunsu_pops = { |
962 | .tx_empty = sunsu_tx_empty, | 962 | .tx_empty = sunsu_tx_empty, |
963 | .set_mctrl = sunsu_set_mctrl, | 963 | .set_mctrl = sunsu_set_mctrl, |
964 | .get_mctrl = sunsu_get_mctrl, | 964 | .get_mctrl = sunsu_get_mctrl, |
@@ -1212,8 +1212,8 @@ static int sunsu_kbd_ms_init(struct uart_sunsu_port *up) | |||
1212 | if (up->port.type == PORT_UNKNOWN) | 1212 | if (up->port.type == PORT_UNKNOWN) |
1213 | return -ENODEV; | 1213 | return -ENODEV; |
1214 | 1214 | ||
1215 | printk("%s: %s port at %llx, irq %u\n", | 1215 | printk("%pOF: %s port at %llx, irq %u\n", |
1216 | up->port.dev->of_node->full_name, | 1216 | up->port.dev->of_node, |
1217 | (up->su_type == SU_PORT_KBD) ? "Keyboard" : "Mouse", | 1217 | (up->su_type == SU_PORT_KBD) ? "Keyboard" : "Mouse", |
1218 | (unsigned long long) up->port.mapbase, | 1218 | (unsigned long long) up->port.mapbase, |
1219 | up->port.irq); | 1219 | up->port.irq); |
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c index 481eb2989a1e..55b702775786 100644 --- a/drivers/tty/serial/ucc_uart.c +++ b/drivers/tty/serial/ucc_uart.c | |||
@@ -1085,7 +1085,7 @@ static int qe_uart_verify_port(struct uart_port *port, | |||
1085 | * | 1085 | * |
1086 | * Details on these functions can be found in Documentation/serial/driver | 1086 | * Details on these functions can be found in Documentation/serial/driver |
1087 | */ | 1087 | */ |
1088 | static struct uart_ops qe_uart_pops = { | 1088 | static const struct uart_ops qe_uart_pops = { |
1089 | .tx_empty = qe_uart_tx_empty, | 1089 | .tx_empty = qe_uart_tx_empty, |
1090 | .set_mctrl = qe_uart_set_mctrl, | 1090 | .set_mctrl = qe_uart_set_mctrl, |
1091 | .get_mctrl = qe_uart_get_mctrl, | 1091 | .get_mctrl = qe_uart_get_mctrl, |
diff --git a/drivers/tty/serial/xilinx_uartps.c b/drivers/tty/serial/xilinx_uartps.c index fde55dcdea5a..31a630ae0870 100644 --- a/drivers/tty/serial/xilinx_uartps.c +++ b/drivers/tty/serial/xilinx_uartps.c | |||
@@ -1163,7 +1163,7 @@ static void cdns_uart_console_putchar(struct uart_port *port, int ch) | |||
1163 | writel(ch, port->membase + CDNS_UART_FIFO); | 1163 | writel(ch, port->membase + CDNS_UART_FIFO); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | static void __init cdns_early_write(struct console *con, const char *s, | 1166 | static void cdns_early_write(struct console *con, const char *s, |
1167 | unsigned n) | 1167 | unsigned n) |
1168 | { | 1168 | { |
1169 | struct earlycon_device *dev = con->data; | 1169 | struct earlycon_device *dev = con->data; |
diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c index 3fafc5a1b2e0..3be981101297 100644 --- a/drivers/tty/synclink.c +++ b/drivers/tty/synclink.c | |||
@@ -884,7 +884,7 @@ static int synclink_init_one (struct pci_dev *dev, | |||
884 | const struct pci_device_id *ent); | 884 | const struct pci_device_id *ent); |
885 | static void synclink_remove_one (struct pci_dev *dev); | 885 | static void synclink_remove_one (struct pci_dev *dev); |
886 | 886 | ||
887 | static struct pci_device_id synclink_pci_tbl[] = { | 887 | static const struct pci_device_id synclink_pci_tbl[] = { |
888 | { PCI_VENDOR_ID_MICROGATE, PCI_DEVICE_ID_MICROGATE_USC, PCI_ANY_ID, PCI_ANY_ID, }, | 888 | { PCI_VENDOR_ID_MICROGATE, PCI_DEVICE_ID_MICROGATE_USC, PCI_ANY_ID, PCI_ANY_ID, }, |
889 | { PCI_VENDOR_ID_MICROGATE, 0x0210, PCI_ANY_ID, PCI_ANY_ID, }, | 889 | { PCI_VENDOR_ID_MICROGATE, 0x0210, PCI_ANY_ID, PCI_ANY_ID, }, |
890 | { 0, }, /* terminate list */ | 890 | { 0, }, /* terminate list */ |
diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c index 529c6e3cd537..636b8ae29b46 100644 --- a/drivers/tty/synclink_gt.c +++ b/drivers/tty/synclink_gt.c | |||
@@ -95,7 +95,7 @@ MODULE_LICENSE("GPL"); | |||
95 | #define MGSL_MAGIC 0x5401 | 95 | #define MGSL_MAGIC 0x5401 |
96 | #define MAX_DEVICES 32 | 96 | #define MAX_DEVICES 32 |
97 | 97 | ||
98 | static struct pci_device_id pci_table[] = { | 98 | static const struct pci_device_id pci_table[] = { |
99 | {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, | 99 | {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, |
100 | {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT2_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, | 100 | {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT2_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, |
101 | {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT4_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, | 101 | {PCI_VENDOR_ID_MICROGATE, SYNCLINK_GT4_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, |
diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c index 9b4fb0251c1a..4fed9e7b281f 100644 --- a/drivers/tty/synclinkmp.c +++ b/drivers/tty/synclinkmp.c | |||
@@ -479,7 +479,7 @@ static char *driver_version = "$Revision: 4.38 $"; | |||
479 | static int synclinkmp_init_one(struct pci_dev *dev,const struct pci_device_id *ent); | 479 | static int synclinkmp_init_one(struct pci_dev *dev,const struct pci_device_id *ent); |
480 | static void synclinkmp_remove_one(struct pci_dev *dev); | 480 | static void synclinkmp_remove_one(struct pci_dev *dev); |
481 | 481 | ||
482 | static struct pci_device_id synclinkmp_pci_tbl[] = { | 482 | static const struct pci_device_id synclinkmp_pci_tbl[] = { |
483 | { PCI_VENDOR_ID_MICROGATE, PCI_DEVICE_ID_MICROGATE_SCA, PCI_ANY_ID, PCI_ANY_ID, }, | 483 | { PCI_VENDOR_ID_MICROGATE, PCI_DEVICE_ID_MICROGATE_SCA, PCI_ANY_ID, PCI_ANY_ID, }, |
484 | { 0, }, /* terminate list */ | 484 | { 0, }, /* terminate list */ |
485 | }; | 485 | }; |
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c index 4e7a4e9dcf4d..f8eba1c5412f 100644 --- a/drivers/tty/tty_buffer.c +++ b/drivers/tty/tty_buffer.c | |||
@@ -362,6 +362,32 @@ int tty_insert_flip_string_flags(struct tty_port *port, | |||
362 | EXPORT_SYMBOL(tty_insert_flip_string_flags); | 362 | EXPORT_SYMBOL(tty_insert_flip_string_flags); |
363 | 363 | ||
364 | /** | 364 | /** |
365 | * __tty_insert_flip_char - Add one character to the tty buffer | ||
366 | * @port: tty port | ||
367 | * @ch: character | ||
368 | * @flag: flag byte | ||
369 | * | ||
370 | * Queue a single byte to the tty buffering, with an optional flag. | ||
371 | * This is the slow path of tty_insert_flip_char. | ||
372 | */ | ||
373 | int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag) | ||
374 | { | ||
375 | struct tty_buffer *tb; | ||
376 | int flags = (flag == TTY_NORMAL) ? TTYB_NORMAL : 0; | ||
377 | |||
378 | if (!__tty_buffer_request_room(port, 1, flags)) | ||
379 | return 0; | ||
380 | |||
381 | tb = port->buf.tail; | ||
382 | if (~tb->flags & TTYB_NORMAL) | ||
383 | *flag_buf_ptr(tb, tb->used) = flag; | ||
384 | *char_buf_ptr(tb, tb->used++) = ch; | ||
385 | |||
386 | return 1; | ||
387 | } | ||
388 | EXPORT_SYMBOL(__tty_insert_flip_char); | ||
389 | |||
390 | /** | ||
365 | * tty_schedule_flip - push characters to ldisc | 391 | * tty_schedule_flip - push characters to ldisc |
366 | * @port: tty port to push from | 392 | * @port: tty port to push from |
367 | * | 393 | * |
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index 10c4038c0e8d..da912517d295 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c | |||
@@ -462,6 +462,14 @@ static int hung_up_tty_fasync(int fd, struct file *file, int on) | |||
462 | return -ENOTTY; | 462 | return -ENOTTY; |
463 | } | 463 | } |
464 | 464 | ||
465 | static void tty_show_fdinfo(struct seq_file *m, struct file *file) | ||
466 | { | ||
467 | struct tty_struct *tty = file_tty(file); | ||
468 | |||
469 | if (tty && tty->ops && tty->ops->show_fdinfo) | ||
470 | tty->ops->show_fdinfo(tty, m); | ||
471 | } | ||
472 | |||
465 | static const struct file_operations tty_fops = { | 473 | static const struct file_operations tty_fops = { |
466 | .llseek = no_llseek, | 474 | .llseek = no_llseek, |
467 | .read = tty_read, | 475 | .read = tty_read, |
@@ -472,6 +480,7 @@ static const struct file_operations tty_fops = { | |||
472 | .open = tty_open, | 480 | .open = tty_open, |
473 | .release = tty_release, | 481 | .release = tty_release, |
474 | .fasync = tty_fasync, | 482 | .fasync = tty_fasync, |
483 | .show_fdinfo = tty_show_fdinfo, | ||
475 | }; | 484 | }; |
476 | 485 | ||
477 | static const struct file_operations console_fops = { | 486 | static const struct file_operations console_fops = { |
diff --git a/include/linux/mcb.h b/include/linux/mcb.h index 4097ac9ea13a..b1a0ad9d23b3 100644 --- a/include/linux/mcb.h +++ b/include/linux/mcb.h | |||
@@ -136,5 +136,7 @@ extern struct resource *mcb_request_mem(struct mcb_device *dev, | |||
136 | const char *name); | 136 | const char *name); |
137 | extern void mcb_release_mem(struct resource *mem); | 137 | extern void mcb_release_mem(struct resource *mem); |
138 | extern int mcb_get_irq(struct mcb_device *dev); | 138 | extern int mcb_get_irq(struct mcb_device *dev); |
139 | extern struct resource *mcb_get_resource(struct mcb_device *dev, | ||
140 | unsigned int type); | ||
139 | 141 | ||
140 | #endif /* _LINUX_MCB_H */ | 142 | #endif /* _LINUX_MCB_H */ |
diff --git a/include/linux/serial_8250.h b/include/linux/serial_8250.h index 61fbb440449c..a27ef5f56431 100644 --- a/include/linux/serial_8250.h +++ b/include/linux/serial_8250.h | |||
@@ -80,9 +80,10 @@ struct uart_8250_ops { | |||
80 | }; | 80 | }; |
81 | 81 | ||
82 | struct uart_8250_em485 { | 82 | struct uart_8250_em485 { |
83 | struct timer_list start_tx_timer; /* "rs485 start tx" timer */ | 83 | struct hrtimer start_tx_timer; /* "rs485 start tx" timer */ |
84 | struct timer_list stop_tx_timer; /* "rs485 stop tx" timer */ | 84 | struct hrtimer stop_tx_timer; /* "rs485 stop tx" timer */ |
85 | struct timer_list *active_timer; /* pointer to active timer */ | 85 | struct hrtimer *active_timer; /* pointer to active timer */ |
86 | struct uart_8250_port *port; /* for hrtimer callbacks */ | ||
86 | }; | 87 | }; |
87 | 88 | ||
88 | /* | 89 | /* |
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h index 1775500294bb..5553e04e59c9 100644 --- a/include/linux/serial_core.h +++ b/include/linux/serial_core.h | |||
@@ -20,7 +20,7 @@ | |||
20 | #ifndef LINUX_SERIAL_CORE_H | 20 | #ifndef LINUX_SERIAL_CORE_H |
21 | #define LINUX_SERIAL_CORE_H | 21 | #define LINUX_SERIAL_CORE_H |
22 | 22 | ||
23 | 23 | #include <linux/bitops.h> | |
24 | #include <linux/compiler.h> | 24 | #include <linux/compiler.h> |
25 | #include <linux/interrupt.h> | 25 | #include <linux/interrupt.h> |
26 | #include <linux/circ_buf.h> | 26 | #include <linux/circ_buf.h> |
@@ -144,7 +144,7 @@ struct uart_port { | |||
144 | unsigned char x_char; /* xon/xoff char */ | 144 | unsigned char x_char; /* xon/xoff char */ |
145 | unsigned char regshift; /* reg offset shift */ | 145 | unsigned char regshift; /* reg offset shift */ |
146 | unsigned char iotype; /* io access style */ | 146 | unsigned char iotype; /* io access style */ |
147 | unsigned char unused1; | 147 | unsigned char quirks; /* internal quirks */ |
148 | 148 | ||
149 | #define UPIO_PORT (SERIAL_IO_PORT) /* 8b I/O port access */ | 149 | #define UPIO_PORT (SERIAL_IO_PORT) /* 8b I/O port access */ |
150 | #define UPIO_HUB6 (SERIAL_IO_HUB6) /* Hub6 ISA card */ | 150 | #define UPIO_HUB6 (SERIAL_IO_HUB6) /* Hub6 ISA card */ |
@@ -155,6 +155,9 @@ struct uart_port { | |||
155 | #define UPIO_MEM32BE (SERIAL_IO_MEM32BE) /* 32b big endian */ | 155 | #define UPIO_MEM32BE (SERIAL_IO_MEM32BE) /* 32b big endian */ |
156 | #define UPIO_MEM16 (SERIAL_IO_MEM16) /* 16b little endian */ | 156 | #define UPIO_MEM16 (SERIAL_IO_MEM16) /* 16b little endian */ |
157 | 157 | ||
158 | /* quirks must be updated while holding port mutex */ | ||
159 | #define UPQ_NO_TXEN_TEST BIT(0) | ||
160 | |||
158 | unsigned int read_status_mask; /* driver specific */ | 161 | unsigned int read_status_mask; /* driver specific */ |
159 | unsigned int ignore_status_mask; /* driver specific */ | 162 | unsigned int ignore_status_mask; /* driver specific */ |
160 | struct uart_state *state; /* pointer to parent state */ | 163 | struct uart_state *state; /* pointer to parent state */ |
@@ -175,7 +178,6 @@ struct uart_port { | |||
175 | * [for bit definitions in the UPF_CHANGE_MASK] | 178 | * [for bit definitions in the UPF_CHANGE_MASK] |
176 | * | 179 | * |
177 | * Bits [0..UPF_LAST_USER] are userspace defined/visible/changeable | 180 | * Bits [0..UPF_LAST_USER] are userspace defined/visible/changeable |
178 | * except bit 15 (UPF_NO_TXEN_TEST) which is masked off. | ||
179 | * The remaining bits are serial-core specific and not modifiable by | 181 | * The remaining bits are serial-core specific and not modifiable by |
180 | * userspace. | 182 | * userspace. |
181 | */ | 183 | */ |
@@ -192,7 +194,6 @@ struct uart_port { | |||
192 | #define UPF_SPD_SHI ((__force upf_t) ASYNC_SPD_SHI /* 12 */ ) | 194 | #define UPF_SPD_SHI ((__force upf_t) ASYNC_SPD_SHI /* 12 */ ) |
193 | #define UPF_LOW_LATENCY ((__force upf_t) ASYNC_LOW_LATENCY /* 13 */ ) | 195 | #define UPF_LOW_LATENCY ((__force upf_t) ASYNC_LOW_LATENCY /* 13 */ ) |
194 | #define UPF_BUGGY_UART ((__force upf_t) ASYNC_BUGGY_UART /* 14 */ ) | 196 | #define UPF_BUGGY_UART ((__force upf_t) ASYNC_BUGGY_UART /* 14 */ ) |
195 | #define UPF_NO_TXEN_TEST ((__force upf_t) (1 << 15)) | ||
196 | #define UPF_MAGIC_MULTIPLIER ((__force upf_t) ASYNC_MAGIC_MULTIPLIER /* 16 */ ) | 197 | #define UPF_MAGIC_MULTIPLIER ((__force upf_t) ASYNC_MAGIC_MULTIPLIER /* 16 */ ) |
197 | 198 | ||
198 | #define UPF_NO_THRE_TEST ((__force upf_t) (1 << 19)) | 199 | #define UPF_NO_THRE_TEST ((__force upf_t) (1 << 19)) |
@@ -246,7 +247,6 @@ struct uart_port { | |||
246 | struct device *dev; /* parent device */ | 247 | struct device *dev; /* parent device */ |
247 | unsigned char hub6; /* this should be in the 8250 driver */ | 248 | unsigned char hub6; /* this should be in the 8250 driver */ |
248 | unsigned char suspended; | 249 | unsigned char suspended; |
249 | unsigned char irq_wake; | ||
250 | unsigned char unused[2]; | 250 | unsigned char unused[2]; |
251 | const char *name; /* port name */ | 251 | const char *name; /* port name */ |
252 | struct attribute_group *attr_group; /* port specific attributes */ | 252 | struct attribute_group *attr_group; /* port specific attributes */ |
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h index 00b2213f6a35..fcdc0f5d9098 100644 --- a/include/linux/tty_driver.h +++ b/include/linux/tty_driver.h | |||
@@ -243,6 +243,7 @@ | |||
243 | #include <linux/list.h> | 243 | #include <linux/list.h> |
244 | #include <linux/cdev.h> | 244 | #include <linux/cdev.h> |
245 | #include <linux/termios.h> | 245 | #include <linux/termios.h> |
246 | #include <linux/seq_file.h> | ||
246 | 247 | ||
247 | struct tty_struct; | 248 | struct tty_struct; |
248 | struct tty_driver; | 249 | struct tty_driver; |
@@ -285,6 +286,7 @@ struct tty_operations { | |||
285 | int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); | 286 | int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); |
286 | int (*get_icount)(struct tty_struct *tty, | 287 | int (*get_icount)(struct tty_struct *tty, |
287 | struct serial_icounter_struct *icount); | 288 | struct serial_icounter_struct *icount); |
289 | void (*show_fdinfo)(struct tty_struct *tty, struct seq_file *m); | ||
288 | #ifdef CONFIG_CONSOLE_POLL | 290 | #ifdef CONFIG_CONSOLE_POLL |
289 | int (*poll_init)(struct tty_driver *driver, int line, char *options); | 291 | int (*poll_init)(struct tty_driver *driver, int line, char *options); |
290 | int (*poll_get_char)(struct tty_driver *driver, int line); | 292 | int (*poll_get_char)(struct tty_driver *driver, int line); |
diff --git a/include/linux/tty_flip.h b/include/linux/tty_flip.h index c28dd523f96e..d43837f2ce3a 100644 --- a/include/linux/tty_flip.h +++ b/include/linux/tty_flip.h | |||
@@ -12,6 +12,7 @@ extern int tty_prepare_flip_string(struct tty_port *port, | |||
12 | unsigned char **chars, size_t size); | 12 | unsigned char **chars, size_t size); |
13 | extern void tty_flip_buffer_push(struct tty_port *port); | 13 | extern void tty_flip_buffer_push(struct tty_port *port); |
14 | void tty_schedule_flip(struct tty_port *port); | 14 | void tty_schedule_flip(struct tty_port *port); |
15 | int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag); | ||
15 | 16 | ||
16 | static inline int tty_insert_flip_char(struct tty_port *port, | 17 | static inline int tty_insert_flip_char(struct tty_port *port, |
17 | unsigned char ch, char flag) | 18 | unsigned char ch, char flag) |
@@ -26,7 +27,7 @@ static inline int tty_insert_flip_char(struct tty_port *port, | |||
26 | *char_buf_ptr(tb, tb->used++) = ch; | 27 | *char_buf_ptr(tb, tb->used++) = ch; |
27 | return 1; | 28 | return 1; |
28 | } | 29 | } |
29 | return tty_insert_flip_string_flags(port, &ch, &flag, 1); | 30 | return __tty_insert_flip_char(port, ch, flag); |
30 | } | 31 | } |
31 | 32 | ||
32 | static inline int tty_insert_flip_string(struct tty_port *port, | 33 | static inline int tty_insert_flip_string(struct tty_port *port, |
diff --git a/include/uapi/linux/serial_core.h b/include/uapi/linux/serial_core.h index c34a2a3eeff5..50d71c436323 100644 --- a/include/uapi/linux/serial_core.h +++ b/include/uapi/linux/serial_core.h | |||
@@ -56,8 +56,6 @@ | |||
56 | #define PORT_ALTR_16550_F128 28 /* Altera 16550 UART with 128 FIFOs */ | 56 | #define PORT_ALTR_16550_F128 28 /* Altera 16550 UART with 128 FIFOs */ |
57 | #define PORT_RT2880 29 /* Ralink RT2880 internal UART */ | 57 | #define PORT_RT2880 29 /* Ralink RT2880 internal UART */ |
58 | #define PORT_16550A_FSL64 30 /* Freescale 16550 UART with 64 FIFOs */ | 58 | #define PORT_16550A_FSL64 30 /* Freescale 16550 UART with 64 FIFOs */ |
59 | #define PORT_DA830 31 /* TI DA8xx/66AK2x */ | ||
60 | #define PORT_MAX_8250 31 /* max port ID */ | ||
61 | 59 | ||
62 | /* | 60 | /* |
63 | * ARM specific type numbers. These are not currently guaranteed | 61 | * ARM specific type numbers. These are not currently guaranteed |
@@ -70,12 +68,17 @@ | |||
70 | #define PORT_CLPS711X 33 | 68 | #define PORT_CLPS711X 33 |
71 | #define PORT_SA1100 34 | 69 | #define PORT_SA1100 34 |
72 | #define PORT_UART00 35 | 70 | #define PORT_UART00 35 |
71 | #define PORT_OWL 36 | ||
73 | #define PORT_21285 37 | 72 | #define PORT_21285 37 |
74 | 73 | ||
75 | /* Sparc type numbers. */ | 74 | /* Sparc type numbers. */ |
76 | #define PORT_SUNZILOG 38 | 75 | #define PORT_SUNZILOG 38 |
77 | #define PORT_SUNSAB 39 | 76 | #define PORT_SUNSAB 39 |
78 | 77 | ||
78 | /* Intel EG20 */ | ||
79 | #define PORT_PCH_8LINE 44 | ||
80 | #define PORT_PCH_2LINE 45 | ||
81 | |||
79 | /* DEC */ | 82 | /* DEC */ |
80 | #define PORT_DZ 46 | 83 | #define PORT_DZ 46 |
81 | #define PORT_ZS 47 | 84 | #define PORT_ZS 47 |
@@ -205,8 +208,8 @@ | |||
205 | /* MAX310X */ | 208 | /* MAX310X */ |
206 | #define PORT_MAX310X 94 | 209 | #define PORT_MAX310X 94 |
207 | 210 | ||
208 | /* High Speed UART for Medfield */ | 211 | /* TI DA8xx/66AK2x */ |
209 | #define PORT_MFD 95 | 212 | #define PORT_DA830 95 |
210 | 213 | ||
211 | /* TI OMAP-UART */ | 214 | /* TI OMAP-UART */ |
212 | #define PORT_OMAP 96 | 215 | #define PORT_OMAP 96 |
@@ -271,4 +274,7 @@ | |||
271 | /* MPS2 UART */ | 274 | /* MPS2 UART */ |
272 | #define PORT_MPS2UART 116 | 275 | #define PORT_MPS2UART 116 |
273 | 276 | ||
277 | /* MediaTek BTIF */ | ||
278 | #define PORT_MTK_BTIF 117 | ||
279 | |||
274 | #endif /* _UAPILINUX_SERIAL_CORE_H */ | 280 | #endif /* _UAPILINUX_SERIAL_CORE_H */ |