u-boot/arch/sandbox/include/asm/scmi_test.h
Etienne Carriere 10d3e5d20b firmware: scmi: fix sandbox and related tests for clock discovery
Updates sandbox SCMI clock driver and tests since enabling CCF will
mandate clock discovery that is all exposed SCMI clocks shall be
discovered at initialization. For this reason, sandbox SCMI clock
driver must emulate all clocks exposed by SCMI server, not only those
effectively consumed by some other U-Boot devices.

Therefore the sandbox SCMI test driver exposes 3 clocks (IDs 0, 1 and 2)
and sandbox SCMI clock consumer driver gets 2 of them.

Cc: Simon Glass <sjg@chromium.org>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
2022-03-02 17:42:06 -05:00

115 lines
3.1 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (C) 2020, Linaro Limited
*/
#ifndef __SANDBOX_SCMI_TEST_H
#define __SANDBOX_SCMI_TEST_H
struct udevice;
struct sandbox_scmi_agent;
struct sandbox_scmi_service;
/**
* struct sandbox_scmi_clk - Simulated clock exposed by SCMI
* @id: Identifier of the clock used in the SCMI protocol
* @enabled: Clock state: true if enabled, false if disabled
* @rate: Clock rate in Hertz
*/
struct sandbox_scmi_clk {
bool enabled;
ulong rate;
};
/**
* struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI
* @id: Identifier of the reset controller used in the SCMI protocol
* @asserted: Reset control state: true if asserted, false if desasserted
*/
struct sandbox_scmi_reset {
uint id;
bool asserted;
};
/**
* struct sandbox_scmi_voltd - Simulated voltage regulator exposed by SCMI
* @id: Identifier of the voltage domain used in the SCMI protocol
* @enabled: Regulator state: true if on, false if off
* @voltage_uv: Regulator current voltage in microvoltd (uV)
*/
struct sandbox_scmi_voltd {
uint id;
bool enabled;
int voltage_uv;
};
/**
* struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent
* @clk: Simulated clocks
* @clk_count: Simulated clocks array size
* @reset: Simulated reset domains
* @reset_count: Simulated reset domains array size
* @voltd: Simulated voltage domains (regulators)
* @voltd_count: Simulated voltage domains array size
*/
struct sandbox_scmi_agent {
struct sandbox_scmi_clk *clk;
size_t clk_count;
struct sandbox_scmi_reset *reset;
size_t reset_count;
struct sandbox_scmi_voltd *voltd;
size_t voltd_count;
};
/**
* struct sandbox_scmi_service - Reference to simutaed SCMI agents/services
* @agent: Pointer to SCMI sandbox agent or NULL if not probed
*/
struct sandbox_scmi_service {
struct sandbox_scmi_agent *agent;
};
/**
* struct sandbox_scmi_devices - Reference to devices probed through SCMI
* @clk: Array the clock devices
* @clk_count: Number of clock devices probed
* @reset: Array the reset controller devices
* @reset_count: Number of reset controller devices probed
* @regul: Array regulator devices
* @regul_count: Number of regulator devices probed
*/
struct sandbox_scmi_devices {
struct clk *clk;
size_t clk_count;
struct reset_ctl *reset;
size_t reset_count;
struct udevice **regul;
size_t regul_count;
};
#ifdef CONFIG_SCMI_FIRMWARE
/**
* sandbox_scmi_service_ctx - Get the simulated SCMI services context
* @return: Reference to backend simulated resources state
*/
struct sandbox_scmi_service *sandbox_scmi_service_ctx(void);
/**
* sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI
* @dev: Reference to the test device used get test resources
* @return: Reference to the devices probed by the SCMI test
*/
struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev);
#else
static inline struct sandbox_scmi_service *sandbox_scmi_service_ctx(void)
{
return NULL;
}
static inline
struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
{
return NULL;
}
#endif /* CONFIG_SCMI_FIRMWARE */
#endif /* __SANDBOX_SCMI_TEST_H */