*/
#include <stdint.h>
+#include <stddef.h>
+
+#define KSEG0 0x80000000
+#define KSEG1 0xa0000000
+
+#define _ATYPE_ __PTRDIFF_TYPE__
+#define _ATYPE32_ int
+
+#define _ACAST32_ (_ATYPE_)(_ATYPE32_)
+
+#define CPHYSADDR(a) ((_ACAST32_(a)) & 0x1fffffff)
+
+#define KSEG0ADDR(a) (CPHYSADDR(a) | KSEG0)
+#define KSEG1ADDR(a) (CPHYSADDR(a) | KSEG1)
#if defined(SOC_MT7620) || defined(SOC_RT3883)
-#define UART_BASE 0xb0000c00
+#define UART_BASE KSEG1ADDR(0x10000c00)
#define UART_THR (UART_BASE + 0x04)
#define UART_LSR (UART_BASE + 0x1c)
#define UART_LSR_THRE_MASK 0x40
#elif defined(SOC_MT7621)
-#define UART_BASE 0xbe000c00
+#define UART_BASE KSEG1ADDR(0x1e000c00)
#define UART_THR (UART_BASE + 0x00)
#define UART_LSR (UART_BASE + 0x14)
#define UART_LSR_THRE_MASK 0x20
#elif defined(SOC_RT305X)
-#define UART_BASE 0x10000500
+#define UART_BASE KSEG1ADDR(0x10000500)
#define UART_THR (UART_BASE + 0x04)
#define UART_LSR (UART_BASE + 0x1c)
#define UART_LSR_THRE_MASK 0x20