Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright 2012 Red Hat Inc.
0003  *
0004  * Permission is hereby granted, free of charge, to any person obtaining a
0005  * copy of this software and associated documentation files (the "Software"),
0006  * to deal in the Software without restriction, including without limitation
0007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
0008  * and/or sell copies of the Software, and to permit persons to whom the
0009  * Software is furnished to do so, subject to the following conditions:
0010  *
0011  * The above copyright notice and this permission notice shall be included in
0012  * all copies or substantial portions of the Software.
0013  *
0014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
0015  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
0016  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
0017  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
0018  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
0019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
0020  * OTHER DEALINGS IN THE SOFTWARE.
0021  *
0022  * Authors: Ben Skeggs
0023  */
0024 #include <subdev/bios.h>
0025 #include <subdev/bios/dcb.h>
0026 #include <subdev/bios/conn.h>
0027 
0028 u32
0029 nvbios_connTe(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len)
0030 {
0031     u32 dcb = dcb_table(bios, ver, hdr, cnt, len);
0032     if (dcb && *ver >= 0x30 && *hdr >= 0x16) {
0033         u32 data = nvbios_rd16(bios, dcb + 0x14);
0034         if (data) {
0035             *ver = nvbios_rd08(bios, data + 0);
0036             *hdr = nvbios_rd08(bios, data + 1);
0037             *cnt = nvbios_rd08(bios, data + 2);
0038             *len = nvbios_rd08(bios, data + 3);
0039             return data;
0040         }
0041     }
0042     return 0x00000000;
0043 }
0044 
0045 u32
0046 nvbios_connTp(struct nvkm_bios *bios, u8 *ver, u8 *hdr, u8 *cnt, u8 *len,
0047           struct nvbios_connT *info)
0048 {
0049     u32 data = nvbios_connTe(bios, ver, hdr, cnt, len);
0050     memset(info, 0x00, sizeof(*info));
0051     switch (!!data * *ver) {
0052     case 0x30:
0053     case 0x40:
0054         return data;
0055     default:
0056         break;
0057     }
0058     return 0x00000000;
0059 }
0060 
0061 u32
0062 nvbios_connEe(struct nvkm_bios *bios, u8 idx, u8 *ver, u8 *len)
0063 {
0064     u8  hdr, cnt;
0065     u32 data = nvbios_connTe(bios, ver, &hdr, &cnt, len);
0066     if (data && idx < cnt)
0067         return data + hdr + (idx * *len);
0068     return 0x00000000;
0069 }
0070 
0071 u32
0072 nvbios_connEp(struct nvkm_bios *bios, u8 idx, u8 *ver, u8 *len,
0073           struct nvbios_connE *info)
0074 {
0075     u32 data = nvbios_connEe(bios, idx, ver, len);
0076     memset(info, 0x00, sizeof(*info));
0077     switch (!!data * *ver) {
0078     case 0x30:
0079     case 0x40:
0080         info->type     =  nvbios_rd08(bios, data + 0x00);
0081         info->location =  nvbios_rd08(bios, data + 0x01) & 0x0f;
0082         info->hpd      = (nvbios_rd08(bios, data + 0x01) & 0x30) >> 4;
0083         info->dp       = (nvbios_rd08(bios, data + 0x01) & 0xc0) >> 6;
0084         if (*len < 4)
0085             return data;
0086         info->hpd     |= (nvbios_rd08(bios, data + 0x02) & 0x03) << 2;
0087         info->dp      |=  nvbios_rd08(bios, data + 0x02) & 0x0c;
0088         info->di       = (nvbios_rd08(bios, data + 0x02) & 0xf0) >> 4;
0089         info->hpd     |= (nvbios_rd08(bios, data + 0x03) & 0x07) << 4;
0090         info->sr       = (nvbios_rd08(bios, data + 0x03) & 0x08) >> 3;
0091         info->lcdid    = (nvbios_rd08(bios, data + 0x03) & 0x70) >> 4;
0092         return data;
0093     default:
0094         break;
0095     }
0096     return 0x00000000;
0097 }