Merge remote branch 'common/android-2.6.36' into android-tegra-2.6.36
[firefly-linux-kernel-4.4.55.git] / drivers / video / tegra / host / nvhost_intr.h
1 /*
2  * drivers/video/tegra/host/nvhost_intr.h
3  *
4  * Tegra Graphics Host Interrupt Management
5  *
6  * Copyright (c) 2010, NVIDIA Corporation.
7  *
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.
12  *
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
16  * more details.
17  *
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.
21  */
22
23 #ifndef __NVHOST_INTR_H
24 #define __NVHOST_INTR_H
25
26 #include <linux/kthread.h>
27 #include <linux/semaphore.h>
28
29 #include "nvhost_hardware.h"
30
31 struct nvhost_channel;
32
33 enum nvhost_intr_action {
34         /**
35          * Perform cleanup after a submit has completed.
36          * 'data' points to a channel
37          */
38         NVHOST_INTR_ACTION_SUBMIT_COMPLETE = 0,
39
40         /**
41          * Save a HW context.
42          * 'data' points to a context
43          */
44         NVHOST_INTR_ACTION_CTXSAVE,
45
46         /**
47          * Wake up a  task.
48          * 'data' points to a wait_queue_head_t
49          */
50         NVHOST_INTR_ACTION_WAKEUP,
51
52         /**
53          * Wake up a interruptible task.
54          * 'data' points to a wait_queue_head_t
55          */
56         NVHOST_INTR_ACTION_WAKEUP_INTERRUPTIBLE,
57
58         NVHOST_INTR_ACTION_COUNT
59 };
60
61 struct nvhost_intr_syncpt {
62         u8 id;
63         u8 irq_requested;
64         u16 irq;
65         spinlock_t lock;
66         struct list_head wait_head;
67         char thresh_irq_name[12];
68 };
69
70 struct nvhost_intr {
71         struct nvhost_intr_syncpt syncpt[NV_HOST1X_SYNCPT_NB_PTS];
72         int host1x_irq;
73         bool host1x_isr_started;
74 };
75
76 /**
77  * Schedule an action to be taken when a sync point reaches the given threshold.
78  *
79  * @id the sync point
80  * @thresh the threshold
81  * @action the action to take
82  * @data a pointer to extra data depending on action, see above
83  * @ref must be passed if cancellation is possible, else NULL
84  *
85  * This is a non-blocking api.
86  */
87 int nvhost_intr_add_action(struct nvhost_intr *intr, u32 id, u32 thresh,
88                         enum nvhost_intr_action action, void *data,
89                         void **ref);
90
91 /**
92  * Unreference an action submitted to nvhost_intr_add_action().
93  * You must call this if you passed non-NULL as ref.
94  * @ref the ref returned from nvhost_intr_add_action()
95  */
96 void nvhost_intr_put_ref(struct nvhost_intr *intr, void *ref);
97
98 int nvhost_intr_init(struct nvhost_intr *intr, u32 irq_gen, u32 irq_sync);
99 void nvhost_intr_deinit(struct nvhost_intr *intr);
100 void nvhost_intr_configure(struct nvhost_intr *intr, u32 hz);
101
102 #endif