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