diff options
-rw-r--r-- | Documentation/devicetree/bindings/serial/cirrus,clps711x-uart.txt | 7 | ||||
-rw-r--r-- | drivers/tty/serial/Kconfig | 1 | ||||
-rw-r--r-- | drivers/tty/serial/clps711x.c | 32 |
3 files changed, 16 insertions, 24 deletions
diff --git a/Documentation/devicetree/bindings/serial/cirrus,clps711x-uart.txt b/Documentation/devicetree/bindings/serial/cirrus,clps711x-uart.txt index 12f3cf834deb..caaeb2583579 100644 --- a/Documentation/devicetree/bindings/serial/cirrus,clps711x-uart.txt +++ b/Documentation/devicetree/bindings/serial/cirrus,clps711x-uart.txt | |||
@@ -8,7 +8,8 @@ Required properties: | |||
8 | - syscon: Phandle to SYSCON node, which contain UART control bits. | 8 | - syscon: Phandle to SYSCON node, which contain UART control bits. |
9 | 9 | ||
10 | Optional properties: | 10 | Optional properties: |
11 | - uart-use-ms: Indicate the UART has modem signal (DCD, DSR, CTS). | 11 | - {rts,cts,dtr,dsr,rng,dcd}-gpios: specify a GPIO for RTS/CTS/DTR/DSR/RI/DCD |
12 | line respectively. | ||
12 | 13 | ||
13 | Note: Each UART port should have an alias correctly numbered | 14 | Note: Each UART port should have an alias correctly numbered |
14 | in "aliases" node. | 15 | in "aliases" node. |
@@ -24,5 +25,7 @@ Example: | |||
24 | interrupts = <12 13>; | 25 | interrupts = <12 13>; |
25 | clocks = <&clks 11>; | 26 | clocks = <&clks 11>; |
26 | syscon = <&syscon1>; | 27 | syscon = <&syscon1>; |
27 | uart-use-ms; | 28 | cts-gpios = <&sysgpio 0 GPIO_ACTIVE_LOW>; |
29 | dsr-gpios = <&sysgpio 1 GPIO_ACTIVE_LOW>; | ||
30 | dcd-gpios = <&sysgpio 2 GPIO_ACTIVE_LOW>; | ||
28 | }; | 31 | }; |
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig index 26cec64dadd7..75cc59f5d253 100644 --- a/drivers/tty/serial/Kconfig +++ b/drivers/tty/serial/Kconfig | |||
@@ -204,6 +204,7 @@ config SERIAL_CLPS711X | |||
204 | tristate "CLPS711X serial port support" | 204 | tristate "CLPS711X serial port support" |
205 | depends on ARCH_CLPS711X || COMPILE_TEST | 205 | depends on ARCH_CLPS711X || COMPILE_TEST |
206 | select SERIAL_CORE | 206 | select SERIAL_CORE |
207 | select SERIAL_MCTRL_GPIO | ||
207 | help | 208 | help |
208 | This enables the driver for the on-chip UARTs of the Cirrus | 209 | This enables the driver for the on-chip UARTs of the Cirrus |
209 | Logic EP711x/EP721x/EP731x processors. | 210 | Logic EP711x/EP721x/EP731x processors. |
diff --git a/drivers/tty/serial/clps711x.c b/drivers/tty/serial/clps711x.c index f5b4c3d7e38f..acfe31773643 100644 --- a/drivers/tty/serial/clps711x.c +++ b/drivers/tty/serial/clps711x.c | |||
@@ -33,6 +33,8 @@ | |||
33 | #include <linux/mfd/syscon.h> | 33 | #include <linux/mfd/syscon.h> |
34 | #include <linux/mfd/syscon/clps711x.h> | 34 | #include <linux/mfd/syscon/clps711x.h> |
35 | 35 | ||
36 | #include "serial_mctrl_gpio.h" | ||
37 | |||
36 | #define UART_CLPS711X_DEVNAME "ttyCL" | 38 | #define UART_CLPS711X_DEVNAME "ttyCL" |
37 | #define UART_CLPS711X_NR 2 | 39 | #define UART_CLPS711X_NR 2 |
38 | #define UART_CLPS711X_MAJOR 204 | 40 | #define UART_CLPS711X_MAJOR 204 |
@@ -62,7 +64,7 @@ struct clps711x_port { | |||
62 | unsigned int tx_enabled; | 64 | unsigned int tx_enabled; |
63 | int rx_irq; | 65 | int rx_irq; |
64 | struct regmap *syscon; | 66 | struct regmap *syscon; |
65 | bool use_ms; | 67 | struct mctrl_gpios *gpios; |
66 | }; | 68 | }; |
67 | 69 | ||
68 | static struct uart_driver clps711x_uart = { | 70 | static struct uart_driver clps711x_uart = { |
@@ -198,28 +200,17 @@ static unsigned int uart_clps711x_tx_empty(struct uart_port *port) | |||
198 | 200 | ||
199 | static unsigned int uart_clps711x_get_mctrl(struct uart_port *port) | 201 | static unsigned int uart_clps711x_get_mctrl(struct uart_port *port) |
200 | { | 202 | { |
203 | unsigned int result = TIOCM_DSR | TIOCM_CTS | TIOCM_CAR; | ||
201 | struct clps711x_port *s = dev_get_drvdata(port->dev); | 204 | struct clps711x_port *s = dev_get_drvdata(port->dev); |
202 | unsigned int result = 0; | ||
203 | |||
204 | if (s->use_ms) { | ||
205 | u32 sysflg = 0; | ||
206 | |||
207 | regmap_read(s->syscon, SYSFLG_OFFSET, &sysflg); | ||
208 | if (sysflg & SYSFLG1_DCD) | ||
209 | result |= TIOCM_CAR; | ||
210 | if (sysflg & SYSFLG1_DSR) | ||
211 | result |= TIOCM_DSR; | ||
212 | if (sysflg & SYSFLG1_CTS) | ||
213 | result |= TIOCM_CTS; | ||
214 | } else | ||
215 | result = TIOCM_DSR | TIOCM_CTS | TIOCM_CAR; | ||
216 | 205 | ||
217 | return result; | 206 | return mctrl_gpio_get(s->gpios, &result); |
218 | } | 207 | } |
219 | 208 | ||
220 | static void uart_clps711x_set_mctrl(struct uart_port *port, unsigned int mctrl) | 209 | static void uart_clps711x_set_mctrl(struct uart_port *port, unsigned int mctrl) |
221 | { | 210 | { |
222 | /* Do nothing */ | 211 | struct clps711x_port *s = dev_get_drvdata(port->dev); |
212 | |||
213 | mctrl_gpio_set(s->gpios, mctrl); | ||
223 | } | 214 | } |
224 | 215 | ||
225 | static void uart_clps711x_break_ctl(struct uart_port *port, int break_state) | 216 | static void uart_clps711x_break_ctl(struct uart_port *port, int break_state) |
@@ -490,15 +481,10 @@ static int uart_clps711x_probe(struct platform_device *pdev) | |||
490 | s->syscon = syscon_regmap_lookup_by_pdevname(syscon_name); | 481 | s->syscon = syscon_regmap_lookup_by_pdevname(syscon_name); |
491 | if (IS_ERR(s->syscon)) | 482 | if (IS_ERR(s->syscon)) |
492 | return PTR_ERR(s->syscon); | 483 | return PTR_ERR(s->syscon); |
493 | |||
494 | s->use_ms = !index; | ||
495 | } else { | 484 | } else { |
496 | s->syscon = syscon_regmap_lookup_by_phandle(np, "syscon"); | 485 | s->syscon = syscon_regmap_lookup_by_phandle(np, "syscon"); |
497 | if (IS_ERR(s->syscon)) | 486 | if (IS_ERR(s->syscon)) |
498 | return PTR_ERR(s->syscon); | 487 | return PTR_ERR(s->syscon); |
499 | |||
500 | if (!index) | ||
501 | s->use_ms = of_property_read_bool(np, "uart-use-ms"); | ||
502 | } | 488 | } |
503 | 489 | ||
504 | s->port.line = index; | 490 | s->port.line = index; |
@@ -513,6 +499,8 @@ static int uart_clps711x_probe(struct platform_device *pdev) | |||
513 | 499 | ||
514 | platform_set_drvdata(pdev, s); | 500 | platform_set_drvdata(pdev, s); |
515 | 501 | ||
502 | s->gpios = mctrl_gpio_init(&pdev->dev, 0); | ||
503 | |||
516 | ret = uart_add_one_port(&clps711x_uart, &s->port); | 504 | ret = uart_add_one_port(&clps711x_uart, &s->port); |
517 | if (ret) | 505 | if (ret) |
518 | return ret; | 506 | return ret; |