drm/nouveau/device: type-safe register accessor macros
authorBen Skeggs <bskeggs@redhat.com>
Thu, 20 Aug 2015 04:54:08 +0000 (14:54 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Fri, 28 Aug 2015 02:40:13 +0000 (12:40 +1000)
These require an explit struct nvkm_device pointer, unlike the previous
macros which take a void *, and assume it's any old nvkm_subdev.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/include/nvkm/core/device.h

index 4ae876096c7d1aae45bb6aa19fc444bc4b921862..167a0dd94fe28b8f0097187273cdc2ba15c185c1 100644 (file)
@@ -147,6 +147,20 @@ struct nvkm_device {
 struct nvkm_device *nvkm_device_find(u64 name);
 int nvkm_device_list(u64 *name, int size);
 
+/* privileged register interface accessor macros */
+#define nvkm_rd08(d,a) ioread8((d)->engine.subdev.mmio + (a))
+#define nvkm_rd16(d,a) ioread16_native((d)->engine.subdev.mmio + (a))
+#define nvkm_rd32(d,a) ioread32_native((d)->engine.subdev.mmio + (a))
+#define nvkm_wr08(d,a,v) iowrite8((v), (d)->engine.subdev.mmio + (a))
+#define nvkm_wr16(d,a,v) iowrite16_native((v), (d)->engine.subdev.mmio + (a))
+#define nvkm_wr32(d,a,v) iowrite32_native((v), (d)->engine.subdev.mmio + (a))
+#define nvkm_mask(d,a,m,v) ({                                                  \
+       struct nvkm_device *_device = (d);                                     \
+       u32 _addr = (a), _temp = nvkm_rd32(_device, _addr);                    \
+       nvkm_wr32(_device, _addr, (_temp & ~(m)) | (v));                       \
+       _temp;                                                                 \
+})
+
 struct nvkm_device *nv_device(void *obj);
 
 static inline bool