diff options
author | Tom Rini <trini@konsulko.com> | 2016-08-11 10:45:53 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-08-11 10:45:53 -0400 |
commit | 28cd88baa3f11cdb52be3b6d0610dcf32c60871a (patch) | |
tree | 4d6150effe763b043c7e30499c8ec2061df81be1 /arch/arm/mach-uniphier/debug.h | |
parent | 2f1eb66e2881a780e622e7fd50b3a497677fd373 (diff) | |
parent | e8a9293295a1a54f6e43970bed2d3bfd124be02c (diff) | |
download | u-boot-imx-28cd88baa3f11cdb52be3b6d0610dcf32c60871a.zip u-boot-imx-28cd88baa3f11cdb52be3b6d0610dcf32c60871a.tar.gz u-boot-imx-28cd88baa3f11cdb52be3b6d0610dcf32c60871a.tar.bz2 |
Merge branch 'master' of git://git.denx.de/u-boot-uniphier
Diffstat (limited to 'arch/arm/mach-uniphier/debug.h')
-rw-r--r-- | arch/arm/mach-uniphier/debug.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/arch/arm/mach-uniphier/debug.h b/arch/arm/mach-uniphier/debug.h new file mode 100644 index 0000000..bc16f77 --- /dev/null +++ b/arch/arm/mach-uniphier/debug.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2016 Socionext Inc. + * Author: Masahiro Yamada <yamada.masahiro@socionext.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __DEBUG_H__ +#define __DEBUG_H__ + +#include <linux/io.h> +#include <linux/serial_reg.h> + +#define DEBUG_UART_BASE 0x54006800 +#define UART_SHIFT 2 + +#define UNIPHIER_UART_TX 0 +#define UNIPHIER_UART_LSR (5 * 4) + +/* All functions are inline so that they can be called from .secure section. */ + +#ifdef DEBUG +static inline void debug_putc(int c) +{ + void __iomem *base = (void __iomem *)DEBUG_UART_BASE; + + while (!(readl(base + UNIPHIER_UART_LSR) & UART_LSR_THRE)) + ; + + writel(c, base + UNIPHIER_UART_TX); +} + +static inline void debug_puts(const char *s) +{ + while (*s) { + if (*s == '\n') + debug_putc('\r'); + + debug_putc(*s++); + } +} + +static inline void debug_puth(unsigned long val) +{ + int i; + unsigned char c; + + for (i = 8; i--; ) { + c = ((val >> (i * 4)) & 0xf); + c += (c >= 10) ? 'a' - 10 : '0'; + debug_putc(c); + } +} +#else +static inline void debug_putc(int c) +{ +} + +static inline void debug_puts(const char *s) +{ +} + +static inline void debug_puth(unsigned long val) +{ +} +#endif + +#endif /* __DEBUG_H__ */ |