blob: ccb0df6c148ffe45aa0af3961e63f8700f11a837 [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
9struct udevice;
10struct sandbox_scmi_agent;
11struct sandbox_scmi_service;
12
13/**
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020014 * struct sandbox_scmi_clk - Simulated clock exposed by SCMI
15 * @id: Identifier of the clock used in the SCMI protocol
16 * @enabled: Clock state: true if enabled, false if disabled
17 * @rate: Clock rate in Hertz
18 */
19struct sandbox_scmi_clk {
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020020 bool enabled;
21 ulong rate;
22};
23
24/**
Etienne Carriere8b9b6892020-09-09 18:44:07 +020025 * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI
Etienne Carrierec83a8432021-03-08 22:38:08 +010026 * @id: Identifier of the reset controller used in the SCMI protocol
Etienne Carriere8b9b6892020-09-09 18:44:07 +020027 * @asserted: Reset control state: true if asserted, false if desasserted
28 */
29struct sandbox_scmi_reset {
30 uint id;
31 bool asserted;
32};
33
34/**
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010035 * struct sandbox_scmi_voltd - Simulated voltage regulator exposed by SCMI
36 * @id: Identifier of the voltage domain used in the SCMI protocol
37 * @enabled: Regulator state: true if on, false if off
38 * @voltage_uv: Regulator current voltage in microvoltd (uV)
39 */
40struct sandbox_scmi_voltd {
41 uint id;
42 bool enabled;
43 int voltage_uv;
44};
45
46/**
Etienne Carriere02fd1262020-09-09 18:44:00 +020047 * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020048 * @clk: Simulated clocks
49 * @clk_count: Simulated clocks array size
Etienne Carrierec83a8432021-03-08 22:38:08 +010050 * @reset: Simulated reset domains
51 * @reset_count: Simulated reset domains array size
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010052 * @voltd: Simulated voltage domains (regulators)
53 * @voltd_count: Simulated voltage domains array size
Etienne Carriere02fd1262020-09-09 18:44:00 +020054 */
55struct sandbox_scmi_agent {
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020056 struct sandbox_scmi_clk *clk;
57 size_t clk_count;
Etienne Carriere8b9b6892020-09-09 18:44:07 +020058 struct sandbox_scmi_reset *reset;
59 size_t reset_count;
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010060 struct sandbox_scmi_voltd *voltd;
61 size_t voltd_count;
Etienne Carriere02fd1262020-09-09 18:44:00 +020062};
63
64/**
65 * struct sandbox_scmi_service - Reference to simutaed SCMI agents/services
Etienne Carriere09665cb2022-02-21 09:22:39 +010066 * @agent: Pointer to SCMI sandbox agent or NULL if not probed
Etienne Carriere02fd1262020-09-09 18:44:00 +020067 */
68struct sandbox_scmi_service {
Etienne Carriere09665cb2022-02-21 09:22:39 +010069 struct sandbox_scmi_agent *agent;
Etienne Carriere02fd1262020-09-09 18:44:00 +020070};
71
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020072/**
73 * struct sandbox_scmi_devices - Reference to devices probed through SCMI
74 * @clk: Array the clock devices
75 * @clk_count: Number of clock devices probed
Etienne Carriere8b9b6892020-09-09 18:44:07 +020076 * @reset: Array the reset controller devices
77 * @reset_count: Number of reset controller devices probed
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010078 * @regul: Array regulator devices
79 * @regul_count: Number of regulator devices probed
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020080 */
81struct sandbox_scmi_devices {
82 struct clk *clk;
83 size_t clk_count;
Etienne Carriere8b9b6892020-09-09 18:44:07 +020084 struct reset_ctl *reset;
85 size_t reset_count;
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010086 struct udevice **regul;
87 size_t regul_count;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020088};
89
Etienne Carriere02fd1262020-09-09 18:44:00 +020090#ifdef CONFIG_SCMI_FIRMWARE
91/**
AKASHI Takahiro6221bf72023-10-11 19:06:56 +090092 * sandbox_scmi_channel_id - Get the channel id
93 * @dev: Reference to the SCMI protocol device
94 *
95 * Return: Channel id
96 */
97unsigned int sandbox_scmi_channel_id(struct udevice *dev);
98
99/**
Etienne Carriere09665cb2022-02-21 09:22:39 +0100100 * sandbox_scmi_service_ctx - Get the simulated SCMI services context
AKASHI Takahirodae00462023-10-11 19:07:03 +0900101 * sandbox_scmi_agent_ctx - Get the simulated SCMI agent context
102 * @dev: Reference to the test agent
Etienne Carriere02fd1262020-09-09 18:44:00 +0200103 * @return: Reference to backend simulated resources state
104 */
AKASHI Takahirodae00462023-10-11 19:07:03 +0900105struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev);
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200106
107/**
Etienne Carriere09665cb2022-02-21 09:22:39 +0100108 * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200109 * @dev: Reference to the test device used get test resources
110 * @return: Reference to the devices probed by the SCMI test
111 */
112struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev);
Etienne Carriere02fd1262020-09-09 18:44:00 +0200113#else
AKASHI Takahiro6221bf72023-10-11 19:06:56 +0900114inline unsigned int sandbox_scmi_channel_id(struct udevice *dev);
115{
116 return 0;
117}
118
AKASHI Takahirodae00462023-10-11 19:07:03 +0900119static struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev)
Etienne Carriere02fd1262020-09-09 18:44:00 +0200120{
121 return NULL;
122}
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200123
124static inline
125struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
126{
127 return NULL;
128}
Etienne Carriere02fd1262020-09-09 18:44:00 +0200129#endif /* CONFIG_SCMI_FIRMWARE */
130#endif /* __SANDBOX_SCMI_TEST_H */