blob: 94b9d904dc644dd4dd210530272c5941f56fbe59 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +09002/*
3 * Copyright (C) 2016 Socionext Inc.
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +09004 */
5
6#include <common.h>
Masahiro Yamadad3a67812016-10-27 23:47:06 +09007#include <spl.h>
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +09008#include <linux/bitops.h>
Simon Glassdbd79542020-05-10 11:40:11 -06009#include <linux/delay.h>
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +090010#include <linux/io.h>
11
12#include "../init.h"
Masahiro Yamada77857e22016-10-27 23:47:05 +090013#include "../sc64-regs.h"
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +090014#include "../sg-regs.h"
15
Masahiro Yamadab3b1bb72017-02-17 16:17:22 +090016#define SDCTRL_EMMC_HW_RESET 0x59810280
17
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +090018void uniphier_ld11_clk_init(void)
19{
Masahiro Yamadad3a67812016-10-27 23:47:06 +090020 /* if booted from a device other than USB, without stand-by MPU */
Masahiro Yamada76b31242019-07-10 20:07:40 +090021 if ((readl(sg_base + SG_PINMON0) & BIT(27)) &&
Masahiro Yamadafb092032017-02-14 01:24:26 +090022 uniphier_boot_device_raw() != BOOT_DEVICE_USB) {
Masahiro Yamada76b31242019-07-10 20:07:40 +090023 writel(1, sg_base + SG_ETPHYPSHUT);
24 writel(1, sg_base + SG_ETPHYCNT);
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +090025
26 udelay(1); /* wait for regulator level 1.1V -> 2.5V */
27
Masahiro Yamada76b31242019-07-10 20:07:40 +090028 writel(3, sg_base + SG_ETPHYCNT);
29 writel(3, sg_base + SG_ETPHYPSHUT);
30 writel(7, sg_base + SG_ETPHYCNT);
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +090031 }
Masahiro Yamada77857e22016-10-27 23:47:05 +090032
Masahiro Yamadab3b1bb72017-02-17 16:17:22 +090033 /* TODO: use "mmc-pwrseq-emmc" */
34 writel(1, SDCTRL_EMMC_HW_RESET);
35
Tom Riniceed5d22017-05-12 22:33:27 -040036#ifdef CONFIG_USB_EHCI_HCD
Masahiro Yamada77857e22016-10-27 23:47:05 +090037 {
Masahiro Yamada0d3af242017-04-14 11:30:05 +090038 int ch;
39
Masahiro Yamada0d3af242017-04-14 11:30:05 +090040 for (ch = 0; ch < 3; ch++) {
Masahiro Yamada76b31242019-07-10 20:07:40 +090041 void __iomem *phyctrl = sg_base + SG_USBPHYCTRL;
Masahiro Yamada0d3af242017-04-14 11:30:05 +090042
43 writel(0x82280600, phyctrl + 8 * ch);
44 writel(0x00000106, phyctrl + 8 * ch + 4);
45 }
Masahiro Yamada77857e22016-10-27 23:47:05 +090046 }
47#endif
Masahiro Yamada8bbbcbd2016-05-24 21:14:01 +090048}