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 | |
AKASHI Takahiro | 535a7bd | 2023-10-16 14:39:45 +0900 | [diff] [blame] | 9 | #include <power-domain.h> |
| 10 | |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 11 | struct udevice; |
| 12 | struct sandbox_scmi_agent; |
| 13 | struct sandbox_scmi_service; |
| 14 | |
| 15 | /** |
AKASHI Takahiro | 535a7bd | 2023-10-16 14:39:45 +0900 | [diff] [blame] | 16 | * struct sandbox_scmi_pwd |
| 17 | * @id: Identifier of the power domain used in the SCMI protocol |
| 18 | * @pstate:: Power state of the domain |
| 19 | */ |
| 20 | struct sandbox_scmi_pwd { |
| 21 | uint id; |
| 22 | u32 pstate; |
| 23 | }; |
| 24 | |
| 25 | /** |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 26 | * struct sandbox_scmi_clk - Simulated clock exposed by SCMI |
| 27 | * @id: Identifier of the clock used in the SCMI protocol |
| 28 | * @enabled: Clock state: true if enabled, false if disabled |
| 29 | * @rate: Clock rate in Hertz |
| 30 | */ |
| 31 | struct sandbox_scmi_clk { |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 32 | bool enabled; |
| 33 | ulong rate; |
| 34 | }; |
| 35 | |
| 36 | /** |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 37 | * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI |
Etienne Carriere | c83a843 | 2021-03-08 22:38:08 +0100 | [diff] [blame] | 38 | * @id: Identifier of the reset controller used in the SCMI protocol |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 39 | * @asserted: Reset control state: true if asserted, false if desasserted |
| 40 | */ |
| 41 | struct sandbox_scmi_reset { |
| 42 | uint id; |
| 43 | bool asserted; |
| 44 | }; |
| 45 | |
| 46 | /** |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 47 | * struct sandbox_scmi_voltd - Simulated voltage regulator exposed by SCMI |
| 48 | * @id: Identifier of the voltage domain used in the SCMI protocol |
| 49 | * @enabled: Regulator state: true if on, false if off |
| 50 | * @voltage_uv: Regulator current voltage in microvoltd (uV) |
| 51 | */ |
| 52 | struct sandbox_scmi_voltd { |
| 53 | uint id; |
| 54 | bool enabled; |
| 55 | int voltage_uv; |
| 56 | }; |
| 57 | |
| 58 | /** |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 59 | * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent |
AKASHI Takahiro | 535a7bd | 2023-10-16 14:39:45 +0900 | [diff] [blame] | 60 | * @pwdom_version: Implemented power domain protocol version |
| 61 | * @pwdom_count: Simulated power domains array size |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 62 | * @clk: Simulated clocks |
| 63 | * @clk_count: Simulated clocks array size |
Etienne Carriere | c83a843 | 2021-03-08 22:38:08 +0100 | [diff] [blame] | 64 | * @reset: Simulated reset domains |
| 65 | * @reset_count: Simulated reset domains array size |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 66 | * @voltd: Simulated voltage domains (regulators) |
| 67 | * @voltd_count: Simulated voltage domains array size |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 68 | */ |
| 69 | struct sandbox_scmi_agent { |
AKASHI Takahiro | 535a7bd | 2023-10-16 14:39:45 +0900 | [diff] [blame] | 70 | int pwdom_version; |
| 71 | struct sandbox_scmi_pwd *pwdom; |
| 72 | size_t pwdom_count; |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 73 | struct sandbox_scmi_clk *clk; |
| 74 | size_t clk_count; |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 75 | struct sandbox_scmi_reset *reset; |
| 76 | size_t reset_count; |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 77 | struct sandbox_scmi_voltd *voltd; |
| 78 | size_t voltd_count; |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | /** |
| 82 | * struct sandbox_scmi_service - Reference to simutaed SCMI agents/services |
Etienne Carriere | 09665cb | 2022-02-21 09:22:39 +0100 | [diff] [blame] | 83 | * @agent: Pointer to SCMI sandbox agent or NULL if not probed |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 84 | */ |
| 85 | struct sandbox_scmi_service { |
Etienne Carriere | 09665cb | 2022-02-21 09:22:39 +0100 | [diff] [blame] | 86 | struct sandbox_scmi_agent *agent; |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 87 | }; |
| 88 | |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 89 | /** |
| 90 | * struct sandbox_scmi_devices - Reference to devices probed through SCMI |
AKASHI Takahiro | 535a7bd | 2023-10-16 14:39:45 +0900 | [diff] [blame] | 91 | * @pwdom: Array of power domains |
| 92 | * @pwdom_count: Number of power domains probed |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 93 | * @clk: Array the clock devices |
| 94 | * @clk_count: Number of clock devices probed |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 95 | * @reset: Array the reset controller devices |
| 96 | * @reset_count: Number of reset controller devices probed |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 97 | * @regul: Array regulator devices |
| 98 | * @regul_count: Number of regulator devices probed |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 99 | */ |
| 100 | struct sandbox_scmi_devices { |
AKASHI Takahiro | 535a7bd | 2023-10-16 14:39:45 +0900 | [diff] [blame] | 101 | struct power_domain *pwdom; |
| 102 | size_t pwdom_count; |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 103 | struct clk *clk; |
| 104 | size_t clk_count; |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 105 | struct reset_ctl *reset; |
| 106 | size_t reset_count; |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 107 | struct udevice **regul; |
| 108 | size_t regul_count; |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 109 | }; |
| 110 | |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 111 | #ifdef CONFIG_SCMI_FIRMWARE |
| 112 | /** |
AKASHI Takahiro | 6221bf7 | 2023-10-11 19:06:56 +0900 | [diff] [blame] | 113 | * sandbox_scmi_channel_id - Get the channel id |
| 114 | * @dev: Reference to the SCMI protocol device |
| 115 | * |
| 116 | * Return: Channel id |
| 117 | */ |
| 118 | unsigned int sandbox_scmi_channel_id(struct udevice *dev); |
| 119 | |
| 120 | /** |
Etienne Carriere | 09665cb | 2022-02-21 09:22:39 +0100 | [diff] [blame] | 121 | * sandbox_scmi_service_ctx - Get the simulated SCMI services context |
AKASHI Takahiro | dae0046 | 2023-10-11 19:07:03 +0900 | [diff] [blame] | 122 | * sandbox_scmi_agent_ctx - Get the simulated SCMI agent context |
| 123 | * @dev: Reference to the test agent |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 124 | * @return: Reference to backend simulated resources state |
| 125 | */ |
AKASHI Takahiro | dae0046 | 2023-10-11 19:07:03 +0900 | [diff] [blame] | 126 | struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev); |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 127 | |
| 128 | /** |
Etienne Carriere | 09665cb | 2022-02-21 09:22:39 +0100 | [diff] [blame] | 129 | * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 130 | * @dev: Reference to the test device used get test resources |
| 131 | * @return: Reference to the devices probed by the SCMI test |
| 132 | */ |
| 133 | struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev); |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 134 | #else |
AKASHI Takahiro | 6221bf7 | 2023-10-11 19:06:56 +0900 | [diff] [blame] | 135 | inline unsigned int sandbox_scmi_channel_id(struct udevice *dev); |
| 136 | { |
| 137 | return 0; |
| 138 | } |
| 139 | |
AKASHI Takahiro | dae0046 | 2023-10-11 19:07:03 +0900 | [diff] [blame] | 140 | static struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev) |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 141 | { |
| 142 | return NULL; |
| 143 | } |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 144 | |
| 145 | static inline |
| 146 | struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev) |
| 147 | { |
| 148 | return NULL; |
| 149 | } |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 150 | #endif /* CONFIG_SCMI_FIRMWARE */ |
| 151 | #endif /* __SANDBOX_SCMI_TEST_H */ |