ramips: add support for 3.3
[openwrt.git] / target / linux / ramips / patches-3.3 / 101-rt288x_serial_driver_hack.patch
1 --- a/drivers/tty/serial/8250/Kconfig
2 +++ b/drivers/tty/serial/8250/Kconfig
3 @@ -258,6 +258,14 @@ config SERIAL_8250_ACORN
4           system, say Y to this option.  The driver can handle 1, 2, or 3 port
5           cards.  If unsure, say N.
6  
7 +config SERIAL_8250_RT288X
8 +       bool "Ralink RT288x/RT305x/RT3662/RT3883 serial port support"
9 +       depends on SERIAL_8250 != n && (SOC_RT288X || SOC_RT305X || SOC_RT3883)
10 +       help
11 +         If you have a Ralink RT288x/RT305x SoC based board and want to use the
12 +         serial port, say Y to this option. The driver can handle up to 2 serial
13 +         ports. If unsure, say N.
14 +
15  config SERIAL_8250_RM9K
16         bool "Support for MIPS RM9xxx integrated serial port"
17         depends on SERIAL_8250 != n && SERIAL_RM9000
18 --- a/include/linux/serial_core.h
19 +++ b/include/linux/serial_core.h
20 @@ -321,7 +321,7 @@ struct uart_port {
21  #define UPIO_HUB6              (1)
22  #define UPIO_MEM               (2)
23  #define UPIO_MEM32             (3)
24 -#define UPIO_AU                        (4)                     /* Au1x00 type IO */
25 +#define UPIO_AU                        (4)                     /* Au1x00 and RT288x type IO */
26  #define UPIO_TSI               (5)                     /* Tsi108/109 type IO */
27  #define UPIO_RM9000            (6)                     /* RM9000 type IO */
28  
29 --- a/drivers/tty/serial/8250/8250.c
30 +++ b/drivers/tty/serial/8250/8250.c
31 @@ -292,9 +292,9 @@ static const struct serial8250_config ua
32         },
33  };
34  
35 -#if defined(CONFIG_MIPS_ALCHEMY)
36 +#if defined(CONFIG_MIPS_ALCHEMY) || defined (CONFIG_SERIAL_8250_RT288X)
37  
38 -/* Au1x00 UART hardware has a weird register layout */
39 +/* Au1x00 and RT288x UART hardware has a weird register layout */
40  static const u8 au_io_in_map[] = {
41         [UART_RX]  = 0,
42         [UART_IER] = 2,
43 @@ -516,8 +516,8 @@ static inline void _serial_dl_write(stru
44         serial_outp(up, UART_DLM, value >> 8 & 0xff);
45  }
46  
47 -#if defined(CONFIG_MIPS_ALCHEMY)
48 -/* Au1x00 haven't got a standard divisor latch */
49 +#if defined(CONFIG_MIPS_ALCHEMY) || defined (CONFIG_SERIAL_8250_RT288X)
50 +/* Au1x00 and RT288x haven't got a standard divisor latch */
51  static int serial_dl_read(struct uart_8250_port *up)
52  {
53         if (up->port.iotype == UPIO_AU)
54 @@ -724,22 +724,19 @@ static int size_fifo(struct uart_8250_po
55   */
56  static unsigned int autoconfig_read_divisor_id(struct uart_8250_port *p)
57  {
58 -       unsigned char old_dll, old_dlm, old_lcr;
59 +       unsigned char old_lcr;
60 +       unsigned int old_dl;
61         unsigned int id;
62  
63         old_lcr = serial_inp(p, UART_LCR);
64         serial_outp(p, UART_LCR, UART_LCR_CONF_MODE_A);
65  
66 -       old_dll = serial_inp(p, UART_DLL);
67 -       old_dlm = serial_inp(p, UART_DLM);
68 +       old_dl = serial_dl_read(p);
69  
70 -       serial_outp(p, UART_DLL, 0);
71 -       serial_outp(p, UART_DLM, 0);
72 +       serial_dl_write(p, 0);
73 +       id = serial_dl_read(p);
74  
75 -       id = serial_inp(p, UART_DLL) | serial_inp(p, UART_DLM) << 8;
76 -
77 -       serial_outp(p, UART_DLL, old_dll);
78 -       serial_outp(p, UART_DLM, old_dlm);
79 +       serial_dl_write(p, old_dl);
80         serial_outp(p, UART_LCR, old_lcr);
81  
82         return id;
83 @@ -865,7 +862,7 @@ static int broken_efr(struct uart_8250_p
84         /*
85          * Exar ST16C2550 "A2" devices incorrectly detect as
86          * having an EFR, and report an ID of 0x0201.  See
87 -        * http://linux.derkeiler.com/Mailing-Lists/Kernel/2004-11/4812.html 
88 +        * http://linux.derkeiler.com/Mailing-Lists/Kernel/2004-11/4812.html
89          */
90         if (autoconfig_read_divisor_id(up) == 0x0201 && size_fifo(up) == 16)
91                 return 1;