ixp4xx: merge fixes and improvements from trunk
[openwrt/svn-archive/archive.git] / target / linux / ixp4xx / patches-3.3 / 160-delayed_uart_io.patch
1 Add a new UART I/O type for slow busses such as the ixp4xx expansion bus
2 --- a/include/linux/serial_8250.h
3 +++ b/include/linux/serial_8250.h
4 @@ -27,6 +27,7 @@ struct plat_serial8250_port {
5 void *private_data;
6 unsigned char regshift; /* register shift */
7 unsigned char iotype; /* UPIO_* */
8 + unsigned int rw_delay; /* udelay for slower busses IXP4XX Expansion Bus */
9 unsigned char hub6;
10 upf_t flags; /* UPF_* flags */
11 unsigned int type; /* If UPF_FIXED_TYPE */
12 --- a/include/linux/serial_core.h
13 +++ b/include/linux/serial_core.h
14 @@ -324,6 +324,7 @@ struct uart_port {
15 #define UPIO_AU (4) /* Au1x00 type IO */
16 #define UPIO_TSI (5) /* Tsi108/109 type IO */
17 #define UPIO_RM9000 (6) /* RM9000 type IO */
18 +#define UPIO_MEM_DELAY (7)
19
20 unsigned int read_status_mask; /* driver specific */
21 unsigned int ignore_status_mask; /* driver specific */
22 @@ -368,6 +369,7 @@ struct uart_port {
23
24 unsigned int mctrl; /* current modem ctrl settings */
25 unsigned int timeout; /* character-based timeout */
26 + unsigned int rw_delay; /* udelay for slow busses, IXP4XX Expansion Bus */
27 unsigned int type; /* port type */
28 const struct uart_ops *ops;
29 unsigned int custom_divisor;
30 --- a/drivers/tty/serial/8250/8250.c
31 +++ b/drivers/tty/serial/8250/8250.c
32 @@ -400,6 +400,20 @@ static void mem_serial_out(struct uart_p
33 writeb(value, p->membase + offset);
34 }
35
36 +static unsigned int memdelay_serial_in(struct uart_port *p, int offset)
37 +{
38 + struct uart_8250_port *up = (struct uart_8250_port *)p;
39 + udelay(up->port.rw_delay);
40 + return mem_serial_in(p, offset);
41 +}
42 +
43 +static void memdelay_serial_out(struct uart_port *p, int offset, int value)
44 +{
45 + struct uart_8250_port *up = (struct uart_8250_port *)p;
46 + udelay(up->port.rw_delay);
47 + mem_serial_out(p, offset, value);
48 +}
49 +
50 static void mem32_serial_out(struct uart_port *p, int offset, int value)
51 {
52 offset = map_8250_out_reg(p, offset) << p->regshift;
53 @@ -459,6 +473,11 @@ static void set_io_from_upio(struct uart
54 p->serial_out = mem32_serial_out;
55 break;
56
57 + case UPIO_MEM_DELAY:
58 + p->serial_in = memdelay_serial_in;
59 + p->serial_out = memdelay_serial_out;
60 + break;
61 +
62 case UPIO_AU:
63 p->serial_in = au_serial_in;
64 p->serial_out = au_serial_out;
65 @@ -481,6 +500,7 @@ serial_out_sync(struct uart_8250_port *u
66 switch (p->iotype) {
67 case UPIO_MEM:
68 case UPIO_MEM32:
69 + case UPIO_MEM_DELAY:
70 case UPIO_AU:
71 p->serial_out(p, offset, value);
72 p->serial_in(p, UART_LCR); /* safe, no side-effects */
73 @@ -2498,6 +2518,7 @@ static int serial8250_request_std_resour
74 case UPIO_TSI:
75 case UPIO_MEM32:
76 case UPIO_MEM:
77 + case UPIO_MEM_DELAY:
78 if (!up->port.mapbase)
79 break;
80
81 @@ -2534,6 +2555,7 @@ static void serial8250_release_std_resou
82 case UPIO_TSI:
83 case UPIO_MEM32:
84 case UPIO_MEM:
85 + case UPIO_MEM_DELAY:
86 if (!up->port.mapbase)
87 break;
88
89 @@ -3050,6 +3072,7 @@ static int __devinit serial8250_probe(st
90 port.set_termios = p->set_termios;
91 port.pm = p->pm;
92 port.dev = &dev->dev;
93 + port.rw_delay = p->rw_delay;
94 port.irqflags |= irqflag;
95 ret = serial8250_register_port(&port);
96 if (ret < 0) {
97 @@ -3199,6 +3222,7 @@ int serial8250_register_port(struct uart
98 uart->port.iotype = port->iotype;
99 uart->port.flags = port->flags | UPF_BOOT_AUTOCONF;
100 uart->port.mapbase = port->mapbase;
101 + uart->port.rw_delay = port->rw_delay;
102 uart->port.private_data = port->private_data;
103 if (port->dev)
104 uart->port.dev = port->dev;
105 --- a/drivers/tty/serial/serial_core.c
106 +++ b/drivers/tty/serial/serial_core.c
107 @@ -2021,6 +2021,7 @@ uart_report_port(struct uart_driver *drv
108 snprintf(address, sizeof(address),
109 "I/O 0x%lx offset 0x%x", port->iobase, port->hub6);
110 break;
111 + case UPIO_MEM_DELAY:
112 case UPIO_MEM:
113 case UPIO_MEM32:
114 case UPIO_AU:
115 @@ -2435,6 +2436,7 @@ int uart_match_port(struct uart_port *po
116 case UPIO_HUB6:
117 return (port1->iobase == port2->iobase) &&
118 (port1->hub6 == port2->hub6);
119 + case UPIO_MEM_DELAY:
120 case UPIO_MEM:
121 case UPIO_MEM32:
122 case UPIO_AU: