diff options
author | Russell King <rmk+kernel@armlinux.org.uk> | 2016-08-31 03:49:52 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@armlinux.org.uk> | 2019-06-04 07:56:38 -0400 |
commit | 3fae166e6799fc51c8e262d9ce48452be12bf5f2 (patch) | |
tree | 8207b20744ff31c922643eaa48b40d53aeb5b83a | |
parent | 59f06d674f380644fb85b14a1eb7259ef291eb7b (diff) |
ARM: sa1100/h3xxx: convert serial to gpiod APIs
Convert the iPAQ H3xxx serial modem control signals to use the gpiod
APIs rather than custom callbacks into platform code.
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
-rw-r--r-- | arch/arm/mach-sa1100/h3xxx.c | 64 |
1 files changed, 11 insertions, 53 deletions
diff --git a/arch/arm/mach-sa1100/h3xxx.c b/arch/arm/mach-sa1100/h3xxx.c index 36a78b0c106f..e7362292612a 100644 --- a/arch/arm/mach-sa1100/h3xxx.c +++ b/arch/arm/mach-sa1100/h3xxx.c | |||
@@ -87,57 +87,6 @@ static struct resource h3xxx_flash_resource = | |||
87 | /* | 87 | /* |
88 | * H3xxx uart support | 88 | * H3xxx uart support |
89 | */ | 89 | */ |
90 | static struct gpio h3xxx_uart_gpio[] = { | ||
91 | { H3XXX_GPIO_COM_DCD, GPIOF_IN, "COM DCD" }, | ||
92 | { H3XXX_GPIO_COM_CTS, GPIOF_IN, "COM CTS" }, | ||
93 | { H3XXX_GPIO_COM_RTS, GPIOF_OUT_INIT_LOW, "COM RTS" }, | ||
94 | }; | ||
95 | |||
96 | static bool h3xxx_uart_request_gpios(void) | ||
97 | { | ||
98 | static bool h3xxx_uart_gpio_ok; | ||
99 | int rc; | ||
100 | |||
101 | if (h3xxx_uart_gpio_ok) | ||
102 | return true; | ||
103 | |||
104 | rc = gpio_request_array(h3xxx_uart_gpio, ARRAY_SIZE(h3xxx_uart_gpio)); | ||
105 | if (rc) | ||
106 | pr_err("h3xxx_uart_request_gpios: error %d\n", rc); | ||
107 | else | ||
108 | h3xxx_uart_gpio_ok = true; | ||
109 | |||
110 | return h3xxx_uart_gpio_ok; | ||
111 | } | ||
112 | |||
113 | static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl) | ||
114 | { | ||
115 | if (port->mapbase == _Ser3UTCR0) { | ||
116 | if (!h3xxx_uart_request_gpios()) | ||
117 | return; | ||
118 | gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS)); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | static u_int h3xxx_uart_get_mctrl(struct uart_port *port) | ||
123 | { | ||
124 | u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; | ||
125 | |||
126 | if (port->mapbase == _Ser3UTCR0) { | ||
127 | if (!h3xxx_uart_request_gpios()) | ||
128 | return ret; | ||
129 | /* | ||
130 | * DCD and CTS bits are inverted in GPLR by RS232 transceiver | ||
131 | */ | ||
132 | if (gpio_get_value(H3XXX_GPIO_COM_DCD)) | ||
133 | ret &= ~TIOCM_CD; | ||
134 | if (gpio_get_value(H3XXX_GPIO_COM_CTS)) | ||
135 | ret &= ~TIOCM_CTS; | ||
136 | } | ||
137 | |||
138 | return ret; | ||
139 | } | ||
140 | |||
141 | static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate) | 90 | static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate) |
142 | { | 91 | { |
143 | if (port->mapbase == _Ser3UTCR0) { | 92 | if (port->mapbase == _Ser3UTCR0) { |
@@ -170,12 +119,20 @@ static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable) | |||
170 | } | 119 | } |
171 | 120 | ||
172 | static struct sa1100_port_fns h3xxx_port_fns __initdata = { | 121 | static struct sa1100_port_fns h3xxx_port_fns __initdata = { |
173 | .set_mctrl = h3xxx_uart_set_mctrl, | ||
174 | .get_mctrl = h3xxx_uart_get_mctrl, | ||
175 | .pm = h3xxx_uart_pm, | 122 | .pm = h3xxx_uart_pm, |
176 | .set_wake = h3xxx_uart_set_wake, | 123 | .set_wake = h3xxx_uart_set_wake, |
177 | }; | 124 | }; |
178 | 125 | ||
126 | static struct gpiod_lookup_table h3xxx_uart3_gpio_table = { | ||
127 | .dev_id = "sa11x0-uart.3", | ||
128 | .table = { | ||
129 | GPIO_LOOKUP("gpio", H3XXX_GPIO_COM_DCD, "dcd", GPIO_ACTIVE_LOW), | ||
130 | GPIO_LOOKUP("gpio", H3XXX_GPIO_COM_CTS, "cts", GPIO_ACTIVE_LOW), | ||
131 | GPIO_LOOKUP("gpio", H3XXX_GPIO_COM_RTS, "rts", GPIO_ACTIVE_LOW), | ||
132 | { }, | ||
133 | }, | ||
134 | }; | ||
135 | |||
179 | /* | 136 | /* |
180 | * EGPIO | 137 | * EGPIO |
181 | */ | 138 | */ |
@@ -283,6 +240,7 @@ static struct gpiod_lookup_table h3xxx_pcmcia_gpio_table = { | |||
283 | void __init h3xxx_mach_init(void) | 240 | void __init h3xxx_mach_init(void) |
284 | { | 241 | { |
285 | gpiod_add_lookup_table(&h3xxx_pcmcia_gpio_table); | 242 | gpiod_add_lookup_table(&h3xxx_pcmcia_gpio_table); |
243 | gpiod_add_lookup_table(&h3xxx_uart3_gpio_table); | ||
286 | sa1100_register_uart_fns(&h3xxx_port_fns); | 244 | sa1100_register_uart_fns(&h3xxx_port_fns); |
287 | sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1); | 245 | sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1); |
288 | platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices)); | 246 | platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices)); |