Commit fcb371a1 authored by Ben Skeggs's avatar Ben Skeggs

drm/nouveau/fb/gf100-: modify constructors to allow more customisation

GF108/GM107 implementations will want slightly different functions for
the upcoming RAM detection improvements.
Signed-off-by: default avatarBen Skeggs <bskeggs@redhat.com>
parent df8dc97c
...@@ -19,13 +19,24 @@ int nv50_ram_get(struct nvkm_ram *, u64, u32, u32, u32, struct nvkm_mem **); ...@@ -19,13 +19,24 @@ int nv50_ram_get(struct nvkm_ram *, u64, u32, u32, u32, struct nvkm_mem **);
void nv50_ram_put(struct nvkm_ram *, struct nvkm_mem **); void nv50_ram_put(struct nvkm_ram *, struct nvkm_mem **);
void __nv50_ram_put(struct nvkm_ram *, struct nvkm_mem *); void __nv50_ram_put(struct nvkm_ram *, struct nvkm_mem *);
int gf100_ram_new_(const struct nvkm_ram_func *, struct nvkm_fb *,
struct nvkm_ram **);
int gf100_ram_ctor(const struct nvkm_ram_func *, struct nvkm_fb *, int gf100_ram_ctor(const struct nvkm_ram_func *, struct nvkm_fb *,
u32, struct nvkm_ram *); u32, struct nvkm_ram *);
int gf100_ram_get(struct nvkm_ram *, u64, u32, u32, u32, struct nvkm_mem **); int gf100_ram_get(struct nvkm_ram *, u64, u32, u32, u32, struct nvkm_mem **);
void gf100_ram_put(struct nvkm_ram *, struct nvkm_mem **); void gf100_ram_put(struct nvkm_ram *, struct nvkm_mem **);
int gf100_ram_init(struct nvkm_ram *);
int gf100_ram_calc(struct nvkm_ram *, u32);
int gf100_ram_prog(struct nvkm_ram *);
void gf100_ram_tidy(struct nvkm_ram *);
int gk104_ram_ctor(struct nvkm_fb *, struct nvkm_ram **, u32); int gk104_ram_new_(const struct nvkm_ram_func *, struct nvkm_fb *,
int gk104_ram_init(struct nvkm_ram *ram); struct nvkm_ram **, u32);
void *gk104_ram_dtor(struct nvkm_ram *);
int gk104_ram_init(struct nvkm_ram *);
int gk104_ram_calc(struct nvkm_ram *, u32);
int gk104_ram_prog(struct nvkm_ram *);
void gk104_ram_tidy(struct nvkm_ram *);
/* RAM type-specific MR calculation routines */ /* RAM type-specific MR calculation routines */
int nvkm_sddr2_calc(struct nvkm_ram *); int nvkm_sddr2_calc(struct nvkm_ram *);
......
...@@ -124,7 +124,7 @@ gf100_ram_train(struct gf100_ramfuc *fuc, u32 magic) ...@@ -124,7 +124,7 @@ gf100_ram_train(struct gf100_ramfuc *fuc, u32 magic)
} }
} }
static int int
gf100_ram_calc(struct nvkm_ram *base, u32 freq) gf100_ram_calc(struct nvkm_ram *base, u32 freq)
{ {
struct gf100_ram *ram = gf100_ram(base); struct gf100_ram *ram = gf100_ram(base);
...@@ -404,7 +404,7 @@ gf100_ram_calc(struct nvkm_ram *base, u32 freq) ...@@ -404,7 +404,7 @@ gf100_ram_calc(struct nvkm_ram *base, u32 freq)
return 0; return 0;
} }
static int int
gf100_ram_prog(struct nvkm_ram *base) gf100_ram_prog(struct nvkm_ram *base)
{ {
struct gf100_ram *ram = gf100_ram(base); struct gf100_ram *ram = gf100_ram(base);
...@@ -413,7 +413,7 @@ gf100_ram_prog(struct nvkm_ram *base) ...@@ -413,7 +413,7 @@ gf100_ram_prog(struct nvkm_ram *base)
return 0; return 0;
} }
static void void
gf100_ram_tidy(struct nvkm_ram *base) gf100_ram_tidy(struct nvkm_ram *base)
{ {
struct gf100_ram *ram = gf100_ram(base); struct gf100_ram *ram = gf100_ram(base);
...@@ -500,7 +500,7 @@ gf100_ram_get(struct nvkm_ram *ram, u64 size, u32 align, u32 ncmin, ...@@ -500,7 +500,7 @@ gf100_ram_get(struct nvkm_ram *ram, u64 size, u32 align, u32 ncmin,
return 0; return 0;
} }
static int int
gf100_ram_init(struct nvkm_ram *base) gf100_ram_init(struct nvkm_ram *base)
{ {
static const u8 train0[] = { static const u8 train0[] = {
...@@ -543,16 +543,6 @@ gf100_ram_init(struct nvkm_ram *base) ...@@ -543,16 +543,6 @@ gf100_ram_init(struct nvkm_ram *base)
return 0; return 0;
} }
static const struct nvkm_ram_func
gf100_ram_func = {
.init = gf100_ram_init,
.get = gf100_ram_get,
.put = gf100_ram_put,
.calc = gf100_ram_calc,
.prog = gf100_ram_prog,
.tidy = gf100_ram_tidy,
};
int int
gf100_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb, gf100_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
u32 maskaddr, struct nvkm_ram *ram) u32 maskaddr, struct nvkm_ram *ram)
...@@ -624,7 +614,8 @@ gf100_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb, ...@@ -624,7 +614,8 @@ gf100_ram_ctor(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
} }
int int
gf100_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram) gf100_ram_new_(const struct nvkm_ram_func *func,
struct nvkm_fb *fb, struct nvkm_ram **pram)
{ {
struct nvkm_subdev *subdev = &fb->subdev; struct nvkm_subdev *subdev = &fb->subdev;
struct nvkm_bios *bios = subdev->device->bios; struct nvkm_bios *bios = subdev->device->bios;
...@@ -635,7 +626,7 @@ gf100_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram) ...@@ -635,7 +626,7 @@ gf100_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
return -ENOMEM; return -ENOMEM;
*pram = &ram->base; *pram = &ram->base;
ret = gf100_ram_ctor(&gf100_ram_func, fb, 0x022554, &ram->base); ret = gf100_ram_ctor(func, fb, 0x022554, &ram->base);
if (ret) if (ret)
return ret; return ret;
...@@ -711,3 +702,19 @@ gf100_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram) ...@@ -711,3 +702,19 @@ gf100_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
ram->fuc.r_0x13d8f4 = ramfuc_reg(0x13d8f4); ram->fuc.r_0x13d8f4 = ramfuc_reg(0x13d8f4);
return 0; return 0;
} }
static const struct nvkm_ram_func
gf100_ram = {
.init = gf100_ram_init,
.get = gf100_ram_get,
.put = gf100_ram_put,
.calc = gf100_ram_calc,
.prog = gf100_ram_prog,
.tidy = gf100_ram_tidy,
};
int
gf100_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
{
return gf100_ram_new_(&gf100_ram, fb, pram);
}
...@@ -1108,7 +1108,7 @@ gk104_ram_calc_xits(struct gk104_ram *ram, struct nvkm_ram_data *next) ...@@ -1108,7 +1108,7 @@ gk104_ram_calc_xits(struct gk104_ram *ram, struct nvkm_ram_data *next)
return ret; return ret;
} }
static int int
gk104_ram_calc(struct nvkm_ram *base, u32 freq) gk104_ram_calc(struct nvkm_ram *base, u32 freq)
{ {
struct gk104_ram *ram = gk104_ram(base); struct gk104_ram *ram = gk104_ram(base);
...@@ -1227,7 +1227,7 @@ gk104_ram_prog_0(struct gk104_ram *ram, u32 freq) ...@@ -1227,7 +1227,7 @@ gk104_ram_prog_0(struct gk104_ram *ram, u32 freq)
nvkm_mask(device, 0x10f444, mask, data); nvkm_mask(device, 0x10f444, mask, data);
} }
static int int
gk104_ram_prog(struct nvkm_ram *base) gk104_ram_prog(struct nvkm_ram *base)
{ {
struct gk104_ram *ram = gk104_ram(base); struct gk104_ram *ram = gk104_ram(base);
...@@ -1247,7 +1247,7 @@ gk104_ram_prog(struct nvkm_ram *base) ...@@ -1247,7 +1247,7 @@ gk104_ram_prog(struct nvkm_ram *base)
return (ram->base.next == &ram->base.xition); return (ram->base.next == &ram->base.xition);
} }
static void void
gk104_ram_tidy(struct nvkm_ram *base) gk104_ram_tidy(struct nvkm_ram *base)
{ {
struct gk104_ram *ram = gk104_ram(base); struct gk104_ram *ram = gk104_ram(base);
...@@ -1509,7 +1509,7 @@ gk104_ram_ctor_data(struct gk104_ram *ram, u8 ramcfg, int i) ...@@ -1509,7 +1509,7 @@ gk104_ram_ctor_data(struct gk104_ram *ram, u8 ramcfg, int i)
return ret; return ret;
} }
static void * void *
gk104_ram_dtor(struct nvkm_ram *base) gk104_ram_dtor(struct nvkm_ram *base)
{ {
struct gk104_ram *ram = gk104_ram(base); struct gk104_ram *ram = gk104_ram(base);
...@@ -1522,31 +1522,14 @@ gk104_ram_dtor(struct nvkm_ram *base) ...@@ -1522,31 +1522,14 @@ gk104_ram_dtor(struct nvkm_ram *base)
return ram; return ram;
} }
static const struct nvkm_ram_func
gk104_ram_func = {
.dtor = gk104_ram_dtor,
.init = gk104_ram_init,
.get = gf100_ram_get,
.put = gf100_ram_put,
.calc = gk104_ram_calc,
.prog = gk104_ram_prog,
.tidy = gk104_ram_tidy,
};
int int
gk104_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram) gk104_ram_new_(const struct nvkm_ram_func *func, struct nvkm_fb *fb,
{ struct nvkm_ram **pram, u32 maskaddr)
return gk104_ram_ctor(fb, pram, 0x022554);
}
int
gk104_ram_ctor(struct nvkm_fb *fb, struct nvkm_ram **pram, u32 maskaddr)
{ {
struct nvkm_subdev *subdev = &fb->subdev; struct nvkm_subdev *subdev = &fb->subdev;
struct nvkm_device *device = subdev->device; struct nvkm_device *device = subdev->device;
struct nvkm_bios *bios = device->bios; struct nvkm_bios *bios = device->bios;
struct nvkm_gpio *gpio = device->gpio; struct dcb_gpio_func gpio;
struct dcb_gpio_func func;
struct gk104_ram *ram; struct gk104_ram *ram;
int ret, i; int ret, i;
u8 ramcfg = nvbios_ramcfg_index(subdev); u8 ramcfg = nvbios_ramcfg_index(subdev);
...@@ -1556,7 +1539,7 @@ gk104_ram_ctor(struct nvkm_fb *fb, struct nvkm_ram **pram, u32 maskaddr) ...@@ -1556,7 +1539,7 @@ gk104_ram_ctor(struct nvkm_fb *fb, struct nvkm_ram **pram, u32 maskaddr)
return -ENOMEM; return -ENOMEM;
*pram = &ram->base; *pram = &ram->base;
ret = gf100_ram_ctor(&gk104_ram_func, fb, maskaddr, &ram->base); ret = gf100_ram_ctor(func, fb, maskaddr, &ram->base);
if (ret) if (ret)
return ret; return ret;
...@@ -1614,18 +1597,18 @@ gk104_ram_ctor(struct nvkm_fb *fb, struct nvkm_ram **pram, u32 maskaddr) ...@@ -1614,18 +1597,18 @@ gk104_ram_ctor(struct nvkm_fb *fb, struct nvkm_ram **pram, u32 maskaddr)
} }
/* lookup memory voltage gpios */ /* lookup memory voltage gpios */
ret = nvkm_gpio_find(gpio, 0, 0x18, DCB_GPIO_UNUSED, &func); ret = nvkm_gpio_find(device->gpio, 0, 0x18, DCB_GPIO_UNUSED, &gpio);
if (ret == 0) { if (ret == 0) {
ram->fuc.r_gpioMV = ramfuc_reg(0x00d610 + (func.line * 0x04)); ram->fuc.r_gpioMV = ramfuc_reg(0x00d610 + (gpio.line * 0x04));
ram->fuc.r_funcMV[0] = (func.log[0] ^ 2) << 12; ram->fuc.r_funcMV[0] = (gpio.log[0] ^ 2) << 12;
ram->fuc.r_funcMV[1] = (func.log[1] ^ 2) << 12; ram->fuc.r_funcMV[1] = (gpio.log[1] ^ 2) << 12;
} }
ret = nvkm_gpio_find(gpio, 0, 0x2e, DCB_GPIO_UNUSED, &func); ret = nvkm_gpio_find(device->gpio, 0, 0x2e, DCB_GPIO_UNUSED, &gpio);
if (ret == 0) { if (ret == 0) {
ram->fuc.r_gpio2E = ramfuc_reg(0x00d610 + (func.line * 0x04)); ram->fuc.r_gpio2E = ramfuc_reg(0x00d610 + (gpio.line * 0x04));
ram->fuc.r_func2E[0] = (func.log[0] ^ 2) << 12; ram->fuc.r_func2E[0] = (gpio.log[0] ^ 2) << 12;
ram->fuc.r_func2E[1] = (func.log[1] ^ 2) << 12; ram->fuc.r_func2E[1] = (gpio.log[1] ^ 2) << 12;
} }
ram->fuc.r_gpiotrig = ramfuc_reg(0x00d604); ram->fuc.r_gpiotrig = ramfuc_reg(0x00d604);
...@@ -1717,3 +1700,20 @@ gk104_ram_ctor(struct nvkm_fb *fb, struct nvkm_ram **pram, u32 maskaddr) ...@@ -1717,3 +1700,20 @@ gk104_ram_ctor(struct nvkm_fb *fb, struct nvkm_ram **pram, u32 maskaddr)
ram->fuc.r_0x100750 = ramfuc_reg(0x100750); ram->fuc.r_0x100750 = ramfuc_reg(0x100750);
return 0; return 0;
} }
static const struct nvkm_ram_func
gk104_ram = {
.dtor = gk104_ram_dtor,
.init = gk104_ram_init,
.get = gf100_ram_get,
.put = gf100_ram_put,
.calc = gk104_ram_calc,
.prog = gk104_ram_prog,
.tidy = gk104_ram_tidy,
};
int
gk104_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
{
return gk104_ram_new_(&gk104_ram, fb, pram, 0x022554);
}
...@@ -23,8 +23,19 @@ ...@@ -23,8 +23,19 @@
*/ */
#include "ram.h" #include "ram.h"
static const struct nvkm_ram_func
gm107_ram = {
.dtor = gk104_ram_dtor,
.init = gk104_ram_init,
.get = gf100_ram_get,
.put = gf100_ram_put,
.calc = gk104_ram_calc,
.prog = gk104_ram_prog,
.tidy = gk104_ram_tidy,
};
int int
gm107_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram) gm107_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
{ {
return gk104_ram_ctor(fb, pram, 0x021c14); return gk104_ram_new_(&gm107_ram, fb, pram, 0x021c14);
} }
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