2010-08-03 10:00:56 +10:00
|
|
|
/*
|
2012-07-11 19:05:01 +10:00
|
|
|
* Copyright 2012 Red Hat Inc.
|
2010-08-03 10:00:56 +10:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
|
|
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
|
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
|
|
* OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors: Ben Skeggs
|
|
|
|
*/
|
2015-01-14 14:52:58 +10:00
|
|
|
#include "gf100.h"
|
2015-08-20 14:54:14 +10:00
|
|
|
#include "ram.h"
|
2010-08-03 10:00:56 +10:00
|
|
|
|
2016-04-14 10:39:18 +10:00
|
|
|
#include <core/memory.h>
|
|
|
|
#include <core/option.h>
|
2018-02-01 13:13:56 -05:00
|
|
|
#include <subdev/therm.h>
|
2016-04-14 10:39:18 +10:00
|
|
|
|
2015-08-20 14:54:20 +10:00
|
|
|
void
|
|
|
|
gf100_fb_intr(struct nvkm_fb *base)
|
2013-12-03 14:10:42 +10:00
|
|
|
{
|
2015-08-20 14:54:20 +10:00
|
|
|
struct gf100_fb *fb = gf100_fb(base);
|
|
|
|
struct nvkm_subdev *subdev = &fb->base.subdev;
|
2015-08-20 14:54:09 +10:00
|
|
|
struct nvkm_device *device = subdev->device;
|
|
|
|
u32 intr = nvkm_rd32(device, 0x000100);
|
2015-08-20 14:54:06 +10:00
|
|
|
if (intr & 0x08000000)
|
2015-08-20 14:54:12 +10:00
|
|
|
nvkm_debug(subdev, "PFFB intr\n");
|
2015-08-20 14:54:06 +10:00
|
|
|
if (intr & 0x00002000)
|
2015-08-20 14:54:12 +10:00
|
|
|
nvkm_debug(subdev, "PBFB intr\n");
|
2013-12-03 14:10:42 +10:00
|
|
|
}
|
|
|
|
|
2016-04-14 10:39:18 +10:00
|
|
|
int
|
2016-10-06 16:49:29 +01:00
|
|
|
gf100_fb_oneinit(struct nvkm_fb *base)
|
2016-04-14 10:39:18 +10:00
|
|
|
{
|
2016-10-06 16:49:29 +01:00
|
|
|
struct gf100_fb *fb = gf100_fb(base);
|
|
|
|
struct nvkm_device *device = fb->base.subdev.device;
|
2018-05-08 20:39:46 +10:00
|
|
|
int ret, size = 1 << (fb->base.page ? fb->base.page : 17);
|
2016-04-14 10:39:18 +10:00
|
|
|
|
|
|
|
size = nvkm_longopt(device->cfgopt, "MmuDebugBufferSize", size);
|
2018-05-08 20:39:46 +10:00
|
|
|
size = max(size, 0x1000);
|
2016-04-14 10:39:18 +10:00
|
|
|
|
|
|
|
ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, size, 0x1000,
|
2017-08-07 13:27:31 +10:00
|
|
|
true, &fb->base.mmu_rd);
|
2016-04-14 10:39:18 +10:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, size, 0x1000,
|
2017-08-07 13:27:31 +10:00
|
|
|
true, &fb->base.mmu_wr);
|
2016-04-14 10:39:18 +10:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-11-01 03:56:19 +10:00
|
|
|
int
|
2016-07-09 10:41:01 +10:00
|
|
|
gf100_fb_init_page(struct nvkm_fb *fb)
|
|
|
|
{
|
|
|
|
struct nvkm_device *device = fb->subdev.device;
|
|
|
|
switch (fb->page) {
|
2017-11-01 03:56:19 +10:00
|
|
|
case 16: nvkm_mask(device, 0x100c80, 0x00000001, 0x00000001); break;
|
|
|
|
case 17: nvkm_mask(device, 0x100c80, 0x00000001, 0x00000000); break;
|
2016-07-09 10:41:01 +10:00
|
|
|
default:
|
2017-11-01 03:56:19 +10:00
|
|
|
return -EINVAL;
|
2016-07-09 10:41:01 +10:00
|
|
|
}
|
2017-11-01 03:56:19 +10:00
|
|
|
return 0;
|
2016-07-09 10:41:01 +10:00
|
|
|
}
|
|
|
|
|
2022-06-01 20:47:51 +10:00
|
|
|
void
|
|
|
|
gf100_fb_sysmem_flush_page_init(struct nvkm_fb *fb)
|
|
|
|
{
|
|
|
|
nvkm_wr32(fb->subdev.device, 0x100c10, fb->sysmem.flush_page_addr >> 8);
|
|
|
|
}
|
|
|
|
|
2015-08-20 14:54:20 +10:00
|
|
|
void
|
|
|
|
gf100_fb_init(struct nvkm_fb *base)
|
2011-08-26 13:05:23 +10:00
|
|
|
{
|
2015-08-20 14:54:20 +10:00
|
|
|
struct gf100_fb *fb = gf100_fb(base);
|
2015-08-20 14:54:09 +10:00
|
|
|
struct nvkm_device *device = fb->base.subdev.device;
|
2012-04-19 19:59:20 +02:00
|
|
|
|
2018-02-01 13:13:56 -05:00
|
|
|
if (base->func->clkgate_pack) {
|
|
|
|
nvkm_therm_clkgate_init(device->therm,
|
|
|
|
base->func->clkgate_pack);
|
|
|
|
}
|
2011-08-26 13:05:23 +10:00
|
|
|
}
|
|
|
|
|
2015-08-20 14:54:20 +10:00
|
|
|
void *
|
|
|
|
gf100_fb_dtor(struct nvkm_fb *base)
|
2011-05-24 11:47:09 +10:00
|
|
|
{
|
2015-08-20 14:54:20 +10:00
|
|
|
struct gf100_fb *fb = gf100_fb(base);
|
2011-05-24 11:47:09 +10:00
|
|
|
|
2015-08-20 14:54:20 +10:00
|
|
|
return fb;
|
2011-05-24 11:47:09 +10:00
|
|
|
}
|
|
|
|
|
2013-03-04 15:01:37 +10:00
|
|
|
int
|
2015-08-20 14:54:20 +10:00
|
|
|
gf100_fb_new_(const struct nvkm_fb_func *func, struct nvkm_device *device,
|
2020-12-04 11:16:21 +10:00
|
|
|
enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
|
2010-08-03 10:00:56 +10:00
|
|
|
{
|
2015-08-20 14:54:06 +10:00
|
|
|
struct gf100_fb *fb;
|
2011-05-24 11:47:09 +10:00
|
|
|
|
2015-08-20 14:54:20 +10:00
|
|
|
if (!(fb = kzalloc(sizeof(*fb), GFP_KERNEL)))
|
|
|
|
return -ENOMEM;
|
2020-12-04 11:16:21 +10:00
|
|
|
nvkm_fb_ctor(func, device, type, inst, &fb->base);
|
2015-08-20 14:54:20 +10:00
|
|
|
*pfb = &fb->base;
|
2011-05-24 11:47:09 +10:00
|
|
|
|
2013-03-04 13:01:21 +10:00
|
|
|
return 0;
|
2010-08-03 10:00:56 +10:00
|
|
|
}
|
2012-07-11 19:05:01 +10:00
|
|
|
|
2015-08-20 14:54:20 +10:00
|
|
|
static const struct nvkm_fb_func
|
|
|
|
gf100_fb = {
|
|
|
|
.dtor = gf100_fb_dtor,
|
2016-04-14 10:39:18 +10:00
|
|
|
.oneinit = gf100_fb_oneinit,
|
2015-08-20 14:54:20 +10:00
|
|
|
.init = gf100_fb_init,
|
2016-07-09 10:41:01 +10:00
|
|
|
.init_page = gf100_fb_init_page,
|
2015-08-20 14:54:20 +10:00
|
|
|
.intr = gf100_fb_intr,
|
2022-06-01 20:47:51 +10:00
|
|
|
.sysmem.flush_page_init = gf100_fb_sysmem_flush_page_init,
|
2015-08-20 14:54:14 +10:00
|
|
|
.ram_new = gf100_ram_new,
|
2017-11-01 03:56:19 +10:00
|
|
|
.default_bigpage = 17,
|
2015-08-20 14:54:20 +10:00
|
|
|
};
|
|
|
|
|
|
|
|
int
|
2020-12-04 11:16:21 +10:00
|
|
|
gf100_fb_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst, struct nvkm_fb **pfb)
|
2015-08-20 14:54:20 +10:00
|
|
|
{
|
2020-12-04 11:16:21 +10:00
|
|
|
return gf100_fb_new_(&gf100_fb, device, type, inst, pfb);
|
2015-08-20 14:54:20 +10:00
|
|
|
}
|