aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwspinlock/hwspinlock_internal.h
diff options
context:
space:
mode:
authorOhad Ben-Cohen <ohad@wizery.com>2011-02-17 12:52:03 -0500
committerTony Lindgren <tony@atomide.com>2011-02-17 12:52:03 -0500
commitbd9a4c7df256cee4e9f6a4b56baa3b89d63f0f1e (patch)
treeee6ca0aaebd8e553576a0cf3fefafa1cd3ec8e1d /drivers/hwspinlock/hwspinlock_internal.h
parentd9e45731debd83e2b249be349993595907dddeae (diff)
drivers: hwspinlock: add framework
Add a platform-independent hwspinlock framework. Hardware spinlock devices are needed, e.g., in order to access data that is shared between remote processors, that otherwise have no alternative mechanism to accomplish synchronization and mutual exclusion operations. Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com> Cc: Hari Kanigeri <h-kanigeri2@ti.com> Cc: Benoit Cousson <b-cousson@ti.com> Cc: Kevin Hilman <khilman@ti.com> Cc: Grant Likely <grant.likely@secretlab.ca> Cc: Paul Walmsley <paul@pwsan.com> Cc: Russell King <linux@arm.linux.org.uk> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'drivers/hwspinlock/hwspinlock_internal.h')
-rw-r--r--drivers/hwspinlock/hwspinlock_internal.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/hwspinlock/hwspinlock_internal.h b/drivers/hwspinlock/hwspinlock_internal.h
new file mode 100644
index 000000000000..69935e6b93e5
--- /dev/null
+++ b/drivers/hwspinlock/hwspinlock_internal.h
@@ -0,0 +1,61 @@
1/*
2 * Hardware spinlocks internal header
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
5 *
6 * Contact: Ohad Ben-Cohen <ohad@wizery.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 */
17
18#ifndef __HWSPINLOCK_HWSPINLOCK_H
19#define __HWSPINLOCK_HWSPINLOCK_H
20
21#include <linux/spinlock.h>
22#include <linux/device.h>
23
24/**
25 * struct hwspinlock_ops - platform-specific hwspinlock handlers
26 *
27 * @trylock: make a single attempt to take the lock. returns 0 on
28 * failure and true on success. may _not_ sleep.
29 * @unlock: release the lock. always succeed. may _not_ sleep.
30 * @relax: optional, platform-specific relax handler, called by hwspinlock
31 * core while spinning on a lock, between two successive
32 * invocations of @trylock. may _not_ sleep.
33 */
34struct hwspinlock_ops {
35 int (*trylock)(struct hwspinlock *lock);
36 void (*unlock)(struct hwspinlock *lock);
37 void (*relax)(struct hwspinlock *lock);
38};
39
40/**
41 * struct hwspinlock - this struct represents a single hwspinlock instance
42 *
43 * @dev: underlying device, will be used to invoke runtime PM api
44 * @ops: platform-specific hwspinlock handlers
45 * @id: a global, unique, system-wide, index of the lock.
46 * @lock: initialized and used by hwspinlock core
47 * @owner: underlying implementation module, used to maintain module ref count
48 *
49 * Note: currently simplicity was opted for, but later we can squeeze some
50 * memory bytes by grouping the dev, ops and owner members in a single
51 * per-platform struct, and have all hwspinlocks point at it.
52 */
53struct hwspinlock {
54 struct device *dev;
55 const struct hwspinlock_ops *ops;
56 int id;
57 spinlock_t lock;
58 struct module *owner;
59};
60
61#endif /* __HWSPINLOCK_HWSPINLOCK_H */