blob: a0f3eed38d4b48117841304f60ee4c1101f33d1d [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
Nico Huber01b680f2017-06-09 16:24:22 +02002-- Copyright (C) 2015-2017 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: --------
46 Disable_Trickle_Feed : constant Boolean := not
47 (CPU in Haswell .. Broadwell);
48 Pipe_Enabled_Workaround : constant Boolean := CPU = Broadwell;
Nico Huber7ad2d652016-12-07 15:19:32 +010049 Has_EDP_Transcoder : constant Boolean := CPU >= Haswell;
Nico Huber83693c82016-10-08 22:17:55 +020050 Has_Pipe_DDI_Func : constant Boolean := CPU >= Haswell;
51 Has_Trans_Clk_Sel : constant Boolean := CPU >= Haswell;
52 Has_Pipe_MSA_Misc : constant Boolean := CPU >= Haswell;
53 Has_Pipeconf_Misc : constant Boolean := CPU >= Broadwell;
54 Has_Pipeconf_BPC : constant Boolean := CPU /= Haswell;
Nico Huber21da5742017-01-20 14:00:53 +010055 Has_Plane_Control : constant Boolean := CPU >= Broxton;
Nico Huber83693c82016-10-08 22:17:55 +020056 Has_DSP_Linoff : constant Boolean := CPU <= Ivybridge;
Nico Huber4916e342016-11-04 14:37:53 +010057 Has_PF_Pipe_Select : constant Boolean := CPU in Ivybridge .. Haswell;
Nico Huberfbb42202016-11-07 15:08:26 +010058 VGA_Plane_Workaround : constant Boolean := CPU = Ivybridge;
Arthur Heymansdfcdd772018-03-28 16:42:50 +020059 Has_GMCH_VGACNTRL : constant Boolean := false;
Arthur Heymans636390c2018-03-28 16:52:13 +020060 Has_GMCH_DP_Transcoder : constant Boolean := false;
Nico Huber83693c82016-10-08 22:17:55 +020061
62 ----- Panel power: -----
63 Has_PP_Write_Protection : constant Boolean := CPU <= Ivybridge;
64 Has_PP_Port_Select : constant Boolean := CPU <= Ivybridge;
65 Use_PP_VDD_Override : constant Boolean := CPU <= Ivybridge;
66
67 ----- PCH/FDI: ---------
Nico Huber1c3b9282017-02-09 13:57:04 +010068 Has_PCH : constant Boolean := CPU /= Broxton;
Nico Huber83693c82016-10-08 22:17:55 +020069 Has_PCH_DAC : constant Boolean := CPU in Ironlake .. Ivybridge or
70 (CPU in Broadwell .. Haswell
71 and CPU_Var = Normal);
72
73 Has_PCH_Aux_Channels : constant Boolean := CPU in Ironlake .. Broadwell;
74
75 VGA_Has_Sync_Disable : constant Boolean := CPU <= Ivybridge;
76
77 Has_Trans_Timing_Ovrrde : constant Boolean := CPU >= Sandybridge;
78
79 Has_DPLL_SEL : constant Boolean := CPU in Ironlake .. Ivybridge;
80 Has_FDI_BPC : constant Boolean := CPU in Ironlake .. Ivybridge;
81 Has_FDI_Composite_Sel : constant Boolean := CPU = Ivybridge;
82 Has_Trans_DP_Ctl : constant Boolean := CPU in
83 Sandybridge .. Ivybridge;
84 Has_FDI_C : constant Boolean := CPU = Ivybridge;
85
86 Has_FDI_RX_Power_Down : constant Boolean := CPU in Haswell .. Broadwell;
87
88 ----- DDI: -------------
89 End_EDP_Training_Late : constant Boolean := CPU in Haswell .. Broadwell;
90 Has_Per_DDI_Clock_Sel : constant Boolean := CPU in Haswell .. Broadwell;
91 Has_HOTPLUG_CTL : constant Boolean := CPU in Haswell .. Broadwell;
92 Has_SHOTPLUG_CTL_A : constant Boolean := (CPU in Haswell .. Broadwell
93 and CPU_Var = ULT) or
94 CPU >= Skylake;
95
Nico Huber19729a72017-07-30 01:05:05 +020096 Has_DDI_PHYs : constant Boolean := CPU = Broxton;
97
98 Has_DDI_D : constant Boolean := CPU >= Haswell and
99 CPU_Var = Normal and
100 not Has_DDI_PHYs;
Nico Huber907e4152017-07-29 21:18:59 +0200101 Has_DDI_E : constant Boolean := -- might be disabled by x4 eDP
102 Has_DDI_D;
Nico Huber83693c82016-10-08 22:17:55 +0200103
Nico Huber18ff0c12017-06-12 15:41:31 +0200104 Has_DDI_Buffer_Trans : constant Boolean := CPU >= Haswell and
105 CPU /= Broxton;
Nico Huber21da5742017-01-20 14:00:53 +0100106 Has_Low_Voltage_Swing : constant Boolean := CPU >= Broxton;
Nico Huber58afc202017-06-12 21:34:55 +0200107 Has_Iboost_Config : constant Boolean := CPU >= Skylake;
Nico Huber83693c82016-10-08 22:17:55 +0200108
109 Need_DP_Aux_Mutex : constant Boolean := False; -- Skylake & (PSR | GTC)
110
Nico Huber1c3b9282017-02-09 13:57:04 +0100111 ----- GMBUS: -----------
Nico Huber83693c82016-10-08 22:17:55 +0200112 Ungate_GMBUS_Unit_Level : constant Boolean := CPU >= Skylake;
Nico Huber1c3b9282017-02-09 13:57:04 +0100113 GMBUS_Alternative_Pins : constant Boolean := CPU = Broxton;
Arthur Heymans229ed1c2018-03-28 16:45:43 +0200114 Has_PCH_GMBUS : constant Boolean := CPU >= Ironlake;
Nico Huber83693c82016-10-08 22:17:55 +0200115
116 ----- Power: -----------
117 Has_IPS : constant Boolean := (CPU = Haswell and
118 CPU_Var = ULT) or
119 CPU = Broadwell;
120 Has_IPS_CTL_Mailbox : constant Boolean := CPU = Broadwell;
121
122 Has_Per_Pipe_SRD : constant Boolean := CPU >= Broadwell;
123
Nico Huber21da5742017-01-20 14:00:53 +0100124 ----- GTT: -------------
Nico Huber83693c82016-10-08 22:17:55 +0200125 Fold_39Bit_GTT_PTE : constant Boolean := CPU <= Haswell;
126
127 ----------------------------------------------------------------------------
128
Nico Huber1b2c9a32016-11-20 03:42:08 +0100129 Max_Pipe : constant Pipe_Index :=
130 (if CPU <= Sandybridge
131 then Secondary
132 else Tertiary);
133
Nico Huber99f10f32016-11-20 00:34:05 +0100134 type Supported_Pipe_Array is array (Pipe_Index) of Boolean;
Nico Huber83693c82016-10-08 22:17:55 +0200135 Supported_Pipe : constant Supported_Pipe_Array :=
Nico Huber1b2c9a32016-11-20 03:42:08 +0100136 (Primary => Primary <= Max_Pipe,
137 Secondary => Secondary <= Max_Pipe,
138 Tertiary => Tertiary <= Max_Pipe);
Nico Huber83693c82016-10-08 22:17:55 +0200139
140 type Valid_Per_Port is array (Port_Type) of Boolean;
141 type Valid_Per_GPU is array (CPU_Type) of Valid_Per_Port;
142 Valid_Port_GPU : Valid_Per_GPU :=
Nico Huber21da5742017-01-20 14:00:53 +0100143 (Ironlake =>
Nico Huber83693c82016-10-08 22:17:55 +0200144 (Disabled => False,
145 Internal => Config.Internal_Display = LVDS,
146 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100147 Sandybridge =>
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 Ivybridge =>
Nico Huber83693c82016-10-08 22:17:55 +0200152 (Disabled => False,
153 Internal => Config.Internal_Display /= None,
154 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100155 Haswell =>
Nico Huber83693c82016-10-08 22:17:55 +0200156 (Disabled => False,
157 Internal => Config.Internal_Display = DP,
Nico Huber0d454cd2016-11-21 13:33:43 +0100158 HDMI3 => CPU_Var = Normal,
Nico Huber83693c82016-10-08 22:17:55 +0200159 DP3 => CPU_Var = Normal,
160 Analog => CPU_Var = Normal,
161 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100162 Broadwell =>
Nico Huber83693c82016-10-08 22:17:55 +0200163 (Disabled => False,
164 Internal => Config.Internal_Display = DP,
Nico Huber0d454cd2016-11-21 13:33:43 +0100165 HDMI3 => CPU_Var = Normal,
Nico Huber83693c82016-10-08 22:17:55 +0200166 DP3 => CPU_Var = Normal,
167 Analog => CPU_Var = Normal,
168 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100169 Broxton =>
170 (Internal => Config.Internal_Display = DP,
171 DP1 => True,
172 DP2 => True,
173 HDMI1 => True,
174 HDMI2 => True,
175 others => False),
176 Skylake =>
Nico Huber83693c82016-10-08 22:17:55 +0200177 (Disabled => False,
178 Internal => Config.Internal_Display = DP,
179 Analog => False,
180 others => True))
181 with
182 Part_Of => GMA.Config_State;
183 Valid_Port : Valid_Per_Port renames Valid_Port_GPU (CPU);
184
Nico Huberac455ad2017-02-14 14:41:19 +0100185 Last_Digital_Port : constant Digital_Port :=
Nico Huber208857d2017-07-29 21:30:24 +0200186 (if Has_DDI_E then DIGI_E else DIGI_C);
Nico Huberac455ad2017-02-14 14:41:19 +0100187
Nico Huber83693c82016-10-08 22:17:55 +0200188 ----------------------------------------------------------------------------
189
Nico Huber3c544ee2016-11-20 04:56:58 +0100190 type FDI_Per_Port is array (Port_Type) of Boolean;
191 Is_FDI_Port : constant FDI_Per_Port :=
192 (case CPU is
193 when Ironlake .. Ivybridge => FDI_Per_Port'
194 (Internal => Internal_Display = LVDS,
195 others => True),
Nico Huber208857d2017-07-29 21:30:24 +0200196 when Haswell .. Broadwell => FDI_Per_Port'
197 (Analog => Has_PCH_DAC,
Nico Huber3c544ee2016-11-20 04:56:58 +0100198 others => False),
Nico Huber21da5742017-01-20 14:00:53 +0100199 when others => FDI_Per_Port'
Nico Huber3c544ee2016-11-20 04:56:58 +0100200 (others => False));
Nico Huber83693c82016-10-08 22:17:55 +0200201
202 type FDI_Lanes_Per_Port is array (GPU_Port) of DP_Lane_Count;
203 FDI_Lane_Count : constant FDI_Lanes_Per_Port :=
204 (DIGI_D => DP_Lane_Count_2,
205 others =>
206 (if CPU in Ironlake .. Ivybridge then
207 DP_Lane_Count_4
208 else
209 DP_Lane_Count_2));
210
211 FDI_Training : constant FDI_Training_Type :=
212 (case CPU is
213 when Ironlake => Simple_Training,
214 when Sandybridge => Full_Training,
215 when others => Auto_Training);
216
Nico Huberf54d0962016-10-20 14:17:18 +0200217 ----------------------------------------------------------------------------
218
Nico Huber247adf32017-06-12 14:39:11 +0200219 Default_DDI_HDMI_Buffer_Translation : constant DDI_HDMI_Buf_Trans_Range :=
220 (case CPU is
Nico Huber730f17c2017-06-12 15:51:25 +0200221 when Haswell => 6,
222 when Broadwell => 7,
Nico Huber247adf32017-06-12 14:39:11 +0200223 when Broxton => 8,
Nico Huber18ff0c12017-06-12 15:41:31 +0200224 when Skylake => 8,
Nico Huber247adf32017-06-12 14:39:11 +0200225 when others => 0);
226
227 ----------------------------------------------------------------------------
228
Nico Huberabe3de22016-10-20 15:03:46 +0200229 Default_CDClk_Freq : constant Frequency_Type :=
230 (case CPU is
231 when Ironlake |
232 Haswell |
233 Broadwell => 450_000_000,
234 when Sandybridge |
235 Ivybridge => 400_000_000,
Nico Huber21da5742017-01-20 14:00:53 +0100236 when Broxton => 288_000_000,
Nico Huberabe3de22016-10-20 15:03:46 +0200237 when Skylake => 337_500_000);
238
Nico Huberf54d0962016-10-20 14:17:18 +0200239 Default_RawClk_Freq : constant Frequency_Type :=
240 (case CPU is
241 when Ironlake |
242 Sandybridge |
243 Ivybridge => 125_000_000,
244 when Haswell |
245 Broadwell => (if CPU_Var = Normal then
246 125_000_000
247 else
248 24_000_000),
Nico Huber21da5742017-01-20 14:00:53 +0100249 when Broxton => Frequency_Type'First, -- none needed
Nico Huberf54d0962016-10-20 14:17:18 +0200250 when Skylake => 24_000_000);
251
Arthur Heymansd1988d12018-03-28 16:27:57 +0200252 Raw_Clock : Frequency_Type := Default_RawClk_Freq
253 with Part_Of => GMA.Config_State;
254
Nico Huberdcd274b2016-11-03 20:15:39 +0100255 ----------------------------------------------------------------------------
256
257 -- Maximum source width with enabled scaler. This only accounts
258 -- for simple 1:1 pipe:scaler mappings.
259
Nico Huber9b479412017-08-27 11:55:56 +0200260 type Width_Per_Pipe is array (Pipe_Index) of Pos16;
Nico Huberdcd274b2016-11-03 20:15:39 +0100261
262 Maximum_Scalable_Width : constant Width_Per_Pipe :=
263 (case CPU is
264 when Ironlake..Haswell =>
265 (Primary => 4096,
266 Secondary => 2048,
267 Tertiary => 2048),
268 when Broadwell..Skylake =>
269 (Primary => 4096,
270 Secondary => 4096,
271 Tertiary => 4096));
272
Nico Huber74ec9622016-11-19 03:00:43 +0100273 ----------------------------------------------------------------------------
274
Nico Huber21da5742017-01-20 14:00:53 +0100275 -- FIXME: Unknown for Broxton, Linux' i915 contains a fixme too :-D
Nico Huber74ec9622016-11-19 03:00:43 +0100276 HDMI_Max_Clock_24bpp : constant Frequency_Type :=
277 (if CPU >= Haswell then 300_000_000 else 225_000_000);
278
Nico Huberb8ae6182017-07-15 20:03:56 +0200279 ----------------------------------------------------------------------------
280
281 GTT_Offset : constant := (case CPU is
282 when Ironlake .. Haswell => 16#0020_0000#,
283 when Broadwell .. Skylake => 16#0080_0000#);
284
285 GTT_Size : constant := (case CPU is
286 when Ironlake .. Haswell => 16#0020_0000#,
287 -- Limit Broadwell to 4MiB to have a stable
288 -- interface (i.e. same number of entries):
289 when Broadwell .. Skylake => 16#0040_0000#);
290
291 GTT_PTE_Size : constant := (case CPU is
292 when Ironlake .. Haswell => 4,
293 when Broadwell .. Skylake => 8);
294
Nico Huberb03c8f12017-08-25 13:29:08 +0200295 Fence_Base : constant := (case CPU is
296 when Ironlake => 16#0000_3000#,
297 when Sandybridge .. Skylake => 16#0010_0000#);
298
299 Fence_Count : constant := (case CPU is
300 when Ironlake .. Sandybridge => 16,
301 when Ivybridge .. Skylake => 32);
302
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200303 ----------------------------------------------------------------------------
304
305 use type HW.Word16;
306
307 function Is_Broadwell_H (Device_Id : Word16) return Boolean is
308 (Device_Id = 16#1612# or Device_Id = 16#1622# or Device_Id = 16#162a#);
309
310 function Is_Skylake_U (Device_Id : Word16) return Boolean is
311 (Device_Id = 16#1906# or Device_Id = 16#1916# or Device_Id = 16#1923# or
312 Device_Id = 16#1926# or Device_Id = 16#1927#);
313
314 -- Rather catch too much here than too little,
315 -- it's only used to distinguish generations.
316 function Is_GPU (Device_Id : Word16; CPU : CPU_Type; CPU_Var : CPU_Variant)
317 return Boolean is
318 (case CPU is
319 when Ironlake => (Device_Id and 16#fff3#) = 16#0042#,
320 when Sandybridge => (Device_Id and 16#ffc2#) = 16#0102#,
321 when Ivybridge => (Device_Id and 16#ffc3#) = 16#0142#,
322 when Haswell =>
323 (case CPU_Var is
324 when Normal => (Device_Id and 16#ffc3#) = 16#0402# or
325 (Device_Id and 16#ffc3#) = 16#0d02#,
326 when ULT => (Device_Id and 16#ffc3#) = 16#0a02#),
327 when Broadwell => ((Device_Id and 16#ffc3#) = 16#1602# or
328 (Device_Id and 16#ffcf#) = 16#160b# or
329 (Device_Id and 16#ffcf#) = 16#160d#) and
330 (case CPU_Var is
331 when Normal => Is_Broadwell_H (Device_Id),
332 when ULT => not Is_Broadwell_H (Device_Id)),
333 when Broxton => (Device_Id and 16#fffe#) = 16#5a84#,
334 when Skylake => ((Device_Id and 16#ffc3#) = 16#1902# or
335 (Device_Id and 16#ffcf#) = 16#190b# or
336 (Device_Id and 16#ffcf#) = 16#190d# or
337 (Device_Id and 16#fff9#) = 16#1921#) and
338 (case CPU_Var is
339 when Normal => not Is_Skylake_U (Device_Id),
340 when ULT => Is_Skylake_U (Device_Id)));
341
342 function Compatible_GPU (Device_Id : Word16) return Boolean is
343 (Is_GPU (Device_Id, CPU, CPU_Var));
344
Nico Huber83693c82016-10-08 22:17:55 +0200345end HW.GFX.GMA.Config;