]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blame - drivers/gpu/drm/nouveau/nvkm/subdev/bios/conn.c
Merge tag 'mac80211-for-davem-2016-06-29-v2' of git://git.kernel.org/pub/scm/linux...
[mirror_ubuntu-focal-kernel.git] / drivers / gpu / drm / nouveau / nvkm / subdev / bios / conn.c
CommitLineData
cb75d97e
BS
1/*
2 * Copyright 2012 Red Hat Inc.
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: Ben Skeggs
23 */
cb75d97e
BS
24#include <subdev/bios.h>
25#include <subdev/bios/dcb.h>
5b8a43ae 26#include <subdev/bios/conn.h>
cb75d97e 27
20014cbe 28u32
d390b480 29nvbios_connTe(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len)
cb75d97e 30{
20014cbe 31 u32 dcb = dcb_table(bios, ver, hdr, cnt, len);
cb75d97e 32 if (dcb && *ver >= 0x30 && *hdr >= 0x16) {
7f5f518f 33 u32 data = nvbios_rd16(bios, dcb + 0x14);
cb75d97e 34 if (data) {
7f5f518f
BS
35 *ver = nvbios_rd08(bios, data + 0);
36 *hdr = nvbios_rd08(bios, data + 1);
37 *cnt = nvbios_rd08(bios, data + 2);
38 *len = nvbios_rd08(bios, data + 3);
cb75d97e
BS
39 return data;
40 }
41 }
20014cbe 42 return 0x00000000;
cb75d97e
BS
43}
44
20014cbe 45u32
d390b480 46nvbios_connTp(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len,
20014cbe
BS
47 struct nvbios_connT *info)
48{
49 u32 data = nvbios_connTe(bios, ver, hdr, cnt, len);
50 memset(info, 0x00, sizeof(*info));
51 switch (!!data * *ver) {
52 case 0x30:
53 case 0x40:
54 return data;
55 default:
56 break;
57 }
58 return 0x00000000;
59}
60
61u32
d390b480 62nvbios_connEe(struct nvkm_bios *bios, u8 idx, u8 *ver, u8 *len)
cb75d97e
BS
63{
64 u8 hdr, cnt;
20014cbe 65 u32 data = nvbios_connTe(bios, ver, &hdr, &cnt, len);
cb75d97e
BS
66 if (data && idx < cnt)
67 return data + hdr + (idx * *len);
20014cbe
BS
68 return 0x00000000;
69}
70
71u32
d390b480 72nvbios_connEp(struct nvkm_bios *bios, u8 idx, u8 *ver, u8 *len,
20014cbe
BS
73 struct nvbios_connE *info)
74{
75 u32 data = nvbios_connEe(bios, idx, ver, len);
76 memset(info, 0x00, sizeof(*info));
77 switch (!!data * *ver) {
78 case 0x30:
79 case 0x40:
7f5f518f
BS
80 info->type = nvbios_rd08(bios, data + 0x00);
81 info->location = nvbios_rd08(bios, data + 0x01) & 0x0f;
82 info->hpd = (nvbios_rd08(bios, data + 0x01) & 0x30) >> 4;
83 info->dp = (nvbios_rd08(bios, data + 0x01) & 0xc0) >> 6;
20014cbe
BS
84 if (*len < 4)
85 return data;
7f5f518f
BS
86 info->hpd |= (nvbios_rd08(bios, data + 0x02) & 0x03) << 2;
87 info->dp |= nvbios_rd08(bios, data + 0x02) & 0x0c;
88 info->di = (nvbios_rd08(bios, data + 0x02) & 0xf0) >> 4;
89 info->hpd |= (nvbios_rd08(bios, data + 0x03) & 0x07) << 4;
90 info->sr = (nvbios_rd08(bios, data + 0x03) & 0x08) >> 3;
91 info->lcdid = (nvbios_rd08(bios, data + 0x03) & 0x70) >> 4;
20014cbe
BS
92 return data;
93 default:
94 break;
95 }
96 return 0x00000000;
cb75d97e 97}