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-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Tegra host1x Syncpoints
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2010-2013, NVIDIA Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #ifndef __HOST1X_SYNCPT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define __HOST1X_SYNCPT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/atomic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/host1x.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include "intr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) struct host1x;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) /* Reserved for replacing an expired wait with a NOP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #define HOST1X_SYNCPT_RESERVED			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct host1x_syncpt_base {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	unsigned int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	bool requested;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) struct host1x_syncpt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	unsigned int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	atomic_t min_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	atomic_t max_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	u32 base_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	bool client_managed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	struct host1x *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct host1x_client *client;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct host1x_syncpt_base *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	/* interrupt data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	struct host1x_syncpt_intr intr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) /* Initialize sync point array  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) int host1x_syncpt_init(struct host1x *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) /*  Free sync point array */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) void host1x_syncpt_deinit(struct host1x *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) /* Return number of sync point supported. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) unsigned int host1x_syncpt_nb_pts(struct host1x *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) /* Return number of wait bases supported. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) unsigned int host1x_syncpt_nb_bases(struct host1x *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /* Return number of mlocks supported. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) unsigned int host1x_syncpt_nb_mlocks(struct host1x *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * Check sync point sanity. If max is larger than min, there have too many
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * sync point increments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62)  * Client managed sync point are not tracked.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  * */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static inline bool host1x_syncpt_check_max(struct host1x_syncpt *sp, u32 real)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	u32 max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if (sp->client_managed)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	max = host1x_syncpt_read_max(sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	return (s32)(max - real) >= 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) /* Return true if sync point is client managed. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) static inline bool host1x_syncpt_client_managed(struct host1x_syncpt *sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	return sp->client_managed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * Returns true if syncpoint min == max, which means that there are no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * outstanding operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) static inline bool host1x_syncpt_idle(struct host1x_syncpt *sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	int min, max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	smp_rmb();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	min = atomic_read(&sp->min_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	max = atomic_read(&sp->max_val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	return (min == max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) /* Load current value from hardware to the shadow register. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) u32 host1x_syncpt_load(struct host1x_syncpt *sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) /* Check if the given syncpoint value has already passed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) bool host1x_syncpt_is_expired(struct host1x_syncpt *sp, u32 thresh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) /* Save host1x sync point state into shadow registers. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) void host1x_syncpt_save(struct host1x *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /* Reset host1x sync point state from shadow registers. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) void host1x_syncpt_restore(struct host1x *host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /* Read current wait base value into shadow register and return it. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* Indicate future operations by incrementing the sync point max. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /* Check if sync point id is valid. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	return sp->id < host1x_syncpt_nb_pts(sp->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #endif