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

5
Last change on this file since 458179f1 was 458179f1, checked in by Sebastian Huber <sebastian.huber@…>, on 09/08/17 at 06:51:07

bsp/qoriq: Remove console stuff from bsp_start()

Update #3085.

  • 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-2015 embedded brains GmbH.  All rights reserved.
11 *
12 *  embedded brains GmbH
13 *  Dornierstr. 4
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.org/license/LICENSE.
21 */
22
23#include <rtems/bspIo.h>
24
25#include <libchip/ns16550.h>
26
27#include <bsp.h>
28#include <bsp/irq.h>
29#include <bsp/qoriq.h>
30#include <bsp/intercom.h>
31#include <bsp/uart-bridge.h>
32#include <bsp/console-termios.h>
33
34#if (QORIQ_UART_0_ENABLE + QORIQ_UART_BRIDGE_0_ENABLE == 2) \
35  || (QORIQ_UART_1_ENABLE + QORIQ_UART_BRIDGE_1_ENABLE == 2)
36  #define BRIDGE_MASTER
37#elif QORIQ_UART_BRIDGE_0_ENABLE || QORIQ_UART_BRIDGE_1_ENABLE
38  #define BRIDGE_SLAVE
39#endif
40
41#ifdef BSP_USE_UART_INTERRUPTS
42  #define DEVICE_FNS &ns16550_handler_interrupt
43#else
44  #define DEVICE_FNS &ns16550_handler_polled
45#endif
46
47#if QORIQ_UART_0_ENABLE || QORIQ_UART_1_ENABLE
48  static bool uart_probe(rtems_termios_device_context *base)
49  {
50    ns16550_context *ctx = (ns16550_context *) base;
51
52    ctx->clock = BSP_bus_frequency;
53
54    return ns16550_probe(base);
55  }
56
57  static uint8_t get_register(uintptr_t addr, uint8_t i)
58  {
59    volatile uint8_t *reg = (uint8_t *) addr;
60
61    return reg [i];
62  }
63
64  static void set_register(uintptr_t addr, uint8_t i, uint8_t val)
65  {
66    volatile uint8_t *reg = (uint8_t *) addr;
67
68    reg [i] = val;
69  }
70#endif
71
72#if QORIQ_UART_0_ENABLE
73static ns16550_context qoriq_uart_context_0 = {
74  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 0"),
75  .get_reg = get_register,
76  .set_reg = set_register,
77  .port = (uintptr_t) &qoriq.uart_0,
78  .irq = QORIQ_IRQ_DUART_1,
79  .initial_baud = BSP_CONSOLE_BAUD
80};
81#endif
82
83#if QORIQ_UART_1_ENABLE
84static ns16550_context qoriq_uart_context_1 = {
85  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 1"),
86  .get_reg = get_register,
87  .set_reg = set_register,
88  .port = (uintptr_t) &qoriq.uart_1,
89  .irq = QORIQ_IRQ_DUART_1,
90  .initial_baud = BSP_CONSOLE_BAUD
91};
92#endif
93
94#ifdef BRIDGE_MASTER
95  #define BRIDGE_PROBE qoriq_uart_bridge_master_probe
96  #define BRIDGE_FNS &qoriq_uart_bridge_master
97  #if QORIQ_UART_BRIDGE_0_ENABLE
98    static uart_bridge_master_context bridge_0_context = {
99      .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART Bridge 0"),
100      .device_path = "/dev/ttyS0",
101      .type = INTERCOM_TYPE_UART_0,
102      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
103        bridge_0_context.transmit_fifo
104      )
105    };
106    #define BRIDGE_0_CONTEXT &bridge_0_context.base
107  #endif
108  #if QORIQ_UART_BRIDGE_1_ENABLE
109    static uart_bridge_master_context bridge_1_context = {
110      .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART Bridge 1"),
111      .device_path = "/dev/ttyS1",
112      .type = INTERCOM_TYPE_UART_1,
113      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
114        bridge_1_context.transmit_fifo
115      )
116    };
117    #define BRIDGE_1_CONTEXT &bridge_1_context.base
118  #endif
119#endif
120
121#ifdef BRIDGE_SLAVE
122  #define BRIDGE_PROBE console_device_probe_default
123  #define BRIDGE_FNS &qoriq_uart_bridge_slave
124  #if QORIQ_UART_BRIDGE_0_ENABLE
125    static uart_bridge_slave_context bridge_0_context = {
126      .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART Bridge 0"),
127      .type = INTERCOM_TYPE_UART_0,
128      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
129        bridge_0_context.transmit_fifo
130      )
131    };
132    #define BRIDGE_0_CONTEXT &bridge_0_context.base
133  #endif
134  #if QORIQ_UART_BRIDGE_1_ENABLE
135    static uart_bridge_slave_context bridge_1_context = {
136      .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART Bridge 1"),
137      .type = INTERCOM_TYPE_UART_1,
138      .transmit_fifo = RTEMS_CHAIN_INITIALIZER_EMPTY(
139        bridge_1_context.transmit_fifo
140      )
141    };
142    #define BRIDGE_1_CONTEXT &bridge_1_context.base
143  #endif
144#endif
145
146const console_device console_device_table[] = {
147  #if QORIQ_UART_0_ENABLE
148    {
149      .device_file = "/dev/ttyS0",
150      .probe = uart_probe,
151      .handler = DEVICE_FNS,
152      .context = &qoriq_uart_context_0.base
153    },
154  #endif
155  #if QORIQ_UART_1_ENABLE
156    {
157      .device_file = "/dev/ttyS1",
158      .probe = uart_probe,
159      .handler = DEVICE_FNS,
160      .context = &qoriq_uart_context_1.base
161    },
162  #endif
163  #if QORIQ_UART_BRIDGE_0_ENABLE
164    {
165      #if QORIQ_UART_1_ENABLE
166        .device_file = "/dev/ttyB0",
167      #else
168        .device_file = "/dev/ttyS0",
169      #endif
170      .probe = BRIDGE_PROBE,
171      .handler = BRIDGE_FNS,
172      .context = BRIDGE_0_CONTEXT
173    },
174  #endif
175  #if QORIQ_UART_BRIDGE_1_ENABLE
176    {
177      #if QORIQ_UART_1_ENABLE
178        .device_file = "/dev/ttyB1",
179      #else
180        .device_file = "/dev/ttyS1",
181      #endif
182      .probe = BRIDGE_PROBE,
183      .handler = BRIDGE_FNS,
184      .context = BRIDGE_1_CONTEXT
185    }
186  #endif
187};
188
189const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
190
191static void output_char(char c)
192{
193  rtems_termios_device_context *ctx = console_device_table[0].context;
194
195  ns16550_polled_putchar(ctx, c);
196}
197
198BSP_output_char_function_type BSP_output_char = output_char;
199
200BSP_polling_getchar_function_type BSP_poll_char = NULL;
Note: See TracBrowser for help on using the repository browser.