struct nvkm_fuse {
struct nvkm_subdev subdev;
+ const struct nvkm_fuse_func *func;
+};
+
+struct nvkm_fuse_func {
+ u32 (*read)(struct nvkm_fuse *, u32 addr);
};
static inline struct nvkm_fuse *
};
static u32
-gf100_fuse_rd32(struct nvkm_object *object, u64 addr)
+gf100_fuse_read(struct nvkm_fuse *obj, u32 addr)
{
- struct gf100_fuse *fuse = (void *)object;
+ struct gf100_fuse *fuse = container_of(obj, typeof(*fuse), base);
struct nvkm_device *device = fuse->base.subdev.device;
unsigned long flags;
u32 fuse_enable, unk, val;
return val;
}
+static const struct nvkm_fuse_func
+gf100_fuse_func = {
+ .read = gf100_fuse_read,
+};
static int
gf100_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
return ret;
spin_lock_init(&fuse->fuse_enable_lock);
+ fuse->base.func = &gf100_fuse_func;
return 0;
}
.dtor = _nvkm_fuse_dtor,
.init = _nvkm_fuse_init,
.fini = _nvkm_fuse_fini,
- .rd32 = gf100_fuse_rd32,
},
};
#include "priv.h"
static u32
-gm107_fuse_rd32(struct nvkm_object *object, u64 addr)
+gm107_fuse_read(struct nvkm_fuse *fuse, u32 addr)
{
- struct nvkm_fuse *fuse = (void *)object;
struct nvkm_device *device = fuse->subdev.device;
return nvkm_rd32(device, 0x21100 + addr);
}
+static const struct nvkm_fuse_func
+gm107_fuse_func = {
+ .read = gm107_fuse_read,
+};
static int
gm107_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
ret = nvkm_fuse_create(parent, engine, oclass, &fuse);
*pobject = nv_object(fuse);
+ fuse->func = &gm107_fuse_func;
return ret;
}
.dtor = _nvkm_fuse_dtor,
.init = _nvkm_fuse_init,
.fini = _nvkm_fuse_fini,
- .rd32 = gm107_fuse_rd32,
},
};
};
static u32
-nv50_fuse_rd32(struct nvkm_object *object, u64 addr)
+nv50_fuse_read(struct nvkm_fuse *obj, u32 addr)
{
- struct nv50_fuse *fuse = (void *)object;
+ struct nv50_fuse *fuse = container_of(obj, typeof(*fuse), base);
struct nvkm_device *device = fuse->base.subdev.device;
unsigned long flags;
u32 fuse_enable, val;
return val;
}
+static const struct nvkm_fuse_func
+nv50_fuse_func = {
+ .read = &nv50_fuse_read,
+};
static int
nv50_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
return ret;
spin_lock_init(&fuse->fuse_enable_lock);
+ fuse->base.func = &nv50_fuse_func;
return 0;
}
.dtor = _nvkm_fuse_dtor,
.init = _nvkm_fuse_init,
.fini = _nvkm_fuse_fini,
- .rd32 = nv50_fuse_rd32,
},
};
struct nvkm_device *device = therm->subdev.device;
struct nvkm_fuse *fuse = nvkm_fuse(therm);
- if (nv_ro32(fuse, 0x1a8) == 1)
+ if (fuse->func->read(fuse, 0x1a8) == 1)
return nvkm_rd32(device, 0x20400);
else
return -ENODEV;
struct nvkm_fuse *fuse = nvkm_fuse(therm);
/* enable temperature reading for cards with insane defaults */
- if (nv_ro32(fuse, 0x1a8) == 1) {
+ if (fuse->func->read(fuse, 0x1a8) == 1) {
nvkm_mask(device, 0x20008, 0x80008000, 0x80000000);
nvkm_mask(device, 0x2000c, 0x80000003, 0x00000000);
mdelay(20); /* wait for the temperature to stabilize */