blob: 968ccc718fb5b3cacc9792d8d6f4cc98b824a5e4 [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
Arthur Heymansd1988d12018-03-28 16:27:57 +020017 Initializes => (Valid_Port_GPU, Raw_Clock)
Nico Huber83693c82016-10-08 22:17:55 +020018is
19
20 CPU : constant CPU_Type := <<CPU>>;
21
22 CPU_Var : constant CPU_Variant := <<CPU_VARIANT>>;
23
24 Internal_Display : constant Internal_Type := <<INTERNAL_PORT>>;
25
Nico Huberd55afeb2016-10-21 14:31:10 +020026 Analog_I2C_Port : constant PCH_Port := <<ANALOG_I2C_PORT>>;
27
Nico Huber83693c82016-10-08 22:17:55 +020028 EDP_Low_Voltage_Swing : constant Boolean := False;
29
Nico Huber247adf32017-06-12 14:39:11 +020030 DDI_HDMI_Buffer_Translation : constant Integer := -1;
31
Nico Huber83693c82016-10-08 22:17:55 +020032 Default_MMIO_Base : constant := <<DEFAULT_MMIO_BASE>>;
33
34 LVDS_Dual_Threshold : constant := 95_000_000;
35
36 ----------------------------------------------------------------------------
37
Nico Huber2b6f6992017-07-09 18:11:34 +020038 Default_MMIO_Base_Set : constant Boolean := Default_MMIO_Base /= 0;
39
Nico Huber83693c82016-10-08 22:17:55 +020040 Has_Internal_Display : constant Boolean := Internal_Display /= None;
41 Internal_Is_EDP : constant Boolean := Internal_Display = DP;
Nico Huber1bc496f2017-06-09 22:23:28 +020042 Have_DVI_I : constant Boolean := Analog_I2C_Port /= PCH_DAC;
Nico Huber1c3b9282017-02-09 13:57:04 +010043 Has_Presence_Straps : constant Boolean := CPU /= Broxton;
Nico Huber83693c82016-10-08 22:17:55 +020044
45 ----- CPU pipe: --------
Nico Huberd58de7d2018-06-07 23:06:55 +020046 Has_Tertiary_Pipe : constant Boolean := CPU >= Ivybridge;
Nico Huber83693c82016-10-08 22:17:55 +020047 Disable_Trickle_Feed : constant Boolean := not
48 (CPU in Haswell .. Broadwell);
49 Pipe_Enabled_Workaround : constant Boolean := CPU = Broadwell;
Nico Huber7ad2d652016-12-07 15:19:32 +010050 Has_EDP_Transcoder : constant Boolean := CPU >= Haswell;
Nico Huber3d06de82018-05-29 01:35:04 +020051 Use_PDW_For_EDP_Scaling : constant Boolean := CPU = Haswell;
Nico Huber83693c82016-10-08 22:17:55 +020052 Has_Pipe_DDI_Func : constant Boolean := CPU >= Haswell;
53 Has_Trans_Clk_Sel : constant Boolean := CPU >= Haswell;
54 Has_Pipe_MSA_Misc : constant Boolean := CPU >= Haswell;
55 Has_Pipeconf_Misc : constant Boolean := CPU >= Broadwell;
56 Has_Pipeconf_BPC : constant Boolean := CPU /= Haswell;
Nico Huber21da5742017-01-20 14:00:53 +010057 Has_Plane_Control : constant Boolean := CPU >= Broxton;
Nico Huber83693c82016-10-08 22:17:55 +020058 Has_DSP_Linoff : constant Boolean := CPU <= Ivybridge;
Nico Huber4916e342016-11-04 14:37:53 +010059 Has_PF_Pipe_Select : constant Boolean := CPU in Ivybridge .. Haswell;
Nico Huber4dc4c612018-01-10 15:55:09 +010060 Has_Cursor_FBC_Control : constant Boolean := CPU >= Ivybridge;
Nico Huberfbb42202016-11-07 15:08:26 +010061 VGA_Plane_Workaround : constant Boolean := CPU = Ivybridge;
Arthur Heymans73ea0322018-03-28 17:17:07 +020062 Has_GMCH_DP_Transcoder : constant Boolean := CPU = G45;
63 Has_GMCH_VGACNTRL : constant Boolean := CPU = G45;
64 Has_GMCH_PFIT_CONTROL : constant Boolean := CPU = G45;
Nico Huber83693c82016-10-08 22:17:55 +020065
66 ----- Panel power: -----
67 Has_PP_Write_Protection : constant Boolean := CPU <= Ivybridge;
68 Has_PP_Port_Select : constant Boolean := CPU <= Ivybridge;
69 Use_PP_VDD_Override : constant Boolean := CPU <= Ivybridge;
Arthur Heymanse87d0d12018-03-28 17:02:49 +020070 Has_PCH_Panel_Power : constant Boolean := CPU >= Ironlake;
Nico Huber83693c82016-10-08 22:17:55 +020071
72 ----- PCH/FDI: ---------
Arthur Heymans73ea0322018-03-28 17:17:07 +020073 Has_PCH : constant Boolean := CPU /= Broxton and CPU /= G45;
Nico Huber83693c82016-10-08 22:17:55 +020074 Has_PCH_DAC : constant Boolean := CPU in Ironlake .. Ivybridge or
Nico Hubereb4e8f92018-06-09 00:00:46 +020075 (CPU in Haswell .. Broadwell
Nico Huber83693c82016-10-08 22:17:55 +020076 and CPU_Var = Normal);
77
78 Has_PCH_Aux_Channels : constant Boolean := CPU in Ironlake .. Broadwell;
79
80 VGA_Has_Sync_Disable : constant Boolean := CPU <= Ivybridge;
81
82 Has_Trans_Timing_Ovrrde : constant Boolean := CPU >= Sandybridge;
83
84 Has_DPLL_SEL : constant Boolean := CPU in Ironlake .. Ivybridge;
85 Has_FDI_BPC : constant Boolean := CPU in Ironlake .. Ivybridge;
86 Has_FDI_Composite_Sel : constant Boolean := CPU = Ivybridge;
87 Has_Trans_DP_Ctl : constant Boolean := CPU in
88 Sandybridge .. Ivybridge;
89 Has_FDI_C : constant Boolean := CPU = Ivybridge;
90
91 Has_FDI_RX_Power_Down : constant Boolean := CPU in Haswell .. Broadwell;
92
Arthur Heymans73ea0322018-03-28 17:17:07 +020093 Has_GMCH_RawClk : constant Boolean := CPU = G45;
94
Nico Huber83693c82016-10-08 22:17:55 +020095 ----- DDI: -------------
96 End_EDP_Training_Late : constant Boolean := CPU in Haswell .. Broadwell;
97 Has_Per_DDI_Clock_Sel : constant Boolean := CPU in Haswell .. Broadwell;
98 Has_HOTPLUG_CTL : constant Boolean := CPU in Haswell .. Broadwell;
99 Has_SHOTPLUG_CTL_A : constant Boolean := (CPU in Haswell .. Broadwell
100 and CPU_Var = ULT) or
101 CPU >= Skylake;
102
Nico Huber19729a72017-07-30 01:05:05 +0200103 Has_DDI_PHYs : constant Boolean := CPU = Broxton;
104
105 Has_DDI_D : constant Boolean := CPU >= Haswell and
106 CPU_Var = Normal and
107 not Has_DDI_PHYs;
Nico Huber907e4152017-07-29 21:18:59 +0200108 Has_DDI_E : constant Boolean := -- might be disabled by x4 eDP
109 Has_DDI_D;
Nico Huber83693c82016-10-08 22:17:55 +0200110
Nico Huber18ff0c12017-06-12 15:41:31 +0200111 Has_DDI_Buffer_Trans : constant Boolean := CPU >= Haswell and
112 CPU /= Broxton;
Nico Huber21da5742017-01-20 14:00:53 +0100113 Has_Low_Voltage_Swing : constant Boolean := CPU >= Broxton;
Nico Huber58afc202017-06-12 21:34:55 +0200114 Has_Iboost_Config : constant Boolean := CPU >= Skylake;
Nico Huber83693c82016-10-08 22:17:55 +0200115
116 Need_DP_Aux_Mutex : constant Boolean := False; -- Skylake & (PSR | GTC)
117
Nico Huber1c3b9282017-02-09 13:57:04 +0100118 ----- GMBUS: -----------
Nico Huber83693c82016-10-08 22:17:55 +0200119 Ungate_GMBUS_Unit_Level : constant Boolean := CPU >= Skylake;
Nico Huber1c3b9282017-02-09 13:57:04 +0100120 GMBUS_Alternative_Pins : constant Boolean := CPU = Broxton;
Arthur Heymans229ed1c2018-03-28 16:45:43 +0200121 Has_PCH_GMBUS : constant Boolean := CPU >= Ironlake;
Nico Huber83693c82016-10-08 22:17:55 +0200122
123 ----- Power: -----------
124 Has_IPS : constant Boolean := (CPU = Haswell and
125 CPU_Var = ULT) or
126 CPU = Broadwell;
127 Has_IPS_CTL_Mailbox : constant Boolean := CPU = Broadwell;
128
129 Has_Per_Pipe_SRD : constant Boolean := CPU >= Broadwell;
130
Nico Huber21da5742017-01-20 14:00:53 +0100131 ----- GTT: -------------
Nico Huber83693c82016-10-08 22:17:55 +0200132 Fold_39Bit_GTT_PTE : constant Boolean := CPU <= Haswell;
133
134 ----------------------------------------------------------------------------
135
Nico Huber1b2c9a32016-11-20 03:42:08 +0100136 Max_Pipe : constant Pipe_Index :=
Nico Huberd58de7d2018-06-07 23:06:55 +0200137 (if Has_Tertiary_Pipe then Tertiary else Secondary);
Nico Huber83693c82016-10-08 22:17:55 +0200138
139 type Valid_Per_Port is array (Port_Type) of Boolean;
140 type Valid_Per_GPU is array (CPU_Type) of Valid_Per_Port;
141 Valid_Port_GPU : Valid_Per_GPU :=
Arthur Heymans73ea0322018-03-28 17:17:07 +0200142 (G45 =>
143 (Disabled => False,
144 Internal => Config.Internal_Display = LVDS,
145 HDMI3 => False,
146 others => True),
147 Ironlake =>
Nico Huber83693c82016-10-08 22:17:55 +0200148 (Disabled => False,
149 Internal => Config.Internal_Display = LVDS,
150 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100151 Sandybridge =>
Nico Huber83693c82016-10-08 22:17:55 +0200152 (Disabled => False,
153 Internal => Config.Internal_Display = LVDS,
154 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100155 Ivybridge =>
Nico Huber83693c82016-10-08 22:17:55 +0200156 (Disabled => False,
157 Internal => Config.Internal_Display /= None,
158 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100159 Haswell =>
Nico Huber83693c82016-10-08 22:17:55 +0200160 (Disabled => False,
161 Internal => Config.Internal_Display = DP,
Nico Huber0d454cd2016-11-21 13:33:43 +0100162 HDMI3 => CPU_Var = Normal,
Nico Huber83693c82016-10-08 22:17:55 +0200163 DP3 => CPU_Var = Normal,
164 Analog => CPU_Var = Normal,
165 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100166 Broadwell =>
Nico Huber83693c82016-10-08 22:17:55 +0200167 (Disabled => False,
168 Internal => Config.Internal_Display = DP,
Nico Huber0d454cd2016-11-21 13:33:43 +0100169 HDMI3 => CPU_Var = Normal,
Nico Huber83693c82016-10-08 22:17:55 +0200170 DP3 => CPU_Var = Normal,
171 Analog => CPU_Var = Normal,
172 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100173 Broxton =>
174 (Internal => Config.Internal_Display = DP,
175 DP1 => True,
176 DP2 => True,
177 HDMI1 => True,
178 HDMI2 => True,
179 others => False),
180 Skylake =>
Nico Huber83693c82016-10-08 22:17:55 +0200181 (Disabled => False,
182 Internal => Config.Internal_Display = DP,
183 Analog => False,
184 others => True))
185 with
186 Part_Of => GMA.Config_State;
187 Valid_Port : Valid_Per_Port renames Valid_Port_GPU (CPU);
188
Nico Huberac455ad2017-02-14 14:41:19 +0100189 Last_Digital_Port : constant Digital_Port :=
Nico Huber208857d2017-07-29 21:30:24 +0200190 (if Has_DDI_E then DIGI_E else DIGI_C);
Nico Huberac455ad2017-02-14 14:41:19 +0100191
Nico Huber83693c82016-10-08 22:17:55 +0200192 ----------------------------------------------------------------------------
193
Nico Huber3c544ee2016-11-20 04:56:58 +0100194 type FDI_Per_Port is array (Port_Type) of Boolean;
195 Is_FDI_Port : constant FDI_Per_Port :=
196 (case CPU is
197 when Ironlake .. Ivybridge => FDI_Per_Port'
198 (Internal => Internal_Display = LVDS,
199 others => True),
Nico Huber208857d2017-07-29 21:30:24 +0200200 when Haswell .. Broadwell => FDI_Per_Port'
201 (Analog => Has_PCH_DAC,
Nico Huber3c544ee2016-11-20 04:56:58 +0100202 others => False),
Nico Huber21da5742017-01-20 14:00:53 +0100203 when others => FDI_Per_Port'
Nico Huber3c544ee2016-11-20 04:56:58 +0100204 (others => False));
Nico Huber83693c82016-10-08 22:17:55 +0200205
206 type FDI_Lanes_Per_Port is array (GPU_Port) of DP_Lane_Count;
207 FDI_Lane_Count : constant FDI_Lanes_Per_Port :=
208 (DIGI_D => DP_Lane_Count_2,
209 others =>
210 (if CPU in Ironlake .. Ivybridge then
211 DP_Lane_Count_4
212 else
213 DP_Lane_Count_2));
214
215 FDI_Training : constant FDI_Training_Type :=
216 (case CPU is
217 when Ironlake => Simple_Training,
218 when Sandybridge => Full_Training,
219 when others => Auto_Training);
220
Nico Huberf54d0962016-10-20 14:17:18 +0200221 ----------------------------------------------------------------------------
222
Nico Huber247adf32017-06-12 14:39:11 +0200223 Default_DDI_HDMI_Buffer_Translation : constant DDI_HDMI_Buf_Trans_Range :=
224 (case CPU is
Nico Huber730f17c2017-06-12 15:51:25 +0200225 when Haswell => 6,
226 when Broadwell => 7,
Nico Huber247adf32017-06-12 14:39:11 +0200227 when Broxton => 8,
Nico Huber18ff0c12017-06-12 15:41:31 +0200228 when Skylake => 8,
Nico Huber247adf32017-06-12 14:39:11 +0200229 when others => 0);
230
231 ----------------------------------------------------------------------------
232
Nico Huberabe3de22016-10-20 15:03:46 +0200233 Default_CDClk_Freq : constant Frequency_Type :=
234 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200235 when G45 => 320_000_000, -- unused
Nico Huberabe3de22016-10-20 15:03:46 +0200236 when Ironlake |
237 Haswell |
238 Broadwell => 450_000_000,
239 when Sandybridge |
240 Ivybridge => 400_000_000,
Nico Huber21da5742017-01-20 14:00:53 +0100241 when Broxton => 288_000_000,
Nico Huberabe3de22016-10-20 15:03:46 +0200242 when Skylake => 337_500_000);
243
Nico Huberf54d0962016-10-20 14:17:18 +0200244 Default_RawClk_Freq : constant Frequency_Type :=
245 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200246 when G45 => 100_000_000, -- unused, depends on FSB
Nico Huberf54d0962016-10-20 14:17:18 +0200247 when Ironlake |
248 Sandybridge |
249 Ivybridge => 125_000_000,
250 when Haswell |
251 Broadwell => (if CPU_Var = Normal then
252 125_000_000
253 else
254 24_000_000),
Nico Huber21da5742017-01-20 14:00:53 +0100255 when Broxton => Frequency_Type'First, -- none needed
Nico Huberf54d0962016-10-20 14:17:18 +0200256 when Skylake => 24_000_000);
257
Arthur Heymansd1988d12018-03-28 16:27:57 +0200258 Raw_Clock : Frequency_Type := Default_RawClk_Freq
259 with Part_Of => GMA.Config_State;
260
Nico Huberdcd274b2016-11-03 20:15:39 +0100261 ----------------------------------------------------------------------------
262
263 -- Maximum source width with enabled scaler. This only accounts
264 -- for simple 1:1 pipe:scaler mappings.
265
Nico Huberc5c767a2018-06-03 01:09:04 +0200266 type Width_Per_Pipe is array (Pipe_Index) of Width_Type;
Nico Huberdcd274b2016-11-03 20:15:39 +0100267
268 Maximum_Scalable_Width : constant Width_Per_Pipe :=
269 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200270 when G45 => -- TODO: Is this true?
271 (Primary => 4096,
272 Secondary => 2048,
Nico Huberc5c767a2018-06-03 01:09:04 +0200273 Tertiary => Pos32'First),
Nico Huberdcd274b2016-11-03 20:15:39 +0100274 when Ironlake..Haswell =>
275 (Primary => 4096,
276 Secondary => 2048,
277 Tertiary => 2048),
278 when Broadwell..Skylake =>
279 (Primary => 4096,
280 Secondary => 4096,
281 Tertiary => 4096));
282
Nico Hubera02b2c62018-01-09 15:58:34 +0100283 -- Maximum X position of hardware cursors
284 Maximum_Cursor_X : constant := (case CPU is
285 when G45 .. Ivybridge => 4095,
286 when Haswell .. Skylake => 8191);
287
288 Maximum_Cursor_Y : constant := 4095;
289
Nico Huber74ec9622016-11-19 03:00:43 +0100290 ----------------------------------------------------------------------------
291
Nico Huber21da5742017-01-20 14:00:53 +0100292 -- FIXME: Unknown for Broxton, Linux' i915 contains a fixme too :-D
Nico Huber74ec9622016-11-19 03:00:43 +0100293 HDMI_Max_Clock_24bpp : constant Frequency_Type :=
294 (if CPU >= Haswell then 300_000_000 else 225_000_000);
295
Nico Huberb8ae6182017-07-15 20:03:56 +0200296 ----------------------------------------------------------------------------
297
298 GTT_Offset : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200299 when G45 .. Haswell => 16#0020_0000#,
Nico Huberb8ae6182017-07-15 20:03:56 +0200300 when Broadwell .. Skylake => 16#0080_0000#);
301
302 GTT_Size : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200303 when G45 .. Haswell => 16#0020_0000#,
Nico Huberb8ae6182017-07-15 20:03:56 +0200304 -- Limit Broadwell to 4MiB to have a stable
305 -- interface (i.e. same number of entries):
306 when Broadwell .. Skylake => 16#0040_0000#);
307
308 GTT_PTE_Size : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200309 when G45 .. Haswell => 4,
310 when Broadwell .. Skylake => 8);
Nico Huberb8ae6182017-07-15 20:03:56 +0200311
Nico Huberb03c8f12017-08-25 13:29:08 +0200312 Fence_Base : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200313 when G45 .. Ironlake => 16#0000_3000#,
Nico Huberb03c8f12017-08-25 13:29:08 +0200314 when Sandybridge .. Skylake => 16#0010_0000#);
315
316 Fence_Count : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200317 when G45 .. Sandybridge => 16,
Nico Huberb03c8f12017-08-25 13:29:08 +0200318 when Ivybridge .. Skylake => 32);
319
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200320 ----------------------------------------------------------------------------
321
322 use type HW.Word16;
323
324 function Is_Broadwell_H (Device_Id : Word16) return Boolean is
325 (Device_Id = 16#1612# or Device_Id = 16#1622# or Device_Id = 16#162a#);
326
327 function Is_Skylake_U (Device_Id : Word16) return Boolean is
328 (Device_Id = 16#1906# or Device_Id = 16#1916# or Device_Id = 16#1923# or
329 Device_Id = 16#1926# or Device_Id = 16#1927#);
330
331 -- Rather catch too much here than too little,
332 -- it's only used to distinguish generations.
333 function Is_GPU (Device_Id : Word16; CPU : CPU_Type; CPU_Var : CPU_Variant)
334 return Boolean is
335 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200336 when G45 => (Device_Id and 16#ff02#) = 16#2e02# or
337 (Device_Id and 16#fffe#) = 16#2a42#,
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200338 when Ironlake => (Device_Id and 16#fff3#) = 16#0042#,
339 when Sandybridge => (Device_Id and 16#ffc2#) = 16#0102#,
340 when Ivybridge => (Device_Id and 16#ffc3#) = 16#0142#,
341 when Haswell =>
342 (case CPU_Var is
343 when Normal => (Device_Id and 16#ffc3#) = 16#0402# or
344 (Device_Id and 16#ffc3#) = 16#0d02#,
345 when ULT => (Device_Id and 16#ffc3#) = 16#0a02#),
346 when Broadwell => ((Device_Id and 16#ffc3#) = 16#1602# or
347 (Device_Id and 16#ffcf#) = 16#160b# or
348 (Device_Id and 16#ffcf#) = 16#160d#) and
349 (case CPU_Var is
350 when Normal => Is_Broadwell_H (Device_Id),
351 when ULT => not Is_Broadwell_H (Device_Id)),
352 when Broxton => (Device_Id and 16#fffe#) = 16#5a84#,
353 when Skylake => ((Device_Id and 16#ffc3#) = 16#1902# or
354 (Device_Id and 16#ffcf#) = 16#190b# or
355 (Device_Id and 16#ffcf#) = 16#190d# or
356 (Device_Id and 16#fff9#) = 16#1921#) and
357 (case CPU_Var is
358 when Normal => not Is_Skylake_U (Device_Id),
359 when ULT => Is_Skylake_U (Device_Id)));
360
361 function Compatible_GPU (Device_Id : Word16) return Boolean is
362 (Is_GPU (Device_Id, CPU, CPU_Var));
363
Nico Huber83693c82016-10-08 22:17:55 +0200364end HW.GFX.GMA.Config;