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

4.115
Last change on this file since d74ed4a was d74ed4a, checked in by Sebastian Huber <sebastian.huber@…>, on May 19, 2011 at 12:30:00 PM

2011-05-19 Sebastian Huber <sebastian.huber@…>

  • i2c/i2c-config.c: New file.
  • include/lcd.h: Removed EMC definitions.
  • misc/dma.c: Fixed initialization.
  • include/i2c.h, include/io.h, include/lpc-ethernet-config.h, include/lpc24xx.h, console/console-config.c, i2c/i2c.c, misc/io.c, misc/lcd.c, startup/bspstart.c, startup/bspstarthooks.c: New pin configuration API.
  • Makefile.am, preinstall.am: Update.
  • 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 found in the file
19 * LICENSE in this distribution or at http://www.rtems.com/license/LICENSE.
20 */
21
22#include <libchip/serial.h>
23#include <libchip/ns16550.h>
24
25#include <bsp.h>
26#include <bsp/lpc24xx.h>
27#include <bsp/irq.h>
28#include <bsp/io.h>
29
30static uint8_t lpc24xx_uart_get_register(uint32_t addr, uint8_t i)
31{
32  volatile uint32_t *reg = (volatile uint32_t *) addr;
33
34  return (uint8_t) reg [i];
35}
36
37static void lpc24xx_uart_set_register(uint32_t addr, uint8_t i, uint8_t val)
38{
39  volatile uint32_t *reg = (volatile uint32_t *) addr;
40
41  reg [i] = val;
42}
43
44#ifdef LPC24XX_CONFIG_UART_1
45  static bool lpc24xx_uart_probe_1(int minor)
46  {
47    static const lpc24xx_pin_range pins [] = {
48      LPC24XX_PIN_UART_1_TXD_P0_15,
49      LPC24XX_PIN_UART_1_RXD_P0_16,
50      LPC24XX_PIN_TERMINAL
51    };
52
53    lpc24xx_module_enable(LPC24XX_MODULE_UART_1, LPC24XX_MODULE_CCLK);
54    lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
55
56    return true;
57  }
58#endif
59
60#ifdef LPC24XX_CONFIG_UART_2
61  static bool lpc24xx_uart_probe_2(int minor)
62  {
63    static const lpc24xx_pin_range pins [] = {
64      LPC24XX_PIN_UART_2_TXD_P0_10,
65      LPC24XX_PIN_UART_2_RXD_P0_11,
66      LPC24XX_PIN_TERMINAL
67    };
68
69    lpc24xx_module_enable(LPC24XX_MODULE_UART_2, LPC24XX_MODULE_CCLK);
70    lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
71
72    return true;
73  }
74#endif
75
76#ifdef LPC24XX_CONFIG_UART_3
77  static bool lpc24xx_uart_probe_3(int minor)
78  {
79    static const lpc24xx_pin_range pins [] = {
80      LPC24XX_PIN_UART_3_TXD_P0_0,
81      LPC24XX_PIN_UART_3_RXD_P0_1,
82      LPC24XX_PIN_TERMINAL
83    };
84
85    lpc24xx_module_enable(LPC24XX_MODULE_UART_3, LPC24XX_MODULE_CCLK);
86    lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
87
88    return true;
89  }
90#endif
91
92rtems_device_minor_number Console_Port_Minor = 0;
93
94console_tbl Console_Port_Tbl [] = {
95  #ifdef LPC24XX_CONFIG_CONSOLE
96    {
97      .sDeviceName = "/dev/ttyS0",
98      .deviceType = SERIAL_NS16550,
99      .pDeviceFns = &ns16550_fns,
100      .deviceProbe = NULL,
101      .pDeviceFlow = NULL,
102      .ulMargin = 16,
103      .ulHysteresis = 8,
104      .pDeviceParams = (void *) LPC24XX_UART_BAUD,
105      .ulCtrlPort1 = UART0_BASE_ADDR,
106      .ulCtrlPort2 = 0,
107      .ulDataPort = UART0_BASE_ADDR,
108      .getRegister = lpc24xx_uart_get_register,
109      .setRegister = lpc24xx_uart_set_register,
110      .getData = NULL,
111      .setData = NULL,
112      .ulClock = LPC24XX_CCLK,
113      .ulIntVector = LPC24XX_IRQ_UART_0
114    },
115  #endif
116  #ifdef LPC24XX_CONFIG_UART_1
117    {
118      .sDeviceName = "/dev/ttyS1",
119      .deviceType = SERIAL_NS16550,
120      .pDeviceFns = &ns16550_fns,
121      .deviceProbe = lpc24xx_uart_probe_1,
122      .pDeviceFlow = NULL,
123      .ulMargin = 16,
124      .ulHysteresis = 8,
125      .pDeviceParams = (void *) LPC24XX_UART_BAUD,
126      .ulCtrlPort1 = UART1_BASE_ADDR,
127      .ulCtrlPort2 = 0,
128      .ulDataPort = UART1_BASE_ADDR,
129      .getRegister = lpc24xx_uart_get_register,
130      .setRegister = lpc24xx_uart_set_register,
131      .getData = NULL,
132      .setData = NULL,
133      .ulClock = LPC24XX_CCLK,
134      .ulIntVector = LPC24XX_IRQ_UART_1
135    },
136  #endif
137  #ifdef LPC24XX_CONFIG_UART_2
138    {
139      .sDeviceName = "/dev/ttyS2",
140      .deviceType = SERIAL_NS16550,
141      .pDeviceFns = &ns16550_fns,
142      .deviceProbe = lpc24xx_uart_probe_2,
143      .pDeviceFlow = NULL,
144      .ulMargin = 16,
145      .ulHysteresis = 8,
146      .pDeviceParams = (void *) LPC24XX_UART_BAUD,
147      .ulCtrlPort1 = UART2_BASE_ADDR,
148      .ulCtrlPort2 = 0,
149      .ulDataPort = UART2_BASE_ADDR,
150      .getRegister = lpc24xx_uart_get_register,
151      .setRegister = lpc24xx_uart_set_register,
152      .getData = NULL,
153      .setData = NULL,
154      .ulClock = LPC24XX_CCLK,
155      .ulIntVector = LPC24XX_IRQ_UART_2
156    },
157  #endif
158  #ifdef LPC24XX_CONFIG_UART_3
159    {
160      .sDeviceName = "/dev/ttyS3",
161      .deviceType = SERIAL_NS16550,
162      .pDeviceFns = &ns16550_fns,
163      .deviceProbe = lpc24xx_uart_probe_3,
164      .pDeviceFlow = NULL,
165      .ulMargin = 16,
166      .ulHysteresis = 8,
167      .pDeviceParams = (void *) LPC24XX_UART_BAUD,
168      .ulCtrlPort1 = UART3_BASE_ADDR,
169      .ulCtrlPort2 = 0,
170      .ulDataPort = UART3_BASE_ADDR,
171      .getRegister = lpc24xx_uart_get_register,
172      .setRegister = lpc24xx_uart_set_register,
173      .getData = NULL,
174      .setData = NULL,
175      .ulClock = LPC24XX_CCLK,
176      .ulIntVector = LPC24XX_IRQ_UART_3
177    },
178  #endif
179};
180
181#define LPC24XX_UART_COUNT \
182  (sizeof(Console_Port_Tbl) / sizeof(Console_Port_Tbl [0]))
183
184unsigned long Console_Port_Count = LPC24XX_UART_COUNT;
185
186console_data Console_Port_Data [LPC24XX_UART_COUNT];
Note: See TracBrowser for help on using the repository browser.