1 /* SPDX-License-Identifier: MIT */
2 #ifndef __NVKM_SUBDEV_H__
3 #define __NVKM_SUBDEV_H__
4 #include <core/device.h>
6 enum nvkm_subdev_type {
7 #define NVKM_LAYOUT_ONCE(t,s,p,...) t,
8 #define NVKM_LAYOUT_INST NVKM_LAYOUT_ONCE
9 #include <core/layout.h>
10 #undef NVKM_LAYOUT_INST
11 #undef NVKM_LAYOUT_ONCE
16 const struct nvkm_subdev_func *func;
17 struct nvkm_device *device;
18 enum nvkm_subdev_type type;
22 struct list_head head;
28 struct nvkm_subdev_func {
29 void *(*dtor)(struct nvkm_subdev *);
30 int (*preinit)(struct nvkm_subdev *);
31 int (*oneinit)(struct nvkm_subdev *);
32 int (*info)(struct nvkm_subdev *, u64 mthd, u64 *data);
33 int (*init)(struct nvkm_subdev *);
34 int (*fini)(struct nvkm_subdev *, bool suspend);
35 void (*intr)(struct nvkm_subdev *);
38 extern const char *nvkm_subdev_type[NVKM_SUBDEV_NR];
39 int nvkm_subdev_new_(const struct nvkm_subdev_func *, struct nvkm_device *, enum nvkm_subdev_type,
40 int inst, struct nvkm_subdev **);
41 void nvkm_subdev_ctor(const struct nvkm_subdev_func *, struct nvkm_device *,
42 enum nvkm_subdev_type, int inst, struct nvkm_subdev *);
43 void nvkm_subdev_disable(struct nvkm_device *, enum nvkm_subdev_type, int inst);
44 void nvkm_subdev_del(struct nvkm_subdev **);
45 int nvkm_subdev_preinit(struct nvkm_subdev *);
46 int nvkm_subdev_init(struct nvkm_subdev *);
47 int nvkm_subdev_fini(struct nvkm_subdev *, bool suspend);
48 int nvkm_subdev_info(struct nvkm_subdev *, u64, u64 *);
49 void nvkm_subdev_intr(struct nvkm_subdev *);
52 #define nvkm_printk_(s,l,p,f,a...) do { \
53 const struct nvkm_subdev *_subdev = (s); \
54 if (CONFIG_NOUVEAU_DEBUG >= (l) && _subdev->debug >= (l)) \
55 dev_##p(_subdev->device->dev, "%s: "f, _subdev->name, ##a); \
57 #define nvkm_printk(s,l,p,f,a...) nvkm_printk_((s), NV_DBG_##l, p, f, ##a)
58 #define nvkm_fatal(s,f,a...) nvkm_printk((s), FATAL, crit, f, ##a)
59 #define nvkm_error(s,f,a...) nvkm_printk((s), ERROR, err, f, ##a)
60 #define nvkm_warn(s,f,a...) nvkm_printk((s), WARN, notice, f, ##a)
61 #define nvkm_info(s,f,a...) nvkm_printk((s), INFO, info, f, ##a)
62 #define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, info, f, ##a)
63 #define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, info, f, ##a)
64 #define nvkm_spam(s,f,a...) nvkm_printk((s), SPAM, dbg, f, ##a)