diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/nvhost.c | 208 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/nvhost_priv.h | 24 |
2 files changed, 232 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/nvhost.c b/drivers/gpu/nvgpu/common/linux/nvhost.c new file mode 100644 index 00000000..19e41e17 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/nvhost.c | |||
@@ -0,0 +1,208 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #include <linux/nvhost.h> | ||
18 | #include <linux/nvhost_ioctl.h> | ||
19 | #include <linux/of_platform.h> | ||
20 | |||
21 | #include <nvgpu/nvhost.h> | ||
22 | |||
23 | #include "nvhost_priv.h" | ||
24 | |||
25 | #include "gk20a/gk20a.h" | ||
26 | |||
27 | int nvgpu_get_nvhost_dev(struct gk20a *g) | ||
28 | { | ||
29 | struct device_node *np = g->dev->of_node; | ||
30 | struct platform_device *host1x_pdev = NULL; | ||
31 | const __be32 *host1x_ptr; | ||
32 | |||
33 | host1x_ptr = of_get_property(np, "nvidia,host1x", NULL); | ||
34 | if (host1x_ptr) { | ||
35 | struct device_node *host1x_node = | ||
36 | of_find_node_by_phandle(be32_to_cpup(host1x_ptr)); | ||
37 | |||
38 | host1x_pdev = of_find_device_by_node(host1x_node); | ||
39 | if (!host1x_pdev) { | ||
40 | dev_warn(g->dev, "host1x device not available"); | ||
41 | return -EPROBE_DEFER; | ||
42 | } | ||
43 | |||
44 | } else { | ||
45 | host1x_pdev = to_platform_device(g->dev->parent); | ||
46 | dev_warn(g->dev, "host1x reference not found. assuming host1x to be parent"); | ||
47 | } | ||
48 | |||
49 | g->nvhost_dev = nvgpu_kzalloc(g, sizeof(struct nvgpu_nvhost_dev)); | ||
50 | if (!g->nvhost_dev) | ||
51 | return -ENOMEM; | ||
52 | |||
53 | g->nvhost_dev->host1x_pdev = host1x_pdev; | ||
54 | |||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | void nvgpu_free_nvhost_dev(struct gk20a *g) | ||
59 | { | ||
60 | nvgpu_kfree(g, g->nvhost_dev); | ||
61 | } | ||
62 | |||
63 | int nvgpu_nvhost_module_busy_ext( | ||
64 | struct nvgpu_nvhost_dev *nvhost_dev) | ||
65 | { | ||
66 | return nvhost_module_busy_ext(nvhost_dev->host1x_pdev); | ||
67 | } | ||
68 | |||
69 | void nvgpu_nvhost_module_idle_ext( | ||
70 | struct nvgpu_nvhost_dev *nvhost_dev) | ||
71 | { | ||
72 | nvhost_module_idle_ext(nvhost_dev->host1x_pdev); | ||
73 | } | ||
74 | |||
75 | void nvgpu_nvhost_debug_dump_device( | ||
76 | struct nvgpu_nvhost_dev *nvhost_dev) | ||
77 | { | ||
78 | nvhost_debug_dump_device(nvhost_dev->host1x_pdev); | ||
79 | } | ||
80 | |||
81 | const char *nvgpu_nvhost_syncpt_get_name( | ||
82 | struct nvgpu_nvhost_dev *nvhost_dev, int id) | ||
83 | { | ||
84 | return nvhost_syncpt_get_name(nvhost_dev->host1x_pdev, id); | ||
85 | } | ||
86 | |||
87 | bool nvgpu_nvhost_syncpt_is_valid_pt_ext( | ||
88 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id) | ||
89 | { | ||
90 | return nvhost_syncpt_is_valid_pt_ext(nvhost_dev->host1x_pdev, id); | ||
91 | } | ||
92 | |||
93 | int nvgpu_nvhost_syncpt_is_expired_ext( | ||
94 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 thresh) | ||
95 | { | ||
96 | return nvhost_syncpt_is_expired_ext(nvhost_dev->host1x_pdev, | ||
97 | id, thresh); | ||
98 | } | ||
99 | |||
100 | u32 nvgpu_nvhost_syncpt_incr_max_ext( | ||
101 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 incrs) | ||
102 | { | ||
103 | return nvhost_syncpt_incr_max_ext(nvhost_dev->host1x_pdev, id, incrs); | ||
104 | } | ||
105 | |||
106 | int nvgpu_nvhost_intr_register_notifier( | ||
107 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 thresh, | ||
108 | void (*callback)(void *, int), void *private_data) | ||
109 | { | ||
110 | return nvhost_intr_register_notifier(nvhost_dev->host1x_pdev, | ||
111 | id, thresh, | ||
112 | callback, private_data); | ||
113 | } | ||
114 | |||
115 | void nvgpu_nvhost_syncpt_set_min_eq_max_ext( | ||
116 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id) | ||
117 | { | ||
118 | nvhost_syncpt_set_min_eq_max_ext(nvhost_dev->host1x_pdev, id); | ||
119 | } | ||
120 | |||
121 | void nvgpu_nvhost_syncpt_put_ref_ext( | ||
122 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id) | ||
123 | { | ||
124 | nvhost_syncpt_put_ref_ext(nvhost_dev->host1x_pdev, id); | ||
125 | } | ||
126 | |||
127 | u32 nvgpu_nvhost_get_syncpt_host_managed( | ||
128 | struct nvgpu_nvhost_dev *nvhost_dev, | ||
129 | u32 param, const char *syncpt_name) | ||
130 | { | ||
131 | return nvhost_get_syncpt_host_managed(nvhost_dev->host1x_pdev, | ||
132 | param, syncpt_name); | ||
133 | } | ||
134 | |||
135 | int nvgpu_nvhost_syncpt_wait_timeout_ext( | ||
136 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, | ||
137 | u32 thresh, u32 timeout, u32 *value, struct timespec *ts) | ||
138 | { | ||
139 | return nvhost_syncpt_wait_timeout_ext(nvhost_dev->host1x_pdev, | ||
140 | id, thresh, timeout, value, ts); | ||
141 | } | ||
142 | |||
143 | int nvgpu_nvhost_syncpt_read_ext_check( | ||
144 | struct nvgpu_nvhost_dev *nvhost_dev, u32 id, u32 *val) | ||
145 | { | ||
146 | return nvhost_syncpt_read_ext_check(nvhost_dev->host1x_pdev, id, val); | ||
147 | } | ||
148 | |||
149 | int nvgpu_nvhost_create_symlink(struct gk20a *g) | ||
150 | { | ||
151 | struct device *dev = g->dev; | ||
152 | int err = 0; | ||
153 | |||
154 | if (g->nvhost_dev && | ||
155 | (dev->parent != &g->nvhost_dev->host1x_pdev->dev)) { | ||
156 | err = sysfs_create_link(&g->nvhost_dev->host1x_pdev->dev.kobj, | ||
157 | &dev->kobj, | ||
158 | dev_name(dev)); | ||
159 | } | ||
160 | |||
161 | return err; | ||
162 | } | ||
163 | |||
164 | void nvgpu_nvhost_remove_symlink(struct gk20a *g) | ||
165 | { | ||
166 | struct device *dev = g->dev; | ||
167 | |||
168 | if (g->nvhost_dev && | ||
169 | (dev->parent != &g->nvhost_dev->host1x_pdev->dev)) { | ||
170 | sysfs_remove_link(&g->nvhost_dev->host1x_pdev->dev.kobj, | ||
171 | dev_name(dev)); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | #ifdef CONFIG_SYNC | ||
176 | u32 nvgpu_nvhost_sync_pt_id(struct sync_pt *pt) | ||
177 | { | ||
178 | return nvhost_sync_pt_id(pt); | ||
179 | } | ||
180 | |||
181 | u32 nvgpu_nvhost_sync_pt_thresh(struct sync_pt *pt) | ||
182 | { | ||
183 | return nvhost_sync_pt_thresh(pt); | ||
184 | } | ||
185 | |||
186 | struct sync_fence *nvgpu_nvhost_sync_fdget(int fd) | ||
187 | { | ||
188 | return nvhost_sync_fdget(fd); | ||
189 | } | ||
190 | |||
191 | int nvgpu_nvhost_sync_num_pts(struct sync_fence *fence) | ||
192 | { | ||
193 | return nvhost_sync_num_pts(fence); | ||
194 | } | ||
195 | |||
196 | struct sync_fence *nvgpu_nvhost_sync_create_fence( | ||
197 | struct nvgpu_nvhost_dev *nvhost_dev, | ||
198 | u32 id, u32 thresh, | ||
199 | u32 num_pts, const char *name) | ||
200 | { | ||
201 | struct nvhost_ctrl_sync_fence_info pt = { | ||
202 | .id = id, | ||
203 | .thresh = thresh, | ||
204 | }; | ||
205 | |||
206 | return nvhost_sync_create_fence(nvhost_dev->host1x_pdev, &pt, num_pts, name); | ||
207 | } | ||
208 | #endif /* CONFIG_SYNC */ | ||
diff --git a/drivers/gpu/nvgpu/common/linux/nvhost_priv.h b/drivers/gpu/nvgpu/common/linux/nvhost_priv.h new file mode 100644 index 00000000..c03390a7 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/nvhost_priv.h | |||
@@ -0,0 +1,24 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License | ||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
15 | */ | ||
16 | |||
17 | #ifndef __NVGPU_NVHOST_PRIV_H__ | ||
18 | #define __NVGPU_NVHOST_PRIV_H__ | ||
19 | |||
20 | struct nvgpu_nvhost_dev { | ||
21 | struct platform_device *host1x_pdev; | ||
22 | }; | ||
23 | |||
24 | #endif /* __NVGPU_NVHOST_PRIV_H__ */ | ||