94b9d904dc644dd4dd210530272c5941f56fbe59
[oweals/u-boot.git] / arch / arm / mach-uniphier / clk / clk-ld11.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2016 Socionext Inc.
4  */
5
6 #include <common.h>
7 #include <spl.h>
8 #include <linux/bitops.h>
9 #include <linux/delay.h>
10 #include <linux/io.h>
11
12 #include "../init.h"
13 #include "../sc64-regs.h"
14 #include "../sg-regs.h"
15
16 #define SDCTRL_EMMC_HW_RESET    0x59810280
17
18 void uniphier_ld11_clk_init(void)
19 {
20         /* if booted from a device other than USB, without stand-by MPU */
21         if ((readl(sg_base + SG_PINMON0) & BIT(27)) &&
22             uniphier_boot_device_raw() != BOOT_DEVICE_USB) {
23                 writel(1, sg_base + SG_ETPHYPSHUT);
24                 writel(1, sg_base + SG_ETPHYCNT);
25
26                 udelay(1); /* wait for regulator level 1.1V -> 2.5V */
27
28                 writel(3, sg_base + SG_ETPHYCNT);
29                 writel(3, sg_base + SG_ETPHYPSHUT);
30                 writel(7, sg_base + SG_ETPHYCNT);
31         }
32
33         /* TODO: use "mmc-pwrseq-emmc" */
34         writel(1, SDCTRL_EMMC_HW_RESET);
35
36 #ifdef CONFIG_USB_EHCI_HCD
37         {
38                 int ch;
39
40                 for (ch = 0; ch < 3; ch++) {
41                         void __iomem *phyctrl = sg_base + SG_USBPHYCTRL;
42
43                         writel(0x82280600, phyctrl + 8 * ch);
44                         writel(0x00000106, phyctrl + 8 * ch + 4);
45                 }
46         }
47 #endif
48 }