2 * Copyright 2012 Red Hat Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
27 struct nouveau_bios *bios;
32 pramin_read(void *data, u32 offset, u32 length, struct nouveau_bios *bios)
35 if (offset + length <= 0x00100000) {
36 for (i = offset; i < offset + length; i += 4)
37 *(u32 *)&bios->data[i] = nv_rd32(bios, 0x700000 + i);
44 pramin_fini(void *data)
46 struct priv *priv = data;
48 nv_wr32(priv->bios, 0x001700, priv->bar0);
54 pramin_init(struct nouveau_bios *bios, const char *name)
56 struct priv *priv = NULL;
59 /* PRAMIN always potentially available prior to nv50 */
60 if (nv_device(bios)->card_type < NV_50)
63 /* we can't get the bios image pointer without PDISP */
64 if (nv_device(bios)->card_type >= GM100)
65 addr = nv_rd32(bios, 0x021c04);
67 if (nv_device(bios)->card_type >= NV_C0)
68 addr = nv_rd32(bios, 0x022500);
69 if (addr & 0x00000001) {
70 nv_debug(bios, "... display disabled\n");
71 return ERR_PTR(-ENODEV);
74 /* check that the window is enabled and in vram, particularly
75 * important as we don't want to be touching vram on an
78 addr = nv_rd32(bios, 0x619f04);
79 if (!(addr & 0x00000008)) {
80 nv_debug(bios, "... not enabled\n");
81 return ERR_PTR(-ENODEV);
83 if ( (addr & 0x00000003) != 1) {
84 nv_debug(bios, "... not in vram\n");
85 return ERR_PTR(-ENODEV);
88 /* some alternate method inherited from xf86-video-nv... */
89 addr = (addr & 0xffffff00) << 8;
91 addr = (u64)nv_rd32(bios, 0x001700) << 16;
95 /* modify bar0 PRAMIN window to cover the bios image */
96 if (!(priv = kmalloc(sizeof(*priv), GFP_KERNEL))) {
97 nv_error(bios, "... out of memory\n");
98 return ERR_PTR(-ENOMEM);
102 priv->bar0 = nv_rd32(bios, 0x001700);
103 nv_wr32(bios, 0x001700, addr >> 16);
107 const struct nvbios_source