drm/nouveau/device: add direct pointers to subdevs from nvkm_device
[deliverable/linux.git] / drivers / gpu / drm / nouveau / include / nvkm / core / device.h
1 #ifndef __NVKM_DEVICE_H__
2 #define __NVKM_DEVICE_H__
3 #include <core/engine.h>
4 #include <core/event.h>
5
6 struct nvkm_device {
7 struct nvkm_engine engine;
8 struct list_head head;
9
10 struct pci_dev *pdev;
11 struct platform_device *platformdev;
12 u64 handle;
13
14 struct nvkm_event event;
15
16 const char *cfgopt;
17 const char *dbgopt;
18 const char *name;
19 const char *cname;
20 u64 disable_mask;
21
22 enum {
23 NV_04 = 0x04,
24 NV_10 = 0x10,
25 NV_11 = 0x11,
26 NV_20 = 0x20,
27 NV_30 = 0x30,
28 NV_40 = 0x40,
29 NV_50 = 0x50,
30 NV_C0 = 0xc0,
31 NV_E0 = 0xe0,
32 GM100 = 0x110,
33 } card_type;
34 u32 chipset;
35 u8 chiprev;
36 u32 crystal;
37
38 struct nvkm_oclass *oclass[NVDEV_SUBDEV_NR];
39 struct nvkm_object *subdev[NVDEV_SUBDEV_NR];
40
41 struct {
42 struct notifier_block nb;
43 } acpi;
44
45 struct nvkm_bar *bar;
46 struct nvkm_bios *bios;
47 struct nvkm_bus *bus;
48 struct nvkm_clk *clk;
49 struct nvkm_devinit *devinit;
50 struct nvkm_fb *fb;
51 struct nvkm_fuse *fuse;
52 struct nvkm_gpio *gpio;
53 struct nvkm_i2c *i2c;
54 struct nvkm_subdev *ibus;
55 struct nvkm_instmem *imem;
56 struct nvkm_ltc *ltc;
57 struct nvkm_mc *mc;
58 struct nvkm_mmu *mmu;
59 struct nvkm_subdev *mxm;
60 struct nvkm_pmu *pmu;
61 struct nvkm_therm *therm;
62 struct nvkm_timer *timer;
63 struct nvkm_volt *volt;
64
65 struct nvkm_engine *bsp;
66 struct nvkm_engine *ce[3];
67 struct nvkm_engine *cipher;
68 struct nvkm_disp *disp;
69 struct nvkm_dmaeng *dma;
70 struct nvkm_fifo *fifo;
71 struct nvkm_gr *gr;
72 struct nvkm_engine *ifb;
73 struct nvkm_engine *me;
74 struct nvkm_engine *mpeg;
75 struct nvkm_engine *msenc;
76 struct nvkm_engine *mspdec;
77 struct nvkm_engine *msppp;
78 struct nvkm_engine *msvld;
79 struct nvkm_pm *pm;
80 struct nvkm_engine *sec;
81 struct nvkm_sw *sw;
82 struct nvkm_engine *vic;
83 struct nvkm_engine *vp;
84 };
85
86 struct nvkm_device *nvkm_device_find(u64 name);
87 int nvkm_device_list(u64 *name, int size);
88
89 struct nvkm_device *nv_device(void *obj);
90
91 static inline bool
92 nv_device_match(struct nvkm_device *device, u16 dev, u16 ven, u16 sub)
93 {
94 return device->pdev->device == dev &&
95 device->pdev->subsystem_vendor == ven &&
96 device->pdev->subsystem_device == sub;
97 }
98
99 static inline bool
100 nv_device_is_pci(struct nvkm_device *device)
101 {
102 return device->pdev != NULL;
103 }
104
105 static inline bool
106 nv_device_is_cpu_coherent(struct nvkm_device *device)
107 {
108 return (!IS_ENABLED(CONFIG_ARM) && nv_device_is_pci(device));
109 }
110
111 static inline struct device *
112 nv_device_base(struct nvkm_device *device)
113 {
114 return nv_device_is_pci(device) ? &device->pdev->dev :
115 &device->platformdev->dev;
116 }
117
118 resource_size_t
119 nv_device_resource_start(struct nvkm_device *device, unsigned int bar);
120
121 resource_size_t
122 nv_device_resource_len(struct nvkm_device *device, unsigned int bar);
123
124 int
125 nv_device_get_irq(struct nvkm_device *device, bool stall);
126
127 struct platform_device;
128
129 enum nv_bus_type {
130 NVKM_BUS_PCI,
131 NVKM_BUS_PLATFORM,
132 };
133
134 #define nvkm_device_create(p,t,n,s,c,d,u) \
135 nvkm_device_create_((void *)(p), (t), (n), (s), (c), (d), \
136 sizeof(**u), (void **)u)
137 int nvkm_device_create_(void *, enum nv_bus_type type, u64 name,
138 const char *sname, const char *cfg, const char *dbg,
139 int, void **);
140 #endif
This page took 0.033983 seconds and 6 git commands to generate.