1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2d5cf3297SMasahiro Yamada /*
3d5cf3297SMasahiro Yamada  * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
4d5cf3297SMasahiro Yamada  */
5d5cf3297SMasahiro Yamada 
6d5cf3297SMasahiro Yamada #include <config.h>
7d5cf3297SMasahiro Yamada #include <linux/kernel.h>
8d5cf3297SMasahiro Yamada #include <linux/io.h>
9d5cf3297SMasahiro Yamada 
10d5cf3297SMasahiro Yamada #include "../sc-regs.h"
11d5cf3297SMasahiro Yamada #include "../sg-regs.h"
12d5cf3297SMasahiro Yamada #include "debug-uart.h"
13d5cf3297SMasahiro Yamada 
14d5cf3297SMasahiro Yamada #define UNIPHIER_LD6B_UART_CLK		88888888
15d5cf3297SMasahiro Yamada 
uniphier_ld6b_debug_uart_init(void)16d5cf3297SMasahiro Yamada unsigned int uniphier_ld6b_debug_uart_init(void)
17d5cf3297SMasahiro Yamada {
18d5cf3297SMasahiro Yamada 	u32 tmp;
19d5cf3297SMasahiro Yamada 
20d5cf3297SMasahiro Yamada 	sg_set_iectrl(0);
21d5cf3297SMasahiro Yamada 	sg_set_pinsel(135, 3, 8, 4);	/* PORT10 -> TXD0 */
22d5cf3297SMasahiro Yamada 	sg_set_pinsel(115, 0, 8, 4);	/* TXD1 -> TXD1 */
23d5cf3297SMasahiro Yamada 	sg_set_pinsel(113, 2, 8, 4);	/* SBO0 -> TXD2 */
24d5cf3297SMasahiro Yamada 
25d5cf3297SMasahiro Yamada 	tmp = readl(SC_CLKCTRL);
26d5cf3297SMasahiro Yamada 	tmp |= SC_CLKCTRL_CEN_PERI;
27d5cf3297SMasahiro Yamada 	writel(tmp, SC_CLKCTRL);
28d5cf3297SMasahiro Yamada 
29d5cf3297SMasahiro Yamada 	return DIV_ROUND_CLOSEST(UNIPHIER_LD6B_UART_CLK, 16 * CONFIG_BAUDRATE);
30d5cf3297SMasahiro Yamada }
31