Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
| 8 | #include <debug_uart.h> |
| 9 | #include <linux/io.h> |
| 10 | #include <linux/serial_reg.h> |
| 11 | |
| 12 | #include "../soc-info.h" |
| 13 | #include "debug-uart.h" |
| 14 | |
| 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 |
| 19 | |
| 20 | static void _debug_uart_putc(int c) |
| 21 | { |
| 22 | void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; |
| 23 | |
| 24 | while (!(readl(base + UNIPHIER_UART_LSR) & UART_LSR_THRE)) |
| 25 | ; |
| 26 | |
| 27 | writel(c, base + UNIPHIER_UART_TX); |
| 28 | } |
| 29 | |
| 30 | void _debug_uart_init(void) |
| 31 | { |
| 32 | void __iomem *base = (void __iomem *)CONFIG_DEBUG_UART_BASE; |
| 33 | unsigned int divisor; |
| 34 | |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame^] | 35 | switch (uniphier_get_soc_id()) { |
Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 36 | #if defined(CONFIG_ARCH_UNIPHIER_SLD3) |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame^] | 37 | case UNIPHIER_SLD3_ID: |
Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 38 | divisor = uniphier_sld3_debug_uart_init(); |
| 39 | break; |
| 40 | #endif |
| 41 | #if defined(CONFIG_ARCH_UNIPHIER_LD4) |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame^] | 42 | case UNIPHIER_LD4_ID: |
Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 43 | divisor = uniphier_ld4_debug_uart_init(); |
| 44 | break; |
| 45 | #endif |
| 46 | #if defined(CONFIG_ARCH_UNIPHIER_PRO4) |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame^] | 47 | case UNIPHIER_PRO4_ID: |
Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 48 | divisor = uniphier_pro4_debug_uart_init(); |
| 49 | break; |
| 50 | #endif |
| 51 | #if defined(CONFIG_ARCH_UNIPHIER_SLD8) |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame^] | 52 | case UNIPHIER_SLD8_ID: |
Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 53 | divisor = uniphier_sld8_debug_uart_init(); |
| 54 | break; |
| 55 | #endif |
| 56 | #if defined(CONFIG_ARCH_UNIPHIER_PRO5) |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame^] | 57 | case UNIPHIER_PRO5_ID: |
Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 58 | divisor = uniphier_pro5_debug_uart_init(); |
| 59 | break; |
| 60 | #endif |
| 61 | #if defined(CONFIG_ARCH_UNIPHIER_PXS2) |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame^] | 62 | case UNIPHIER_PXS2_ID: |
Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 63 | divisor = uniphier_pxs2_debug_uart_init(); |
| 64 | break; |
| 65 | #endif |
| 66 | #if defined(CONFIG_ARCH_UNIPHIER_LD6B) |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame^] | 67 | case UNIPHIER_LD6B_ID: |
Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 68 | divisor = uniphier_ld6b_debug_uart_init(); |
| 69 | break; |
| 70 | #endif |
| 71 | #if defined(CONFIG_ARCH_UNIPHIER_LD11) || defined(CONFIG_ARCH_UNIPHIER_LD20) |
Masahiro Yamada | e27d6c7 | 2017-01-21 18:05:26 +0900 | [diff] [blame^] | 72 | case UNIPHIER_LD11_ID: |
| 73 | case UNIPHIER_LD20_ID: |
Masahiro Yamada | d5cf329 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 74 | divisor = uniphier_ld20_debug_uart_init(); |
| 75 | break; |
| 76 | #endif |
| 77 | default: |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | writel(UART_LCR_WLEN8 << 8, base + UNIPHIER_UART_LCR_MCR); |
| 82 | |
| 83 | writel(divisor, base + UNIPHIER_UART_LDR); |
| 84 | } |
| 85 | DEBUG_UART_FUNCS |