Commit bd9a4c7d authored by Ohad Ben-Cohen's avatar Ohad Ben-Cohen Committed by Tony Lindgren

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
Signed-off-by: default avatarOhad Ben-Cohen <>
Cc: Hari Kanigeri <>
Cc: Benoit Cousson <>
Cc: Kevin Hilman <>
Cc: Grant Likely <>
Cc: Paul Walmsley <>
Cc: Russell King <>
Acked-by: default avatarArnd Bergmann <>
Signed-off-by: default avatarTony Lindgren <>
parent d9e45731
This diff is collapsed.
......@@ -117,4 +117,6 @@ source "drivers/staging/Kconfig"
source "drivers/platform/Kconfig"
source "drivers/clk/Kconfig"
source "drivers/hwspinlock/Kconfig"
......@@ -117,3 +117,5 @@ obj-y += platform/
obj-y += ieee802154/
#common clk code
obj-y += clk/
obj-$(CONFIG_HWSPINLOCK) += hwspinlock/
# Generic HWSPINLOCK framework
tristate "Generic Hardware Spinlock framework"
Say y here to support the generic hardware spinlock framework.
You only need to enable this if you have hardware spinlock module
on your system (usually only relevant if your system has remote slave
If unsure, say N.
# Generic Hardware Spinlock framework
obj-$(CONFIG_HWSPINLOCK) += hwspinlock_core.o
This diff is collapsed.
* Hardware spinlocks internal header
* Copyright (C) 2010 Texas Instruments Incorporated -
* Contact: Ohad Ben-Cohen <>
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* GNU General Public License for more details.
#include <linux/spinlock.h>
#include <linux/device.h>
* struct hwspinlock_ops - platform-specific hwspinlock handlers
* @trylock: make a single attempt to take the lock. returns 0 on
* failure and true on success. may _not_ sleep.
* @unlock: release the lock. always succeed. may _not_ sleep.
* @relax: optional, platform-specific relax handler, called by hwspinlock
* core while spinning on a lock, between two successive
* invocations of @trylock. may _not_ sleep.
struct hwspinlock_ops {
int (*trylock)(struct hwspinlock *lock);
void (*unlock)(struct hwspinlock *lock);
void (*relax)(struct hwspinlock *lock);
* struct hwspinlock - this struct represents a single hwspinlock instance
* @dev: underlying device, will be used to invoke runtime PM api
* @ops: platform-specific hwspinlock handlers
* @id: a global, unique, system-wide, index of the lock.
* @lock: initialized and used by hwspinlock core
* @owner: underlying implementation module, used to maintain module ref count
* Note: currently simplicity was opted for, but later we can squeeze some
* memory bytes by grouping the dev, ops and owner members in a single
* per-platform struct, and have all hwspinlocks point at it.
struct hwspinlock {
struct device *dev;
const struct hwspinlock_ops *ops;
int id;
spinlock_t lock;
struct module *owner;
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment