blob: 2349272cea94b4e8cdd5598184a4ea1bc0e6a04b [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;
Nico Huber83693c82016-10-08 22:17:55 +020060
61 ----- Panel power: -----
62 Has_PP_Write_Protection : constant Boolean := CPU <= Ivybridge;
63 Has_PP_Port_Select : constant Boolean := CPU <= Ivybridge;
64 Use_PP_VDD_Override : constant Boolean := CPU <= Ivybridge;
65
66 ----- PCH/FDI: ---------
Nico Huber1c3b9282017-02-09 13:57:04 +010067 Has_PCH : constant Boolean := CPU /= Broxton;
Nico Huber83693c82016-10-08 22:17:55 +020068 Has_PCH_DAC : constant Boolean := CPU in Ironlake .. Ivybridge or
69 (CPU in Broadwell .. Haswell
70 and CPU_Var = Normal);
71
72 Has_PCH_Aux_Channels : constant Boolean := CPU in Ironlake .. Broadwell;
73
74 VGA_Has_Sync_Disable : constant Boolean := CPU <= Ivybridge;
75
76 Has_Trans_Timing_Ovrrde : constant Boolean := CPU >= Sandybridge;
77
78 Has_DPLL_SEL : constant Boolean := CPU in Ironlake .. Ivybridge;
79 Has_FDI_BPC : constant Boolean := CPU in Ironlake .. Ivybridge;
80 Has_FDI_Composite_Sel : constant Boolean := CPU = Ivybridge;
81 Has_Trans_DP_Ctl : constant Boolean := CPU in
82 Sandybridge .. Ivybridge;
83 Has_FDI_C : constant Boolean := CPU = Ivybridge;
84
85 Has_FDI_RX_Power_Down : constant Boolean := CPU in Haswell .. Broadwell;
86
87 ----- DDI: -------------
88 End_EDP_Training_Late : constant Boolean := CPU in Haswell .. Broadwell;
89 Has_Per_DDI_Clock_Sel : constant Boolean := CPU in Haswell .. Broadwell;
90 Has_HOTPLUG_CTL : constant Boolean := CPU in Haswell .. Broadwell;
91 Has_SHOTPLUG_CTL_A : constant Boolean := (CPU in Haswell .. Broadwell
92 and CPU_Var = ULT) or
93 CPU >= Skylake;
94
Nico Huber19729a72017-07-30 01:05:05 +020095 Has_DDI_PHYs : constant Boolean := CPU = Broxton;
96
97 Has_DDI_D : constant Boolean := CPU >= Haswell and
98 CPU_Var = Normal and
99 not Has_DDI_PHYs;
Nico Huber907e4152017-07-29 21:18:59 +0200100 Has_DDI_E : constant Boolean := -- might be disabled by x4 eDP
101 Has_DDI_D;
Nico Huber83693c82016-10-08 22:17:55 +0200102
Nico Huber18ff0c12017-06-12 15:41:31 +0200103 Has_DDI_Buffer_Trans : constant Boolean := CPU >= Haswell and
104 CPU /= Broxton;
Nico Huber21da5742017-01-20 14:00:53 +0100105 Has_Low_Voltage_Swing : constant Boolean := CPU >= Broxton;
Nico Huber58afc202017-06-12 21:34:55 +0200106 Has_Iboost_Config : constant Boolean := CPU >= Skylake;
Nico Huber83693c82016-10-08 22:17:55 +0200107
108 Need_DP_Aux_Mutex : constant Boolean := False; -- Skylake & (PSR | GTC)
109
Nico Huber1c3b9282017-02-09 13:57:04 +0100110 ----- GMBUS: -----------
Nico Huber83693c82016-10-08 22:17:55 +0200111 Ungate_GMBUS_Unit_Level : constant Boolean := CPU >= Skylake;
Nico Huber1c3b9282017-02-09 13:57:04 +0100112 GMBUS_Alternative_Pins : constant Boolean := CPU = Broxton;
Nico Huber83693c82016-10-08 22:17:55 +0200113
114 ----- Power: -----------
115 Has_IPS : constant Boolean := (CPU = Haswell and
116 CPU_Var = ULT) or
117 CPU = Broadwell;
118 Has_IPS_CTL_Mailbox : constant Boolean := CPU = Broadwell;
119
120 Has_Per_Pipe_SRD : constant Boolean := CPU >= Broadwell;
121
Nico Huber21da5742017-01-20 14:00:53 +0100122 ----- GTT: -------------
Nico Huber83693c82016-10-08 22:17:55 +0200123 Fold_39Bit_GTT_PTE : constant Boolean := CPU <= Haswell;
124
125 ----------------------------------------------------------------------------
126
Nico Huber1b2c9a32016-11-20 03:42:08 +0100127 Max_Pipe : constant Pipe_Index :=
128 (if CPU <= Sandybridge
129 then Secondary
130 else Tertiary);
131
Nico Huber99f10f32016-11-20 00:34:05 +0100132 type Supported_Pipe_Array is array (Pipe_Index) of Boolean;
Nico Huber83693c82016-10-08 22:17:55 +0200133 Supported_Pipe : constant Supported_Pipe_Array :=
Nico Huber1b2c9a32016-11-20 03:42:08 +0100134 (Primary => Primary <= Max_Pipe,
135 Secondary => Secondary <= Max_Pipe,
136 Tertiary => Tertiary <= Max_Pipe);
Nico Huber83693c82016-10-08 22:17:55 +0200137
138 type Valid_Per_Port is array (Port_Type) of Boolean;
139 type Valid_Per_GPU is array (CPU_Type) of Valid_Per_Port;
140 Valid_Port_GPU : Valid_Per_GPU :=
Nico Huber21da5742017-01-20 14:00:53 +0100141 (Ironlake =>
Nico Huber83693c82016-10-08 22:17:55 +0200142 (Disabled => False,
143 Internal => Config.Internal_Display = LVDS,
144 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100145 Sandybridge =>
Nico Huber83693c82016-10-08 22:17:55 +0200146 (Disabled => False,
147 Internal => Config.Internal_Display = LVDS,
148 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100149 Ivybridge =>
Nico Huber83693c82016-10-08 22:17:55 +0200150 (Disabled => False,
151 Internal => Config.Internal_Display /= None,
152 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100153 Haswell =>
Nico Huber83693c82016-10-08 22:17:55 +0200154 (Disabled => False,
155 Internal => Config.Internal_Display = DP,
Nico Huber0d454cd2016-11-21 13:33:43 +0100156 HDMI3 => CPU_Var = Normal,
Nico Huber83693c82016-10-08 22:17:55 +0200157 DP3 => CPU_Var = Normal,
158 Analog => CPU_Var = Normal,
159 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100160 Broadwell =>
Nico Huber83693c82016-10-08 22:17:55 +0200161 (Disabled => False,
162 Internal => Config.Internal_Display = DP,
Nico Huber0d454cd2016-11-21 13:33:43 +0100163 HDMI3 => CPU_Var = Normal,
Nico Huber83693c82016-10-08 22:17:55 +0200164 DP3 => CPU_Var = Normal,
165 Analog => CPU_Var = Normal,
166 others => True),
Nico Huber21da5742017-01-20 14:00:53 +0100167 Broxton =>
168 (Internal => Config.Internal_Display = DP,
169 DP1 => True,
170 DP2 => True,
171 HDMI1 => True,
172 HDMI2 => True,
173 others => False),
174 Skylake =>
Nico Huber83693c82016-10-08 22:17:55 +0200175 (Disabled => False,
176 Internal => Config.Internal_Display = DP,
177 Analog => False,
178 others => True))
179 with
180 Part_Of => GMA.Config_State;
181 Valid_Port : Valid_Per_Port renames Valid_Port_GPU (CPU);
182
Nico Huberac455ad2017-02-14 14:41:19 +0100183 Last_Digital_Port : constant Digital_Port :=
Nico Huber208857d2017-07-29 21:30:24 +0200184 (if Has_DDI_E then DIGI_E else DIGI_C);
Nico Huberac455ad2017-02-14 14:41:19 +0100185
Nico Huber83693c82016-10-08 22:17:55 +0200186 ----------------------------------------------------------------------------
187
Nico Huber3c544ee2016-11-20 04:56:58 +0100188 type FDI_Per_Port is array (Port_Type) of Boolean;
189 Is_FDI_Port : constant FDI_Per_Port :=
190 (case CPU is
191 when Ironlake .. Ivybridge => FDI_Per_Port'
192 (Internal => Internal_Display = LVDS,
193 others => True),
Nico Huber208857d2017-07-29 21:30:24 +0200194 when Haswell .. Broadwell => FDI_Per_Port'
195 (Analog => Has_PCH_DAC,
Nico Huber3c544ee2016-11-20 04:56:58 +0100196 others => False),
Nico Huber21da5742017-01-20 14:00:53 +0100197 when others => FDI_Per_Port'
Nico Huber3c544ee2016-11-20 04:56:58 +0100198 (others => False));
Nico Huber83693c82016-10-08 22:17:55 +0200199
200 type FDI_Lanes_Per_Port is array (GPU_Port) of DP_Lane_Count;
201 FDI_Lane_Count : constant FDI_Lanes_Per_Port :=
202 (DIGI_D => DP_Lane_Count_2,
203 others =>
204 (if CPU in Ironlake .. Ivybridge then
205 DP_Lane_Count_4
206 else
207 DP_Lane_Count_2));
208
209 FDI_Training : constant FDI_Training_Type :=
210 (case CPU is
211 when Ironlake => Simple_Training,
212 when Sandybridge => Full_Training,
213 when others => Auto_Training);
214
Nico Huberf54d0962016-10-20 14:17:18 +0200215 ----------------------------------------------------------------------------
216
Nico Huber247adf32017-06-12 14:39:11 +0200217 Default_DDI_HDMI_Buffer_Translation : constant DDI_HDMI_Buf_Trans_Range :=
218 (case CPU is
Nico Huber730f17c2017-06-12 15:51:25 +0200219 when Haswell => 6,
220 when Broadwell => 7,
Nico Huber247adf32017-06-12 14:39:11 +0200221 when Broxton => 8,
Nico Huber18ff0c12017-06-12 15:41:31 +0200222 when Skylake => 8,
Nico Huber247adf32017-06-12 14:39:11 +0200223 when others => 0);
224
225 ----------------------------------------------------------------------------
226
Nico Huberabe3de22016-10-20 15:03:46 +0200227 Default_CDClk_Freq : constant Frequency_Type :=
228 (case CPU is
229 when Ironlake |
230 Haswell |
231 Broadwell => 450_000_000,
232 when Sandybridge |
233 Ivybridge => 400_000_000,
Nico Huber21da5742017-01-20 14:00:53 +0100234 when Broxton => 288_000_000,
Nico Huberabe3de22016-10-20 15:03:46 +0200235 when Skylake => 337_500_000);
236
Nico Huberf54d0962016-10-20 14:17:18 +0200237 Default_RawClk_Freq : constant Frequency_Type :=
238 (case CPU is
239 when Ironlake |
240 Sandybridge |
241 Ivybridge => 125_000_000,
242 when Haswell |
243 Broadwell => (if CPU_Var = Normal then
244 125_000_000
245 else
246 24_000_000),
Nico Huber21da5742017-01-20 14:00:53 +0100247 when Broxton => Frequency_Type'First, -- none needed
Nico Huberf54d0962016-10-20 14:17:18 +0200248 when Skylake => 24_000_000);
249
Arthur Heymansd1988d12018-03-28 16:27:57 +0200250 Raw_Clock : Frequency_Type := Default_RawClk_Freq
251 with Part_Of => GMA.Config_State;
252
Nico Huberdcd274b2016-11-03 20:15:39 +0100253 ----------------------------------------------------------------------------
254
255 -- Maximum source width with enabled scaler. This only accounts
256 -- for simple 1:1 pipe:scaler mappings.
257
Nico Huber9b479412017-08-27 11:55:56 +0200258 type Width_Per_Pipe is array (Pipe_Index) of Pos16;
Nico Huberdcd274b2016-11-03 20:15:39 +0100259
260 Maximum_Scalable_Width : constant Width_Per_Pipe :=
261 (case CPU is
262 when Ironlake..Haswell =>
263 (Primary => 4096,
264 Secondary => 2048,
265 Tertiary => 2048),
266 when Broadwell..Skylake =>
267 (Primary => 4096,
268 Secondary => 4096,
269 Tertiary => 4096));
270
Nico Huber74ec9622016-11-19 03:00:43 +0100271 ----------------------------------------------------------------------------
272
Nico Huber21da5742017-01-20 14:00:53 +0100273 -- FIXME: Unknown for Broxton, Linux' i915 contains a fixme too :-D
Nico Huber74ec9622016-11-19 03:00:43 +0100274 HDMI_Max_Clock_24bpp : constant Frequency_Type :=
275 (if CPU >= Haswell then 300_000_000 else 225_000_000);
276
Nico Huberb8ae6182017-07-15 20:03:56 +0200277 ----------------------------------------------------------------------------
278
279 GTT_Offset : constant := (case CPU is
280 when Ironlake .. Haswell => 16#0020_0000#,
281 when Broadwell .. Skylake => 16#0080_0000#);
282
283 GTT_Size : constant := (case CPU is
284 when Ironlake .. Haswell => 16#0020_0000#,
285 -- Limit Broadwell to 4MiB to have a stable
286 -- interface (i.e. same number of entries):
287 when Broadwell .. Skylake => 16#0040_0000#);
288
289 GTT_PTE_Size : constant := (case CPU is
290 when Ironlake .. Haswell => 4,
291 when Broadwell .. Skylake => 8);
292
Nico Huberb03c8f12017-08-25 13:29:08 +0200293 Fence_Base : constant := (case CPU is
294 when Ironlake => 16#0000_3000#,
295 when Sandybridge .. Skylake => 16#0010_0000#);
296
297 Fence_Count : constant := (case CPU is
298 when Ironlake .. Sandybridge => 16,
299 when Ivybridge .. Skylake => 32);
300
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200301 ----------------------------------------------------------------------------
302
303 use type HW.Word16;
304
305 function Is_Broadwell_H (Device_Id : Word16) return Boolean is
306 (Device_Id = 16#1612# or Device_Id = 16#1622# or Device_Id = 16#162a#);
307
308 function Is_Skylake_U (Device_Id : Word16) return Boolean is
309 (Device_Id = 16#1906# or Device_Id = 16#1916# or Device_Id = 16#1923# or
310 Device_Id = 16#1926# or Device_Id = 16#1927#);
311
312 -- Rather catch too much here than too little,
313 -- it's only used to distinguish generations.
314 function Is_GPU (Device_Id : Word16; CPU : CPU_Type; CPU_Var : CPU_Variant)
315 return Boolean is
316 (case CPU is
317 when Ironlake => (Device_Id and 16#fff3#) = 16#0042#,
318 when Sandybridge => (Device_Id and 16#ffc2#) = 16#0102#,
319 when Ivybridge => (Device_Id and 16#ffc3#) = 16#0142#,
320 when Haswell =>
321 (case CPU_Var is
322 when Normal => (Device_Id and 16#ffc3#) = 16#0402# or
323 (Device_Id and 16#ffc3#) = 16#0d02#,
324 when ULT => (Device_Id and 16#ffc3#) = 16#0a02#),
325 when Broadwell => ((Device_Id and 16#ffc3#) = 16#1602# or
326 (Device_Id and 16#ffcf#) = 16#160b# or
327 (Device_Id and 16#ffcf#) = 16#160d#) and
328 (case CPU_Var is
329 when Normal => Is_Broadwell_H (Device_Id),
330 when ULT => not Is_Broadwell_H (Device_Id)),
331 when Broxton => (Device_Id and 16#fffe#) = 16#5a84#,
332 when Skylake => ((Device_Id and 16#ffc3#) = 16#1902# or
333 (Device_Id and 16#ffcf#) = 16#190b# or
334 (Device_Id and 16#ffcf#) = 16#190d# or
335 (Device_Id and 16#fff9#) = 16#1921#) and
336 (case CPU_Var is
337 when Normal => not Is_Skylake_U (Device_Id),
338 when ULT => Is_Skylake_U (Device_Id)));
339
340 function Compatible_GPU (Device_Id : Word16) return Boolean is
341 (Is_GPU (Device_Id, CPU, CPU_Var));
342
Nico Huber83693c82016-10-08 22:17:55 +0200343end HW.GFX.GMA.Config;