Commit bf4861cf3e7df123c0c62f00ae2c301c292f669c

Authored by Peter Ma
Committed by Haavard Skinnemoen
1 parent a6b6b5ff8f

avr32: add RTS/CTS/CLK pin selection for the USARTs

Adds extra parameter to AT32 at32_map_usart(), so as to reserve
RTS/CTS/CLK pins.

All boards under arch/avr32/boards have been updated (trivial change), but
not all have been tested.

Signed-off-by: Peter Ma <pma@mediamatech.com>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>

Showing 10 changed files with 47 additions and 30 deletions Side-by-side Diff

arch/avr32/boards/atngw100/setup.c
... ... @@ -118,7 +118,7 @@
118 118  
119 119 void __init setup_board(void)
120 120 {
121   - at32_map_usart(1, 0); /* USART 1: /dev/ttyS0, DB9 */
  121 + at32_map_usart(1, 0, 0); /* USART 1: /dev/ttyS0, DB9 */
122 122 at32_setup_serial_console(0);
123 123 }
124 124  
arch/avr32/boards/atstk1000/atstk1002.c
... ... @@ -252,12 +252,12 @@
252 252 void __init setup_board(void)
253 253 {
254 254 #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
255   - at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
  255 + at32_map_usart(0, 1, 0); /* USART 0/B: /dev/ttyS1, IRDA */
256 256 #else
257   - at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
  257 + at32_map_usart(1, 0, 0); /* USART 1/A: /dev/ttyS0, DB9 */
258 258 #endif
259 259 /* USART 2/unused: expansion connector */
260   - at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */
  260 + at32_map_usart(3, 2, 0); /* USART 3/C: /dev/ttyS2, DB9 */
261 261  
262 262 at32_setup_serial_console(0);
263 263 }
arch/avr32/boards/atstk1000/atstk1003.c
... ... @@ -115,12 +115,12 @@
115 115 void __init setup_board(void)
116 116 {
117 117 #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
118   - at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
  118 + at32_map_usart(0, 1, 0); /* USART 0/B: /dev/ttyS1, IRDA */
119 119 #else
120   - at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
  120 + at32_map_usart(1, 0, 0); /* USART 1/A: /dev/ttyS0, DB9 */
121 121 #endif
122 122 /* USART 2/unused: expansion connector */
123   - at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */
  123 + at32_map_usart(3, 2, 0); /* USART 3/C: /dev/ttyS2, DB9 */
124 124  
125 125 at32_setup_serial_console(0);
126 126 }
arch/avr32/boards/atstk1000/atstk1004.c
... ... @@ -120,12 +120,12 @@
120 120 void __init setup_board(void)
121 121 {
122 122 #ifdef CONFIG_BOARD_ATSTK100X_SW2_CUSTOM
123   - at32_map_usart(0, 1); /* USART 0/B: /dev/ttyS1, IRDA */
  123 + at32_map_usart(0, 1, 0); /* USART 0/B: /dev/ttyS1, IRDA */
124 124 #else
125   - at32_map_usart(1, 0); /* USART 1/A: /dev/ttyS0, DB9 */
  125 + at32_map_usart(1, 0, 0); /* USART 1/A: /dev/ttyS0, DB9 */
126 126 #endif
127 127 /* USART 2/unused: expansion connector */
128   - at32_map_usart(3, 2); /* USART 3/C: /dev/ttyS2, DB9 */
  128 + at32_map_usart(3, 2, 0); /* USART 3/C: /dev/ttyS2, DB9 */
129 129  
130 130 at32_setup_serial_console(0);
131 131 }
arch/avr32/boards/favr-32/setup.c
... ... @@ -250,7 +250,7 @@
250 250  
251 251 void __init setup_board(void)
252 252 {
253   - at32_map_usart(3, 0); /* USART 3 => /dev/ttyS0 */
  253 + at32_map_usart(3, 0, 0); /* USART 3 => /dev/ttyS0 */
254 254 at32_setup_serial_console(0);
255 255 }
256 256  
arch/avr32/boards/hammerhead/setup.c
... ... @@ -165,7 +165,7 @@
165 165  
166 166 void __init setup_board(void)
167 167 {
168   - at32_map_usart(1, 0); /* USART 1: /dev/ttyS0, DB9 */
  168 + at32_map_usart(1, 0, 0); /* USART 1: /dev/ttyS0, DB9 */
169 169 at32_setup_serial_console(0);
170 170 }
171 171  
arch/avr32/boards/merisc/setup.c
... ... @@ -231,9 +231,9 @@
231 231  
232 232 void __init setup_board(void)
233 233 {
234   - at32_map_usart(0, 0);
235   - at32_map_usart(1, 1);
236   - at32_map_usart(3, 3);
  234 + at32_map_usart(0, 0, 0);
  235 + at32_map_usart(1, 1, 0);
  236 + at32_map_usart(3, 3, 0);
237 237 at32_setup_serial_console(1);
238 238 }
239 239  
... ... @@ -248,7 +248,7 @@
248 248 at32_reserve_pin(GPIO_PIOE_BASE, ATMEL_EBI_PE_DATA_ALL | (1 << 26));
249 249  
250 250 if (merisc_board_id >= 1)
251   - at32_map_usart(2, 2);
  251 + at32_map_usart(2, 2, 0);
