Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 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 | /** |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 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 | uint id; |
| 21 | bool enabled; |
| 22 | ulong rate; |
| 23 | }; |
| 24 | |
| 25 | /** |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 26 | * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI |
Etienne Carriere | c83a843 | 2021-03-08 22:38:08 +0100 | [diff] [blame] | 27 | * @id: Identifier of the reset controller used in the SCMI protocol |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 28 | * @asserted: Reset control state: true if asserted, false if desasserted |
| 29 | */ |
| 30 | struct sandbox_scmi_reset { |
| 31 | uint id; |
| 32 | bool asserted; |
| 33 | }; |
| 34 | |
| 35 | /** |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 36 | * 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 | */ |
| 41 | struct sandbox_scmi_voltd { |
| 42 | uint id; |
| 43 | bool enabled; |
| 44 | int voltage_uv; |
| 45 | }; |
| 46 | |
| 47 | /** |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 48 | * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent |
| 49 | * @idx: Identifier for the SCMI agent, its index |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 50 | * @clk: Simulated clocks |
| 51 | * @clk_count: Simulated clocks array size |
Etienne Carriere | c83a843 | 2021-03-08 22:38:08 +0100 | [diff] [blame] | 52 | * @reset: Simulated reset domains |
| 53 | * @reset_count: Simulated reset domains array size |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 54 | * @voltd: Simulated voltage domains (regulators) |
| 55 | * @voltd_count: Simulated voltage domains array size |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 56 | */ |
| 57 | struct sandbox_scmi_agent { |
| 58 | uint idx; |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 59 | struct sandbox_scmi_clk *clk; |
| 60 | size_t clk_count; |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 61 | struct sandbox_scmi_reset *reset; |
| 62 | size_t reset_count; |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 63 | struct sandbox_scmi_voltd *voltd; |
| 64 | size_t voltd_count; |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 65 | }; |
| 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 | */ |
| 72 | struct sandbox_scmi_service { |
| 73 | struct sandbox_scmi_agent **agent; |
| 74 | size_t agent_count; |
| 75 | }; |
| 76 | |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 77 | /** |
| 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 Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 81 | * @reset: Array the reset controller devices |
| 82 | * @reset_count: Number of reset controller devices probed |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 83 | * @regul: Array regulator devices |
| 84 | * @regul_count: Number of regulator devices probed |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 85 | */ |
| 86 | struct sandbox_scmi_devices { |
| 87 | struct clk *clk; |
| 88 | size_t clk_count; |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 89 | struct reset_ctl *reset; |
| 90 | size_t reset_count; |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 91 | struct udevice **regul; |
| 92 | size_t regul_count; |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 93 | }; |
| 94 | |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 95 | #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 | */ |
| 100 | struct sandbox_scmi_service *sandbox_scmi_service_ctx(void); |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 101 | |
| 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 | */ |
| 107 | struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev); |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 108 | #else |
| 109 | static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx(void) |
| 110 | { |
| 111 | return NULL; |
| 112 | } |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 113 | |
| 114 | static inline |
| 115 | struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev) |
| 116 | { |
| 117 | return NULL; |
| 118 | } |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 119 | #endif /* CONFIG_SCMI_FIRMWARE */ |
| 120 | #endif /* __SANDBOX_SCMI_TEST_H */ |