source: rtems/c/src/lib/libbsp/powerpc/qoriq/console/console-config.c @ dc0a7df

4.115
Last change on this file since dc0a7df was dc0a7df, checked in by Sebastian Huber <sebastian.huber@…>, on Jul 21, 2011 at 3:18:02 PM

2011-07-21 Sebastian Huber <sebastian.huber@…>

PR 1799/bsps

  • .cvsignore, ChangeLog?, Makefile.am, README, bsp_specs, configure.ac, clock/clock-config.c, console/console-config.c, console/uart-bridge-master.c, console/uart-bridge-slave.c, include/.cvsignore, include/bsp.h, include/hwreg_vals.h, include/intercom.h, include/irq.h, include/mmu.h, include/qoriq.h, include/tm27.h, include/tsec-config.h, include/u-boot-config.h, include/uart-bridge.h, irq/irq.c, make/custom/qoriq.inc, make/custom/qoriq_core_0.cfg, make/custom/qoriq_core_1.cfg, make/custom/qoriq_p1020rdb.cfg, network/if_intercom.c, network/network.c, rtc/rtc-config.c, shmsupp/intercom-mpci.c, shmsupp/intercom.c, shmsupp/lock.S, start/start.S, startup/bsppredriverhook.c, startup/bspreset.c, startup/bspstart.c, startup/linkcmds.base, startup/linkcmds.qoriq_core_0, startup/linkcmds.qoriq_core_1, startup/linkcmds.qoriq_p1020rdb, startup/mmu-config.c, startup/mmu-tlb1.S, startup/mmu.c: New files.
  • Property mode set to 100644
