1 /* $NetBSD: subdev.h,v 1.5 2021/12/19 10:51:56 riastradh Exp $ */ 2 3 /* SPDX-License-Identifier: MIT */ 4 #ifndef __NVKM_SUBDEV_H__ 5 #define __NVKM_SUBDEV_H__ 6 #include <core/device.h> 7 8 struct nvkm_subdev { 9 const struct nvkm_subdev_func *func; 10 struct nvkm_device *device; 11 enum nvkm_devidx index; 12 struct mutex mutex; 13 u32 debug; 14 15 bool oneinit; 16 }; 17 18 struct nvkm_subdev_func { 19 void *(*dtor)(struct nvkm_subdev *); 20 int (*preinit)(struct nvkm_subdev *); 21 int (*oneinit)(struct nvkm_subdev *); 22 int (*info)(struct nvkm_subdev *, u64 mthd, u64 *data); 23 int (*init)(struct nvkm_subdev *); 24 int (*fini)(struct nvkm_subdev *, bool suspend); 25 void (*intr)(struct nvkm_subdev *); 26 }; 27 28 extern const char *nvkm_subdev_name[NVKM_SUBDEV_NR]; 29 void nvkm_subdev_ctor(const struct nvkm_subdev_func *, struct nvkm_device *, 30 int index, struct nvkm_subdev *); 31 void nvkm_subdev_del(struct nvkm_subdev **); 32 int nvkm_subdev_preinit(struct nvkm_subdev *); 33 int nvkm_subdev_init(struct nvkm_subdev *); 34 int nvkm_subdev_fini(struct nvkm_subdev *, bool suspend); 35 int nvkm_subdev_info(struct nvkm_subdev *, u64, u64 *); 36 void nvkm_subdev_intr(struct nvkm_subdev *); 37 38 /* subdev logging */ 39 #define nvkm_printk_(s,l,p,f,a...) do { \ 40 const struct nvkm_subdev *_subdev = (s); \ 41 if ((CONFIG_NOUVEAU_DEBUG == (l) || CONFIG_NOUVEAU_DEBUG > (l)) && \ 42 (_subdev->debug == (l) || _subdev->debug > (l))) { \ 43 dev_##p(_subdev->device->dev, "%s: "f, \ 44 nvkm_subdev_name[_subdev->index], ##a); \ 45 } \ 46 } while(0) 47 #define nvkm_printk(s,l,p,f,a...) nvkm_printk_((s), NV_DBG_##l, p, f, ##a) 48 #define nvkm_fatal(s,f,a...) nvkm_printk((s), FATAL, crit, f, ##a) 49 #define nvkm_error(s,f,a...) nvkm_printk((s), ERROR, err, f, ##a) 50 #define nvkm_warn(s,f,a...) nvkm_printk((s), WARN, notice, f, ##a) 51 #define nvkm_info(s,f,a...) nvkm_printk((s), INFO, info, f, ##a) 52 #define nvkm_debug(s,f,a...) nvkm_printk((s), DEBUG, info, f, ##a) 53 #define nvkm_trace(s,f,a...) nvkm_printk((s), TRACE, info, f, ##a) 54 #define nvkm_spam(s,f,a...) nvkm_printk((s), SPAM, dbg, f, ##a) 55 #endif 56