Commit 7e24c114 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/fuse: remove object accessor functions

Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent 7f5f518f
......@@ -5,6 +5,11 @@
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 *
......
......@@ -30,9 +30,9 @@ struct gf100_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;
......@@ -48,6 +48,10 @@ gf100_fuse_rd32(struct nvkm_object *object, u64 addr)
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,
......@@ -63,6 +67,7 @@ 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;
}
......@@ -74,6 +79,5 @@ gf100_fuse_oclass = {
.dtor = _nvkm_fuse_dtor,
.init = _nvkm_fuse_init,
.fini = _nvkm_fuse_fini,
.rd32 = gf100_fuse_rd32,
},
};
......@@ -24,13 +24,16 @@
#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,
......@@ -43,6 +46,7 @@ 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;
}
......@@ -54,6 +58,5 @@ gm107_fuse_oclass = {
.dtor = _nvkm_fuse_dtor,
.init = _nvkm_fuse_init,
.fini = _nvkm_fuse_fini,
.rd32 = gm107_fuse_rd32,
},
};
......@@ -30,9 +30,9 @@ struct nv50_fuse {
};
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;
......@@ -46,6 +46,10 @@ nv50_fuse_rd32(struct nvkm_object *object, u64 addr)
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,
......@@ -61,6 +65,7 @@ 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;
}
......@@ -72,6 +77,5 @@ nv50_fuse_oclass = {
.dtor = _nvkm_fuse_dtor,
.init = _nvkm_fuse_init,
.fini = _nvkm_fuse_fini,
.rd32 = nv50_fuse_rd32,
},
};
......@@ -32,7 +32,7 @@ g84_temp_get(struct nvkm_therm *therm)
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;
......@@ -45,7 +45,7 @@ g84_sensor_setup(struct nvkm_therm *therm)
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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment