blob: 2357b4ff771e2b064cdb393920b4771f55ab161e [file] [log] [blame]
Chris Lew63b2d6b2016-08-01 10:59:49 -07001/* 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
30typedef struct {
31 volatile uint32_t lock;
32} raw_remote_spinlock_t;
33
34typedef raw_remote_spinlock_t *_remote_spinlock_t;
35
36#define remote_spinlock_id_t const char *
37
38#if defined(CONFIG_REMOTE_SPINLOCK_MSM)
39int _remote_spin_lock_init(remote_spinlock_id_t, _remote_spinlock_t *lock);
40void _remote_spin_release_all(uint32_t pid);
41void _remote_spin_lock(_remote_spinlock_t *lock);
42void _remote_spin_unlock(_remote_spinlock_t *lock);
43int _remote_spin_trylock(_remote_spinlock_t *lock);
44int _remote_spin_release(_remote_spinlock_t *lock, uint32_t pid);
45int _remote_spin_owner(_remote_spinlock_t *lock);
46void _remote_spin_lock_rlock_id(_remote_spinlock_t *lock, uint32_t tid);
47void _remote_spin_unlock_rlock(_remote_spinlock_t *lock);
48int _remote_spin_get_hw_spinlocks_element(_remote_spinlock_t *lock);
49#else
50static inline
51int _remote_spin_lock_init(remote_spinlock_id_t id, _remote_spinlock_t *lock)
52{
53 return -EINVAL;
54}
55static inline void _remote_spin_release_all(uint32_t pid) {}
56static inline void _remote_spin_lock(_remote_spinlock_t *lock) {}
57static inline void _remote_spin_unlock(_remote_spinlock_t *lock) {}
58static inline int _remote_spin_trylock(_remote_spinlock_t *lock)
59{
60 return -ENODEV;
61}
62static inline int _remote_spin_release(_remote_spinlock_t *lock, uint32_t pid)
63{
64 return -ENODEV;
65}
66static inline int _remote_spin_owner(_remote_spinlock_t *lock)
67{
68 return -ENODEV;
69}
70static inline void _remote_spin_lock_rlock_id(_remote_spinlock_t *lock,
71 uint32_t tid) {}
72static inline void _remote_spin_unlock_rlock(_remote_spinlock_t *lock) {}
73static 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 */