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 @@ ...@@ -5,6 +5,11 @@
struct nvkm_fuse { struct nvkm_fuse {
struct nvkm_subdev subdev; 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 inline struct nvkm_fuse *
......
...@@ -30,9 +30,9 @@ struct gf100_fuse { ...@@ -30,9 +30,9 @@ struct gf100_fuse {
}; };
static u32 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; struct nvkm_device *device = fuse->base.subdev.device;
unsigned long flags; unsigned long flags;
u32 fuse_enable, unk, val; u32 fuse_enable, unk, val;
...@@ -48,6 +48,10 @@ gf100_fuse_rd32(struct nvkm_object *object, u64 addr) ...@@ -48,6 +48,10 @@ gf100_fuse_rd32(struct nvkm_object *object, u64 addr)
return val; return val;
} }
static const struct nvkm_fuse_func
gf100_fuse_func = {
.read = gf100_fuse_read,
};
static int static int
gf100_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine, 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, ...@@ -63,6 +67,7 @@ gf100_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
return ret; return ret;
spin_lock_init(&fuse->fuse_enable_lock); spin_lock_init(&fuse->fuse_enable_lock);
fuse->base.func = &gf100_fuse_func;
return 0; return 0;
} }
...@@ -74,6 +79,5 @@ gf100_fuse_oclass = { ...@@ -74,6 +79,5 @@ gf100_fuse_oclass = {
.dtor = _nvkm_fuse_dtor, .dtor = _nvkm_fuse_dtor,
.init = _nvkm_fuse_init, .init = _nvkm_fuse_init,
.fini = _nvkm_fuse_fini, .fini = _nvkm_fuse_fini,
.rd32 = gf100_fuse_rd32,
}, },
}; };
...@@ -24,13 +24,16 @@ ...@@ -24,13 +24,16 @@
#include "priv.h" #include "priv.h"
static u32 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; struct nvkm_device *device = fuse->subdev.device;
return nvkm_rd32(device, 0x21100 + addr); return nvkm_rd32(device, 0x21100 + addr);
} }
static const struct nvkm_fuse_func
gm107_fuse_func = {
.read = gm107_fuse_read,
};
static int static int
gm107_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine, 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, ...@@ -43,6 +46,7 @@ gm107_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
ret = nvkm_fuse_create(parent, engine, oclass, &fuse); ret = nvkm_fuse_create(parent, engine, oclass, &fuse);
*pobject = nv_object(fuse); *pobject = nv_object(fuse);
fuse->func = &gm107_fuse_func;
return ret; return ret;
} }
...@@ -54,6 +58,5 @@ gm107_fuse_oclass = { ...@@ -54,6 +58,5 @@ gm107_fuse_oclass = {
.dtor = _nvkm_fuse_dtor, .dtor = _nvkm_fuse_dtor,
.init = _nvkm_fuse_init, .init = _nvkm_fuse_init,
.fini = _nvkm_fuse_fini, .fini = _nvkm_fuse_fini,
.rd32 = gm107_fuse_rd32,
}, },
}; };
...@@ -30,9 +30,9 @@ struct nv50_fuse { ...@@ -30,9 +30,9 @@ struct nv50_fuse {
}; };
static u32 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; struct nvkm_device *device = fuse->base.subdev.device;
unsigned long flags; unsigned long flags;
u32 fuse_enable, val; u32 fuse_enable, val;
...@@ -46,6 +46,10 @@ nv50_fuse_rd32(struct nvkm_object *object, u64 addr) ...@@ -46,6 +46,10 @@ nv50_fuse_rd32(struct nvkm_object *object, u64 addr)
return val; return val;
} }
static const struct nvkm_fuse_func
nv50_fuse_func = {
.read = &nv50_fuse_read,
};
static int static int
nv50_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine, 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, ...@@ -61,6 +65,7 @@ nv50_fuse_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
return ret; return ret;
spin_lock_init(&fuse->fuse_enable_lock); spin_lock_init(&fuse->fuse_enable_lock);
fuse->base.func = &nv50_fuse_func;
return 0; return 0;
} }
...@@ -72,6 +77,5 @@ nv50_fuse_oclass = { ...@@ -72,6 +77,5 @@ nv50_fuse_oclass = {
.dtor = _nvkm_fuse_dtor, .dtor = _nvkm_fuse_dtor,
.init = _nvkm_fuse_init, .init = _nvkm_fuse_init,
.fini = _nvkm_fuse_fini, .fini = _nvkm_fuse_fini,
.rd32 = nv50_fuse_rd32,
}, },
}; };
...@@ -32,7 +32,7 @@ g84_temp_get(struct nvkm_therm *therm) ...@@ -32,7 +32,7 @@ g84_temp_get(struct nvkm_therm *therm)
struct nvkm_device *device = therm->subdev.device; struct nvkm_device *device = therm->subdev.device;
struct nvkm_fuse *fuse = nvkm_fuse(therm); 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); return nvkm_rd32(device, 0x20400);
else else
return -ENODEV; return -ENODEV;
...@@ -45,7 +45,7 @@ g84_sensor_setup(struct nvkm_therm *therm) ...@@ -45,7 +45,7 @@ g84_sensor_setup(struct nvkm_therm *therm)
struct nvkm_fuse *fuse = nvkm_fuse(therm); struct nvkm_fuse *fuse = nvkm_fuse(therm);
/* enable temperature reading for cards with insane defaults */ /* 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, 0x20008, 0x80008000, 0x80000000);
nvkm_mask(device, 0x2000c, 0x80000003, 0x00000000); nvkm_mask(device, 0x2000c, 0x80000003, 0x00000000);
mdelay(20); /* wait for the temperature to stabilize */ 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