blob: b742feb4b0d288d9e6a47e586bce47a5e51e1fef [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 "../sc64-regs.h"
11#include "../sg-regs.h"
12#include "debug-uart.h"
13
14#define UNIPHIER_LD20_UART_CLK 58820000
15
16unsigned int uniphier_ld20_debug_uart_init(void)
17{
18 u32 tmp;
19
20 sg_set_iectrl(54); /* TXD0 */
21 sg_set_iectrl(58); /* TXD1 */
22 sg_set_iectrl(90); /* TXD2 */
23 sg_set_iectrl(94); /* TXD3 */
24 sg_set_pinsel(54, 0, 8, 4); /* TXD0 -> TXD0 */
25 sg_set_pinsel(58, 1, 8, 4); /* SPITXD1 -> TXD1 */
26 sg_set_pinsel(90, 1, 8, 4); /* PC0WE -> TXD2 */
27 sg_set_pinsel(94, 1, 8, 4); /* PCD00 -> TXD3 */
28
29 tmp = readl(SC_CLKCTRL4);
30 tmp |= SC_CLKCTRL4_PERI;
31 writel(tmp, SC_CLKCTRL4);
32
33 return DIV_ROUND_CLOSEST(UNIPHIER_LD20_UART_CLK, 16 * CONFIG_BAUDRATE);
34}