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
|
|
|
|
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
|
|
|
|
2013-12-03 12:10:42 +08:00
|
|
|
static void
|
2015-01-14 12:52:58 +08:00
|
|
|
gf100_fb_intr(struct nvkm_subdev *subdev)
|
2013-12-03 12:10:42 +08:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
|
2013-03-04 13:01:37 +08:00
|
|
|
int
|
2015-01-14 12:52:58 +08:00
|
|
|
gf100_fb_init(struct nvkm_object *object)
|
2011-08-26 11:05:23 +08:00
|
|
|
{
|
2015-08-20 12:54:06 +08:00
|
|
|
struct gf100_fb *fb = (void *)object;
|
2015-08-20 12:54:09 +08:00
|
|
|
struct nvkm_device *device = fb->base.subdev.device;
|
2012-07-11 17:05:01 +08:00
|
|
|
int ret;
|
|
|
|
|
2015-08-20 12:54:06 +08:00
|
|
|
ret = nvkm_fb_init(&fb->base);
|
2012-07-11 17:05:01 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
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);
|
2015-01-14 12:52:58 +08:00
|
|
|
|
2015-08-20 12:54:09 +08:00
|
|
|
nvkm_mask(device, 0x100c80, 0x00000001, 0x00000000); /* 128KiB lpg */
|
2012-07-11 17:05:01 +08:00
|
|
|
return 0;
|
2011-08-26 11:05:23 +08:00
|
|
|
}
|
|
|
|
|
2013-03-04 13:01:37 +08:00
|
|
|
void
|
2015-01-14 12:52:58 +08:00
|
|
|
gf100_fb_dtor(struct nvkm_object *object)
|
2011-05-24 09:47:09 +08:00
|
|
|
{
|
2015-01-14 12:52:58 +08:00
|
|
|
struct nvkm_device *device = nv_device(object);
|
2015-08-20 12:54:06 +08:00
|
|
|
struct gf100_fb *fb = (void *)object;
|
2011-08-26 11:05:23 +08:00
|
|
|
|
2015-08-20 12:54:06 +08:00
|
|
|
if (fb->r100c10_page) {
|
|
|
|
dma_unmap_page(nv_device_base(device), 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:06 +08:00
|
|
|
nvkm_fb_destroy(&fb->base);
|
2011-05-24 09:47:09 +08:00
|
|
|
}
|
|
|
|
|
2013-03-04 13:01:37 +08:00
|
|
|
int
|
2015-01-14 12:52:58 +08:00
|
|
|
gf100_fb_ctor(struct nvkm_object *parent, struct nvkm_object *engine,
|
|
|
|
struct nvkm_oclass *oclass, void *data, u32 size,
|
|
|
|
struct nvkm_object **pobject)
|
2010-08-03 08:00:56 +08:00
|
|
|
{
|
2015-01-14 12:52:58 +08:00
|
|
|
struct nvkm_device *device = nv_device(parent);
|
2015-08-20 12:54:06 +08:00
|
|
|
struct gf100_fb *fb;
|
2011-05-24 09:47:09 +08:00
|
|
|
int ret;
|
|
|
|
|
2015-08-20 12:54:06 +08:00
|
|
|
ret = nvkm_fb_create(parent, engine, oclass, &fb);
|
|
|
|
*pobject = nv_object(fb);
|
2012-07-11 17:05:01 +08:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2011-05-24 09:47:09 +08:00
|
|
|
|
2015-08-20 12:54:06 +08:00
|
|
|
fb->r100c10_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
|
|
|
|
if (fb->r100c10_page) {
|
|
|
|
fb->r100c10 = dma_map_page(nv_device_base(device),
|
|
|
|
fb->r100c10_page, 0, PAGE_SIZE,
|
2014-07-31 17:09:42 +08:00
|
|
|
DMA_BIDIRECTIONAL);
|
2015-08-20 12:54:06 +08:00
|
|
|
if (dma_mapping_error(nv_device_base(device), fb->r100c10))
|
2013-01-16 08:05:31 +08:00
|
|
|
return -EFAULT;
|
|
|
|
}
|
2012-07-11 17:05:01 +08:00
|
|
|
|
2015-08-20 12:54:06 +08:00
|
|
|
nv_subdev(fb)->intr = gf100_fb_intr;
|
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-01-14 12:52:58 +08:00
|
|
|
struct nvkm_oclass *
|
|
|
|
gf100_fb_oclass = &(struct nvkm_fb_impl) {
|
2013-10-21 06:50:25 +08:00
|
|
|
.base.handle = NV_SUBDEV(FB, 0xc0),
|
2015-01-14 12:52:58 +08:00
|
|
|
.base.ofuncs = &(struct nvkm_ofuncs) {
|
|
|
|
.ctor = gf100_fb_ctor,
|
|
|
|
.dtor = gf100_fb_dtor,
|
|
|
|
.init = gf100_fb_init,
|
|
|
|
.fini = _nvkm_fb_fini,
|
2012-07-11 17:05:01 +08:00
|
|
|
},
|
2015-01-14 12:52:58 +08:00
|
|
|
.memtype = gf100_fb_memtype_valid,
|
2015-08-20 12:54:14 +08:00
|
|
|
.ram_new = gf100_ram_new,
|
2013-10-21 06:50:25 +08:00
|
|
|
}.base;
|