blob: 7844ad14cb66c3b60fc88efc2b12c9e70ccf54ef [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00002/*
Ley Foon Tandd5d12d2017-04-26 02:44:34 +08003 * Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00004 */
5
Ley Foon Tandd5d12d2017-04-26 02:44:34 +08006#ifndef _RESET_MANAGER_H_
7#define _RESET_MANAGER_H_
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00008
Ley Foon Tanfed4c952019-11-08 10:38:19 +08009phys_addr_t socfpga_get_rstmgr_addr(void);
10
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000011void reset_cpu(ulong addr);
Marek Vasut8d8c6482014-09-08 14:08:45 +020012
Marek Vasut3425eeb2015-07-09 02:45:15 +020013void socfpga_per_reset(u32 reset, int set);
Marek Vasut49edbd42015-07-09 04:27:28 +020014void socfpga_per_reset_all(void);
Marek Vasut3425eeb2015-07-09 02:45:15 +020015
Simon Goldschmidtb32e1e82019-07-15 21:47:52 +020016#define RSTMGR_CTRL_SWCOLDRSTREQ_LSB 0
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000017#define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000018
Marek Vasutbb1f8892015-07-09 02:30:35 +020019/*
20 * Define a reset identifier, from which a permodrst bank ID
21 * and reset ID can be extracted using the subsequent macros
22 * RSTMGR_RESET() and RSTMGR_BANK().
23 */
24#define RSTMGR_BANK_OFFSET 8
25#define RSTMGR_BANK_MASK 0x7
26#define RSTMGR_RESET_OFFSET 0
27#define RSTMGR_RESET_MASK 0x1f
28#define RSTMGR_DEFINE(_bank, _offset) \
29 ((_bank) << RSTMGR_BANK_OFFSET) | ((_offset) << RSTMGR_RESET_OFFSET)
30
31/* Extract reset ID from the reset identifier. */
32#define RSTMGR_RESET(_reset) \
33 (((_reset) >> RSTMGR_RESET_OFFSET) & RSTMGR_RESET_MASK)
34
35/* Extract bank ID from the reset identifier. */
36#define RSTMGR_BANK(_reset) \
37 (((_reset) >> RSTMGR_BANK_OFFSET) & RSTMGR_BANK_MASK)
38
Marek Vasutbb1f8892015-07-09 02:30:35 +020039/* Create a human-readable reference to SoCFPGA reset. */
40#define SOCFPGA_RESET(_name) RSTMGR_##_name
Pavel Machek56a00ab2014-09-09 14:03:28 +020041
Ley Foon Tandd5d12d2017-04-26 02:44:34 +080042#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
43#include <asm/arch/reset_manager_gen5.h>
Ley Foon Tan778ed2c2017-04-26 02:44:38 +080044#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
45#include <asm/arch/reset_manager_arria10.h>
Ley Foon Tanef9805a2019-11-27 15:55:17 +080046#elif defined(CONFIG_TARGET_SOCFPGA_STRATIX10) || \
47 defined(CONFIG_TARGET_SOCFPGA_AGILEX)
Ley Foon Tan89700b42019-11-27 15:55:16 +080048#include <asm/arch/reset_manager_soc64.h>
Ley Foon Tandd5d12d2017-04-26 02:44:34 +080049#endif
50
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000051#endif /* _RESET_MANAGER_H_ */