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