1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2020, Linaro Limited
11 #include <asm/scmi_test.h>
12 #include <dm/device_compat.h>
15 * Simulate to some extent a SCMI exchange.
16 * This drivers gets SCMI resources and offers API function to the
17 * SCMI test sequence manipulate the resources, currently clocks.
20 #define SCMI_TEST_DEVICES_CLK_COUNT 3
23 * struct sandbox_scmi_device_priv - Storage for device handles used by test
24 * @clk: Array of clock instances used by tests
25 * @devices: Resources exposed by sandbox_scmi_devices_ctx()
27 struct sandbox_scmi_device_priv {
28 struct clk clk[SCMI_TEST_DEVICES_CLK_COUNT];
29 struct sandbox_scmi_devices devices;
32 struct sandbox_scmi_devices *sandbox_scmi_devices_ctx(struct udevice *dev)
34 struct sandbox_scmi_device_priv *priv = dev_get_priv(dev);
37 return &priv->devices;
42 static int sandbox_scmi_devices_probe(struct udevice *dev)
44 struct sandbox_scmi_device_priv *priv = dev_get_priv(dev);
48 priv->devices = (struct sandbox_scmi_devices){
50 .clk_count = SCMI_TEST_DEVICES_CLK_COUNT,
53 for (n = 0; n < SCMI_TEST_DEVICES_CLK_COUNT; n++) {
54 ret = clk_get_by_index(dev, n, priv->devices.clk + n);
56 dev_err(dev, "%s: Failed on clk %zu\n", __func__, n);
64 static const struct udevice_id sandbox_scmi_devices_ids[] = {
65 { .compatible = "sandbox,scmi-devices" },
69 U_BOOT_DRIVER(sandbox_scmi_devices) = {
70 .name = "sandbox-scmi_devices",
72 .of_match = sandbox_scmi_devices_ids,
73 .priv_auto_alloc_size = sizeof(struct sandbox_scmi_device_priv),
74 .probe = sandbox_scmi_devices_probe,