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