[go: nahoru, domu]

nv41.c revision 6d338081a6008b3638ca45e0020c5a0cebe362fd
14ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs/*
24ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * Copyright (C) 2010 Francisco Jerez.
34ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * All Rights Reserved.
44ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs *
54ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * Permission is hereby granted, free of charge, to any person obtaining
64ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * a copy of this software and associated documentation files (the
74ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * "Software"), to deal in the Software without restriction, including
84ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * without limitation the rights to use, copy, modify, merge, publish,
94ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * distribute, sublicense, and/or sell copies of the Software, and to
104ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * permit persons to whom the Software is furnished to do so, subject to
114ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * the following conditions:
124ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs *
134ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * The above copyright notice and this permission notice (including the
144ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * next paragraph) shall be included in all copies or substantial
154ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * portions of the Software.
164ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs *
174ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
184ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
194ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
204ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
214ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
224ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
234ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
244ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs *
254ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs */
264ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
274ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs#include <subdev/fb.h>
284ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
294ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggsstruct nv41_fb_priv {
304ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	struct nouveau_fb base;
314ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs};
324ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
334ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggsvoid
344ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggsnv41_fb_tile_prog(struct nouveau_fb *pfb, int i, struct nouveau_fb_tile *tile)
354ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs{
364ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	nv_wr32(pfb, 0x100604 + (i * 0x10), tile->limit);
374ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	nv_wr32(pfb, 0x100608 + (i * 0x10), tile->pitch);
384ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	nv_wr32(pfb, 0x100600 + (i * 0x10), tile->addr);
396d338081a6008b3638ca45e0020c5a0cebe362fdBen Skeggs	nv_rd32(pfb, 0x100600 + (i * 0x10));
405f8e256704e86df795037b18395fdf102b75199eBen Skeggs	nv_wr32(pfb, 0x100700 + (i * 0x04), tile->zcomp);
414ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs}
424ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
434ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggsint
444ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggsnv41_fb_init(struct nouveau_object *object)
454ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs{
464ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	struct nv41_fb_priv *priv = (void *)object;
474ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	int ret;
484ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
494ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	ret = nouveau_fb_init(&priv->base);
504ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	if (ret)
514ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs		return ret;
524ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
534ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	nv_wr32(priv, 0x100800, 0x00000001);
544ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	return 0;
554ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs}
564ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
574ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggsstatic int
584ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggsnv41_fb_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
594ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	     struct nouveau_oclass *oclass, void *data, u32 size,
604ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	     struct nouveau_object **pobject)
614ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs{
624ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	struct nouveau_device *device = nv_device(parent);
634ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	struct nv41_fb_priv *priv;
644ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	u32 pfb474;
654ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	int ret;
664ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
674ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	ret = nouveau_fb_create(parent, engine, oclass, &priv);
684ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	*pobject = nv_object(priv);
694ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	if (ret)
704ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs		return ret;
714ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
724ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	pfb474 = nv_rd32(priv, 0x100474);
734ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	if (pfb474 & 0x00000004)
744ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs		priv->base.ram.type = NV_MEM_TYPE_GDDR3;
754ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	if (pfb474 & 0x00000002)
764ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs		priv->base.ram.type = NV_MEM_TYPE_DDR2;
774ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	if (pfb474 & 0x00000001)
784ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs		priv->base.ram.type = NV_MEM_TYPE_DDR1;
794ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
804ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	priv->base.ram.size = nv_rd32(priv, 0x10020c) & 0xff000000;
814ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
824ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	priv->base.memtype_valid = nv04_fb_memtype_valid;
834ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	priv->base.tile.regions = 12;
844ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	priv->base.tile.init = nv30_fb_tile_init;
854ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	priv->base.tile.fini = nv30_fb_tile_fini;
864ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	priv->base.tile.prog = nv41_fb_tile_prog;
874ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	return nouveau_fb_created(&priv->base);
884ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs}
894ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
904ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs
914ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggsstruct nouveau_oclass
924ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggsnv41_fb_oclass = {
934ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	.handle = NV_SUBDEV(FB, 0x41),
944ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	.ofuncs = &(struct nouveau_ofuncs) {
954ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs		.ctor = nv41_fb_ctor,
964ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs		.dtor = _nouveau_fb_dtor,
974ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs		.init = nv41_fb_init,
984ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs		.fini = _nouveau_fb_fini,
994ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs	},
1004ae207453ee0c68cc927c71c54277255a6f62f99Ben Skeggs};
101