0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __HOST1X_SYNCPT_H
0009 #define __HOST1X_SYNCPT_H
0010
0011 #include <linux/atomic.h>
0012 #include <linux/host1x.h>
0013 #include <linux/kernel.h>
0014 #include <linux/kref.h>
0015 #include <linux/sched.h>
0016
0017 #include "intr.h"
0018
0019 struct host1x;
0020
0021
0022 #define HOST1X_SYNCPT_RESERVED 0
0023
0024 struct host1x_syncpt_base {
0025 unsigned int id;
0026 bool requested;
0027 };
0028
0029 struct host1x_syncpt {
0030 struct kref ref;
0031
0032 unsigned int id;
0033 atomic_t min_val;
0034 atomic_t max_val;
0035 u32 base_val;
0036 const char *name;
0037 bool client_managed;
0038 struct host1x *host;
0039 struct host1x_syncpt_base *base;
0040
0041
0042 struct host1x_syncpt_intr intr;
0043
0044
0045
0046
0047
0048
0049 bool locked;
0050 };
0051
0052
0053 int host1x_syncpt_init(struct host1x *host);
0054
0055
0056 void host1x_syncpt_deinit(struct host1x *host);
0057
0058
0059 unsigned int host1x_syncpt_nb_pts(struct host1x *host);
0060
0061
0062 unsigned int host1x_syncpt_nb_bases(struct host1x *host);
0063
0064
0065 unsigned int host1x_syncpt_nb_mlocks(struct host1x *host);
0066
0067
0068
0069
0070
0071
0072
0073 static inline bool host1x_syncpt_check_max(struct host1x_syncpt *sp, u32 real)
0074 {
0075 u32 max;
0076 if (sp->client_managed)
0077 return true;
0078 max = host1x_syncpt_read_max(sp);
0079 return (s32)(max - real) >= 0;
0080 }
0081
0082
0083 static inline bool host1x_syncpt_client_managed(struct host1x_syncpt *sp)
0084 {
0085 return sp->client_managed;
0086 }
0087
0088
0089
0090
0091
0092 static inline bool host1x_syncpt_idle(struct host1x_syncpt *sp)
0093 {
0094 int min, max;
0095 smp_rmb();
0096 min = atomic_read(&sp->min_val);
0097 max = atomic_read(&sp->max_val);
0098 return (min == max);
0099 }
0100
0101
0102 u32 host1x_syncpt_load(struct host1x_syncpt *sp);
0103
0104
0105 bool host1x_syncpt_is_expired(struct host1x_syncpt *sp, u32 thresh);
0106
0107
0108 void host1x_syncpt_save(struct host1x *host);
0109
0110
0111 void host1x_syncpt_restore(struct host1x *host);
0112
0113
0114 u32 host1x_syncpt_load_wait_base(struct host1x_syncpt *sp);
0115
0116
0117 u32 host1x_syncpt_incr_max(struct host1x_syncpt *sp, u32 incrs);
0118
0119
0120 static inline int host1x_syncpt_is_valid(struct host1x_syncpt *sp)
0121 {
0122 return sp->id < host1x_syncpt_nb_pts(sp->host);
0123 }
0124
0125 static inline void host1x_syncpt_set_locked(struct host1x_syncpt *sp)
0126 {
0127 sp->locked = true;
0128 }
0129
0130 #endif