drm/nouveau/therm: implement automatic fan management
[deliverable/linux.git] / drivers / gpu / drm / nouveau / core / include / core / device.h
CommitLineData
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>
7
8enum nv_subdev_type {
9 NVDEV_SUBDEV_DEVICE,
10 NVDEV_SUBDEV_VBIOS,
7234d023
BS
11
12 /* All subdevs from DEVINIT to DEVINIT_LAST will be created before
13 * *any* of them are initialised. This subdev category is used
14 * for any subdevs that the VBIOS init table parsing may call out
15 * to during POST.
16 */
17 NVDEV_SUBDEV_DEVINIT,
9274f4a9
BS
18 NVDEV_SUBDEV_GPIO,
19 NVDEV_SUBDEV_I2C,
20 NVDEV_SUBDEV_CLOCK,
7234d023
BS
21 NVDEV_SUBDEV_DEVINIT_LAST = NVDEV_SUBDEV_CLOCK,
22
23 /* This grouping of subdevs are initialised right after they've
24 * been created, and are allowed to assume any subdevs in the
25 * list above them exist and have been initialised.
26 */
9274f4a9 27 NVDEV_SUBDEV_MXM,
9274f4a9
BS
28 NVDEV_SUBDEV_MC,
29 NVDEV_SUBDEV_TIMER,
30 NVDEV_SUBDEV_FB,
31 NVDEV_SUBDEV_LTCG,
2c1a425e 32 NVDEV_SUBDEV_IBUS,
9274f4a9
BS
33 NVDEV_SUBDEV_INSTMEM,
34 NVDEV_SUBDEV_VM,
35 NVDEV_SUBDEV_BAR,
36 NVDEV_SUBDEV_VOLT,
9274f4a9 37 NVDEV_SUBDEV_THERM,
7234d023 38
9274f4a9
BS
39 NVDEV_ENGINE_DMAOBJ,
40 NVDEV_ENGINE_FIFO,
41 NVDEV_ENGINE_SW,
42 NVDEV_ENGINE_GR,
43 NVDEV_ENGINE_MPEG,
44 NVDEV_ENGINE_ME,
45 NVDEV_ENGINE_VP,
46 NVDEV_ENGINE_CRYPT,
47 NVDEV_ENGINE_BSP,
48 NVDEV_ENGINE_PPP,
49 NVDEV_ENGINE_COPY0,
50 NVDEV_ENGINE_COPY1,
51 NVDEV_ENGINE_UNK1C1,
dbff2dee 52 NVDEV_ENGINE_VENC,
9274f4a9 53 NVDEV_ENGINE_DISP,
7234d023 54
9274f4a9
BS
55 NVDEV_SUBDEV_NR,
56};
57
58struct nouveau_device {
59 struct nouveau_subdev base;
60 struct list_head head;
61
62 struct pci_dev *pdev;
63 u64 handle;
64
65 const char *cfgopt;
66 const char *dbgopt;
67 const char *name;
68 const char *cname;
69
70 enum {
71 NV_04 = 0x04,
72 NV_10 = 0x10,
73 NV_20 = 0x20,
74 NV_30 = 0x30,
75 NV_40 = 0x40,
76 NV_50 = 0x50,
77 NV_C0 = 0xc0,
78 NV_D0 = 0xd0,
79 NV_E0 = 0xe0,
80 } card_type;
81 u32 chipset;
82 u32 crystal;
83
84 struct nouveau_oclass *oclass[NVDEV_SUBDEV_NR];
85 struct nouveau_object *subdev[NVDEV_SUBDEV_NR];
86};
87
88static inline struct nouveau_device *
89nv_device(void *obj)
90{
91 struct nouveau_object *object = nv_object(obj);
92 struct nouveau_object *device = object;
93
94 if (device->engine)
95 device = device->engine;
96 if (device->parent)
97 device = device->parent;
98
99#if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
100 if (unlikely(!nv_iclass(device, NV_SUBDEV_CLASS) ||
101 (nv_hclass(device) & 0xff) != NVDEV_SUBDEV_DEVICE)) {
102 nv_assert("BAD CAST -> NvDevice, 0x%08x 0x%08x",
103 nv_hclass(object), nv_hclass(device));
104 }
105#endif
106
107 return (void *)device;
108}
109
110static inline struct nouveau_subdev *
111nouveau_subdev(void *obj, int sub)
112{
113 if (nv_device(obj)->subdev[sub])
114 return nv_subdev(nv_device(obj)->subdev[sub]);
115 return NULL;
116}
117
118static inline struct nouveau_engine *
119nouveau_engine(void *obj, int sub)
120{
121 struct nouveau_subdev *subdev = nouveau_subdev(obj, sub);
122 if (subdev && nv_iclass(subdev, NV_ENGINE_CLASS))
123 return nv_engine(subdev);
124 return NULL;
125}
126
127static inline bool
128nv_device_match(struct nouveau_object *object, u16 dev, u16 ven, u16 sub)
129{
130 struct nouveau_device *device = nv_device(object);
131 return device->pdev->device == dev &&
132 device->pdev->subsystem_vendor == ven &&
133 device->pdev->subsystem_device == sub;
134}
135
136#endif
This page took 0.055424 seconds and 5 git commands to generate.