blob: b30e536a35771ec3e1439c1e64fd09de3728dc50 [file] [log] [blame]
Etienne Carriere02fd1262020-09-09 18:44:00 +02001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2020, Linaro Limited
4 */
5
6#ifndef __SANDBOX_SCMI_TEST_H
7#define __SANDBOX_SCMI_TEST_H
8
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +09009#include <power-domain.h>
10
Etienne Carriere02fd1262020-09-09 18:44:00 +020011struct udevice;
12struct sandbox_scmi_agent;
13struct sandbox_scmi_service;
14
15/**
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +090016 * struct sandbox_scmi_pwd
17 * @id: Identifier of the power domain used in the SCMI protocol
18 * @pstate:: Power state of the domain
19 */
20struct sandbox_scmi_pwd {
21 uint id;
22 u32 pstate;
23};
24
25/**
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020026 * struct sandbox_scmi_clk - Simulated clock exposed by SCMI
27 * @id: Identifier of the clock used in the SCMI protocol
28 * @enabled: Clock state: true if enabled, false if disabled
29 * @rate: Clock rate in Hertz
Alice Guo6e2a7e72025-04-28 18:37:32 +080030 * @perm: Indicating state/parent/rate permission
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020031 */
32struct sandbox_scmi_clk {
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020033 bool enabled;
34 ulong rate;
Alice Guo6e2a7e72025-04-28 18:37:32 +080035 u32 perm;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020036};
37
38/**
Etienne Carriere8b9b6892020-09-09 18:44:07 +020039 * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI
Etienne Carrierec83a8432021-03-08 22:38:08 +010040 * @id: Identifier of the reset controller used in the SCMI protocol
Etienne Carriere8b9b6892020-09-09 18:44:07 +020041 * @asserted: Reset control state: true if asserted, false if desasserted
42 */
43struct sandbox_scmi_reset {
44 uint id;
45 bool asserted;
46};
47
48/**
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010049 * struct sandbox_scmi_voltd - Simulated voltage regulator exposed by SCMI
50 * @id: Identifier of the voltage domain used in the SCMI protocol
51 * @enabled: Regulator state: true if on, false if off
52 * @voltage_uv: Regulator current voltage in microvoltd (uV)
53 */
54struct sandbox_scmi_voltd {
55 uint id;
56 bool enabled;
57 int voltage_uv;
58};
59
60/**
Etienne Carriere02fd1262020-09-09 18:44:00 +020061 * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +090062 * @pwdom_version: Implemented power domain protocol version
63 * @pwdom_count: Simulated power domains array size
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020064 * @clk: Simulated clocks
65 * @clk_count: Simulated clocks array size
Etienne Carrierec83a8432021-03-08 22:38:08 +010066 * @reset: Simulated reset domains
67 * @reset_count: Simulated reset domains array size
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010068 * @voltd: Simulated voltage domains (regulators)
69 * @voltd_count: Simulated voltage domains array size
Etienne Carriere02fd1262020-09-09 18:44:00 +020070 */
71struct sandbox_scmi_agent {
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +090072 int pwdom_version;
73 struct sandbox_scmi_pwd *pwdom;
74 size_t pwdom_count;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020075 struct sandbox_scmi_clk *clk;
76 size_t clk_count;
Etienne Carriere8b9b6892020-09-09 18:44:07 +020077 struct sandbox_scmi_reset *reset;
78 size_t reset_count;
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010079 struct sandbox_scmi_voltd *voltd;
80 size_t voltd_count;
Etienne Carriere02fd1262020-09-09 18:44:00 +020081};
82
83/**
84 * struct sandbox_scmi_service - Reference to simutaed SCMI agents/services
Etienne Carriere09665cb2022-02-21 09:22:39 +010085 * @agent: Pointer to SCMI sandbox agent or NULL if not probed
Etienne Carriere02fd1262020-09-09 18:44:00 +020086 */
87struct sandbox_scmi_service {
Etienne Carriere09665cb2022-02-21 09:22:39 +010088 struct sandbox_scmi_agent *agent;
Etienne Carriere02fd1262020-09-09 18:44:00 +020089};
90
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020091/**
92 * struct sandbox_scmi_devices - Reference to devices probed through SCMI
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +090093 * @pwdom: Array of power domains
94 * @pwdom_count: Number of power domains probed
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020095 * @clk: Array the clock devices
96 * @clk_count: Number of clock devices probed
Etienne Carriere8b9b6892020-09-09 18:44:07 +020097 * @reset: Array the reset controller devices
98 * @reset_count: Number of reset controller devices probed
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010099 * @regul: Array regulator devices
100 * @regul_count: Number of regulator devices probed
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200101 */
102struct sandbox_scmi_devices {
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +0900103 struct power_domain *pwdom;
104 size_t pwdom_count;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200105 struct clk *clk;
106 size_t clk_count;
Etienne Carriere8b9b6892020-09-09 18:44:07 +0200107 struct reset_ctl *reset;
108 size_t reset_count;
Etienne Carriereb8f15cd2021-03-08 22:38:07 +0100109 struct udevice **regul;
110 size_t regul_count;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200111};
112
Etienne Carriere02fd1262020-09-09 18:44:00 +0200113#ifdef CONFIG_SCMI_FIRMWARE
114/**
AKASHI Takahiro6221bf72023-10-11 19:06:56 +0900115 * sandbox_scmi_channel_id - Get the channel id
116 * @dev: Reference to the SCMI protocol device
117 *
118 * Return: Channel id
119 */
120unsigned int sandbox_scmi_channel_id(struct udevice *dev);
121
122/**
Etienne Carriere09665cb2022-02-21 09:22:39 +0100123 * sandbox_scmi_service_ctx - Get the simulated SCMI services context
AKASHI Takahirodae00462023-10-11 19:07:03 +0900124 * sandbox_scmi_agent_ctx - Get the simulated SCMI agent context
125 * @dev: Reference to the test agent
Etienne Carriere02fd1262020-09-09 18:44:00 +0200126 * @return: Reference to backend simulated resources state
127 */
AKASHI Takahirodae00462023-10-11 19:07:03 +0900128struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev);
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200129
130/**
Etienne Carriere09665cb2022-02-21 09:22:39 +0100131 * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200132 * @dev: Reference to the test device used get test resources
133 * @return: Reference to the devices probed by the SCMI test
134 */
135struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev);
Etienne Carriere02fd1262020-09-09 18:44:00 +0200136#else
AKASHI Takahiro6221bf72023-10-11 19:06:56 +0900137inline unsigned int sandbox_scmi_channel_id(struct udevice *dev);
138{
139 return 0;
140}
141
AKASHI Takahirodae00462023-10-11 19:07:03 +0900142static struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev)
Etienne Carriere02fd1262020-09-09 18:44:00 +0200143{
144 return NULL;
145}
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200146
147static inline
148struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
149{
150 return NULL;
151}
Etienne Carriere02fd1262020-09-09 18:44:00 +0200152#endif /* CONFIG_SCMI_FIRMWARE */
153#endif /* __SANDBOX_SCMI_TEST_H */