160-delayed_uart_io.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. --- a/drivers/tty/serial/8250/8250_core.c
  2. +++ b/drivers/tty/serial/8250/8250_core.c
  3. @@ -825,6 +825,7 @@ static int serial8250_probe(struct platf
  4. uart.port.set_termios = p->set_termios;
  5. uart.port.pm = p->pm;
  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);
  10. if (ret < 0) {
  11. @@ -981,6 +982,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. @@ -2185,6 +2185,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);
  24. break;
  25. + case UPIO_MEM_DELAY:
  26. case UPIO_MEM:
  27. case UPIO_MEM32:
  28. case UPIO_MEM32BE:
  29. @@ -2830,6 +2831,7 @@ int uart_match_port(struct uart_port *po
  30. case UPIO_HUB6:
  31. return (port1->iobase == port2->iobase) &&
  32. (port1->hub6 == port2->hub6);
  33. + case UPIO_MEM_DELAY:
  34. case UPIO_MEM:
  35. case UPIO_MEM32:
  36. case UPIO_MEM32BE:
  37. --- a/include/linux/serial_8250.h
  38. +++ b/include/linux/serial_8250.h
  39. @@ -28,6 +28,7 @@ struct plat_serial8250_port {
  40. void *private_data;
  41. unsigned char regshift; /* register shift */
  42. unsigned char iotype; /* UPIO_* */
  43. + unsigned int rw_delay; /* udelay for slower busses IXP4XX Expansion Bus */
  44. unsigned char hub6;
  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. @@ -150,6 +150,7 @@ struct uart_port {
  50. #define UPIO_AU (SERIAL_IO_AU) /* Au1x00 and RT288x type IO */
  51. #define UPIO_TSI (SERIAL_IO_TSI) /* Tsi108/109 type IO */
  52. #define UPIO_MEM32BE (SERIAL_IO_MEM32BE) /* 32b big endian */
  53. +#define UPIO_MEM_DELAY (SERIAL_IO_MEM_DELAY)
  54. unsigned int read_status_mask; /* driver specific */
  55. unsigned int ignore_status_mask; /* driver specific */
  56. @@ -231,6 +232,7 @@ struct uart_port {
  57. int hw_stopped; /* sw-assisted CTS flow state */
  58. unsigned int mctrl; /* current modem ctrl settings */
  59. unsigned int timeout; /* character-based timeout */
  60. + unsigned int rw_delay; /* udelay for slow busses, IXP4XX Expansion Bus */
  61. unsigned int type; /* port type */
  62. const struct uart_ops *ops;
  63. unsigned int custom_divisor;
  64. --- a/include/uapi/linux/serial.h
  65. +++ b/include/uapi/linux/serial.h
  66. @@ -69,6 +69,7 @@ struct serial_struct {
  67. #define SERIAL_IO_AU 4
  68. #define SERIAL_IO_TSI 5
  69. #define SERIAL_IO_MEM32BE 6
  70. +#define SERIAL_IO_MEM_DELAY 7
  71. #define UART_CLEAR_FIFO 0x01
  72. #define UART_USE_FIFO 0x02
  73. --- a/drivers/tty/serial/8250/8250_port.c
  74. +++ b/drivers/tty/serial/8250/8250_port.c
  75. @@ -368,6 +368,20 @@ static void mem_serial_out(struct uart_p
  76. writeb(value, p->membase + offset);
  77. }
  78. +static unsigned int memdelay_serial_in(struct uart_port *p, int offset)
  79. +{
  80. + struct uart_8250_port *up = (struct uart_8250_port *)p;
  81. + udelay(up->port.rw_delay);
  82. + return mem_serial_in(p, offset);
  83. +}
  84. +
  85. +static void memdelay_serial_out(struct uart_port *p, int offset, int value)
  86. +{
  87. + struct uart_8250_port *up = (struct uart_8250_port *)p;
  88. + udelay(up->port.rw_delay);
  89. + mem_serial_out(p, offset, value);
  90. +}
  91. +
  92. static void mem32_serial_out(struct uart_port *p, int offset, int value)
  93. {
  94. offset = offset << p->regshift;
  95. @@ -435,6 +449,11 @@ static void set_io_from_upio(struct uart
  96. p->serial_out = mem32be_serial_out;
  97. break;
  98. + case UPIO_MEM_DELAY:
  99. + p->serial_in = memdelay_serial_in;
  100. + p->serial_out = memdelay_serial_out;
  101. + break;
  102. +
  103. #ifdef CONFIG_SERIAL_8250_RT288X
  104. case UPIO_AU:
  105. p->serial_in = au_serial_in;
  106. @@ -461,6 +480,7 @@ serial_port_out_sync(struct uart_port *p
  107. case UPIO_MEM:
  108. case UPIO_MEM32:
  109. case UPIO_MEM32BE:
  110. + case UPIO_MEM_DELAY:
  111. case UPIO_AU:
  112. p->serial_out(p, offset, value);
  113. p->serial_in(p, UART_LCR); /* safe, no side-effects */
  114. @@ -2460,6 +2480,7 @@ static int serial8250_request_std_resour
  115. case UPIO_MEM32:
  116. case UPIO_MEM32BE:
  117. case UPIO_MEM:
  118. + case UPIO_MEM_DELAY:
  119. if (!port->mapbase)
  120. break;
  121. @@ -2497,6 +2518,7 @@ static void serial8250_release_std_resou
  122. case UPIO_MEM32:
  123. case UPIO_MEM32BE:
  124. case UPIO_MEM:
  125. + case UPIO_MEM_DELAY:
  126. if (!port->mapbase)
  127. break;