.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Support for Compaq iPAQ H3100 and H3600 handheld computers (common code) |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks) |
---|
5 | 6 | * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru> |
---|
6 | | - * |
---|
7 | | - * This program is free software; you can redistribute it and/or modify |
---|
8 | | - * it under the terms of the GNU General Public License version 2 as |
---|
9 | | - * published by the Free Software Foundation. |
---|
10 | | - * |
---|
11 | 7 | */ |
---|
12 | 8 | |
---|
13 | 9 | #include <linux/kernel.h> |
---|
.. | .. |
---|
87 | 83 | /* |
---|
88 | 84 | * H3xxx uart support |
---|
89 | 85 | */ |
---|
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 | 86 | static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate) |
---|
142 | 87 | { |
---|
143 | 88 | if (port->mapbase == _Ser3UTCR0) { |
---|
.. | .. |
---|
170 | 115 | } |
---|
171 | 116 | |
---|
172 | 117 | static struct sa1100_port_fns h3xxx_port_fns __initdata = { |
---|
173 | | - .set_mctrl = h3xxx_uart_set_mctrl, |
---|
174 | | - .get_mctrl = h3xxx_uart_get_mctrl, |
---|
175 | 118 | .pm = h3xxx_uart_pm, |
---|
176 | 119 | .set_wake = h3xxx_uart_set_wake, |
---|
| 120 | +}; |
---|
| 121 | + |
---|
| 122 | +static struct gpiod_lookup_table h3xxx_uart3_gpio_table = { |
---|
| 123 | + .dev_id = "sa11x0-uart.3", |
---|
| 124 | + .table = { |
---|
| 125 | + GPIO_LOOKUP("gpio", H3XXX_GPIO_COM_DCD, "dcd", GPIO_ACTIVE_LOW), |
---|
| 126 | + GPIO_LOOKUP("gpio", H3XXX_GPIO_COM_CTS, "cts", GPIO_ACTIVE_LOW), |
---|
| 127 | + GPIO_LOOKUP("gpio", H3XXX_GPIO_COM_RTS, "rts", GPIO_ACTIVE_LOW), |
---|
| 128 | + { }, |
---|
| 129 | + }, |
---|
177 | 130 | }; |
---|
178 | 131 | |
---|
179 | 132 | /* |
---|
.. | .. |
---|
283 | 236 | void __init h3xxx_mach_init(void) |
---|
284 | 237 | { |
---|
285 | 238 | gpiod_add_lookup_table(&h3xxx_pcmcia_gpio_table); |
---|
| 239 | + gpiod_add_lookup_table(&h3xxx_uart3_gpio_table); |
---|
286 | 240 | sa1100_register_uart_fns(&h3xxx_port_fns); |
---|
287 | 241 | sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1); |
---|
288 | 242 | platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices)); |
---|