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 uint id; 21 bool enabled; 22 ulong rate; 23 }; 24 25 /** 26 * struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI 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_agent - Simulated SCMI service seen by SCMI agent 36 * @idx: Identifier for the SCMI agent, its index 37 * @clk: Simulated clocks 38 * @clk_count: Simulated clocks array size 39 * @clk: Simulated reset domains 40 * @clk_count: Simulated reset domains array size 41 */ 42 struct sandbox_scmi_agent { 43 uint idx; 44 struct sandbox_scmi_clk *clk; 45 size_t clk_count; 46 struct sandbox_scmi_reset *reset; 47 size_t reset_count; 48 }; 49 50 /** 51 * struct sandbox_scmi_service - Reference to simutaed SCMI agents/services 52 * @agent: Pointer to SCMI sandbox agent pointers array 53 * @agent_count: Number of emulated agents exposed in array @agent. 54 */ 55 struct sandbox_scmi_service { 56 struct sandbox_scmi_agent **agent; 57 size_t agent_count; 58 }; 59 60 /** 61 * struct sandbox_scmi_devices - Reference to devices probed through SCMI 62 * @clk: Array the clock devices 63 * @clk_count: Number of clock devices probed 64 * @reset: Array the reset controller devices 65 * @reset_count: Number of reset controller devices probed 66 */ 67 struct sandbox_scmi_devices { 68 struct clk *clk; 69 size_t clk_count; 70 struct reset_ctl *reset; 71 size_t reset_count; 72 }; 73 74 #ifdef CONFIG_SCMI_FIRMWARE 75 /** 76 * sandbox_scmi_service_context - Get the simulated SCMI services context 77 * @return: Reference to backend simulated resources state 78 */ 79 struct sandbox_scmi_service *sandbox_scmi_service_ctx(void); 80 81 /** 82 * sandbox_scmi_devices_get_ref - Get references to devices accessed through SCMI 83 * @dev: Reference to the test device used get test resources 84 * @return: Reference to the devices probed by the SCMI test 85 */ 86 struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev); 87 #else sandbox_scmi_service_ctx(void)88static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx(void) 89 { 90 return NULL; 91 } 92 93 static inline sandbox_scmi_devices_ctx(struct udevice * dev)94struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev) 95 { 96 return NULL; 97 } 98 #endif /* CONFIG_SCMI_FIRMWARE */ 99 #endif /* __SANDBOX_SCMI_TEST_H */ 100