1 | /* |
---|
2 | * Console driver for for KIT637_V6 (CSB637) |
---|
3 | * |
---|
4 | * This driver uses the shared console driver in |
---|
5 | * ...../libbsp/shared/console.c |
---|
6 | * |
---|
7 | * Copyright (c) 2003 by Cogent Computer Systems |
---|
8 | * Written by Jay Monkman <jtm@lopingdog.com> |
---|
9 | * |
---|
10 | * Modified by Fernando Nicodemos <fgnicodemos@terra.com.br> |
---|
11 | * from NCB - Sistemas Embarcados Ltda. (Brazil) |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.com/license/LICENSE. |
---|
16 | * |
---|
17 | * Modified and FrameBuffer Console Device Support added by |
---|
18 | * Joel Sherrill, 2009. |
---|
19 | * |
---|
20 | * $Id$ |
---|
21 | */ |
---|
22 | |
---|
23 | #include <bsp.h> |
---|
24 | #include <rtems/libio.h> |
---|
25 | #include <termios.h> |
---|
26 | #include <rtems/bspIo.h> |
---|
27 | |
---|
28 | #include <at91rm9200.h> |
---|
29 | #include <at91rm9200_dbgu.h> |
---|
30 | #include <libchip/serial.h> |
---|
31 | #include <libchip/sersupp.h> |
---|
32 | #include <bspopts.h> |
---|
33 | |
---|
34 | /* rtems console uses the following minor number */ |
---|
35 | rtems_device_minor_number Console_Port_Minor = 0; |
---|
36 | extern console_fns dbgu_fns; |
---|
37 | |
---|
38 | #if ENABLE_LCD |
---|
39 | extern console_fns fbcons_fns; |
---|
40 | #define LCD_DEV 1 |
---|
41 | #else |
---|
42 | #define LCD_DEV 0 |
---|
43 | #endif |
---|
44 | |
---|
45 | #if (ENABLE_UMON && ENABLE_UMON_CONSOLE) |
---|
46 | extern console_fns umoncons_fns; |
---|
47 | #define UMON_CONS_DEV 1 |
---|
48 | #else |
---|
49 | #define UMON_CONS_DEV 0 |
---|
50 | #endif |
---|
51 | |
---|
52 | #if ENABLE_USART0 || ENABLE_USART1 || ENABLE_USART2 || ENABLE_USART3 |
---|
53 | extern console_fns usart_polling_fns; |
---|
54 | #endif |
---|
55 | |
---|
56 | #if ENABLE_USART0 |
---|
57 | #define USART0_DEV 1 |
---|
58 | #else |
---|
59 | #define USART0_DEV 0 |
---|
60 | #endif |
---|
61 | |
---|
62 | #if ENABLE_USART1 |
---|
63 | #define USART1_DEV 1 |
---|
64 | #else |
---|
65 | #define USART1_DEV 0 |
---|
66 | #endif |
---|
67 | |
---|
68 | #if ENABLE_USART2 |
---|
69 | #define USART2_DEV 1 |
---|
70 | #else |
---|
71 | #define USART2_DEV 0 |
---|
72 | #endif |
---|
73 | |
---|
74 | #if ENABLE_USART3 |
---|
75 | #define USART3_DEV 1 |
---|
76 | #else |
---|
77 | #define USART3_DEV 0 |
---|
78 | #endif |
---|
79 | |
---|
80 | #define NUM_DEVS \ |
---|
81 | (1 + LCD_DEV + UMON_CONS_DEV + \ |
---|
82 | USART0_DEV + USART1_DEV + USART2_DEV + USART3_DEV) |
---|
83 | |
---|
84 | /* These are used by code in console.c */ |
---|
85 | unsigned long Console_Port_Count = NUM_DEVS; |
---|
86 | console_data Console_Port_Data[NUM_DEVS]; |
---|
87 | |
---|
88 | /* |
---|
89 | * There's one item in array for each UART. |
---|
90 | * |
---|
91 | * Some of these fields are marked "NOT USED". They are not used |
---|
92 | * by console.c, but may be used by drivers in libchip |
---|
93 | * |
---|
94 | * when we add other types of UARTS we will need to move this |
---|
95 | * structure to a generic uart.c file with only this in it |
---|
96 | */ |
---|
97 | console_tbl Console_Port_Tbl[] = { |
---|
98 | { |
---|
99 | "/dev/console", /* sDeviceName */ |
---|
100 | SERIAL_CUSTOM, /* deviceType */ |
---|
101 | &dbgu_fns, /* pDeviceFns */ |
---|
102 | NULL, /* deviceProbe */ |
---|
103 | NULL, /* pDeviceFlow */ |
---|
104 | 0, /* ulMargin - NOT USED */ |
---|
105 | 0, /* ulHysteresis - NOT USED */ |
---|
106 | NULL, /* pDeviceParams */ |
---|
107 | DBGU_BASE, /* ulCtrlPort1 - Pointer to DBGU regs */ |
---|
108 | 0, /* ulCtrlPort2 - NOT USED */ |
---|
109 | 0, /* ulDataPort - NOT USED */ |
---|
110 | NULL, /* getRegister - NOT USED */ |
---|
111 | NULL, /* setRegister - NOT USED */ |
---|
112 | NULL, /* getData - NOT USED */ |
---|
113 | NULL, /* setData - NOT USED */ |
---|
114 | 0, /* ulClock - NOT USED */ |
---|
115 | 0 /* ulIntVector - NOT USED */ |
---|
116 | }, |
---|
117 | #if ENABLE_LCD |
---|
118 | { |
---|
119 | "/dev/fbcons", /* sDeviceName */ |
---|
120 | SERIAL_CUSTOM, /* deviceType */ |
---|
121 | &fbcons_fns, /* pDeviceFns */ |
---|
122 | NULL, /* deviceProbe */ |
---|
123 | NULL, /* pDeviceFlow */ |
---|
124 | 0, /* ulMargin - NOT USED */ |
---|
125 | 0, /* ulHysteresis - NOT USED */ |
---|
126 | NULL, /* pDeviceParams */ |
---|
127 | 0, /* ulCtrlPort1 - Pointer to DBGU regs */ |
---|
128 | 0, /* ulCtrlPort2 - NOT USED */ |
---|
129 | 0, /* ulDataPort - NOT USED */ |
---|
130 | NULL, /* getRegister - NOT USED */ |
---|
131 | NULL, /* setRegister - NOT USED */ |
---|
132 | NULL, /* getData - NOT USED */ |
---|
133 | NULL, /* setData - NOT USED */ |
---|
134 | 0, /* ulClock - NOT USED */ |
---|
135 | 0 /* ulIntVector - NOT USED */ |
---|
136 | }, |
---|
137 | #endif |
---|
138 | #if ENABLE_UMON |
---|
139 | { |
---|
140 | "/dev/umon", /* sDeviceName */ |
---|
141 | SERIAL_CUSTOM, /* deviceType */ |
---|
142 | &umoncons_fns, /* pDeviceFns */ |
---|
143 | NULL, /* deviceProbe */ |
---|
144 | NULL, /* pDeviceFlow */ |
---|
145 | 0, /* ulMargin - NOT USED */ |
---|
146 | 0, /* ulHysteresis - NOT USED */ |
---|
147 | NULL, /* pDeviceParams */ |
---|
148 | 0, /* ulCtrlPort1 - Pointer to UMON regs */ |
---|
149 | 0, /* ulCtrlPort2 - NOT USED */ |
---|
150 | 0, /* ulDataPort - NOT USED */ |
---|
151 | NULL, /* getRegister - NOT USED */ |
---|
152 | NULL, /* setRegister - NOT USED */ |
---|
153 | NULL, /* getData - NOT USED */ |
---|
154 | NULL, /* setData - NOT USED */ |
---|
155 | 0, /* ulClock - NOT USED */ |
---|
156 | 0 /* ulIntVector - NOT USED */ |
---|
157 | }, |
---|
158 | #endif |
---|
159 | #if ENABLE_USART0 |
---|
160 | { |
---|
161 | "/dev/com1", /* sDeviceName */ |
---|
162 | SERIAL_CUSTOM, /* deviceType */ |
---|
163 | &usart_polling_fns,/* pDeviceFns */ |
---|
164 | NULL, /* deviceProbe */ |
---|
165 | NULL, /* pDeviceFlow */ |
---|
166 | 0, /* ulMargin - NOT USED */ |
---|
167 | 0, /* ulHysteresis - NOT USED */ |
---|
168 | NULL, /* pDeviceParams */ |
---|
169 | USART0_BASE, /* ulCtrlPort1 - Pointer to USART 0 regs */ |
---|
170 | 0, /* ulCtrlPort2 - NOT USED */ |
---|
171 | 0, /* ulDataPort - NOT USED */ |
---|
172 | NULL, /* getRegister - NOT USED */ |
---|
173 | NULL, /* setRegister - NOT USED */ |
---|
174 | NULL, /* getData - NOT USED */ |
---|
175 | NULL, /* setData - NOT USED */ |
---|
176 | 0, /* ulClock - NOT USED */ |
---|
177 | 0 /* ulIntVector - NOT USED */ |
---|
178 | }, |
---|
179 | #endif |
---|
180 | #if ENABLE_USART1 |
---|
181 | { |
---|
182 | "/dev/com2", /* sDeviceName */ |
---|
183 | SERIAL_CUSTOM, /* deviceType */ |
---|
184 | &usart_polling_fns,/* pDeviceFns */ |
---|
185 | NULL, /* deviceProbe */ |
---|
186 | NULL, /* pDeviceFlow */ |
---|
187 | 0, /* ulMargin - NOT USED */ |
---|
188 | 0, /* ulHysteresis - NOT USED */ |
---|
189 | NULL, /* pDeviceParams */ |
---|
190 | USART1_BASE, /* ulCtrlPort1 - Pointer to USART 1 regs */ |
---|
191 | 0, /* ulCtrlPort2 - NOT USED */ |
---|
192 | 0, /* ulDataPort - NOT USED */ |
---|
193 | NULL, /* getRegister - NOT USED */ |
---|
194 | NULL, /* setRegister - NOT USED */ |
---|
195 | NULL, /* getData - NOT USED */ |
---|
196 | NULL, /* setData - NOT USED */ |
---|
197 | 0, /* ulClock - NOT USED */ |
---|
198 | 0 /* ulIntVector - NOT USED */ |
---|
199 | }, |
---|
200 | #endif |
---|
201 | #if ENABLE_USART2 |
---|
202 | { |
---|
203 | "/dev/com3", /* sDeviceName */ |
---|
204 | SERIAL_CUSTOM, /* deviceType */ |
---|
205 | &usart_polling_fns,/* pDeviceFns */ |
---|
206 | NULL, /* deviceProbe */ |
---|
207 | NULL, /* pDeviceFlow */ |
---|
208 | 0, /* ulMargin - NOT USED */ |
---|
209 | 0, /* ulHysteresis - NOT USED */ |
---|
210 | NULL, /* pDeviceParams */ |
---|
211 | USART2_BASE, /* ulCtrlPort1 - Pointer to USART 2 regs */ |
---|
212 | 0, /* ulCtrlPort2 - NOT USED */ |
---|
213 | 0, /* ulDataPort - NOT USED */ |
---|
214 | NULL, /* getRegister - NOT USED */ |
---|
215 | NULL, /* setRegister - NOT USED */ |
---|
216 | NULL, /* getData - NOT USED */ |
---|
217 | NULL, /* setData - NOT USED */ |
---|
218 | 0, /* ulClock - NOT USED */ |
---|
219 | 0 /* ulIntVector - NOT USED */ |
---|
220 | }, |
---|
221 | #endif |
---|
222 | #if ENABLE_USART3 |
---|
223 | { |
---|
224 | "/dev/com4", /* sDeviceName */ |
---|
225 | SERIAL_CUSTOM, /* deviceType */ |
---|
226 | &usart_polling_fns,/* pDeviceFns */ |
---|
227 | NULL, /* deviceProbe */ |
---|
228 | NULL, /* pDeviceFlow */ |
---|
229 | 0, /* ulMargin - NOT USED */ |
---|
230 | 0, /* ulHysteresis - NOT USED */ |
---|
231 | NULL, /* pDeviceParams */ |
---|
232 | USART3_BASE, /* ulCtrlPort1 - Pointer to USART 3 regs */ |
---|
233 | 0, /* ulCtrlPort2 - NOT USED */ |
---|
234 | 0, /* ulDataPort - NOT USED */ |
---|
235 | NULL, /* getRegister - NOT USED */ |
---|
236 | NULL, /* setRegister - NOT USED */ |
---|
237 | NULL, /* getData - NOT USED */ |
---|
238 | NULL, /* setData - NOT USED */ |
---|
239 | 0, /* ulClock - NOT USED */ |
---|
240 | 0 /* ulIntVector - NOT USED */ |
---|
241 | } |
---|
242 | #endif |
---|
243 | }; |
---|
244 | |
---|
245 | console_tbl *BSP_get_uart_from_minor(int minor) |
---|
246 | { |
---|
247 | return &Console_Port_Tbl[minor]; |
---|
248 | } |
---|