mcip.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * ARConnect IP Support (Multi core enabler: Cross core IPI, RTC ...)
  4. *
  5. * Copyright (C) 2014-15 Synopsys, Inc. (www.synopsys.com)
  6. */
  7. #ifndef __SOC_ARC_MCIP_H
  8. #define __SOC_ARC_MCIP_H
  9. #include <soc/arc/aux.h>
  10. #define ARC_REG_MCIP_BCR 0x0d0
  11. #define ARC_REG_MCIP_IDU_BCR 0x0D5
  12. #define ARC_REG_GFRC_BUILD 0x0D6
  13. #define ARC_REG_MCIP_CMD 0x600
  14. #define ARC_REG_MCIP_WDATA 0x601
  15. #define ARC_REG_MCIP_READBACK 0x602
  16. struct mcip_cmd {
  17. #ifdef CONFIG_CPU_BIG_ENDIAN
  18. unsigned int pad:8, param:16, cmd:8;
  19. #else
  20. unsigned int cmd:8, param:16, pad:8;
  21. #endif
  22. #define CMD_INTRPT_GENERATE_IRQ 0x01
  23. #define CMD_INTRPT_GENERATE_ACK 0x02
  24. #define CMD_INTRPT_READ_STATUS 0x03
  25. #define CMD_INTRPT_CHECK_SOURCE 0x04
  26. /* Semaphore Commands */
  27. #define CMD_SEMA_CLAIM_AND_READ 0x11
  28. #define CMD_SEMA_RELEASE 0x12
  29. #define CMD_DEBUG_SET_MASK 0x34
  30. #define CMD_DEBUG_READ_MASK 0x35
  31. #define CMD_DEBUG_SET_SELECT 0x36
  32. #define CMD_DEBUG_READ_SELECT 0x37
  33. #define CMD_GFRC_READ_LO 0x42
  34. #define CMD_GFRC_READ_HI 0x43
  35. #define CMD_GFRC_SET_CORE 0x47
  36. #define CMD_GFRC_READ_CORE 0x48
  37. #define CMD_IDU_ENABLE 0x71
  38. #define CMD_IDU_DISABLE 0x72
  39. #define CMD_IDU_SET_MODE 0x74
  40. #define CMD_IDU_READ_MODE 0x75
  41. #define CMD_IDU_SET_DEST 0x76
  42. #define CMD_IDU_ACK_CIRQ 0x79
  43. #define CMD_IDU_SET_MASK 0x7C
  44. #define IDU_M_TRIG_LEVEL 0x0
  45. #define IDU_M_TRIG_EDGE 0x1
  46. #define IDU_M_DISTRI_RR 0x0
  47. #define IDU_M_DISTRI_DEST 0x2
  48. };
  49. struct mcip_bcr {
  50. #ifdef CONFIG_CPU_BIG_ENDIAN
  51. unsigned int pad4:6, pw_dom:1, pad3:1,
  52. idu:1, pad2:1, num_cores:6,
  53. pad:1, gfrc:1, dbg:1, pw:1,
  54. msg:1, sem:1, ipi:1, slv:1,
  55. ver:8;
  56. #else
  57. unsigned int ver:8,
  58. slv:1, ipi:1, sem:1, msg:1,
  59. pw:1, dbg:1, gfrc:1, pad:1,
  60. num_cores:6, pad2:1, idu:1,
  61. pad3:1, pw_dom:1, pad4:6;
  62. #endif
  63. };
  64. struct mcip_idu_bcr {
  65. #ifdef CONFIG_CPU_BIG_ENDIAN
  66. unsigned int pad:21, cirqnum:3, ver:8;
  67. #else
  68. unsigned int ver:8, cirqnum:3, pad:21;
  69. #endif
  70. };
  71. /*
  72. * Build register for IDU contains not an actual number of supported common
  73. * interrupts but an exponent of 2 which must be multiplied by 4 to
  74. * get a number of supported common interrupts.
  75. */
  76. #define mcip_idu_bcr_to_nr_irqs(bcr) (4 * (1 << (bcr).cirqnum))
  77. /*
  78. * MCIP programming model
  79. *
  80. * - Simple commands write {cmd:8,param:16} to MCIP_CMD aux reg
  81. * (param could be irq, common_irq, core_id ...)
  82. * - More involved commands setup MCIP_WDATA with cmd specific data
  83. * before invoking the simple command
  84. */
  85. static inline void __mcip_cmd(unsigned int cmd, unsigned int param)
  86. {
  87. struct mcip_cmd buf;
  88. buf.pad = 0;
  89. buf.cmd = cmd;
  90. buf.param = param;
  91. WRITE_AUX(ARC_REG_MCIP_CMD, buf);
  92. }
  93. /*
  94. * Setup additional data for a cmd
  95. * Callers need to lock to ensure atomicity
  96. */
  97. static inline void __mcip_cmd_data(unsigned int cmd, unsigned int param,
  98. unsigned int data)
  99. {
  100. write_aux_reg(ARC_REG_MCIP_WDATA, data);
  101. __mcip_cmd(cmd, param);
  102. }
  103. /*
  104. * Read MCIP register
  105. */
  106. static inline unsigned int __mcip_cmd_read(unsigned int cmd, unsigned int param)
  107. {
  108. __mcip_cmd(cmd, param);
  109. return read_aux_reg(ARC_REG_MCIP_READBACK);
  110. }
  111. #endif