blob: 6aa242e7cc6ae086ca8380cf3b1c60e394728f86 [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 Huber27088aa2018-06-10 13:28:05 +020015private package HW.GFX.GMA.Config is
Nico Huber83693c82016-10-08 22:17:55 +020016
Nico Huber6621a142018-06-07 23:56:54 +020017 Gen : constant Generation := <<GEN>>;
18
Nico Huberd7809ab2018-06-10 15:44:23 +020019 CPU_First : constant CPU_Type :=
20 (case Gen is
21 when G45 => G45,
22 when Ironlake => Ironlake,
23 when Haswell => Haswell,
24 when Broxton => Broxton,
Tim Wawrzynczak605660b2022-06-08 12:48:19 -060025 when Skylake => Skylake,
26 when Tigerlake => Tigerlake);
Nico Huberd7809ab2018-06-10 15:44:23 +020027 CPU_Last : constant CPU_Type :=
28 (case Gen is
Nico Huber7f3e2802019-09-28 20:40:55 +020029 when G45 => GM45,
Nico Huberd7809ab2018-06-10 15:44:23 +020030 when Ironlake => Ivybridge,
31 when Haswell => Broadwell,
32 when Broxton => Broxton,
Tim Wawrzynczak605660b2022-06-08 12:48:19 -060033 when Skylake => Kabylake,
34 when Tigerlake => Tigerlake);
Nico Huberd7809ab2018-06-10 15:44:23 +020035 CPU_Var_Last : constant CPU_Variant :=
36 (case Gen is
Tim Wawrzynczak605660b2022-06-08 12:48:19 -060037 when Haswell | Skylake | Tigerlake => ULX,
38 when others => Normal);
Nico Huberd7809ab2018-06-10 15:44:23 +020039 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
Nico Hubere79babd2020-12-20 01:33:26 +010046 PCH_First : constant PCH_Type :=
47 (case Gen is
48 when G45 => No_PCH,
49 when Ironlake => Ibex_Peak,
50 when Haswell => Lynx_Point,
51 when Broxton => No_PCH,
Tim Wawrzynczak605660b2022-06-08 12:48:19 -060052 when Skylake => Sunrise_Point,
53 when Tigerlake => Tiger_Point);
Nico Hubere79babd2020-12-20 01:33:26 +010054 PCH_Last : constant PCH_Type :=
55 (case Gen is
56 when G45 => No_PCH,
57 when Ironlake => Cougar_Point,
58 when Haswell => Lynx_Point,
59 when Broxton => No_PCH,
Tim Wawrzynczak605660b2022-06-08 12:48:19 -060060 when Skylake => Cannon_Point,
61 when Tigerlake => Tiger_Point);
Nico Hubere79babd2020-12-20 01:33:26 +010062 subtype Gen_PCH_Type is PCH_Type range PCH_First .. PCH_Last;
63
64 PCH : constant Gen_PCH_Type := <<PCH>>;
65
Nico Huber2bbd6e72020-01-07 18:22:59 +010066 Panel_Ports : constant array (Valid_Panels) of Port_Type :=
Nico Huber5dbaf4b2020-01-08 17:24:58 +010067 (Panel_1 => <<PANEL_1_PORT>>,
68 Panel_2 => <<PANEL_2_PORT>>);
Nico Huber83693c82016-10-08 22:17:55 +020069
Nico Huberd55afeb2016-10-21 14:31:10 +020070 Analog_I2C_Port : constant PCH_Port := <<ANALOG_I2C_PORT>>;
71
Nico Huber83693c82016-10-08 22:17:55 +020072 EDP_Low_Voltage_Swing : constant Boolean := False;
73
Nico Huber247adf32017-06-12 14:39:11 +020074 DDI_HDMI_Buffer_Translation : constant Integer := -1;
75
Nico Huber83693c82016-10-08 22:17:55 +020076 Default_MMIO_Base : constant := <<DEFAULT_MMIO_BASE>>;
77
78 LVDS_Dual_Threshold : constant := 95_000_000;
79
Matt DeVillier2a3dbba2020-05-14 17:34:13 -050080 Ignore_Presence_Straps : constant Boolean := <<IGNORE_STRAPS>>;
81
Nico Huber83693c82016-10-08 22:17:55 +020082 ----------------------------------------------------------------------------
83
Nico Huber07ff1b92019-09-29 00:03:17 +020084 -- On older generations dot clocks are limited to 90% of
85 -- the CDClk rate. To ease proofs, we limit CDClk's range.
86 CDClk_Min : constant Frequency_Type :=
87 (case Gen is
88 when G45 .. Ironlake => Frequency_Type'First * 100 / 90 + 1,
89 when others => Frequency_Type'First);
90 subtype CDClk_Range is Frequency_Type range CDClk_Min .. Frequency_Type'Last;
91
92 ----------------------------------------------------------------------------
93
Nico Huber30e84082018-06-10 13:28:05 +020094 type Valid_Port_Array is array (Port_Type) of Boolean;
95 type Variable_Config is record
96 Valid_Port : Valid_Port_Array;
Nico Huber07ff1b92019-09-29 00:03:17 +020097 CDClk : CDClk_Range;
98 Max_CDClk : CDClk_Range;
Nico Huber30e84082018-06-10 13:28:05 +020099 Raw_Clock : Frequency_Type;
Nico Huberadfe11f2018-06-10 14:59:04 +0200100 Dyn_CPU : Gen_CPU_Type;
101 Dyn_CPU_Var : Gen_CPU_Variant;
Nico Huber30e84082018-06-10 13:28:05 +0200102 end record;
103
Nico Huber27088aa2018-06-10 13:28:05 +0200104 Initial_Settings : constant Variable_Config :=
Nico Huber30e84082018-06-10 13:28:05 +0200105 (Valid_Port => (others => False),
Nico Huber07ff1b92019-09-29 00:03:17 +0200106 CDClk => CDClk_Range'First,
107 Max_CDClk => CDClk_Range'First,
Nico Huberadfe11f2018-06-10 14:59:04 +0200108 Raw_Clock => Frequency_Type'First,
109 Dyn_CPU => Gen_CPU_Type'First,
110 Dyn_CPU_Var => Gen_CPU_Variant'First);
Nico Huber27088aa2018-06-10 13:28:05 +0200111
Nico Hubere317e9c2019-09-29 03:03:18 +0200112 Variable : Variable_Config with Part_Of => GMA.State;
Nico Huber30e84082018-06-10 13:28:05 +0200113
114 Valid_Port : Valid_Port_Array renames Variable.Valid_Port;
Nico Huber07ff1b92019-09-29 00:03:17 +0200115 CDClk : CDClk_Range renames Variable.CDClk;
116 Max_CDClk : CDClk_Range renames Variable.Max_CDClk;
Nico Huber30e84082018-06-10 13:28:05 +0200117 Raw_Clock : Frequency_Type renames Variable.Raw_Clock;
Nico Huberadfe11f2018-06-10 14:59:04 +0200118 CPU : Gen_CPU_Type renames Variable.Dyn_CPU;
119 CPU_Var : Gen_CPU_Variant renames Variable.Dyn_CPU_Var;
Nico Huber30e84082018-06-10 13:28:05 +0200120
121 ----------------------------------------------------------------------------
122
Nico Huberd9365612018-06-10 14:59:04 +0200123 -- To support both static configurations, that are compiled for a
124 -- fixed CPU, and dynamic configurations, where the CPU and its
125 -- variant are detected at runtime, all derived config values are
126 -- tagged based on their dependencies.
127 --
128 -- Booleans that only depend on the generation should be tagged
129 -- <genbool>. Those that may depend on the CPU are tagged with the
130 -- generations where that is the case. For instance `CPU_Ivybridge`
131 -- can be decided purely based on the generation unless the gene-
132 -- ration is Ironlake, thus, it is tagged <ilkbool>.
133 --
134 -- For non-boolean constants, per generation tags <...var> are
135 -- used (e.g. <ilkvar>).
136 --
137 -- To ease parsing, all multiline expressions of tagged config
138 -- values start after a line break.
Nico Huber6621a142018-06-07 23:56:54 +0200139
Nico Huberd9365612018-06-10 14:59:04 +0200140 Gen_G45 : <genbool> := Gen = G45;
141 Gen_Ironlake : <genbool> := Gen = Ironlake;
142 Gen_Haswell : <genbool> := Gen = Haswell;
143 Gen_Broxton : <genbool> := Gen = Broxton;
144 Gen_Skylake : <genbool> := Gen = Skylake;
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600145 Gen_Tigerlake : <genbool> := Gen = Tigerlake;
Nico Huber6621a142018-06-07 23:56:54 +0200146
Nico Huberd9365612018-06-10 14:59:04 +0200147 Up_To_Ironlake : <genbool> := Gen <= Ironlake;
148 Ironlake_On : <genbool> := Gen >= Ironlake;
149 Haswell_On : <genbool> := Gen >= Haswell;
150 Broxton_On : <genbool> := Gen >= Broxton;
151 Skylake_On : <genbool> := Gen >= Skylake;
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600152 Tigerlake_On : <genbool> := Gen >= Tigerlake;
Nico Huber998ee2b2018-06-12 23:02:17 +0200153
Nico Huberb47a5c42019-09-29 00:07:21 +0200154 GMCH_GM45 : <g45bool> := Gen_G45 and then CPU = GM45;
Nico Huberd9365612018-06-10 14:59:04 +0200155 CPU_Ironlake : <ilkbool> := Gen_Ironlake and then CPU = Ironlake;
156 CPU_Sandybridge : <ilkbool> := Gen_Ironlake and then CPU = Sandybridge;
157 CPU_Ivybridge : <ilkbool> := Gen_Ironlake and then CPU = Ivybridge;
158 CPU_Haswell : <hswbool> := Gen_Haswell and then CPU = Haswell;
159 CPU_Broadwell : <hswbool> := Gen_Haswell and then CPU = Broadwell;
Nico Huber88badbe2018-09-27 16:36:47 +0200160 CPU_Skylake : <sklbool> := Gen_Skylake and then CPU = Skylake;
161 CPU_Kabylake : <sklbool> := Gen_Skylake and then CPU = Kabylake;
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600162 CPU_Tigerlake : <tglbool> := Gen_Tigerlake;
Nico Huberd9365612018-06-10 14:59:04 +0200163
164 Sandybridge_On : <ilkbool> :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200165 ((Gen_Ironlake and then CPU >= Sandybridge) or Haswell_On);
Nico Huberd9365612018-06-10 14:59:04 +0200166 Ivybridge_On : <ilkbool> :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200167 ((Gen_Ironlake and then CPU >= Ivybridge) or Haswell_On);
Nico Huberd9365612018-06-10 14:59:04 +0200168 Broadwell_On : <hswbool> :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200169 ((Gen_Haswell and then CPU >= Broadwell) or Broxton_On);
170
Nico Hubere79babd2020-12-20 01:33:26 +0100171 PCH_Cougar_Point : <genbool> := Gen_Ironlake and then PCH = Cougar_Point;
172
173 Cougar_Point_On : <genbool> :=
174 ((Gen_Ironlake and then PCH >= Cougar_Point) or Haswell_On);
Nico Huberdde06302020-12-20 02:18:30 +0100175 Cannon_Point_On : <genbool> := Skylake_On and then PCH >= Cannon_Point;
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600176 Tiger_Point_On : <genbool> := Tigerlake_On and then PCH >= Tiger_Point;
Nico Hubere79babd2020-12-20 01:33:26 +0100177
Nico Huber6621a142018-06-07 23:56:54 +0200178 ----------------------------------------------------------------------------
179
Nico Huber117db372018-06-09 17:56:05 +0200180 Have_HDMI_Buf_Override : constant Boolean := DDI_HDMI_Buffer_Translation >= 0;
Nico Huber2b6f6992017-07-09 18:11:34 +0200181 Default_MMIO_Base_Set : constant Boolean := Default_MMIO_Base /= 0;
182
Nico Huber1bc496f2017-06-09 22:23:28 +0200183 Have_DVI_I : constant Boolean := Analog_I2C_Port /= PCH_DAC;
Nico Huberd9365612018-06-10 14:59:04 +0200184
185 Has_Presence_Straps : <genbool> := not Gen_Broxton;
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600186 Is_ULT : <hswskltglbool> :=
187 ((Gen_Haswell or Gen_Skylake or Gen_Tigerlake) and then CPU_Var = ULT);
188 Is_ULX : <hswskltglbool> :=
189 ((Gen_Haswell or Gen_Skylake or Gen_Tigerlake) and then CPU_Var = ULX);
190 Is_LP : <hswskltglbool> := Is_ULT or Is_ULX;
Nico Huber83693c82016-10-08 22:17:55 +0200191
Nico Huberd9365612018-06-10 14:59:04 +0200192 ---------- CPU pipe: ---------
193 Has_Tertiary_Pipe : <ilkbool> := Ivybridge_On;
194 Disable_Trickle_Feed : <genbool> := not Gen_Haswell;
195 Pipe_Enabled_Workaround : <hswbool> := CPU_Broadwell;
196 Has_EDP_Transcoder : <genbool> := Haswell_On;
197 Use_PDW_For_EDP_Scaling : <hswbool> := CPU_Haswell;
198 Has_Pipe_DDI_Func : <genbool> := Haswell_On;
199 Has_Trans_Clk_Sel : <genbool> := Haswell_On;
200 Has_Pipe_MSA_Misc : <genbool> := Haswell_On;
201 Has_Pipeconf_Misc : <hswbool> := Broadwell_On;
202 Has_Pipeconf_BPC : <hswbool> := not CPU_Haswell;
203 Has_Plane_Control : <genbool> := Broxton_On;
204 Has_DSP_Linoff : <genbool> := Up_To_Ironlake;
205 Has_PF_Pipe_Select : <ilkhswbool> := CPU_Ivybridge or CPU_Haswell;
Nico Huber75a707f2018-06-18 16:28:33 +0200206 Has_Ivybridge_Cursors : <ilkbool> := Ivybridge_On;
Nico Huberd9365612018-06-10 14:59:04 +0200207 VGA_Plane_Workaround : <ilkbool> := CPU_Ivybridge;
208 Has_GMCH_DP_Transcoder : <genbool> := Gen_G45;
209 Has_GMCH_VGACNTRL : <genbool> := Gen_G45;
210 Has_GMCH_PFIT_CONTROL : <genbool> := Gen_G45;
Nico Huber83693c82016-10-08 22:17:55 +0200211
Nico Huberd9365612018-06-10 14:59:04 +0200212 --------- Panel power: -------
213 Has_PP_Write_Protection : <genbool> := Up_To_Ironlake;
214 Has_PP_Port_Select : <genbool> := Up_To_Ironlake;
215 Use_PP_VDD_Override : <genbool> := Up_To_Ironlake;
216 Has_PCH_Panel_Power : <genbool> := Ironlake_On;
Nico Huberdde06302020-12-20 02:18:30 +0100217 Has_PP_Divisor_Reg : <genbool> :=
218 (not Gen_Broxton and not Cannon_Point_On);
219 Has_New_Backlight_Control : <genbool> := Gen_Broxton or Cannon_Point_On;
Nico Huber83693c82016-10-08 22:17:55 +0200220
Nico Huberd9365612018-06-10 14:59:04 +0200221 ----------- PCH/FDI: ---------
Nico Hubere79babd2020-12-20 01:33:26 +0100222 Has_PCH : <genbool> := PCH /= No_PCH;
Nico Huberd9365612018-06-10 14:59:04 +0200223 Has_PCH_DAC : <hswbool> :=
Nico Huber25fdb152019-02-17 15:54:39 +0100224 (Gen_Ironlake or (Gen_Haswell and then not Is_LP));
Nico Huber83693c82016-10-08 22:17:55 +0200225
Nico Huberd9365612018-06-10 14:59:04 +0200226 Has_PCH_Aux_Channels : <genbool> := Gen_Ironlake or Gen_Haswell;
Nico Huber83693c82016-10-08 22:17:55 +0200227
Nico Huberd9365612018-06-10 14:59:04 +0200228 VGA_Has_Sync_Disable : <genbool> := Up_To_Ironlake;
Nico Huber83693c82016-10-08 22:17:55 +0200229
Nico Huberd9365612018-06-10 14:59:04 +0200230 Has_Trans_Timing_Ovrrde : <ilkbool> := Sandybridge_On;
Nico Huber83693c82016-10-08 22:17:55 +0200231
Nico Huberd9365612018-06-10 14:59:04 +0200232 Has_DPLL_SEL : <genbool> := Gen_Ironlake;
233 Has_FDI_BPC : <genbool> := Gen_Ironlake;
234 Has_FDI_Composite_Sel : <ilkbool> := CPU_Ivybridge;
Nico Hubere79babd2020-12-20 01:33:26 +0100235 Has_New_FDI_Sink : <genbool> := Cougar_Point_On;
Nico Huberd9365612018-06-10 14:59:04 +0200236 Has_New_FDI_Source : <ilkbool> := Ivybridge_On;
Nico Hubere79babd2020-12-20 01:33:26 +0100237 Has_Trans_DP_Ctl : <genbool> := PCH_Cougar_Point;
Nico Huberd9365612018-06-10 14:59:04 +0200238 Has_FDI_C : <ilkbool> := CPU_Ivybridge;
Nico Huber83693c82016-10-08 22:17:55 +0200239
Nico Huberd9365612018-06-10 14:59:04 +0200240 Has_FDI_RX_Power_Down : <genbool> := Gen_Haswell;
Nico Huber83693c82016-10-08 22:17:55 +0200241
Nico Huberd0f84b92019-09-22 21:31:52 +0200242 ---------- Clocks: -----------
Nico Huberd9365612018-06-10 14:59:04 +0200243 Has_GMCH_RawClk : <genbool> := Gen_G45;
Nico Huberb47a5c42019-09-29 00:07:21 +0200244 Has_GMCH_Mobile_VCO : <g45bool> := GMCH_GM45;
Nico Huberd0f84b92019-09-22 21:31:52 +0200245 Has_Broadwell_CDClk : <hswbool> := CPU_Broadwell;
246 Can_Switch_CDClk : <hswbool> := Broadwell_On;
Nico Huberdde06302020-12-20 02:18:30 +0100247 Has_Fractional_RawClk : <genbool> := Cannon_Point_On;
Arthur Heymans73ea0322018-03-28 17:17:07 +0200248
Nico Huberd9365612018-06-10 14:59:04 +0200249 ----------- DDI: -------------
250 End_EDP_Training_Late : <genbool> := Gen_Haswell;
251 Has_Per_DDI_Clock_Sel : <genbool> := Gen_Haswell;
252 Has_HOTPLUG_CTL : <genbool> := Gen_Haswell;
253 Has_SHOTPLUG_CTL_A : <hswbool> :=
Nico Huber25fdb152019-02-17 15:54:39 +0100254 ((Gen_Haswell and then Is_LP) or Skylake_On);
Nico Huber83693c82016-10-08 22:17:55 +0200255
Nico Huberd9365612018-06-10 14:59:04 +0200256 Has_DDI_PHYs : <genbool> := Gen_Broxton;
Nico Huber19729a72017-07-30 01:05:05 +0200257
Nico Huberd9365612018-06-10 14:59:04 +0200258 Has_DDI_D : <hswsklbool> :=
Nico Huber25fdb152019-02-17 15:54:39 +0100259 ((Gen_Haswell or Gen_Skylake) and then not Is_LP);
Nico Huberd9365612018-06-10 14:59:04 +0200260 -- might be disabled by x4 eDP:
261 Has_DDI_E : <hswsklbool> := Has_DDI_D;
Nico Huber83693c82016-10-08 22:17:55 +0200262
Nico Huberd9365612018-06-10 14:59:04 +0200263 Has_DDI_Buffer_Trans : <genbool> := Haswell_On and not Has_DDI_PHYs;
264 Has_Low_Voltage_Swing : <genbool> := Broxton_On;
265 Has_Iboost_Config : <genbool> := Skylake_On;
Nico Huber88badbe2018-09-27 16:36:47 +0200266 Use_KBL_DDI_Buf_Trans : <sklbool> := CPU_Kabylake;
Nico Huber83693c82016-10-08 22:17:55 +0200267
Nico Huberd9365612018-06-10 14:59:04 +0200268 Need_DP_Aux_Mutex : <genbool> := False; -- Skylake & (PSR | GTC)
Nico Huber83693c82016-10-08 22:17:55 +0200269
Nico Huber25fdb152019-02-17 15:54:39 +0100270 ----- DP: --------------------
271 DP_Max_2_7_GHz : <hswbool> :=
272 (not Haswell_On or else (CPU_Haswell and Is_ULX));
273
Nico Huberd9365612018-06-10 14:59:04 +0200274 ----------- GMBUS: -----------
275 Ungate_GMBUS_Unit_Level : <genbool> := Skylake_On;
Nico Huberdde06302020-12-20 02:18:30 +0100276 GMBUS_Alternative_Pins : <genbool> := Gen_Broxton or Cannon_Point_On;
Nico Huberd9365612018-06-10 14:59:04 +0200277 Has_PCH_GMBUS : <genbool> := Ironlake_On;
Nico Huber83693c82016-10-08 22:17:55 +0200278
Nico Huberd9365612018-06-10 14:59:04 +0200279 ----------- Power: -----------
280 Has_IPS : <hswbool> :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200281 (Gen_Haswell and then
Nico Huber25fdb152019-02-17 15:54:39 +0100282 ((CPU_Haswell and Is_LP) or CPU_Broadwell));
Nico Huberd9365612018-06-10 14:59:04 +0200283 Has_IPS_CTL_Mailbox : <hswbool> := CPU_Broadwell;
Nico Huber83693c82016-10-08 22:17:55 +0200284
Nico Huberd9365612018-06-10 14:59:04 +0200285 Has_Per_Pipe_SRD : <hswbool> := Broadwell_On;
Nico Huber83693c82016-10-08 22:17:55 +0200286
Nico Huberd9365612018-06-10 14:59:04 +0200287 ----------- GTT: -------------
288 Has_64bit_GTT : <hswbool> := Broadwell_On;
Nico Huber83693c82016-10-08 22:17:55 +0200289
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600290 ----------- Type-C: ----------
291 Has_Type_C_Ports : <genbool> := Tigerlake_On;
292
Nico Huber83693c82016-10-08 22:17:55 +0200293 ----------------------------------------------------------------------------
294
Nico Huberd9365612018-06-10 14:59:04 +0200295 Max_Pipe : <ilkvar> Pipe_Index :=
Nico Huberd58de7d2018-06-07 23:06:55 +0200296 (if Has_Tertiary_Pipe then Tertiary else Secondary);
Nico Huber83693c82016-10-08 22:17:55 +0200297
Nico Huberd9365612018-06-10 14:59:04 +0200298 Last_Digital_Port : <hswsklvar> Digital_Port :=
Nico Huber208857d2017-07-29 21:30:24 +0200299 (if Has_DDI_E then DIGI_E else DIGI_C);
Nico Huberac455ad2017-02-14 14:41:19 +0100300
Nico Huber83693c82016-10-08 22:17:55 +0200301 ----------------------------------------------------------------------------
302
Nico Huber3c544ee2016-11-20 04:56:58 +0100303 type FDI_Per_Port is array (Port_Type) of Boolean;
Nico Huberd9365612018-06-10 14:59:04 +0200304 Is_FDI_Port : <hswvar> FDI_Per_Port :=
Nico Huber6621a142018-06-07 23:56:54 +0200305 (Disabled => False,
Nico Huber8beafd72020-01-07 14:59:44 +0100306 eDP => False,
307 LVDS => Gen_Ironlake,
Nico Huber6621a142018-06-07 23:56:54 +0200308 DP1 .. HDMI3 => Gen_Ironlake,
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600309 Analog => Has_PCH_DAC,
310 others => False);
Nico Huber83693c82016-10-08 22:17:55 +0200311
312 type FDI_Lanes_Per_Port is array (GPU_Port) of DP_Lane_Count;
313 FDI_Lane_Count : constant FDI_Lanes_Per_Port :=
314 (DIGI_D => DP_Lane_Count_2,
Nico Huber6621a142018-06-07 23:56:54 +0200315 others => (if Gen_Ironlake then DP_Lane_Count_4 else DP_Lane_Count_2));
Nico Huber83693c82016-10-08 22:17:55 +0200316
Nico Huberd9365612018-06-10 14:59:04 +0200317 FDI_Training : <ilkvar> FDI_Training_Type :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200318 (if CPU_Ironlake then Simple_Training
319 elsif CPU_Sandybridge then Full_Training
320 else Auto_Training);
Nico Huber83693c82016-10-08 22:17:55 +0200321
Nico Huberf54d0962016-10-20 14:17:18 +0200322 ----------------------------------------------------------------------------
323
Nico Huber88badbe2018-09-27 16:36:47 +0200324 DDI_Buffer_Iboost : <hswsklvar> Natural :=
325 (if Is_ULX or (CPU_Kabylake and Is_ULT) then 3 else 1);
Nico Huber25fdb152019-02-17 15:54:39 +0100326
Nico Huberd9365612018-06-10 14:59:04 +0200327 Default_DDI_HDMI_Buffer_Translation : <hswvar> DDI_HDMI_Buf_Trans_Range :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200328 (if CPU_Haswell then 6
329 elsif CPU_Broadwell then 7
330 elsif Broxton_On then 8
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600331 elsif Tigerlake_On then 6
Nico Huber998ee2b2018-06-12 23:02:17 +0200332 else 0);
Nico Huber247adf32017-06-12 14:39:11 +0200333
334 ----------------------------------------------------------------------------
335
Nico Huber07ff1b92019-09-29 00:03:17 +0200336 Default_CDClk_Freq : <ilkhswvar> CDClk_Range :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200337 (if Gen_G45 then 320_000_000 -- unused
Nico Huber25fdb152019-02-17 15:54:39 +0100338 elsif CPU_Ironlake then 450_000_000
Nico Huber998ee2b2018-06-12 23:02:17 +0200339 elsif CPU_Sandybridge or CPU_Ivybridge then 400_000_000
Nico Huber25fdb152019-02-17 15:54:39 +0100340 elsif Gen_Haswell and then Is_ULX then 337_500_000
341 elsif Gen_Haswell then 450_000_000
Nico Huber998ee2b2018-06-12 23:02:17 +0200342 elsif Gen_Broxton then 288_000_000
343 elsif Gen_Skylake then 337_500_000
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600344 elsif Gen_Tigerlake then CDClk_Range'First -- depends on ref clk
Nico Huber07ff1b92019-09-29 00:03:17 +0200345 else CDClk_Range'First);
Nico Huberabe3de22016-10-20 15:03:46 +0200346
Nico Huberd9365612018-06-10 14:59:04 +0200347 Default_RawClk_Freq : <hswvar> Frequency_Type :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200348 (if Gen_G45 then 100_000_000 -- unused, depends on FSB
349 elsif Gen_Ironlake then 125_000_000
Nico Huber25fdb152019-02-17 15:54:39 +0100350 elsif Gen_Haswell then (if Is_LP then 24_000_000 else 125_000_000)
Nico Huber998ee2b2018-06-12 23:02:17 +0200351 elsif Gen_Broxton then Frequency_Type'First -- none needed
352 elsif Gen_Skylake then 24_000_000
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600353 elsif Gen_Tigerlake then 24_000_000
Nico Huber998ee2b2018-06-12 23:02:17 +0200354 else Frequency_Type'First);
Nico Huberf54d0962016-10-20 14:17:18 +0200355
Nico Huberdcd274b2016-11-03 20:15:39 +0100356 ----------------------------------------------------------------------------
357
358 -- Maximum source width with enabled scaler. This only accounts
359 -- for simple 1:1 pipe:scaler mappings.
360
Nico Huberc5c767a2018-06-03 01:09:04 +0200361 type Width_Per_Pipe is array (Pipe_Index) of Width_Type;
Nico Huberdcd274b2016-11-03 20:15:39 +0100362
Nico Huberd9365612018-06-10 14:59:04 +0200363 Maximum_Scalable_Width : <hswvar> Width_Per_Pipe :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200364 (if Gen_G45 then -- TODO: Is this true?
365 (Primary => 4096,
366 Secondary => 2048,
367 Tertiary => Pos32'First)
368 elsif Gen_Ironlake or CPU_Haswell then
369 (Primary => 4096,
370 Secondary => 2048,
371 Tertiary => 2048)
372 else
373 (Primary => 4096,
374 Secondary => 4096,
375 Tertiary => 4096));
Nico Huberdcd274b2016-11-03 20:15:39 +0100376
Nico Hubera02b2c62018-01-09 15:58:34 +0100377 -- Maximum X position of hardware cursors
Nico Huberd9365612018-06-10 14:59:04 +0200378 Maximum_Cursor_X : constant :=
379 (case Gen is
380 when G45 .. Ironlake => 4095,
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600381 when Haswell .. Tigerlake => 8191);
Nico Hubera02b2c62018-01-09 15:58:34 +0100382
383 Maximum_Cursor_Y : constant := 4095;
384
Nico Huber74ec9622016-11-19 03:00:43 +0100385 ----------------------------------------------------------------------------
386
Nico Huber21da5742017-01-20 14:00:53 +0100387 -- FIXME: Unknown for Broxton, Linux' i915 contains a fixme too :-D
Nico Huber74ec9622016-11-19 03:00:43 +0100388 HDMI_Max_Clock_24bpp : constant Frequency_Type :=
Nico Huber530651b2019-10-03 14:59:38 +0200389 (case Gen is
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600390 when Generation'First .. G45 => 165_000_000,
391 when Ironlake => 225_000_000,
392 when Haswell .. Skylake => 300_000_000,
393 when Tigerlake .. Generation'Last => 600_000_000);
Nico Huber74ec9622016-11-19 03:00:43 +0100394
Nico Huberb8ae6182017-07-15 20:03:56 +0200395 ----------------------------------------------------------------------------
396
Nico Huberadfe11f2018-06-10 14:59:04 +0200397 GTT_PTE_Size : <hswvar> Natural := (if Has_64bit_GTT then 8 else 4);
Nico Huberb8ae6182017-07-15 20:03:56 +0200398
Nico Huberadfe11f2018-06-10 14:59:04 +0200399 Fence_Base : <ilkvar> Natural :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200400 (if not Sandybridge_On then 16#0000_3000# else 16#0010_0000#);
Nico Huberb03c8f12017-08-25 13:29:08 +0200401
Nico Huberadfe11f2018-06-10 14:59:04 +0200402 Fence_Count : <ilkvar> Natural :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200403 (if not Ivybridge_On then 16 else 32);
Nico Huberb03c8f12017-08-25 13:29:08 +0200404
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200405 ----------------------------------------------------------------------------
406
407 use type HW.Word16;
408
Nico Huber25fdb152019-02-17 15:54:39 +0100409 -- GMA PCI IDs:
410 --
411 -- Rather catch too much here than too little, it's
412 -- mostly used to distinguish generations. Best public
413 -- reference for these IDs is Linux' i915.
414 --
415 -- Since Sandybridge, bits 4 and 5 encode the compu-
416 -- tational capabilities and can mostly be ignored.
417 -- From Haswell on, we have to distinguish between
418 -- Normal, ULT (U CPU lines) and ULX (Y CPU lines).
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200419
Nico Huber25fdb152019-02-17 15:54:39 +0100420 function Is_Haswell_Y (Device_Id : Word16) return Boolean is
421 ((Device_Id and 16#ffef#) = 16#0a0e#);
422 function Is_Haswell_U (Device_Id : Word16) return Boolean is
423 (((Device_Id and 16#ffc3#) = 16#0a02# or
424 (Device_Id and 16#ffcf#) = 16#0a0b#) and
425 not Is_Haswell_Y (Device_Id));
426 function Is_Haswell (Device_Id : Word16) return Boolean is
427 ((Device_Id and 16#ffc3#) = 16#0402# or
428 (Device_Id and 16#ffcf#) = 16#040b# or
429 (Device_Id and 16#ffc3#) = 16#0c02# or
430 (Device_Id and 16#ffcf#) = 16#0c0b# or
431 (Device_Id and 16#ffc3#) = 16#0d02# or
432 (Device_Id and 16#ffcf#) = 16#0d0b#);
433
434 function Is_Broadwell_Y (Device_Id : Word16) return Boolean is
435 ((Device_Id and 16#ffcf#) = 16#160e#);
436 function Is_Broadwell_U (Device_Id : Word16) return Boolean is
437 ((Device_Id and 16#ffcf#) = 16#1606# or
438 (Device_Id and 16#ffcf#) = 16#160b#);
439 function Is_Broadwell (Device_Id : Word16) return Boolean is
440 ((Device_Id and 16#ffc7#) = 16#1602# or
441 (Device_Id and 16#ffcf#) = 16#160d#);
442
443 function Is_Skylake_Y (Device_Id : Word16) return Boolean is
444 ((Device_Id and 16#ffcf#) = 16#190e#);
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200445 function Is_Skylake_U (Device_Id : Word16) return Boolean is
Nico Huber25fdb152019-02-17 15:54:39 +0100446 ((Device_Id and 16#ffc9#) = 16#1901# or
447 (Device_Id and 16#ffcf#) = 16#1906#);
448 function Is_Skylake (Device_Id : Word16) return Boolean is
449 ((Device_Id and 16#ffc7#) = 16#1902# or
450 (Device_Id and 16#ffcf#) = 16#190b# or
451 (Device_Id and 16#ffcf#) = 16#190d#);
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200452
Nico Huber88badbe2018-09-27 16:36:47 +0200453 function Is_Kaby_Lake_Y (Device_Id : Word16) return Boolean is
454 ((Device_Id and 16#ffcf#) = 16#5905# or
455 (Device_Id and 16#ffcf#) = 16#590e#);
456 function Is_Kaby_Lake_Y_AML (Device_Id : Word16) return Boolean is
457 (Device_Id = 16#591c# or Device_Id = 16#87c0#);
458 function Is_Kaby_Lake_U (Device_Id : Word16) return Boolean is
459 ((Device_Id and 16#ffcd#) = 16#5901# or
460 (Device_Id and 16#ffce#) = 16#5906#);
461 function Is_Kaby_Lake (Device_Id : Word16) return Boolean is
462 ((Device_Id and 16#ffc7#) = 16#5902# or
463 (Device_Id and 16#ffcf#) = 16#5908# or
464 (Device_Id and 16#ffcf#) = 16#590b# or
465 (Device_Id and 16#ffcf#) = 16#590d#);
466
Nico Huber2c927942019-02-17 19:07:31 +0100467 function Is_Coffee_Lake_Y_AML (Device_Id : Word16) return Boolean is
468 (Device_Id = 16#87ca#);
469 -- Including Whiskey Lake:
470 function Is_Coffee_Lake_U (Device_Id : Word16) return Boolean is
471 ((Device_Id and 16#fff0#) = 16#3ea0#);
472 function Is_Coffee_Lake (Device_Id : Word16) return Boolean is
473 ((Device_Id and 16#fff0#) = 16#3e90#);
474
Nico Hubercdbfce22019-10-29 20:00:43 +0100475 function Is_Comet_Lake_U (Device_Id : Word16) return Boolean is
476 ((Device_Id and 16#ff9f#) = 16#9b01# or
477 (Device_Id and 16#ff9f#) = 16#9b8a# or
478 (Device_Id and 16#ff9f#) = 16#9b8c#);
479 function Is_Comet_Lake (Device_Id : Word16) return Boolean is
480 ((Device_Id and 16#ff8f#) = 16#9b82# or
481 (Device_Id and 16#ff8f#) = 16#9b84# or
482 (Device_Id and 16#ff8f#) = 16#9b85# or
483 (Device_Id and 16#ff8f#) = 16#9b86# or
484 (Device_Id and 16#ff8f#) = 16#9b88#);
485
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600486 -- For TGL, the distinction is UP4 (formerly Y), UP3 (U), or H (Normal),
487 -- however, the PRMs state "The Intel UHD Graphics Device ID SKUs are
488 -- unified for both UP3 and UP4, e.g. there is no unique device ID
489 -- between UP3 and UP4"
490 function Is_Tiger_Lake_U (Device_Id : Word16) return Boolean is
491 (Device_Id = 16#9a40# or
492 Device_Id = 16#9a49# or
493 Device_Id = 16#9a59# or
494 Device_Id = 16#9a78# or
495 Device_Id = 16#9ac0# or
496 Device_Id = 16#9ac9# or
497 Device_Id = 16#9ad9# or
498 Device_Id = 16#9af8#);
499
500 function Is_Tiger_Lake_H (Device_Id : Word16) return Boolean is
501 (Device_Id = 16#9a60# or
502 Device_Id = 16#9a68# or
503 Device_Id = 16#9a70#);
504
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200505 function Is_GPU (Device_Id : Word16; CPU : CPU_Type; CPU_Var : CPU_Variant)
506 return Boolean is
507 (case CPU is
Nico Huber7f3e2802019-09-28 20:40:55 +0200508 when G45 => (Device_Id and 16#ff02#) = 16#2e02#,
509 when GM45 => (Device_Id and 16#fffe#) = 16#2a42#,
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200510 when Ironlake => (Device_Id and 16#fff3#) = 16#0042#,
511 when Sandybridge => (Device_Id and 16#ffc2#) = 16#0102#,
512 when Ivybridge => (Device_Id and 16#ffc3#) = 16#0142#,
Nico Huber25fdb152019-02-17 15:54:39 +0100513 when Haswell => (case CPU_Var is
514 when Normal => Is_Haswell (Device_Id),
515 when ULT => Is_Haswell_U (Device_Id),
516 when ULX => Is_Haswell_Y (Device_Id)),
517 when Broadwell => (case CPU_Var is
518 when Normal => Is_Broadwell (Device_Id),
519 when ULT => Is_Broadwell_U (Device_Id),
520 when ULX => Is_Broadwell_Y (Device_Id)),
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200521 when Broxton => (Device_Id and 16#fffe#) = 16#5a84#,
Nico Huber25fdb152019-02-17 15:54:39 +0100522 when Skylake => (case CPU_Var is
523 when Normal => Is_Skylake (Device_Id),
524 when ULT => Is_Skylake_U (Device_Id),
Nico Huber88badbe2018-09-27 16:36:47 +0200525 when ULX => Is_Skylake_Y (Device_Id)),
526 when Kabylake => (case CPU_Var is
Nico Huber2c927942019-02-17 19:07:31 +0100527 when Normal =>
528 Is_Kaby_Lake (Device_Id) or
Nico Hubercdbfce22019-10-29 20:00:43 +0100529 Is_Coffee_Lake (Device_Id) or
530 Is_Comet_Lake (Device_Id),
Nico Huber2c927942019-02-17 19:07:31 +0100531 when ULT =>
532 Is_Kaby_Lake_U (Device_Id) or
Nico Hubercdbfce22019-10-29 20:00:43 +0100533 Is_Coffee_Lake_U (Device_Id) or
534 Is_Comet_Lake_U (Device_Id),
Nico Huber2c927942019-02-17 19:07:31 +0100535 when ULX =>
536 Is_Kaby_Lake_Y (Device_Id) or
537 Is_Kaby_Lake_Y_AML (Device_Id) or
Tim Wawrzynczak605660b2022-06-08 12:48:19 -0600538 Is_Coffee_Lake_Y_AML (Device_Id)),
539 when Tigerlake => (case CPU_Var is
540 when Normal =>
541 Is_Tiger_Lake_H (Device_Id),
542 when ULT | ULX =>
543 Is_Tiger_Lake_U (Device_Id)));
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200544
545 function Compatible_GPU (Device_Id : Word16) return Boolean is
546 (Is_GPU (Device_Id, CPU, CPU_Var));
547
Nico Huber6a996dc2018-06-17 16:30:33 +0200548 pragma Warnings (GNATprove, Off, "subprogram ""Detect_CPU"" has no effect",
549 Reason => "only effective in dynamic cpu config");
550 procedure Detect_CPU (Device : Word16)<cpunull>;
551
Nico Huber83693c82016-10-08 22:17:55 +0200552end HW.GFX.GMA.Config;