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 | #include <rtems/console.h> |
---|
19 | |
---|
20 | #include <libcpu/bf537.h> |
---|
21 | #include <libcpu/interrupt.h> |
---|
22 | #include <libcpu/uart.h> |
---|
23 | |
---|
24 | /* |
---|
25 | #undef CONSOLE_USE_INTERRUPTS |
---|
26 | #define CONSOLE_USE_INTERRUPTS 1 |
---|
27 | */ |
---|
28 | |
---|
29 | static bfin_uart_channel_t channels[] = { |
---|
30 | {"/dev/console", |
---|
31 | UART0_BASE_ADDRESS, |
---|
32 | 0, |
---|
33 | 0, |
---|
34 | CONSOLE_USE_INTERRUPTS, |
---|
35 | 0, |
---|
36 | #ifdef CONSOLE_FORCE_BAUD |
---|
37 | CONSOLE_FORCE_BAUD, |
---|
38 | #else |
---|
39 | 0, |
---|
40 | #endif |
---|
41 | NULL, |
---|
42 | 0, |
---|
43 | 0} |
---|
44 | |
---|
45 | #if (!BFIN_ON_SKYEYE) |
---|
46 | , |
---|
47 | {"/dev/tty1", |
---|
48 | UART1_BASE_ADDRESS, |
---|
49 | CONSOLE_USE_INTERRUPTS, |
---|
50 | 0, |
---|
51 | NULL, |
---|
52 | 0} |
---|
53 | #endif |
---|
54 | }; |
---|
55 | |
---|
56 | static bfin_uart_config_t config = { |
---|
57 | SCLK, |
---|
58 | sizeof(channels) / sizeof(channels[0]), |
---|
59 | channels |
---|
60 | }; |
---|
61 | |
---|
62 | #if CONSOLE_USE_INTERRUPTS |
---|
63 | static bfin_isr_t bfinUARTISRs[] = { |
---|
64 | {SIC_DMA8_UART0_RX_VECTOR, bfinUart_rxIsr, 0, 0, NULL}, |
---|
65 | {SIC_DMA10_UART1_RX_VECTOR, bfinUart_rxIsr, 0, 0, NULL}, |
---|
66 | {SIC_DMA9_UART0_TX_VECTOR, bfinUart_txIsr, 0, 0, NULL}, |
---|
67 | {SIC_DMA11_UART1_TX_VECTOR, bfinUart_txIsr, 0, 0, NULL} |
---|
68 | }; |
---|
69 | #endif |
---|
70 | |
---|
71 | |
---|
72 | static void bf537Stamp_BSP_output_char(char c) { |
---|
73 | |
---|
74 | bfin_uart_poll_write(0, c); |
---|
75 | } |
---|
76 | |
---|
77 | static int bf537Stamp_BSP_poll_char(void) { |
---|
78 | |
---|
79 | return bfin_uart_poll_read(0); |
---|
80 | } |
---|
81 | |
---|
82 | BSP_output_char_function_type BSP_output_char = bf537Stamp_BSP_output_char; |
---|
83 | BSP_polling_getchar_function_type BSP_poll_char = bf537Stamp_BSP_poll_char; |
---|
84 | |
---|
85 | rtems_device_driver console_initialize(rtems_device_major_number major, |
---|
86 | rtems_device_minor_number minor, |
---|
87 | void *arg) { |
---|
88 | rtems_status_code status; |
---|
89 | #if CONSOLE_USE_INTERRUPTS |
---|
90 | int i; |
---|
91 | #endif |
---|
92 | |
---|
93 | status = bfin_uart_initialize(major, &config); |
---|
94 | #if CONSOLE_USE_INTERRUPTS |
---|
95 | for (i = 0; i < sizeof(bfinUARTISRs) / sizeof(bfinUARTISRs[0]); i++) { |
---|
96 | bfin_interrupt_register(&bfinUARTISRs[i]); |
---|
97 | bfin_interrupt_enable(&bfinUARTISRs[i], TRUE); |
---|
98 | } |
---|
99 | #endif |
---|
100 | |
---|
101 | if (status != RTEMS_SUCCESSFUL) |
---|
102 | rtems_fatal_error_occurred(status); |
---|
103 | |
---|
104 | return RTEMS_SUCCESSFUL; |
---|
105 | } |
---|
106 | |
---|
107 | rtems_device_driver console_open(rtems_device_major_number major, |
---|
108 | rtems_device_minor_number minor, |
---|
109 | void *arg) { |
---|
110 | |
---|
111 | return bfin_uart_open(major, minor, arg); |
---|
112 | } |
---|
113 | |
---|
114 | rtems_device_driver console_close(rtems_device_major_number major, |
---|
115 | rtems_device_minor_number minor, |
---|
116 | void *arg) { |
---|
117 | |
---|
118 | return rtems_termios_close(arg); |
---|
119 | } |
---|
120 | |
---|
121 | rtems_device_driver console_read(rtems_device_major_number major, |
---|
122 | rtems_device_minor_number minor, |
---|
123 | void *arg) { |
---|
124 | |
---|
125 | return rtems_termios_read(arg); |
---|
126 | } |
---|
127 | |
---|
128 | rtems_device_driver console_write(rtems_device_major_number major, |
---|
129 | rtems_device_minor_number minor, |
---|
130 | void *arg) { |
---|
131 | |
---|
132 | return rtems_termios_write(arg); |
---|
133 | } |
---|
134 | |
---|
135 | rtems_device_driver console_control(rtems_device_major_number major, |
---|
136 | rtems_device_minor_number minor, |
---|
137 | void *arg) { |
---|
138 | |
---|
139 | return rtems_termios_ioctl(arg); |
---|
140 | } |
---|
141 | |
---|