1 #ifndef __NOUVEAU_DEVICE_H__
2 #define __NOUVEAU_DEVICE_H__
4 #include <core/object.h>
5 #include <core/subdev.h>
6 #include <core/engine.h>
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
20 NVDEV_SUBDEV_DEVINIT_LAST
= NVDEV_SUBDEV_I2C
,
22 /* This grouping of subdevs are initialised right after they've
23 * been created, and are allowed to assume any subdevs in the
24 * list above them exist and have been initialised.
42 NVDEV_ENGINE_DMAOBJ
= NVDEV_ENGINE_FIRST
,
63 struct nouveau_device
{
64 struct nouveau_engine base
;
65 struct list_head head
;
91 struct nouveau_oclass
*oclass
[NVDEV_SUBDEV_NR
];
92 struct nouveau_object
*subdev
[NVDEV_SUBDEV_NR
];
95 static inline struct nouveau_device
*
98 struct nouveau_object
*object
= nv_object(obj
);
99 struct nouveau_object
*device
= object
;
102 device
= device
->engine
;
104 device
= device
->parent
;
106 #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
107 if (unlikely(!nv_iclass(device
, NV_SUBDEV_CLASS
) ||
108 (nv_hclass(device
) & 0xff) != NVDEV_ENGINE_DEVICE
)) {
109 nv_assert("BAD CAST -> NvDevice, 0x%08x 0x%08x",
110 nv_hclass(object
), nv_hclass(device
));
114 return (void *)device
;
117 static inline struct nouveau_subdev
*
118 nouveau_subdev(void *obj
, int sub
)
120 if (nv_device(obj
)->subdev
[sub
])
121 return nv_subdev(nv_device(obj
)->subdev
[sub
]);
125 static inline struct nouveau_engine
*
126 nouveau_engine(void *obj
, int sub
)
128 struct nouveau_subdev
*subdev
= nouveau_subdev(obj
, sub
);
129 if (subdev
&& nv_iclass(subdev
, NV_ENGINE_CLASS
))
130 return nv_engine(subdev
);
135 nv_device_match(struct nouveau_object
*object
, u16 dev
, u16 ven
, u16 sub
)
137 struct nouveau_device
*device
= nv_device(object
);
138 return device
->pdev
->device
== dev
&&
139 device
->pdev
->subsystem_vendor
== ven
&&
140 device
->pdev
->subsystem_device
== sub
;