blob: 619f8f5098cdd82ba2343897166c34c82c753422 [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
30 */
31struct sandbox_scmi_clk {
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020032 bool enabled;
33 ulong rate;
34};
35
36/**
Etienne Carriere8b9b6892020-09-09 18:44:07 +020037 * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI
Etienne Carrierec83a8432021-03-08 22:38:08 +010038 * @id: Identifier of the reset controller used in the SCMI protocol
Etienne Carriere8b9b6892020-09-09 18:44:07 +020039 * @asserted: Reset control state: true if asserted, false if desasserted
40 */
41struct sandbox_scmi_reset {
42 uint id;
43 bool asserted;
44};
45
46/**
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010047 * struct sandbox_scmi_voltd - Simulated voltage regulator exposed by SCMI
48 * @id: Identifier of the voltage domain used in the SCMI protocol
49 * @enabled: Regulator state: true if on, false if off
50 * @voltage_uv: Regulator current voltage in microvoltd (uV)
51 */
52struct sandbox_scmi_voltd {
53 uint id;
54 bool enabled;
55 int voltage_uv;
56};
57
58/**
Etienne Carriere02fd1262020-09-09 18:44:00 +020059 * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +090060 * @pwdom_version: Implemented power domain protocol version
61 * @pwdom_count: Simulated power domains array size
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020062 * @clk: Simulated clocks
63 * @clk_count: Simulated clocks array size
Etienne Carrierec83a8432021-03-08 22:38:08 +010064 * @reset: Simulated reset domains
65 * @reset_count: Simulated reset domains array size
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010066 * @voltd: Simulated voltage domains (regulators)
67 * @voltd_count: Simulated voltage domains array size
Etienne Carriere02fd1262020-09-09 18:44:00 +020068 */
69struct sandbox_scmi_agent {
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +090070 int pwdom_version;
71 struct sandbox_scmi_pwd *pwdom;
72 size_t pwdom_count;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020073 struct sandbox_scmi_clk *clk;
74 size_t clk_count;
Etienne Carriere8b9b6892020-09-09 18:44:07 +020075 struct sandbox_scmi_reset *reset;
76 size_t reset_count;
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010077 struct sandbox_scmi_voltd *voltd;
78 size_t voltd_count;
Etienne Carriere02fd1262020-09-09 18:44:00 +020079};
80
81/**
82 * struct sandbox_scmi_service - Reference to simutaed SCMI agents/services
Etienne Carriere09665cb2022-02-21 09:22:39 +010083 * @agent: Pointer to SCMI sandbox agent or NULL if not probed
Etienne Carriere02fd1262020-09-09 18:44:00 +020084 */
85struct sandbox_scmi_service {
Etienne Carriere09665cb2022-02-21 09:22:39 +010086 struct sandbox_scmi_agent *agent;
Etienne Carriere02fd1262020-09-09 18:44:00 +020087};
88
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020089/**
90 * struct sandbox_scmi_devices - Reference to devices probed through SCMI
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +090091 * @pwdom: Array of power domains
92 * @pwdom_count: Number of power domains probed
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020093 * @clk: Array the clock devices
94 * @clk_count: Number of clock devices probed
Etienne Carriere8b9b6892020-09-09 18:44:07 +020095 * @reset: Array the reset controller devices
96 * @reset_count: Number of reset controller devices probed
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010097 * @regul: Array regulator devices
98 * @regul_count: Number of regulator devices probed
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020099 */
100struct sandbox_scmi_devices {
AKASHI Takahiro535a7bd2023-10-16 14:39:45 +0900101 struct power_domain *pwdom;
102 size_t pwdom_count;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200103 struct clk *clk;
104 size_t clk_count;
Etienne Carriere8b9b6892020-09-09 18:44:07 +0200105 struct reset_ctl *reset;
106 size_t reset_count;
Etienne Carriereb8f15cd2021-03-08 22:38:07 +0100107 struct udevice **regul;
108 size_t regul_count;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200109};
110
Etienne Carriere02fd1262020-09-09 18:44:00 +0200111#ifdef CONFIG_SCMI_FIRMWARE
112/**
AKASHI Takahiro6221bf72023-10-11 19:06:56 +0900113 * sandbox_scmi_channel_id - Get the channel id
114 * @dev: Reference to the SCMI protocol device
115 *
116 * Return: Channel id
117 */
118unsigned int sandbox_scmi_channel_id(struct udevice *dev);
119
120/**
Etienne Carriere09665cb2022-02-21 09:22:39 +0100121 * sandbox_scmi_service_ctx - Get the simulated SCMI services context
AKASHI Takahirodae00462023-10-11 19:07:03 +0900122 * sandbox_scmi_agent_ctx - Get the simulated SCMI agent context
123 * @dev: Reference to the test agent
Etienne Carriere02fd1262020-09-09 18:44:00 +0200124 * @return: Reference to backend simulated resources state
125 */
AKASHI Takahirodae00462023-10-11 19:07:03 +0900126struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev);
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200127
128/**
Etienne Carriere09665cb2022-02-21 09:22:39 +0100129 * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200130 * @dev: Reference to the test device used get test resources
131 * @return: Reference to the devices probed by the SCMI test
132 */
133struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev);
Etienne Carriere02fd1262020-09-09 18:44:00 +0200134#else
AKASHI Takahiro6221bf72023-10-11 19:06:56 +0900135inline unsigned int sandbox_scmi_channel_id(struct udevice *dev);
136{
137 return 0;
138}
139
AKASHI Takahirodae00462023-10-11 19:07:03 +0900140static struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev)
Etienne Carriere02fd1262020-09-09 18:44:00 +0200141{
142 return NULL;
143}
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200144
145static inline
146struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
147{
148 return NULL;
149}
Etienne Carriere02fd1262020-09-09 18:44:00 +0200150#endif /* CONFIG_SCMI_FIRMWARE */
151#endif /* __SANDBOX_SCMI_TEST_H */