blob: 8e59578f374b7f799a36a3998b4f874beddd5d5d [file] [log] [blame]
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00001/*
2 * Copyright (C) 2012 Altera Corporation <www.altera.com>
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Dinh Nguyenad51f7c2012-10-04 06:46:02 +00005 */
6
7#ifndef _RESET_MANAGER_H_
8#define _RESET_MANAGER_H_
9
10void reset_cpu(ulong addr);
11void reset_deassert_peripherals_handoff(void);
12
Marek Vasut8d8c6482014-09-08 14:08:45 +020013void socfpga_bridges_reset(int enable);
14
Marek Vasut3425eeb2015-07-09 02:45:15 +020015void socfpga_per_reset(u32 reset, int set);
Marek Vasut49edbd42015-07-09 04:27:28 +020016void socfpga_per_reset_all(void);
Marek Vasut3425eeb2015-07-09 02:45:15 +020017
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000018struct socfpga_reset_manager {
Chin Liang See1922dad2013-08-07 10:08:03 -050019 u32 status;
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000020 u32 ctrl;
Chin Liang See1922dad2013-08-07 10:08:03 -050021 u32 counts;
22 u32 padding1;
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000023 u32 mpu_mod_reset;
24 u32 per_mod_reset;
25 u32 per2_mod_reset;
26 u32 brg_mod_reset;
Marek Vasutab8f13f2015-07-09 03:39:06 +020027 u32 misc_mod_reset;
28 u32 tstscratch;
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000029};
30
Chin Liang See1922dad2013-08-07 10:08:03 -050031#if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
32#define RSTMGR_CTRL_SWWARMRSTREQ_LSB 2
33#else
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000034#define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
Chin Liang See1922dad2013-08-07 10:08:03 -050035#endif
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000036
Marek Vasutbb1f8892015-07-09 02:30:35 +020037/*
38 * Define a reset identifier, from which a permodrst bank ID
39 * and reset ID can be extracted using the subsequent macros
40 * RSTMGR_RESET() and RSTMGR_BANK().
41 */
42#define RSTMGR_BANK_OFFSET 8
43#define RSTMGR_BANK_MASK 0x7
44#define RSTMGR_RESET_OFFSET 0
45#define RSTMGR_RESET_MASK 0x1f
46#define RSTMGR_DEFINE(_bank, _offset) \
47 ((_bank) << RSTMGR_BANK_OFFSET) | ((_offset) << RSTMGR_RESET_OFFSET)
48
49/* Extract reset ID from the reset identifier. */
50#define RSTMGR_RESET(_reset) \
51 (((_reset) >> RSTMGR_RESET_OFFSET) & RSTMGR_RESET_MASK)
52
53/* Extract bank ID from the reset identifier. */
54#define RSTMGR_BANK(_reset) \
55 (((_reset) >> RSTMGR_BANK_OFFSET) & RSTMGR_BANK_MASK)
56
57/*
58 * SocFPGA Cyclone V/Arria V reset IDs, bank mapping is as follows:
59 * 0 ... mpumodrst
60 * 1 ... permodrst
61 * 2 ... per2modrst
62 * 3 ... brgmodrst
63 * 4 ... miscmodrst
64 */
65#define RSTMGR_EMAC0 RSTMGR_DEFINE(1, 0)
66#define RSTMGR_EMAC1 RSTMGR_DEFINE(1, 1)
67#define RSTMGR_L4WD0 RSTMGR_DEFINE(1, 6)
68#define RSTMGR_OSC1TIMER0 RSTMGR_DEFINE(1, 8)
69#define RSTMGR_UART0 RSTMGR_DEFINE(1, 16)
70#define RSTMGR_SPIM0 RSTMGR_DEFINE(1, 18)
71#define RSTMGR_SPIM1 RSTMGR_DEFINE(1, 19)
Marek Vasutfc31d6e2015-07-09 04:28:13 +020072#define RSTMGR_QSPI RSTMGR_DEFINE(0, 5)
73#define RSTMGR_SDMMC RSTMGR_DEFINE(0, 22)
74#define RSTMGR_DMA RSTMGR_DEFINE(0, 28)
Marek Vasutbb1f8892015-07-09 02:30:35 +020075#define RSTMGR_SDR RSTMGR_DEFINE(1, 29)
76
77/* Create a human-readable reference to SoCFPGA reset. */
78#define SOCFPGA_RESET(_name) RSTMGR_##_name
Pavel Machek56a00ab2014-09-09 14:03:28 +020079
Dinh Nguyenad51f7c2012-10-04 06:46:02 +000080#endif /* _RESET_MANAGER_H_ */