File size: 5.1 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup QorIQ
5 *
6 * @brief Console configuration.
7 */
8
9/*
10 * Copyright (c) 2010 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Obere Lagerstr. 30
14 *  82178 Puchheim
15 *  Germany
16 *  <rtems@embedded-brains.de>
17 *
18 * The license and distribution terms for this file may be
19 * found in the file LICENSE in this distribution or at
20 * http://www.rtems.com/license/LICENSE.
21 *
22 * $Id$
23 */
24
25#include <assert.h>
26
27#include <rtems/bspIo.h>
28
29#include <libchip/serial.h>
30#include <libchip/ns16550.h>
31
32#include <bspopts.h>
33#include <bsp/irq.h>
34#include <bsp/qoriq.h>
35#include <bsp/intercom.h>
36#include <bsp/uart-bridge.h>
37
38#define CONSOLE_COUNT \
39  (QORIQ_UART_0_ENABLE \
40    + QORIQ_UART_1_ENABLE \
41    + QORIQ_UART_BRIDGE_0_ENABLE \
42    + QORIQ_UART_BRIDGE_1_ENABLE)
43
44#if (QORIQ_UART_0_ENABLE + QORIQ_UART_BRIDGE_0_ENABLE == 2) \
45  || (QORIQ_UART_1_ENABLE + QORIQ_UART_BRIDGE_1_ENABLE == 2)
46  #define BRIDGE_MASTER
47#elif QORIQ_UART_BRIDGE_0_ENABLE || QORIQ_UART_BRIDGE_1_ENABLE
48  #define BRIDGE_SLAVE
49#endif
50
51#ifdef BRIDGE_MASTER
52  #define BRIDGE_FNS &qoriq_uart_bridge_master
53  #if QORIQ_UART_BRIDGE_0_ENABLE
54    static uart_bridge_master_control bridge_0_control = {
55      .device_path = "/dev/ttyS0",
56      .type = INTERCOM_TYPE_UART_0,
57      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
58        bridge_0_control.transmit_fifo
59      )
60    };
61    #define BRIDGE_0_CONTROL &bridge_0_control
62  #endif
63  #if QORIQ_UART_BRIDGE_1_ENABLE
64    static uart_bridge_master_control bridge_1_control = {
65      .device_path = "/dev/ttyS1",
66      .type = INTERCOM_TYPE_UART_1,
67      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
68        bridge_1_control.transmit_fifo
69      )
70    };
71    #define BRIDGE_1_CONTROL &bridge_1_control
72  #endif
73#endif
74
75#ifdef BRIDGE_SLAVE
76  #define BRIDGE_FNS &qoriq_uart_bridge_slave
77  #if QORIQ_UART_BRIDGE_0_ENABLE
78    static uart_bridge_slave_control bridge_0_control = {
79      .type = INTERCOM_TYPE_UART_0,
80      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
81        bridge_0_control.transmit_fifo
82      )
83    };
84    #define BRIDGE_0_CONTROL &bridge_0_control
85  #endif
86  #if QORIQ_UART_BRIDGE_1_ENABLE
87    static uart_bridge_slave_control bridge_1_control = {
88      .type = INTERCOM_TYPE_UART_1,
89      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
90        bridge_1_control.transmit_fifo
91      )
92    };
93    #define BRIDGE_1_CONTROL &bridge_1_control
94  #endif
95#endif
96
97#ifdef BSP_USE_UART_INTERRUPTS
98  #define DEVICE_FNS &ns16550_fns
99#else
100  #define DEVICE_FNS &ns16550_fns_polled
101#endif
102
103#if QORIQ_UART_0_ENABLE || QORIQ_UART_1_ENABLE
104  static uint8_t get_register(uintptr_t addr, uint8_t i)
105  {
106    volatile uint8_t *reg = (uint8_t *) addr;
107
108    return reg [i];
109  }
110
111  static void set_register(uintptr_t addr, uint8_t i, uint8_t val)
112  {
113    volatile uint8_t *reg = (uint8_t *) addr;
114
115    reg [i] = val; 
116  }
117#endif
118
119unsigned long Console_Port_Count = CONSOLE_COUNT;
120
121rtems_device_minor_number Console_Port_Minor;
122
123console_data Console_Port_Data [CONSOLE_COUNT];
124
125console_tbl Console_Port_Tbl [CONSOLE_COUNT] = {
126  #if QORIQ_UART_0_ENABLE
127    {
128      .sDeviceName = "/dev/ttyS0",
129      .deviceType = SERIAL_NS16550,
130      .pDeviceFns = DEVICE_FNS,
131      .deviceProbe = NULL,
132      .pDeviceFlow = NULL,
133      .ulMargin = 16,
134      .ulHysteresis = 8,
135      .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
136      .ulCtrlPort1 = (uintptr_t) &qoriq.uart_0,
137      .ulCtrlPort2 = 0,
138      .ulDataPort =  (uintptr_t) &qoriq.uart_0,
139      .getRegister = get_register,
140      .setRegister = set_register,
141      .getData = NULL,
142      .setData = NULL,
143      .ulClock = 0,
144      .ulIntVector = QORIQ_IRQ_DUART
145    },
146  #endif
147  #if QORIQ_UART_1_ENABLE
148    {
149      .sDeviceName = "/dev/ttyS1",
150      .deviceType = SERIAL_NS16550,
151      .pDeviceFns = DEVICE_FNS,
152      .deviceProbe = NULL,
153      .pDeviceFlow = NULL,
154      .ulMargin = 16,
155      .ulHysteresis = 8,
156      .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
157      .ulCtrlPort1 = (uintptr_t) &qoriq.uart_1,
158      .ulCtrlPort2 = 0,
159      .ulDataPort =  (uintptr_t) &qoriq.uart_1,
160      .getRegister = get_register,
161      .setRegister = set_register,
162      .getData = NULL,
163      .setData = NULL,
164      .ulClock = 0,
165      .ulIntVector = QORIQ_IRQ_DUART
166    },
167  #endif
168  #if QORIQ_UART_BRIDGE_0_ENABLE
169    {
170      #if QORIQ_UART_1_ENABLE
171        .sDeviceName = "/dev/ttyB0",
172      #else
173        .sDeviceName = "/dev/ttyS0",
174      #endif
175      .deviceType = SERIAL_CUSTOM,
176      .pDeviceFns = BRIDGE_FNS,
177      .pDeviceParams = BRIDGE_0_CONTROL
178    },
179  #endif
180  #if QORIQ_UART_BRIDGE_1_ENABLE
181    {
182      #if QORIQ_UART_1_ENABLE
183        .sDeviceName = "/dev/ttyB1",
184      #else
185        .sDeviceName = "/dev/ttyS1",
186      #endif
187      .deviceType = SERIAL_CUSTOM,
188      .pDeviceFns = BRIDGE_FNS,
189      .pDeviceParams = BRIDGE_1_CONTROL
190    }
191  #endif
192};
193
194static void output_char(char c)
195{
196  const console_fns *con = Console_Port_Tbl [Console_Port_Minor].pDeviceFns;
197 
198  if (c == '\n') {
199    con->deviceWritePolled((int) Console_Port_Minor, '\r');
200  }
201  con->deviceWritePolled((int) Console_Port_Minor, c);
202}
203
204BSP_output_char_function_type BSP_output_char = output_char;
205
206BSP_polling_getchar_function_type BSP_poll_char = NULL;
Note: See TracBrowser for help on using the repository browser.