Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2016 Socionext Inc. |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Masahiro Yamada | d3a6781 | 2016-10-27 23:47:06 +0900 | [diff] [blame] | 7 | #include <spl.h> |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 8 | #include <linux/bitops.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame^] | 9 | #include <linux/delay.h> |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 10 | #include <linux/io.h> |
| 11 | |
| 12 | #include "../init.h" |
Masahiro Yamada | 77857e2 | 2016-10-27 23:47:05 +0900 | [diff] [blame] | 13 | #include "../sc64-regs.h" |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 14 | #include "../sg-regs.h" |
| 15 | |
Masahiro Yamada | b3b1bb7 | 2017-02-17 16:17:22 +0900 | [diff] [blame] | 16 | #define SDCTRL_EMMC_HW_RESET 0x59810280 |
| 17 | |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 18 | void uniphier_ld11_clk_init(void) |
| 19 | { |
Masahiro Yamada | d3a6781 | 2016-10-27 23:47:06 +0900 | [diff] [blame] | 20 | /* if booted from a device other than USB, without stand-by MPU */ |
Masahiro Yamada | 76b3124 | 2019-07-10 20:07:40 +0900 | [diff] [blame] | 21 | if ((readl(sg_base + SG_PINMON0) & BIT(27)) && |
Masahiro Yamada | fb09203 | 2017-02-14 01:24:26 +0900 | [diff] [blame] | 22 | uniphier_boot_device_raw() != BOOT_DEVICE_USB) { |
Masahiro Yamada | 76b3124 | 2019-07-10 20:07:40 +0900 | [diff] [blame] | 23 | writel(1, sg_base + SG_ETPHYPSHUT); |
| 24 | writel(1, sg_base + SG_ETPHYCNT); |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 25 | |
| 26 | udelay(1); /* wait for regulator level 1.1V -> 2.5V */ |
| 27 | |
Masahiro Yamada | 76b3124 | 2019-07-10 20:07:40 +0900 | [diff] [blame] | 28 | writel(3, sg_base + SG_ETPHYCNT); |
| 29 | writel(3, sg_base + SG_ETPHYPSHUT); |
| 30 | writel(7, sg_base + SG_ETPHYCNT); |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 31 | } |
Masahiro Yamada | 77857e2 | 2016-10-27 23:47:05 +0900 | [diff] [blame] | 32 | |
Masahiro Yamada | b3b1bb7 | 2017-02-17 16:17:22 +0900 | [diff] [blame] | 33 | /* TODO: use "mmc-pwrseq-emmc" */ |
| 34 | writel(1, SDCTRL_EMMC_HW_RESET); |
| 35 | |
Tom Rini | ceed5d2 | 2017-05-12 22:33:27 -0400 | [diff] [blame] | 36 | #ifdef CONFIG_USB_EHCI_HCD |
Masahiro Yamada | 77857e2 | 2016-10-27 23:47:05 +0900 | [diff] [blame] | 37 | { |
Masahiro Yamada | 0d3af24 | 2017-04-14 11:30:05 +0900 | [diff] [blame] | 38 | int ch; |
| 39 | |
Masahiro Yamada | 0d3af24 | 2017-04-14 11:30:05 +0900 | [diff] [blame] | 40 | for (ch = 0; ch < 3; ch++) { |
Masahiro Yamada | 76b3124 | 2019-07-10 20:07:40 +0900 | [diff] [blame] | 41 | void __iomem *phyctrl = sg_base + SG_USBPHYCTRL; |
Masahiro Yamada | 0d3af24 | 2017-04-14 11:30:05 +0900 | [diff] [blame] | 42 | |
| 43 | writel(0x82280600, phyctrl + 8 * ch); |
| 44 | writel(0x00000106, phyctrl + 8 * ch + 4); |
| 45 | } |
Masahiro Yamada | 77857e2 | 2016-10-27 23:47:05 +0900 | [diff] [blame] | 46 | } |
| 47 | #endif |
Masahiro Yamada | 8bbbcbd | 2016-05-24 21:14:01 +0900 | [diff] [blame] | 48 | } |