Chris Lew | 63b2d6b | 2016-08-01 10:59:49 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2009, 2011, 2013-2015 The Linux Foundation. All rights reserved. |
| 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | /* |
| 15 | * Part of this this code is based on the standard ARM spinlock |
| 16 | * implementation (asm/spinlock.h) found in the 2.6.29 kernel. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __ASM__ARCH_QC_REMOTE_SPINLOCK_H |
| 20 | #define __ASM__ARCH_QC_REMOTE_SPINLOCK_H |
| 21 | |
| 22 | #include <linux/io.h> |
| 23 | #include <linux/types.h> |
| 24 | |
| 25 | #define REMOTE_SPINLOCK_NUM_PID 128 |
| 26 | #define REMOTE_SPINLOCK_TID_START REMOTE_SPINLOCK_NUM_PID |
| 27 | |
| 28 | /* Remote spinlock definitions. */ |
| 29 | |
| 30 | typedef struct { |
| 31 | volatile uint32_t lock; |
| 32 | } raw_remote_spinlock_t; |
| 33 | |
| 34 | typedef raw_remote_spinlock_t *_remote_spinlock_t; |
| 35 | |
| 36 | #define remote_spinlock_id_t const char * |
| 37 | |
| 38 | #if defined(CONFIG_REMOTE_SPINLOCK_MSM) |
| 39 | int _remote_spin_lock_init(remote_spinlock_id_t, _remote_spinlock_t *lock); |
| 40 | void _remote_spin_release_all(uint32_t pid); |
| 41 | void _remote_spin_lock(_remote_spinlock_t *lock); |
| 42 | void _remote_spin_unlock(_remote_spinlock_t *lock); |
| 43 | int _remote_spin_trylock(_remote_spinlock_t *lock); |
| 44 | int _remote_spin_release(_remote_spinlock_t *lock, uint32_t pid); |
| 45 | int _remote_spin_owner(_remote_spinlock_t *lock); |
| 46 | void _remote_spin_lock_rlock_id(_remote_spinlock_t *lock, uint32_t tid); |
| 47 | void _remote_spin_unlock_rlock(_remote_spinlock_t *lock); |
| 48 | int _remote_spin_get_hw_spinlocks_element(_remote_spinlock_t *lock); |
| 49 | #else |
| 50 | static inline |
| 51 | int _remote_spin_lock_init(remote_spinlock_id_t id, _remote_spinlock_t *lock) |
| 52 | { |
| 53 | return -EINVAL; |
| 54 | } |
| 55 | static inline void _remote_spin_release_all(uint32_t pid) {} |
| 56 | static inline void _remote_spin_lock(_remote_spinlock_t *lock) {} |
| 57 | static inline void _remote_spin_unlock(_remote_spinlock_t *lock) {} |
| 58 | static inline int _remote_spin_trylock(_remote_spinlock_t *lock) |
| 59 | { |
| 60 | return -ENODEV; |
| 61 | } |
| 62 | static inline int _remote_spin_release(_remote_spinlock_t *lock, uint32_t pid) |
| 63 | { |
| 64 | return -ENODEV; |
| 65 | } |
| 66 | static inline int _remote_spin_owner(_remote_spinlock_t *lock) |
| 67 | { |
| 68 | return -ENODEV; |
| 69 | } |
| 70 | static inline void _remote_spin_lock_rlock_id(_remote_spinlock_t *lock, |
| 71 | uint32_t tid) {} |
| 72 | static inline void _remote_spin_unlock_rlock(_remote_spinlock_t *lock) {} |
| 73 | static inline int _remote_spin_get_hw_spinlocks_element( |
| 74 | _remote_spinlock_t *lock) |
| 75 | { |
| 76 | return -ENODEV; |
| 77 | } |
| 78 | #endif |
| 79 | #endif /* __ASM__ARCH_QC_REMOTE_SPINLOCK_H */ |