Skip to content

Commit 3fae166

Browse files
author
Russell King
committed
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 <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent 59f06d6 commit 3fae166

File tree

1 file changed

+11
-53
lines changed

1 file changed

+11
-53
lines changed

arch/arm/mach-sa1100/h3xxx.c

Lines changed: 11 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -87,57 +87,6 @@ static struct resource h3xxx_flash_resource =
8787
/*
8888
* H3xxx uart support
8989
*/
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-
14190
static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
14291
{
14392
if (port->mapbase == _Ser3UTCR0) {
@@ -170,12 +119,20 @@ static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable)
170119
}
171120

172121
static struct sa1100_port_fns h3xxx_port_fns __initdata = {
173-
.set_mctrl = h3xxx_uart_set_mctrl,
174-
.get_mctrl = h3xxx_uart_get_mctrl,
175122
.pm = h3xxx_uart_pm,
176123
.set_wake = h3xxx_uart_set_wake,
177124
};
178125

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+
179136
/*
180137
* EGPIO
181138
*/
@@ -283,6 +240,7 @@ static struct gpiod_lookup_table h3xxx_pcmcia_gpio_table = {
283240
void __init h3xxx_mach_init(void)
284241
{
285242
gpiod_add_lookup_table(&h3xxx_pcmcia_gpio_table);
243+
gpiod_add_lookup_table(&h3xxx_uart3_gpio_table);
286244
sa1100_register_uart_fns(&h3xxx_port_fns);
287245
sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
288246
platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices));

0 commit comments

Comments
 (0)