2 * drivers/video/tegra/host/nvhost_syncpt.h
4 * Tegra Graphics Host Syncpoints
6 * Copyright (c) 2010, NVIDIA Corporation.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 #ifndef __NVHOST_SYNCPT_H
24 #define __NVHOST_SYNCPT_H
26 #include <linux/kernel.h>
27 #include <linux/sched.h>
28 #include <mach/nvhost.h>
29 #include <mach/nvmap.h>
30 #include <asm/atomic.h>
32 #include "nvhost_hardware.h"
34 #define NVSYNCPT_GRAPHICS_HOST (0)
35 #define NVSYNCPT_VI_ISP_0 (12)
36 #define NVSYNCPT_VI_ISP_1 (13)
37 #define NVSYNCPT_VI_ISP_2 (14)
38 #define NVSYNCPT_VI_ISP_3 (15)
39 #define NVSYNCPT_VI_ISP_4 (16)
40 #define NVSYNCPT_VI_ISP_5 (17)
41 #define NVSYNCPT_2D_0 (18)
42 #define NVSYNCPT_2D_1 (19)
43 #define NVSYNCPT_3D (22)
44 #define NVSYNCPT_MPE (23)
45 #define NVSYNCPT_DISP0 (24)
46 #define NVSYNCPT_DISP1 (25)
47 #define NVSYNCPT_VBLANK0 (26)
48 #define NVSYNCPT_VBLANK1 (27)
49 #define NVSYNCPT_MPE_EBM_EOF (28)
50 #define NVSYNCPT_MPE_WR_SAFE (29)
51 #define NVSYNCPT_DSI (31)
52 #define NVSYNCPT_INVALID (-1)
54 /*#define NVSYNCPT_2D_CHANNEL2_0 (20) */
55 /*#define NVSYNCPT_2D_CHANNEL2_1 (21) */
56 /*#define NVSYNCPT_2D_TINYBLT_WAR (30)*/
57 /*#define NVSYNCPT_2D_TINYBLT_RESTORE_CLASS_ID (30)*/
59 /* sync points that are wholly managed by the client */
60 #define NVSYNCPTS_CLIENT_MANAGED ( \
61 BIT(NVSYNCPT_DISP0) | BIT(NVSYNCPT_DISP1) | BIT(NVSYNCPT_DSI) | \
62 BIT(NVSYNCPT_VI_ISP_0) | BIT(NVSYNCPT_VI_ISP_2) | \
63 BIT(NVSYNCPT_VI_ISP_3) | BIT(NVSYNCPT_VI_ISP_4) | BIT(NVSYNCPT_VI_ISP_5) | \
64 BIT(NVSYNCPT_MPE_EBM_EOF) | BIT(NVSYNCPT_MPE_WR_SAFE) | \
67 #define NVWAITBASE_2D_0 (1)
68 #define NVWAITBASE_2D_1 (2)
69 #define NVWAITBASE_3D (3)
70 #define NVWAITBASE_MPE (4)
72 struct nvhost_syncpt {
73 atomic_t min_val[NV_HOST1X_SYNCPT_NB_PTS];
74 atomic_t max_val[NV_HOST1X_SYNCPT_NB_PTS];
75 u32 base_val[NV_HOST1X_SYNCPT_NB_BASES];
79 * Updates the value sent to hardware.
81 static inline u32 nvhost_syncpt_incr_max(struct nvhost_syncpt *sp,
84 return (u32)atomic_add_return(incrs, &sp->max_val[id]);
88 * Updated the value sent to hardware.
90 static inline u32 nvhost_syncpt_set_max(struct nvhost_syncpt *sp,
93 atomic_set(&sp->max_val[id], val);
98 static inline u32 nvhost_syncpt_read_max(struct nvhost_syncpt *sp, u32 id)
101 return (u32)atomic_read(&sp->max_val[id]);
105 * Returns true if syncpoint has reached threshold
107 static inline bool nvhost_syncpt_min_cmp(struct nvhost_syncpt *sp,
112 cur = (u32)atomic_read(&sp->min_val[id]);
113 return ((s32)(cur - thresh) >= 0);
117 * Returns true if syncpoint min == max
119 static inline bool nvhost_syncpt_min_eq_max(struct nvhost_syncpt *sp, u32 id)
123 min = atomic_read(&sp->min_val[id]);
124 max = atomic_read(&sp->max_val[id]);
128 void nvhost_syncpt_cpu_incr(struct nvhost_syncpt *sp, u32 id);
130 u32 nvhost_syncpt_update_min(struct nvhost_syncpt *sp, u32 id);
132 void nvhost_syncpt_save(struct nvhost_syncpt *sp);
134 void nvhost_syncpt_reset(struct nvhost_syncpt *sp);
136 u32 nvhost_syncpt_read(struct nvhost_syncpt *sp, u32 id);
138 void nvhost_syncpt_incr(struct nvhost_syncpt *sp, u32 id);
140 int nvhost_syncpt_wait_timeout(struct nvhost_syncpt *sp, u32 id, u32 thresh,
143 static inline int nvhost_syncpt_wait(struct nvhost_syncpt *sp, u32 id, u32 thresh)
145 return nvhost_syncpt_wait_timeout(sp, id, thresh, MAX_SCHEDULE_TIMEOUT);
148 int nvhost_syncpt_wait_check(struct nvmap_client *nvmap,
149 struct nvhost_syncpt *sp, u32 mask,
150 struct nvhost_waitchk *waitp, u32 num_waits);
152 const char *nvhost_syncpt_name(u32 id);
154 void nvhost_syncpt_debug(struct nvhost_syncpt *sp);