aboutsummaryrefslogtreecommitdiff
path: root/core/drivers
diff options
context:
space:
mode:
authorJerome Forissier <jerome.forissier@linaro.org>2017-02-17 14:35:55 +0100
committerJerome Forissier <jerome.forissier@linaro.org>2017-03-17 18:23:51 +0100
commit26267e8209dfae98152c7cea053067c24d4b5952 (patch)
tree12b2e15f8b31adc04113b436816c9c7af0fc275a /core/drivers
parented7617df5b6e5e629b307195ea2800bb0a77b1ed (diff)
drivers: convert imx_uart driver to use struct serial_chip
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
Diffstat (limited to 'core/drivers')
-rw-r--r--core/drivers/imx_uart.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/core/drivers/imx_uart.c b/core/drivers/imx_uart.c
index b66d9059..dae1a2fc 100644
--- a/core/drivers/imx_uart.c
+++ b/core/drivers/imx_uart.c
@@ -25,12 +25,10 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <platform_config.h>
-
+#include <assert.h>
#include <drivers/imx_uart.h>
-#include <console.h>
#include <io.h>
-#include <compiler.h>
+#include <util.h>
/* Register definitions */
#define URXD 0x0 /* Receiver Register */
@@ -80,33 +78,56 @@
#define UTS_RXFULL (1<<3) /* RxFIFO full */
#define UTS_SOFTRST (1<<0) /* Software reset */
-void imx_uart_init(vaddr_t __unused vbase)
+static vaddr_t chip_to_base(struct serial_chip *chip)
{
- /*
- * Do nothing, debug uart(uart0) share with normal world,
- * everything for uart0 intialization is done in bootloader.
- */
+ struct imx_uart_data *pd =
+ container_of(chip, struct imx_uart_data, chip);
+
+ return io_pa_or_va(&pd->base);
}
-void imx_uart_flush_tx_fifo(vaddr_t base)
+static void imx_uart_flush(struct serial_chip *chip)
{
+ vaddr_t base = chip_to_base(chip);
+
while (!(read32(base + UTS) & UTS_TXEMPTY))
;
}
-int imx_uart_getchar(vaddr_t base)
+static int imx_uart_getchar(struct serial_chip *chip)
{
+ vaddr_t base = chip_to_base(chip);
+
while (read32(base + UTS) & UTS_RXEMPTY)
;
return (read32(base + URXD) & URXD_RX_DATA);
}
-void imx_uart_putc(const char c, vaddr_t base)
+static void imx_uart_putc(struct serial_chip *chip, int ch)
{
- write32(c, base + UTXD);
+ vaddr_t base = chip_to_base(chip);
+
+ write32(ch, base + UTXD);
- /* wait until sent */
+ /* Wait until sent */
while (!(read32(base + UTS) & UTS_TXEMPTY))
;
}
+
+static const struct serial_ops imx_uart_ops = {
+ .flush = imx_uart_flush,
+ .getchar = imx_uart_getchar,
+ .putc = imx_uart_putc,
+};
+
+void imx_uart_init(struct imx_uart_data *pd, paddr_t base)
+{
+ pd->base.pa = base;
+ pd->chip.ops = &imx_uart_ops;
+
+ /*
+ * Do nothing, debug uart(uart0) share with normal world,
+ * everything for uart0 initialization is done in bootloader.
+ */
+}