summaryrefslogtreecommitdiff
path: root/drivers/hwspinlock/sandbox_hwspinlock.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-12-07 10:55:12 -0500
committerTom Rini <trini@konsulko.com>2018-12-07 10:55:12 -0500
commit3589025867274ff28f689029ab8323301771c8ec (patch)
treebc8f6b088d9b5ceec8e99602082f4d034800b8ef /drivers/hwspinlock/sandbox_hwspinlock.c
parent57dbc151437b36cc1105857d222df28b095236d7 (diff)
parentfdce9d35dc3671dfc6ce29b4c76e152cc5780869 (diff)
Merge branch '2018-12-06-master-imports'
- Various FAT fixes - Hardware spinlock uclass - DMA uclass - Various am335x fixes - DT resyncs for a number of TI platforms - stm32 updates
Diffstat (limited to 'drivers/hwspinlock/sandbox_hwspinlock.c')
-rw-r--r--drivers/hwspinlock/sandbox_hwspinlock.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/drivers/hwspinlock/sandbox_hwspinlock.c b/drivers/hwspinlock/sandbox_hwspinlock.c
new file mode 100644
index 0000000000..be920f5f99
--- /dev/null
+++ b/drivers/hwspinlock/sandbox_hwspinlock.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
+/*
+ * Copyright (C) 2018, STMicroelectronics - All Rights Reserved
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <hwspinlock.h>
+#include <asm/state.h>
+
+static int sandbox_lock(struct udevice *dev, int index)
+{
+ struct sandbox_state *state = state_get_current();
+
+ if (index != 0)
+ return -1;
+
+ if (state->hwspinlock)
+ return -1;
+
+ state->hwspinlock = true;
+
+ return 0;
+}
+
+static int sandbox_unlock(struct udevice *dev, int index)
+{
+ struct sandbox_state *state = state_get_current();
+
+ if (index != 0)
+ return -1;
+
+ if (!state->hwspinlock)
+ return -1;
+
+ state->hwspinlock = false;
+
+ return 0;
+}
+
+static const struct hwspinlock_ops sandbox_hwspinlock_ops = {
+ .lock = sandbox_lock,
+ .unlock = sandbox_unlock,
+};
+
+static const struct udevice_id sandbox_hwspinlock_ids[] = {
+ { .compatible = "sandbox,hwspinlock" },
+ {}
+};
+
+U_BOOT_DRIVER(hwspinlock_sandbox) = {
+ .name = "hwspinlock_sandbox",
+ .id = UCLASS_HWSPINLOCK,
+ .of_match = sandbox_hwspinlock_ids,
+ .ops = &sandbox_hwspinlock_ops,
+};