aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/clps711x.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial/clps711x.c')
-rw-r--r--drivers/tty/serial/clps711x.c32
1 files changed, 10 insertions, 22 deletions
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
68static struct uart_driver clps711x_uart = { 70static struct uart_driver clps711x_uart = {
@@ -198,28 +200,17 @@ static unsigned int uart_clps711x_tx_empty(struct uart_port *port)
198 200
199static unsigned int uart_clps711x_get_mctrl(struct uart_port *port) 201static 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
220static void uart_clps711x_set_mctrl(struct uart_port *port, unsigned int mctrl) 209static 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
225static void uart_clps711x_break_ctl(struct uart_port *port, int break_state) 216static 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;