blob: 8f231e0ba86d0609882dca208f9a280dc9663dd5 [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
Nico Huber3d06de82018-05-29 01:35:04 +02002-- Copyright (C) 2015-2018 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
15private package HW.GFX.GMA.Config
16with
Nico Huber318bca12018-06-09 19:22:52 +020017 Initializes => (Valid_Port, Raw_Clock)
Nico Huber83693c82016-10-08 22:17:55 +020018is
19
Nico Huber6621a142018-06-07 23:56:54 +020020 Gen : constant Generation := <<GEN>>;
21
Nico Huber83693c82016-10-08 22:17:55 +020022 CPU : constant CPU_Type := <<CPU>>;
23
24 CPU_Var : constant CPU_Variant := <<CPU_VARIANT>>;
25
26 Internal_Display : constant Internal_Type := <<INTERNAL_PORT>>;
27
Nico Huberd55afeb2016-10-21 14:31:10 +020028 Analog_I2C_Port : constant PCH_Port := <<ANALOG_I2C_PORT>>;
29
Nico Huber83693c82016-10-08 22:17:55 +020030 EDP_Low_Voltage_Swing : constant Boolean := False;
31
Nico Huber247adf32017-06-12 14:39:11 +020032 DDI_HDMI_Buffer_Translation : constant Integer := -1;
33
Nico Huber83693c82016-10-08 22:17:55 +020034 Default_MMIO_Base : constant := <<DEFAULT_MMIO_BASE>>;
35
36 LVDS_Dual_Threshold : constant := 95_000_000;
37
38 ----------------------------------------------------------------------------
39
Nico Huber6621a142018-06-07 23:56:54 +020040 Gen_G45 : constant Boolean := Gen = G45;
41 Gen_Ironlake : constant Boolean := Gen = Ironlake;
42 Gen_Haswell : constant Boolean := Gen = Haswell;
43 Gen_Broxton : constant Boolean := Gen = Broxton;
44 Gen_Skylake : constant Boolean := Gen = Skylake;
45
46 Up_To_Ironlake : constant Boolean := Gen <= Ironlake;
47 Ironlake_On : constant Boolean := Gen >= Ironlake;
48 Haswell_On : constant Boolean := Gen >= Haswell;
49 Broxton_On : constant Boolean := Gen >= Broxton;
50 Skylake_On : constant Boolean := Gen >= Skylake;
51
Nico Huber998ee2b2018-06-12 23:02:17 +020052 CPU_Ironlake : constant Boolean := Gen_Ironlake and then CPU = Ironlake;
53 CPU_Sandybridge : constant Boolean := Gen_Ironlake and then CPU = Sandybridge;
54 CPU_Ivybridge : constant Boolean := Gen_Ironlake and then CPU = Ivybridge;
55 CPU_Haswell : constant Boolean := Gen_Haswell and then CPU = Haswell;
56 CPU_Broadwell : constant Boolean := Gen_Haswell and then CPU = Broadwell;
57
58 Sandybridge_On : constant Boolean :=
59 ((Gen_Ironlake and then CPU >= Sandybridge) or Haswell_On);
60 Ivybridge_On : constant Boolean :=
61 ((Gen_Ironlake and then CPU >= Ivybridge) or Haswell_On);
62 Broadwell_On : constant Boolean :=
63 ((Gen_Haswell and then CPU >= Broadwell) or Broxton_On);
64
Nico Huber6621a142018-06-07 23:56:54 +020065 ----------------------------------------------------------------------------
66
Nico Huber117db372018-06-09 17:56:05 +020067 Have_HDMI_Buf_Override : constant Boolean := DDI_HDMI_Buffer_Translation >= 0;
Nico Huber2b6f6992017-07-09 18:11:34 +020068 Default_MMIO_Base_Set : constant Boolean := Default_MMIO_Base /= 0;
69
Nico Huber83693c82016-10-08 22:17:55 +020070 Has_Internal_Display : constant Boolean := Internal_Display /= None;
Nico Huber318bca12018-06-09 19:22:52 +020071 Internal_Is_LVDS : constant Boolean := Internal_Display = LVDS;
Nico Huber83693c82016-10-08 22:17:55 +020072 Internal_Is_EDP : constant Boolean := Internal_Display = DP;
Nico Huber1bc496f2017-06-09 22:23:28 +020073 Have_DVI_I : constant Boolean := Analog_I2C_Port /= PCH_DAC;
Nico Huber6621a142018-06-07 23:56:54 +020074 Has_Presence_Straps : constant Boolean := not Gen_Broxton;
Nico Huber998ee2b2018-06-12 23:02:17 +020075 Is_ULT : constant Boolean :=
76 ((Gen_Haswell or Gen_Skylake) and then CPU_Var = ULT);
Nico Huber83693c82016-10-08 22:17:55 +020077
78 ----- CPU pipe: --------
Nico Huber998ee2b2018-06-12 23:02:17 +020079 Has_Tertiary_Pipe : constant Boolean := Ivybridge_On;
Nico Huber6621a142018-06-07 23:56:54 +020080 Disable_Trickle_Feed : constant Boolean := not Gen_Haswell;
Nico Huber998ee2b2018-06-12 23:02:17 +020081 Pipe_Enabled_Workaround : constant Boolean := CPU_Broadwell;
Nico Huber6621a142018-06-07 23:56:54 +020082 Has_EDP_Transcoder : constant Boolean := Haswell_On;
Nico Huber998ee2b2018-06-12 23:02:17 +020083 Use_PDW_For_EDP_Scaling : constant Boolean := CPU_Haswell;
Nico Huber6621a142018-06-07 23:56:54 +020084 Has_Pipe_DDI_Func : constant Boolean := Haswell_On;
85 Has_Trans_Clk_Sel : constant Boolean := Haswell_On;
86 Has_Pipe_MSA_Misc : constant Boolean := Haswell_On;
Nico Huber998ee2b2018-06-12 23:02:17 +020087 Has_Pipeconf_Misc : constant Boolean := Broadwell_On;
88 Has_Pipeconf_BPC : constant Boolean := not CPU_Haswell;
Nico Huber6621a142018-06-07 23:56:54 +020089 Has_Plane_Control : constant Boolean := Broxton_On;
90 Has_DSP_Linoff : constant Boolean := Up_To_Ironlake;
Nico Huber998ee2b2018-06-12 23:02:17 +020091 Has_PF_Pipe_Select : constant Boolean := CPU_Ivybridge or CPU_Haswell;
92 Has_Cursor_FBC_Control : constant Boolean := Ivybridge_On;
93 VGA_Plane_Workaround : constant Boolean := CPU_Ivybridge;
Nico Huber6621a142018-06-07 23:56:54 +020094 Has_GMCH_DP_Transcoder : constant Boolean := Gen_G45;
95 Has_GMCH_VGACNTRL : constant Boolean := Gen_G45;
96 Has_GMCH_PFIT_CONTROL : constant Boolean := Gen_G45;
Nico Huber83693c82016-10-08 22:17:55 +020097
98 ----- Panel power: -----
Nico Huber6621a142018-06-07 23:56:54 +020099 Has_PP_Write_Protection : constant Boolean := Up_To_Ironlake;
100 Has_PP_Port_Select : constant Boolean := Up_To_Ironlake;
101 Use_PP_VDD_Override : constant Boolean := Up_To_Ironlake;
102 Has_PCH_Panel_Power : constant Boolean := Ironlake_On;
Nico Huber83693c82016-10-08 22:17:55 +0200103
104 ----- PCH/FDI: ---------
Nico Huber6621a142018-06-07 23:56:54 +0200105 Has_PCH : constant Boolean := not Gen_Broxton and not Gen_G45;
Nico Huber998ee2b2018-06-12 23:02:17 +0200106 Has_PCH_DAC : constant Boolean :=
107 (Gen_Ironlake or (Gen_Haswell and then not Is_ULT));
Nico Huber83693c82016-10-08 22:17:55 +0200108
Nico Huber6621a142018-06-07 23:56:54 +0200109 Has_PCH_Aux_Channels : constant Boolean := Gen_Ironlake or Gen_Haswell;
Nico Huber83693c82016-10-08 22:17:55 +0200110
Nico Huber6621a142018-06-07 23:56:54 +0200111 VGA_Has_Sync_Disable : constant Boolean := Up_To_Ironlake;
Nico Huber83693c82016-10-08 22:17:55 +0200112
Nico Huber998ee2b2018-06-12 23:02:17 +0200113 Has_Trans_Timing_Ovrrde : constant Boolean := Sandybridge_On;
Nico Huber83693c82016-10-08 22:17:55 +0200114
Nico Huber6621a142018-06-07 23:56:54 +0200115 Has_DPLL_SEL : constant Boolean := Gen_Ironlake;
116 Has_FDI_BPC : constant Boolean := Gen_Ironlake;
Nico Huber998ee2b2018-06-12 23:02:17 +0200117 Has_FDI_Composite_Sel : constant Boolean := CPU_Ivybridge;
118 Has_New_FDI_Sink : constant Boolean := Sandybridge_On;
119 Has_New_FDI_Source : constant Boolean := Ivybridge_On;
120 Has_Trans_DP_Ctl : constant Boolean := CPU_Sandybridge or CPU_Ivybridge;
121 Has_FDI_C : constant Boolean := CPU_Ivybridge;
Nico Huber83693c82016-10-08 22:17:55 +0200122
Nico Huber6621a142018-06-07 23:56:54 +0200123 Has_FDI_RX_Power_Down : constant Boolean := Gen_Haswell;
Nico Huber83693c82016-10-08 22:17:55 +0200124
Nico Huber6621a142018-06-07 23:56:54 +0200125 Has_GMCH_RawClk : constant Boolean := Gen_G45;
Arthur Heymans73ea0322018-03-28 17:17:07 +0200126
Nico Huber83693c82016-10-08 22:17:55 +0200127 ----- DDI: -------------
Nico Huber6621a142018-06-07 23:56:54 +0200128 End_EDP_Training_Late : constant Boolean := Gen_Haswell;
129 Has_Per_DDI_Clock_Sel : constant Boolean := Gen_Haswell;
130 Has_HOTPLUG_CTL : constant Boolean := Gen_Haswell;
Nico Huber998ee2b2018-06-12 23:02:17 +0200131 Has_SHOTPLUG_CTL_A : constant Boolean :=
132 ((Gen_Haswell and then Is_ULT) or Skylake_On);
Nico Huber83693c82016-10-08 22:17:55 +0200133
Nico Huber6621a142018-06-07 23:56:54 +0200134 Has_DDI_PHYs : constant Boolean := Gen_Broxton;
Nico Huber19729a72017-07-30 01:05:05 +0200135
Nico Huber998ee2b2018-06-12 23:02:17 +0200136 Has_DDI_D : constant Boolean :=
137 ((Gen_Haswell or Gen_Skylake) and then not Is_ULT);
Nico Huber907e4152017-07-29 21:18:59 +0200138 Has_DDI_E : constant Boolean := -- might be disabled by x4 eDP
139 Has_DDI_D;
Nico Huber83693c82016-10-08 22:17:55 +0200140
Nico Huber6621a142018-06-07 23:56:54 +0200141 Has_DDI_Buffer_Trans : constant Boolean := Haswell_On and
142 not Gen_Broxton;
143 Has_Low_Voltage_Swing : constant Boolean := Broxton_On;
144 Has_Iboost_Config : constant Boolean := Skylake_On;
Nico Huber83693c82016-10-08 22:17:55 +0200145
146 Need_DP_Aux_Mutex : constant Boolean := False; -- Skylake & (PSR | GTC)
147
Nico Huber1c3b9282017-02-09 13:57:04 +0100148 ----- GMBUS: -----------
Nico Huber6621a142018-06-07 23:56:54 +0200149 Ungate_GMBUS_Unit_Level : constant Boolean := Skylake_On;
150 GMBUS_Alternative_Pins : constant Boolean := Gen_Broxton;
151 Has_PCH_GMBUS : constant Boolean := Ironlake_On;
Nico Huber83693c82016-10-08 22:17:55 +0200152
153 ----- Power: -----------
Nico Huber998ee2b2018-06-12 23:02:17 +0200154 Has_IPS : constant Boolean :=
155 (Gen_Haswell and then
156 ((CPU_Haswell and Is_ULT) or CPU_Broadwell));
157 Has_IPS_CTL_Mailbox : constant Boolean := CPU_Broadwell;
Nico Huber83693c82016-10-08 22:17:55 +0200158
Nico Huber998ee2b2018-06-12 23:02:17 +0200159 Has_Per_Pipe_SRD : constant Boolean := Broadwell_On;
Nico Huber83693c82016-10-08 22:17:55 +0200160
Nico Huber21da5742017-01-20 14:00:53 +0100161 ----- GTT: -------------
Nico Huber998ee2b2018-06-12 23:02:17 +0200162 Has_64bit_GTT : constant Boolean := Broadwell_On;
Nico Huber83693c82016-10-08 22:17:55 +0200163
164 ----------------------------------------------------------------------------
165
Nico Huber1b2c9a32016-11-20 03:42:08 +0100166 Max_Pipe : constant Pipe_Index :=
Nico Huberd58de7d2018-06-07 23:06:55 +0200167 (if Has_Tertiary_Pipe then Tertiary else Secondary);
Nico Huber83693c82016-10-08 22:17:55 +0200168
Nico Huber318bca12018-06-09 19:22:52 +0200169 Valid_Port : array (Port_Type) of Boolean := (others => False)
Nico Huber83693c82016-10-08 22:17:55 +0200170 with
171 Part_Of => GMA.Config_State;
Nico Huber83693c82016-10-08 22:17:55 +0200172
Nico Huberac455ad2017-02-14 14:41:19 +0100173 Last_Digital_Port : constant Digital_Port :=
Nico Huber208857d2017-07-29 21:30:24 +0200174 (if Has_DDI_E then DIGI_E else DIGI_C);
Nico Huberac455ad2017-02-14 14:41:19 +0100175
Nico Huber83693c82016-10-08 22:17:55 +0200176 ----------------------------------------------------------------------------
177
Nico Huber3c544ee2016-11-20 04:56:58 +0100178 type FDI_Per_Port is array (Port_Type) of Boolean;
179 Is_FDI_Port : constant FDI_Per_Port :=
Nico Huber6621a142018-06-07 23:56:54 +0200180 (Disabled => False,
181 Internal => Gen_Ironlake and Internal_Is_LVDS,
182 DP1 .. HDMI3 => Gen_Ironlake,
183 Analog => Has_PCH_DAC);
Nico Huber83693c82016-10-08 22:17:55 +0200184
185 type FDI_Lanes_Per_Port is array (GPU_Port) of DP_Lane_Count;
186 FDI_Lane_Count : constant FDI_Lanes_Per_Port :=
187 (DIGI_D => DP_Lane_Count_2,
Nico Huber6621a142018-06-07 23:56:54 +0200188 others => (if Gen_Ironlake then DP_Lane_Count_4 else DP_Lane_Count_2));
Nico Huber83693c82016-10-08 22:17:55 +0200189
190 FDI_Training : constant FDI_Training_Type :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200191 (if CPU_Ironlake then Simple_Training
192 elsif CPU_Sandybridge then Full_Training
193 else Auto_Training);
Nico Huber83693c82016-10-08 22:17:55 +0200194
Nico Huberf54d0962016-10-20 14:17:18 +0200195 ----------------------------------------------------------------------------
196
Nico Huber247adf32017-06-12 14:39:11 +0200197 Default_DDI_HDMI_Buffer_Translation : constant DDI_HDMI_Buf_Trans_Range :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200198 (if CPU_Haswell then 6
199 elsif CPU_Broadwell then 7
200 elsif Broxton_On then 8
201 else 0);
Nico Huber247adf32017-06-12 14:39:11 +0200202
203 ----------------------------------------------------------------------------
204
Nico Huberabe3de22016-10-20 15:03:46 +0200205 Default_CDClk_Freq : constant Frequency_Type :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200206 (if Gen_G45 then 320_000_000 -- unused
207 elsif CPU_Ironlake or Gen_Haswell then 450_000_000
208 elsif CPU_Sandybridge or CPU_Ivybridge then 400_000_000
209 elsif Gen_Broxton then 288_000_000
210 elsif Gen_Skylake then 337_500_000
211 else Frequency_Type'First);
Nico Huberabe3de22016-10-20 15:03:46 +0200212
Nico Huberf54d0962016-10-20 14:17:18 +0200213 Default_RawClk_Freq : constant Frequency_Type :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200214 (if Gen_G45 then 100_000_000 -- unused, depends on FSB
215 elsif Gen_Ironlake then 125_000_000
216 elsif Gen_Haswell then (if Is_ULT then 24_000_000 else 125_000_000)
217 elsif Gen_Broxton then Frequency_Type'First -- none needed
218 elsif Gen_Skylake then 24_000_000
219 else Frequency_Type'First);
Nico Huberf54d0962016-10-20 14:17:18 +0200220
Arthur Heymansd1988d12018-03-28 16:27:57 +0200221 Raw_Clock : Frequency_Type := Default_RawClk_Freq
222 with Part_Of => GMA.Config_State;
223
Nico Huberdcd274b2016-11-03 20:15:39 +0100224 ----------------------------------------------------------------------------
225
226 -- Maximum source width with enabled scaler. This only accounts
227 -- for simple 1:1 pipe:scaler mappings.
228
Nico Huberc5c767a2018-06-03 01:09:04 +0200229 type Width_Per_Pipe is array (Pipe_Index) of Width_Type;
Nico Huberdcd274b2016-11-03 20:15:39 +0100230
231 Maximum_Scalable_Width : constant Width_Per_Pipe :=
Nico Huber998ee2b2018-06-12 23:02:17 +0200232 (if Gen_G45 then -- TODO: Is this true?
233 (Primary => 4096,
234 Secondary => 2048,
235 Tertiary => Pos32'First)
236 elsif Gen_Ironlake or CPU_Haswell then
237 (Primary => 4096,
238 Secondary => 2048,
239 Tertiary => 2048)
240 else
241 (Primary => 4096,
242 Secondary => 4096,
243 Tertiary => 4096));
Nico Huberdcd274b2016-11-03 20:15:39 +0100244
Nico Hubera02b2c62018-01-09 15:58:34 +0100245 -- Maximum X position of hardware cursors
Nico Huber6621a142018-06-07 23:56:54 +0200246 Maximum_Cursor_X : constant := (case Gen is
247 when G45 .. Ironlake => 4095,
Nico Hubera02b2c62018-01-09 15:58:34 +0100248 when Haswell .. Skylake => 8191);
249
250 Maximum_Cursor_Y : constant := 4095;
251
Nico Huber74ec9622016-11-19 03:00:43 +0100252 ----------------------------------------------------------------------------
253
Nico Huber21da5742017-01-20 14:00:53 +0100254 -- FIXME: Unknown for Broxton, Linux' i915 contains a fixme too :-D
Nico Huber74ec9622016-11-19 03:00:43 +0100255 HDMI_Max_Clock_24bpp : constant Frequency_Type :=
Nico Huber6621a142018-06-07 23:56:54 +0200256 (if Haswell_On then 300_000_000 else 225_000_000);
Nico Huber74ec9622016-11-19 03:00:43 +0100257
Nico Huberb8ae6182017-07-15 20:03:56 +0200258 ----------------------------------------------------------------------------
259
Nico Huber0b2329a2018-06-09 21:14:27 +0200260 GTT_PTE_Size : constant := (if Has_64bit_GTT then 8 else 4);
Nico Huberb8ae6182017-07-15 20:03:56 +0200261
Nico Huber998ee2b2018-06-12 23:02:17 +0200262 Fence_Base : constant :=
263 (if not Sandybridge_On then 16#0000_3000# else 16#0010_0000#);
Nico Huberb03c8f12017-08-25 13:29:08 +0200264
Nico Huber998ee2b2018-06-12 23:02:17 +0200265 Fence_Count : constant :=
266 (if not Ivybridge_On then 16 else 32);
Nico Huberb03c8f12017-08-25 13:29:08 +0200267
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200268 ----------------------------------------------------------------------------
269
270 use type HW.Word16;
271
272 function Is_Broadwell_H (Device_Id : Word16) return Boolean is
273 (Device_Id = 16#1612# or Device_Id = 16#1622# or Device_Id = 16#162a#);
274
275 function Is_Skylake_U (Device_Id : Word16) return Boolean is
276 (Device_Id = 16#1906# or Device_Id = 16#1916# or Device_Id = 16#1923# or
277 Device_Id = 16#1926# or Device_Id = 16#1927#);
278
279 -- Rather catch too much here than too little,
280 -- it's only used to distinguish generations.
281 function Is_GPU (Device_Id : Word16; CPU : CPU_Type; CPU_Var : CPU_Variant)
282 return Boolean is
283 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200284 when G45 => (Device_Id and 16#ff02#) = 16#2e02# or
285 (Device_Id and 16#fffe#) = 16#2a42#,
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200286 when Ironlake => (Device_Id and 16#fff3#) = 16#0042#,
287 when Sandybridge => (Device_Id and 16#ffc2#) = 16#0102#,
288 when Ivybridge => (Device_Id and 16#ffc3#) = 16#0142#,
289 when Haswell =>
290 (case CPU_Var is
291 when Normal => (Device_Id and 16#ffc3#) = 16#0402# or
292 (Device_Id and 16#ffc3#) = 16#0d02#,
293 when ULT => (Device_Id and 16#ffc3#) = 16#0a02#),
294 when Broadwell => ((Device_Id and 16#ffc3#) = 16#1602# or
295 (Device_Id and 16#ffcf#) = 16#160b# or
296 (Device_Id and 16#ffcf#) = 16#160d#) and
297 (case CPU_Var is
298 when Normal => Is_Broadwell_H (Device_Id),
299 when ULT => not Is_Broadwell_H (Device_Id)),
300 when Broxton => (Device_Id and 16#fffe#) = 16#5a84#,
301 when Skylake => ((Device_Id and 16#ffc3#) = 16#1902# or
302 (Device_Id and 16#ffcf#) = 16#190b# or
303 (Device_Id and 16#ffcf#) = 16#190d# or
304 (Device_Id and 16#fff9#) = 16#1921#) and
305 (case CPU_Var is
306 when Normal => not Is_Skylake_U (Device_Id),
307 when ULT => Is_Skylake_U (Device_Id)));
308
309 function Compatible_GPU (Device_Id : Word16) return Boolean is
310 (Is_GPU (Device_Id, CPU, CPU_Var));
311
Nico Huber83693c82016-10-08 22:17:55 +0200312end HW.GFX.GMA.Config;