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