reset_manager.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (C) 2012 Altera Corporation <www.altera.com>
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #ifndef _RESET_MANAGER_H_
  7. #define _RESET_MANAGER_H_
  8. void reset_cpu(ulong addr);
  9. void reset_deassert_peripherals_handoff(void);
  10. void socfpga_bridges_reset(int enable);
  11. void socfpga_emac_reset(int enable);
  12. void socfpga_watchdog_reset(void);
  13. void socfpga_spim_enable(void);
  14. void socfpga_uart0_enable(void);
  15. void socfpga_sdram_enable(void);
  16. void socfpga_osc1timer_enable(void);
  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. #if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET)
  30. #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 2
  31. #else
  32. #define RSTMGR_CTRL_SWWARMRSTREQ_LSB 1
  33. #endif
  34. /*
  35. * Define a reset identifier, from which a permodrst bank ID
  36. * and reset ID can be extracted using the subsequent macros
  37. * RSTMGR_RESET() and RSTMGR_BANK().
  38. */
  39. #define RSTMGR_BANK_OFFSET 8
  40. #define RSTMGR_BANK_MASK 0x7
  41. #define RSTMGR_RESET_OFFSET 0
  42. #define RSTMGR_RESET_MASK 0x1f
  43. #define RSTMGR_DEFINE(_bank, _offset) \
  44. ((_bank) << RSTMGR_BANK_OFFSET) | ((_offset) << RSTMGR_RESET_OFFSET)
  45. /* Extract reset ID from the reset identifier. */
  46. #define RSTMGR_RESET(_reset) \
  47. (((_reset) >> RSTMGR_RESET_OFFSET) & RSTMGR_RESET_MASK)
  48. /* Extract bank ID from the reset identifier. */
  49. #define RSTMGR_BANK(_reset) \
  50. (((_reset) >> RSTMGR_BANK_OFFSET) & RSTMGR_BANK_MASK)
  51. /*
  52. * SocFPGA Cyclone V/Arria V reset IDs, bank mapping is as follows:
  53. * 0 ... mpumodrst
  54. * 1 ... permodrst
  55. * 2 ... per2modrst
  56. * 3 ... brgmodrst
  57. * 4 ... miscmodrst
  58. */
  59. #define RSTMGR_EMAC0 RSTMGR_DEFINE(1, 0)
  60. #define RSTMGR_EMAC1 RSTMGR_DEFINE(1, 1)
  61. #define RSTMGR_L4WD0 RSTMGR_DEFINE(1, 6)
  62. #define RSTMGR_OSC1TIMER0 RSTMGR_DEFINE(1, 8)
  63. #define RSTMGR_UART0 RSTMGR_DEFINE(1, 16)
  64. #define RSTMGR_SPIM0 RSTMGR_DEFINE(1, 18)
  65. #define RSTMGR_SPIM1 RSTMGR_DEFINE(1, 19)
  66. #define RSTMGR_SDR RSTMGR_DEFINE(1, 29)
  67. /* Create a human-readable reference to SoCFPGA reset. */
  68. #define SOCFPGA_RESET(_name) RSTMGR_##_name
  69. #endif /* _RESET_MANAGER_H_ */