101-rt288x_serial_driver_hack.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. --- a/drivers/serial/8250.c
  2. +++ b/drivers/serial/8250.c
  3. @@ -289,9 +289,9 @@ static const struct serial8250_config ua
  4. },
  5. };
  6. -#if defined (CONFIG_SERIAL_8250_AU1X00)
  7. +#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
  8. -/* Au1x00 UART hardware has a weird register layout */
  9. +/* Au1x00 and RT288x UART hardware has a weird register layout */
  10. static const u8 au_io_in_map[] = {
  11. [UART_RX] = 0,
  12. [UART_IER] = 2,
  13. @@ -409,7 +409,7 @@ static unsigned int mem32_serial_in(stru
  14. return readl(p->membase + offset);
  15. }
  16. -#ifdef CONFIG_SERIAL_8250_AU1X00
  17. +#if defined(CONFIG_SERIAL_8250_AU1X00) || defined(CONFIG_SERIAL_8250_RT288X)
  18. static unsigned int au_serial_in(struct uart_port *p, int offset)
  19. {
  20. offset = map_8250_in_reg(p, offset) << p->regshift;
  21. @@ -490,7 +490,7 @@ static void set_io_from_upio(struct uart
  22. p->serial_out = mem32_serial_out;
  23. break;
  24. -#ifdef CONFIG_SERIAL_8250_AU1X00
  25. +#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
  26. case UPIO_AU:
  27. p->serial_in = au_serial_in;
  28. p->serial_out = au_serial_out;
  29. @@ -522,7 +522,7 @@ serial_out_sync(struct uart_8250_port *u
  30. switch (p->iotype) {
  31. case UPIO_MEM:
  32. case UPIO_MEM32:
  33. -#ifdef CONFIG_SERIAL_8250_AU1X00
  34. +#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
  35. case UPIO_AU:
  36. #endif
  37. case UPIO_DWAPB:
  38. @@ -560,8 +560,8 @@ static inline void _serial_dl_write(stru
  39. serial_outp(up, UART_DLM, value >> 8 & 0xff);
  40. }
  41. -#if defined(CONFIG_SERIAL_8250_AU1X00)
  42. -/* Au1x00 haven't got a standard divisor latch */
  43. +#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
  44. +/* Au1x00 and RT288x haven't got a standard divisor latch */
  45. static int serial_dl_read(struct uart_8250_port *up)
  46. {
  47. if (up->port.iotype == UPIO_AU)
  48. @@ -768,22 +768,19 @@ static int size_fifo(struct uart_8250_po
  49. */
  50. static unsigned int autoconfig_read_divisor_id(struct uart_8250_port *p)
  51. {
  52. - unsigned char old_dll, old_dlm, old_lcr;
  53. + unsigned char old_lcr;
  54. + unsigned int old_dl;
  55. unsigned int id;
  56. old_lcr = serial_inp(p, UART_LCR);
  57. serial_outp(p, UART_LCR, UART_LCR_DLAB);
  58. - old_dll = serial_inp(p, UART_DLL);
  59. - old_dlm = serial_inp(p, UART_DLM);
  60. + old_dl = serial_dl_read(p);
  61. - serial_outp(p, UART_DLL, 0);
  62. - serial_outp(p, UART_DLM, 0);
  63. + serial_dl_write(p, 0);
  64. + id = serial_dl_read(p);
  65. - id = serial_inp(p, UART_DLL) | serial_inp(p, UART_DLM) << 8;
  66. -
  67. - serial_outp(p, UART_DLL, old_dll);
  68. - serial_outp(p, UART_DLM, old_dlm);
  69. + serial_dl_write(p, old_dl);
  70. serial_outp(p, UART_LCR, old_lcr);
  71. return id;
  72. @@ -1205,7 +1202,7 @@ static void autoconfig(struct uart_8250_
  73. }
  74. #endif
  75. -#ifdef CONFIG_SERIAL_8250_AU1X00
  76. +#if defined (CONFIG_SERIAL_8250_AU1X00) || defined (CONFIG_SERIAL_8250_RT288X)
  77. /* if access method is AU, it is a 16550 with a quirk */
  78. if (up->port.type == PORT_16550A && up->port.iotype == UPIO_AU)
  79. up->bugs |= UART_BUG_NOMSR;
  80. --- a/drivers/serial/Kconfig
  81. +++ b/drivers/serial/Kconfig
  82. @@ -266,6 +266,14 @@ config SERIAL_8250_AU1X00
  83. say Y to this option. The driver can handle up to 4 serial ports,
  84. depending on the SOC. If unsure, say N.
  85. +config SERIAL_8250_RT288X
  86. + bool "Ralink RT288x/RT305x serial port support"
  87. + depends on SERIAL_8250 != n && (SOC_RT288X || SOC_RT305X)
  88. + help
  89. + If you have a Ralink RT288x/RT305x SoC based board and want to use the
  90. + serial port, say Y to this option. The driver can handle up to 2 serial
  91. + ports. If unsure, say N.
  92. +
  93. config SERIAL_8250_RM9K
  94. bool "Support for MIPS RM9xxx integrated serial port"
  95. depends on SERIAL_8250 != n && SERIAL_RM9000
  96. --- a/include/linux/serial_core.h
  97. +++ b/include/linux/serial_core.h
  98. @@ -269,7 +269,7 @@ struct uart_port {
  99. #define UPIO_HUB6 (1)
  100. #define UPIO_MEM (2)
  101. #define UPIO_MEM32 (3)
  102. -#define UPIO_AU (4) /* Au1x00 type IO */
  103. +#define UPIO_AU (4) /* Au1x00 and RT288x type IO */
  104. #define UPIO_TSI (5) /* Tsi108/109 type IO */
  105. #define UPIO_DWAPB (6) /* DesignWare APB UART */
  106. #define UPIO_RM9000 (7) /* RM9000 type IO */