Chin Liang See | 1922dad | 2013-08-07 10:08:03 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Altera Corporation <www.altera.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <asm/io.h> |
| 10 | #include <asm/arch/reset_manager.h> |
| 11 | |
| 12 | DECLARE_GLOBAL_DATA_PTR; |
| 13 | |
| 14 | static const struct socfpga_reset_manager *reset_manager_base = |
| 15 | (void *)SOCFPGA_RSTMGR_ADDRESS; |
| 16 | |
Pavel Machek | 56a00ab | 2014-09-09 14:03:28 +0200 | [diff] [blame] | 17 | /* Toggle reset signal to watchdog (WDT is disabled after this operation!) */ |
| 18 | void socfpga_watchdog_reset(void) |
| 19 | { |
| 20 | /* assert reset for watchdog */ |
| 21 | setbits_le32(&reset_manager_base->per_mod_reset, |
| 22 | 1 << RSTMGR_PERMODRST_L4WD0_LSB); |
| 23 | |
| 24 | /* deassert watchdog from reset (watchdog in not running state) */ |
| 25 | clrbits_le32(&reset_manager_base->per_mod_reset, |
| 26 | 1 << RSTMGR_PERMODRST_L4WD0_LSB); |
| 27 | } |
| 28 | |
Chin Liang See | 1922dad | 2013-08-07 10:08:03 -0500 | [diff] [blame] | 29 | /* |
| 30 | * Write the reset manager register to cause reset |
| 31 | */ |
| 32 | void reset_cpu(ulong addr) |
| 33 | { |
| 34 | /* request a warm reset */ |
| 35 | writel((1 << RSTMGR_CTRL_SWWARMRSTREQ_LSB), |
| 36 | &reset_manager_base->ctrl); |
| 37 | /* |
| 38 | * infinite loop here as watchdog will trigger and reset |
| 39 | * the processor |
| 40 | */ |
| 41 | while (1) |
| 42 | ; |
| 43 | } |
| 44 | |
| 45 | /* |
| 46 | * Release peripherals from reset based on handoff |
| 47 | */ |
| 48 | void reset_deassert_peripherals_handoff(void) |
| 49 | { |
| 50 | writel(0, &reset_manager_base->per_mod_reset); |
| 51 | } |
Marek Vasut | c38c869 | 2014-09-08 14:08:45 +0200 | [diff] [blame] | 52 | |
| 53 | /* Change the reset state for EMAC 0 and EMAC 1 */ |
| 54 | void socfpga_emac_reset(int enable) |
| 55 | { |
| 56 | const void *reset = &reset_manager_base->per_mod_reset; |
| 57 | |
| 58 | if (enable) { |
| 59 | setbits_le32(reset, 1 << RSTMGR_PERMODRST_EMAC0_LSB); |
| 60 | setbits_le32(reset, 1 << RSTMGR_PERMODRST_EMAC1_LSB); |
| 61 | } else { |
| 62 | #if (CONFIG_EMAC_BASE == SOCFPGA_EMAC0_ADDRESS) |
| 63 | clrbits_le32(reset, 1 << RSTMGR_PERMODRST_EMAC0_LSB); |
| 64 | #elif (CONFIG_EMAC_BASE == SOCFPGA_EMAC1_ADDRESS) |
| 65 | clrbits_le32(reset, 1 << RSTMGR_PERMODRST_EMAC1_LSB); |
| 66 | #endif |
| 67 | } |
| 68 | } |