blob: 2930e686d72a31b14f0fa7830f85e61a8d363bba [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 {
20 uint id;
21 bool enabled;
22 ulong rate;
23};
24
25/**
Etienne Carriere8b9b6892020-09-09 18:44:07 +020026 * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI
Etienne Carrierec83a8432021-03-08 22:38:08 +010027 * @id: Identifier of the reset controller used in the SCMI protocol
Etienne Carriere8b9b6892020-09-09 18:44:07 +020028 * @asserted: Reset control state: true if asserted, false if desasserted
29 */
30struct sandbox_scmi_reset {
31 uint id;
32 bool asserted;
33};
34
35/**
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010036 * struct sandbox_scmi_voltd - Simulated voltage regulator exposed by SCMI
37 * @id: Identifier of the voltage domain used in the SCMI protocol
38 * @enabled: Regulator state: true if on, false if off
39 * @voltage_uv: Regulator current voltage in microvoltd (uV)
40 */
41struct sandbox_scmi_voltd {
42 uint id;
43 bool enabled;
44 int voltage_uv;
45};
46
47/**
Etienne Carriere02fd1262020-09-09 18:44:00 +020048 * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent
49 * @idx: Identifier for the SCMI agent, its index
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020050 * @clk: Simulated clocks
51 * @clk_count: Simulated clocks array size
Etienne Carrierec83a8432021-03-08 22:38:08 +010052 * @reset: Simulated reset domains
53 * @reset_count: Simulated reset domains array size
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010054 * @voltd: Simulated voltage domains (regulators)
55 * @voltd_count: Simulated voltage domains array size
Etienne Carriere02fd1262020-09-09 18:44:00 +020056 */
57struct sandbox_scmi_agent {
58 uint idx;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020059 struct sandbox_scmi_clk *clk;
60 size_t clk_count;
Etienne Carriere8b9b6892020-09-09 18:44:07 +020061 struct sandbox_scmi_reset *reset;
62 size_t reset_count;
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010063 struct sandbox_scmi_voltd *voltd;
64 size_t voltd_count;
Etienne Carriere02fd1262020-09-09 18:44:00 +020065};
66
67/**
68 * struct sandbox_scmi_service - Reference to simutaed SCMI agents/services
69 * @agent: Pointer to SCMI sandbox agent pointers array
70 * @agent_count: Number of emulated agents exposed in array @agent.
71 */
72struct sandbox_scmi_service {
73 struct sandbox_scmi_agent **agent;
74 size_t agent_count;
75};
76
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020077/**
78 * struct sandbox_scmi_devices - Reference to devices probed through SCMI
79 * @clk: Array the clock devices
80 * @clk_count: Number of clock devices probed
Etienne Carriere8b9b6892020-09-09 18:44:07 +020081 * @reset: Array the reset controller devices
82 * @reset_count: Number of reset controller devices probed
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010083 * @regul: Array regulator devices
84 * @regul_count: Number of regulator devices probed
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020085 */
86struct sandbox_scmi_devices {
87 struct clk *clk;
88 size_t clk_count;
Etienne Carriere8b9b6892020-09-09 18:44:07 +020089 struct reset_ctl *reset;
90 size_t reset_count;
Etienne Carriereb8f15cd2021-03-08 22:38:07 +010091 struct udevice **regul;
92 size_t regul_count;
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +020093};
94
Etienne Carriere02fd1262020-09-09 18:44:00 +020095#ifdef CONFIG_SCMI_FIRMWARE
96/**
97 * sandbox_scmi_service_context - Get the simulated SCMI services context
98 * @return: Reference to backend simulated resources state
99 */
100struct sandbox_scmi_service *sandbox_scmi_service_ctx(void);
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200101
102/**
103 * sandbox_scmi_devices_get_ref - Get references to devices accessed through SCMI
104 * @dev: Reference to the test device used get test resources
105 * @return: Reference to the devices probed by the SCMI test
106 */
107struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev);
Etienne Carriere02fd1262020-09-09 18:44:00 +0200108#else
109static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx(void)
110{
111 return NULL;
112}
Etienne Carriere2d94c08fa2020-09-09 18:44:05 +0200113
114static inline
115struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
116{
117 return NULL;
118}
Etienne Carriere02fd1262020-09-09 18:44:00 +0200119#endif /* CONFIG_SCMI_FIRMWARE */
120#endif /* __SANDBOX_SCMI_TEST_H */