diff options
| -rw-r--r-- | Documentation/hwspinlock.txt | 74 | ||||
| -rw-r--r-- | MAINTAINERS | 14 | ||||
| -rw-r--r-- | arch/arm/mach-omap2/hwspinlock.c | 9 | ||||
| -rw-r--r-- | drivers/hwspinlock/Kconfig | 27 | ||||
| -rw-r--r-- | drivers/hwspinlock/Makefile | 1 | ||||
| -rw-r--r-- | drivers/hwspinlock/hwspinlock_core.c | 204 | ||||
| -rw-r--r-- | drivers/hwspinlock/hwspinlock_internal.h | 40 | ||||
| -rw-r--r-- | drivers/hwspinlock/omap_hwspinlock.c | 127 | ||||
| -rw-r--r-- | drivers/hwspinlock/u8500_hsem.c | 198 | ||||
| -rw-r--r-- | drivers/mmc/host/omap_hsmmc.c | 2 | ||||
| -rw-r--r-- | include/linux/hwspinlock.h | 46 |
11 files changed, 516 insertions, 226 deletions
diff --git a/Documentation/hwspinlock.txt b/Documentation/hwspinlock.txt index 7dcd1a4e726c..a903ee5e9776 100644 --- a/Documentation/hwspinlock.txt +++ b/Documentation/hwspinlock.txt | |||
| @@ -39,23 +39,20 @@ independent, drivers. | |||
| 39 | in case an unused hwspinlock isn't available. Users of this | 39 | in case an unused hwspinlock isn't available. Users of this |
| 40 | API will usually want to communicate the lock's id to the remote core | 40 | API will usually want to communicate the lock's id to the remote core |
| 41 | before it can be used to achieve synchronization. | 41 | before it can be used to achieve synchronization. |
| 42 | Can be called from an atomic context (this function will not sleep) but | 42 | Should be called from a process context (might sleep). |
| 43 | not from within interrupt context. | ||
| 44 | 43 | ||
| 45 | struct hwspinlock *hwspin_lock_request_specific(unsigned int id); | 44 | struct hwspinlock *hwspin_lock_request_specific(unsigned int id); |
| 46 | - assign a specific hwspinlock id and return its address, or NULL | 45 | - assign a specific hwspinlock id and return its address, or NULL |
| 47 | if that hwspinlock is already in use. Usually board code will | 46 | if that hwspinlock is already in use. Usually board code will |
| 48 | be calling this function in order to reserve specific hwspinlock | 47 | be calling this function in order to reserve specific hwspinlock |
| 49 | ids for predefined purposes. | 48 | ids for predefined purposes. |
| 50 | Can be called from an atomic context (this function will not sleep) but | 49 | Should be called from a process context (might sleep). |
| 51 | not from within interrupt context. | ||
| 52 | 50 | ||
| 53 | int hwspin_lock_free(struct hwspinlock *hwlock); | 51 | int hwspin_lock_free(struct hwspinlock *hwlock); |
| 54 | - free a previously-assigned hwspinlock; returns 0 on success, or an | 52 | - free a previously-assigned hwspinlock; returns 0 on success, or an |
| 55 | appropriate error code on failure (e.g. -EINVAL if the hwspinlock | 53 | appropriate error code on failure (e.g. -EINVAL if the hwspinlock |
| 56 | is already free). | 54 | is already free). |
| 57 | Can be called from an atomic context (this function will not sleep) but | 55 | Should be called from a process context (might sleep). |
| 58 | not from within interrupt context. | ||
| 59 | 56 | ||
| 60 | int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int timeout); | 57 | int hwspin_lock_timeout(struct hwspinlock *hwlock, unsigned int timeout); |
| 61 | - lock a previously-assigned hwspinlock with a timeout limit (specified in | 58 | - lock a previously-assigned hwspinlock with a timeout limit (specified in |
| @@ -230,45 +227,62 @@ int hwspinlock_example2(void) | |||
| 230 | 227 | ||
| 231 | 4. API for implementors | 228 | 4. API for implementors |
| 232 | 229 | ||
| 233 | int hwspin_lock_register(struct hwspinlock *hwlock); | 230 | int hwspin_lock_register(struct hwspinlock_device *bank, struct device *dev, |
| 231 | const struct hwspinlock_ops *ops, int base_id, int num_locks); | ||
| 234 | - to be called from the underlying platform-specific implementation, in | 232 | - to be called from the underlying platform-specific implementation, in |
| 235 | order to register a new hwspinlock instance. Can be called from an atomic | 233 | order to register a new hwspinlock device (which is usually a bank of |
| 236 | context (this function will not sleep) but not from within interrupt | 234 | numerous locks). Should be called from a process context (this function |
| 237 | context. Returns 0 on success, or appropriate error code on failure. | 235 | might sleep). |
| 236 | Returns 0 on success, or appropriate error code on failure. | ||
| 238 | 237 | ||
| 239 | struct hwspinlock *hwspin_lock_unregister(unsigned int id); | 238 | int hwspin_lock_unregister(struct hwspinlock_device *bank); |
| 240 | - to be called from the underlying vendor-specific implementation, in order | 239 | - to be called from the underlying vendor-specific implementation, in order |
| 241 | to unregister an existing (and unused) hwspinlock instance. | 240 | to unregister an hwspinlock device (which is usually a bank of numerous |
| 242 | Can be called from an atomic context (will not sleep) but not from | 241 | locks). |
| 243 | within interrupt context. | 242 | Should be called from a process context (this function might sleep). |
| 244 | Returns the address of hwspinlock on success, or NULL on error (e.g. | 243 | Returns the address of hwspinlock on success, or NULL on error (e.g. |
| 245 | if the hwspinlock is sill in use). | 244 | if the hwspinlock is sill in use). |
| 246 | 245 | ||
| 247 | 5. struct hwspinlock | 246 | 5. Important structs |
| 248 | 247 | ||
| 249 | This struct represents an hwspinlock instance. It is registered by the | 248 | struct hwspinlock_device is a device which usually contains a bank |
| 250 | underlying hwspinlock implementation using the hwspin_lock_register() API. | 249 | of hardware locks. It is registered by the underlying hwspinlock |
| 250 | implementation using the hwspin_lock_register() API. | ||
| 251 | 251 | ||
| 252 | /** | 252 | /** |
| 253 | * struct hwspinlock - vendor-specific hwspinlock implementation | 253 | * struct hwspinlock_device - a device which usually spans numerous hwspinlocks |
| 254 | * | 254 | * @dev: underlying device, will be used to invoke runtime PM api |
| 255 | * @dev: underlying device, will be used with runtime PM api | 255 | * @ops: platform-specific hwspinlock handlers |
| 256 | * @ops: vendor-specific hwspinlock handlers | 256 | * @base_id: id index of the first lock in this device |
| 257 | * @id: a global, unique, system-wide, index of the lock. | 257 | * @num_locks: number of locks in this device |
| 258 | * @lock: initialized and used by hwspinlock core | 258 | * @lock: dynamically allocated array of 'struct hwspinlock' |
| 259 | * @owner: underlying implementation module, used to maintain module ref count | ||
| 260 | */ | 259 | */ |
| 261 | struct hwspinlock { | 260 | struct hwspinlock_device { |
| 262 | struct device *dev; | 261 | struct device *dev; |
| 263 | const struct hwspinlock_ops *ops; | 262 | const struct hwspinlock_ops *ops; |
| 264 | int id; | 263 | int base_id; |
| 264 | int num_locks; | ||
| 265 | struct hwspinlock lock[0]; | ||
| 266 | }; | ||
| 267 | |||
| 268 | struct hwspinlock_device contains an array of hwspinlock structs, each | ||
| 269 | of which represents a single hardware lock: | ||
| 270 | |||
| 271 | /** | ||
| 272 | * struct hwspinlock - this struct represents a single hwspinlock instance | ||
| 273 | * @bank: the hwspinlock_device structure which owns this lock | ||
| 274 | * @lock: initialized and used by hwspinlock core | ||
| 275 | * @priv: private data, owned by the underlying platform-specific hwspinlock drv | ||
| 276 | */ | ||
| 277 | struct hwspinlock { | ||
| 278 | struct hwspinlock_device *bank; | ||
| 265 | spinlock_t lock; | 279 | spinlock_t lock; |
| 266 | struct module *owner; | 280 | void *priv; |
| 267 | }; | 281 | }; |
| 268 | 282 | ||
| 269 | The underlying implementation is responsible to assign the dev, ops, id and | 283 | When registering a bank of locks, the hwspinlock driver only needs to |
| 270 | owner members. The lock member, OTOH, is initialized and used by the hwspinlock | 284 | set the priv members of the locks. The rest of the members are set and |
| 271 | core. | 285 | initialized by the hwspinlock core itself. |
| 272 | 286 | ||
| 273 | 6. Implementation callbacks | 287 | 6. Implementation callbacks |
| 274 | 288 | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 4cb8c51b4792..ab7767001286 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -3018,6 +3018,13 @@ F: Documentation/hw_random.txt | |||
| 3018 | F: drivers/char/hw_random/ | 3018 | F: drivers/char/hw_random/ |
| 3019 | F: include/linux/hw_random.h | 3019 | F: include/linux/hw_random.h |
| 3020 | 3020 | ||
| 3021 | HARDWARE SPINLOCK CORE | ||
| 3022 | M: Ohad Ben-Cohen <ohad@wizery.com> | ||
| 3023 | S: Maintained | ||
| 3024 | F: Documentation/hwspinlock.txt | ||
| 3025 | F: drivers/hwspinlock/hwspinlock_* | ||
| 3026 | F: include/linux/hwspinlock.h | ||
| 3027 | |||
| 3021 | HARMONY SOUND DRIVER | 3028 | HARMONY SOUND DRIVER |
| 3022 | M: Kyle McMartin <kyle@mcmartin.ca> | 3029 | M: Kyle McMartin <kyle@mcmartin.ca> |
| 3023 | L: linux-parisc@vger.kernel.org | 3030 | L: linux-parisc@vger.kernel.org |
| @@ -4714,6 +4721,13 @@ S: Maintained | |||
| 4714 | F: drivers/video/omap2/ | 4721 | F: drivers/video/omap2/ |
| 4715 | F: Documentation/arm/OMAP/DSS | 4722 | F: Documentation/arm/OMAP/DSS |
| 4716 | 4723 | ||
| 4724 | OMAP HARDWARE SPINLOCK SUPPORT | ||
| 4725 | M: Ohad Ben-Cohen <ohad@wizery.com> | ||
| 4726 | L: linux-omap@vger.kernel.org | ||
| 4727 | S: Maintained | ||
| 4728 | F: drivers/hwspinlock/omap_hwspinlock.c | ||
| 4729 | F: arch/arm/mach-omap2/hwspinlock.c | ||
| 4730 | |||
| 4717 | OMAP MMC SUPPORT | 4731 | OMAP MMC SUPPORT |
| 4718 | M: Jarkko Lavinen <jarkko.lavinen@nokia.com> | 4732 | M: Jarkko Lavinen <jarkko.lavinen@nokia.com> |
| 4719 | L: linux-omap@vger.kernel.org | 4733 | L: linux-omap@vger.kernel.org |
diff --git a/arch/arm/mach-omap2/hwspinlock.c b/arch/arm/mach-omap2/hwspinlock.c index 36e21091b06a..454dfce125ca 100644 --- a/arch/arm/mach-omap2/hwspinlock.c +++ b/arch/arm/mach-omap2/hwspinlock.c | |||
| @@ -19,10 +19,15 @@ | |||
| 19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
| 21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
| 22 | #include <linux/hwspinlock.h> | ||
| 22 | 23 | ||
| 23 | #include <plat/omap_hwmod.h> | 24 | #include <plat/omap_hwmod.h> |
