blob: c72ec1e1cb2550044b7ab8a4a64a848cfe8c4f98 [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/**
Etienne Carriere09665cb2022-02-21 09:22:39 +010092 * sandbox_scmi_service_ctx - Get the simulated SCMI services context
Etienne Carriere02fd1262020-09-09 18:44:00 +020093 * @return: Reference to backend simulated resources state
94 */
95struct sandbox_scmi_service *sandbox_scmi_service_ctx(void);
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020096
97/**
Etienne Carriere09665cb2022-02-21 09:22:39 +010098 * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020099 * @dev: Reference to the test device used get test resources
100 * @return: Reference to the devices probed by the SCMI test
101 */
102struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev);
Etienne Carriere02fd1262020-09-09 18:44:00 +0200103#else
104static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx(void)
105{
106 return NULL;
107}
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200108
109static inline
110struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
111{
112 return NULL;
113}
Etienne Carriere02fd1262020-09-09 18:44:00 +0200114#endif /* CONFIG_SCMI_FIRMWARE */
115#endif /* __SANDBOX_SCMI_TEST_H */