scmi_sq.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2019, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <arch_helpers.h>
  8. #include <common/debug.h>
  9. #include <drivers/arm/css/scmi.h>
  10. #include "scmi_private.h"
  11. #include "scmi_sq.h"
  12. #include <sq_common.h>
  13. /* SCMI message ID to get the available DRAM region */
  14. #define SCMI_VENDOR_EXT_MEMINFO_GET_MSG 0x3
  15. #define SCMI_VENDOR_EXT_MEMINFO_GET_MSG_LEN 4
  16. /*
  17. * API to get the available DRAM region
  18. */
  19. int scmi_get_draminfo(void *p, struct draminfo *info)
  20. {
  21. mailbox_mem_t *mbx_mem;
  22. int token = 0, ret;
  23. scmi_channel_t *ch = (scmi_channel_t *)p;
  24. struct dram_info_resp response;
  25. validate_scmi_channel(ch);
  26. scmi_get_channel(ch);
  27. mbx_mem = (mailbox_mem_t *)(ch->info->scmi_mbx_mem);
  28. mbx_mem->msg_header = SCMI_MSG_CREATE(SCMI_SYS_VENDOR_EXT_PROTO_ID,
  29. SCMI_VENDOR_EXT_MEMINFO_GET_MSG, token);
  30. mbx_mem->len = SCMI_VENDOR_EXT_MEMINFO_GET_MSG_LEN;
  31. mbx_mem->flags = SCMI_FLAG_RESP_POLL;
  32. scmi_send_sync_command(ch);
  33. /*
  34. * Ensure that any read to the SCPI payload area is done after reading
  35. * the MHU register. If these 2 reads were reordered then the CPU would
  36. * read invalid payload data
  37. */
  38. dmbld();
  39. /* Get the return values */
  40. SCMI_PAYLOAD_RET_VAL1(mbx_mem->payload, ret);
  41. memcpy(&response, (void *)mbx_mem->payload, sizeof(response));
  42. scmi_put_channel(ch);
  43. *info = response.info;
  44. return ret;
  45. }