2 * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
4 * SPDX-License-Identifier: GPL-2.0+
8 #include <debug_uart.h>
10 #include <linux/serial_reg.h>
12 #include "../soc-info.h"
13 #include "debug-uart.h"
15 #define UNIPHIER_UART_TX 0x00
16 #define UNIPHIER_UART_LCR_MCR 0x10
17 #define UNIPHIER_UART_LSR 0x14
18 #define UNIPHIER_UART_LDR 0x24
20 static void _debug_uart_putc(int c)
22 void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE;
24 while (!(readl(base + UNIPHIER_UART_LSR) & UART_LSR_THRE))
27 writel(c, base + UNIPHIER_UART_TX);
30 void _debug_uart_init(void)
32 void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE;
35 switch (uniphier_get_soc_id()) {
36 #if defined(CONFIG_ARCH_UNIPHIER_LD4)
38 divisor = uniphier_ld4_debug_uart_init();
41 #if defined(CONFIG_ARCH_UNIPHIER_PRO4)
42 case UNIPHIER_PRO4_ID:
43 divisor = uniphier_pro4_debug_uart_init();
46 #if defined(CONFIG_ARCH_UNIPHIER_SLD8)
47 case UNIPHIER_SLD8_ID:
48 divisor = uniphier_sld8_debug_uart_init();
51 #if defined(CONFIG_ARCH_UNIPHIER_PRO5)
52 case UNIPHIER_PRO5_ID:
53 divisor = uniphier_pro5_debug_uart_init();
56 #if defined(CONFIG_ARCH_UNIPHIER_PXS2)
57 case UNIPHIER_PXS2_ID:
58 divisor = uniphier_pxs2_debug_uart_init();
61 #if defined(CONFIG_ARCH_UNIPHIER_LD6B)
62 case UNIPHIER_LD6B_ID:
63 divisor = uniphier_ld6b_debug_uart_init();
66 #if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20)
67 case UNIPHIER_LD11_ID:
68 case UNIPHIER_LD20_ID:
69 divisor = uniphier_ld20_debug_uart_init();
76 writel(UART_LCR_WLEN8 << 8, base + UNIPHIER_UART_LCR_MCR);
78 writel(divisor, base + UNIPHIER_UART_LDR);