mips-cpc.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. * Copyright (C) 2013 Imagination Technologies
  3. * Author: Paul Burton <paul.burton@mips.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License as published by the
  7. * Free Software Foundation; either version 2 of the License, or (at your
  8. * option) any later version.
  9. */
  10. #ifndef __MIPS_ASM_MIPS_CPS_H__
  11. # error Please include asm/mips-cps.h rather than asm/mips-cpc.h
  12. #endif
  13. #ifndef __MIPS_ASM_MIPS_CPC_H__
  14. #define __MIPS_ASM_MIPS_CPC_H__
  15. #include <linux/bitops.h>
  16. #include <linux/errno.h>
  17. /* The base address of the CPC registers */
  18. extern void __iomem *mips_cpc_base;
  19. /**
  20. * mips_cpc_default_phys_base - retrieve the default physical base address of
  21. * the CPC
  22. *
  23. * Returns the default physical base address of the Cluster Power Controller
  24. * memory mapped registers. This is platform dependant & must therefore be
  25. * implemented per-platform.
  26. */
  27. extern phys_addr_t mips_cpc_default_phys_base(void);
  28. /**
  29. * mips_cpc_probe - probe for a Cluster Power Controller
  30. *
  31. * Attempt to detect the presence of a Cluster Power Controller. Returns 0 if
  32. * a CPC is successfully detected, else -errno.
  33. */
  34. #ifdef CONFIG_MIPS_CPC
  35. extern int mips_cpc_probe(void);
  36. #else
  37. static inline int mips_cpc_probe(void)
  38. {
  39. return -ENODEV;
  40. }
  41. #endif
  42. /**
  43. * mips_cpc_present - determine whether a Cluster Power Controller is present
  44. *
  45. * Returns true if a CPC is present in the system, else false.
  46. */
  47. static inline bool mips_cpc_present(void)
  48. {
  49. #ifdef CONFIG_MIPS_CPC
  50. return mips_cpc_base != NULL;
  51. #else
  52. return false;
  53. #endif
  54. }
  55. /* Offsets from the CPC base address to various control blocks */
  56. #define MIPS_CPC_GCB_OFS 0x0000
  57. #define MIPS_CPC_CLCB_OFS 0x2000
  58. #define MIPS_CPC_COCB_OFS 0x4000
  59. #define CPC_ACCESSOR_RO(sz, off, name) \
  60. CPS_ACCESSOR_RO(cpc, sz, MIPS_CPC_GCB_OFS + off, name) \
  61. CPS_ACCESSOR_RO(cpc, sz, MIPS_CPC_COCB_OFS + off, redir_##name)
  62. #define CPC_ACCESSOR_RW(sz, off, name) \
  63. CPS_ACCESSOR_RW(cpc, sz, MIPS_CPC_GCB_OFS + off, name) \
  64. CPS_ACCESSOR_RW(cpc, sz, MIPS_CPC_COCB_OFS + off, redir_##name)
  65. #define CPC_CX_ACCESSOR_RO(sz, off, name) \
  66. CPS_ACCESSOR_RO(cpc, sz, MIPS_CPC_CLCB_OFS + off, cl_##name) \
  67. CPS_ACCESSOR_RO(cpc, sz, MIPS_CPC_COCB_OFS + off, co_##name)
  68. #define CPC_CX_ACCESSOR_RW(sz, off, name) \
  69. CPS_ACCESSOR_RW(cpc, sz, MIPS_CPC_CLCB_OFS + off, cl_##name) \
  70. CPS_ACCESSOR_RW(cpc, sz, MIPS_CPC_COCB_OFS + off, co_##name)
  71. /* CPC_ACCESS - Control core/IOCU access to CPC registers prior to CM 3 */
  72. CPC_ACCESSOR_RW(32, 0x000, access)
  73. /* CPC_SEQDEL - Configure delays between command sequencer steps */
  74. CPC_ACCESSOR_RW(32, 0x008, seqdel)
  75. /* CPC_RAIL - Configure the delay from rail power-up to stability */
  76. CPC_ACCESSOR_RW(32, 0x010, rail)
  77. /* CPC_RESETLEN - Configure the length of reset sequences */
  78. CPC_ACCESSOR_RW(32, 0x018, resetlen)
  79. /* CPC_REVISION - Indicates the revisison of the CPC */
  80. CPC_ACCESSOR_RO(32, 0x020, revision)
  81. /* CPC_PWRUP_CTL - Control power to the Coherence Manager (CM) */
  82. CPC_ACCESSOR_RW(32, 0x030, pwrup_ctl)
  83. #define CPC_PWRUP_CTL_CM_PWRUP BIT(0)
  84. /* CPC_CONFIG - Mirrors GCR_CONFIG */
  85. CPC_ACCESSOR_RW(64, 0x138, config)
  86. /* CPC_SYS_CONFIG - Control cluster endianness */
  87. CPC_ACCESSOR_RW(32, 0x140, sys_config)
  88. #define CPC_SYS_CONFIG_BE_IMMEDIATE BIT(2)
  89. #define CPC_SYS_CONFIG_BE_STATUS BIT(1)
  90. #define CPC_SYS_CONFIG_BE BIT(0)
  91. /* CPC_Cx_CMD - Instruct the CPC to take action on a core */
  92. CPC_CX_ACCESSOR_RW(32, 0x000, cmd)
  93. #define CPC_Cx_CMD GENMASK(3, 0)
  94. #define CPC_Cx_CMD_CLOCKOFF 0x1
  95. #define CPC_Cx_CMD_PWRDOWN 0x2
  96. #define CPC_Cx_CMD_PWRUP 0x3
  97. #define CPC_Cx_CMD_RESET 0x4
  98. /* CPC_Cx_STAT_CONF - Indicates core configuration & state */
  99. CPC_CX_ACCESSOR_RW(32, 0x008, stat_conf)
  100. #define CPC_Cx_STAT_CONF_PWRUPE BIT(23)
  101. #define CPC_Cx_STAT_CONF_SEQSTATE GENMASK(22, 19)
  102. #define CPC_Cx_STAT_CONF_SEQSTATE_D0 0x0
  103. #define CPC_Cx_STAT_CONF_SEQSTATE_U0 0x1
  104. #define CPC_Cx_STAT_CONF_SEQSTATE_U1 0x2
  105. #define CPC_Cx_STAT_CONF_SEQSTATE_U2 0x3
  106. #define CPC_Cx_STAT_CONF_SEQSTATE_U3 0x4
  107. #define CPC_Cx_STAT_CONF_SEQSTATE_U4 0x5
  108. #define CPC_Cx_STAT_CONF_SEQSTATE_U5 0x6
  109. #define CPC_Cx_STAT_CONF_SEQSTATE_U6 0x7
  110. #define CPC_Cx_STAT_CONF_SEQSTATE_D1 0x8
  111. #define CPC_Cx_STAT_CONF_SEQSTATE_D3 0x9
  112. #define CPC_Cx_STAT_CONF_SEQSTATE_D2 0xa
  113. #define CPC_Cx_STAT_CONF_CLKGAT_IMPL BIT(17)
  114. #define CPC_Cx_STAT_CONF_PWRDN_IMPL BIT(16)
  115. #define CPC_Cx_STAT_CONF_EJTAG_PROBE BIT(15)
  116. /* CPC_Cx_OTHER - Configure the core-other register block prior to CM 3 */
  117. CPC_CX_ACCESSOR_RW(32, 0x010, other)
  118. #define CPC_Cx_OTHER_CORENUM GENMASK(23, 16)
  119. /* CPC_Cx_VP_STOP - Stop Virtual Processors (VPs) within a core from running */
  120. CPC_CX_ACCESSOR_RW(32, 0x020, vp_stop)
  121. /* CPC_Cx_VP_START - Start Virtual Processors (VPs) within a core running */
  122. CPC_CX_ACCESSOR_RW(32, 0x028, vp_run)
  123. /* CPC_Cx_VP_RUNNING - Indicate which Virtual Processors (VPs) are running */
  124. CPC_CX_ACCESSOR_RW(32, 0x030, vp_running)
  125. /* CPC_Cx_CONFIG - Mirrors GCR_Cx_CONFIG */
  126. CPC_CX_ACCESSOR_RW(32, 0x090, config)
  127. #ifdef CONFIG_MIPS_CPC
  128. /**
  129. * mips_cpc_lock_other - lock access to another core
  130. * core: the other core to be accessed
  131. *
  132. * Call before operating upon a core via the 'other' register region in
  133. * order to prevent the region being moved during access. Must be called
  134. * within the bounds of a mips_cm_{lock,unlock}_other pair, and followed
  135. * by a call to mips_cpc_unlock_other.
  136. */
  137. extern void mips_cpc_lock_other(unsigned int core);
  138. /**
  139. * mips_cpc_unlock_other - unlock access to another core
  140. *
  141. * Call after operating upon another core via the 'other' register region.
  142. * Must be called after mips_cpc_lock_other.
  143. */
  144. extern void mips_cpc_unlock_other(void);
  145. #else /* !CONFIG_MIPS_CPC */
  146. static inline void mips_cpc_lock_other(unsigned int core) { }
  147. static inline void mips_cpc_unlock_other(void) { }
  148. #endif /* !CONFIG_MIPS_CPC */
  149. #endif /* __MIPS_ASM_MIPS_CPC_H__ */