ixp4xx: add v3.18 support
[openwrt/svn-archive/archive.git] / target / linux / ixp4xx / patches-3.18 / 160-delayed_uart_io.patch
1 --- a/drivers/tty/serial/8250/8250_core.c
2 +++ b/drivers/tty/serial/8250/8250_core.c
3 @@ -410,6 +410,20 @@ static void mem_serial_out(struct uart_p
4 writeb(value, p->membase + offset);
5 }
6
7 +static unsigned int memdelay_serial_in(struct uart_port *p, int offset)
8 +{
9 + struct uart_8250_port *up = (struct uart_8250_port *)p;
10 + udelay(up->port.rw_delay);
11 + return mem_serial_in(p, offset);
12 +}
13 +
14 +static void memdelay_serial_out(struct uart_port *p, int offset, int value)
15 +{
16 + struct uart_8250_port *up = (struct uart_8250_port *)p;
17 + udelay(up->port.rw_delay);
18 + mem_serial_out(p, offset, value);
19 +}
20 +
21 static void mem32_serial_out(struct uart_port *p, int offset, int value)
22 {
23 offset = offset << p->regshift;
24 @@ -461,6 +475,11 @@ static void set_io_from_upio(struct uart
25 p->serial_out = mem32_serial_out;
26 break;
27
28 + case UPIO_MEM_DELAY:
29 + p->serial_in = memdelay_serial_in;
30 + p->serial_out = memdelay_serial_out;
31 + break;
32 +
33 #if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X)
34 case UPIO_AU:
35 p->serial_in = au_serial_in;
36 @@ -486,6 +505,7 @@ serial_port_out_sync(struct uart_port *p
37 switch (p->iotype) {
38 case UPIO_MEM:
39 case UPIO_MEM32:
40 + case UPIO_MEM_DELAY:
41 case UPIO_AU:
42 p->serial_out(p, offset, value);
43 p->serial_in(p, UART_LCR); /* safe, no side-effects */
44 @@ -2538,6 +2558,7 @@ static int serial8250_request_std_resour
45 case UPIO_TSI:
46 case UPIO_MEM32:
47 case UPIO_MEM:
48 + case UPIO_MEM_DELAY:
49 if (!port->mapbase)
50 break;
51
52 @@ -2574,6 +2595,7 @@ static void serial8250_release_std_resou
53 case UPIO_TSI:
54 case UPIO_MEM32:
55 case UPIO_MEM:
56 + case UPIO_MEM_DELAY:
57 if (!port->mapbase)
58 break;
59
60 @@ -3113,6 +3135,7 @@ static int serial8250_probe(struct platf
61 uart.port.set_termios = p->set_termios;
62 uart.port.pm = p->pm;
63 uart.port.dev = &dev->dev;
64 + uart.port.rw_delay = p->rw_delay;
65 uart.port.irqflags |= irqflag;
66 ret = serial8250_register_8250_port(&uart);
67 if (ret < 0) {
68 @@ -3264,6 +3287,7 @@ int serial8250_register_8250_port(struct
69 uart->port.flags = up->port.flags | UPF_BOOT_AUTOCONF;
70 uart->bugs = up->bugs;
71 uart->port.mapbase = up->port.mapbase;
72 + uart->port.rw_delay = up->port.rw_delay;
73 uart->port.private_data = up->port.private_data;
74 uart->port.fifosize = up->port.fifosize;
75 uart->tx_loadsz = up->tx_loadsz;
76 --- a/drivers/tty/serial/serial_core.c
77 +++ b/drivers/tty/serial/serial_core.c
78 @@ -2090,6 +2090,7 @@ uart_report_port(struct uart_driver *drv
79 snprintf(address, sizeof(address),
80 "I/O 0x%lx offset 0x%x", port->iobase, port->hub6);
81 break;
82 + case UPIO_MEM_DELAY:
83 case UPIO_MEM:
84 case UPIO_MEM32:
85 case UPIO_AU:
86 @@ -2711,6 +2712,7 @@ int uart_match_port(struct uart_port *po
87 case UPIO_HUB6:
88 return (port1->iobase == port2->iobase) &&
89 (port1->hub6 == port2->hub6);
90 + case UPIO_MEM_DELAY:
91 case UPIO_MEM:
92 case UPIO_MEM32:
93 case UPIO_AU:
94 --- a/include/linux/serial_8250.h
95 +++ b/include/linux/serial_8250.h
96 @@ -27,6 +27,7 @@ struct plat_serial8250_port {
97 void *private_data;
98 unsigned char regshift; /* register shift */
99 unsigned char iotype; /* UPIO_* */
100 + unsigned int rw_delay; /* udelay for slower busses IXP4XX Expansion Bus */
101 unsigned char hub6;
102 upf_t flags; /* UPF_* flags */
103 unsigned int type; /* If UPF_FIXED_TYPE */
104 --- a/include/linux/serial_core.h
105 +++ b/include/linux/serial_core.h
106 @@ -141,6 +141,7 @@ struct uart_port {
107 #define UPIO_MEM32 (3)
108 #define UPIO_AU (4) /* Au1x00 and RT288x type IO */
109 #define UPIO_TSI (5) /* Tsi108/109 type IO */
110 +#define UPIO_MEM_DELAY (6)
111
112 unsigned int read_status_mask; /* driver specific */
113 unsigned int ignore_status_mask; /* driver specific */
114 @@ -189,6 +190,7 @@ struct uart_port {
115
116 unsigned int mctrl; /* current modem ctrl settings */
117 unsigned int timeout; /* character-based timeout */
118 + unsigned int rw_delay; /* udelay for slow busses, IXP4XX Expansion Bus */
119 unsigned int type; /* port type */
120 const struct uart_ops *ops;
121 unsigned int custom_divisor;