Commit | Line | Data |
---|---|---|
9274f4a9 BS |
1 | #ifndef __NOUVEAU_DEVICE_H__ |
2 | #define __NOUVEAU_DEVICE_H__ | |
3 | ||
4 | #include <core/object.h> | |
5 | #include <core/subdev.h> | |
6 | #include <core/engine.h> | |
ed76a870 | 7 | #include <core/event.h> |
9274f4a9 BS |
8 | |
9 | enum nv_subdev_type { | |
dded35de | 10 | NVDEV_ENGINE_DEVICE, |
9274f4a9 | 11 | NVDEV_SUBDEV_VBIOS, |
7234d023 BS |
12 | |
13 | /* All subdevs from DEVINIT to DEVINIT_LAST will be created before | |
14 | * *any* of them are initialised. This subdev category is used | |
15 | * for any subdevs that the VBIOS init table parsing may call out | |
16 | * to during POST. | |
17 | */ | |
18 | NVDEV_SUBDEV_DEVINIT, | |
c49c0b44 | 19 | NVDEV_SUBDEV_IBUS, |
9274f4a9 BS |
20 | NVDEV_SUBDEV_GPIO, |
21 | NVDEV_SUBDEV_I2C, | |
54ecff3e | 22 | NVDEV_SUBDEV_DEVINIT_LAST = NVDEV_SUBDEV_I2C, |
7234d023 BS |
23 | |
24 | /* This grouping of subdevs are initialised right after they've | |
25 | * been created, and are allowed to assume any subdevs in the | |
26 | * list above them exist and have been initialised. | |
27 | */ | |
3ca6cd43 | 28 | NVDEV_SUBDEV_FUSE, |
9274f4a9 | 29 | NVDEV_SUBDEV_MXM, |
9274f4a9 | 30 | NVDEV_SUBDEV_MC, |
a10220bb | 31 | NVDEV_SUBDEV_BUS, |
9274f4a9 BS |
32 | NVDEV_SUBDEV_TIMER, |
33 | NVDEV_SUBDEV_FB, | |
95484b57 | 34 | NVDEV_SUBDEV_LTC, |
9274f4a9 | 35 | NVDEV_SUBDEV_INSTMEM, |
5ce3bf3c | 36 | NVDEV_SUBDEV_MMU, |
9274f4a9 | 37 | NVDEV_SUBDEV_BAR, |
ebb58dc2 | 38 | NVDEV_SUBDEV_PMU, |
9274f4a9 | 39 | NVDEV_SUBDEV_VOLT, |
9274f4a9 | 40 | NVDEV_SUBDEV_THERM, |
f3867f43 | 41 | NVDEV_SUBDEV_CLK, |
7234d023 | 42 | |
cb1567c2 BS |
43 | NVDEV_ENGINE_FIRST, |
44 | NVDEV_ENGINE_DMAOBJ = NVDEV_ENGINE_FIRST, | |
33f8c6d0 | 45 | NVDEV_ENGINE_IFB, |
9274f4a9 BS |
46 | NVDEV_ENGINE_FIFO, |
47 | NVDEV_ENGINE_SW, | |
48 | NVDEV_ENGINE_GR, | |
49 | NVDEV_ENGINE_MPEG, | |
50 | NVDEV_ENGINE_ME, | |
51 | NVDEV_ENGINE_VP, | |
52 | NVDEV_ENGINE_CRYPT, | |
53 | NVDEV_ENGINE_BSP, | |
54 | NVDEV_ENGINE_PPP, | |
55 | NVDEV_ENGINE_COPY0, | |
56 | NVDEV_ENGINE_COPY1, | |
b0bc5304 | 57 | NVDEV_ENGINE_COPY2, |
c42a7aec | 58 | NVDEV_ENGINE_VIC, |
dbff2dee | 59 | NVDEV_ENGINE_VENC, |
9274f4a9 | 60 | NVDEV_ENGINE_DISP, |
aa4d7a4d | 61 | NVDEV_ENGINE_PERFMON, |
eccf7e8a | 62 | NVDEV_ENGINE_MSVLD, |
7234d023 | 63 | |
9274f4a9 BS |
64 | NVDEV_SUBDEV_NR, |
65 | }; | |
66 | ||
67 | struct nouveau_device { | |
587f7a5b | 68 | struct nouveau_engine engine; |
9274f4a9 BS |
69 | struct list_head head; |
70 | ||
71 | struct pci_dev *pdev; | |
420b9469 | 72 | struct platform_device *platformdev; |
9274f4a9 BS |
73 | u64 handle; |
74 | ||
79ca2770 | 75 | struct nvkm_event event; |
ed76a870 | 76 | |
9274f4a9 BS |
77 | const char *cfgopt; |
78 | const char *dbgopt; | |
79 | const char *name; | |
80 | const char *cname; | |
f0d13e3a | 81 | u64 disable_mask; |
9274f4a9 BS |
82 | |
83 | enum { | |
84 | NV_04 = 0x04, | |
85 | NV_10 = 0x10, | |
4a0ff754 | 86 | NV_11 = 0x11, |
9274f4a9 BS |
87 | NV_20 = 0x20, |
88 | NV_30 = 0x30, | |
89 | NV_40 = 0x40, | |
90 | NV_50 = 0x50, | |
91 | NV_C0 = 0xc0, | |
9274f4a9 | 92 | NV_E0 = 0xe0, |
3f204647 | 93 | GM100 = 0x110, |
9274f4a9 BS |
94 | } card_type; |
95 | u32 chipset; | |
3704791d | 96 | u8 chiprev; |
9274f4a9 BS |
97 | u32 crystal; |
98 | ||
99 | struct nouveau_oclass *oclass[NVDEV_SUBDEV_NR]; | |
100 | struct nouveau_object *subdev[NVDEV_SUBDEV_NR]; | |
ed76a870 BS |
101 | |
102 | struct { | |
103 | struct notifier_block nb; | |
104 | } acpi; | |
9274f4a9 BS |
105 | }; |
106 | ||
803c1787 BS |
107 | int nouveau_device_list(u64 *name, int size); |
108 | ||
a38f37a7 | 109 | struct nouveau_device *nv_device(void *obj); |
9274f4a9 BS |
110 | |
111 | static inline bool | |
112 | nv_device_match(struct nouveau_object *object, u16 dev, u16 ven, u16 sub) | |
113 | { | |
114 | struct nouveau_device *device = nv_device(object); | |
115 | return device->pdev->device == dev && | |
116 | device->pdev->subsystem_vendor == ven && | |
117 | device->pdev->subsystem_device == sub; | |
118 | } | |
119 | ||
420b9469 AC |
120 | static inline bool |
121 | nv_device_is_pci(struct nouveau_device *device) | |
122 | { | |
123 | return device->pdev != NULL; | |
124 | } | |
125 | ||
c5d7ddf7 AC |
126 | static inline bool |
127 | nv_device_is_cpu_coherent(struct nouveau_device *device) | |
128 | { | |
129 | return (!IS_ENABLED(CONFIG_ARM) && nv_device_is_pci(device)); | |
130 | } | |
131 | ||
420b9469 AC |
132 | static inline struct device * |
133 | nv_device_base(struct nouveau_device *device) | |
134 | { | |
135 | return nv_device_is_pci(device) ? &device->pdev->dev : | |
136 | &device->platformdev->dev; | |
137 | } | |
138 | ||
139 | resource_size_t | |
140 | nv_device_resource_start(struct nouveau_device *device, unsigned int bar); | |
141 | ||
142 | resource_size_t | |
143 | nv_device_resource_len(struct nouveau_device *device, unsigned int bar); | |
144 | ||
420b9469 AC |
145 | int |
146 | nv_device_get_irq(struct nouveau_device *device, bool stall); | |
147 | ||
9274f4a9 | 148 | #endif |