Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Hardware spinlocks internal header
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Contact: Ohad Ben-Cohen <ohad@wizery.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #ifndef __HWSPINLOCK_HWSPINLOCK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define __HWSPINLOCK_HWSPINLOCK_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/spinlock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct hwspinlock_device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * struct hwspinlock_ops - platform-specific hwspinlock handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * @trylock: make a single attempt to take the lock. returns 0 on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  *	     failure and true on success. may _not_ sleep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  * @unlock:  release the lock. always succeed. may _not_ sleep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  * @relax:   optional, platform-specific relax handler, called by hwspinlock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)  *	     core while spinning on a lock, between two successive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)  *	     invocations of @trylock. may _not_ sleep.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) struct hwspinlock_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	int (*trylock)(struct hwspinlock *lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	void (*unlock)(struct hwspinlock *lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	void (*relax)(struct hwspinlock *lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)  * struct hwspinlock - this struct represents a single hwspinlock instance
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)  * @bank: the hwspinlock_device structure which owns this lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)  * @lock: initialized and used by hwspinlock core
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)  * @priv: private data, owned by the underlying platform-specific hwspinlock drv
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct hwspinlock {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	struct hwspinlock_device *bank;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	spinlock_t lock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	void *priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)  * struct hwspinlock_device - a device which usually spans numerous hwspinlocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)  * @dev: underlying device, will be used to invoke runtime PM api
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)  * @ops: platform-specific hwspinlock handlers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)  * @base_id: id index of the first lock in this device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)  * @num_locks: number of locks in this device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)  * @lock: dynamically allocated array of 'struct hwspinlock'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct hwspinlock_device {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	struct device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	const struct hwspinlock_ops *ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	int base_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	int num_locks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	struct hwspinlock lock[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static inline int hwlock_to_id(struct hwspinlock *hwlock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	int local_id = hwlock - &hwlock->bank->lock[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	return hwlock->bank->base_id + local_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #endif /* __HWSPINLOCK_HWSPINLOCK_H */