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

4.115
Last change on this file since 964c734b was 964c734b, checked in by Jennifer Averett <Jennifer.Averett@…>, on Oct 18, 2011 at 6:32:23 PM

2011-10-18 Jennifer Averett <Jennifer.Averett@…>

PR 1917/bsps

  • Makefile.am, console/console-config.c, console/uart-bridge-master.c, console/uart-bridge-slave.c, startup/bspstart.c: Modifications to add dynamic tables for libchip serial drivers.
  • 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#include "../../../shared/console_private.h"
32
33#include <bspopts.h>
34#include <bsp/irq.h>
35#include <bsp/qoriq.h>
36#include <bsp/intercom.h>
37#include <bsp/uart-bridge.h>
38
39#define CONSOLE_COUNT \
40  (QORIQ_UART_0_ENABLE \
41    + QORIQ_UART_1_ENABLE \
42    + QORIQ_UART_BRIDGE_0_ENABLE \
43    + QORIQ_UART_BRIDGE_1_ENABLE)
44
45#if (QORIQ_UART_0_ENABLE + QORIQ_UART_BRIDGE_0_ENABLE == 2) \
46  || (QORIQ_UART_1_ENABLE + QORIQ_UART_BRIDGE_1_ENABLE == 2)
47  #define BRIDGE_MASTER
48#elif QORIQ_UART_BRIDGE_0_ENABLE || QORIQ_UART_BRIDGE_1_ENABLE
49  #define BRIDGE_SLAVE
50#endif
51
52#ifdef BRIDGE_MASTER
53  #define BRIDGE_FNS &qoriq_uart_bridge_master
54  #if QORIQ_UART_BRIDGE_0_ENABLE
55    static uart_bridge_master_control bridge_0_control = {
56      .device_path = "/dev/ttyS0",
57      .type = INTERCOM_TYPE_UART_0,
58      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
59        bridge_0_control.transmit_fifo
60      )
61    };
62    #define BRIDGE_0_CONTROL &bridge_0_control
63  #endif
64  #if QORIQ_UART_BRIDGE_1_ENABLE
65    static uart_bridge_master_control bridge_1_control = {
66      .device_path = "/dev/ttyS1",
67      .type = INTERCOM_TYPE_UART_1,
68      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
69        bridge_1_control.transmit_fifo
70      )
71    };
72    #define BRIDGE_1_CONTROL &bridge_1_control
73  #endif
74#endif
75
76#ifdef BRIDGE_SLAVE
77  #define BRIDGE_FNS &qoriq_uart_bridge_slave
78  #if QORIQ_UART_BRIDGE_0_ENABLE
79    static uart_bridge_slave_control bridge_0_control = {
80      .type = INTERCOM_TYPE_UART_0,
81      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
82        bridge_0_control.transmit_fifo
83      )
84    };
85    #define BRIDGE_0_CONTROL &bridge_0_control
86  #endif
87  #if QORIQ_UART_BRIDGE_1_ENABLE
88    static uart_bridge_slave_control bridge_1_control = {
89      .type = INTERCOM_TYPE_UART_1,
90      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
91        bridge_1_control.transmit_fifo
92      )
93    };
94    #define BRIDGE_1_CONTROL &bridge_1_control
95  #endif
96#endif
97
98#ifdef BSP_USE_UART_INTERRUPTS
99  #define DEVICE_FNS &ns16550_fns
100#else
101  #define DEVICE_FNS &ns16550_fns_polled
102#endif
103
104#if QORIQ_UART_0_ENABLE || QORIQ_UART_1_ENABLE
105  static uint8_t get_register(uintptr_t addr, uint8_t i)
106  {
107    volatile uint8_t *reg = (uint8_t *) addr;
108
109    return reg [i];
110  }
111
112  static void set_register(uintptr_t addr, uint8_t i, uint8_t val)
113  {
114    volatile uint8_t *reg = (uint8_t *) addr;
115
116    reg [i] = val; 
117  }
118#endif
119
120unsigned long Console_Configuration_Count = CONSOLE_COUNT;
121console_tbl Console_Configuration_Ports [CONSOLE_COUNT] = {
122  #if QORIQ_UART_0_ENABLE
123    {
124      .sDeviceName = "/dev/ttyS0",
125      .deviceType = SERIAL_NS16550,
126      .pDeviceFns = DEVICE_FNS,
127      .deviceProbe = NULL,
128      .pDeviceFlow = NULL,
129      .ulMargin = 16,
130      .ulHysteresis = 8,
131      .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
132      .ulCtrlPort1 = (uintptr_t) &qoriq.uart_0,
133      .ulCtrlPort2 = 0,
134      .ulDataPort =  (uintptr_t) &qoriq.uart_0,
135      .getRegister = get_register,
136      .setRegister = set_register,
137      .getData = NULL,
138      .setData = NULL,
139      .ulClock = 0,
140      .ulIntVector = QORIQ_IRQ_DUART
141    },
142  #endif
143  #if QORIQ_UART_1_ENABLE
144    {
145      .sDeviceName = "/dev/ttyS1",
146      .deviceType = SERIAL_NS16550,
147      .pDeviceFns = DEVICE_FNS,
148      .deviceProbe = NULL,
149      .pDeviceFlow = NULL,
150      .ulMargin = 16,
151      .ulHysteresis = 8,
152      .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
153      .ulCtrlPort1 = (uintptr_t) &qoriq.uart_1,
154      .ulCtrlPort2 = 0,
155      .ulDataPort =  (uintptr_t) &qoriq.uart_1,
156      .getRegister = get_register,
157      .setRegister = set_register,
158      .getData = NULL,
159      .setData = NULL,
160      .ulClock = 0,
161      .ulIntVector = QORIQ_IRQ_DUART
162    },
163  #endif
164  #if QORIQ_UART_BRIDGE_0_ENABLE
165    {
166      #if QORIQ_UART_1_ENABLE
167        .sDeviceName = "/dev/ttyB0",
168      #else
169        .sDeviceName = "/dev/ttyS0",
170      #endif
171      .deviceType = SERIAL_CUSTOM,
172      .pDeviceFns = BRIDGE_FNS,
173      .pDeviceParams = BRIDGE_0_CONTROL
174    },
175  #endif
176  #if QORIQ_UART_BRIDGE_1_ENABLE
177    {
178      #if QORIQ_UART_1_ENABLE
179        .sDeviceName = "/dev/ttyB1",
180      #else
181        .sDeviceName = "/dev/ttyS1",
182      #endif
183      .deviceType = SERIAL_CUSTOM,
184      .pDeviceFns = BRIDGE_FNS,
185      .pDeviceParams = BRIDGE_1_CONTROL
186    }
187  #endif
188};
189
190static void output_char(char c)
191{
192  const console_fns *con = Console_Port_Tbl [Console_Port_Minor]->pDeviceFns;
193 
194  if (c == '\n') {
195    con->deviceWritePolled((int) Console_Port_Minor, '\r');
196  }
197  con->deviceWritePolled((int) Console_Port_Minor, c);
198}
199
200BSP_output_char_function_type BSP_output_char = output_char;
201
202BSP_polling_getchar_function_type BSP_poll_char = NULL;
Note: See TracBrowser for help on using the repository browser.