252 252  
253 253 at32_add_device_usart(0);
254 254 at32_add_device_usart(1);
arch/avr32/boards/mimc200/setup.c
... ... @@ -175,10 +175,10 @@
175 175  
176 176 void __init setup_board(void)
177 177 {
178   - at32_map_usart(0, 0); /* USART 0: /dev/ttyS0 (TTL --> Altera) */
179   - at32_map_usart(1, 1); /* USART 1: /dev/ttyS1 (RS232) */
180   - at32_map_usart(2, 2); /* USART 2: /dev/ttyS2 (RS485) */
181   - at32_map_usart(3, 3); /* USART 3: /dev/ttyS3 (RS422 Multidrop) */
  178 + at32_map_usart(0, 0, 0); /* USART 0: /dev/ttyS0 (TTL --> Altera) */
  179 + at32_map_usart(1, 1, 0); /* USART 1: /dev/ttyS1 (RS232) */
  180 + at32_map_usart(2, 2, 0); /* USART 2: /dev/ttyS2 (RS485) */
  181 + at32_map_usart(3, 3, 0); /* USART 3: /dev/ttyS3 (RS422 Multidrop) */
182 182 }
183 183  
184 184 static struct i2c_gpio_platform_data i2c_gpio_data = {
arch/avr32/mach-at32ap/at32ap700x.c
... ... @@ -966,56 +966,68 @@
966 966 DEFINE_DEV_DATA(atmel_usart, 3);
967 967 DEV_CLK(usart, atmel_usart3, pba, 6);
968 968  
969   -static inline void configure_usart0_pins(void)
  969 +static inline void configure_usart0_pins(int flags)
970 970 {
971 971 u32 pin_mask = (1 << 8) | (1 << 9); /* RXD & TXD */
  972 + if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 6);
  973 + if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 7);
  974 + if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 10);
972 975  
973 976 select_peripheral(PIOA, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
974 977 }
975 978  
976   -static inline void configure_usart1_pins(void)
  979 +static inline void configure_usart1_pins(int flags)
977 980 {
978 981 u32 pin_mask = (1 << 17) | (1 << 18); /* RXD & TXD */
  982 + if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 19);
  983 + if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 20);
  984 + if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 16);
979 985  
980 986 select_peripheral(PIOA, pin_mask, PERIPH_A, AT32_GPIOF_PULLUP);
981 987 }
982 988  
983   -static inline void configure_usart2_pins(void)
  989 +static inline void configure_usart2_pins(int flags)
984 990 {
985 991 u32 pin_mask = (1 << 26) | (1 << 27); /* RXD & TXD */
  992 + if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 30);
  993 + if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 29);
  994 + if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 28);
986 995  
987 996 select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
988 997 }
989 998  
990   -static inline void configure_usart3_pins(void)
  999 +static inline void configure_usart3_pins(int flags)
991 1000 {
992 1001 u32 pin_mask = (1 << 18) | (1 << 17); /* RXD & TXD */
  1002 + if (flags & ATMEL_USART_RTS) pin_mask |= (1 << 16);
  1003 + if (flags & ATMEL_USART_CTS) pin_mask |= (1 << 15);
  1004 + if (flags & ATMEL_USART_CLK) pin_mask |= (1 << 19);
993 1005  
994 1006 select_peripheral(PIOB, pin_mask, PERIPH_B, AT32_GPIOF_PULLUP);
995 1007 }
996 1008  
997 1009 static struct platform_device *__initdata at32_usarts[4];
998 1010  
999   -void __init at32_map_usart(unsigned int hw_id, unsigned int line)
  1011 +void __init at32_map_usart(unsigned int hw_id, unsigned int line, int flags)
1000 1012 {
1001 1013 struct platform_device *pdev;
1002 1014  
1003 1015 switch (hw_id) {
1004 1016 case 0:
1005 1017 pdev = &atmel_usart0_device;
1006   - configure_usart0_pins();
  1018 + configure_usart0_pins(flags);
1007 1019 break;
1008 1020 case 1:
1009 1021 pdev = &atmel_usart1_device;
1010   - configure_usart1_pins();
  1022 + configure_usart1_pins(flags);
1011 1023 break;
1012 1024 case 2:
1013 1025 pdev = &atmel_usart2_device;
1014   - configure_usart2_pins();
  1026 + configure_usart2_pins(flags);
1015 1027 break;
1016 1028 case 3:
1017 1029 pdev = &atmel_usart3_device;
1018   - configure_usart3_pins();
  1030 + configure_usart3_pins(flags);
1019 1031 break;
1020 1032 default:
1021 1033 return;
arch/avr32/mach-at32ap/include/mach/board.h
... ... @@ -26,12 +26,17 @@
26 26 #define ATMEL_MAX_UART 4
27 27 extern struct platform_device *atmel_default_console_device;
28 28  
  29 +/* Flags for selecting USART extra pins */
  30 +#define ATMEL_USART_RTS 0x01
  31 +#define ATMEL_USART_CTS 0x02
  32 +#define ATMEL_USART_CLK 0x03
  33 +
29 34 struct atmel_uart_data {
30 35 short use_dma_tx; /* use transmit DMA? */
31 36 short use_dma_rx; /* use receive DMA? */
32 37 void __iomem *regs; /* virtual base address, if any */
33 38 };
34   -void at32_map_usart(unsigned int hw_id, unsigned int line);
  39 +void at32_map_usart(unsigned int hw_id, unsigned int line, int flags);
35 40 struct platform_device *at32_add_device_usart(unsigned int id);
36 41  
37 42 struct eth_platform_data {