1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3 * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
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_PXS2_UART_CLK 88888888
15
uniphier_pxs2_debug_uart_init(void)16 unsigned int uniphier_pxs2_debug_uart_init(void)
17 {
18 u32 tmp;
19
20 sg_set_iectrl(0);
21 sg_set_pinsel(217, 8, 8, 4); /* TXD0 -> TXD0 */
22 sg_set_pinsel(115, 8, 8, 4); /* TXD1 -> TXD1 */
23 sg_set_pinsel(113, 8, 8, 4); /* TXD2 -> TXD2 */
24 sg_set_pinsel(219, 8, 8, 4); /* TXD3 -> TXD3 */
25
26 tmp = readl(sc_base + SC_CLKCTRL);
27 tmp |= SC_CLKCTRL_CEN_PERI;
28 writel(tmp, sc_base + SC_CLKCTRL);
29
30 return DIV_ROUND_CLOSEST(UNIPHIER_PXS2_UART_CLK, 16 * CONFIG_BAUDRATE);
31 }
32