mcip.h 3.0 KB

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