aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-sa1100/h3xxx.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-sa1100/h3xxx.c')
-rw-r--r--arch/arm/mach-sa1100/h3xxx.c58
1 files changed, 27 insertions, 31 deletions
diff --git a/arch/arm/mach-sa1100/h3xxx.c b/arch/arm/mach-sa1100/h3xxx.c
index f17e7382242a..c79bf467fb7f 100644
--- a/arch/arm/mach-sa1100/h3xxx.c
+++ b/arch/arm/mach-sa1100/h3xxx.c
@@ -28,37 +28,6 @@
28 28
29#include "generic.h" 29#include "generic.h"
30 30
31void h3xxx_init_gpio(struct gpio_default_state *s, size_t n)
32{
33 while (n--) {
34 const char *name = s->name;
35 int err;
36
37 if (!name)
38 name = "[init]";
39 err = gpio_request(s->gpio, name);
40 if (err) {
41 printk(KERN_ERR "gpio%u: unable to request: %d\n",
42 s->gpio, err);
43 continue;
44 }
45 if (s->mode >= 0) {
46 err = gpio_direction_output(s->gpio, s->mode);
47 } else {
48 err = gpio_direction_input(s->gpio);
49 }
50 if (err) {
51 printk(KERN_ERR "gpio%u: unable to set direction: %d\n",
52 s->gpio, err);
53 continue;
54 }
55 if (!s->name)
56 gpio_free(s->gpio);
57 s++;
58 }
59}
60
61
62/* 31/*
63 * H3xxx flash support 32 * H3xxx flash support
64 */ 33 */
@@ -116,9 +85,34 @@ static struct resource h3xxx_flash_resource =
116/* 85/*
117 * H3xxx uart support 86 * H3xxx uart support
118 */ 87 */
88static struct gpio h3xxx_uart_gpio[] = {
89 { H3XXX_GPIO_COM_DCD, GPIOF_IN, "COM DCD" },
90 { H3XXX_GPIO_COM_CTS, GPIOF_IN, "COM CTS" },
91 { H3XXX_GPIO_COM_RTS, GPIOF_OUT_INIT_LOW, "COM RTS" },
92};
93
94static bool h3xxx_uart_request_gpios(void)
95{
96 static bool h3xxx_uart_gpio_ok;
97 int rc;
98
99 if (h3xxx_uart_gpio_ok)
100 return true;
101
102 rc = gpio_request_array(h3xxx_uart_gpio, ARRAY_SIZE(h3xxx_uart_gpio));
103 if (rc)
104 pr_err("h3xxx_uart_request_gpios: error %d\n", rc);
105 else
106 h3xxx_uart_gpio_ok = true;
107
108 return h3xxx_uart_gpio_ok;
109}
110
119static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl) 111static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl)
120{ 112{
121 if (port->mapbase == _Ser3UTCR0) { 113 if (port->mapbase == _Ser3UTCR0) {
114 if (!h3xxx_uart_request_gpios())
115 return;
122 gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS)); 116 gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS));
123 } 117 }
124} 118}
@@ -128,6 +122,8 @@ static u_int h3xxx_uart_get_mctrl(struct uart_port *port)
128 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; 122 u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
129 123
130 if (port->mapbase == _Ser3UTCR0) { 124 if (port->mapbase == _Ser3UTCR0) {
125 if (!h3xxx_uart_request_gpios())
126 return ret;
131 /* 127 /*
132 * DCD and CTS bits are inverted in GPLR by RS232 transceiver 128 * DCD and CTS bits are inverted in GPLR by RS232 transceiver
133 */ 129 */