diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-10-06 10:16:27 -0400 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2009-12-06 11:52:24 -0500 |
commit | 6e21ee6aa76df6297e6dcea22d6583cafdb669f7 (patch) | |
tree | 52b7fbf09fed5b0e903cf61fd3c2111ce3a41118 /arch/arm/mach-sa1100/h3600.c | |
parent | 9c196f0f8db928ef9a2a935d86d75a218a7131b1 (diff) |
ARM: iPAQ: move serial port support functions
No point calling sa1100_register_uart_fns early - these aren't
used until late in the boot sequence. Also convert to gpiolib
support.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-sa1100/h3600.c')
-rw-r--r-- | arch/arm/mach-sa1100/h3600.c | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/arch/arm/mach-sa1100/h3600.c b/arch/arm/mach-sa1100/h3600.c index c53ad6518352..8a6a0e744db3 100644 --- a/arch/arm/mach-sa1100/h3600.c +++ b/arch/arm/mach-sa1100/h3600.c | |||
@@ -91,6 +91,9 @@ static void h3xxx_init_gpio(struct gpio_default_state *s, size_t n) | |||
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | ||
94 | /* | ||
95 | * H3xxx flash support | ||
96 | */ | ||
94 | static struct mtd_partition h3xxx_partitions[] = { | 97 | static struct mtd_partition h3xxx_partitions[] = { |
95 | { | 98 | { |
96 | .name = "H3XXX boot firmware", | 99 | .name = "H3XXX boot firmware", |
@@ -122,42 +125,35 @@ static struct resource h3xxx_flash_resource = { | |||
122 | .flags = IORESOURCE_MEM, | 125 | .flags = IORESOURCE_MEM, |
123 | }; | 126 | }; |
124 | 127 | ||
125 | static void h3xxx_mach_init(void) | ||
126 | { | ||
127 | sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1); | ||
128 | } | ||
129 | 128 | ||
130 | /* | 129 | /* |
131 | * low-level UART features | 130 | * H3xxx uart support |
132 | */ | 131 | */ |
133 | 132 | static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl) | |
134 | static void h3600_uart_set_mctrl(struct uart_port *port, u_int mctrl) | ||
135 | { | 133 | { |
136 | if (port->mapbase == _Ser3UTCR0) { | 134 | if (port->mapbase == _Ser3UTCR0) { |
137 | if (mctrl & TIOCM_RTS) | 135 | gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS)); |
138 | GPCR = GPIO_H3600_COM_RTS; | ||
139 | else | ||
140 | GPSR = GPIO_H3600_COM_RTS; | ||
141 | } | 136 | } |
142 | } | 137 | } |
143 | 138 | ||
144 | static u_int h3600_uart_get_mctrl(struct uart_port *port) | 139 | static u_int h3xxx_uart_get_mctrl(struct uart_port *port) |
145 | { | 140 | { |
146 | u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; | 141 | u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR; |
147 | 142 | ||
148 | if (port->mapbase == _Ser3UTCR0) { | 143 | if (port->mapbase == _Ser3UTCR0) { |
149 | int gplr = GPLR; | 144 | /* |
150 | /* DCD and CTS bits are inverted in GPLR by RS232 transceiver */ | 145 | * DCD and CTS bits are inverted in GPLR by RS232 transceiver |
151 | if (gplr & GPIO_H3600_COM_DCD) | 146 | */ |
147 | if (gpio_get_value(H3XXX_GPIO_COM_DCD)) | ||
152 | ret &= ~TIOCM_CD; | 148 | ret &= ~TIOCM_CD; |
153 | if (gplr & GPIO_H3600_COM_CTS) | 149 | if (gpio_get_value(H3XXX_GPIO_COM_CTS)) |
154 | ret &= ~TIOCM_CTS; | 150 | ret &= ~TIOCM_CTS; |
155 | } | 151 | } |
156 | 152 | ||
157 | return ret; | 153 | return ret; |
158 | } | 154 | } |
159 | 155 | ||
160 | static void h3600_uart_pm(struct uart_port *port, u_int state, u_int oldstate) | 156 | static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate) |
161 | { | 157 | { |
162 | if (port->mapbase == _Ser2UTCR0) { /* TODO: REMOVE THIS */ | 158 | if (port->mapbase == _Ser2UTCR0) { /* TODO: REMOVE THIS */ |
163 | assign_h3600_egpio(IPAQ_EGPIO_IR_ON, !state); | 159 | assign_h3600_egpio(IPAQ_EGPIO_IR_ON, !state); |
@@ -170,7 +166,7 @@ static void h3600_uart_pm(struct uart_port *port, u_int state, u_int oldstate) | |||
170 | * Enable/Disable wake up events for this serial port. | 166 | * Enable/Disable wake up events for this serial port. |
171 | * Obviously, we only support this on the normal COM port. | 167 | * Obviously, we only support this on the normal COM port. |
172 | */ | 168 | */ |
173 | static int h3600_uart_set_wake(struct uart_port *port, u_int enable) | 169 | static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable) |
174 | { | 170 | { |
175 | int err = -EINVAL; | 171 | int err = -EINVAL; |
176 | 172 | ||
@@ -184,13 +180,20 @@ static int h3600_uart_set_wake(struct uart_port *port, u_int enable) | |||
184 | return err; | 180 | return err; |
185 | } | 181 | } |
186 | 182 | ||
187 | static struct sa1100_port_fns h3600_port_fns __initdata = { | 183 | static struct sa1100_port_fns h3xxx_port_fns __initdata = { |
188 | .set_mctrl = h3600_uart_set_mctrl, | 184 | .set_mctrl = h3xxx_uart_set_mctrl, |
189 | .get_mctrl = h3600_uart_get_mctrl, | 185 | .get_mctrl = h3xxx_uart_get_mctrl, |
190 | .pm = h3600_uart_pm, | 186 | .pm = h3xxx_uart_pm, |
191 | .set_wake = h3600_uart_set_wake, | 187 | .set_wake = h3xxx_uart_set_wake, |
192 | }; | 188 | }; |
193 | 189 | ||
190 | |||
191 | static void h3xxx_mach_init(void) | ||
192 | { | ||
193 | sa1100_register_uart_fns(&h3xxx_port_fns); | ||
194 | sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1); | ||
195 | } | ||
196 | |||
194 | /* | 197 | /* |
195 | * helper for sa1100fb | 198 | * helper for sa1100fb |
196 | */ | 199 | */ |
@@ -227,7 +230,6 @@ static void __init h3xxx_map_io(void) | |||
227 | sa1100_map_io(); | 230 | sa1100_map_io(); |
228 | iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc)); | 231 | iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc)); |
229 | 232 | ||
230 | sa1100_register_uart_fns(&h3600_port_fns); | ||
231 | sa1100_register_uart(0, 3); /* Common serial port */ | 233 | sa1100_register_uart(0, 3); /* Common serial port */ |
232 | // sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */ | 234 | // sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */ |
233 | 235 | ||
@@ -329,7 +331,7 @@ static void __init h3100_map_io(void) | |||
329 | 331 | ||
330 | /* Initialize h3100-specific values here */ | 332 | /* Initialize h3100-specific values here */ |
331 | GPCR = 0x0fffffff; /* All outputs are set low by default */ | 333 | GPCR = 0x0fffffff; /* All outputs are set low by default */ |
332 | GPDR = GPIO_H3600_COM_RTS | GPIO_H3600_L3_CLOCK | | 334 | GPDR = GPIO_H3600_L3_CLOCK | |
333 | GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA | | 335 | GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA | |
334 | GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 | | 336 | GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 | |
335 | H3100_DIRECT_EGPIO; | 337 | H3100_DIRECT_EGPIO; |
@@ -364,6 +366,9 @@ static struct irda_platform_data h3100_irda_data = { | |||
364 | static struct gpio_default_state h3100_default_gpio[] = { | 366 | static struct gpio_default_state h3100_default_gpio[] = { |
365 | { H3100_GPIO_IR_ON, GPIO_MODE_OUT0, "IrDA power" }, | 367 | { H3100_GPIO_IR_ON, GPIO_MODE_OUT0, "IrDA power" }, |
366 | { H3100_GPIO_IR_FSEL, GPIO_MODE_OUT0, "IrDA fsel" }, | 368 | { H3100_GPIO_IR_FSEL, GPIO_MODE_OUT0, "IrDA fsel" }, |
369 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, | ||
370 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, | ||
371 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, | ||
367 | }; | 372 | }; |
368 | 373 | ||
369 | static void h3100_mach_init(void) | 374 | static void h3100_mach_init(void) |
@@ -460,7 +465,7 @@ static void __init h3600_map_io(void) | |||
460 | /* Initialize h3600-specific values here */ | 465 | /* Initialize h3600-specific values here */ |
461 | 466 | ||
462 | GPCR = 0x0fffffff; /* All outputs are set low by default */ | 467 | GPCR = 0x0fffffff; /* All outputs are set low by default */ |
463 | GPDR = GPIO_H3600_COM_RTS | GPIO_H3600_L3_CLOCK | | 468 | GPDR = GPIO_H3600_L3_CLOCK | |
464 | GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA | | 469 | GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA | |
465 | GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 | | 470 | GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 | |
466 | GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 | | 471 | GPIO_LDD15 | GPIO_LDD14 | GPIO_LDD13 | GPIO_LDD12 | |
@@ -489,8 +494,15 @@ static struct irda_platform_data h3600_irda_data = { | |||
489 | .set_speed = h3600_irda_set_speed, | 494 | .set_speed = h3600_irda_set_speed, |
490 | }; | 495 | }; |
491 | 496 | ||
497 | static struct gpio_default_state h3600_default_gpio[] = { | ||
498 | { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" }, | ||
499 | { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" }, | ||
500 | { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" }, | ||
501 | }; | ||
502 | |||
492 | static void h3600_mach_init(void) | 503 | static void h3600_mach_init(void) |
493 | { | 504 | { |
505 | h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio)); | ||
494 | h3xxx_mach_init(); | 506 | h3xxx_mach_init(); |
495 | sa11x0_register_irda(&h3600_irda_data); | 507 | sa11x0_register_irda(&h3600_irda_data); |
496 | } | 508 | } |