xref: /rk3399_rockchip-uboot/arch/arm/mach-socfpga/include/mach/reset_manager.h (revision a71df7aa4fa775199280bba19072bd232cc35cb1)
1 /*
2  *  Copyright (C) 2012 Altera Corporation <www.altera.com>
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #ifndef	_RESET_MANAGER_H_
8 #define	_RESET_MANAGER_H_
9 
10 void reset_cpu(ulong addr);
11 void reset_deassert_peripherals_handoff(void);
12 
13 void socfpga_bridges_reset(int enable);
14 
15 void socfpga_per_reset(u32 reset, int set);
16 
17 struct socfpga_reset_manager {
18 	u32	status;
19 	u32	ctrl;
20 	u32	counts;
21 	u32	padding1;
22 	u32	mpu_mod_reset;
23 	u32	per_mod_reset;
24 	u32	per2_mod_reset;
25 	u32	brg_mod_reset;
26 	u32	misc_mod_reset;
27 	u32	tstscratch;
28 };
29 
30 #if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
31 #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 2
32 #else
33 #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
34 #endif
35 
36 /*
37  * Define a reset identifier, from which a permodrst bank ID
38  * and reset ID can be extracted using the subsequent macros
39  * RSTMGR_RESET() and RSTMGR_BANK().
40  */
41 #define RSTMGR_BANK_OFFSET	8
42 #define RSTMGR_BANK_MASK	0x7
43 #define RSTMGR_RESET_OFFSET	0
44 #define RSTMGR_RESET_MASK	0x1f
45 #define RSTMGR_DEFINE(_bank, _offset)		\
46 	((_bank) << RSTMGR_BANK_OFFSET) | ((_offset) << RSTMGR_RESET_OFFSET)
47 
48 /* Extract reset ID from the reset identifier. */
49 #define RSTMGR_RESET(_reset)			\
50 	(((_reset) >> RSTMGR_RESET_OFFSET) & RSTMGR_RESET_MASK)
51 
52 /* Extract bank ID from the reset identifier. */
53 #define RSTMGR_BANK(_reset)			\
54 	(((_reset) >> RSTMGR_BANK_OFFSET) & RSTMGR_BANK_MASK)
55 
56 /*
57  * SocFPGA Cyclone V/Arria V reset IDs, bank mapping is as follows:
58  * 0 ... mpumodrst
59  * 1 ... permodrst
60  * 2 ... per2modrst
61  * 3 ... brgmodrst
62  * 4 ... miscmodrst
63  */
64 #define RSTMGR_EMAC0		RSTMGR_DEFINE(1, 0)
65 #define RSTMGR_EMAC1		RSTMGR_DEFINE(1, 1)
66 #define RSTMGR_L4WD0		RSTMGR_DEFINE(1, 6)
67 #define RSTMGR_OSC1TIMER0	RSTMGR_DEFINE(1, 8)
68 #define RSTMGR_UART0		RSTMGR_DEFINE(1, 16)
69 #define RSTMGR_SPIM0		RSTMGR_DEFINE(1, 18)
70 #define RSTMGR_SPIM1		RSTMGR_DEFINE(1, 19)
71 #define RSTMGR_SDR		RSTMGR_DEFINE(1, 29)
72 
73 /* Create a human-readable reference to SoCFPGA reset. */
74 #define SOCFPGA_RESET(_name)	RSTMGR_##_name
75 
76 #endif /* _RESET_MANAGER_H_ */
77