blob: ca9a7c679d94810b4b7839ea2fa24269f4ced40e [file] [log] [blame]
Gregory CLEMENTaf05ee52018-12-14 16:16:47 +01001// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
2/*
3 * Copyright (c) 2018 Microsemi Corporation
4 */
5
Gregory CLEMENTaf05ee52018-12-14 16:16:47 +01006#include <asm/sections.h>
7#include <asm/io.h>
8
9#include <asm/reboot.h>
10
11void _machine_restart(void)
12{
Horatiu Vulturc15620a2019-01-17 15:33:27 +010013#if defined(CONFIG_SOC_JR2) || defined(CONFIG_SOC_SERVALT)
Horatiu Vultur8a22b882019-01-12 18:56:56 +010014 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 Vultur914e7872019-01-23 16:39:42 +010028#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 Vultur00f52852019-04-15 11:56:36 +020037 for (i = 0; i < 2000; i++)
Horatiu Vultur914e7872019-01-23 16:39:42 +010038 ;
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 CLEMENTaf05ee52018-12-14 16:16:47 +010052 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 Vultur8a22b882019-01-12 18:56:56 +010064#endif
Gregory CLEMENTaf05ee52018-12-14 16:16:47 +010065
66 while (1)
67 ; /* NOP */
68}