blob: 6eb8f05ce68a6924b3891ae31f0127cdb0c9bdbd [file] [log] [blame]
Werner Zehc42a6132015-02-12 12:40:15 +01001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2014 Siemens AG
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#ifndef _MODHWINFO_H_
21#define _MODHWINFO_H_
22
23#include <types.h>
24
25#define LEN_MAGIC_NUM 8
26#define LEN_MLFB 20
27#define LEN_SERIAL_NUM 16
28#define LEN_HW_REVISION 2
29#define LEN_MAC_ADDRESS 6
30#define LEN_SPD 128
31#define NUMBER_OF_MAC_ADDR 4
32#define LEN_EDID 128
33#define LEN_MAIN_HWINFO 509
34#define LEN_SHORT_INFO 289
35#define LEN_EDID_INFO 181
36#define NEXT_OFFSET_HWINFO 476
37#define NEXT_OFFSET_SIB 260
38#define NEXT_OFFSET_EDID 176
39#define HWI_LEN_OFFSET 12
40
41/* Define some masks and values */
42#define SIB_HWINIT_IDX 0x0e
43#define SIB_COLOR_6BIT 0x00
44#define SIB_COLOR_8BIT 0x01
45#define SIB_COLOR_10BIT 0x02
46#define SIB_DISP_CON_IDX 0x16
47#define SIB_LVDS_SINGLE_LANE 0x00
48#define SIB_LVDS_DUAL_LANE 0x05
49
50struct PhysDevStruc {
51 u8 bustype;
52 u8 devfn;
53 u16 bus;
54} __attribute__ ((packed));
55
56
57struct hwinfo {
58// Offset 0x0
59 char magicNumber[LEN_MAGIC_NUM];
60// Offset 0x08
61 u8 versionID[4];
62// Offset 0x0c
63 u16 length;
64// Offset 0x0e
65 char BGR_Name[128];
66//Offset 0x8e
67 char MLFB[LEN_MLFB];
68// Offset 0xa2
69 u8 uniqueNumber[16];
70// Offset 0xb2
71 u8 fill_1[12];
72// Offset 0xbe
73 u8 hwRevision[LEN_HW_REVISION];
74//Offset 0xc0
75 u8 macAddress1[LEN_MAC_ADDRESS];
76 u8 numOfAuxMacAddr1;
77 u8 fill_2;
78//Offset 0xc8
79 u8 macAddress2[LEN_MAC_ADDRESS];
80 u8 numOfAuxMacAddr2;
81 u8 fill_3;
82//Offset 0xd0
83 u8 macAddress3[LEN_MAC_ADDRESS];
84 u8 numOfAuxMacAddr3;
85 u8 fill_4;
86//Offset 0xd8
87 u8 macAddress4[LEN_MAC_ADDRESS];
88 u8 numOfAuxMacAddr4;
89 u8 fill_5;
90// Offset 0xe0
91 u8 SPD[LEN_SPD];
92// Offset 0x160
93 u8 fill_6[88];
94// Offset 0x1b8
95 u32 featureFlags;
96// Offset 0x1bc
97 u8 fill_7[4];
98// Offset 0x1c0
99 u32 biosFlags;
100// Offset 0x1c4
101 u8 fill_8[8];
102//Offset 0x1cc
103 struct PhysDevStruc etherDev[NUMBER_OF_MAC_ADDR];
104// Offset 0x1dc
105 s32 nextInfoOffset;
106// Offset 0x1e0
107 u8 fill_9[4];
108// Offset 0x1e4
109 u32 portRTC;
110// Offset 0x1e8
111 u8 typeRTC;
112// Offset 0x1e9
113 u8 fill_10[20];
114} __attribute__ ((packed));
115
116struct shortinfo {
117// Offset 0x0
118 char magicNumber[LEN_MAGIC_NUM];
119// Offset 0x08
120 u8 versionID[4];
121// Offset 0x0c
122 u16 length;
123// Offset 0x0e
124 char BGR_Name[128];
125//Offset 0x8e
126 char MLFB[LEN_MLFB];
127// Offset 0xa2
128 u8 uniqueNumber[26];
129// Offset 0xbc
130 u8 fill_1[12];
131//Offset 0xc8
132 u8 hwRevision[2];
133// Offset 0xca
134 u8 fill_2[18];
135// Offset 0xdc
136 u8 panelFeatures[32];
137// Offset 0xfc
138 u8 fill_3[8];
139// Offset 0x104
140 s32 nextInfoOffset;
141// Offset 0x108
142 u8 fill_4[25];
143} __attribute__ ((packed));
144
145struct edidinfo {
146// Offset 0x0
147 char magicNumber[LEN_MAGIC_NUM];
148// Offset 0x08
149 u8 versionID[4];
150// Offset 0x0c
151 u16 length;
152// Offset 0x0e
153 u8 fill_1[2];
154// Offset 0x10
155 u8 edid[LEN_EDID];
156// Offset 0x90
157 u8 fill_2[32];
158// Offset 0xb0
159 s32 nextInfoOffset;
160// Offset 0xb4
161 u8 fill_3;
162} __attribute__ ((packed));
163
164u8* get_first_linked_block(char *filename, u8 **starting_adr);
165struct hwinfo* get_hwinfo(char *filename);
166struct shortinfo* get_shortinfo(char *filename);
167struct edidinfo* get_edidinfo(char *filename);
168enum cb_err mainboard_get_mac_address(u16 bus, u8 devfn, u8 mac[6]);
169
170#endif /* _MODHWINFO_H_ */