e44740d6f731a6631cc7adcb1ee03cbc05971af5
[openwrt/svn-archive/archive.git] / target / linux / ixp4xx / patches-4.1 / 160-delayed_uart_io.patch
1 --- a/drivers/tty/serial/8250/8250_core.c
2 +++ b/drivers/tty/serial/8250/8250_core.c
3 @@ -438,6 +438,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 @@ -505,6 +519,11 @@ static void set_io_from_upio(struct uart
25 p->serial_out = mem32be_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 @@ -531,6 +550,7 @@ serial_port_out_sync(struct uart_port *p
37 case UPIO_MEM:
38 case UPIO_MEM32:
39 case UPIO_MEM32BE:
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 @@ -2768,6 +2788,7 @@ static int serial8250_request_std_resour
45 case UPIO_MEM32:
46 case UPIO_MEM32BE:
47 case UPIO_MEM:
48 + case UPIO_MEM_DELAY:
49 if (!port->mapbase)
50 break;
51
52 @@ -2805,6 +2826,7 @@ static void serial8250_release_std_resou
53 case UPIO_MEM32:
54 case UPIO_MEM32BE:
55 case UPIO_MEM:
56 + case UPIO_MEM_DELAY:
57 if (!port->mapbase)
58 break;
59
60 @@ -3693,6 +3715,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 @@ -3849,6 +3872,7 @@ int serial8250_register_8250_port(struct
69 uart->bugs = up->bugs;
70 uart->port.mapbase = up->port.mapbase;
71 uart->port.mapsize = up->port.mapsize;
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 @@ -2177,6 +2177,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_MEM32BE:
86 @@ -2824,6 +2825,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_MEM32BE:
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 @@ -150,6 +150,7 @@ struct uart_port {
107 #define UPIO_AU (SERIAL_IO_AU) /* Au1x00 and RT288x type IO */
108 #define UPIO_TSI (SERIAL_IO_TSI) /* Tsi108/109 type IO */
109 #define UPIO_MEM32BE (SERIAL_IO_MEM32BE) /* 32b big endian */
110 +#define UPIO_MEM_DELAY (SERIAL_IO_MEM_DELAY)
111
112 unsigned int read_status_mask; /* driver specific */
113 unsigned int ignore_status_mask; /* driver specific */
114 @@ -231,6 +232,7 @@ struct uart_port {
115 int hw_stopped; /* sw-assisted CTS flow state */
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;
122 --- a/include/uapi/linux/serial.h
123 +++ b/include/uapi/linux/serial.h
124 @@ -69,6 +69,7 @@ struct serial_struct {
125 #define SERIAL_IO_AU 4
126 #define SERIAL_IO_TSI 5
127 #define SERIAL_IO_MEM32BE 6
128 +#define SERIAL_IO_MEM_DELAY 7
129
130 #define UART_CLEAR_FIFO 0x01
131 #define UART_USE_FIFO 0x02