blob: ef3b383ee4310d78e6cfc3474fe441ccc0226b5a [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamadad5cf3292016-03-18 16:41:52 +09002/*
3 * Copyright (C) 2016 Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamadad5cf3292016-03-18 16:41:52 +09004 */
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_PRO5_UART_CLK 73728000
15
16unsigned int uniphier_pro5_debug_uart_init(void)
17{
18 u32 tmp;
19
20 sg_set_iectrl(0);
21 sg_set_pinsel(47, 0, 4, 8); /* TXD0 -> TXD0 */
22 sg_set_pinsel(49, 0, 4, 8); /* TXD1 -> TXD1 */
23 sg_set_pinsel(51, 0, 4, 8); /* TXD2 -> TXD2 */
24 sg_set_pinsel(53, 0, 4, 8); /* TXD3 -> TXD3 */
25
Masahiro Yamadad41b3582019-07-10 20:07:40 +090026 writel(1, sg_base + SG_LOADPINCTRL);
Masahiro Yamadad5cf3292016-03-18 16:41:52 +090027
Masahiro Yamada739ba412019-07-10 20:07:41 +090028 tmp = readl(sc_base + SC_CLKCTRL);
Masahiro Yamadad5cf3292016-03-18 16:41:52 +090029 tmp |= SC_CLKCTRL_CEN_PERI;
Masahiro Yamada739ba412019-07-10 20:07:41 +090030 writel(tmp, sc_base + SC_CLKCTRL);
Masahiro Yamadad5cf3292016-03-18 16:41:52 +090031
32 return DIV_ROUND_CLOSEST(UNIPHIER_PRO5_UART_CLK, 16 * CONFIG_BAUDRATE);
33}