blob: 8cb4f87ae54b9491775588de3529cb1c63fd3c22 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada1fe65d32015-09-22 00:27:41 +09002/*
3 * Copyright (C) 2015 Masahiro Yamada <yamada.masahiro@socionext.com>
Masahiro Yamada1fe65d32015-09-22 00:27:41 +09004 */
5
Masahiro Yamada85ab6072016-07-22 20:20:11 +09006#include <linux/bitops.h>
Masahiro Yamada1fe65d32015-09-22 00:27:41 +09007#include <linux/io.h>
Masahiro Yamadaefdf3402016-01-09 01:51:13 +09008
9#include "../init.h"
10#include "../sc-regs.h"
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090011
Masahiro Yamada98905692016-03-30 20:17:02 +090012void uniphier_pxs2_clk_init(void)
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090013{
14 u32 tmp;
15
16 /* deassert reset */
Masahiro Yamadac84024c2019-07-10 20:07:41 +090017 tmp = readl(sc_base + SC_RSTCTRL);
Masahiro Yamada260eda22017-10-14 02:21:17 +090018#ifdef CONFIG_USB_DWC3_UNIPHIER
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090019 tmp |= SC_RSTCTRL_NRST_USB3B0 | SC_RSTCTRL_NRST_GIO;
20#endif
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090021#ifdef CONFIG_NAND_DENALI
22 tmp |= SC_RSTCTRL_NRST_NAND;
23#endif
Masahiro Yamadac84024c2019-07-10 20:07:41 +090024 writel(tmp, sc_base + SC_RSTCTRL);
25 readl(sc_base + SC_RSTCTRL); /* dummy read */
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090026
Masahiro Yamada260eda22017-10-14 02:21:17 +090027#ifdef CONFIG_USB_DWC3_UNIPHIER
Masahiro Yamadac84024c2019-07-10 20:07:41 +090028 tmp = readl(sc_base + SC_RSTCTRL2);
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090029 tmp |= SC_RSTCTRL2_NRST_USB3B1;
Masahiro Yamadac84024c2019-07-10 20:07:41 +090030 writel(tmp, sc_base + SC_RSTCTRL2);
31 readl(sc_base + SC_RSTCTRL2); /* dummy read */
Masahiro Yamada85ab6072016-07-22 20:20:11 +090032
Masahiro Yamadac84024c2019-07-10 20:07:41 +090033 tmp = readl(sc_base + SC_RSTCTRL6);
Masahiro Yamada85ab6072016-07-22 20:20:11 +090034 tmp |= 0x37;
Masahiro Yamadac84024c2019-07-10 20:07:41 +090035 writel(tmp, sc_base + SC_RSTCTRL6);
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090036#endif
37
Masahiro Yamada1c6a5e42016-03-30 20:17:42 +090038 /* provide clocks */
Masahiro Yamadac84024c2019-07-10 20:07:41 +090039 tmp = readl(sc_base + SC_CLKCTRL);
Masahiro Yamada260eda22017-10-14 02:21:17 +090040#ifdef CONFIG_USB_DWC3_UNIPHIER
Masahiro Yamada85ab6072016-07-22 20:20:11 +090041 tmp |= BIT(20) | BIT(19) | SC_CLKCTRL_CEN_USB31 | SC_CLKCTRL_CEN_USB30 |
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090042 SC_CLKCTRL_CEN_GIO;
43#endif
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090044#ifdef CONFIG_NAND_DENALI
45 tmp |= SC_CLKCTRL_CEN_NAND;
46#endif
Masahiro Yamadac84024c2019-07-10 20:07:41 +090047 writel(tmp, sc_base + SC_CLKCTRL);
48 readl(sc_base + SC_CLKCTRL); /* dummy read */
Masahiro Yamada1fe65d32015-09-22 00:27:41 +090049}