Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
subdev.h
Go to the documentation of this file.
1 #ifndef __NOUVEAU_SUBDEV_H__
2 #define __NOUVEAU_SUBDEV_H__
3 
4 #include <core/object.h>
5 
6 #define NV_SUBDEV_(sub,var) (NV_SUBDEV_CLASS | ((var) << 8) | (sub))
7 #define NV_SUBDEV(name,var) NV_SUBDEV_(NVDEV_SUBDEV_##name, (var))
8 
9 struct nouveau_subdev {
11  struct mutex mutex;
12  const char *name;
13  void __iomem *mmio;
16 
17  void (*intr)(struct nouveau_subdev *);
18 };
19 
20 static inline struct nouveau_subdev *
21 nv_subdev(void *obj)
22 {
23 #if CONFIG_NOUVEAU_DEBUG >= NV_DBG_PARANOIA
25  nv_assert("BAD CAST -> NvSubDev, %08x", nv_hclass(obj));
26 #endif
27  return obj;
28 }
29 
30 static inline int
31 nv_subidx(struct nouveau_object *object)
32 {
33  return nv_hclass(nv_subdev(object)) & 0xff;
34 }
35 
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)
39 
41  struct nouveau_oclass *, u32 pclass,
42  const char *sname, const char *fname,
43  int size, void **);
46 int nouveau_subdev_fini(struct nouveau_subdev *, bool suspend);
48 
51 int _nouveau_subdev_fini(struct nouveau_object *, bool suspend);
52 
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); \
56  } \
57 } while(0)
58 
59 static inline u8
60 nv_rd08(void *obj, u32 addr)
61 {
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);
65  return data;
66 }
67 
68 static inline u16
69 nv_rd16(void *obj, u32 addr)
70 {
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);
74  return data;
75 }
76 
77 static inline u32
78 nv_rd32(void *obj, u32 addr)
79 {
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);
83  return data;
84 }
85 
86 static inline void
87 nv_wr08(void *obj, u32 addr, u8 data)
88 {
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);
92 }
93 
94 static inline void
95 nv_wr16(void *obj, u32 addr, u16 data)
96 {
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);
100 }
101 
102 static inline void
103 nv_wr32(void *obj, u32 addr, u32 data)
104 {
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);
108 }
109 
110 static inline u32
111 nv_mask(void *obj, u32 addr, u32 mask, u32 data)
112 {
113  u32 temp = nv_rd32(obj, addr);
114  nv_wr32(obj, addr, (temp & ~mask) | data);
115  return temp;
116 }
117 
118 #endif