scmi.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (c) 2024, Rockchip, Inc. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <string.h>
  8. #include <platform_def.h>
  9. #include <drivers/scmi-msg.h>
  10. #include <drivers/scmi.h>
  11. #include <lib/utils.h>
  12. #include <lib/utils_def.h>
  13. #define MAX_PROTOCOL_IN_LIST 8U
  14. static const char vendor[] = "rockchip";
  15. static const char sub_vendor[] = "";
  16. #pragma weak rockchip_scmi_protocol_table
  17. const uint8_t rockchip_scmi_protocol_table[1][MAX_PROTOCOL_IN_LIST] = {
  18. {
  19. SCMI_PROTOCOL_ID_CLOCK,
  20. SCMI_PROTOCOL_ID_RESET_DOMAIN,
  21. 0
  22. }
  23. };
  24. const char *plat_scmi_vendor_name(void)
  25. {
  26. return vendor;
  27. }
  28. const char *plat_scmi_sub_vendor_name(void)
  29. {
  30. return sub_vendor;
  31. }
  32. size_t plat_scmi_protocol_count(void)
  33. {
  34. unsigned int count = 0U;
  35. const uint8_t *protocol_list = rockchip_scmi_protocol_table[0];
  36. while (protocol_list[count])
  37. count++;
  38. return count;
  39. }
  40. const uint8_t *plat_scmi_protocol_list(unsigned int agent_id)
  41. {
  42. assert(agent_id < ARRAY_SIZE(rockchip_scmi_protocol_table));
  43. return rockchip_scmi_protocol_table[agent_id];
  44. }
  45. static struct scmi_msg_channel scmi_channel[] = {
  46. [0] = {
  47. .shm_addr = SMT_BUFFER0_BASE,
  48. .shm_size = SMT_BUF_SLOT_SIZE,
  49. },
  50. #ifdef SMT_BUFFER1_BASE
  51. [1] = {
  52. .shm_addr = SMT_BUFFER1_BASE,
  53. .shm_size = SMT_BUF_SLOT_SIZE,
  54. },
  55. #endif
  56. };
  57. struct scmi_msg_channel *plat_scmi_get_channel(unsigned int agent_id)
  58. {
  59. assert(agent_id < ARRAY_SIZE(scmi_channel));
  60. return &scmi_channel[agent_id];
  61. }
  62. #pragma weak rockchip_init_scmi_server
  63. void rockchip_init_scmi_server(void)
  64. {
  65. size_t i;
  66. for (i = 0U; i < ARRAY_SIZE(scmi_channel); i++)
  67. scmi_smt_init_agent_channel(&scmi_channel[i]);
  68. }