1 --- a/drivers/tty/serial/8250/8250_core.c
2 +++ b/drivers/tty/serial/8250/8250_core.c
3 @@ -833,6 +833,7 @@ static int serial8250_probe(struct platf
4 uart.port.get_mctrl = p->get_mctrl;
6 uart.port.dev = &dev->dev;
7 + uart.port.rw_delay = p->rw_delay;
8 uart.port.irqflags |= irqflag;
9 ret = serial8250_register_8250_port(&uart);
11 @@ -989,6 +990,7 @@ int serial8250_register_8250_port(struct
12 uart->bugs = up->bugs;
13 uart->port.mapbase = up->port.mapbase;
14 uart->port.mapsize = up->port.mapsize;
15 + uart->port.rw_delay = up->port.rw_delay;
16 uart->port.private_data = up->port.private_data;
17 uart->tx_loadsz = up->tx_loadsz;
18 uart->capabilities = up->capabilities;
19 --- a/drivers/tty/serial/serial_core.c
20 +++ b/drivers/tty/serial/serial_core.c
21 @@ -2233,6 +2233,7 @@ uart_report_port(struct uart_driver *drv
22 snprintf(address, sizeof(address),
23 "I/O 0x%lx offset 0x%x", port->iobase, port->hub6);
25 + case UPIO_MEM_DELAY:
29 @@ -2897,6 +2898,7 @@ int uart_match_port(struct uart_port *po
31 return (port1->iobase == port2->iobase) &&
32 (port1->hub6 == port2->hub6);
33 + case UPIO_MEM_DELAY:
37 --- a/include/linux/serial_8250.h
38 +++ b/include/linux/serial_8250.h
39 @@ -28,6 +28,7 @@ struct plat_serial8250_port {
41 unsigned char regshift; /* register shift */
42 unsigned char iotype; /* UPIO_* */
43 + unsigned int rw_delay; /* udelay for slower busses IXP4XX Expansion Bus */
45 upf_t flags; /* UPF_* flags */
46 unsigned int type; /* If UPF_FIXED_TYPE */
47 --- a/include/linux/serial_core.h
48 +++ b/include/linux/serial_core.h
49 @@ -152,6 +152,7 @@ struct uart_port {
50 #define UPIO_TSI (SERIAL_IO_TSI) /* Tsi108/109 type IO */
51 #define UPIO_MEM32BE (SERIAL_IO_MEM32BE) /* 32b big endian */
52 #define UPIO_MEM16 (SERIAL_IO_MEM16) /* 16b little endian */
53 +#define UPIO_MEM_DELAY (SERIAL_IO_MEM_DELAY)
55 unsigned int read_status_mask; /* driver specific */
56 unsigned int ignore_status_mask; /* driver specific */
57 @@ -233,6 +234,7 @@ struct uart_port {
58 int hw_stopped; /* sw-assisted CTS flow state */
59 unsigned int mctrl; /* current modem ctrl settings */
60 unsigned int timeout; /* character-based timeout */
61 + unsigned int rw_delay; /* udelay for slow busses, IXP4XX Expansion Bus */
62 unsigned int type; /* port type */
63 const struct uart_ops *ops;
64 unsigned int custom_divisor;
65 --- a/drivers/tty/serial/8250/8250_port.c
66 +++ b/drivers/tty/serial/8250/8250_port.c
67 @@ -384,6 +384,20 @@ static unsigned int mem16_serial_in(stru
68 return readw(p->membase + offset);
71 +static unsigned int memdelay_serial_in(struct uart_port *p, int offset)
73 + struct uart_8250_port *up = (struct uart_8250_port *)p;
74 + udelay(up->port.rw_delay);
75 + return mem_serial_in(p, offset);
78 +static void memdelay_serial_out(struct uart_port *p, int offset, int value)
80 + struct uart_8250_port *up = (struct uart_8250_port *)p;
81 + udelay(up->port.rw_delay);
82 + mem_serial_out(p, offset, value);
85 static void mem32_serial_out(struct uart_port *p, int offset, int value)
87 offset = offset << p->regshift;
88 @@ -456,6 +470,11 @@ static void set_io_from_upio(struct uart
89 p->serial_out = mem32be_serial_out;
92 + case UPIO_MEM_DELAY:
93 + p->serial_in = memdelay_serial_in;
94 + p->serial_out = memdelay_serial_out;
97 #ifdef CONFIG_SERIAL_8250_RT288X
99 p->serial_in = au_serial_in;
100 @@ -483,6 +502,7 @@ serial_port_out_sync(struct uart_port *p
104 + case UPIO_MEM_DELAY:
106 p->serial_out(p, offset, value);
107 p->serial_in(p, UART_LCR); /* safe, no side-effects */
108 @@ -2760,6 +2780,7 @@ static int serial8250_request_std_resour
112 + case UPIO_MEM_DELAY:
116 @@ -2798,6 +2819,7 @@ static void serial8250_release_std_resou
120 + case UPIO_MEM_DELAY:
124 --- a/include/uapi/linux/serial.h
125 +++ b/include/uapi/linux/serial.h
126 @@ -70,6 +70,7 @@ struct serial_struct {
127 #define SERIAL_IO_TSI 5
128 #define SERIAL_IO_MEM32BE 6
129 #define SERIAL_IO_MEM16 7
130 +#define SERIAL_IO_MEM_DELAY 10
132 #define UART_CLEAR_FIFO 0x01
133 #define UART_USE_FIFO 0x02