Merge tag 'v2022.04-rc4' into next
[platform/kernel/u-boot.git] / arch / sandbox / include / asm / scmi_test.h
1 /* 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
9 struct udevice;
10 struct sandbox_scmi_agent;
11 struct sandbox_scmi_service;
12
13 /**
14  * 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  */
19 struct sandbox_scmi_clk {
20         bool enabled;
21         ulong rate;
22 };
23
24 /**
25  * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI
26  * @id:         Identifier of the reset controller used in the SCMI protocol
27  * @asserted:   Reset control state: true if asserted, false if desasserted
28  */
29 struct sandbox_scmi_reset {
30         uint id;
31         bool asserted;
32 };
33
34 /**
35  * 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  */
40 struct sandbox_scmi_voltd {
41         uint id;
42         bool enabled;
43         int voltage_uv;
44 };
45
46 /**
47  * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent
48  * @clk:        Simulated clocks
49  * @clk_count:  Simulated clocks array size
50  * @reset:      Simulated reset domains
51  * @reset_count: Simulated reset domains array size
52  * @voltd:       Simulated voltage domains (regulators)
53  * @voltd_count: Simulated voltage domains array size
54  */
55 struct sandbox_scmi_agent {
56         struct sandbox_scmi_clk *clk;
57         size_t clk_count;
58         struct sandbox_scmi_reset *reset;
59         size_t reset_count;
60         struct sandbox_scmi_voltd *voltd;
61         size_t voltd_count;
62 };
63
64 /**
65  * struct sandbox_scmi_service - Reference to simutaed SCMI agents/services
66  * @agent:              Pointer to SCMI sandbox agent or NULL if not probed
67  */
68 struct sandbox_scmi_service {
69         struct sandbox_scmi_agent *agent;
70 };
71
72 /**
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
76  * @reset:              Array the reset controller devices
77  * @reset_count:        Number of reset controller devices probed
78  * @regul:              Array regulator devices
79  * @regul_count:        Number of regulator devices probed
80  */
81 struct sandbox_scmi_devices {
82         struct clk *clk;
83         size_t clk_count;
84         struct reset_ctl *reset;
85         size_t reset_count;
86         struct udevice **regul;
87         size_t regul_count;
88 };
89
90 #ifdef CONFIG_SCMI_FIRMWARE
91 /**
92  * sandbox_scmi_service_ctx - Get the simulated SCMI services context
93  * @return:     Reference to backend simulated resources state
94  */
95 struct sandbox_scmi_service *sandbox_scmi_service_ctx(void);
96
97 /**
98  * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI
99  * @dev:        Reference to the test device used get test resources
100  * @return:     Reference to the devices probed by the SCMI test
101  */
102 struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev);
103 #else
104 static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx(void)
105 {
106         return NULL;
107 }
108
109 static inline
110 struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
111 {
112         return NULL;
113 }
114 #endif /* CONFIG_SCMI_FIRMWARE */
115 #endif /* __SANDBOX_SCMI_TEST_H */