aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/ixp4xx/patches-3.18/160-delayed_uart_io.patch
blob: 1c80d16bf0ebd5d88673f775811125ad7573e3d1 (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
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -410,6 +410,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 = offset << p->regshift;
@@ -461,6 +475,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;
+
 #if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X)
 	case UPIO_AU:
 		p->serial_in = au_serial_in;
@@ -486,6 +505,7 @@ serial_port_out_sync(struct uart_port *p
 	switch (p->iotype) {
 	case UPIO_MEM:
 	case UPIO_MEM32:
+	case UPIO_MEM_DELAY:
 	case UPIO_AU:
 		p->serial_out(p, offset, value);
 		p->serial_in(p, UART_LCR);	/* safe, no side-effects */
@@ -2538,6 +2558,7 @@ static int serial8250_request_std_resour
 	case UPIO_TSI:
 	case UPIO_MEM32:
 	case UPIO_MEM:
+	case UPIO_MEM_DELAY:
 		if (!port->mapbase)
 			break;
 
@@ -2574,6 +2595,7 @@ static void serial8250_release_std_resou
 	case UPIO_TSI:
 	case UPIO_MEM32:
 	case UPIO_MEM:
+	case UPIO_MEM_DELAY:
 		if (!port->mapbase)
 			break;
 
@@ -3113,6 +3135,7 @@ static int serial8250_probe(struct platf
 		uart.port.set_termios	= p->set_termios;
 		uart.port.pm		= p->pm;
 		uart.port.dev		= &dev->dev;
+		uart.port.rw_delay	= p->rw_delay;
 		uart.port.irqflags	|= irqflag;
 		ret = serial8250_register_8250_port(&uart);
 		if (ret < 0) {
@@ -3264,6 +3287,7 @@ int serial8250_register_8250_port(struct
 		uart->port.flags        = up->port.flags | UPF_BOOT_AUTOCONF;
 		uart->bugs		= up->bugs;
 		uart->port.mapbase      = up->port.mapbase;
+		uart->port.rw_delay	= up->port.rw_delay;
 		uart->port.private_data = up->port.private_data;
 		uart->port.fifosize	= up->port.fifosize;
 		uart->tx_loadsz		= up->tx_loadsz;
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2090,6 +2090,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:
@@ -2711,6 +2712,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:
--- 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
@@ -141,6 +141,7 @@ struct uart_port {
 #define UPIO_MEM32		(3)
 #define UPIO_AU			(4)			/* Au1x00 and RT288x type IO */
 #define UPIO_TSI		(5)			/* Tsi108/109 type IO */
+#define UPIO_MEM_DELAY		(6)
 
 	unsigned int		read_status_mask;	/* driver specific */
 	unsigned int		ignore_status_mask;	/* driver specific */
@@ -189,6 +190,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;