Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | 52f0c51 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com> |
Masahiro Yamada | 52f0c51 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <config.h> |
| 7 | #include <linux/kernel.h> |
| 8 | #include <linux/io.h> |
| 9 | |
| 10 | #include "../sc-regs.h" |
| 11 | #include "../sg-regs.h" |
| 12 | #include "debug-uart.h" |
| 13 | |
| 14 | #define UNIPHIER_PRO4_UART_CLK 73728000 |
| 15 | |
| 16 | unsigned int uniphier_pro4_debug_uart_init(void) |
| 17 | { |
| 18 | u32 tmp; |
| 19 | |
| 20 | sg_set_iectrl(0); |
| 21 | sg_set_pinsel(128, 0, 4, 8); /* TXD0 -> TXD0 */ |
| 22 | |
Masahiro Yamada | 76b3124 | 2019-07-10 20:07:40 +0900 | [diff] [blame] | 23 | writel(1, sg_base + SG_LOADPINCTRL); |
Masahiro Yamada | 52f0c51 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 24 | |
Masahiro Yamada | c84024c | 2019-07-10 20:07:41 +0900 | [diff] [blame] | 25 | tmp = readl(sc_base + SC_CLKCTRL); |
Masahiro Yamada | 52f0c51 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 26 | tmp |= SC_CLKCTRL_CEN_PERI; |
Masahiro Yamada | c84024c | 2019-07-10 20:07:41 +0900 | [diff] [blame] | 27 | writel(tmp, sc_base + SC_CLKCTRL); |
Masahiro Yamada | 52f0c51 | 2016-03-18 16:41:52 +0900 | [diff] [blame] | 28 | |
| 29 | return DIV_ROUND_CLOSEST(UNIPHIER_PRO4_UART_CLK, 16 * CONFIG_BAUDRATE); |
| 30 | } |