160-delayed_uart_io.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. --- a/drivers/tty/serial/8250/8250_core.c
  2. +++ b/drivers/tty/serial/8250/8250_core.c
  3. @@ -416,6 +416,20 @@ static void mem_serial_out(struct uart_p
  4. writeb(value, p->membase + offset);
  5. }
  6. +static unsigned int memdelay_serial_in(struct uart_port *p, int offset)
  7. +{
  8. + struct uart_8250_port *up = (struct uart_8250_port *)p;
  9. + udelay(up->port.rw_delay);
  10. + return mem_serial_in(p, offset);
  11. +}
  12. +
  13. +static void memdelay_serial_out(struct uart_port *p, int offset, int value)
  14. +{
  15. + struct uart_8250_port *up = (struct uart_8250_port *)p;
  16. + udelay(up->port.rw_delay);
  17. + mem_serial_out(p, offset, value);
  18. +}
  19. +
  20. static void mem32_serial_out(struct uart_port *p, int offset, int value)
  21. {
  22. offset = offset << p->regshift;
  23. @@ -466,6 +480,11 @@ static void set_io_from_upio(struct uart
  24. p->serial_out = mem32_serial_out;
  25. break;
  26. + case UPIO_MEM_DELAY:
  27. + p->serial_in = memdelay_serial_in;
  28. + p->serial_out = memdelay_serial_out;
  29. + break;
  30. +
  31. #if defined(CONFIG_MIPS_ALCHEMY) || defined(CONFIG_SERIAL_8250_RT288X)
  32. case UPIO_AU:
  33. p->serial_in = au_serial_in;
  34. @@ -491,6 +510,7 @@ serial_port_out_sync(struct uart_port *p
  35. switch (p->iotype) {
  36. case UPIO_MEM:
  37. case UPIO_MEM32:
  38. + case UPIO_MEM_DELAY:
  39. case UPIO_AU:
  40. p->serial_out(p, offset, value);
  41. p->serial_in(p, UART_LCR); /* safe, no side-effects */
  42. @@ -2655,6 +2675,7 @@ static int serial8250_request_std_resour
  43. case UPIO_TSI:
  44. case UPIO_MEM32:
  45. case UPIO_MEM:
  46. + case UPIO_MEM_DELAY:
  47. if (!port->mapbase)
  48. break;
  49. @@ -2691,6 +2712,7 @@ static void serial8250_release_std_resou
  50. case UPIO_TSI:
  51. case UPIO_MEM32:
  52. case UPIO_MEM:
  53. + case UPIO_MEM_DELAY:
  54. if (!port->mapbase)
  55. break;
  56. @@ -3424,6 +3446,7 @@ static int serial8250_probe(struct platf
  57. uart.port.set_termios = p->set_termios;
  58. uart.port.pm = p->pm;
  59. uart.port.dev = &dev->dev;
  60. + uart.port.rw_delay = p->rw_delay;
  61. uart.port.irqflags |= irqflag;
  62. ret = serial8250_register_8250_port(&uart);
  63. if (ret < 0) {
  64. @@ -3580,6 +3603,7 @@ int serial8250_register_8250_port(struct
  65. uart->port.flags = up->port.flags | UPF_BOOT_AUTOCONF;
  66. uart->bugs = up->bugs;
  67. uart->port.mapbase = up->port.mapbase;
  68. + uart->port.rw_delay = up->port.rw_delay;
  69. uart->port.private_data = up->port.private_data;
  70. uart->port.fifosize = up->port.fifosize;
  71. uart->tx_loadsz = up->tx_loadsz;
  72. --- a/drivers/tty/serial/serial_core.c
  73. +++ b/drivers/tty/serial/serial_core.c
  74. @@ -2090,6 +2090,7 @@ uart_report_port(struct uart_driver *drv
  75. snprintf(address, sizeof(address),
  76. "I/O 0x%lx offset 0x%x", port->iobase, port->hub6);
  77. break;
  78. + case UPIO_MEM_DELAY:
  79. case UPIO_MEM:
  80. case UPIO_MEM32:
  81. case UPIO_AU:
  82. @@ -2736,6 +2737,7 @@ int uart_match_port(struct uart_port *po
  83. case UPIO_HUB6:
  84. return (port1->iobase == port2->iobase) &&
  85. (port1->hub6 == port2->hub6);
  86. + case UPIO_MEM_DELAY:
  87. case UPIO_MEM:
  88. case UPIO_MEM32:
  89. case UPIO_AU:
  90. --- a/include/linux/serial_8250.h
  91. +++ b/include/linux/serial_8250.h
  92. @@ -27,6 +27,7 @@ struct plat_serial8250_port {
  93. void *private_data;
  94. unsigned char regshift; /* register shift */
  95. unsigned char iotype; /* UPIO_* */
  96. + unsigned int rw_delay; /* udelay for slower busses IXP4XX Expansion Bus */
  97. unsigned char hub6;
  98. upf_t flags; /* UPF_* flags */
  99. unsigned int type; /* If UPF_FIXED_TYPE */
  100. --- a/include/linux/serial_core.h
  101. +++ b/include/linux/serial_core.h
  102. @@ -146,6 +146,7 @@ struct uart_port {
  103. #define UPIO_MEM32 (3)
  104. #define UPIO_AU (4) /* Au1x00 and RT288x type IO */
  105. #define UPIO_TSI (5) /* Tsi108/109 type IO */
  106. +#define UPIO_MEM_DELAY (6)
  107. unsigned int read_status_mask; /* driver specific */
  108. unsigned int ignore_status_mask; /* driver specific */
  109. @@ -202,6 +203,7 @@ struct uart_port {
  110. int hw_stopped; /* sw-assisted CTS flow state */
  111. unsigned int mctrl; /* current modem ctrl settings */
  112. unsigned int timeout; /* character-based timeout */
  113. + unsigned int rw_delay; /* udelay for slow busses, IXP4XX Expansion Bus */
  114. unsigned int type; /* port type */
  115. const struct uart_ops *ops;
  116. unsigned int custom_divisor;