aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nvkm/subdev/bios/extdev.c
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2015-01-13 07:13:14 -0500
committerBen Skeggs <bskeggs@redhat.com>2015-01-21 21:15:10 -0500
commitc39f472e9f14e49a9bc091977ced0ec45fc00c57 (patch)
tree75af3291cccda2482913cc0044888a8a86f4841b /drivers/gpu/drm/nouveau/nvkm/subdev/bios/extdev.c
parent055a65d5987a7f246c3fc2297158286882dbdbcf (diff)
drm/nouveau: remove symlinks, move core/ to nvkm/ (no code changes)
The symlinks were annoying some people, and they're not used anywhere else in the kernel tree. The include directory structure has been changed so that symlinks aren't needed anymore. NVKM has been moved from core/ to nvkm/ to make it more obvious as to what the directory is for, and as some minor prep for when NVKM gets split out into its own module (virt) at a later date. Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/nouveau/nvkm/subdev/bios/extdev.c')
-rw-r--r--drivers/gpu/drm/nouveau/nvkm/subdev/bios/extdev.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/extdev.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/extdev.c
new file mode 100644
index 000000000000..49285d4f7ca5
--- /dev/null
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/extdev.c
@@ -0,0 +1,100 @@
1/*
2 * Copyright 2012 Nouveau Community
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
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.
21 *
22 * Authors: Martin Peres
23 */
24
25#include <subdev/bios.h>
26#include <subdev/bios/dcb.h>
27#include <subdev/bios/extdev.h>
28
29static u16
30extdev_table(struct nouveau_bios *bios, u8 *ver, u8 *hdr, u8 *len, u8 *cnt)
31{
32 u8 dcb_ver, dcb_hdr, dcb_cnt, dcb_len;
33 u16 dcb, extdev = 0;
34
35 dcb = dcb_table(bios, &dcb_ver, &dcb_hdr, &dcb_cnt, &dcb_len);
36 if (!dcb || (dcb_ver != 0x30 && dcb_ver != 0x40))
37 return 0x0000;
38
39 extdev = nv_ro16(bios, dcb + 18);
40 if (!extdev)
41 return 0x0000;
42
43 *ver = nv_ro08(bios, extdev + 0);
44 *hdr = nv_ro08(bios, extdev + 1);
45 *cnt = nv_ro08(bios, extdev + 2);
46 *len = nv_ro08(bios, extdev + 3);
47
48 return extdev + *hdr;
49}
50
51static u16
52nvbios_extdev_entry(struct nouveau_bios *bios, int idx, u8 *ver, u8 *len)
53{
54 u8 hdr, cnt;
55 u16 extdev = extdev_table(bios, ver, &hdr, len, &cnt);
56 if (extdev && idx < cnt)
57 return extdev + idx * *len;
58 return 0x0000;
59}
60
61static void
62extdev_parse_entry(struct nouveau_bios *bios, u16 offset,
63 struct nvbios_extdev_func *entry)
64{
65 entry->type = nv_ro08(bios, offset + 0);
66 entry->addr = nv_ro08(bios, offset + 1);
67 entry->bus = (nv_ro08(bios, offset + 2) >> 4) & 1;
68}
69
70int
71nvbios_extdev_parse(struct nouveau_bios *bios, int idx,
72 struct nvbios_extdev_func *func)
73{
74 u8 ver, len;
75 u16 entry;
76
77 if (!(entry = nvbios_extdev_entry(bios, idx, &ver, &len)))
78 return -EINVAL;
79
80 extdev_parse_entry(bios, entry, func);
81
82 return 0;
83}
84
85int
86nvbios_extdev_find(struct nouveau_bios *bios, enum nvbios_extdev_type type,
87 struct nvbios_extdev_func *func)
88{
89 u8 ver, len, i;
90 u16 entry;
91
92 i = 0;
93 while ((entry = nvbios_extdev_entry(bios, i++, &ver, &len))) {
94 extdev_parse_entry(bios, entry, func);
95 if (func->type == type)
96 return 0;
97 }
98
99 return -EINVAL;
100}