source: rtems/c/src/lib/libbsp/arm/lpc24xx/console/console-config.c @ 0e27119

4.11
Last change on this file since 0e27119 was 0e27119, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 11, 2012 at 8:52:18 PM

Use proper 3 line form of license text

  • Property mode set to 100644
File size: 4.8 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup lpc24xx
5 *
6 * @brief Console configuration.
7 */
8
9/*
10 * Copyright (c) 2008-2011 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
23#include <libchip/serial.h>
24#include <libchip/ns16550.h>
25
26#include <bsp.h>
27#include <bsp/lpc24xx.h>
28#include <bsp/irq.h>
29#include <bsp/io.h>
30
31static uint8_t lpc24xx_uart_get_register(uint32_t addr, uint8_t i)
32{
33  volatile uint32_t *reg = (volatile uint32_t *) addr;
34
35  return (uint8_t) reg [i];
36}
37
38static void lpc24xx_uart_set_register(uint32_t addr, uint8_t i, uint8_t val)
39{
40  volatile uint32_t *reg = (volatile uint32_t *) addr;
41
42  reg [i] = val;
43}
44
45#ifdef LPC24XX_CONFIG_UART_1
46  static bool lpc24xx_uart_probe_1(int minor)
47  {
48    static const lpc24xx_pin_range pins [] = {
49      LPC24XX_PIN_UART_1_TXD_P0_15,
50      LPC24XX_PIN_UART_1_RXD_P0_16,
51      LPC24XX_PIN_TERMINAL
52    };
53
54    lpc24xx_module_enable(LPC24XX_MODULE_UART_1, LPC24XX_MODULE_PCLK_DEFAULT);
55    lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
56
57    return true;
58  }
59#endif
60
61#ifdef LPC24XX_CONFIG_UART_2
62  static bool lpc24xx_uart_probe_2(int minor)
63  {
64    static const lpc24xx_pin_range pins [] = {
65      LPC24XX_PIN_UART_2_TXD_P0_10,
66      LPC24XX_PIN_UART_2_RXD_P0_11,
67      LPC24XX_PIN_TERMINAL
68    };
69
70    lpc24xx_module_enable(LPC24XX_MODULE_UART_2, LPC24XX_MODULE_PCLK_DEFAULT);
71    lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
72
73    return true;
74  }
75#endif
76
77#ifdef LPC24XX_CONFIG_UART_3
78  static bool lpc24xx_uart_probe_3(int minor)
79  {
80    static const lpc24xx_pin_range pins [] = {
81      LPC24XX_PIN_UART_3_TXD_P0_0,
82      LPC24XX_PIN_UART_3_RXD_P0_1,
83      LPC24XX_PIN_TERMINAL
84    };
85
86    lpc24xx_module_enable(LPC24XX_MODULE_UART_3, LPC24XX_MODULE_PCLK_DEFAULT);
87    lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
88
89    return true;
90  }
91#endif
92
93console_tbl Console_Configuration_Ports [] = {
94  #ifdef LPC24XX_CONFIG_CONSOLE
95    {
96      .sDeviceName = "/dev/ttyS0",
97      .deviceType = SERIAL_NS16550_WITH_FDR,
98      .pDeviceFns = &ns16550_fns,
99      .deviceProbe = NULL,
100      .pDeviceFlow = NULL,
101      .ulMargin = 16,
102      .ulHysteresis = 8,
103      .pDeviceParams = (void *) LPC24XX_UART_BAUD,
104      .ulCtrlPort1 = UART0_BASE_ADDR,
105      .ulCtrlPort2 = 0,
106      .ulDataPort = UART0_BASE_ADDR,
107      .getRegister = lpc24xx_uart_get_register,
108      .setRegister = lpc24xx_uart_set_register,
109      .getData = NULL,
110      .setData = NULL,
111      .ulClock = LPC24XX_PCLK,
112      .ulIntVector = LPC24XX_IRQ_UART_0
113    },
114  #endif
115  #ifdef LPC24XX_CONFIG_UART_1
116    {
117      .sDeviceName = "/dev/ttyS1",
118      .deviceType = SERIAL_NS16550_WITH_FDR,
119      .pDeviceFns = &ns16550_fns,
120      .deviceProbe = lpc24xx_uart_probe_1,
121      .pDeviceFlow = NULL,
122      .ulMargin = 16,
123      .ulHysteresis = 8,
124      .pDeviceParams = (void *) LPC24XX_UART_BAUD,
125      .ulCtrlPort1 = UART1_BASE_ADDR,
126      .ulCtrlPort2 = 0,
127      .ulDataPort = UART1_BASE_ADDR,
128      .getRegister = lpc24xx_uart_get_register,
129      .setRegister = lpc24xx_uart_set_register,
130      .getData = NULL,
131      .setData = NULL,
132      .ulClock = LPC24XX_PCLK,
133      .ulIntVector = LPC24XX_IRQ_UART_1
134    },
135  #endif
136  #ifdef LPC24XX_CONFIG_UART_2
137    {
138      .sDeviceName = "/dev/ttyS2",
139      .deviceType = SERIAL_NS16550_WITH_FDR,
140      .pDeviceFns = &ns16550_fns,
141      .deviceProbe = lpc24xx_uart_probe_2,
142      .pDeviceFlow = NULL,
143      .ulMargin = 16,
144      .ulHysteresis = 8,
145      .pDeviceParams = (void *) LPC24XX_UART_BAUD,
146      .ulCtrlPort1 = UART2_BASE_ADDR,
147      .ulCtrlPort2 = 0,
148      .ulDataPort = UART2_BASE_ADDR,
149      .getRegister = lpc24xx_uart_get_register,
150      .setRegister = lpc24xx_uart_set_register,
151      .getData = NULL,
152      .setData = NULL,
153      .ulClock = LPC24XX_PCLK,
154      .ulIntVector = LPC24XX_IRQ_UART_2
155    },
156  #endif
157  #ifdef LPC24XX_CONFIG_UART_3
158    {
159      .sDeviceName = "/dev/ttyS3",
160      .deviceType = SERIAL_NS16550_WITH_FDR,
161      .pDeviceFns = &ns16550_fns,
162      .deviceProbe = lpc24xx_uart_probe_3,
163      .pDeviceFlow = NULL,
164      .ulMargin = 16,
165      .ulHysteresis = 8,
166      .pDeviceParams = (void *) LPC24XX_UART_BAUD,
167      .ulCtrlPort1 = UART3_BASE_ADDR,
168      .ulCtrlPort2 = 0,
169      .ulDataPort = UART3_BASE_ADDR,
170      .getRegister = lpc24xx_uart_get_register,
171      .setRegister = lpc24xx_uart_set_register,
172      .getData = NULL,
173      .setData = NULL,
174      .ulClock = LPC24XX_PCLK,
175      .ulIntVector = LPC24XX_IRQ_UART_3
176    },
177  #endif
178};
179
180#define LPC24XX_UART_COUNT \
181  (sizeof(Console_Configuration_Ports) \
182    / sizeof(Console_Configuration_Ports [0]))
183unsigned long Console_Configuration_Count = LPC24XX_UART_COUNT;
Note: See TracBrowser for help on using the repository browser.