Masahiro Yamada | 667dbcd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 Socionext Inc. |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Masahiro Yamada | 9c5313d | 2016-10-27 23:47:06 +0900 | [diff] [blame] | 8 | #include <spl.h> |
Masahiro Yamada | 667dbcd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 9 | #include <linux/bitops.h> |
| 10 | #include <linux/io.h> |
| 11 | |
| 12 | #include "../init.h" |
Masahiro Yamada | 76466bd | 2016-10-27 23:47:05 +0900 | [diff] [blame] | 13 | #include "../sc64-regs.h" |
Masahiro Yamada | 667dbcd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 14 | #include "../sg-regs.h" |
| 15 | |
Masahiro Yamada | c21f585 | 2017-02-17 16:17:22 +0900 | [diff] [blame] | 16 | #define SDCTRL_EMMC_HW_RESET 0x59810280 |
| 17 | |
Masahiro Yamada | 667dbcd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 18 | void uniphier_ld11_clk_init(void) |
| 19 | { |
Masahiro Yamada | 9c5313d | 2016-10-27 23:47:06 +0900 | [diff] [blame] | 20 | /* if booted from a device other than USB, without stand-by MPU */ |
| 21 | if ((readl(SG_PINMON0) & BIT(27)) && |
Masahiro Yamada | 784548e | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 22 | uniphier_boot_device_raw() != BOOT_DEVICE_USB) { |
Masahiro Yamada | 667dbcd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 23 | writel(1, SG_ETPHYPSHUT); |
| 24 | writel(1, SG_ETPHYCNT); |
| 25 | |
| 26 | udelay(1); /* wait for regulator level 1.1V -> 2.5V */ |
| 27 | |
| 28 | writel(3, SG_ETPHYCNT); |
| 29 | writel(3, SG_ETPHYPSHUT); |
| 30 | writel(7, SG_ETPHYCNT); |
| 31 | } |
Masahiro Yamada | 76466bd | 2016-10-27 23:47:05 +0900 | [diff] [blame] | 32 | |
Masahiro Yamada | c21f585 | 2017-02-17 16:17:22 +0900 | [diff] [blame] | 33 | /* TODO: use "mmc-pwrseq-emmc" */ |
| 34 | writel(1, SDCTRL_EMMC_HW_RESET); |
| 35 | |
Masahiro Yamada | 76466bd | 2016-10-27 23:47:05 +0900 | [diff] [blame] | 36 | #ifdef CONFIG_USB_EHCI |
| 37 | { |
| 38 | /* FIXME: the current clk driver can not handle parents */ |
| 39 | u32 tmp; |
Masahiro Yamada | 395e214 | 2017-04-14 11:30:05 +0900 | [diff] [blame] | 40 | int ch; |
| 41 | |
Masahiro Yamada | 76466bd | 2016-10-27 23:47:05 +0900 | [diff] [blame] | 42 | tmp = readl(SC_CLKCTRL4); |
| 43 | tmp |= SC_CLKCTRL4_MIO | SC_CLKCTRL4_STDMAC; |
| 44 | writel(tmp, SC_CLKCTRL4); |
Masahiro Yamada | 395e214 | 2017-04-14 11:30:05 +0900 | [diff] [blame] | 45 | |
| 46 | for (ch = 0; ch < 3; ch++) { |
| 47 | void __iomem *phyctrl = (void __iomem *)SG_USBPHYCTRL; |
| 48 | |
| 49 | writel(0x82280600, phyctrl + 8 * ch); |
| 50 | writel(0x00000106, phyctrl + 8 * ch + 4); |
| 51 | } |
Masahiro Yamada | 76466bd | 2016-10-27 23:47:05 +0900 | [diff] [blame] | 52 | } |
| 53 | #endif |
Masahiro Yamada | 667dbcd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 54 | } |