source: rtems/bsps/arm/lpc24xx/console/console-config.c @ ba619b7f

Last change on this file since ba619b7f was ba619b7f, checked in by Joel Sherrill <joel@…>, on 03/01/22 at 21:38:20

bsps/arm/: Scripted embedded brains header file clean up

Updates #4625.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup RTEMSBSPsARMLPC24XX
5 *
6 * @brief Console configuration.
7 */
8
9/*
10 * Copyright (c) 2008-2014 embedded brains GmbH.  All rights reserved.
11 *
12 * The license and distribution terms for this file may be
13 * found in the file LICENSE in this distribution or at
14 * http://www.rtems.org/license/LICENSE.
15 */
16
17#include <rtems/console.h>
18
19#include <libchip/ns16550.h>
20
21#include <bsp.h>
22#include <bsp/lpc24xx.h>
23#include <bsp/irq.h>
24#include <bsp/io.h>
25#include <bsp/console-termios.h>
26
27static uint8_t lpc24xx_uart_get_register(uintptr_t addr, uint8_t i)
28{
29  volatile uint32_t *reg = (volatile uint32_t *) addr;
30
31  return (uint8_t) reg [i];
32}
33
34static void lpc24xx_uart_set_register(uintptr_t addr, uint8_t i, uint8_t val)
35{
36  volatile uint32_t *reg = (volatile uint32_t *) addr;
37
38  reg [i] = val;
39}
40
41#ifdef LPC24XX_CONFIG_CONSOLE
42static ns16550_context lpc24xx_uart_context_0 = {
43  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 0"),
44  .get_reg = lpc24xx_uart_get_register,
45  .set_reg = lpc24xx_uart_set_register,
46  .port = UART0_BASE_ADDR,
47  .irq = LPC24XX_IRQ_UART_0,
48  .clock = LPC24XX_PCLK,
49  .initial_baud = LPC24XX_UART_BAUD,
50  .has_fractional_divider_register = true
51};
52#endif
53
54#ifdef LPC24XX_CONFIG_UART_1
55static ns16550_context lpc24xx_uart_context_1 = {
56  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 1"),
57  .get_reg = lpc24xx_uart_get_register,
58  .set_reg = lpc24xx_uart_set_register,
59  .port = UART1_BASE_ADDR,
60  .irq = LPC24XX_IRQ_UART_1,
61  .clock = LPC24XX_PCLK,
62  .initial_baud = LPC24XX_UART_BAUD,
63  .has_fractional_divider_register = true
64};
65#endif
66
67#ifdef LPC24XX_CONFIG_UART_2
68static ns16550_context lpc24xx_uart_context_2 = {
69  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 2"),
70  .get_reg = lpc24xx_uart_get_register,
71  .set_reg = lpc24xx_uart_set_register,
72  .port = UART2_BASE_ADDR,
73  .irq = LPC24XX_IRQ_UART_2,
74  .clock = LPC24XX_PCLK,
75  .initial_baud = LPC24XX_UART_BAUD,
76  .has_fractional_divider_register = true
77};
78#endif
79
80#ifdef LPC24XX_CONFIG_UART_3
81static ns16550_context lpc24xx_uart_context_3 = {
82  .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 3"),
83  .get_reg = lpc24xx_uart_get_register,
84  .set_reg = lpc24xx_uart_set_register,
85  .port = UART3_BASE_ADDR,
86  .irq = LPC24XX_IRQ_UART_3,
87  .clock = LPC24XX_PCLK,
88  .initial_baud = LPC24XX_UART_BAUD,
89  .has_fractional_divider_register = true
90};
91#endif
92
93const console_device console_device_table[] = {
94  #ifdef LPC24XX_CONFIG_CONSOLE
95    {
96      .device_file = "/dev/ttyS0",
97      .probe = console_device_probe_default,
98      .handler = &ns16550_handler_interrupt,
99      .context = &lpc24xx_uart_context_0.base
100    },
101  #endif
102  #ifdef LPC24XX_CONFIG_UART_1
103    {
104      .device_file = "/dev/ttyS1",
105      .probe = lpc24xx_uart_probe_1,
106      .handler = &ns16550_handler_interrupt,
107      .context = &lpc24xx_uart_context_1.base
108    },
109  #endif
110  #ifdef LPC24XX_CONFIG_UART_2
111    {
112      .device_file = "/dev/ttyS2",
113      .probe = lpc24xx_uart_probe_2,
114      .handler = &ns16550_handler_interrupt,
115      .context = &lpc24xx_uart_context_2.base
116    },
117  #endif
118  #ifdef LPC24XX_CONFIG_UART_3
119    {
120      .device_file = "/dev/ttyS3",
121      .probe = lpc24xx_uart_probe_3,
122      .handler = &ns16550_handler_interrupt,
123      .context = &lpc24xx_uart_context_3.base
124    },
125  #endif
126};
127
128const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
Note: See TracBrowser for help on using the repository browser.