Skip to content

Commit 7b9c516

Browse files
Niklas Casselgregkh
authored andcommitted
serial: etraxfs-uart: use mctrl_gpio helpers for handling modem signals
In order to use the mctrl_gpio helpers, we change the DT bindings: ri-gpios renamed to rng-gpios. cd-gpios renamed to dcd-gpios. However, no in-tree dts/dtsi specifies these, so no worries. Signed-off-by: Niklas Cassel <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Tested-by: Guenter Roeck <[email protected]> Acked-by: Linus Walleij <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 9625734 commit 7b9c516

File tree

3 files changed

+16
-31
lines changed

3 files changed

+16
-31
lines changed

Documentation/devicetree/bindings/serial/axis,etraxfs-uart.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Required properties:
66
- interrupts: device interrupt
77

88
Optional properties:
9-
- {dtr,dsr,ri,cd}-gpios: specify a GPIO for DTR/DSR/RI/CD
9+
- {dtr,dsr,rng,dcd}-gpios: specify a GPIO for DTR/DSR/RI/DCD
1010
line respectively.
1111

1212
Example:
@@ -16,4 +16,8 @@ serial@b00260000 {
1616
reg = <0xb0026000 0x1000>;
1717
interrupts = <68>;
1818
status = "disabled";
19+
dtr-gpios = <&sysgpio 0 GPIO_ACTIVE_LOW>;
20+
dsr-gpios = <&sysgpio 1 GPIO_ACTIVE_LOW>;
21+
rng-gpios = <&sysgpio 2 GPIO_ACTIVE_LOW>;
22+
dcd-gpios = <&sysgpio 3 GPIO_ACTIVE_LOW>;
1923
};

drivers/tty/serial/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,6 +1067,7 @@ config SERIAL_ETRAXFS
10671067
bool "ETRAX FS serial port support"
10681068
depends on ETRAX_ARCH_V32 && OF
10691069
select SERIAL_CORE
1070+
select SERIAL_MCTRL_GPIO if GPIOLIB
10701071

10711072
config SERIAL_ETRAXFS_CONSOLE
10721073
bool "ETRAX FS serial console support"

drivers/tty/serial/etraxfs-uart.c

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
#include <linux/of_address.h>
1111
#include <hwregs/ser_defs.h>
1212

13+
#include "serial_mctrl_gpio.h"
14+
1315
#define DRV_NAME "etraxfs-uart"
1416
#define UART_NR CONFIG_ETRAX_SERIAL_PORTS
1517

@@ -28,10 +30,7 @@ struct uart_cris_port {
2830

2931
void __iomem *regi_ser;
3032

31-
struct gpio_desc *dtr_pin;
32-
struct gpio_desc *dsr_pin;
33-
struct gpio_desc *ri_pin;
34-
struct gpio_desc *cd_pin;
33+
struct mctrl_gpios *gpios;
3534

3635
int write_ongoing;
3736
};
@@ -389,37 +388,17 @@ static unsigned int etraxfs_uart_get_mctrl(struct uart_port *port)
389388
ret = 0;
390389
if (crisv32_serial_get_rts(up))
391390
ret |= TIOCM_RTS;
392-
/* DTR is active low */
393-
if (up->dtr_pin && !gpiod_get_raw_value(up->dtr_pin))
394-
ret |= TIOCM_DTR;
395-
/* CD is active low */
396-
if (up->cd_pin && !gpiod_get_raw_value(up->cd_pin))
397-
ret |= TIOCM_CD;
398-
/* RI is active low */
399-
if (up->ri_pin && !gpiod_get_raw_value(up->ri_pin))
400-
ret |= TIOCM_RI;
401-
/* DSR is active low */
402-
if (up->dsr_pin && !gpiod_get_raw_value(up->dsr_pin))
403-
ret |= TIOCM_DSR;
404391
if (crisv32_serial_get_cts(up))
405392
ret |= TIOCM_CTS;
406-
return ret;
393+
return mctrl_gpio_get(up->gpios, &ret);
407394
}
408395

409396
static void etraxfs_uart_set_mctrl(struct uart_port *port, unsigned int mctrl)
410397
{
411398
struct uart_cris_port *up = (struct uart_cris_port *)port;
412399

413400
crisv32_serial_set_rts(up, mctrl & TIOCM_RTS ? 1 : 0, 0);
414-
/* DTR is active low */
415-
if (up->dtr_pin)
416-
gpiod_set_raw_value(up->dtr_pin, mctrl & TIOCM_DTR ? 0 : 1);
417-
/* RI is active low */
418-
if (up->ri_pin)
419-
gpiod_set_raw_value(up->ri_pin, mctrl & TIOCM_RNG ? 0 : 1);
420-
/* CD is active low */
421-
if (up->cd_pin)
422-
gpiod_set_raw_value(up->cd_pin, mctrl & TIOCM_CD ? 0 : 1);
401+
mctrl_gpio_set(up->gpios, mctrl);
423402
}
424403

425404
static void etraxfs_uart_break_ctl(struct uart_port *port, int break_state)
@@ -913,11 +892,12 @@ static int etraxfs_uart_probe(struct platform_device *pdev)
913892

914893
up->irq = irq_of_parse_and_map(np, 0);
915894
up->regi_ser = of_iomap(np, 0);
916-
up->dtr_pin = devm_gpiod_get_optional(&pdev->dev, "dtr");
917-
up->dsr_pin = devm_gpiod_get_optional(&pdev->dev, "dsr");
918-
up->ri_pin = devm_gpiod_get_optional(&pdev->dev, "ri");
919-
up->cd_pin = devm_gpiod_get_optional(&pdev->dev, "cd");
920895
up->port.dev = &pdev->dev;
896+
897+
up->gpios = mctrl_gpio_init(&pdev->dev, 0);
898+
if (IS_ERR(up->gpios))
899+
return PTR_ERR(up->gpios);
900+
921901
cris_serial_port_init(&up->port, dev_id);
922902

923903
etraxfs_uart_ports[dev_id] = up;

0 commit comments

Comments
 (0)