1/* $NetBSD: nouveau_subdev_devinit_nv20.c,v 1.1.1.1 2014/08/06 12:36:30 riastradh Exp $ */
2
3/*
4 * Copyright (C) 2010 Francisco Jerez.
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining
8 * a copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sublicense, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
14 *
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial
17 * portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
23 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 *
27 */
28
29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: nouveau_subdev_devinit_nv20.c,v 1.1.1.1 2014/08/06 12:36:30 riastradh Exp $");
31
32#include "nv04.h"
33#include "fbmem.h"
34
35static void
36nv20_devinit_meminit(struct nouveau_devinit *devinit)
37{
38 struct nv04_devinit_priv *priv = (void *)devinit;
39 struct nouveau_device *device = nv_device(priv);
40 uint32_t mask = (device->chipset >= 0x25 ? 0x300 : 0x900);
41 uint32_t amount, off;
42 struct io_mapping *fb;
43
44 /* Map the framebuffer aperture */
45 fb = fbmem_init(nv_device(priv));
46 if (!fb) {
47 nv_error(priv, "failed to map fb\n");
48 return;
49 }
50
51 nv_wr32(priv, NV10_PFB_REFCTRL, NV10_PFB_REFCTRL_VALID_1);
52
53 /* Allow full addressing */
54 nv_mask(priv, NV04_PFB_CFG0, 0, mask);
55
56 amount = nv_rd32(priv, 0x10020c);
57 for (off = amount; off > 0x2000000; off -= 0x2000000)
58 fbmem_poke(fb, off - 4, off);
59
60 amount = nv_rd32(priv, 0x10020c);
61 if (amount != fbmem_peek(fb, amount - 4))
62 /* IC missing - disable the upper half memory space. */
63 nv_mask(priv, NV04_PFB_CFG0, mask, 0);
64
65 fbmem_fini(fb);
66}
67
68struct nouveau_oclass *
69nv20_devinit_oclass = &(struct nouveau_devinit_impl) {
70 .base.handle = NV_SUBDEV(DEVINIT, 0x20),
71 .base.ofuncs = &(struct nouveau_ofuncs) {
72 .ctor = nv04_devinit_ctor,
73 .dtor = nv04_devinit_dtor,
74 .init = nv04_devinit_init,
75 .fini = nv04_devinit_fini,
76 },
77 .meminit = nv20_devinit_meminit,
78 .pll_set = nv04_devinit_pll_set,
79}.base;
80