source: rtems/c/src/lib/libbsp/arm/lpc24xx/console/console-config.c @ 991fdb33

4.115
Last change on this file since 991fdb33 was 6ec438e, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 7, 2014 at 6:29:16 AM

libchip/serial: Add alternative NS16550 driver

Use the Termios device API.

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