1 | /** |
---|
2 | *@file |
---|
3 | * |
---|
4 | *@brief |
---|
5 | * - This file implements uart console for TLL6527M. TLL6527M has BF527 with |
---|
6 | * second uart (uart-1) connected to the console. |
---|
7 | * |
---|
8 | * Target: TLL6527v1-0 |
---|
9 | * Compiler: |
---|
10 | * |
---|
11 | * COPYRIGHT (c) 2010 by ECE Northeastern University. |
---|
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.org/license |
---|
16 | * |
---|
17 | * @author Rohan Kangralkar, ECE, Northeastern University |
---|
18 | * (kangralkar.r@husky.neu.edu) |
---|
19 | * |
---|
20 | * LastChange: |
---|
21 | */ |
---|
22 | |
---|
23 | #include <rtems.h> |
---|
24 | #include <rtems/libio.h> |
---|
25 | #include <bsp.h> |
---|
26 | #include <rtems/bspIo.h> |
---|
27 | #include <rtems/console.h> |
---|
28 | |
---|
29 | #include <bsp/interrupt.h> |
---|
30 | #include <libcpu/uart.h> |
---|
31 | |
---|
32 | /*************************************************** |
---|
33 | LOCAL DEFINES |
---|
34 | ***************************************************/ |
---|
35 | |
---|
36 | |
---|
37 | /*************************************************** |
---|
38 | STATIC GLOBALS |
---|
39 | ***************************************************/ |
---|
40 | /** |
---|
41 | * Declaration of UART |
---|
42 | */ |
---|
43 | static bfin_uart_channel_t channels[] = { |
---|
44 | {"/dev/console", |
---|
45 | UART1_BASE_ADDRESS, |
---|
46 | DMA10_BASE_ADDRESS, |
---|
47 | DMA11_BASE_ADDRESS, |
---|
48 | CONSOLE_USE_INTERRUPTS, |
---|
49 | UART_USE_DMA, |
---|
50 | CONSOLE_BAUDRATE, |
---|
51 | NULL, |
---|
52 | 0, |
---|
53 | 0} |
---|
54 | }; |
---|
55 | |
---|
56 | /** |
---|
57 | * Over all configuration |
---|
58 | */ |
---|
59 | static bfin_uart_config_t config = { |
---|
60 | SCLK, |
---|
61 | sizeof(channels) / sizeof(channels[0]), |
---|
62 | channels |
---|
63 | }; |
---|
64 | |
---|
65 | |
---|
66 | #if CONSOLE_USE_INTERRUPTS |
---|
67 | /** |
---|
68 | * The Rx and Tx isr will get the same argument |
---|
69 | * The isr will have to find if it was the rx that caused the interrupt or |
---|
70 | * the tx |
---|
71 | */ |
---|
72 | static bfin_isr_t bfinUARTISRs[] = { |
---|
73 | #if UART_USE_DMA |
---|
74 | /* For First uart */ |
---|
75 | {IRQ_DMA10_UART1_RX, bfinUart_rxDmaIsr, (void *)&channels[0], 0}, |
---|
76 | {IRQ_DMA11_UART1_TX, bfinUart_txDmaIsr, (void *)&channels[0], 0}, |
---|
77 | /* For second uart */ |
---|
78 | #else |
---|
79 | /* For First uart */ |
---|
80 | {IRQ_DMA10_UART1_RX, bfinUart_rxIsr, &channels[0], 0}, |
---|
81 | {IRQ_DMA11_UART1_TX, bfinUart_txIsr, &channels[0], 0}, |
---|
82 | /* For second uart */ |
---|
83 | #endif |
---|
84 | }; |
---|
85 | #endif |
---|
86 | |
---|
87 | |
---|
88 | static void TLL6527_BSP_output_char(char c) { |
---|
89 | |
---|
90 | bfin_uart_poll_write(0, c); |
---|
91 | } |
---|
92 | |
---|
93 | static int TLL6527_BSP_poll_char(void) { |
---|
94 | |
---|
95 | return bfin_uart_poll_read(0); |
---|
96 | } |
---|
97 | |
---|
98 | BSP_output_char_function_type BSP_output_char = TLL6527_BSP_output_char; |
---|
99 | BSP_polling_getchar_function_type BSP_poll_char = TLL6527_BSP_poll_char; |
---|
100 | |
---|
101 | |
---|
102 | |
---|
103 | rtems_device_driver console_close(rtems_device_major_number major, |
---|
104 | rtems_device_minor_number minor, |
---|
105 | void *arg) { |
---|
106 | |
---|
107 | return rtems_termios_close(arg); |
---|
108 | } |
---|
109 | |
---|
110 | rtems_device_driver console_read(rtems_device_major_number major, |
---|
111 | rtems_device_minor_number minor, |
---|
112 | void *arg) { |
---|
113 | |
---|
114 | return rtems_termios_read(arg); |
---|
115 | } |
---|
116 | |
---|
117 | rtems_device_driver console_write(rtems_device_major_number major, |
---|
118 | rtems_device_minor_number minor, |
---|
119 | void *arg) { |
---|
120 | |
---|
121 | return rtems_termios_write(arg); |
---|
122 | } |
---|
123 | |
---|
124 | rtems_device_driver console_control(rtems_device_major_number major, |
---|
125 | rtems_device_minor_number minor, |
---|
126 | void *arg) { |
---|
127 | |
---|
128 | return rtems_termios_ioctl(arg); |
---|
129 | } |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | /* |
---|
134 | * Open entry point |
---|
135 | */ |
---|
136 | rtems_device_driver console_open(rtems_device_major_number major, |
---|
137 | rtems_device_minor_number minor, |
---|
138 | void *arg) { |
---|
139 | |
---|
140 | return bfin_uart_open(major, minor, arg); |
---|
141 | } |
---|
142 | |
---|
143 | |
---|
144 | |
---|
145 | /** |
---|
146 | * |
---|
147 | * This routine initializes the console IO driver. |
---|
148 | * |
---|
149 | * Parameters |
---|
150 | * @param major major number |
---|
151 | * @param minor minor number |
---|
152 | * |
---|
153 | * Output parameters: NONE |
---|
154 | * |
---|
155 | * @return void |
---|
156 | */ |
---|
157 | rtems_device_driver console_initialize(rtems_device_major_number major, |
---|
158 | rtems_device_minor_number minor, |
---|
159 | void *arg) { |
---|
160 | rtems_status_code status = RTEMS_NOT_DEFINED; |
---|
161 | #if CONSOLE_USE_INTERRUPTS |
---|
162 | int i = 0; |
---|
163 | #endif |
---|
164 | |
---|
165 | status = bfin_uart_initialize(major, &config); |
---|
166 | if (status != RTEMS_SUCCESSFUL) { |
---|
167 | rtems_fatal_error_occurred(status); |
---|
168 | } |
---|
169 | |
---|
170 | #if CONSOLE_USE_INTERRUPTS |
---|
171 | for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) { |
---|
172 | bfin_interrupt_register(&bfinUARTISRs[i]); |
---|
173 | #if INTERRUPT_USE_TABLE |
---|
174 | #else |
---|
175 | bfin_interrupt_enable(&bfinUARTISRs[i], 1); |
---|
176 | #endif |
---|
177 | } |
---|
178 | #endif |
---|
179 | |
---|
180 | return RTEMS_SUCCESSFUL; |
---|
181 | } |
---|