u32 reserved;
int (*alloc)(struct nvkm_instmem *, struct nvkm_object *,
u32 size, u32 align, struct nvkm_object **);
+
+ const struct nvkm_instmem_func *func;
+};
+
+struct nvkm_instmem_func {
+ u32 (*rd32)(struct nvkm_instmem *, u32 addr);
+ void (*wr32)(struct nvkm_instmem *, u32 addr, u32 data);
};
static inline struct nvkm_instmem *
{
struct nvkm_instmem *imem = nvkm_instmem(object);
u32 inst = *(u32 *)args << 4;
- return nv_ro32(imem, inst);
+ return imem->func->rd32(imem, inst);
}
static int
struct nvkm_device *device = mpeg->base.engine.subdev.device;
struct nvkm_instmem *imem = device->imem;
u32 inst = *(u32 *)arg << 4;
- u32 dma0 = nv_ro32(imem, inst + 0);
- u32 dma1 = nv_ro32(imem, inst + 4);
- u32 dma2 = nv_ro32(imem, inst + 8);
+ u32 dma0 = imem->func->rd32(imem, inst + 0);
+ u32 dma1 = imem->func->rd32(imem, inst + 4);
+ u32 dma2 = imem->func->rd32(imem, inst + 8);
u32 base = (dma2 & 0xfffff000) | (dma0 >> 20);
u32 size = dma1 + 1;
struct nvkm_device *device = mpeg->base.engine.subdev.device;
struct nvkm_instmem *imem = device->imem;
u32 inst = *(u32 *)arg << 4;
- u32 dma0 = nv_ro32(imem, inst + 0);
- u32 dma1 = nv_ro32(imem, inst + 4);
- u32 dma2 = nv_ro32(imem, inst + 8);
+ u32 dma0 = imem->func->rd32(imem, inst + 0);
+ u32 dma1 = imem->func->rd32(imem, inst + 4);
+ u32 dma2 = imem->func->rd32(imem, inst + 8);
u32 base = (dma2 & 0xfffff000) | (dma0 >> 20);
u32 size = dma1 + 1;
static u32
nv04_instobj_rd32(struct nvkm_object *object, u64 addr)
{
- struct nv04_instmem *imem = (void *)nvkm_instmem(object);
+ struct nvkm_instmem *imem = nvkm_instmem(object);
struct nv04_instobj *node = (void *)object;
- return nv_ro32(imem, node->mem->offset + addr);
+ return imem->func->rd32(imem, node->mem->offset + addr);
}
static void
nv04_instobj_wr32(struct nvkm_object *object, u64 addr, u32 data)
{
- struct nv04_instmem *imem = (void *)nvkm_instmem(object);
+ struct nvkm_instmem *imem = nvkm_instmem(object);
struct nv04_instobj *node = (void *)object;
- nv_wo32(imem, node->mem->offset + addr, data);
+ imem->func->wr32(imem, node->mem->offset + addr, data);
}
static void
*****************************************************************************/
static u32
-nv04_instmem_rd32(struct nvkm_object *object, u64 addr)
+nv04_instmem_rd32(struct nvkm_instmem *imem, u32 addr)
{
- struct nvkm_instmem *imem = (void *)object;
return nvkm_rd32(imem->subdev.device, 0x700000 + addr);
}
static void
-nv04_instmem_wr32(struct nvkm_object *object, u64 addr, u32 data)
+nv04_instmem_wr32(struct nvkm_instmem *imem, u32 addr, u32 data)
{
- struct nvkm_instmem *imem = (void *)object;
nvkm_wr32(imem->subdev.device, 0x700000 + addr, data);
}
nvkm_instmem_destroy(&imem->base);
}
+static const struct nvkm_instmem_func
+nv04_instmem_func = {
+ .rd32 = nv04_instmem_rd32,
+ .wr32 = nv04_instmem_wr32,
+};
+
static int
nv04_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
if (ret)
return ret;
+ imem->base.func = &nv04_instmem_func;
+
/* PRAMIN aperture maps over the end of VRAM, reserve it */
imem->base.reserved = 512 * 1024;
.dtor = nv04_instmem_dtor,
.init = _nvkm_instmem_init,
.fini = _nvkm_instmem_fini,
- .rd32 = nv04_instmem_rd32,
- .wr32 = nv04_instmem_wr32,
},
.instobj = &nv04_instobj_oclass.base,
}.base;
*****************************************************************************/
static u32
-nv40_instmem_rd32(struct nvkm_object *object, u64 addr)
+nv40_instmem_rd32(struct nvkm_instmem *obj, u32 addr)
{
- struct nv04_instmem *imem = (void *)object;
+ struct nv04_instmem *imem = container_of(obj, typeof(*imem), base);
return ioread32_native(imem->iomem + addr);
}
static void
-nv40_instmem_wr32(struct nvkm_object *object, u64 addr, u32 data)
+nv40_instmem_wr32(struct nvkm_instmem *obj, u32 addr, u32 data)
{
- struct nv04_instmem *imem = (void *)object;
+ struct nv04_instmem *imem = container_of(obj, typeof(*imem), base);
iowrite32_native(data, imem->iomem + addr);
}
+static const struct nvkm_instmem_func
+nv40_instmem_func = {
+ .rd32 = nv40_instmem_rd32,
+ .wr32 = nv40_instmem_wr32,
+};
+
static int
nv40_instmem_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
struct nvkm_oclass *oclass, void *data, u32 size,
if (ret)
return ret;
+ imem->base.func = &nv40_instmem_func;
+
/* map bar */
if (nv_device_resource_len(device, 2))
bar = 2;
.dtor = nv04_instmem_dtor,
.init = _nvkm_instmem_init,
.fini = _nvkm_instmem_fini,
- .rd32 = nv40_instmem_rd32,
- .wr32 = nv40_instmem_wr32,
},
.instobj = &nv04_instobj_oclass.base,
}.base;