mailbox_s10.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * Copyright (C) 2017-2018 Intel Corporation <www.intel.com>
  4. *
  5. */
  6. #ifndef _MAILBOX_S10_H_
  7. #define _MAILBOX_S10_H_
  8. /* user define Uboot ID */
  9. #define MBOX_CLIENT_ID_UBOOT 0xB
  10. #define MBOX_ID_UBOOT 0x1
  11. #define MBOX_CMD_DIRECT 0
  12. #define MBOX_CMD_INDIRECT 1
  13. #define MBOX_MAX_CMD_INDEX 2047
  14. #define MBOX_CMD_BUFFER_SIZE 32
  15. #define MBOX_RESP_BUFFER_SIZE 16
  16. #define MBOX_HDR_CMD_LSB 0
  17. #define MBOX_HDR_CMD_MSK (BIT(11) - 1)
  18. #define MBOX_HDR_I_LSB 11
  19. #define MBOX_HDR_I_MSK BIT(11)
  20. #define MBOX_HDR_LEN_LSB 12
  21. #define MBOX_HDR_LEN_MSK 0x007FF000
  22. #define MBOX_HDR_ID_LSB 24
  23. #define MBOX_HDR_ID_MSK 0x0F000000
  24. #define MBOX_HDR_CLIENT_LSB 28
  25. #define MBOX_HDR_CLIENT_MSK 0xF0000000
  26. /* Interrupt flags */
  27. #define MBOX_FLAGS_INT_COE BIT(0) /* COUT update interrupt enable */
  28. #define MBOX_FLAGS_INT_RIE BIT(1) /* RIN update interrupt enable */
  29. #define MBOX_FLAGS_INT_UAE BIT(8) /* Urgent ACK interrupt enable */
  30. #define MBOX_ALL_INTRS (MBOX_FLAGS_INT_COE | \
  31. MBOX_FLAGS_INT_RIE | \
  32. MBOX_FLAGS_INT_UAE)
  33. /* Status */
  34. #define MBOX_STATUS_UA_MSK BIT(8)
  35. #define MBOX_CMD_HEADER(client, id, len, indirect, cmd) \
  36. ((((cmd) << MBOX_HDR_CMD_LSB) & MBOX_HDR_CMD_MSK) | \
  37. (((indirect) << MBOX_HDR_I_LSB) & MBOX_HDR_I_MSK) | \
  38. (((len) << MBOX_HDR_LEN_LSB) & MBOX_HDR_LEN_MSK) | \
  39. (((id) << MBOX_HDR_ID_LSB) & MBOX_HDR_ID_MSK) | \
  40. (((client) << MBOX_HDR_CLIENT_LSB) & MBOX_HDR_CLIENT_MSK))
  41. #define MBOX_RESP_ERR_GET(resp) \
  42. (((resp) & MBOX_HDR_CMD_MSK) >> MBOX_HDR_CMD_LSB)
  43. #define MBOX_RESP_LEN_GET(resp) \
  44. (((resp) & MBOX_HDR_LEN_MSK) >> MBOX_HDR_LEN_LSB)
  45. #define MBOX_RESP_ID_GET(resp) \
  46. (((resp) & MBOX_HDR_ID_MSK) >> MBOX_HDR_ID_LSB)
  47. #define MBOX_RESP_CLIENT_GET(resp) \
  48. (((resp) & MBOX_HDR_CLIENT_MSK) >> MBOX_HDR_CLIENT_LSB)
  49. /* Response error list */
  50. enum ALT_SDM_MBOX_RESP_CODE {
  51. /* CMD completed successfully, but check resp ARGS for any errors */
  52. MBOX_RESP_STATOK = 0,
  53. /* CMD is incorrectly formatted in some way */
  54. MBOX_RESP_INVALID_COMMAND = 1,
  55. /* BootROM Command code not undesrtood */
  56. MBOX_RESP_UNKNOWN_BR = 2,
  57. /* CMD code not recognized by firmware */
  58. MBOX_RESP_UNKNOWN = 3,
  59. /* Indicates that the device is not configured */
  60. MBOX_RESP_NOT_CONFIGURED = 256,
  61. /* Indicates that the device is busy */
  62. MBOX_RESP_DEVICE_BUSY = 0x1FF,
  63. /* Indicates that there is no valid response available */
  64. MBOX_RESP_NO_VALID_RESP_AVAILABLE = 0x2FF,
  65. /* General Error */
  66. MBOX_RESP_ERROR = 0x3FF,
  67. };
  68. /* Mailbox command list */
  69. #define MBOX_RESTART 2
  70. #define MBOX_CONFIG_STATUS 4
  71. #define MBOX_RECONFIG 6
  72. #define MBOX_RECONFIG_MSEL 7
  73. #define MBOX_RECONFIG_DATA 8
  74. #define MBOX_RECONFIG_STATUS 9
  75. #define MBOX_QSPI_OPEN 50
  76. #define MBOX_QSPI_CLOSE 51
  77. #define MBOX_QSPI_DIRECT 59
  78. #define MBOX_REBOOT_HPS 71
  79. /* Mailbox registers */
  80. #define MBOX_CIN 0 /* command valid offset */
  81. #define MBOX_ROUT 4 /* response output offset */
  82. #define MBOX_URG 8 /* urgent command */
  83. #define MBOX_FLAGS 0x0c /* interrupt enables */
  84. #define MBOX_COUT 0x20 /* command free offset */
  85. #define MBOX_RIN 0x24 /* respond valid offset */
  86. #define MBOX_STATUS 0x2c /* mailbox status */
  87. #define MBOX_CMD_BUF 0x40 /* circular command buffer */
  88. #define MBOX_RESP_BUF 0xc0 /* circular response buffer */
  89. #define MBOX_DOORBELL_TO_SDM 0x400 /* Doorbell to SDM */
  90. #define MBOX_DOORBELL_FROM_SDM 0x480 /* Doorbell from SDM */
  91. /* Status and bit information returned by RECONFIG_STATUS */
  92. #define RECONFIG_STATUS_RESPONSE_LEN 6
  93. #define RECONFIG_STATUS_STATE 0
  94. #define RECONFIG_STATUS_PIN_STATUS 2
  95. #define RECONFIG_STATUS_SOFTFUNC_STATUS 3
  96. #define MBOX_CFGSTAT_STATE_IDLE 0x00000000
  97. #define MBOX_CFGSTAT_STATE_CONFIG 0x10000000
  98. #define MBOX_CFGSTAT_STATE_FAILACK 0x08000000
  99. #define MBOX_CFGSTAT_STATE_ERROR_INVALID 0xf0000001
  100. #define MBOX_CFGSTAT_STATE_ERROR_CORRUPT 0xf0000002
  101. #define MBOX_CFGSTAT_STATE_ERROR_AUTH 0xf0000003
  102. #define MBOX_CFGSTAT_STATE_ERROR_CORE_IO 0xf0000004
  103. #define MBOX_CFGSTAT_STATE_ERROR_HARDWARE 0xf0000005
  104. #define MBOX_CFGSTAT_STATE_ERROR_FAKE 0xf0000006
  105. #define MBOX_CFGSTAT_STATE_ERROR_BOOT_INFO 0xf0000007
  106. #define MBOX_CFGSTAT_STATE_ERROR_QSPI_ERROR 0xf0000008
  107. #define RCF_SOFTFUNC_STATUS_CONF_DONE BIT(0)
  108. #define RCF_SOFTFUNC_STATUS_INIT_DONE BIT(1)
  109. #define RCF_SOFTFUNC_STATUS_SEU_ERROR BIT(3)
  110. #define RCF_PIN_STATUS_NSTATUS BIT(31)
  111. int mbox_send_cmd(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg, u8 urgent,
  112. u32 *resp_buf_len, u32 *resp_buf);
  113. int mbox_send_cmd_psci(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg,
  114. u8 urgent, u32 *resp_buf_len, u32 *resp_buf);
  115. int mbox_send_cmd_only(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg);
  116. int mbox_send_cmd_only_psci(u8 id, u32 cmd, u8 is_indirect, u32 len, u32 *arg);
  117. int mbox_rcv_resp(u32 *resp_buf, u32 resp_buf_max_len);
  118. int mbox_rcv_resp_psci(u32 *resp_buf, u32 resp_buf_max_len);
  119. int mbox_init(void);
  120. #ifdef CONFIG_CADENCE_QSPI
  121. int mbox_qspi_close(void);
  122. int mbox_qspi_open(void);
  123. #endif
  124. int mbox_reset_cold(void);
  125. #endif /* _MAILBOX_S10_H_ */