add further fixes for the optional Cambria UART - thanks, Chris
[openwrt/svn-archive/archive.git] / target / linux / ixp4xx / patches-2.6.28 / 191-cambria_optional_uart.patch
1 --- a/arch/arm/mach-ixp4xx/cambria-setup.c
2 +++ b/arch/arm/mach-ixp4xx/cambria-setup.c
3 @@ -34,6 +34,7 @@
4 #include <asm/mach/arch.h>
5 #include <asm/mach/flash.h>
6 #include <asm/setup.h>
7 +#include <linux/irq.h>
8
9 struct cambria_board_info {
10 unsigned char *model;
11 @@ -127,6 +128,45 @@ static struct platform_device cambria_ua
12 .resource = &cambria_uart_resource,
13 };
14
15 +static struct resource cambria_optional_uart_resources[] = {
16 + {
17 + .start = 0x52000000,
18 + .end = 0x52000fff,
19 + .flags = IORESOURCE_MEM
20 + },
21 + {
22 + .start = 0x53000000,
23 + .end = 0x53000fff,
24 + .flags = IORESOURCE_MEM
25 + }
26 +};
27 +
28 +static struct plat_serial8250_port cambria_optional_uart_data[] = {
29 + {
30 + .flags = UPF_BOOT_AUTOCONF,
31 + .iotype = UPIO_MEM_DELAY,
32 + .regshift = 0,
33 + .uartclk = 1843200,
34 + .rw_delay = 2,
35 + },
36 + {
37 + .flags = UPF_BOOT_AUTOCONF,
38 + .iotype = UPIO_MEM_DELAY,
39 + .regshift = 0,
40 + .uartclk = 1843200,
41 + .rw_delay = 2,
42 + },
43 + { },
44 +};
45 +
46 +static struct platform_device cambria_optional_uart = {
47 + .name = "serial8250",
48 + .id = PLAT8250_DEV_PLATFORM1,
49 + .dev.platform_data = cambria_optional_uart_data,
50 + .num_resources = 2,
51 + .resource = cambria_optional_uart_resources,
52 +};
53 +
54 static struct resource cambria_pata_resources[] = {
55 {
56 .flags = IORESOURCE_MEM
57 @@ -283,6 +323,19 @@ static void __init cambria_gw23xx_setup(
58
59 static void __init cambria_gw2350_setup(void)
60 {
61 + *IXP4XX_EXP_CS2 = 0xBFFF3C43;
62 + set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
63 + cambria_optional_uart_data[0].mapbase = 0x52FF0000;
64 + cambria_optional_uart_data[0].membase = (void __iomem *)ioremap(0x52FF0000, 0x0fff);
65 + cambria_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO3;
66 +
67 + *IXP4XX_EXP_CS3 = 0xBFFF3C43;
68 + set_irq_type(IRQ_IXP4XX_GPIO4, IRQ_TYPE_EDGE_RISING);
69 + cambria_optional_uart_data[1].mapbase = 0x53FF0000;
70 + cambria_optional_uart_data[1].membase = (void __iomem *)ioremap(0x53FF0000, 0x0fff);
71 + cambria_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO4;
72 +
73 + platform_device_register(&cambria_optional_uart);
74 platform_device_register(&cambria_npec_device);
75 platform_device_register(&cambria_npea_device);
76
77 @@ -294,6 +347,19 @@ static void __init cambria_gw2350_setup(
78
79 static void __init cambria_gw2358_setup(void)
80 {
81 + *IXP4XX_EXP_CS3 = 0xBFFF3C433;
82 + set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
83 + cambria_optional_uart_data[0].mapbase = 0x53FC0000;
84 + cambria_optional_uart_data[0].membase = (void __iomem *)ioremap(0x53FC0000, 0x0fff);
85 + cambria_optional_uart_data[0].irq = IRQ_IXP4XX_GPIO3;
86 +
87 + set_irq_type(IRQ_IXP4XX_GPIO4, IRQ_TYPE_EDGE_RISING);
88 + cambria_optional_uart_data[1].mapbase = 0x53F80000;
89 + cambria_optional_uart_data[1].membase = (void __iomem *)ioremap(0x53F80000, 0x0fff);
90 + cambria_optional_uart_data[1].irq = IRQ_IXP4XX_GPIO4;
91 +
92 + platform_device_register(&cambria_optional_uart);
93 +
94 platform_device_register(&cambria_npec_device);
95 platform_device_register(&cambria_npea_device);
96
97 --- a/include/linux/serial_8250.h
98 +++ b/include/linux/serial_8250.h
99 @@ -26,6 +26,7 @@ struct plat_serial8250_port {
100 void *private_data;
101 unsigned char regshift; /* register shift */
102 unsigned char iotype; /* UPIO_* */
103 + unsigned int rw_delay; /* udelay for slower busses IXP4XX Expansion Bus */
104 unsigned char hub6;
105 upf_t flags; /* UPF_* flags */
106 };
107 --- a/include/linux/serial_core.h
108 +++ b/include/linux/serial_core.h
109 @@ -262,6 +262,7 @@ struct uart_port {
110 #define UPIO_TSI (5) /* Tsi108/109 type IO */
111 #define UPIO_DWAPB (6) /* DesignWare APB UART */
112 #define UPIO_RM9000 (7) /* RM9000 type IO */
113 +#define UPIO_MEM_DELAY (8)
114
115 unsigned int read_status_mask; /* driver specific */
116 unsigned int ignore_status_mask; /* driver specific */
117 @@ -301,6 +302,7 @@ struct uart_port {
118
119 unsigned int mctrl; /* current modem ctrl settings */
120 unsigned int timeout; /* character-based timeout */
121 + unsigned int rw_delay; /* udelay for slow busses, IXP4XX Expansion Bus */
122 unsigned int type; /* port type */
123 const struct uart_ops *ops;
124 unsigned int custom_divisor;
125 --- a/drivers/serial/8250.c
126 +++ b/drivers/serial/8250.c
127 @@ -373,6 +373,8 @@ static unsigned int serial_in(struct uar
128 outb(up->port.hub6 - 1 + offset, up->port.iobase);
129 return inb(up->port.iobase + 1);
130
131 + case UPIO_MEM_DELAY:
132 + udelay(up->port.rw_delay);
133 case UPIO_MEM:
134 case UPIO_DWAPB:
135 return readb(up->port.membase + offset);
136 @@ -411,6 +413,8 @@ serial_out(struct uart_8250_port *up, in
137 outb(value, up->port.iobase + 1);
138 break;
139
140 + case UPIO_MEM_DELAY:
141 + udelay(up->port.rw_delay);
142 case UPIO_MEM:
143 writeb(value, up->port.membase + offset);
144 break;
145 @@ -2823,6 +2827,7 @@ static int __devinit serial8250_probe(st
146 port.hub6 = p->hub6;
147 port.private_data = p->private_data;
148 port.dev = &dev->dev;
149 + port.rw_delay = p->rw_delay;
150 if (share_irqs)
151 port.flags |= UPF_SHARE_IRQ;
152 ret = serial8250_register_port(&port);
153 @@ -2972,6 +2977,7 @@ int serial8250_register_port(struct uart
154 uart->port.iotype = port->iotype;
155 uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
156 uart->port.mapbase = port->mapbase;
157 + uart->port.rw_delay = port->rw_delay;
158 uart->port.private_data = port->private_data;
159 if (port->dev)
160 uart->port.dev = port->dev;
161 --- a/drivers/serial/serial_core.c
162 +++ b/drivers/serial/serial_core.c
163 @@ -2161,6 +2161,7 @@ uart_report_port(struct uart_driver *drv
164 snprintf(address, sizeof(address),
165 "I/O 0x%lx offset 0x%x", port->iobase, port->hub6);
166 break;
167 + case UPIO_MEM_DELAY:
168 case UPIO_MEM:
169 case UPIO_MEM32:
170 case UPIO_AU:
171 @@ -2577,6 +2578,7 @@ int uart_match_port(struct uart_port *po
172 case UPIO_HUB6:
173 return (port1->iobase == port2->iobase) &&
174 (port1->hub6 == port2->hub6);
175 + case UPIO_MEM_DELAY:
176 case UPIO_MEM:
177 case UPIO_MEM32:
178 case UPIO_AU: