blob: 03b4e47c632153adbce3acaaff99fb9bfbb4c007 [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
Nico Huber25fdb152019-02-17 15:54:39 +01002-- Copyright (C) 2015-2019 secunet Security Networks AG
Nico Huber83693c82016-10-08 22:17:55 +02003--
4-- This program is free software; you can redistribute it and/or modify
5-- it under the terms of the GNU General Public License as published by
Nico Huber125a29e2016-10-18 00:23:54 +02006-- the Free Software Foundation; either version 2 of the License, or
7-- (at your option) any later version.
Nico Huber83693c82016-10-08 22:17:55 +02008--
9-- This program is distributed in the hope that it will be useful,
10-- but WITHOUT ANY WARRANTY; without even the implied warranty of
11-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12-- GNU General Public License for more details.
13--
14
Nico Huber8a9062a2018-06-17 23:15:52 +020015pragma Restrictions (No_Elaboration_Code);
16
Nico Huber27088aa2018-06-10 13:28:05 +020017private package HW.GFX.GMA.Config is
Nico Huber83693c82016-10-08 22:17:55 +020018
Nico Huber6621a142018-06-07 23:56:54 +020019 Gen : constant Generation := <<GEN>>;
20
Nico Huberd7809ab2018-06-10 15:44:23 +020021 CPU_First : constant CPU_Type :=
22 (case Gen is
23 when G45 => G45,
24 when Ironlake => Ironlake,
25 when Haswell => Haswell,
26 when Broxton => Broxton,
27 when Skylake => Skylake);
28 CPU_Last : constant CPU_Type :=
29 (case Gen is
30 when G45 => G45,
31 when Ironlake => Ivybridge,
32 when Haswell => Broadwell,
33 when Broxton => Broxton,
34 when Skylake => Skylake);
35 CPU_Var_Last : constant CPU_Variant :=
36 (case Gen is
Nico Huber25fdb152019-02-17 15:54:39 +010037 when Haswell | Skylake => ULX,
Nico Huberd7809ab2018-06-10 15:44:23 +020038 when others => Normal);
39 subtype Gen_CPU_Type is CPU_Type range CPU_First .. CPU_Last;
40 subtype Gen_CPU_Variant is CPU_Variant range Normal .. CPU_Var_Last;
Nico Huber83693c82016-10-08 22:17:55 +020041
Nico Huberd7809ab2018-06-10 15:44:23 +020042 CPU : constant Gen_CPU_Type := <<CPU>>;
43
44 CPU_Var : constant Gen_CPU_Variant := <<CPU_VARIANT>>;
Nico Huber83693c82016-10-08 22:17:55 +020045
46 Internal_Display : constant Internal_Type := <<INTERNAL_PORT>>;
47
Nico Huberd55afeb2016-10-21 14:31:10 +020048 Analog_I2C_Port : constant PCH_Port := <<ANALOG_I2C_PORT>>;
49
Nico Huber83693c82016-10-08 22:17:55 +020050 EDP_Low_Voltage_Swing : constant Boolean := False;
51
Nico Huber247adf32017-06-12 14:39:11 +020052 DDI_HDMI_Buffer_Translation : constant Integer := -1;
53
Nico Huber83693c82016-10-08 22:17:55 +020054 Default_MMIO_Base : constant := <<DEFAULT_MMIO_BASE>>;
55
56 LVDS_Dual_Threshold : constant := 95_000_000;
57
58 ----------------------------------------------------------------------------
59
Nico Huber30e84082018-06-10 13:28:05 +020060 type Valid_Port_Array is array (Port_Type) of Boolean;
61 type Variable_Config is record
62 Valid_Port : Valid_Port_Array;
63 Raw_Clock : Frequency_Type;
Nico Huberadfe11f2018-06-10 14:59:04 +020064 Dyn_CPU : Gen_CPU_Type;
65 Dyn_CPU_Var : Gen_CPU_Variant;
Nico Huber30e84082018-06-10 13:28:05 +020066 end record;
67
Nico Huber27088aa2018-06-10 13:28:05 +020068 Initial_Settings : constant Variable_Config :=
Nico Huber30e84082018-06-10 13:28:05 +020069 (Valid_Port => (others => False),
Nico Huberadfe11f2018-06-10 14:59:04 +020070 Raw_Clock => Frequency_Type'First,
71 Dyn_CPU => Gen_CPU_Type'First,
72 Dyn_CPU_Var => Gen_CPU_Variant'First);
Nico Huber27088aa2018-06-10 13:28:05 +020073
74 Variable : Variable_Config with Part_Of => GMA.Config_State;
Nico Huber30e84082018-06-10 13:28:05 +020075
76 Valid_Port : Valid_Port_Array renames Variable.Valid_Port;
77 Raw_Clock : Frequency_Type renames Variable.Raw_Clock;
Nico Huberadfe11f2018-06-10 14:59:04 +020078 CPU : Gen_CPU_Type renames Variable.Dyn_CPU;
79 CPU_Var : Gen_CPU_Variant renames Variable.Dyn_CPU_Var;
Nico Huber30e84082018-06-10 13:28:05 +020080
81 ----------------------------------------------------------------------------
82
Nico Huberd9365612018-06-10 14:59:04 +020083 -- To support both static configurations, that are compiled for a
84 -- fixed CPU, and dynamic configurations, where the CPU and its
85 -- variant are detected at runtime, all derived config values are
86 -- tagged based on their dependencies.
87 --
88 -- Booleans that only depend on the generation should be tagged
89 -- <genbool>. Those that may depend on the CPU are tagged with the
90 -- generations where that is the case. For instance `CPU_Ivybridge`
91 -- can be decided purely based on the generation unless the gene-
92 -- ration is Ironlake, thus, it is tagged <ilkbool>.
93 --
94 -- For non-boolean constants, per generation tags <...var> are
95 -- used (e.g. <ilkvar>).
96 --
97 -- To ease parsing, all multiline expressions of tagged config
98 -- values start after a line break.
Nico Huber6621a142018-06-07 23:56:54 +020099
Nico Huberd9365612018-06-10 14:59:04 +0200100 Gen_G45 : <genbool> := Gen = G45;
101 Gen_Ironlake : <genbool> := Gen = Ironlake;
102 Gen_Haswell : <genbool> := Gen = Haswell;
103 Gen_Broxton : <genbool> := Gen = Broxton;
104 Gen_Skylake : <genbool> := Gen = Skylake;
Nico Huber6621a142018-06-07 23:56:54 +0200105
Nico Huberd9365612018-06-10 14:59:04 +0200106 Up_To_Ironlake : <genbool> := Gen <= Ironlake;
107 Ironlake_On : <genbool> := Gen >= Ironlake;
108 Haswell_On : <genbool> := Gen >= Haswell;
109 Broxton_On : <genbool> := Gen >= Broxton;
110 Skylake_On : <genbool> := Gen >= Skylake;
Nico Huber998ee2b2018-06-12 23:02:17 +0200111
Nico Huberd9365612018-06-10 14:59:04 +0200112 CPU_Ironlake : <ilkbool> := Gen_Ironlake and then CPU = Ironlake;
113 CPU_Sandybridge : <ilkbool> := Gen_Ironlake and then CPU = Sandybridge;
114 CPU_Ivybridge : <ilkbool> := Gen_Ironlake and then CPU = Ivybridge;
115 CPU_Haswell : <hswbool> := Gen_Haswell and then CPU = Haswell;
116 CPU_Broadwell : <hswbool> := Gen_Haswell and then CPU = Broadwell;
117
118 Sandybridge_On : <ilkbool> :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200119 ((Gen_Ironlake and then CPU >= Sandybridge) or Haswell_On);
Nico Huberd9365612018-06-10 14:59:04 +0200120 Ivybridge_On : <ilkbool> :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200121 ((Gen_Ironlake and then CPU >= Ivybridge) or Haswell_On);
Nico Huberd9365612018-06-10 14:59:04 +0200122 Broadwell_On : <hswbool> :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200123 ((Gen_Haswell and then CPU >= Broadwell) or Broxton_On);
124
Nico Huber6621a142018-06-07 23:56:54 +0200125 ----------------------------------------------------------------------------
126
Nico Huber117db372018-06-09 17:56:05 +0200127 Have_HDMI_Buf_Override : constant Boolean := DDI_HDMI_Buffer_Translation >= 0;
Nico Huber2b6f6992017-07-09 18:11:34 +0200128 Default_MMIO_Base_Set : constant Boolean := Default_MMIO_Base /= 0;
129
Nico Huber83693c82016-10-08 22:17:55 +0200130 Has_Internal_Display : constant Boolean := Internal_Display /= None;
Nico Huber318bca12018-06-09 19:22:52 +0200131 Internal_Is_LVDS : constant Boolean := Internal_Display = LVDS;
Nico Huber83693c82016-10-08 22:17:55 +0200132 Internal_Is_EDP : constant Boolean := Internal_Display = DP;
Nico Huber1bc496f2017-06-09 22:23:28 +0200133 Have_DVI_I : constant Boolean := Analog_I2C_Port /= PCH_DAC;
Nico Huberd9365612018-06-10 14:59:04 +0200134
135 Has_Presence_Straps : <genbool> := not Gen_Broxton;
136 Is_ULT : <hswsklbool> :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200137 ((Gen_Haswell or Gen_Skylake) and then CPU_Var = ULT);
Nico Huber25fdb152019-02-17 15:54:39 +0100138 Is_ULX : <hswsklbool> :=
139 ((Gen_Haswell or Gen_Skylake) and then CPU_Var = ULX);
140 Is_LP : <hswsklbool> := Is_ULT or Is_ULX;
Nico Huber83693c82016-10-08 22:17:55 +0200141
Nico Huberd9365612018-06-10 14:59:04 +0200142 ---------- CPU pipe: ---------
143 Has_Tertiary_Pipe : <ilkbool> := Ivybridge_On;
144 Disable_Trickle_Feed : <genbool> := not Gen_Haswell;
145 Pipe_Enabled_Workaround : <hswbool> := CPU_Broadwell;
146 Has_EDP_Transcoder : <genbool> := Haswell_On;
147 Use_PDW_For_EDP_Scaling : <hswbool> := CPU_Haswell;
148 Has_Pipe_DDI_Func : <genbool> := Haswell_On;
149 Has_Trans_Clk_Sel : <genbool> := Haswell_On;
150 Has_Pipe_MSA_Misc : <genbool> := Haswell_On;
151 Has_Pipeconf_Misc : <hswbool> := Broadwell_On;
152 Has_Pipeconf_BPC : <hswbool> := not CPU_Haswell;
153 Has_Plane_Control : <genbool> := Broxton_On;
154 Has_DSP_Linoff : <genbool> := Up_To_Ironlake;
155 Has_PF_Pipe_Select : <ilkhswbool> := CPU_Ivybridge or CPU_Haswell;
156 Has_Cursor_FBC_Control : <ilkbool> := Ivybridge_On;
157 VGA_Plane_Workaround : <ilkbool> := CPU_Ivybridge;
158 Has_GMCH_DP_Transcoder : <genbool> := Gen_G45;
159 Has_GMCH_VGACNTRL : <genbool> := Gen_G45;
160 Has_GMCH_PFIT_CONTROL : <genbool> := Gen_G45;
Nico Huber83693c82016-10-08 22:17:55 +0200161
Nico Huberd9365612018-06-10 14:59:04 +0200162 --------- Panel power: -------
163 Has_PP_Write_Protection : <genbool> := Up_To_Ironlake;
164 Has_PP_Port_Select : <genbool> := Up_To_Ironlake;
165 Use_PP_VDD_Override : <genbool> := Up_To_Ironlake;
166 Has_PCH_Panel_Power : <genbool> := Ironlake_On;
Nico Huber83693c82016-10-08 22:17:55 +0200167
Nico Huberd9365612018-06-10 14:59:04 +0200168 ----------- PCH/FDI: ---------
169 Has_PCH : <genbool> := not Gen_Broxton and not Gen_G45;
170 Has_PCH_DAC : <hswbool> :=
Nico Huber25fdb152019-02-17 15:54:39 +0100171 (Gen_Ironlake or (Gen_Haswell and then not Is_LP));
Nico Huber83693c82016-10-08 22:17:55 +0200172
Nico Huberd9365612018-06-10 14:59:04 +0200173 Has_PCH_Aux_Channels : <genbool> := Gen_Ironlake or Gen_Haswell;
Nico Huber83693c82016-10-08 22:17:55 +0200174
Nico Huberd9365612018-06-10 14:59:04 +0200175 VGA_Has_Sync_Disable : <genbool> := Up_To_Ironlake;
Nico Huber83693c82016-10-08 22:17:55 +0200176
Nico Huberd9365612018-06-10 14:59:04 +0200177 Has_Trans_Timing_Ovrrde : <ilkbool> := Sandybridge_On;
Nico Huber83693c82016-10-08 22:17:55 +0200178
Nico Huberd9365612018-06-10 14:59:04 +0200179 Has_DPLL_SEL : <genbool> := Gen_Ironlake;
180 Has_FDI_BPC : <genbool> := Gen_Ironlake;
181 Has_FDI_Composite_Sel : <ilkbool> := CPU_Ivybridge;
182 Has_New_FDI_Sink : <ilkbool> := Sandybridge_On;
183 Has_New_FDI_Source : <ilkbool> := Ivybridge_On;
184 Has_Trans_DP_Ctl : <ilkbool> := CPU_Sandybridge or CPU_Ivybridge;
185 Has_FDI_C : <ilkbool> := CPU_Ivybridge;
Nico Huber83693c82016-10-08 22:17:55 +0200186
Nico Huberd9365612018-06-10 14:59:04 +0200187 Has_FDI_RX_Power_Down : <genbool> := Gen_Haswell;
Nico Huber83693c82016-10-08 22:17:55 +0200188
Nico Huberd9365612018-06-10 14:59:04 +0200189 Has_GMCH_RawClk : <genbool> := Gen_G45;
Arthur Heymans73ea0322018-03-28 17:17:07 +0200190
Nico Huberd9365612018-06-10 14:59:04 +0200191 ----------- DDI: -------------
192 End_EDP_Training_Late : <genbool> := Gen_Haswell;
193 Has_Per_DDI_Clock_Sel : <genbool> := Gen_Haswell;
194 Has_HOTPLUG_CTL : <genbool> := Gen_Haswell;
195 Has_SHOTPLUG_CTL_A : <hswbool> :=
Nico Huber25fdb152019-02-17 15:54:39 +0100196 ((Gen_Haswell and then Is_LP) or Skylake_On);
Nico Huber83693c82016-10-08 22:17:55 +0200197
Nico Huberd9365612018-06-10 14:59:04 +0200198 Has_DDI_PHYs : <genbool> := Gen_Broxton;
Nico Huber19729a72017-07-30 01:05:05 +0200199
Nico Huberd9365612018-06-10 14:59:04 +0200200 Has_DDI_D : <hswsklbool> :=
Nico Huber25fdb152019-02-17 15:54:39 +0100201 ((Gen_Haswell or Gen_Skylake) and then not Is_LP);
Nico Huberd9365612018-06-10 14:59:04 +0200202 -- might be disabled by x4 eDP:
203 Has_DDI_E : <hswsklbool> := Has_DDI_D;
Nico Huber83693c82016-10-08 22:17:55 +0200204
Nico Huberd9365612018-06-10 14:59:04 +0200205 Has_DDI_Buffer_Trans : <genbool> := Haswell_On and not Has_DDI_PHYs;
206 Has_Low_Voltage_Swing : <genbool> := Broxton_On;
207 Has_Iboost_Config : <genbool> := Skylake_On;
Nico Huber83693c82016-10-08 22:17:55 +0200208
Nico Huberd9365612018-06-10 14:59:04 +0200209 Need_DP_Aux_Mutex : <genbool> := False; -- Skylake & (PSR | GTC)
Nico Huber83693c82016-10-08 22:17:55 +0200210
Nico Huber25fdb152019-02-17 15:54:39 +0100211 ----- DP: --------------------
212 DP_Max_2_7_GHz : <hswbool> :=
213 (not Haswell_On or else (CPU_Haswell and Is_ULX));
214
Nico Huberd9365612018-06-10 14:59:04 +0200215 ----------- GMBUS: -----------
216 Ungate_GMBUS_Unit_Level : <genbool> := Skylake_On;
217 GMBUS_Alternative_Pins : <genbool> := Gen_Broxton;
218 Has_PCH_GMBUS : <genbool> := Ironlake_On;
Nico Huber83693c82016-10-08 22:17:55 +0200219
Nico Huberd9365612018-06-10 14:59:04 +0200220 ----------- Power: -----------
221 Has_IPS : <hswbool> :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200222 (Gen_Haswell and then
Nico Huber25fdb152019-02-17 15:54:39 +0100223 ((CPU_Haswell and Is_LP) or CPU_Broadwell));
Nico Huberd9365612018-06-10 14:59:04 +0200224 Has_IPS_CTL_Mailbox : <hswbool> := CPU_Broadwell;
Nico Huber83693c82016-10-08 22:17:55 +0200225
Nico Huberd9365612018-06-10 14:59:04 +0200226 Has_Per_Pipe_SRD : <hswbool> := Broadwell_On;
Nico Huber83693c82016-10-08 22:17:55 +0200227
Nico Huberd9365612018-06-10 14:59:04 +0200228 ----------- GTT: -------------
229 Has_64bit_GTT : <hswbool> := Broadwell_On;
Nico Huber83693c82016-10-08 22:17:55 +0200230
231 ----------------------------------------------------------------------------
232
Nico Huberd9365612018-06-10 14:59:04 +0200233 Max_Pipe : <ilkvar> Pipe_Index :=
Nico Huberd58de7d2018-06-07 23:06:55 +0200234 (if Has_Tertiary_Pipe then Tertiary else Secondary);
Nico Huber83693c82016-10-08 22:17:55 +0200235
Nico Huberd9365612018-06-10 14:59:04 +0200236 Last_Digital_Port : <hswsklvar> Digital_Port :=
Nico Huber208857d2017-07-29 21:30:24 +0200237 (if Has_DDI_E then DIGI_E else DIGI_C);
Nico Huberac455ad2017-02-14 14:41:19 +0100238
Nico Huber83693c82016-10-08 22:17:55 +0200239 ----------------------------------------------------------------------------
240
Nico Huber3c544ee2016-11-20 04:56:58 +0100241 type FDI_Per_Port is array (Port_Type) of Boolean;
Nico Huberd9365612018-06-10 14:59:04 +0200242 Is_FDI_Port : <hswvar> FDI_Per_Port :=
Nico Huber6621a142018-06-07 23:56:54 +0200243 (Disabled => False,
244 Internal => Gen_Ironlake and Internal_Is_LVDS,
245 DP1 .. HDMI3 => Gen_Ironlake,
246 Analog => Has_PCH_DAC);
Nico Huber83693c82016-10-08 22:17:55 +0200247
248 type FDI_Lanes_Per_Port is array (GPU_Port) of DP_Lane_Count;
249 FDI_Lane_Count : constant FDI_Lanes_Per_Port :=
250 (DIGI_D => DP_Lane_Count_2,
Nico Huber6621a142018-06-07 23:56:54 +0200251 others => (if Gen_Ironlake then DP_Lane_Count_4 else DP_Lane_Count_2));
Nico Huber83693c82016-10-08 22:17:55 +0200252
Nico Huberd9365612018-06-10 14:59:04 +0200253 FDI_Training : <ilkvar> FDI_Training_Type :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200254 (if CPU_Ironlake then Simple_Training
255 elsif CPU_Sandybridge then Full_Training
256 else Auto_Training);
Nico Huber83693c82016-10-08 22:17:55 +0200257
Nico Huberf54d0962016-10-20 14:17:18 +0200258 ----------------------------------------------------------------------------
259
Nico Huber25fdb152019-02-17 15:54:39 +0100260 DDI_Buffer_Iboost : <hswsklvar> Natural := (if Is_ULX then 3 else 1);
261
Nico Huberd9365612018-06-10 14:59:04 +0200262 Default_DDI_HDMI_Buffer_Translation : <hswvar> DDI_HDMI_Buf_Trans_Range :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200263 (if CPU_Haswell then 6
264 elsif CPU_Broadwell then 7
265 elsif Broxton_On then 8
266 else 0);
Nico Huber247adf32017-06-12 14:39:11 +0200267
268 ----------------------------------------------------------------------------
269
Nico Huber25fdb152019-02-17 15:54:39 +0100270 Default_CDClk_Freq : <ilkhswvar> Frequency_Type :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200271 (if Gen_G45 then 320_000_000 -- unused
Nico Huber25fdb152019-02-17 15:54:39 +0100272 elsif CPU_Ironlake then 450_000_000
Nico Huber998ee2b2018-06-12 23:02:17 +0200273 elsif CPU_Sandybridge or CPU_Ivybridge then 400_000_000
Nico Huber25fdb152019-02-17 15:54:39 +0100274 elsif Gen_Haswell and then Is_ULX then 337_500_000
275 elsif Gen_Haswell then 450_000_000
Nico Huber998ee2b2018-06-12 23:02:17 +0200276 elsif Gen_Broxton then 288_000_000
277 elsif Gen_Skylake then 337_500_000
278 else Frequency_Type'First);
Nico Huberabe3de22016-10-20 15:03:46 +0200279
Nico Huberd9365612018-06-10 14:59:04 +0200280 Default_RawClk_Freq : <hswvar> Frequency_Type :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200281 (if Gen_G45 then 100_000_000 -- unused, depends on FSB
282 elsif Gen_Ironlake then 125_000_000
Nico Huber25fdb152019-02-17 15:54:39 +0100283 elsif Gen_Haswell then (if Is_LP then 24_000_000 else 125_000_000)
Nico Huber998ee2b2018-06-12 23:02:17 +0200284 elsif Gen_Broxton then Frequency_Type'First -- none needed
285 elsif Gen_Skylake then 24_000_000
286 else Frequency_Type'First);
Nico Huberf54d0962016-10-20 14:17:18 +0200287
Nico Huberdcd274b2016-11-03 20:15:39 +0100288 ----------------------------------------------------------------------------
289
290 -- Maximum source width with enabled scaler. This only accounts
291 -- for simple 1:1 pipe:scaler mappings.
292
Nico Huberc5c767a2018-06-03 01:09:04 +0200293 type Width_Per_Pipe is array (Pipe_Index) of Width_Type;
Nico Huberdcd274b2016-11-03 20:15:39 +0100294
Nico Huberd9365612018-06-10 14:59:04 +0200295 Maximum_Scalable_Width : <hswvar> Width_Per_Pipe :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200296 (if Gen_G45 then -- TODO: Is this true?
297 (Primary => 4096,
298 Secondary => 2048,
299 Tertiary => Pos32'First)
300 elsif Gen_Ironlake or CPU_Haswell then
301 (Primary => 4096,
302 Secondary => 2048,
303 Tertiary => 2048)
304 else
305 (Primary => 4096,
306 Secondary => 4096,
307 Tertiary => 4096));
Nico Huberdcd274b2016-11-03 20:15:39 +0100308
Nico Hubera02b2c62018-01-09 15:58:34 +0100309 -- Maximum X position of hardware cursors
Nico Huberd9365612018-06-10 14:59:04 +0200310 Maximum_Cursor_X : constant :=
311 (case Gen is
312 when G45 .. Ironlake => 4095,
313 when Haswell .. Skylake => 8191);
Nico Hubera02b2c62018-01-09 15:58:34 +0100314
315 Maximum_Cursor_Y : constant := 4095;
316
Nico Huber74ec9622016-11-19 03:00:43 +0100317 ----------------------------------------------------------------------------
318
Nico Huber21da5742017-01-20 14:00:53 +0100319 -- FIXME: Unknown for Broxton, Linux' i915 contains a fixme too :-D
Nico Huber74ec9622016-11-19 03:00:43 +0100320 HDMI_Max_Clock_24bpp : constant Frequency_Type :=
Nico Huber6621a142018-06-07 23:56:54 +0200321 (if Haswell_On then 300_000_000 else 225_000_000);
Nico Huber74ec9622016-11-19 03:00:43 +0100322
Nico Huberb8ae6182017-07-15 20:03:56 +0200323 ----------------------------------------------------------------------------
324
Nico Huberadfe11f2018-06-10 14:59:04 +0200325 GTT_PTE_Size : <hswvar> Natural := (if Has_64bit_GTT then 8 else 4);
Nico Huberb8ae6182017-07-15 20:03:56 +0200326
Nico Huberadfe11f2018-06-10 14:59:04 +0200327 Fence_Base : <ilkvar> Natural :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200328 (if not Sandybridge_On then 16#0000_3000# else 16#0010_0000#);
Nico Huberb03c8f12017-08-25 13:29:08 +0200329
Nico Huberadfe11f2018-06-10 14:59:04 +0200330 Fence_Count : <ilkvar> Natural :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200331 (if not Ivybridge_On then 16 else 32);
Nico Huberb03c8f12017-08-25 13:29:08 +0200332
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200333 ----------------------------------------------------------------------------
334
335 use type HW.Word16;
336
Nico Huber25fdb152019-02-17 15:54:39 +0100337 -- GMA PCI IDs:
338 --
339 -- Rather catch too much here than too little, it's
340 -- mostly used to distinguish generations. Best public
341 -- reference for these IDs is Linux' i915.
342 --
343 -- Since Sandybridge, bits 4 and 5 encode the compu-
344 -- tational capabilities and can mostly be ignored.
345 -- From Haswell on, we have to distinguish between
346 -- Normal, ULT (U CPU lines) and ULX (Y CPU lines).
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200347
Nico Huber25fdb152019-02-17 15:54:39 +0100348 function Is_Haswell_Y (Device_Id : Word16) return Boolean is
349 ((Device_Id and 16#ffef#) = 16#0a0e#);
350 function Is_Haswell_U (Device_Id : Word16) return Boolean is
351 (((Device_Id and 16#ffc3#) = 16#0a02# or
352 (Device_Id and 16#ffcf#) = 16#0a0b#) and
353 not Is_Haswell_Y (Device_Id));
354 function Is_Haswell (Device_Id : Word16) return Boolean is
355 ((Device_Id and 16#ffc3#) = 16#0402# or
356 (Device_Id and 16#ffcf#) = 16#040b# or
357 (Device_Id and 16#ffc3#) = 16#0c02# or
358 (Device_Id and 16#ffcf#) = 16#0c0b# or
359 (Device_Id and 16#ffc3#) = 16#0d02# or
360 (Device_Id and 16#ffcf#) = 16#0d0b#);
361
362 function Is_Broadwell_Y (Device_Id : Word16) return Boolean is
363 ((Device_Id and 16#ffcf#) = 16#160e#);
364 function Is_Broadwell_U (Device_Id : Word16) return Boolean is
365 ((Device_Id and 16#ffcf#) = 16#1606# or
366 (Device_Id and 16#ffcf#) = 16#160b#);
367 function Is_Broadwell (Device_Id : Word16) return Boolean is
368 ((Device_Id and 16#ffc7#) = 16#1602# or
369 (Device_Id and 16#ffcf#) = 16#160d#);
370
371 function Is_Skylake_Y (Device_Id : Word16) return Boolean is
372 ((Device_Id and 16#ffcf#) = 16#190e#);
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200373 function Is_Skylake_U (Device_Id : Word16) return Boolean is
Nico Huber25fdb152019-02-17 15:54:39 +0100374 ((Device_Id and 16#ffc9#) = 16#1901# or
375 (Device_Id and 16#ffcf#) = 16#1906#);
376 function Is_Skylake (Device_Id : Word16) return Boolean is
377 ((Device_Id and 16#ffc7#) = 16#1902# or
378 (Device_Id and 16#ffcf#) = 16#190b# or
379 (Device_Id and 16#ffcf#) = 16#190d#);
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200380
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200381 function Is_GPU (Device_Id : Word16; CPU : CPU_Type; CPU_Var : CPU_Variant)
382 return Boolean is
383 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200384 when G45 => (Device_Id and 16#ff02#) = 16#2e02# or
385 (Device_Id and 16#fffe#) = 16#2a42#,
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200386 when Ironlake => (Device_Id and 16#fff3#) = 16#0042#,
387 when Sandybridge => (Device_Id and 16#ffc2#) = 16#0102#,
388 when Ivybridge => (Device_Id and 16#ffc3#) = 16#0142#,
Nico Huber25fdb152019-02-17 15:54:39 +0100389 when Haswell => (case CPU_Var is
390 when Normal => Is_Haswell (Device_Id),
391 when ULT => Is_Haswell_U (Device_Id),
392 when ULX => Is_Haswell_Y (Device_Id)),
393 when Broadwell => (case CPU_Var is
394 when Normal => Is_Broadwell (Device_Id),
395 when ULT => Is_Broadwell_U (Device_Id),
396 when ULX => Is_Broadwell_Y (Device_Id)),
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200397 when Broxton => (Device_Id and 16#fffe#) = 16#5a84#,
Nico Huber25fdb152019-02-17 15:54:39 +0100398 when Skylake => (case CPU_Var is
399 when Normal => Is_Skylake (Device_Id),
400 when ULT => Is_Skylake_U (Device_Id),
401 when ULX => Is_Skylake_Y (Device_Id)));
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200402
403 function Compatible_GPU (Device_Id : Word16) return Boolean is
404 (Is_GPU (Device_Id, CPU, CPU_Var));
405
Nico Huber6a996dc2018-06-17 16:30:33 +0200406 pragma Warnings (GNATprove, Off, "subprogram ""Detect_CPU"" has no effect",
407 Reason => "only effective in dynamic cpu config");
408 procedure Detect_CPU (Device : Word16)<cpunull>;
409
Nico Huber83693c82016-10-08 22:17:55 +0200410end HW.GFX.GMA.Config;