2020-09-09 16:44:00 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2020, Linaro Limited
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SANDBOX_SCMI_TEST_H
|
|
|
|
#define __SANDBOX_SCMI_TEST_H
|
|
|
|
|
2023-10-16 05:39:45 +00:00
|
|
|
#include <power-domain.h>
|
|
|
|
|
2020-09-09 16:44:00 +00:00
|
|
|
struct udevice;
|
|
|
|
struct sandbox_scmi_agent;
|
|
|
|
struct sandbox_scmi_service;
|
|
|
|
|
2023-10-16 05:39:45 +00:00
|
|
|
/**
|
|
|
|
* struct sandbox_scmi_pwd
|
|
|
|
* @id: Identifier of the power domain used in the SCMI protocol
|
|
|
|
* @pstate:: Power state of the domain
|
|
|
|
*/
|
|
|
|
struct sandbox_scmi_pwd {
|
|
|
|
uint id;
|
|
|
|
u32 pstate;
|
|
|
|
};
|
|
|
|
|
2020-09-09 16:44:05 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
};
|
|
|
|
|
2020-09-09 16:44:07 +00:00
|
|
|
/**
|
|
|
|
* struct sandbox_scmi_reset - Simulated reset controller exposed by SCMI
|
2021-03-08 21:38:08 +00:00
|
|
|
* @id: Identifier of the reset controller used in the SCMI protocol
|
2020-09-09 16:44:07 +00:00
|
|
|
* @asserted: Reset control state: true if asserted, false if desasserted
|
|
|
|
*/
|
|
|
|
struct sandbox_scmi_reset {
|
|
|
|
uint id;
|
|
|
|
bool asserted;
|
|
|
|
};
|
|
|
|
|
2021-03-08 21:38:07 +00:00
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
};
|
|
|
|
|
2020-09-09 16:44:00 +00:00
|
|
|
/**
|
|
|
|
* struct sandbox_scmi_agent - Simulated SCMI service seen by SCMI agent
|
2023-10-16 05:39:45 +00:00
|
|
|
* @pwdom_version: Implemented power domain protocol version
|
|
|
|
* @pwdom_count: Simulated power domains array size
|
2020-09-09 16:44:05 +00:00
|
|
|
* @clk: Simulated clocks
|
|
|
|
* @clk_count: Simulated clocks array size
|
2021-03-08 21:38:08 +00:00
|
|
|
* @reset: Simulated reset domains
|
|
|
|
* @reset_count: Simulated reset domains array size
|
2021-03-08 21:38:07 +00:00
|
|
|
* @voltd: Simulated voltage domains (regulators)
|
|
|
|
* @voltd_count: Simulated voltage domains array size
|
2020-09-09 16:44:00 +00:00
|
|
|
*/
|
|
|
|
struct sandbox_scmi_agent {
|
2023-10-16 05:39:45 +00:00
|
|
|
int pwdom_version;
|
|
|
|
struct sandbox_scmi_pwd *pwdom;
|
|
|
|
size_t pwdom_count;
|
2020-09-09 16:44:05 +00:00
|
|
|
struct sandbox_scmi_clk *clk;
|
|
|
|
size_t clk_count;
|
2020-09-09 16:44:07 +00:00
|
|
|
struct sandbox_scmi_reset *reset;
|
|
|
|
size_t reset_count;
|
2021-03-08 21:38:07 +00:00
|
|
|
struct sandbox_scmi_voltd *voltd;
|
|
|
|
size_t voltd_count;
|
2020-09-09 16:44:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct sandbox_scmi_service - Reference to simutaed SCMI agents/services
|
2022-02-21 08:22:39 +00:00
|
|
|
* @agent: Pointer to SCMI sandbox agent or NULL if not probed
|
2020-09-09 16:44:00 +00:00
|
|
|
*/
|
|
|
|
struct sandbox_scmi_service {
|
2022-02-21 08:22:39 +00:00
|
|
|
struct sandbox_scmi_agent *agent;
|
2020-09-09 16:44:00 +00:00
|
|
|
};
|
|
|
|
|
2020-09-09 16:44:05 +00:00
|
|
|
/**
|
|
|
|
* struct sandbox_scmi_devices - Reference to devices probed through SCMI
|
2023-10-16 05:39:45 +00:00
|
|
|
* @pwdom: Array of power domains
|
|
|
|
* @pwdom_count: Number of power domains probed
|
2020-09-09 16:44:05 +00:00
|
|
|
* @clk: Array the clock devices
|
|
|
|
* @clk_count: Number of clock devices probed
|
2020-09-09 16:44:07 +00:00
|
|
|
* @reset: Array the reset controller devices
|
|
|
|
* @reset_count: Number of reset controller devices probed
|
2021-03-08 21:38:07 +00:00
|
|
|
* @regul: Array regulator devices
|
|
|
|
* @regul_count: Number of regulator devices probed
|
2020-09-09 16:44:05 +00:00
|
|
|
*/
|
|
|
|
struct sandbox_scmi_devices {
|
2023-10-16 05:39:45 +00:00
|
|
|
struct power_domain *pwdom;
|
|
|
|
size_t pwdom_count;
|
2020-09-09 16:44:05 +00:00
|
|
|
struct clk *clk;
|
|
|
|
size_t clk_count;
|
2020-09-09 16:44:07 +00:00
|
|
|
struct reset_ctl *reset;
|
|
|
|
size_t reset_count;
|
2021-03-08 21:38:07 +00:00
|
|
|
struct udevice **regul;
|
|
|
|
size_t regul_count;
|
2020-09-09 16:44:05 +00:00
|
|
|
};
|
|
|
|
|
2020-09-09 16:44:00 +00:00
|
|
|
#ifdef CONFIG_SCMI_FIRMWARE
|
2023-10-11 10:06:56 +00:00
|
|
|
/**
|
|
|
|
* sandbox_scmi_channel_id - Get the channel id
|
|
|
|
* @dev: Reference to the SCMI protocol device
|
|
|
|
*
|
|
|
|
* Return: Channel id
|
|
|
|
*/
|
|
|
|
unsigned int sandbox_scmi_channel_id(struct udevice *dev);
|
|
|
|
|
2020-09-09 16:44:00 +00:00
|
|
|
/**
|
2022-02-21 08:22:39 +00:00
|
|
|
* sandbox_scmi_service_ctx - Get the simulated SCMI services context
|
2023-10-11 10:07:03 +00:00
|
|
|
* sandbox_scmi_agent_ctx - Get the simulated SCMI agent context
|
|
|
|
* @dev: Reference to the test agent
|
2020-09-09 16:44:00 +00:00
|
|
|
* @return: Reference to backend simulated resources state
|
|
|
|
*/
|
2023-10-11 10:07:03 +00:00
|
|
|
struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev);
|
2020-09-09 16:44:05 +00:00
|
|
|
|
|
|
|
/**
|
2022-02-21 08:22:39 +00:00
|
|
|
* sandbox_scmi_devices_ctx - Get references to devices accessed through SCMI
|
2020-09-09 16:44:05 +00:00
|
|
|
* @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);
|
2020-09-09 16:44:00 +00:00
|
|
|
#else
|
2023-10-11 10:06:56 +00:00
|
|
|
inline unsigned int sandbox_scmi_channel_id(struct udevice *dev);
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-10-11 10:07:03 +00:00
|
|
|
static struct sandbox_scmi_agent *sandbox_scmi_agent_ctx(struct udevice *dev)
|
2020-09-09 16:44:00 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-09-09 16:44:05 +00:00
|
|
|
|
|
|
|
static inline
|
|
|
|
struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-09-09 16:44:00 +00:00
|
|
|
#endif /* CONFIG_SCMI_FIRMWARE */
|
|
|
|
#endif /* __SANDBOX_SCMI_TEST_H */
|