summaryrefslogtreecommitdiff
path: root/core/drivers/ns16550.c
diff options
context:
space:
mode:
authorr.tyminski <r.tyminski@partner.samsung.com>2017-06-05 10:44:25 (GMT)
committerr.tyminski <r.tyminski@partner.samsung.com>2017-06-05 10:44:25 (GMT)
commit146aec115cd05a164a88e6d7b07435c57a33817f (patch)
treed8099075c92576b1928069af274f9b833aca996e /core/drivers/ns16550.c
parentf9a43781767007462965b21f3f518c4cfc0744c7 (diff)
downloadtef-optee_os-146aec115cd05a164a88e6d7b07435c57a33817f.zip
tef-optee_os-146aec115cd05a164a88e6d7b07435c57a33817f.tar.gz
tef-optee_os-146aec115cd05a164a88e6d7b07435c57a33817f.tar.bz2
Update from upstream to 2.4.0 versionupstream/2.4.0upstreamrefs/changes/68/132468/1
Change-Id: I2b3a30f20684d6629fe379d9cd7895aff759c301
Diffstat (limited to 'core/drivers/ns16550.c')
-rw-r--r--core/drivers/ns16550.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/core/drivers/ns16550.c b/core/drivers/ns16550.c
index 710b351..62c6d7f 100644
--- a/core/drivers/ns16550.c
+++ b/core/drivers/ns16550.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Freescale Semiconductor, Inc.
+ * Copyright (c) 2017, Linaro Limited
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,6 +28,8 @@
#include <drivers/ns16550.h>
#include <io.h>
+#include <keep.h>
+#include <util.h>
/* uart register defines */
#define UART_RBR 0x0
@@ -42,16 +45,45 @@
/* uart status register bits */
#define UART_LSR_THRE 0x20 /* Transmit-hold-register empty */
-void ns16550_flush(vaddr_t base)
+static vaddr_t chip_to_base(struct serial_chip *chip)
{
+ struct ns16550_data *pd =
+ container_of(chip, struct ns16550_data, chip);
+
+ return io_pa_or_va(&pd->base);
+}
+
+static void ns16550_flush(struct serial_chip *chip)
+{
+ vaddr_t base = chip_to_base(chip);
+
while ((read8(base + UART_LSR) & UART_LSR_THRE) == 0)
;
}
-void ns16550_putc(int ch, vaddr_t base)
+static void ns16550_putc(struct serial_chip *chip, int ch)
{
- ns16550_flush(base);
+ vaddr_t base = chip_to_base(chip);
+
+ ns16550_flush(chip);
/* write out charset to Transmit-hold-register */
write8(ch, base + UART_THR);
}
+
+static const struct serial_ops ns16550_ops = {
+ .flush = ns16550_flush,
+ .putc = ns16550_putc,
+};
+KEEP_PAGER(ns16550_ops);
+
+void ns16550_init(struct ns16550_data *pd, paddr_t base)
+{
+ pd->base.pa = base;
+ pd->chip.ops = &ns16550_ops;
+
+ /*
+ * Do nothing, uart driver shared with normal world,
+ * everything for uart driver initialization is done in bootloader.
+ */
+}