1 | /* Console driver for bf537Stamp |
---|
2 | */ |
---|
3 | |
---|
4 | /* |
---|
5 | * Copyright (c) 2008 Kallisti Labs, Los Gatos, CA, USA |
---|
6 | * written by Allan Hessenflow <allanh@kallisti.com> |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.org/license/LICENSE. |
---|
11 | */ |
---|
12 | |
---|
13 | |
---|
14 | #include <rtems.h> |
---|
15 | #include <rtems/libio.h> |
---|
16 | #include <bsp.h> |
---|
17 | #include <rtems/bspIo.h> |
---|
18 | |
---|
19 | #include <libcpu/bf537.h> |
---|
20 | #include <libcpu/interrupt.h> |
---|
21 | #include <libcpu/uart.h> |
---|
22 | |
---|
23 | /* |
---|
24 | #undef CONSOLE_USE_INTERRUPTS |
---|
25 | #define CONSOLE_USE_INTERRUPTS 1 |
---|
26 | */ |
---|
27 | |
---|
28 | static bfin_uart_channel_t channels[] = { |
---|
29 | {"/dev/console", |
---|
30 | UART0_BASE_ADDRESS, |
---|
31 | 0, |
---|
32 | 0, |
---|
33 | CONSOLE_USE_INTERRUPTS, |
---|
34 | 0, |
---|
35 | #ifdef CONSOLE_FORCE_BAUD |
---|
36 | CONSOLE_FORCE_BAUD, |
---|
37 | #else |
---|
38 | 0, |
---|
39 | #endif |
---|
40 | NULL, |
---|
41 | 0, |
---|
42 | 0} |
---|
43 | |
---|
44 | #if (!BFIN_ON_SKYEYE) |
---|
45 | , |
---|
46 | {"/dev/tty1", |
---|
47 | (char *) UART1_BASE_ADDRESS, |
---|
48 | CONSOLE_USE_INTERRUPTS, |
---|
49 | 0, |
---|
50 | NULL, |
---|
51 | 0} |
---|
52 | #endif |
---|
53 | }; |
---|
54 | |
---|
55 | static bfin_uart_config_t config = { |
---|
56 | SCLK, |
---|
57 | sizeof(channels) / sizeof(channels[0]), |
---|
58 | channels |
---|
59 | }; |
---|
60 | |
---|
61 | #if CONSOLE_USE_INTERRUPTS |
---|
62 | static bfin_isr_t bfinUARTISRs[] = { |
---|
63 | {SIC_DMA8_UART0_RX_VECTOR, bfinUart_rxIsr, 0, 0, NULL}, |
---|
64 | {SIC_DMA10_UART1_RX_VECTOR, bfinUart_rxIsr, 0, 0, NULL}, |
---|
65 | {SIC_DMA9_UART0_TX_VECTOR, bfinUart_txIsr, 0, 0, NULL}, |
---|
66 | {SIC_DMA11_UART1_TX_VECTOR, bfinUart_txIsr, 0, 0, NULL} |
---|
67 | }; |
---|
68 | #endif |
---|
69 | |
---|
70 | |
---|
71 | static void bf537Stamp_BSP_output_char(char c) { |
---|
72 | |
---|
73 | bfin_uart_poll_write(0, c); |
---|
74 | } |
---|
75 | |
---|
76 | static int bf537Stamp_BSP_poll_char(void) { |
---|
77 | |
---|
78 | return bfin_uart_poll_read(0); |
---|
79 | } |
---|
80 | |
---|
81 | BSP_output_char_function_type BSP_output_char = bf537Stamp_BSP_output_char; |
---|
82 | BSP_polling_getchar_function_type BSP_poll_char = bf537Stamp_BSP_poll_char; |
---|
83 | |
---|
84 | rtems_device_driver console_initialize(rtems_device_major_number major, |
---|
85 | rtems_device_minor_number minor, |
---|
86 | void *arg) { |
---|
87 | rtems_status_code status; |
---|
88 | #if CONSOLE_USE_INTERRUPTS |
---|
89 | int i; |
---|
90 | #endif |
---|
91 | |
---|
92 | status = bfin_uart_initialize(major, &config); |
---|
93 | #if CONSOLE_USE_INTERRUPTS |
---|
94 | for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) { |
---|
95 | bfin_interrupt_register(&bfinUARTISRs[i]); |
---|
96 | bfin_interrupt_enable(&bfinUARTISRs[i], TRUE); |
---|
97 | } |
---|
98 | #endif |
---|
99 | |
---|
100 | if (status != RTEMS_SUCCESSFUL) |
---|
101 | rtems_fatal_error_occurred(status); |
---|
102 | |
---|
103 | return RTEMS_SUCCESSFUL; |
---|
104 | } |
---|
105 | |
---|
106 | rtems_device_driver console_open(rtems_device_major_number major, |
---|
107 | rtems_device_minor_number minor, |
---|
108 | void *arg) { |
---|
109 | |
---|
110 | return bfin_uart_open(major, minor, arg); |
---|
111 | } |
---|
112 | |
---|
113 | rtems_device_driver console_close(rtems_device_major_number major, |
---|
114 | rtems_device_minor_number minor, |
---|
115 | void *arg) { |
---|
116 | |
---|
117 | return rtems_termios_close(arg); |
---|
118 | } |
---|
119 | |
---|
120 | rtems_device_driver console_read(rtems_device_major_number major, |
---|
121 | rtems_device_minor_number minor, |
---|
122 | void *arg) { |
---|
123 | |
---|
124 | return rtems_termios_read(arg); |
---|
125 | } |
---|
126 | |
---|
127 | rtems_device_driver console_write(rtems_device_major_number major, |
---|
128 | rtems_device_minor_number minor, |
---|
129 | void *arg) { |
---|
130 | |
---|
131 | return rtems_termios_write(arg); |
---|
132 | } |
---|
133 | |
---|
134 | rtems_device_driver console_control(rtems_device_major_number major, |
---|
135 | rtems_device_minor_number minor, |
---|
136 | void *arg) { |
---|
137 | |
---|
138 | return rtems_termios_ioctl(arg); |
---|
139 | } |
---|
140 | |
---|