1 #ifndef __NOUVEAU_SUBDEV_H__
2 #define __NOUVEAU_SUBDEV_H__
4 #include <core/object.h>
6 #define NV_SUBDEV_(sub,var) (NV_SUBDEV_CLASS | ((var) << 8) | (sub))
7 #define NV_SUBDEV(name,var) NV_SUBDEV_(NVDEV_SUBDEV_##name, (var))
9 struct nouveau_subdev {
10 struct nouveau_object base;
17 void (*intr)(struct nouveau_subdev *);
20 static inline struct nouveau_subdev *
23 #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
24 if (unlikely(!nv_iclass(obj, NV_SUBDEV_CLASS)))
25 nv_assert("BAD CAST -> NvSubDev, %08x", nv_hclass(obj));
31 nv_subidx(struct nouveau_object *object)
33 return nv_hclass(nv_subdev(object)) & 0xff;
36 #define nouveau_subdev_create(p,e,o,v,s,f,d) \
37 nouveau_subdev_create_((p), (e), (o), (v), (s), (f), \
38 sizeof(**d),(void **)d)
40 int nouveau_subdev_create_(struct nouveau_object *, struct nouveau_object *,
41 struct nouveau_oclass *, u32 pclass,
42 const char *sname, const char *fname,
44 void nouveau_subdev_destroy(struct nouveau_subdev *);
45 int nouveau_subdev_init(struct nouveau_subdev *);
46 int nouveau_subdev_fini(struct nouveau_subdev *, bool suspend);
47 void nouveau_subdev_reset(struct nouveau_object *);
49 void _nouveau_subdev_dtor(struct nouveau_object *);
50 int _nouveau_subdev_init(struct nouveau_object *);
51 int _nouveau_subdev_fini(struct nouveau_object *, bool suspend);
53 #define s_printk(s,l,f,a...) do { \
54 if ((s)->debug >= OS_DBG_##l) { \
55 nv_printk((s)->base.parent, (s)->name, l, f, ##a); \
60 nv_rd08(void *obj, u32 addr)
62 struct nouveau_subdev *subdev = nv_subdev(obj);
63 u8 data = ioread8(subdev->mmio + addr);
64 nv_spam(subdev, "nv_rd08 0x%06x 0x%02x\n", addr, data);
69 nv_rd16(void *obj, u32 addr)
71 struct nouveau_subdev *subdev = nv_subdev(obj);
72 u16 data = ioread16_native(subdev->mmio + addr);
73 nv_spam(subdev, "nv_rd16 0x%06x 0x%04x\n", addr, data);
78 nv_rd32(void *obj, u32 addr)
80 struct nouveau_subdev *subdev = nv_subdev(obj);
81 u32 data = ioread32_native(subdev->mmio + addr);
82 nv_spam(subdev, "nv_rd32 0x%06x 0x%08x\n", addr, data);
87 nv_wr08(void *obj, u32 addr, u8 data)
89 struct nouveau_subdev *subdev = nv_subdev(obj);
90 nv_spam(subdev, "nv_wr08 0x%06x 0x%02x\n", addr, data);
91 iowrite8(data, subdev->mmio + addr);
95 nv_wr16(void *obj, u32 addr, u16 data)
97 struct nouveau_subdev *subdev = nv_subdev(obj);
98 nv_spam(subdev, "nv_wr16 0x%06x 0x%04x\n", addr, data);
99 iowrite16_native(data, subdev->mmio + addr);
103 nv_wr32(void *obj, u32 addr, u32 data)
105 struct nouveau_subdev *subdev = nv_subdev(obj);
106 nv_spam(subdev, "nv_wr32 0x%06x 0x%08x\n", addr, data);
107 iowrite32_native(data, subdev->mmio + addr);
111 nv_mask(void *obj, u32 addr, u32 mask, u32 data)
113 u32 temp = nv_rd32(obj, addr);
114 nv_wr32(obj, addr, (temp & ~mask) | data);