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 #include <power-domain.h> 10 11 struct udevice; 12 struct sandbox_scmi_agent; 13 struct sandbox_scmi_service; 14 15 /** 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 /** 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 * @perm: Indicating state/parent/rate permission 31 */ 32 struct sandbox_scmi_clk { 33 bool enabled; 34 ulong rate; 35 u32 perm; 36 }; 37 38 /** 39 * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI 40 * @id: Identifier of the reset controller used in the SCMI protocol 41 * @asserted: Reset control state: true if asserted, false if desasserted 42 */ 43 struct sandbox_scmi_reset { 44 uint id; 45 bool asserted; 46 }; 47 48 /** 49 * struct sandbox_scmi_voltd - Simulated voltage regulator exposed by SCMI 50 * @id: Identifier of the voltage domain used in the SCMI protocol 51 * @enabled: Regulator state: true if on, false if off 52 * @voltage_uv: Regulator current voltage in microvoltd (uV) 53 */ 54 struct sandbox_scmi_voltd { 55 uint id; 56 bool enabled; 57 int voltage_uv; 58 }; 59 60 /** 61 * struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent 62 * @pwdom_version: Implemented power domain protocol version 63 * @pwdom_count: Simulated power domains array size 64 * @clk: Simulated clocks 65 * @clk_count: Simulated clocks array size 66 * @reset: Simulated reset domains 67 * @reset_count: Simulated reset domains array size 68 * @voltd: Simulated voltage domains (regulators) 69 * @voltd_count: Simulated voltage domains array size 70 */ 71 struct sandbox_scmi_agent { 72 int pwdom_version; 73 struct sandbox_scmi_pwd *pwdom; 74 size_t pwdom_count; 75 struct sandbox_scmi_clk *clk; 76 size_t clk_count; 77 struct sandbox_scmi_reset *reset; 78 size_t reset_count; 79 struct sandbox_scmi_voltd *voltd; 80 size_t voltd_count; 81 }; 82 83 /** 84 * struct sandbox_scmi_service - Reference to simutaed SCMI agents/services 85 * @agent: Pointer to SCMI sandbox agent or NULL if not probed 86 */ 87 struct sandbox_scmi_service { 88 struct sandbox_scmi_agent *agent; 89 }; 90 91 /** 92 * struct sandbox_scmi_devices - Reference to devices probed through SCMI 93 * @pwdom: Array of power domains 94 * @pwdom_count: Number of power domains probed 95 * @clk: Array the clock devices 96 * @clk_count: Number of clock devices probed 97 * @reset: Array the reset controller devices 98 * @reset_count: Number of reset controller devices probed 99 * @regul: Array regulator devices 100 * @regul_count: Number of regulator devices probed 101 */ 102 struct sandbox_scmi_devices { 103 struct power_domain *pwdom; 104 size_t pwdom_count; 105 struct clk *clk; 106 size_t clk_count; 107 struct reset_ctl *reset; 108 size_t reset_count; 109 struct udevice **regul; 110 size_t regul_count; 111 }; 112 113 #if IS_ENABLED(CONFIG_SCMI_FIRMWARE) 114 /** 115 * sandbox_scmi_channel_id - Get the channel id 116 * @dev: Reference to the SCMI protocol device 117 * 118 * Return: Channel id 119 */ 120 unsigned int sandbox_scmi_channel_id(struct udevice *dev); 121 122 /** 123 * sandbox_scmi_service_ctx - Get the simulated SCMI services context 124 * sandbox_scmi_agent_ctx - Get the simulated SCMI agent context 125 * @dev: Reference to the test agent 126 * @return: Reference to backend simulated resources state 127 */ 128 struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev); 129 130 /** 131 * sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI 132 * @dev: Reference to the test device used get test resources 133 * @return: Reference to the devices probed by the SCMI test 134 */ 135 struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev); 136 #else 137 inline unsigned int sandbox_scmi_channel_id(struct udevice *dev); 138 { 139 return 0; 140 } 141 sandbox_scmi_agent_ctx(struct udevice * dev)142static struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev) 143 { 144 return NULL; 145 } 146 147 static inline sandbox_scmi_devices_ctx(struct udevice * dev)148struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev) 149 { 150 return NULL; 151 } 152 #endif /* CONFIG_SCMI_FIRMWARE */ 153 #endif /* __SANDBOX_SCMI_TEST_H */ 154