arm: socfpga: reset: Implement unified function to toggle reset
[oweals/u-boot.git] / arch / arm / mach-socfpga / include / mach / reset_manager.h
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 void socfpga_emac_reset(int enable);
18 void socfpga_watchdog_reset(void);
19 void socfpga_spim_enable(void);
20 void socfpga_uart0_enable(void);
21 void socfpga_sdram_enable(void);
22 void socfpga_osc1timer_enable(void);
23
24 struct socfpga_reset_manager {
25         u32     status;
26         u32     ctrl;
27         u32     counts;
28         u32     padding1;
29         u32     mpu_mod_reset;
30         u32     per_mod_reset;
31         u32     per2_mod_reset;
32         u32     brg_mod_reset;
33         u32     misc_mod_reset;
34         u32     tstscratch;
35 };
36
37 #if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
38 #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 2
39 #else
40 #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
41 #endif
42
43 /*
44  * Define a reset identifier, from which a permodrst bank ID
45  * and reset ID can be extracted using the subsequent macros
46  * RSTMGR_RESET() and RSTMGR_BANK().
47  */
48 #define RSTMGR_BANK_OFFSET      8
49 #define RSTMGR_BANK_MASK        0x7
50 #define RSTMGR_RESET_OFFSET     0
51 #define RSTMGR_RESET_MASK       0x1f
52 #define RSTMGR_DEFINE(_bank, _offset)           \
53         ((_bank) << RSTMGR_BANK_OFFSET) | ((_offset) << RSTMGR_RESET_OFFSET)
54
55 /* Extract reset ID from the reset identifier. */
56 #define RSTMGR_RESET(_reset)                    \
57         (((_reset) >> RSTMGR_RESET_OFFSET) & RSTMGR_RESET_MASK)
58
59 /* Extract bank ID from the reset identifier. */
60 #define RSTMGR_BANK(_reset)                     \
61         (((_reset) >> RSTMGR_BANK_OFFSET) & RSTMGR_BANK_MASK)
62
63 /*
64  * SocFPGA Cyclone V/Arria V reset IDs, bank mapping is as follows:
65  * 0 ... mpumodrst
66  * 1 ... permodrst
67  * 2 ... per2modrst
68  * 3 ... brgmodrst
69  * 4 ... miscmodrst
70  */
71 #define RSTMGR_EMAC0            RSTMGR_DEFINE(1, 0)
72 #define RSTMGR_EMAC1            RSTMGR_DEFINE(1, 1)
73 #define RSTMGR_L4WD0            RSTMGR_DEFINE(1, 6)
74 #define RSTMGR_OSC1TIMER0       RSTMGR_DEFINE(1, 8)
75 #define RSTMGR_UART0            RSTMGR_DEFINE(1, 16)
76 #define RSTMGR_SPIM0            RSTMGR_DEFINE(1, 18)
77 #define RSTMGR_SPIM1            RSTMGR_DEFINE(1, 19)
78 #define RSTMGR_SDR              RSTMGR_DEFINE(1, 29)
79
80 /* Create a human-readable reference to SoCFPGA reset. */
81 #define SOCFPGA_RESET(_name)    RSTMGR_##_name
82
83 #endif /* _RESET_MANAGER_H_ */