Gregory CLEMENT | af05ee5 | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: (GPL-2.0+ OR MIT) |
| 2 | /* |
| 3 | * Copyright (c) 2018 Microsemi Corporation |
| 4 | */ |
| 5 | |
Gregory CLEMENT | af05ee5 | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 6 | #include <asm/sections.h> |
| 7 | #include <asm/io.h> |
| 8 | |
| 9 | #include <asm/reboot.h> |
| 10 | |
| 11 | void _machine_restart(void) |
| 12 | { |
Horatiu Vultur | c15620a | 2019-01-17 15:33:27 +0100 | [diff] [blame] | 13 | #if defined(CONFIG_SOC_JR2) || defined(CONFIG_SOC_SERVALT) |
Horatiu Vultur | 8a22b88 | 2019-01-12 18:56:56 +0100 | [diff] [blame] | 14 | register u32 reg = readl(BASE_CFG + ICPU_GENERAL_CTRL); |
| 15 | /* Set owner */ |
| 16 | reg &= ~ICPU_GENERAL_CTRL_IF_SI_OWNER_M; |
| 17 | reg |= ICPU_GENERAL_CTRL_IF_SI_OWNER(1); |
| 18 | /* Set boot mode */ |
| 19 | reg |= ICPU_GENERAL_CTRL_BOOT_MODE_ENA; |
| 20 | writel(reg, BASE_CFG + ICPU_GENERAL_CTRL); |
| 21 | /* Read back in order to make BOOT mode setting active */ |
| 22 | reg = readl(BASE_CFG + ICPU_GENERAL_CTRL); |
| 23 | /* Reset CPU only - still executing _here_. but from cache */ |
| 24 | writel(readl(BASE_CFG + ICPU_RESET) | |
| 25 | ICPU_RESET_CORE_RST_CPU_ONLY | |
| 26 | ICPU_RESET_CORE_RST_FORCE, |
| 27 | BASE_CFG + ICPU_RESET); |
Horatiu Vultur | 914e787 | 2019-01-23 16:39:42 +0100 | [diff] [blame] | 28 | #elif defined(CONFIG_SOC_SERVAL) |
| 29 | register unsigned long i; |
| 30 | |
| 31 | /* Prevent VCore-III from being reset with a global reset */ |
| 32 | writel(ICPU_RESET_CORE_RST_PROTECT, BASE_CFG + ICPU_RESET); |
| 33 | |
| 34 | /* Do global reset */ |
| 35 | writel(PERF_SOFT_RST_SOFT_CHIP_RST, BASE_DEVCPU_GCB + PERF_SOFT_RST); |
| 36 | |
Horatiu Vultur | 00f5285 | 2019-04-15 11:56:36 +0200 | [diff] [blame] | 37 | for (i = 0; i < 2000; i++) |
Horatiu Vultur | 914e787 | 2019-01-23 16:39:42 +0100 | [diff] [blame] | 38 | ; |
| 39 | |
| 40 | /* Power down DDR for clean DDR re-training */ |
| 41 | writel(readl(BASE_CFG + ICPU_MEMCTRL_CTRL) | |
| 42 | ICPU_MEMCTRL_CTRL_PWR_DOWN, |
| 43 | BASE_CFG + ICPU_MEMCTRL_CTRL); |
| 44 | |
| 45 | while (!(readl(BASE_CFG + ICPU_MEMCTRL_STAT) & |
| 46 | ICPU_MEMCTRL_STAT_PWR_DOWN_ACK)) |
| 47 | ; |
| 48 | |
| 49 | /* Reset VCore-III, only. */ |
| 50 | writel(ICPU_RESET_CORE_RST_FORCE, BASE_CFG + ICPU_RESET); |
| 51 | #else /* Luton || Ocelot */ |
Gregory CLEMENT | af05ee5 | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 52 | register u32 resetbits = PERF_SOFT_RST_SOFT_CHIP_RST; |
| 53 | (void)readl(BASE_DEVCPU_GCB + PERF_SOFT_RST); |
| 54 | |
| 55 | /* Make sure VCore is NOT protected from reset */ |
| 56 | clrbits_le32(BASE_CFG + ICPU_RESET, ICPU_RESET_CORE_RST_PROTECT); |
| 57 | |
| 58 | /* Change to SPI bitbang for SPI reset workaround... */ |
| 59 | writel(ICPU_SW_MODE_SW_SPI_CS_OE(1) | ICPU_SW_MODE_SW_SPI_CS(1) | |
| 60 | ICPU_SW_MODE_SW_PIN_CTRL_MODE, BASE_CFG + ICPU_SW_MODE); |
| 61 | |
| 62 | /* Do the global reset */ |
| 63 | writel(resetbits, BASE_DEVCPU_GCB + PERF_SOFT_RST); |
Horatiu Vultur | 8a22b88 | 2019-01-12 18:56:56 +0100 | [diff] [blame] | 64 | #endif |
Gregory CLEMENT | af05ee5 | 2018-12-14 16:16:47 +0100 | [diff] [blame] | 65 | |
| 66 | while (1) |
| 67 | ; /* NOP */ |
| 68 | } |