aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ixp4xx/patches-2.6.35/191-cambria_optional_uart.patch
blob: 2ebe3e4e3e0cc7a2e283af29f08b014ea50f5847 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
--- a/arch/arm/mach-ixp4xx/cambria-setup.c
+++ b/arch/arm/mach-ixp4xx/cambria-setup.c
@@ -34,6 +34,7 @@
 #include <asm/mach/arch.h>
 #include <asm/mach/flash.h>
 #include <asm/setup.h>
+#include <linux/irq.h>
 
 struct cambria_board_info {
 	unsigned char	*model;
@@ -127,6 +128,45 @@ static struct platform_device cambria_ua
 	.resource	= &cambria_uart_resource,
 };
 
+static struct resource cambria_optional_uart_resources[] = {
+	{
+		.start	= 0x52000000,
+		.end	= 0x52000fff,
+		.flags	= IORESOURCE_MEM
+	},
+	{
+		.start	= 0x53000000,
+		.end	= 0x53000fff,
+		.flags	= IORESOURCE_MEM
+	}
+};
+
+static struct plat_serial8250_port cambria_optional_uart_data[] = {
+	{
+		.flags		= UPF_BOOT_AUTOCONF,
+		.iotype		= UPIO_MEM_DELAY,
+		.regshift	= 0,
+		.uartclk	= 1843200,
+		.rw_delay	= 2,
+	},
+	{
+		.flags		= UPF_BOOT_AUTOCONF,
+		.iotype		= UPIO_MEM_DELAY,
+		.regshift	= 0,
+		.uartclk	= 1843200,
+		.rw_delay	= 2,
+	},
+  { },
+};
+
+static struct platform_device cambria_optional_uart = {
+	.name		= "serial8250",
+	.id		= PLAT8250_DEV_PLATFORM1,
+	.dev.platform_data	= cambria_optional_uart_data,
+	.num_resources	= 2,
+	.resource	= cambria_optional_uart_resources,
+};
+
 static struct resource cambria_pata_resources[] = {
 	{
 		.flags	= IORESOURCE_MEM
@@ -283,6 +323,19 @@ static void __init cambria_gw23xx_setup(
 
 static void __init cambria_gw2350_setup(void)
 {
+	*IXP4XX_EXP_CS2 = 0xBFFF3C43;
+	set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
+	cambria_optional_uart_data[0].mapbase	= 0x52FF0000;
+	cambria_optional_uart_data[0].membase	= (void __iomem *)ioremap(0x52FF0000, 0x0fff);
+	cambria_optional_uart_data[0].irq		= IRQ_IXP4XX_GPIO3;
+
+	*IXP4XX_EXP_CS3 = 0xBFFF3C43;
+	set_irq_type(IRQ_IXP4XX_GPIO4, IRQ_TYPE_EDGE_RISING);
+	cambria_optional_uart_data[1].mapbase	= 0x53FF0000;
+	cambria_optional_uart_data[1].membase	= (void __iomem *)ioremap(0x53FF0000, 0x0fff);
+	cambria_optional_uart_data[1].irq		= IRQ_IXP4XX_GPIO4;
+
+	platform_device_register(&cambria_optional_uart);
 	platform_device_register(&cambria_npec_device);
 	platform_device_register(&cambria_npea_device);
 
@@ -294,6 +347,19 @@ static void __init cambria_gw2350_setup(
 
 static void __init cambria_gw2358_setup(void)
 {
+	*IXP4XX_EXP_CS3 = 0xBFFF3C43;
+	set_irq_type(IRQ_IXP4XX_GPIO3, IRQ_TYPE_EDGE_RISING);
+	cambria_optional_uart_data[0].mapbase	= 0x53FC0000;
+	cambria_optional_uart_data[0].membase	= (void __iomem *)ioremap(0x53FC0000, 0x0fff);
+	cambria_optional_uart_data[0].irq		= IRQ_IXP4XX_GPIO3;
+
+	set_irq_type(IRQ_IXP4XX_GPIO4, IRQ_TYPE_EDGE_RISING);
+	cambria_optional_uart_data[1].mapbase	= 0x53F80000;
+	cambria_optional_uart_data[1].membase	= (void __iomem *)ioremap(0x53F80000, 0x0fff);
+	cambria_optional_uart_data[1].irq		= IRQ_IXP4XX_GPIO4;
+
+	platform_device_register(&cambria_optional_uart);
+
 	platform_device_register(&cambria_npec_device);
 	platform_device_register(&cambria_npea_device);
 
--- a/include/linux/serial_8250.h
+++ b/include/linux/serial_8250.h
@@ -27,6 +27,7 @@ struct plat_serial8250_port {
 	void            *private_data;
 	unsigned char	regshift;	/* register shift */
 	unsigned char	iotype;		/* UPIO_* */
+	unsigned int rw_delay;	/* udelay for slower busses IXP4XX Expansion Bus */
 	unsigned char	hub6;
 	upf_t		flags;		/* UPF_* flags */
 	unsigned int	type;		/* If UPF_FIXED_TYPE */
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -288,6 +288,7 @@ struct uart_port {
 #define UPIO_TSI		(5)			/* Tsi108/109 type IO */
 #define UPIO_DWAPB		(6)			/* DesignWare APB UART */
 #define UPIO_RM9000		(7)			/* RM9000 type IO */
+#define UPIO_MEM_DELAY	(8)
 
 	unsigned int		read_status_mask;	/* driver specific */
 	unsigned int		ignore_status_mask;	/* driver specific */
@@ -330,6 +331,7 @@ struct uart_port {
 
 	unsigned int		mctrl;			/* current modem ctrl settings */
 	unsigned int		timeout;		/* character-based timeout */
+	unsigned int		rw_delay;		/* udelay for slow busses, IXP4XX Expansion Bus */
 	unsigned int		type;			/* port type */
 	const struct uart_ops	*ops;
 	unsigned int		custom_divisor;
--- a/drivers/serial/8250.c
+++ b/drivers/serial/8250.c
@@ -409,6 +409,20 @@ static void mem_serial_out(struct uart_p
 	writeb(value, p->membase + offset);
 }
 
+static unsigned int memdelay_serial_in(struct uart_port *p, int offset)
+{
+	struct uart_8250_port *up = (struct uart_8250_port *)p;
+	udelay(up->port.rw_delay);
+	return mem_serial_in(p, offset);
+}
+
+static void memdelay_serial_out(struct uart_port *p, int offset, int value)
+{
+	struct uart_8250_port *up = (struct uart_8250_port *)p;
+	udelay(up->port.rw_delay);
+	mem_serial_out(p, offset, value);
+}
+
 static void mem32_serial_out(struct uart_port *p, int offset, int value)
 {
 	offset = map_8250_out_reg(p, offset) << p->regshift;
@@ -502,6 +516,11 @@ static void set_io_from_upio(struct uart
 		p->serial_out = mem32_serial_out;
 		break;
 
+	case UPIO_MEM_DELAY:
+		p->serial_in = memdelay_serial_in;
+		p->serial_out = memdelay_serial_out;
+		break;
+
 #ifdef CONFIG_SERIAL_8250_AU1X00
 	case UPIO_AU:
 		p->serial_in = au_serial_in;
@@ -534,6 +553,7 @@ serial_out_sync(struct uart_8250_port *u
 	switch (p->iotype) {
 	case UPIO_MEM:
 	case UPIO_MEM32:
+	case UPIO_MEM_DELAY:
 #ifdef CONFIG_SERIAL_8250_AU1X00
 	case UPIO_AU:
 #endif
@@ -2450,6 +2470,7 @@ static int serial8250_request_std_resour
 	case UPIO_MEM32:
 	case UPIO_MEM:
 	case UPIO_DWAPB:
+	case UPIO_MEM_DELAY:
 		if (!up->port.mapbase)
 			break;
 
@@ -2487,6 +2508,7 @@ static void serial8250_release_std_resou
 	case UPIO_MEM32:
 	case UPIO_MEM:
 	case UPIO_DWAPB:
+	case UPIO_MEM_DELAY:
 		if (!up->port.mapbase)
 			break;
 
@@ -2964,6 +2986,7 @@ static int __devinit serial8250_probe(st
 		port.serial_in		= p->serial_in;
 		port.serial_out		= p->serial_out;
 		port.dev		= &dev->dev;
+		port.rw_delay		= p->rw_delay;
 		port.irqflags		|= irqflag;
 		ret = serial8250_register_port(&port);
 		if (ret < 0) {
@@ -3113,6 +3136,7 @@ int serial8250_register_port(struct uart
 		uart->port.iotype       = port->iotype;
 		uart->port.flags        = port->flags | UPF_BOOT_AUTOCONF;
 		uart->port.mapbase      = port->mapbase;
+		uart->port.rw_delay			= port->rw_delay;
 		uart->port.private_data = port->private_data;
 		if (port->dev)
 			uart->port.dev = port->dev;
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -2144,6 +2144,7 @@ uart_report_port(struct uart_driver *drv
 		snprintf(address, sizeof(address),
 			 "I/O 0x%lx offset 0x%x", port->iobase, port->hub6);
 		break;
+	case UPIO_MEM_DELAY:
 	case UPIO_MEM:
 	case UPIO_MEM32:
 	case UPIO_AU:
@@ -2557,6 +2558,7 @@ int uart_match_port(struct uart_port *po
 	case UPIO_HUB6:
 		return (port1->iobase == port2->iobase) &&
 		       (port1->hub6   == port2->hub6);
+	case UPIO_MEM_DELAY:
 	case UPIO_MEM:
 	case UPIO_MEM32:
 	case UPIO_AU: