1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief Console configuration. |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * Copyright (c) 2008, 2010 embedded brains GmbH. All rights reserved. |
---|
9 | * |
---|
10 | * embedded brains GmbH |
---|
11 | * Obere Lagerstr. 30 |
---|
12 | * 82178 Puchheim |
---|
13 | * Germany |
---|
14 | * <rtems@embedded-brains.de> |
---|
15 | * |
---|
16 | * The license and distribution terms for this file may be |
---|
17 | * found in the file LICENSE in this distribution or at |
---|
18 | * http://www.rtems.com/license/LICENSE. |
---|
19 | */ |
---|
20 | |
---|
21 | #include <rtems/bspIo.h> |
---|
22 | |
---|
23 | #include <libchip/serial.h> |
---|
24 | #include <libchip/ns16550.h> |
---|
25 | |
---|
26 | #include <mpc83xx/mpc83xx.h> |
---|
27 | |
---|
28 | #include <bspopts.h> |
---|
29 | #include <bsp/irq.h> |
---|
30 | |
---|
31 | #ifdef BSP_USE_UART2 |
---|
32 | #define PORT_COUNT 2 |
---|
33 | #else |
---|
34 | #define PORT_COUNT 1 |
---|
35 | #endif |
---|
36 | |
---|
37 | #ifdef BSP_USE_UART_INTERRUPTS |
---|
38 | #define DEVICE_FNS &ns16550_fns |
---|
39 | #else |
---|
40 | #define DEVICE_FNS &ns16550_fns_polled |
---|
41 | #endif |
---|
42 | |
---|
43 | static uint8_t gen83xx_console_get_register(uint32_t addr, uint8_t i) |
---|
44 | { |
---|
45 | volatile uint8_t *reg = (volatile uint8_t *) addr; |
---|
46 | |
---|
47 | return reg [i]; |
---|
48 | } |
---|
49 | |
---|
50 | static void gen83xx_console_set_register(uint32_t addr, uint8_t i, uint8_t val) |
---|
51 | { |
---|
52 | volatile uint8_t *reg = (volatile uint8_t *) addr; |
---|
53 | |
---|
54 | reg [i] = val; |
---|
55 | } |
---|
56 | |
---|
57 | unsigned long Console_Port_Count = PORT_COUNT; |
---|
58 | |
---|
59 | rtems_device_minor_number Console_Port_Minor = 0; |
---|
60 | |
---|
61 | console_data Console_Port_Data [PORT_COUNT]; |
---|
62 | |
---|
63 | console_tbl Console_Port_Tbl [PORT_COUNT] = { |
---|
64 | { |
---|
65 | .sDeviceName = "/dev/ttyS0", |
---|
66 | .deviceType = SERIAL_NS16550, |
---|
67 | .pDeviceFns = DEVICE_FNS, |
---|
68 | .deviceProbe = NULL, |
---|
69 | .pDeviceFlow = NULL, |
---|
70 | .ulMargin = 16, |
---|
71 | .ulHysteresis = 8, |
---|
72 | .pDeviceParams = (void *) BSP_CONSOLE_BAUD, |
---|
73 | .ulCtrlPort1 = (uint32_t) &mpc83xx.duart [0], |
---|
74 | .ulCtrlPort2 = 0, |
---|
75 | .ulDataPort = (uint32_t) &mpc83xx.duart [0], |
---|
76 | .getRegister = gen83xx_console_get_register, |
---|
77 | .setRegister = gen83xx_console_set_register, |
---|
78 | .getData = NULL, |
---|
79 | .setData = NULL, |
---|
80 | .ulClock = 0, |
---|
81 | .ulIntVector = BSP_IPIC_IRQ_UART1 |
---|
82 | } |
---|
83 | #ifdef BSP_USE_UART2 |
---|
84 | , { |
---|
85 | .sDeviceName = "/dev/ttyS1", |
---|
86 | .deviceType = SERIAL_NS16550, |
---|
87 | .pDeviceFns = DEVICE_FNS, |
---|
88 | .deviceProbe = NULL, |
---|
89 | .pDeviceFlow = NULL, |
---|
90 | .ulMargin = 16, |
---|
91 | .ulHysteresis = 8, |
---|
92 | .pDeviceParams = (void *) BSP_CONSOLE_BAUD, |
---|
93 | .ulCtrlPort1 = (uint32_t) &mpc83xx.duart [1], |
---|
94 | .ulCtrlPort2 = 0, |
---|
95 | .ulDataPort = (uint32_t) &mpc83xx.duart [1], |
---|
96 | .getRegister = gen83xx_console_get_register, |
---|
97 | .setRegister = gen83xx_console_set_register, |
---|
98 | .getData = NULL, |
---|
99 | .setData = NULL, |
---|
100 | .ulClock = 0, |
---|
101 | .ulIntVector = BSP_IPIC_IRQ_UART2 |
---|
102 | } |
---|
103 | #endif |
---|
104 | }; |
---|
105 | |
---|
106 | static void gen83xx_output_char(char c) |
---|
107 | { |
---|
108 | const console_fns *console = Console_Port_Tbl [Console_Port_Minor].pDeviceFns; |
---|
109 | |
---|
110 | if (c == '\n') { |
---|
111 | console->deviceWritePolled((int) Console_Port_Minor, '\r'); |
---|
112 | } |
---|
113 | console->deviceWritePolled((int) Console_Port_Minor, c); |
---|
114 | } |
---|
115 | |
---|
116 | BSP_output_char_function_type BSP_output_char = gen83xx_output_char; |
---|
117 | |
---|
118 | BSP_polling_getchar_function_type BSP_poll_char = NULL; |
---|