mcip.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 __ASM_MCIP_H
  11. #define __ASM_MCIP_H
  12. #ifdef CONFIG_ISA_ARCV2
  13. #include <asm/arcregs.h>
  14. #define ARC_REG_MCIP_BCR 0x0d0
  15. #define ARC_REG_MCIP_CMD 0x600
  16. #define ARC_REG_MCIP_WDATA 0x601
  17. #define ARC_REG_MCIP_READBACK 0x602
  18. struct mcip_cmd {
  19. #ifdef CONFIG_CPU_BIG_ENDIAN
  20. unsigned int pad:8, param:16, cmd:8;
  21. #else
  22. unsigned int cmd:8, param:16, pad:8;
  23. #endif
  24. #define CMD_INTRPT_GENERATE_IRQ 0x01
  25. #define CMD_INTRPT_GENERATE_ACK 0x02
  26. #define CMD_INTRPT_READ_STATUS 0x03
  27. #define CMD_INTRPT_CHECK_SOURCE 0x04
  28. /* Semaphore Commands */
  29. #define CMD_SEMA_CLAIM_AND_READ 0x11
  30. #define CMD_SEMA_RELEASE 0x12
  31. #define CMD_DEBUG_SET_MASK 0x34
  32. #define CMD_DEBUG_SET_SELECT 0x36
  33. #define CMD_GRTC_READ_LO 0x42
  34. #define CMD_GRTC_READ_HI 0x43
  35. #define CMD_IDU_ENABLE 0x71
  36. #define CMD_IDU_DISABLE 0x72
  37. #define CMD_IDU_SET_MODE 0x74
  38. #define CMD_IDU_SET_DEST 0x76
  39. #define CMD_IDU_SET_MASK 0x7C
  40. #define IDU_M_TRIG_LEVEL 0x0
  41. #define IDU_M_TRIG_EDGE 0x1
  42. #define IDU_M_DISTRI_RR 0x0
  43. #define IDU_M_DISTRI_DEST 0x2
  44. };
  45. /*
  46. * MCIP programming model
  47. *
  48. * - Simple commands write {cmd:8,param:16} to MCIP_CMD aux reg
  49. * (param could be irq, common_irq, core_id ...)
  50. * - More involved commands setup MCIP_WDATA with cmd specific data
  51. * before invoking the simple command
  52. */
  53. static inline void __mcip_cmd(unsigned int cmd, unsigned int param)
  54. {
  55. struct mcip_cmd buf;
  56. buf.pad = 0;
  57. buf.cmd = cmd;
  58. buf.param = param;
  59. WRITE_AUX(ARC_REG_MCIP_CMD, buf);
  60. }
  61. /*
  62. * Setup additional data for a cmd
  63. * Callers need to lock to ensure atomicity
  64. */
  65. static inline void __mcip_cmd_data(unsigned int cmd, unsigned int param,
  66. unsigned int data)
  67. {
  68. write_aux_reg(ARC_REG_MCIP_WDATA, data);
  69. __mcip_cmd(cmd, param);
  70. }
  71. #endif
  72. #endif