1 /*
2  * Copyright 2021, Breakaway Consulting Pty. Ltd.
3  *
4  * A simple output only UART driver for the NXP i.MX Low Power UART.
5  *
6  * Technical Reference:
7  *   i.MX 8DualX/8DualXPlus/8QuadXPlus Applications Processor Reference Manual
8  *   Revision 0 (IMX8DQXPRM.pdf)
9  *   Chapter 16.13 (page 7908)
10  *
11  * SPDX-License-Identifier: GPL-2.0-only
12  */
13 
14 #include <config.h>
15 #include <stdint.h>
16 #include <util.h>
17 #include <machine/io.h>
18 #include <plat/machine/devices_gen.h>
19 
20 #define STAT 0x14
21 #define TRANSMIT 0x1c
22 
23 #define STAT_TDRE (1 << 23)
24 
25 #define UART_REG(x) ((volatile uint32_t *)(UART_PPTR + (x)))
26 
27 #if defined(CONFIG_DEBUG_BUILD) || defined(CONFIG_PRINTING)
uart_drv_putchar(unsigned char c)28 void uart_drv_putchar(unsigned char c)
29 {
30     while (!(*UART_REG(STAT) & STAT_TDRE)) { }
31     *UART_REG(TRANSMIT) = c;
32 }
33 #endif
34 
35 #ifdef CONFIG_DEBUG_BUILD
uart_drv_getchar(void)36 unsigned char uart_drv_getchar(void)
37 {
38     return 0;
39 }
40 #endif /* CONFIG_DEBUG_BUILD */
41