Ignore:
Timestamp:
Oct 7, 2014, 6:29:16 AM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
2fd3e65f
Parents:
d5cc923f
git-author:
Sebastian Huber <sebastian.huber@…> (10/07/14 06:29:16)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/07/14 14:35:20)
Message:

libchip/serial: Add alternative NS16550 driver

Use the Termios device API.

Location:
c/src/lib/libbsp/arm/lpc24xx/console
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/lpc24xx/console/console-config.c

    rd5cc923f r6ec438e  
    88
    99/*
    10  * Copyright (c) 2008-2011 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2008-2014 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    2121 */
    2222
    23 #include <libchip/serial.h>
     23#include <rtems/console.h>
     24
    2425#include <libchip/ns16550.h>
    2526
     
    2829#include <bsp/irq.h>
    2930#include <bsp/io.h>
     31#include <bsp/console-termios.h>
    3032
    3133static uint8_t lpc24xx_uart_get_register(uintptr_t addr, uint8_t i)
     
    4345}
    4446
    45 console_tbl Console_Configuration_Ports [] = {
     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[] = {
    46100  #ifdef LPC24XX_CONFIG_CONSOLE
    47101    {
    48       .sDeviceName = "/dev/ttyS0",
    49       .deviceType = SERIAL_NS16550_WITH_FDR,
    50       .pDeviceFns = &ns16550_fns,
    51       .deviceProbe = NULL,
    52       .pDeviceFlow = NULL,
    53       .ulMargin = 16,
    54       .ulHysteresis = 8,
    55       .pDeviceParams = (void *) LPC24XX_UART_BAUD,
    56       .ulCtrlPort1 = UART0_BASE_ADDR,
    57       .ulCtrlPort2 = 0,
    58       .ulDataPort = UART0_BASE_ADDR,
    59       .getRegister = lpc24xx_uart_get_register,
    60       .setRegister = lpc24xx_uart_set_register,
    61       .getData = NULL,
    62       .setData = NULL,
    63       .ulClock = LPC24XX_PCLK,
    64       .ulIntVector = LPC24XX_IRQ_UART_0
     102      .device_file = "/dev/ttyS0",
     103      .probe = console_device_probe_default,
     104      .handler = &ns16550_handler_interrupt,
     105      .context = &lpc24xx_uart_context_0.base
    65106    },
    66107  #endif
    67108  #ifdef LPC24XX_CONFIG_UART_1
    68109    {
    69       .sDeviceName = "/dev/ttyS1",
    70       .deviceType = SERIAL_NS16550_WITH_FDR,
    71       .pDeviceFns = &ns16550_fns,
    72       .deviceProbe = lpc24xx_uart_probe_1,
    73       .pDeviceFlow = NULL,
    74       .ulMargin = 16,
    75       .ulHysteresis = 8,
    76       .pDeviceParams = (void *) LPC24XX_UART_BAUD,
    77       .ulCtrlPort1 = UART1_BASE_ADDR,
    78       .ulCtrlPort2 = 0,
    79       .ulDataPort = UART1_BASE_ADDR,
    80       .getRegister = lpc24xx_uart_get_register,
    81       .setRegister = lpc24xx_uart_set_register,
    82       .getData = NULL,
    83       .setData = NULL,
    84       .ulClock = LPC24XX_PCLK,
    85       .ulIntVector = LPC24XX_IRQ_UART_1
     110      .device_file = "/dev/ttyS1",
     111      .probe = lpc24xx_uart_probe_1,
     112      .handler = &ns16550_handler_interrupt,
     113      .context = &lpc24xx_uart_context_1.base
    86114    },
    87115  #endif
    88116  #ifdef LPC24XX_CONFIG_UART_2
    89117    {
    90       .sDeviceName = "/dev/ttyS2",
    91       .deviceType = SERIAL_NS16550_WITH_FDR,
    92       .pDeviceFns = &ns16550_fns,
    93       .deviceProbe = lpc24xx_uart_probe_2,
    94       .pDeviceFlow = NULL,
    95       .ulMargin = 16,
    96       .ulHysteresis = 8,
    97       .pDeviceParams = (void *) LPC24XX_UART_BAUD,
    98       .ulCtrlPort1 = UART2_BASE_ADDR,
    99       .ulCtrlPort2 = 0,
    100       .ulDataPort = UART2_BASE_ADDR,
    101       .getRegister = lpc24xx_uart_get_register,
    102       .setRegister = lpc24xx_uart_set_register,
    103       .getData = NULL,
    104       .setData = NULL,
    105       .ulClock = LPC24XX_PCLK,
    106       .ulIntVector = LPC24XX_IRQ_UART_2
     118      .device_file = "/dev/ttyS2",
     119      .probe = lpc24xx_uart_probe_2,
     120      .handler = &ns16550_handler_interrupt,
     121      .context = &lpc24xx_uart_context_2.base
    107122    },
    108123  #endif
    109124  #ifdef LPC24XX_CONFIG_UART_3
    110125    {
    111       .sDeviceName = "/dev/ttyS3",
    112       .deviceType = SERIAL_NS16550_WITH_FDR,
    113       .pDeviceFns = &ns16550_fns,
    114       .deviceProbe = lpc24xx_uart_probe_3,
    115       .pDeviceFlow = NULL,
    116       .ulMargin = 16,
    117       .ulHysteresis = 8,
    118       .pDeviceParams = (void *) LPC24XX_UART_BAUD,
    119       .ulCtrlPort1 = UART3_BASE_ADDR,
    120       .ulCtrlPort2 = 0,
    121       .ulDataPort = UART3_BASE_ADDR,
    122       .getRegister = lpc24xx_uart_get_register,
    123       .setRegister = lpc24xx_uart_set_register,
    124       .getData = NULL,
    125       .setData = NULL,
    126       .ulClock = LPC24XX_PCLK,
    127       .ulIntVector = LPC24XX_IRQ_UART_3
     126      .device_file = "/dev/ttyS3",
     127      .probe = lpc24xx_uart_probe_3,
     128      .handler = &ns16550_handler_interrupt,
     129      .context = &lpc24xx_uart_context_3.base
    128130    },
    129131  #endif
    130132};
    131133
    132 #define LPC24XX_UART_COUNT \
    133   (sizeof(Console_Configuration_Ports) \
    134     / sizeof(Console_Configuration_Ports [0]))
    135 unsigned long Console_Configuration_Count = LPC24XX_UART_COUNT;
     134const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
  • c/src/lib/libbsp/arm/lpc24xx/console/uart-probe-1.c

    rd5cc923f r6ec438e  
    88
    99/*
    10  * Copyright (c) 2011-2013 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2011-2014 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    2121 */
    2222
     23#include <libchip/ns16550.h>
     24
    2325#include <bsp.h>
    2426#include <bsp/io.h>
    2527
    26 bool lpc24xx_uart_probe_1(int minor)
     28bool lpc24xx_uart_probe_1(rtems_termios_device_context *context)
    2729{
    2830  static const lpc24xx_pin_range pins [] = {
     
    3537  lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
    3638
    37   return true;
     39  return ns16550_probe(context);
    3840}
  • c/src/lib/libbsp/arm/lpc24xx/console/uart-probe-2.c

    rd5cc923f r6ec438e  
    88
    99/*
    10  * Copyright (c) 2011-2013 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2011-2014 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    2121 */
    2222
     23#include <libchip/ns16550.h>
     24
    2325#include <bsp.h>
    2426#include <bsp/io.h>
    2527
    26 bool lpc24xx_uart_probe_2(int minor)
     28bool lpc24xx_uart_probe_2(rtems_termios_device_context *context)
    2729{
    2830  static const lpc24xx_pin_range pins [] = {
     
    3537  lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
    3638
    37   return true;
     39  return ns16550_probe(context);
    3840}
  • c/src/lib/libbsp/arm/lpc24xx/console/uart-probe-3.c

    rd5cc923f r6ec438e  
    88
    99/*
    10  * Copyright (c) 2011-2013 embedded brains GmbH.  All rights reserved.
     10 * Copyright (c) 2011-2014 embedded brains GmbH.  All rights reserved.
    1111 *
    1212 *  embedded brains GmbH
    13  *  Obere Lagerstr. 30
     13 *  Dornierstr. 4
    1414 *  82178 Puchheim
    1515 *  Germany
     
    2121 */
    2222
     23#include <libchip/ns16550.h>
     24
    2325#include <bsp.h>
    2426#include <bsp/io.h>
    2527
    26 bool lpc24xx_uart_probe_3(int minor)
     28bool lpc24xx_uart_probe_3(rtems_termios_device_context *context)
    2729{
    2830  static const lpc24xx_pin_range pins [] = {
     
    3537  lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
    3638
    37   return true;
     39  return ns16550_probe(context);
    3840}
Note: See TracChangeset for help on using the changeset viewer.