sysregs.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright 2011 Calxeda, Inc.
  4. */
  5. #ifndef _MACH_HIGHBANK__SYSREGS_H_
  6. #define _MACH_HIGHBANK__SYSREGS_H_
  7. #include <linux/io.h>
  8. #include <linux/smp.h>
  9. #include <asm/smp_plat.h>
  10. #include <asm/smp_scu.h>
  11. #include "core.h"
  12. extern void __iomem *sregs_base;
  13. #define HB_SREG_A9_PWR_REQ 0xf00
  14. #define HB_SREG_A9_BOOT_STAT 0xf04
  15. #define HB_SREG_A9_BOOT_DATA 0xf08
  16. #define HB_PWR_SUSPEND 0
  17. #define HB_PWR_SOFT_RESET 1
  18. #define HB_PWR_HARD_RESET 2
  19. #define HB_PWR_SHUTDOWN 3
  20. #define SREG_CPU_PWR_CTRL(c) (0x200 + ((c) * 4))
  21. static inline void highbank_set_core_pwr(void)
  22. {
  23. int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(smp_processor_id()), 0);
  24. if (scu_base_addr)
  25. scu_power_mode(scu_base_addr, SCU_PM_POWEROFF);
  26. else
  27. writel_relaxed(1, sregs_base + SREG_CPU_PWR_CTRL(cpu));
  28. }
  29. static inline void highbank_clear_core_pwr(void)
  30. {
  31. int cpu = MPIDR_AFFINITY_LEVEL(cpu_logical_map(smp_processor_id()), 0);
  32. if (scu_base_addr)
  33. scu_power_mode(scu_base_addr, SCU_PM_NORMAL);
  34. else
  35. writel_relaxed(0, sregs_base + SREG_CPU_PWR_CTRL(cpu));
  36. }
  37. static inline void highbank_set_pwr_suspend(void)
  38. {
  39. writel(HB_PWR_SUSPEND, sregs_base + HB_SREG_A9_PWR_REQ);
  40. highbank_set_core_pwr();
  41. }
  42. static inline void highbank_set_pwr_shutdown(void)
  43. {
  44. writel(HB_PWR_SHUTDOWN, sregs_base + HB_SREG_A9_PWR_REQ);
  45. highbank_set_core_pwr();
  46. }
  47. static inline void highbank_set_pwr_soft_reset(void)
  48. {
  49. writel(HB_PWR_SOFT_RESET, sregs_base + HB_SREG_A9_PWR_REQ);
  50. highbank_set_core_pwr();
  51. }
  52. static inline void highbank_set_pwr_hard_reset(void)
  53. {
  54. writel(HB_PWR_HARD_RESET, sregs_base + HB_SREG_A9_PWR_REQ);
  55. highbank_set_core_pwr();
  56. }
  57. static inline void highbank_clear_pwr_request(void)
  58. {
  59. writel(~0UL, sregs_base + HB_SREG_A9_PWR_REQ);
  60. highbank_clear_core_pwr();
  61. }
  62. #endif