forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 10ebd8556b7990499c896a550e3d416b444211e6
kernel/arch/arm/mach-sa1100/h3xxx.c
....@@ -1,13 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Support for Compaq iPAQ H3100 and H3600 handheld computers (common code)
34 *
45 * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
56 * 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
- *
117 */
128
139 #include <linux/kernel.h>
....@@ -87,57 +83,6 @@
8783 /*
8884 * H3xxx uart support
8985 */
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
-
14186 static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
14287 {
14388 if (port->mapbase == _Ser3UTCR0) {
....@@ -170,10 +115,18 @@
170115 }
171116
172117 static struct sa1100_port_fns h3xxx_port_fns __initdata = {
173
- .set_mctrl = h3xxx_uart_set_mctrl,
174
- .get_mctrl = h3xxx_uart_get_mctrl,
175118 .pm = h3xxx_uart_pm,
176119 .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
+ },
177130 };
178131
179132 /*
....@@ -283,6 +236,7 @@
283236 void __init h3xxx_mach_init(void)
284237 {
285238 gpiod_add_lookup_table(&h3xxx_pcmcia_gpio_table);
239
+ gpiod_add_lookup_table(&h3xxx_uart3_gpio_table);
286240 sa1100_register_uart_fns(&h3xxx_port_fns);
287241 sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
288242 platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices));