]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/blob - drivers/video/tegra/host/host1x/host1x.h
video: tegra: host: simplify channel map usage
[sojka/nv-tegra/linux-3.10.git] / drivers / video / tegra / host / host1x / host1x.h
1 /*
2  * drivers/video/tegra/host/host1x/host1x.h
3  *
4  * Tegra Graphics Host Driver Entrypoint
5  *
6  * Copyright (c) 2010-2014, NVIDIA Corporation. All rights reserved.
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms and conditions of the GNU General Public License,
10  * version 2, as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  * more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef __NVHOST_HOST1X_H
22 #define __NVHOST_HOST1X_H
23
24 #include <linux/cdev.h>
25 #include <linux/nvhost.h>
26
27 #include "nvhost_syncpt.h"
28 #include "nvhost_channel.h"
29 #include "nvhost_intr.h"
30
31 #define TRACE_MAX_LENGTH        128U
32 #define IFACE_NAME              "nvhost"
33
34 struct nvhost_channel;
35 struct mem_mgr;
36
37 struct host1x_device_info {
38         int             nb_channels;    /* host1x: num channels supported */
39         int             nb_pts;         /* host1x: num syncpoints supported */
40         int             nb_bases;       /* host1x: num syncpoints supported */
41         int             nb_mlocks;      /* host1x: number of mlocks */
42 };
43
44 struct nvhost_master {
45         void __iomem *aperture;
46         void __iomem *sync_aperture;
47         struct class *nvhost_class;
48         struct cdev cdev;
49         struct device *ctrl;
50         struct nvhost_syncpt syncpt;
51         struct nvhost_intr intr;
52         struct platform_device *dev;
53         atomic_t clientid;
54         struct host1x_device_info info;
55         struct kobject *caps_kobj;
56         struct nvhost_capability_node *caps_nodes;
57         struct mutex timeout_mutex;
58
59         struct nvhost_channel **chlist; /* channel list */
60         struct mutex chlist_mutex;      /* mutex for channel list */
61         unsigned long allocated_channels;
62         unsigned long next_free_ch;
63 };
64
65 extern struct nvhost_master *nvhost;
66
67 void nvhost_debug_init(struct nvhost_master *master);
68 void nvhost_device_debug_init(struct platform_device *dev);
69 void nvhost_device_debug_deinit(struct platform_device *dev);
70 void nvhost_debug_dump(struct nvhost_master *master);
71
72 int nvhost_host1x_finalize_poweron(struct platform_device *dev);
73 int nvhost_host1x_prepare_poweroff(struct platform_device *dev);
74
75 void nvhost_set_chanops(struct nvhost_channel *ch);
76
77 int nvhost_gather_filter_enabled(struct nvhost_syncpt *sp);
78
79 extern pid_t nvhost_debug_null_kickoff_pid;
80
81 static inline void *nvhost_get_private_data(struct platform_device *_dev)
82 {
83         struct nvhost_device_data *pdata =
84                 (struct nvhost_device_data *)platform_get_drvdata(_dev);
85         BUG_ON(!pdata);
86         return pdata ? pdata->private_data : NULL;
87 }
88
89 static inline void nvhost_set_private_data(struct platform_device *_dev,
90         void *priv_data)
91 {
92         struct nvhost_device_data *pdata =
93                 (struct nvhost_device_data *)platform_get_drvdata(_dev);
94         WARN_ON(!pdata);
95         pdata->private_data = priv_data;
96 }
97
98 static inline struct nvhost_master *nvhost_get_host(
99         struct platform_device *_dev)
100 {
101         struct platform_device *pdev;
102
103         if (_dev->dev.parent && _dev->dev.parent != &platform_bus) {
104                 pdev = to_platform_device(_dev->dev.parent);
105                 return nvhost_get_private_data(pdev);
106         } else
107                 return nvhost_get_private_data(_dev);
108 }
109
110 static inline struct platform_device *nvhost_get_parent(
111         struct platform_device *_dev)
112 {
113         return (_dev->dev.parent && _dev->dev.parent != &platform_bus)
114                 ? to_platform_device(_dev->dev.parent) : NULL;
115 }
116
117 #endif