2010-08-03 08:00:56 +08:00
|
|
|
/*
|
2012-07-11 17:05:01 +08:00
|
|
|
* Copyright 2012 Red Hat Inc.
|
2010-08-03 08:00:56 +08: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 12:52:58 +08:00
|
|
|
#include "gf100.h"
|
2015-08-20 12:54:14 +08:00
|
|
|
#include "ram.h"
|
2010-08-03 08:00:56 +08:00
|
|
|
|
2016-04-14 08:39:18 +08:00
|
|
|
#include <core/memory.h>
|
|
|
|
#include <core/option.h>
|
|
|
|
|
2015-01-14 12:52:58 +08:00
|
|
|
extern const u8 gf100_pte_storage_type_map[256];
|
2013-03-28 05:16:53 +08:00
|
|
|
|
2013-03-04 13:01:37 +08:00
|
|
|
bool
|
2015-08-20 12:54:06 +08:00
|
|
|
gf100_fb_memtype_valid(struct nvkm_fb *fb, u32 tile_flags)
|
2011-08-26 11:05:23 +08:00
|
|
|
{
|
2012-07-11 17:05:01 +08:00
|
|
|
u8 memtype = (tile_flags & 0x0000ff00) >> 8;
|
2015-01-14 12:52:58 +08:00
|
|
|
return likely((gf100_pte_storage_type_map[memtype] != 0xff));
|
2012-07-11 17:05:01 +08:00
|
|
|
}
|
2011-08-26 11:05:23 +08:00
|
|
|
|
2015-08-20 12:54:20 +08:00
|
|
|
void
|
|
|
|
gf100_fb_intr(struct nvkm_fb *base)
|
2013-12-03 12:10:42 +08:00
|
|
|
{
|
2015-08-20 12:54:20 +08:00
|
|
|
struct gf100_fb *fb = gf100_fb(base);
|
|
|
|
struct nvkm_subdev *subdev = &fb->base.subdev;
|
2015-08-20 12:54:09 +08:00
|
|
|
struct nvkm_device *device = subdev->device;
|
|
|
|
u32 intr = nvkm_rd32(device, 0x000100);
|
2015-08-20 12:54:06 +08:00
|
|
|
if (intr & 0x08000000)
|
2015-08-20 12:54:12 +08:00
|
|
|
nvkm_debug(subdev, "PFFB intr\n");
|
2015-08-20 12:54:06 +08:00
|
|
|
if (intr & 0x00002000)
|
2015-08-20 12:54:12 +08:00
|
|
|
nvkm_debug(subdev, "PBFB intr\n");
|
2013-12-03 12:10:42 +08:00
|
|
|
}
|
|
|
|
|
2016-04-14 08:39:18 +08:00
|
|
|
int
|
2016-10-06 23:49:29 +08:00
|
|
|
gf100_fb_oneinit(struct nvkm_fb *base)
|
2016-04-14 08:39:18 +08:00
|
|
|
{
|
2016-10-06 23:49:29 +08:00
|
|
|
struct gf100_fb *fb = gf100_fb(base);
|
|
|
|
struct nvkm_device *device = fb->base.subdev.device;
|
2016-04-14 08:39:18 +08:00
|
|
|
int ret, size = 0x1000;
|
|
|
|
|
|
|
|
size = nvkm_longopt(device->cfgopt, "MmuDebugBufferSize", size);
|
|
|
|
size = min(size, 0x1000);
|
|
|
|
|
|
|
|
ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, size, 0x1000,
|
2017-08-07 11:27:31 +08:00
|
|
|
true, &fb->base.mmu_rd);
|
2016-04-14 08:39:18 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
ret = nvkm_memory_new(device, NVKM_MEM_TARGET_INST, size, 0x1000,
|
2017-08-07 11:27:31 +08:00
|
|
|
true, &fb->base.mmu_wr);
|
2016-04-14 08:39:18 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
2016-10-06 23:49:29 +08:00
|
|
|
fb->r100c10_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
|
|
|
|
if (fb->r100c10_page) {
|
|
|
|
fb->r100c10 = dma_map_page(device->dev, fb->r100c10_page, 0,
|
|
|
|
PAGE_SIZE, DMA_BIDIRECTIONAL);
|
|
|
|
if (dma_mapping_error(device->dev, fb->r100c10))
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
2016-04-14 08:39:18 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-07-09 08:41:01 +08:00
|
|
|
void
|
|
|
|
gf100_fb_init_page(struct nvkm_fb *fb)
|
|
|
|
{
|
|
|
|
struct nvkm_device *device = fb->subdev.device;
|
|
|
|
switch (fb->page) {
|
|
|
|
case 16:
|
|
|
|
nvkm_mask(device, 0x100c80, 0x00000001, 0x00000001);
|
|
|
|
break;
|
|
|
|
case 17:
|
|
|
|
default:
|
|
|
|
nvkm_mask(device, 0x100c80, 0x00000001, 0x00000000);
|
|
|
|
fb->page = 17;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-20 12:54:20 +08:00
|
|
|
void
|
|
|
|
gf100_fb_init(struct nvkm_fb *base)
|
2011-08-26 11:05:23 +08:00
|
|
|
{
|
2015-08-20 12:54:20 +08:00
|
|
|
struct gf100_fb *fb = gf100_fb(base);
|
2015-08-20 12:54:09 +08:00
|
|
|
struct nvkm_device *device = fb->base.subdev.device;
|
2012-04-20 01:59:20 +08:00
|
|
|
|
2015-08-20 12:54:06 +08:00
|
|
|
if (fb->r100c10_page)
|
2015-08-20 12:54:09 +08:00
|
|
|
nvkm_wr32(device, 0x100c10, fb->r100c10 >> 8);
|
2011-08-26 11:05:23 +08:00
|
|
|
}
|
|
|
|
|
2015-08-20 12:54:20 +08:00
|
|
|
void *
|
|
|
|
gf100_fb_dtor(struct nvkm_fb *base)
|
2011-05-24 09:47:09 +08:00
|
|
|
{
|
2015-08-20 12:54:20 +08:00
|
|
|
struct gf100_fb *fb = gf100_fb(base);
|
|
|
|
struct nvkm_device *device = fb->base.subdev.device;
|
2011-08-26 11:05:23 +08:00
|
|
|
|
2015-08-20 12:54:06 +08:00
|
|
|
if (fb->r100c10_page) {
|
2015-08-20 12:54:23 +08:00
|
|
|
dma_unmap_page(device->dev, fb->r100c10, PAGE_SIZE,
|
2014-07-31 17:09:42 +08:00
|
|
|
DMA_BIDIRECTIONAL);
|
2015-08-20 12:54:06 +08:00
|
|
|
__free_page(fb->r100c10_page);
|
2011-05-24 09:47:09 +08:00
|
|
|
}
|
|
|
|
|
2015-08-20 12:54:20 +08:00
|
|
|
return fb;
|
2011-05-24 09:47:09 +08:00
|
|
|
}
|
|
|
|
|
2013-03-04 13:01:37 +08:00
|
|
|
int
|
2015-08-20 12:54:20 +08:00
|
|
|
gf100_fb_new_(const struct nvkm_fb_func *func, struct nvkm_device *device,
|
|
|
|
int index, struct nvkm_fb **pfb)
|
2010-08-03 08:00:56 +08:00
|
|
|
{
|
2015-08-20 12:54:06 +08:00
|
|
|
struct gf100_fb *fb;
|
2011-05-24 09:47:09 +08:00
|
|
|
|
2015-08-20 12:54:20 +08:00
|
|
|
if (!(fb = kzalloc(sizeof(*fb), GFP_KERNEL)))
|
|
|
|
return -ENOMEM;
|
|
|
|
nvkm_fb_ctor(func, device, index, &fb->base);
|
|
|
|
*pfb = &fb->base;
|
2011-05-24 09:47:09 +08:00
|
|
|
|
2013-03-04 11:01:21 +08:00
|
|
|
return 0;
|
2010-08-03 08:00:56 +08:00
|
|
|
}
|
2012-07-11 17:05:01 +08:00
|
|
|
|
2015-08-20 12:54:20 +08:00
|
|
|
static const struct nvkm_fb_func
|
|
|
|
gf100_fb = {
|
|
|
|
.dtor = gf100_fb_dtor,
|
2016-04-14 08:39:18 +08:00
|
|
|
.oneinit = gf100_fb_oneinit,
|
2015-08-20 12:54:20 +08:00
|
|
|
.init = gf100_fb_init,
|
2016-07-09 08:41:01 +08:00
|
|
|
.init_page = gf100_fb_init_page,
|
2015-08-20 12:54:20 +08:00
|
|
|
.intr = gf100_fb_intr,
|
2015-08-20 12:54:14 +08:00
|
|
|
.ram_new = gf100_ram_new,
|
2015-08-20 12:54:20 +08:00
|
|
|
.memtype_valid = gf100_fb_memtype_valid,
|
|
|
|
};
|
|
|
|
|
|
|
|
int
|
|
|
|
gf100_fb_new(struct nvkm_device *device, int index, struct nvkm_fb **pfb)
|
|
|
|
{
|
|
|
|
return gf100_fb_new_(&gf100_fb, device, index, pfb);
|
|
|
|
}
|