diff options
author | Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 2013-11-26 05:11:00 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2014-02-12 05:36:02 -0500 |
commit | eb02313d2c96e1793cf37693d432fd2c129ae170 (patch) | |
tree | 152973303b3644f77985f7e7646c236d7c0b6dfd | |
parent | 162e68c08c916d0b701331a85291537fed2ad537 (diff) |
ARM: 7902/1: sa1100: h3xxx: move serial port GPIO handling to common place
Both h3100 and h3600 request UART gpios during init_machine time. As
sa1100 gpio driver is going to become proper machine driver, move gpio
handling to UART port functions. Request all gpios using gpio_request
array once and then guard them from rerequesting with bool variable.
Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r-- | arch/arm/mach-sa1100/h3100.c | 7 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/h3600.c | 7 | ||||
-rw-r--r-- | arch/arm/mach-sa1100/h3xxx.c | 27 |
3 files changed, 27 insertions, 14 deletions
diff --git a/arch/arm/mach-sa1100/h3100.c b/arch/arm/mach-sa1100/h3100.c index daa27c474c13..3c43219bc881 100644 --- a/arch/arm/mach-sa1100/h3100.c +++ b/arch/arm/mach-sa1100/h3100.c | |||
@@ -122,15 +122,8 @@ static struct irda_platform_data h3100_irda_data = { | |||
122 | .shutdown = h3100_irda_shutdown, | 122 | .shutdown = h3100_irda_shutdown, |
123 | }; | 123 | }; |
124 | 124 | ||
125 | static struct gpio_default_state h3100_default_gpio[] = { | ||
126 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, | ||
127 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, | ||
128 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, | ||
129 | }; | ||
130 | |||
131 | static void __init h3100_mach_init(void) | 125 | static void __init h3100_mach_init(void) |
132 | { | 126 | { |
133 | h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio)); | ||
134 | h3xxx_mach_init(); | 127 | h3xxx_mach_init(); |
135 | 128 | ||
136 | sa11x0_register_lcd(&h3100_lcd_info); | 129 | sa11x0_register_lcd(&h3100_lcd_info); |
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c index a663e7230141..5be54c214c7c 100644 --- a/arch/arm/mach-sa1100/h3600.c +++ b/arch/arm/mach-sa1100/h3600.c | |||
@@ -130,15 +130,8 @@ static struct irda_platform_data h3600_irda_data = { | |||
130 | .shutdown = h3600_irda_shutdown, | 130 | .shutdown = h3600_irda_shutdown, |
131 | }; | 131 | }; |
132 | 132 | ||
133 | static struct gpio_default_state h3600_default_gpio[] = { | ||
134 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, | ||
135 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, | ||
136 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, | ||
137 | }; | ||
138 | |||
139 | static void __init h3600_mach_init(void) | 133 | static void __init h3600_mach_init(void) |
140 | { | 134 | { |
141 | h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio)); | ||
142 | h3xxx_mach_init(); | 135 | h3xxx_mach_init(); |
143 | 136 | ||
144 | sa11x0_register_lcd(&h3600_lcd_info); | 137 | sa11x0_register_lcd(&h3600_lcd_info); |
diff --git a/arch/arm/mach-sa1100/h3xxx.c b/arch/arm/mach-sa1100/h3xxx.c index f17e7382242a..82e87024b1a6 100644 --- a/arch/arm/mach-sa1100/h3xxx.c +++ b/arch/arm/mach-sa1100/h3xxx.c | |||
@@ -116,9 +116,34 @@ static struct resource h3xxx_flash_resource = | |||
116 | /* | 116 | /* |
117 | * H3xxx uart support | 117 | * H3xxx uart support |
118 | */ | 118 | */ |
119 | static struct gpio h3xxx_uart_gpio[] = { | ||
120 | { H3XXX_GPIO_COM_DCD, GPIOF_IN, "COM DCD" }, | ||
121 | { H3XXX_GPIO_COM_CTS, GPIOF_IN, "COM CTS" }, | ||
122 | { H3XXX_GPIO_COM_RTS, GPIOF_OUT_INIT_LOW, "COM RTS" }, | ||
123 | }; | ||
124 | |||
125 | static bool h3xxx_uart_request_gpios(void) | ||
126 | { | ||
127 | static bool h3xxx_uart_gpio_ok; | ||
128 | int rc; | ||
129 | |||
130 | if (h3xxx_uart_gpio_ok) | ||
131 | return true; | ||
132 | |||
133 | rc = gpio_request_array(h3xxx_uart_gpio, ARRAY_SIZE(h3xxx_uart_gpio)); | ||
134 | if (rc) | ||
135 | pr_err("h3xxx_uart_request_gpios: error %d\n", rc); | ||
136 | else | ||
137 | h3xxx_uart_gpio_ok = true; | ||
138 | |||
139 | return h3xxx_uart_gpio_ok; | ||
140 | } | ||
141 | |||
119 | static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl) | 142 | static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl) |
120 | { | 143 | { |
121 | if (port->mapbase == _Ser3UTCR0) { | 144 | if (port->mapbase == _Ser3UTCR0) { |
145 | if (!h3xxx_uart_request_gpios()) | ||
146 | return; | ||
122 | gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS)); | 147 | gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS)); |
123 | } | 148 | } |
124 | } | 149 | } |
@@ -128,6 +153,8 @@ static u_int h3xxx_uart_get_mctrl(struct uart_port *port) | |||
128 | u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; | 153 | u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; |
129 | 154 | ||
130 | if (port->mapbase == _Ser3UTCR0) { | 155 | if (port->mapbase == _Ser3UTCR0) { |
156 | if (!h3xxx_uart_request_gpios()) | ||
157 | return ret; | ||
131 | /* | 158 | /* |
132 | * DCD and CTS bits are inverted in GPLR by RS232 transceiver | 159 | * DCD and CTS bits are inverted in GPLR by RS232 transceiver |
133 | */ | 160 | */ |