source: rtems/bsps/powerpc/gen83xx/console/console-config.c @ 8f8ccee

5
Last change on this file since 8f8ccee was d7d66d7, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 19, 2018 at 4:28:01 AM

bsps: Move console drivers to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/**
2 * @file
3 *
4 * @brief Console configuration.
5 */
6
7/*
8 * Copyright (c) 2008-2014 embedded brains GmbH.  All rights reserved.
9 *
10 *  embedded brains GmbH
11 *  Dornierstr. 4
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.org/license/LICENSE.
19 */
20
21#include <rtems/bspIo.h>
22
23#include <libchip/ns16550.h>
24
25#include <mpc83xx/mpc83xx.h>
26
27#include <bsp.h>
28#include <bsp/irq.h>
29#include <bsp/console-termios.h>
30
31#ifdef BSP_USE_UART_INTERRUPTS
32  #define DEVICE_FNS &ns16550_handler_interrupt
33#else
34  #define DEVICE_FNS &ns16550_handler_polled
35#endif
36
37static uint8_t gen83xx_console_get_register(uintptr_t addr, uint8_t i)
38{
39  volatile uint8_t *reg = (volatile uint8_t *) addr;
40
41  return reg [i];
42}
43
44static void gen83xx_console_set_register(uintptr_t addr, uint8_t i, uint8_t val)
45{
46  volatile uint8_t *reg = (volatile uint8_t *) addr;
47
48  reg [i] = val;
49}
50
51static ns16550_context gen83xx_uart_context_0 = {
52  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 0"),
53  .get_reg = gen83xx_console_get_register,
54  .set_reg = gen83xx_console_set_register,
55  .port = (uintptr_t) &mpc83xx.duart[0],
56#if MPC83XX_CHIP_TYPE / 10 == 830
57   .irq = BSP_IPIC_IRQ_UART,
58#else
59   .irq = BSP_IPIC_IRQ_UART1,
60#endif
61  .initial_baud = BSP_CONSOLE_BAUD
62};
63
64#ifdef BSP_USE_UART2
65static ns16550_context gen83xx_uart_context_1 = {
66  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 1"),
67  .get_reg = gen83xx_console_get_register,
68  .set_reg = gen83xx_console_set_register,
69  .port = (uintptr_t) &mpc83xx.duart[1],
70#if MPC83XX_CHIP_TYPE / 10 == 830
71  .irq = BSP_IPIC_IRQ_UART,
72#else
73  .irq = BSP_IPIC_IRQ_UART2,
74#endif
75  .initial_baud = BSP_CONSOLE_BAUD
76};
77#endif
78
79const console_device console_device_table[] = {
80  {
81    .device_file = "/dev/ttyS0",
82    .probe = ns16550_probe,
83    .handler = DEVICE_FNS,
84    .context = &gen83xx_uart_context_0.base
85  }
86#ifdef BSP_USE_UART2
87  , {
88    .device_file = "/dev/ttyS1",
89    .probe = ns16550_probe,
90    .handler = DEVICE_FNS,
91    .context = &gen83xx_uart_context_1.base
92  }
93#endif
94};
95
96const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
97
98static void gen83xx_output_char(char c)
99{
100  rtems_termios_device_context *ctx = console_device_table[0].context;
101
102  ns16550_polled_putchar(ctx, c);
103}
104
105BSP_output_char_function_type BSP_output_char = gen83xx_output_char;
106
107BSP_polling_getchar_function_type BSP_poll_char = NULL;
Note: See TracBrowser for help on using the repository browser.