1 // SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
3 * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
8 #include <hwspinlock.h>
11 static int sandbox_lock(struct udevice *dev, int index)
13 struct sandbox_state *state = state_get_current();
18 if (state->hwspinlock)
21 state->hwspinlock = true;
26 static int sandbox_unlock(struct udevice *dev, int index)
28 struct sandbox_state *state = state_get_current();
33 if (!state->hwspinlock)
36 state->hwspinlock = false;
41 static const struct hwspinlock_ops sandbox_hwspinlock_ops = {
43 .unlock = sandbox_unlock,
46 static const struct udevice_id sandbox_hwspinlock_ids[] = {
47 { .compatible = "sandbox,hwspinlock" },
51 U_BOOT_DRIVER(hwspinlock_sandbox) = {
52 .name = "hwspinlock_sandbox",
53 .id = UCLASS_HWSPINLOCK,
54 .of_match = sandbox_hwspinlock_ids,
55 .ops = &sandbox_hwspinlock_ops,