drm/nouveau/bar: tidy up the subdev and object class definitions
[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
88524bc0 27#include "priv.h"
cb75d97e
BS
28#include "fbmem.h"
29
30struct nv20_devinit_priv {
31 struct nouveau_devinit base;
32 u8 owner;
33};
34
35static void
36nv20_devinit_meminit(struct nouveau_devinit *devinit)
37{
38 struct nv20_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)->pdev);
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
68static int
69nv20_devinit_ctor(struct nouveau_object *parent, struct nouveau_object *engine,
70 struct nouveau_oclass *oclass, void *data, u32 size,
71 struct nouveau_object **pobject)
72{
73 struct nv20_devinit_priv *priv;
74 int ret;
75
76 ret = nouveau_devinit_create(parent, engine, oclass, &priv);
77 *pobject = nv_object(priv);
78 if (ret)
79 return ret;
80
81 priv->base.meminit = nv20_devinit_meminit;
88524bc0 82 priv->base.pll_set = nv04_devinit_pll_set;
cb75d97e
BS
83 return 0;
84}
85
86struct nouveau_oclass
87nv20_devinit_oclass = {
88 .handle = NV_SUBDEV(DEVINIT, 0x20),
89 .ofuncs = &(struct nouveau_ofuncs) {
90 .ctor = nv20_devinit_ctor,
91 .dtor = nv04_devinit_dtor,
92 .init = nv04_devinit_init,
93 .fini = nv04_devinit_fini,
94 },
95};