summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/gen83xx
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-10-07 08:29:16 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-10-07 16:35:20 +0200
commit6ec438e8a323cf623cdaecce6f2b3b52b062881a (patch)
tree8cd71b9fb974897a825b36ea1f070dd4405af46f /c/src/lib/libbsp/powerpc/gen83xx
parentbsps: Add Termios console driver initialization (diff)
downloadrtems-6ec438e8a323cf623cdaecce6f2b3b52b062881a.tar.bz2
libchip/serial: Add alternative NS16550 driver
Use the Termios device API.
Diffstat (limited to 'c/src/lib/libbsp/powerpc/gen83xx')
-rw-r--r--c/src/lib/libbsp/powerpc/gen83xx/Makefile.am10
-rw-r--r--c/src/lib/libbsp/powerpc/gen83xx/console/console-config.c114
-rw-r--r--c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c34
3 files changed, 73 insertions, 85 deletions
diff --git a/c/src/lib/libbsp/powerpc/gen83xx/Makefile.am b/c/src/lib/libbsp/powerpc/gen83xx/Makefile.am
index 3e24d308bd..35a093be20 100644
--- a/c/src/lib/libbsp/powerpc/gen83xx/Makefile.am
+++ b/c/src/lib/libbsp/powerpc/gen83xx/Makefile.am
@@ -82,12 +82,10 @@ libbsp_a_SOURCES += ../../shared/src/irq-shell.c
libbsp_a_SOURCES += irq/irq.c
# console
-libbsp_a_SOURCES += ../../shared/console.c \
- ../../shared/console_select.c \
- console/console-config.c \
- ../../shared/console_read.c \
- ../../shared/console_write.c \
- ../../shared/console_control.c
+libbsp_a_SOURCES += ../../shared/console-termios-init.c
+libbsp_a_SOURCES += ../../shared/console-termios.c
+libbsp_a_SOURCES += console/console-config.c
+
# bsp_i2c
libbsp_a_SOURCES += i2c/i2c_init.c
# bsp_spi
diff --git a/c/src/lib/libbsp/powerpc/gen83xx/console/console-config.c b/c/src/lib/libbsp/powerpc/gen83xx/console/console-config.c
index b3ccb9c63f..8dd7249651 100644
--- a/c/src/lib/libbsp/powerpc/gen83xx/console/console-config.c
+++ b/c/src/lib/libbsp/powerpc/gen83xx/console/console-config.c
@@ -5,10 +5,10 @@
*/
/*
- * Copyright (c) 2008, 2010 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2008-2014 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
- * Obere Lagerstr. 30
+ * Dornierstr. 4
* 82178 Puchheim
* Germany
* <rtems@embedded-brains.de>
@@ -20,104 +20,92 @@
#include <rtems/bspIo.h>
-#include <libchip/serial.h>
#include <libchip/ns16550.h>
-#include "../../../shared/console_private.h"
#include <mpc83xx/mpc83xx.h>
-#include <bspopts.h>
+#include <bsp.h>
#include <bsp/irq.h>
-
-#ifdef BSP_USE_UART2
- #define PORT_COUNT 2
-#else
- #define PORT_COUNT 1
-#endif
+#include <bsp/console-termios.h>
#ifdef BSP_USE_UART_INTERRUPTS
- #define DEVICE_FNS &ns16550_fns
+ #define DEVICE_FNS &ns16550_handler_interrupt
#else
- #define DEVICE_FNS &ns16550_fns_polled
+ #define DEVICE_FNS &ns16550_handler_polled
#endif
-static uint8_t gen83xx_console_get_register(uint32_t addr, uint8_t i)
+static uint8_t gen83xx_console_get_register(uintptr_t addr, uint8_t i)
{
volatile uint8_t *reg = (volatile uint8_t *) addr;
return reg [i];
}
-static void gen83xx_console_set_register(uint32_t addr, uint8_t i, uint8_t val)
+static void gen83xx_console_set_register(uintptr_t addr, uint8_t i, uint8_t val)
{
volatile uint8_t *reg = (volatile uint8_t *) addr;
- reg [i] = val;
+ reg [i] = val;
}
-unsigned long Console_Configuration_Count = PORT_COUNT;
-
-console_tbl Console_Configuration_Ports [PORT_COUNT] = {
- {
- .sDeviceName = "/dev/ttyS0",
- .deviceType = SERIAL_NS16550,
- .pDeviceFns = DEVICE_FNS,
- .deviceProbe = NULL,
- .pDeviceFlow = NULL,
- .ulMargin = 16,
- .ulHysteresis = 8,
- .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
- .ulCtrlPort1 = (uint32_t) &mpc83xx.duart [0],
- .ulCtrlPort2 = 0,
- .ulDataPort = (uint32_t) &mpc83xx.duart [0],
- .getRegister = gen83xx_console_get_register,
- .setRegister = gen83xx_console_set_register,
- .getData = NULL,
- .setData = NULL,
- .ulClock = 0,
+static ns16550_context gen83xx_uart_context_0 = {
+ .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 0"),
+ .get_reg = gen83xx_console_get_register,
+ .set_reg = gen83xx_console_set_register,
+ .port = (uintptr_t) &mpc83xx.duart[0],
#if MPC83XX_CHIP_TYPE / 10 == 830
- .ulIntVector = BSP_IPIC_IRQ_UART
+ .irq = BSP_IPIC_IRQ_UART,
#else
- .ulIntVector = BSP_IPIC_IRQ_UART1
+ .irq = BSP_IPIC_IRQ_UART1,
#endif
- }
+ .initial_baud = BSP_CONSOLE_BAUD
+};
+
#ifdef BSP_USE_UART2
- , {
- .sDeviceName = "/dev/ttyS1",
- .deviceType = SERIAL_NS16550,
- .pDeviceFns = DEVICE_FNS,
- .deviceProbe = NULL,
- .pDeviceFlow = NULL,
- .ulMargin = 16,
- .ulHysteresis = 8,
- .pDeviceParams = (void *) BSP_CONSOLE_BAUD,
- .ulCtrlPort1 = (uint32_t) &mpc83xx.duart [1],
- .ulCtrlPort2 = 0,
- .ulDataPort = (uint32_t) &mpc83xx.duart [1],
- .getRegister = gen83xx_console_get_register,
- .setRegister = gen83xx_console_set_register,
- .getData = NULL,
- .setData = NULL,
- .ulClock = 0,
+static ns16550_context gen83xx_uart_context_1 = {
+ .base = RTEMS_TERMIOS_DEVICE_CONTEXT_INITIALIZER("UART 1"),
+ .get_reg = gen83xx_console_get_register,
+ .set_reg = gen83xx_console_set_register,
+ .port = (uintptr_t) &mpc83xx.duart[1],
#if MPC83XX_CHIP_TYPE / 10 == 830
- .ulIntVector = BSP_IPIC_IRQ_UART
+ .irq = BSP_IPIC_IRQ_UART,
#else
- .ulIntVector = BSP_IPIC_IRQ_UART2
+ .irq = BSP_IPIC_IRQ_UART2,
#endif
+ .initial_baud = BSP_CONSOLE_BAUD
+};
+#endif
+
+const console_device console_device_table[] = {
+ {
+ .device_file = "/dev/ttyS0",
+ .probe = ns16550_probe,
+ .handler = DEVICE_FNS,
+ .context = &gen83xx_uart_context_0.base
+ }
+#ifdef BSP_USE_UART2
+ , {
+ .device_file = "/dev/ttyS1",
+ .probe = ns16550_probe,
+ .handler = DEVICE_FNS,
+ .context = &gen83xx_uart_context_1.base
}
#endif
};
+const size_t console_device_count = RTEMS_ARRAY_SIZE(console_device_table);
+
static void gen83xx_output_char(char c)
{
- const console_fns *console = Console_Port_Tbl [Console_Port_Minor]->pDeviceFns;
-
+ rtems_termios_device_context *ctx = console_device_table[0].context;
+
if (c == '\n') {
- console->deviceWritePolled((int) Console_Port_Minor, '\r');
+ ns16550_polled_putchar(ctx, '\r');
}
- console->deviceWritePolled((int) Console_Port_Minor, c);
+
+ ns16550_polled_putchar(ctx, c);
}
-BSP_output_char_function_type BSP_output_char = gen83xx_output_char;
+BSP_output_char_function_type BSP_output_char = gen83xx_output_char;
BSP_polling_getchar_function_type BSP_poll_char = NULL;
diff --git a/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c b/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c
index 4428b8df19..f1ffcac9e1 100644
--- a/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c
+++ b/c/src/lib/libbsp/powerpc/gen83xx/startup/bspstart.c
@@ -7,12 +7,13 @@
*/
/*
- * Copyright (c) 2008
- * Embedded Brains GmbH
- * Obere Lagerstr. 30
- * D-82178 Puchheim
- * Germany
- * rtems@embedded-brains.de
+ * Copyright (c) 2008-2014 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Dornierstr. 4
+ * 82178 Puchheim
+ * Germany
+ * <info@embedded-brains.de>
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
@@ -21,7 +22,7 @@
#include <rtems/counter.h>
-#include <libchip/serial.h>
+#include <libchip/ns16550.h>
#include <libcpu/powerpc-utility.h>
@@ -31,6 +32,7 @@
#include <bsp/irq-generic.h>
#include <bsp/linker-symbols.h>
#include <bsp/u-boot.h>
+#include <bsp/console-termios.h>
/* Configuration parameters for console driver, ... */
unsigned int BSP_bus_frequency;
@@ -54,6 +56,7 @@ void BSP_panic(char *s)
rtems_interrupt_level level;
rtems_interrupt_disable(level);
+ (void) level;
printk("%s PANIC %s\n", rtems_get_version_string(), s);
@@ -67,6 +70,7 @@ void _BSP_Fatal_error(unsigned n)
rtems_interrupt_level level;
rtems_interrupt_disable( level);
+ (void) level;
printk( "%s PANIC ERROR %u\n", rtems_get_version_string(), n);
@@ -80,15 +84,12 @@ void bsp_start( void)
rtems_status_code sc = RTEMS_SUCCESSFUL;
unsigned long i = 0;
- ppc_cpu_id_t myCpu;
- ppc_cpu_revision_t myCpuRevision;
-
/*
* Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
* store the result in global variables so that it can be used latter...
*/
- myCpu = get_ppc_cpu_type();
- myCpuRevision = get_ppc_cpu_revision();
+ get_ppc_cpu_type();
+ get_ppc_cpu_revision();
/* Basic CPU initialization */
cpu_init();
@@ -122,12 +123,13 @@ void bsp_start( void)
rtems_counter_initialize_converter(bsp_time_base_frequency);
/* Initialize some console parameters */
- for (i = 0; i < Console_Configuration_Count; ++i) {
- Console_Configuration_Ports [i].ulClock = BSP_bus_frequency;
+ for (i = 0; i < console_device_count; ++i) {
+ ns16550_context *ctx = (ns16550_context *) console_device_table[i].context;
+
+ ctx->clock = BSP_bus_frequency;
#ifdef HAS_UBOOT
- Console_Configuration_Ports [i].pDeviceParams =
- (void *) bsp_uboot_board_info.bi_baudrate;
+ ctx->initial_baud = bsp_uboot_board_info.bi_baudrate;
#endif
}