blob: 48fac168585e30daeb668fa88c38eb06d436b0dd [file] [log] [blame]
Etienne Carriere13b353c2019-11-28 09:13:34 +01001/* SPDX-License-Identifier: BSD-3-Clause */
2/*
3 * Copyright (c) 2015-2019, Arm Limited and Contributors. All rights reserved.
4 * Copyright (c) 2019, Linaro Limited
5 */
6
7#ifndef SCMI_MSG_H
8#define SCMI_MSG_H
9
10#include <stdbool.h>
11#include <stddef.h>
12#include <stdint.h>
13
14/* Minimum size expected for SMT based shared memory message buffers */
15#define SMT_BUF_SLOT_SIZE 128U
16
17/* A channel abstract a communication path between agent and server */
18struct scmi_msg_channel;
19
20/*
21 * struct scmi_msg_channel - Shared memory buffer for a agent-to-server channel
22 *
23 * @shm_addr: Address of the shared memory for the SCMI channel
24 * @shm_size: Byte size of the shared memory for the SCMI channel
25 * @busy: True when channel is busy, flase when channel is free
26 * @agent_name: Agent name, SCMI protocol exposes 16 bytes max, or NULL
27 */
28struct scmi_msg_channel {
29 uintptr_t shm_addr;
30 size_t shm_size;
31 bool busy;
32 const char *agent_name;
33};
34
35/* Platform callback functions */
36
37/*
38 * Return the SCMI channel related to an agent
39 * @agent_id: SCMI agent ID
40 * Return a pointer to channel on success, NULL otherwise
41 */
42struct scmi_msg_channel *plat_scmi_get_channel(unsigned int agent_id);
43
44/*
45 * Return how many SCMI protocols supported by the platform
46 * According to the SCMI specification, this function does not target
47 * a specific agent ID and shall return all platform known capabilities.
48 */
49size_t plat_scmi_protocol_count(void);
50
51/*
52 * Get the count and list of SCMI protocols (but base) supported for an agent
53 *
54 * @agent_id: SCMI agent ID
55 * Return a pointer to a null terminated array supported protocol IDs.
56 */
57const uint8_t *plat_scmi_protocol_list(unsigned int agent_id);
58
59/* Get the name of the SCMI vendor for the platform */
60const char *plat_scmi_vendor_name(void);
61
62/* Get the name of the SCMI sub-vendor for the platform */
63const char *plat_scmi_sub_vendor_name(void);
64
Etienne Carriere76b3cc62020-05-01 10:32:02 +020065/* Handlers for SCMI Clock protocol services */
66
67/*
68 * Return number of clock controllers for an agent
69 * @agent_id: SCMI agent ID
70 * Return number of clock controllers
71 */
72size_t plat_scmi_clock_count(unsigned int agent_id);
73
74/*
75 * Get clock controller string ID (aka name)
76 * @agent_id: SCMI agent ID
77 * @scmi_id: SCMI clock ID
78 * Return pointer to name or NULL
79 */
80const char *plat_scmi_clock_get_name(unsigned int agent_id,
81 unsigned int scmi_id);
82
83/*
84 * Get clock possible rate as an array of frequencies in Hertz.
85 *
86 * @agent_id: SCMI agent ID
87 * @scmi_id: SCMI clock ID
88 * @rates: If NULL, function returns, else output rates array
89 * @nb_elts: Array size of @rates.
90 * Return an SCMI compliant error code
91 */
92int32_t plat_scmi_clock_rates_array(unsigned int agent_id, unsigned int scmi_id,
93 unsigned long *rates, size_t *nb_elts);
94
95/*
96 * Get clock possible rate as range with regular steps in Hertz
97 *
98 * @agent_id: SCMI agent ID
99 * @scmi_id: SCMI clock ID
100 * @min_max_step: 3 cell array for min, max and step rate data
101 * Return an SCMI compliant error code
102 */
103int32_t plat_scmi_clock_rates_by_step(unsigned int agent_id,
104 unsigned int scmi_id,
105 unsigned long *min_max_step);
106
107/*
108 * Get clock rate in Hertz
109 * @agent_id: SCMI agent ID
110 * @scmi_id: SCMI clock ID
111 * Return clock rate or 0 if not supported
112 */
113unsigned long plat_scmi_clock_get_rate(unsigned int agent_id,
114 unsigned int scmi_id);
115
116/*
117 * Set clock rate in Hertz
118 * @agent_id: SCMI agent ID
119 * @scmi_id: SCMI clock ID
120 * @rate: Target clock frequency in Hertz
121 * Return a compliant SCMI error code
122 */
123int32_t plat_scmi_clock_set_rate(unsigned int agent_id, unsigned int scmi_id,
124 unsigned long rate);
125
126/*
127 * Get clock state (enabled or disabled)
128 * @agent_id: SCMI agent ID
129 * @scmi_id: SCMI clock ID
130 * Return 1 if clock is enabled, 0 if disables, or a negative SCMI error code
131 */
132int32_t plat_scmi_clock_get_state(unsigned int agent_id, unsigned int scmi_id);
133
134/*
135 * Get clock state (enabled or disabled)
136 * @agent_id: SCMI agent ID
137 * @scmi_id: SCMI clock ID
138 * @enable_not_disable: Enable clock if true, disable clock otherwise
139 * Return a compliant SCMI error code
140 */
141int32_t plat_scmi_clock_set_state(unsigned int agent_id, unsigned int scmi_id,
142 bool enable_not_disable);
143
Etienne Carriere13b353c2019-11-28 09:13:34 +0100144#endif /* SCMI_MSG_H */