summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gk20a.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c259
1 files changed, 0 insertions, 259 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 060429d1..1c75123f 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -19,12 +19,10 @@
19#include <linux/module.h> 19#include <linux/module.h>
20#include <linux/dma-mapping.h> 20#include <linux/dma-mapping.h>
21#include <linux/string.h> 21#include <linux/string.h>
22#include <linux/cdev.h>
23#include <linux/delay.h> 22#include <linux/delay.h>
24#include <linux/interrupt.h> 23#include <linux/interrupt.h>
25#include <linux/irq.h> 24#include <linux/irq.h>
26#include <linux/export.h> 25#include <linux/export.h>
27#include <linux/file.h>
28#include <linux/of.h> 26#include <linux/of.h>
29#include <linux/of_device.h> 27#include <linux/of_device.h>
30#include <linux/of_platform.h> 28#include <linux/of_platform.h>
@@ -48,7 +46,6 @@
48 46
49#include "gk20a.h" 47#include "gk20a.h"
50#include "debug_gk20a.h" 48#include "debug_gk20a.h"
51#include "ctrl_gk20a.h"
52#include "channel_sync_gk20a.h" 49#include "channel_sync_gk20a.h"
53 50
54#include "gk20a_scale.h" 51#include "gk20a_scale.h"
@@ -167,100 +164,6 @@ static inline void set_gk20a(struct platform_device *pdev, struct gk20a *gk20a)
167 gk20a_get_platform(&pdev->dev)->g = gk20a; 164 gk20a_get_platform(&pdev->dev)->g = gk20a;
168} 165}
169 166
170const struct file_operations gk20a_channel_ops = {
171 .owner = THIS_MODULE,
172 .release = gk20a_channel_release,
173 .open = gk20a_channel_open,
174#ifdef CONFIG_COMPAT
175 .compat_ioctl = gk20a_channel_ioctl,
176#endif
177 .unlocked_ioctl = gk20a_channel_ioctl,
178};
179
180static const struct file_operations gk20a_ctrl_ops = {
181 .owner = THIS_MODULE,
182 .release = gk20a_ctrl_dev_release,
183 .open = gk20a_ctrl_dev_open,
184 .unlocked_ioctl = gk20a_ctrl_dev_ioctl,
185#ifdef CONFIG_COMPAT
186 .compat_ioctl = gk20a_ctrl_dev_ioctl,
187#endif
188};
189
190static const struct file_operations gk20a_dbg_ops = {
191 .owner = THIS_MODULE,
192 .release = gk20a_dbg_gpu_dev_release,
193 .open = gk20a_dbg_gpu_dev_open,
194 .unlocked_ioctl = gk20a_dbg_gpu_dev_ioctl,
195 .poll = gk20a_dbg_gpu_dev_poll,
196#ifdef CONFIG_COMPAT
197 .compat_ioctl = gk20a_dbg_gpu_dev_ioctl,
198#endif
199};
200
201static const struct file_operations gk20a_as_ops = {
202 .owner = THIS_MODULE,
203 .release = gk20a_as_dev_release,
204 .open = gk20a_as_dev_open,
205#ifdef CONFIG_COMPAT
206 .compat_ioctl = gk20a_as_dev_ioctl,
207#endif
208 .unlocked_ioctl = gk20a_as_dev_ioctl,
209};
210
211/*
212 * Note: We use a different 'open' to trigger handling of the profiler session.
213 * Most of the code is shared between them... Though, at some point if the
214 * code does get too tangled trying to handle each in the same path we can
215 * separate them cleanly.
216 */
217static const struct file_operations gk20a_prof_ops = {
218 .owner = THIS_MODULE,
219 .release = gk20a_dbg_gpu_dev_release,
220 .open = gk20a_prof_gpu_dev_open,
221 .unlocked_ioctl = gk20a_dbg_gpu_dev_ioctl,
222 /* .mmap = gk20a_prof_gpu_dev_mmap,*/
223 /*int (*mmap) (struct file *, struct vm_area_struct *);*/
224#ifdef CONFIG_COMPAT
225 .compat_ioctl = gk20a_dbg_gpu_dev_ioctl,
226#endif
227};
228
229static const struct file_operations gk20a_tsg_ops = {
230 .owner = THIS_MODULE,
231 .release = gk20a_tsg_dev_release,
232 .open = gk20a_tsg_dev_open,
233#ifdef CONFIG_COMPAT
234 .compat_ioctl = gk20a_tsg_dev_ioctl,
235#endif
236 .unlocked_ioctl = gk20a_tsg_dev_ioctl,
237};
238
239static const struct file_operations gk20a_ctxsw_ops = {
240 .owner = THIS_MODULE,
241 .release = gk20a_ctxsw_dev_release,
242 .open = gk20a_ctxsw_dev_open,
243#ifdef CONFIG_COMPAT
244 .compat_ioctl = gk20a_ctxsw_dev_ioctl,
245#endif
246 .unlocked_ioctl = gk20a_ctxsw_dev_ioctl,
247 .poll = gk20a_ctxsw_dev_poll,
248 .read = gk20a_ctxsw_dev_read,
249 .mmap = gk20a_ctxsw_dev_mmap,
250};
251
252static const struct file_operations gk20a_sched_ops = {
253 .owner = THIS_MODULE,
254 .release = gk20a_sched_dev_release,
255 .open = gk20a_sched_dev_open,
256#ifdef CONFIG_COMPAT
257 .compat_ioctl = gk20a_sched_dev_ioctl,
258#endif
259 .unlocked_ioctl = gk20a_sched_dev_ioctl,
260 .poll = gk20a_sched_dev_poll,
261 .read = gk20a_sched_dev_read,
262};
263
264void __nvgpu_check_gpu_state(struct gk20a *g) 167void __nvgpu_check_gpu_state(struct gk20a *g)
265{ 168{
266 u32 boot_0 = g->ops.mc.boot_0(g, NULL, NULL, NULL); 169 u32 boot_0 = g->ops.mc.boot_0(g, NULL, NULL, NULL);
@@ -773,168 +676,6 @@ static struct of_device_id tegra_gk20a_of_match[] = {
773 { }, 676 { },
774}; 677};
775 678
776static int gk20a_create_device(
777 struct device *dev, int devno,
778 const char *interface_name, const char *cdev_name,
779 struct cdev *cdev, struct device **out,
780 const struct file_operations *ops,
781 struct class *class)
782{
783 struct device *subdev;
784 int err;
785
786 gk20a_dbg_fn("");
787
788 cdev_init(cdev, ops);
789 cdev->owner = THIS_MODULE;
790
791 err = cdev_add(cdev, devno, 1);
792 if (err) {
793 dev_err(dev, "failed to add %s cdev\n", cdev_name);
794 return err;
795 }
796
797 subdev = device_create(class, NULL, devno, NULL,
798 interface_name, cdev_name);
799
800 if (IS_ERR(subdev)) {
801 err = PTR_ERR(dev);
802 cdev_del(cdev);
803 dev_err(dev, "failed to create %s device\n",
804 cdev_name);
805 return err;
806 }
807
808 *out = subdev;
809 return 0;
810}
811
812void gk20a_user_deinit(struct device *dev, struct class *class)
813{
814 struct gk20a *g = gk20a_from_dev(dev);
815
816 if (g->channel.node) {
817 device_destroy(class, g->channel.cdev.dev);
818 cdev_del(&g->channel.cdev);
819 }
820
821 if (g->as.node) {
822 device_destroy(class, g->as.cdev.dev);
823 cdev_del(&g->as.cdev);
824 }
825
826 if (g->ctrl.node) {
827 device_destroy(class, g->ctrl.cdev.dev);
828 cdev_del(&g->ctrl.cdev);
829 }
830
831 if (g->dbg.node) {
832 device_destroy(class, g->dbg.cdev.dev);
833 cdev_del(&g->dbg.cdev);
834 }
835
836 if (g->prof.node) {
837 device_destroy(class, g->prof.cdev.dev);
838 cdev_del(&g->prof.cdev);
839 }
840
841 if (g->tsg.node) {
842 device_destroy(class, g->tsg.cdev.dev);
843 cdev_del(&g->tsg.cdev);
844 }
845
846 if (g->ctxsw.node) {
847 device_destroy(class, g->ctxsw.cdev.dev);
848 cdev_del(&g->ctxsw.cdev);
849 }
850
851 if (g->sched.node) {
852 device_destroy(class, g->sched.cdev.dev);
853 cdev_del(&g->sched.cdev);
854 }
855
856 if (g->cdev_region)
857 unregister_chrdev_region(g->cdev_region, GK20A_NUM_CDEVS);
858}
859
860int gk20a_user_init(struct device *dev, const char *interface_name,
861 struct class *class)
862{
863 int err;
864 dev_t devno;
865 struct gk20a *g = gk20a_from_dev(dev);
866
867 err = alloc_chrdev_region(&devno, 0, GK20A_NUM_CDEVS, dev_name(dev));
868 if (err) {
869 dev_err(dev, "failed to allocate devno\n");
870 goto fail;
871 }
872 g->cdev_region = devno;
873
874 err = gk20a_create_device(dev, devno++, interface_name, "",
875 &g->channel.cdev, &g->channel.node,
876 &gk20a_channel_ops,
877 class);
878 if (err)
879 goto fail;
880
881 err = gk20a_create_device(dev, devno++, interface_name, "-as",
882 &g->as.cdev, &g->as.node,
883 &gk20a_as_ops,
884 class);
885 if (err)
886 goto fail;
887
888 err = gk20a_create_device(dev, devno++, interface_name, "-ctrl",
889 &g->ctrl.cdev, &g->ctrl.node,
890 &gk20a_ctrl_ops,
891 class);
892 if (err)
893 goto fail;
894
895 err = gk20a_create_device(dev, devno++, interface_name, "-dbg",
896 &g->dbg.cdev, &g->dbg.node,
897 &gk20a_dbg_ops,
898 class);
899 if (err)
900 goto fail;
901
902 err = gk20a_create_device(dev, devno++, interface_name, "-prof",
903 &g->prof.cdev, &g->prof.node,
904 &gk20a_prof_ops,
905 class);
906 if (err)
907 goto fail;
908
909 err = gk20a_create_device(dev, devno++, interface_name, "-tsg",
910 &g->tsg.cdev, &g->tsg.node,
911 &gk20a_tsg_ops,
912 class);
913 if (err)
914 goto fail;
915
916#ifdef CONFIG_GK20A_CTXSW_TRACE
917 err = gk20a_create_device(dev, devno++, interface_name, "-ctxsw",
918 &g->ctxsw.cdev, &g->ctxsw.node,
919 &gk20a_ctxsw_ops,
920 class);
921 if (err)
922 goto fail;
923#endif
924
925 err = gk20a_create_device(dev, devno++, interface_name, "-sched",
926 &g->sched.cdev, &g->sched.node,
927 &gk20a_sched_ops,
928 class);
929 if (err)
930 goto fail;
931
932 return 0;
933fail:
934 gk20a_user_deinit(dev, &nvgpu_class);
935 return err;
936}
937
938static int gk20a_pm_railgate(struct device *dev) 679static int gk20a_pm_railgate(struct device *dev)
939{ 680{
940 struct gk20a_platform *platform = dev_get_drvdata(dev); 681 struct gk20a_platform *platform = dev_get_drvdata(dev);