summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/arm/shared/arm-pl050.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libbsp/arm/shared/arm-pl050.c')
-rw-r--r--c/src/lib/libbsp/arm/shared/arm-pl050.c95
1 files changed, 39 insertions, 56 deletions
diff --git a/c/src/lib/libbsp/arm/shared/arm-pl050.c b/c/src/lib/libbsp/arm/shared/arm-pl050.c
index 292934a8c2..0b645095b5 100644
--- a/c/src/lib/libbsp/arm/shared/arm-pl050.c
+++ b/c/src/lib/libbsp/arm/shared/arm-pl050.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013 embedded brains GmbH. All rights reserved.
+ * Copyright (c) 2013-2014 embedded brains GmbH. All rights reserved.
*
* embedded brains GmbH
* Dornierstr. 4
@@ -16,22 +16,19 @@
#include <bsp/irq.h>
#include <bsp/arm-pl050.h>
-#include <bsp/arm-pl050-regs.h>
-#include <libchip/sersupp.h>
-
-static volatile pl050 *pl050_get_regs(int minor)
+static volatile pl050 *pl050_get_regs(rtems_termios_device_context *base)
{
- const console_tbl *ct = Console_Port_Tbl[minor];
+ arm_pl050_context *ctx = (arm_pl050_context *) base;
- return (volatile pl050 *) ct->ulCtrlPort1;
+ return ctx->regs;
}
static void pl050_interrupt(void *arg)
{
- int minor = (int) arg;
- const console_data *cd = &Console_Port_Data[minor];
- volatile pl050 *regs = pl050_get_regs(minor);
+ rtems_termios_tty *tty = arg;
+ rtems_termios_device_context *base = rtems_termios_get_device_context(tty);
+ volatile pl050 *regs = pl050_get_regs(base);
uint32_t kmiir_rx = PL050_KMIIR_KMIRXINTR;
uint32_t kmiir_tx = (regs->kmicr & PL050_KMICR_KMITXINTREN) != 0 ?
PL050_KMIIR_KMITXINTR : 0;
@@ -40,70 +37,68 @@ static void pl050_interrupt(void *arg)
if ((kmiir & kmiir_rx) != 0) {
char c = (char) PL050_KMIDATA_KMIDATA_GET(regs->kmidata);
- rtems_termios_enqueue_raw_characters(cd->termios_data, &c, 1);
+ rtems_termios_enqueue_raw_characters(tty, &c, 1);
}
if ((kmiir & kmiir_tx) != 0) {
- rtems_termios_dequeue_characters(cd->termios_data, 1);
+ rtems_termios_dequeue_characters(tty, 1);
}
}
-static void pl050_initialize(int minor)
-{
- /* Nothing to do */
-}
-
-static int pl050_first_open(int major, int minor, void *arg)
+static bool pl050_first_open(
+ struct rtems_termios_tty *tty,
+ rtems_termios_device_context *base,
+ struct termios *term,
+ rtems_libio_open_close_args_t *args
+)
{
- rtems_libio_open_close_args_t *oc = (rtems_libio_open_close_args_t *) arg;
- struct rtems_termios_tty *tty = (struct rtems_termios_tty *) oc->iop->data1;
- console_data *cd = &Console_Port_Data[minor];
- const console_tbl *ct = Console_Port_Tbl[minor];
- volatile pl050 *regs = pl050_get_regs(minor);
+ arm_pl050_context *ctx = (arm_pl050_context *) base;
+ volatile pl050 *regs = pl050_get_regs(base);
rtems_status_code sc;
- cd->termios_data = tty;
- rtems_termios_set_initial_baud(tty, (rtems_termios_baud_t) ct->pDeviceParams);
+ rtems_termios_set_initial_baud(tty, ctx->initial_baud);
regs->kmicr = PL050_KMICR_KMIEN | PL050_KMICR_KMIRXINTREN;
sc = rtems_interrupt_handler_install(
- ct->ulIntVector,
- ct->sDeviceName,
+ ctx->irq,
+ "PL050",
RTEMS_INTERRUPT_UNIQUE,
pl050_interrupt,
- (void *) minor
+ tty
);
assert(sc == RTEMS_SUCCESSFUL);
- return 0;
+ return true;
}
-static int pl050_last_close(int major, int minor, void *arg)
+static void pl050_last_close(
+ struct rtems_termios_tty *tty,
+ rtems_termios_device_context *base,
+ rtems_libio_open_close_args_t *args
+)
{
- const console_tbl *ct = Console_Port_Tbl[minor];
- volatile pl050 *regs = pl050_get_regs(minor);
+ arm_pl050_context *ctx = (arm_pl050_context *) base;
+ volatile pl050 *regs = pl050_get_regs(base);
rtems_status_code sc;
regs->kmicr = 0;
sc = rtems_interrupt_handler_remove(
- ct->ulIntVector,
+ ctx->irq,
pl050_interrupt,
- (void *) minor
+ tty
);
assert(sc == RTEMS_SUCCESSFUL);
-
- return 0;
}
-static ssize_t pl050_write_support(
- int minor,
+static void pl050_write_support(
+ rtems_termios_device_context *base,
const char *s,
size_t n
)
{
- volatile pl050 *regs = pl050_get_regs(minor);
+ volatile pl050 *regs = pl050_get_regs(base);
if (n > 0) {
regs->kmidata = PL050_KMIDATA_KMIDATA(s[0]);
@@ -111,23 +106,11 @@ static ssize_t pl050_write_support(
} else {
regs->kmicr &= ~PL050_KMICR_KMITXINTREN;
}
-
- return 0;
-}
-
-static int pl050_set_attribues(int minor, const struct termios *term)
-{
- return -1;
}
-const console_fns arm_pl050_fns = {
- .deviceProbe = libchip_serial_default_probe,
- .deviceFirstOpen = pl050_first_open,
- .deviceLastClose = pl050_last_close,
- .deviceRead = NULL,
- .deviceWrite = pl050_write_support,
- .deviceInitialize = pl050_initialize,
- .deviceWritePolled = NULL,
- .deviceSetAttributes = pl050_set_attribues,
- .deviceOutputUsesInterrupts = true
+const rtems_termios_device_handler arm_pl050_fns = {
+ .first_open = pl050_first_open,
+ .last_close = pl050_last_close,
+ .write = pl050_write_support,
+ .mode = TERMIOS_IRQ_DRIVEN
};