blob: 65917454f85ea726c4d5f20c6fdd1a204bf96d9e [file] [log] [blame]
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00001/*
Ley Foon Tandd5d12d2017-04-26 02:44:34 +08002 * Copyright (C) 2012-2017 Altera Corporation <www.altera.com>
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00003 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00005 */
6
Ley Foon Tandd5d12d2017-04-26 02:44:34 +08007#ifndef _RESET_MANAGER_H_
8#define _RESET_MANAGER_H_
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00009
10void reset_cpu(ulong addr);
Marek Vasut8d8c6482014-09-08 14:08:45 +020011
Marek Vasut3425eeb2015-07-09 02:45:15 +020012void socfpga_per_reset(u32 reset, int set);
Marek Vasut49edbd42015-07-09 04:27:28 +020013void socfpga_per_reset_all(void);
Marek Vasut3425eeb2015-07-09 02:45:15 +020014
Chin Liang See1922dad2013-08-07 10:08:03 -050015#if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
16#define RSTMGR_CTRL_SWWARMRSTREQ_LSB 2
17#else
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000018#define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
Chin Liang See1922dad2013-08-07 10:08:03 -050019#endif
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000020
Marek Vasutbb1f8892015-07-09 02:30:35 +020021/*
22 * Define a reset identifier, from which a permodrst bank ID
23 * and reset ID can be extracted using the subsequent macros
24 * RSTMGR_RESET() and RSTMGR_BANK().
25 */
26#define RSTMGR_BANK_OFFSET 8
27#define RSTMGR_BANK_MASK 0x7
28#define RSTMGR_RESET_OFFSET 0
29#define RSTMGR_RESET_MASK 0x1f
30#define RSTMGR_DEFINE(_bank, _offset) \
31 ((_bank) << RSTMGR_BANK_OFFSET) | ((_offset) << RSTMGR_RESET_OFFSET)
32
33/* Extract reset ID from the reset identifier. */
34#define RSTMGR_RESET(_reset) \
35 (((_reset) >> RSTMGR_RESET_OFFSET) & RSTMGR_RESET_MASK)
36
37/* Extract bank ID from the reset identifier. */
38#define RSTMGR_BANK(_reset) \
39 (((_reset) >> RSTMGR_BANK_OFFSET) & RSTMGR_BANK_MASK)
40
Marek Vasutbb1f8892015-07-09 02:30:35 +020041/* Create a human-readable reference to SoCFPGA reset. */
42#define SOCFPGA_RESET(_name) RSTMGR_##_name
Pavel Machek56a00ab2014-09-09 14:03:28 +020043
Ley Foon Tandd5d12d2017-04-26 02:44:34 +080044#if defined(CONFIG_TARGET_SOCFPGA_GEN5)
45#include <asm/arch/reset_manager_gen5.h>
Ley Foon Tan778ed2c2017-04-26 02:44:38 +080046#elif defined(CONFIG_TARGET_SOCFPGA_ARRIA10)
47#include <asm/arch/reset_manager_arria10.h>
Ley Foon Tandd5d12d2017-04-26 02:44:34 +080048#endif
49
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000050#endif /* _RESET_MANAGER_H_ */