Add PL011 UART driver
A minimal PL011 driver containing necessary functions
to print to UART. Based on the assembly implementation
found in TF-A (hash: 39bcbeac9c8c20ae660cb6d9e825ceb01e6144e7;
file: drivers/arm/pl011/aarch64/pl011_console.S).
Signed-off-by: Gabor Toth <gabor.toth2@arm.com>
Signed-off-by: Gabor Ambrus <gabor.ambrus@arm.com>
Change-Id: I644fb011b2b9a68aa09e8cc3a09ebd8b9576bb30
diff --git a/platform/interface/uart.h b/platform/interface/uart.h
new file mode 100644
index 0000000..8f0c34f
--- /dev/null
+++ b/platform/interface/uart.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2023, Arm Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef TS_PLATFORM_INTERFACE_UART_H
+#define TS_PLATFORM_INTERFACE_UART_H
+
+/*
+ * Interface definintion for a platform uart driver. A platform provider will
+ * provide concrete implementations of this interface for each alternative
+ * implementation supported.
+ */
+#include <stddef.h>
+
+#include "device_region.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * A platform uart driver context.
+ */
+typedef struct {
+ /* Base address of the driver instance */
+ uintptr_t base_address;
+} platform_uart_context;
+
+/*
+ * Virtual interface for a platform uart driver. A platform will provide
+ * one or more concrete implementations of this interface.
+ */
+struct platform_uart_iface {
+ /**
+ * \brief Putc to submit a character to platform uart
+ * *
+ * * \param context Platform driver context
+ * \param ch Character to be written to UART
+ *
+ * \return 0 if successful.
+ */
+ int (*uart_putc)(platform_uart_context *context, uint8_t ch);
+ /**
+ * \brief Wait for empty input FIFO in platform uart
+ *
+ * * \param context Platform driver context
+ * *
+ * \return 0 if successful.
+ */
+ int (*uart_flush)(platform_uart_context *context);
+};
+
+/*
+ * A platform uart driver instance.
+ */
+struct platform_uart_driver {
+ void *context; /**< Opaque driver context */
+ const struct platform_uart_iface *iface; /**< Interface methods */
+};
+
+/**
+ * \brief Factory method to construct a platform specific uart driver
+ *
+ * \param driver Pointer to driver structure to initialize on construction.
+ * \param instance Deployment specific uart instance.
+ *
+ * \return 0 if successful.
+ */
+int platform_uart_create(struct platform_uart_driver *driver, int instance);
+
+/**
+ * \brief Destroy a driver constructed using the factory method
+ *
+ * \param driver Pointer to driver structure for constructed driver.
+ */
+void platform_uart_destroy(struct platform_uart_driver *driver);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* TS_PLATFORM_INTERFACE_UART_H */