mss_ipc_drv.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright (C) 2018 Marvell International Ltd.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. * https://spdx.org/licenses
  6. */
  7. #ifndef MSS_IPC_DRV_H
  8. #define MSS_IPC_DRV_H
  9. #include <lib/psci/psci.h>
  10. #define MV_PM_FW_IPC_VERSION_MAGIC (0xCA530000) /* Do NOT change */
  11. /* Increament for each version */
  12. #define MV_PM_FW_IPC_VERSION_SEQ (0x00000001)
  13. #define MV_PM_FW_IPC_VERSION (MV_PM_FW_IPC_VERSION_MAGIC | \
  14. MV_PM_FW_IPC_VERSION_SEQ)
  15. #define IPC_MSG_STATE_LOC (0x0)
  16. #define IPC_MSG_SYNC_ID_LOC (0x4)
  17. #define IPC_MSG_ID_LOC (0x8)
  18. #define IPC_MSG_RET_CH_ID_LOC (0xC)
  19. #define IPC_MSG_CPU_ID_LOC (0x10)
  20. #define IPC_MSG_CLUSTER_ID_LOC (0x14)
  21. #define IPC_MSG_SYSTEM_ID_LOC (0x18)
  22. #define IPC_MSG_POWER_STATE_LOC (0x1C)
  23. #define IPC_MSG_REPLY_LOC (0x20)
  24. #define IPC_MSG_RESERVED_LOC (0x24)
  25. /* IPC initialization state */
  26. enum mss_pm_ipc_init_state {
  27. IPC_UN_INITIALIZED = 1,
  28. IPC_INITIALIZED = 2
  29. };
  30. /* IPC queue direction */
  31. enum mss_pm_ipc_init_msg_dir {
  32. IPC_MSG_TX = 0,
  33. IPC_MSG_RX = 1
  34. };
  35. /* IPC message state */
  36. enum mss_pm_ipc_msg_state {
  37. IPC_MSG_FREE = 1,
  38. IPC_MSG_OCCUPY = 2
  39. };
  40. /* IPC control block */
  41. struct mss_pm_ipc_ctrl {
  42. unsigned int ctrl_base_address;
  43. unsigned int msg_base_address;
  44. unsigned int num_of_channels;
  45. unsigned int channel_size;
  46. unsigned int queue_size;
  47. };
  48. /* IPC message types */
  49. enum mss_pm_msg_id {
  50. PM_IPC_MSG_CPU_SUSPEND = 1,
  51. PM_IPC_MSG_CPU_OFF = 2,
  52. PM_IPC_MSG_CPU_ON = 3,
  53. PM_IPC_MSG_SYSTEM_RESET = 4,
  54. PM_IPC_MSG_SYSTEM_SUSPEND = 5,
  55. PM_IPC_MAX_MSG
  56. };
  57. struct mss_pm_ipc_msg {
  58. unsigned int msg_sync_id; /*
  59. * Sync number, validate message
  60. * reply corresponding to message
  61. * received
  62. */
  63. unsigned int msg_id; /* Message Id */
  64. unsigned int ret_channel_id; /* IPC channel reply */
  65. unsigned int cpu_id; /* CPU Id */
  66. unsigned int cluster_id; /* Cluster Id */
  67. unsigned int system_id; /* System Id */
  68. unsigned int power_state;
  69. unsigned int msg_reply; /* Message reply */
  70. };
  71. /* IPC queue */
  72. struct mss_pm_ipc_queue {
  73. unsigned int state;
  74. struct mss_pm_ipc_msg msg;
  75. };
  76. /* IPC channel */
  77. struct mss_pm_ipc_ch {
  78. struct mss_pm_ipc_queue *tx_queue;
  79. struct mss_pm_ipc_queue *rx_queue;
  80. };
  81. /*****************************************************************************
  82. * mv_pm_ipc_init
  83. *
  84. * DESCRIPTION: Initialize PM IPC infrastructure
  85. *****************************************************************************
  86. */
  87. int mv_pm_ipc_init(unsigned long ipc_control_addr);
  88. /*****************************************************************************
  89. * mv_pm_ipc_msg_rx
  90. *
  91. * DESCRIPTION: Retrieve message from IPC channel
  92. *****************************************************************************
  93. */
  94. int mv_pm_ipc_msg_rx(unsigned int channel_id, struct mss_pm_ipc_msg *msg);
  95. /*****************************************************************************
  96. * mv_pm_ipc_msg_tx
  97. *
  98. * DESCRIPTION: Send message via IPC channel
  99. *****************************************************************************
  100. */
  101. int mv_pm_ipc_msg_tx(unsigned int channel_id, unsigned int msg_id,
  102. unsigned int cluster_power_state);
  103. #endif /* MSS_IPC_DRV_H */