From: Ben Skeggs Date: Thu, 20 Aug 2015 04:54:08 +0000 (+1000) Subject: drm/nouveau/device: type-safe register accessor macros X-Git-Tag: v4.3-rc1~75^2~11^2~213 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=dd64694208d7c902ba7a5bcd2bf012c1087ba0f0;p=karo-tx-linux.git drm/nouveau/device: type-safe register accessor macros 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 --- diff --git a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h index 4ae876096c7d..167a0dd94fe2 100644 --- a/drivers/gpu/drm/nouveau/include/nvkm/core/device.h +++ b/drivers/gpu/drm/nouveau/include/nvkm/core/device.h @@ -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