intr.h revision 7ede0b0bf3e2595d40d6195b6fe4c4dcef438830
1/*
2 * Tegra host1x Interrupt Management
3 *
4 * Copyright (c) 2010-2013, NVIDIA Corporation.
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms and conditions of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
13 * more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#ifndef __HOST1X_INTR_H
20#define __HOST1X_INTR_H
21
22#include <linux/interrupt.h>
23#include <linux/workqueue.h>
24
25struct host1x;
26
27enum host1x_intr_action {
28	/*
29	 * Wake up a  task.
30	 * 'data' points to a wait_queue_head_t
31	 */
32	HOST1X_INTR_ACTION_WAKEUP,
33
34	/*
35	 * Wake up a interruptible task.
36	 * 'data' points to a wait_queue_head_t
37	 */
38	HOST1X_INTR_ACTION_WAKEUP_INTERRUPTIBLE,
39
40	HOST1X_INTR_ACTION_COUNT
41};
42
43struct host1x_syncpt_intr {
44	spinlock_t lock;
45	struct list_head wait_head;
46	char thresh_irq_name[12];
47	struct work_struct work;
48};
49
50struct host1x_waitlist {
51	struct list_head list;
52	struct kref refcount;
53	u32 thresh;
54	enum host1x_intr_action action;
55	atomic_t state;
56	void *data;
57	int count;
58};
59
60/*
61 * Schedule an action to be taken when a sync point reaches the given threshold.
62 *
63 * @id the sync point
64 * @thresh the threshold
65 * @action the action to take
66 * @data a pointer to extra data depending on action, see above
67 * @waiter waiter structure - assumes ownership
68 * @ref must be passed if cancellation is possible, else NULL
69 *
70 * This is a non-blocking api.
71 */
72int host1x_intr_add_action(struct host1x *host, u32 id, u32 thresh,
73	enum host1x_intr_action action, void *data,
74	struct host1x_waitlist *waiter, void **ref);
75
76/*
77 * Unreference an action submitted to host1x_intr_add_action().
78 * You must call this if you passed non-NULL as ref.
79 * @ref the ref returned from host1x_intr_add_action()
80 */
81void host1x_intr_put_ref(struct host1x *host, u32 id, void *ref);
82
83/* Initialize host1x sync point interrupt */
84int host1x_intr_init(struct host1x *host, unsigned int irq_sync);
85
86/* Deinitialize host1x sync point interrupt */
87void host1x_intr_deinit(struct host1x *host);
88
89/* Enable host1x sync point interrupt */
90void host1x_intr_start(struct host1x *host);
91
92/* Disable host1x sync point interrupt */
93void host1x_intr_stop(struct host1x *host);
94
95irqreturn_t host1x_syncpt_thresh_fn(void *dev_id);
96#endif
97