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 { |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 20 | bool enabled; |
| 21 | ulong rate; |
| 22 | }; |
| 23 | |
| 24 | /** |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 25 | * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI |
Etienne Carriere | c83a843 | 2021-03-08 22:38:08 +0100 | [diff] [blame] | 26 | * @id: Identifier of the reset controller used in the SCMI protocol |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 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 | /** |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 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 | /** |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 47 | * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 48 | * @clk: Simulated clocks |
| 49 | * @clk_count: Simulated clocks array size |
Etienne Carriere | c83a843 | 2021-03-08 22:38:08 +0100 | [diff] [blame] | 50 | * @reset: Simulated reset domains |
| 51 | * @reset_count: Simulated reset domains array size |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 52 | * @voltd: Simulated voltage domains (regulators) |
| 53 | * @voltd_count: Simulated voltage domains array size |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 54 | */ |
| 55 | struct sandbox_scmi_agent { |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 56 | struct sandbox_scmi_clk *clk; |
| 57 | size_t clk_count; |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 58 | struct sandbox_scmi_reset *reset; |
| 59 | size_t reset_count; |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 60 | struct sandbox_scmi_voltd *voltd; |
| 61 | size_t voltd_count; |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | /** |
| 65 | * struct sandbox_scmi_service - Reference to simutaed SCMI agents/services |
Etienne Carriere | 09665cb | 2022-02-21 09:22:39 +0100 | [diff] [blame] | 66 | * @agent: Pointer to SCMI sandbox agent or NULL if not probed |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 67 | */ |
| 68 | struct sandbox_scmi_service { |
Etienne Carriere | 09665cb | 2022-02-21 09:22:39 +0100 | [diff] [blame] | 69 | struct sandbox_scmi_agent *agent; |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 70 | }; |
| 71 | |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 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 |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 76 | * @reset: Array the reset controller devices |
| 77 | * @reset_count: Number of reset controller devices probed |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 78 | * @regul: Array regulator devices |
| 79 | * @regul_count: Number of regulator devices probed |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 80 | */ |
| 81 | struct sandbox_scmi_devices { |
| 82 | struct clk *clk; |
| 83 | size_t clk_count; |
Etienne Carriere | 8b9b689 | 2020-09-09 18:44:07 +0200 | [diff] [blame] | 84 | struct reset_ctl *reset; |
| 85 | size_t reset_count; |
Etienne Carriere | b8f15cd | 2021-03-08 22:38:07 +0100 | [diff] [blame] | 86 | struct udevice **regul; |
| 87 | size_t regul_count; |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 88 | }; |
| 89 | |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 90 | #ifdef CONFIG_SCMI_FIRMWARE |
| 91 | /** |
AKASHI Takahiro | 6221bf7 | 2023-10-11 19:06:56 +0900 | [diff] [blame] | 92 | * sandbox_scmi_channel_id - Get the channel id |
| 93 | * @dev: Reference to the SCMI protocol device |
| 94 | * |
| 95 | * Return: Channel id |
| 96 | */ |
| 97 | unsigned int sandbox_scmi_channel_id(struct udevice *dev); |
| 98 | |
| 99 | /** |
Etienne Carriere | 09665cb | 2022-02-21 09:22:39 +0100 | [diff] [blame] | 100 | * sandbox_scmi_service_ctx - Get the simulated SCMI services context |
AKASHI Takahiro | dae0046 | 2023-10-11 19:07:03 +0900 | [diff] [blame] | 101 | * sandbox_scmi_agent_ctx - Get the simulated SCMI agent context |
| 102 | * @dev: Reference to the test agent |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 103 | * @return: Reference to backend simulated resources state |
| 104 | */ |
AKASHI Takahiro | dae0046 | 2023-10-11 19:07:03 +0900 | [diff] [blame] | 105 | struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev); |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 106 | |
| 107 | /** |
Etienne Carriere | 09665cb | 2022-02-21 09:22:39 +0100 | [diff] [blame] | 108 | * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 109 | * @dev: Reference to the test device used get test resources |
| 110 | * @return: Reference to the devices probed by the SCMI test |
| 111 | */ |
| 112 | struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev); |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 113 | #else |
AKASHI Takahiro | 6221bf7 | 2023-10-11 19:06:56 +0900 | [diff] [blame] | 114 | inline unsigned int sandbox_scmi_channel_id(struct udevice *dev); |
| 115 | { |
| 116 | return 0; |
| 117 | } |
| 118 | |
AKASHI Takahiro | dae0046 | 2023-10-11 19:07:03 +0900 | [diff] [blame] | 119 | static struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev) |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 120 | { |
| 121 | return NULL; |
| 122 | } |
Etienne Carriere | 2d94c08fa | 2020-09-09 18:44:05 +0200 | [diff] [blame] | 123 | |
| 124 | static inline |
| 125 | struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev) |
| 126 | { |
| 127 | return NULL; |
| 128 | } |
Etienne Carriere | 02fd126 | 2020-09-09 18:44:00 +0200 | [diff] [blame] | 129 | #endif /* CONFIG_SCMI_FIRMWARE */ |
| 130 | #endif /* __SANDBOX_SCMI_TEST_H */ |