blob: 398b340ba17b4a7f7e8a468eb3c0ecf716793846 [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
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 Huber117db372018-06-09 17:56:05 +020038 Have_HDMI_Buf_Override : constant Boolean := DDI_HDMI_Buffer_Translation >= 0;
Nico Huber2b6f6992017-07-09 18:11:34 +020039 Default_MMIO_Base_Set : constant Boolean := Default_MMIO_Base /= 0;
40
Nico Huber83693c82016-10-08 22:17:55 +020041 Has_Internal_Display : constant Boolean := Internal_Display /= None;
Nico Huber318bca12018-06-09 19:22:52 +020042 Internal_Is_LVDS : constant Boolean := Internal_Display = LVDS;
Nico Huber83693c82016-10-08 22:17:55 +020043 Internal_Is_EDP : constant Boolean := Internal_Display = DP;
Nico Huber1bc496f2017-06-09 22:23:28 +020044 Have_DVI_I : constant Boolean := Analog_I2C_Port /= PCH_DAC;
Nico Huber1c3b9282017-02-09 13:57:04 +010045 Has_Presence_Straps : constant Boolean := CPU /= Broxton;
Nico Huber67cf6d82018-06-09 18:48:11 +020046 Is_ULT : constant Boolean := CPU_Var = ULT;
Nico Huber83693c82016-10-08 22:17:55 +020047
48 ----- CPU pipe: --------
Nico Huberd58de7d2018-06-07 23:06:55 +020049 Has_Tertiary_Pipe : constant Boolean := CPU >= Ivybridge;
Nico Huber83693c82016-10-08 22:17:55 +020050 Disable_Trickle_Feed : constant Boolean := not
51 (CPU in Haswell .. Broadwell);
52 Pipe_Enabled_Workaround : constant Boolean := CPU = Broadwell;
Nico Huber7ad2d652016-12-07 15:19:32 +010053 Has_EDP_Transcoder : constant Boolean := CPU >= Haswell;
Nico Huber3d06de82018-05-29 01:35:04 +020054 Use_PDW_For_EDP_Scaling : constant Boolean := CPU = Haswell;
Nico Huber83693c82016-10-08 22:17:55 +020055 Has_Pipe_DDI_Func : constant Boolean := CPU >= Haswell;
56 Has_Trans_Clk_Sel : constant Boolean := CPU >= Haswell;
57 Has_Pipe_MSA_Misc : constant Boolean := CPU >= Haswell;
58 Has_Pipeconf_Misc : constant Boolean := CPU >= Broadwell;
59 Has_Pipeconf_BPC : constant Boolean := CPU /= Haswell;
Nico Huber21da5742017-01-20 14:00:53 +010060 Has_Plane_Control : constant Boolean := CPU >= Broxton;
Nico Huber83693c82016-10-08 22:17:55 +020061 Has_DSP_Linoff : constant Boolean := CPU <= Ivybridge;
Nico Huber4916e342016-11-04 14:37:53 +010062 Has_PF_Pipe_Select : constant Boolean := CPU in Ivybridge .. Haswell;
Nico Huber4dc4c612018-01-10 15:55:09 +010063 Has_Cursor_FBC_Control : constant Boolean := CPU >= Ivybridge;
Nico Huberfbb42202016-11-07 15:08:26 +010064 VGA_Plane_Workaround : constant Boolean := CPU = Ivybridge;
Arthur Heymans73ea0322018-03-28 17:17:07 +020065 Has_GMCH_DP_Transcoder : constant Boolean := CPU = G45;
66 Has_GMCH_VGACNTRL : constant Boolean := CPU = G45;
67 Has_GMCH_PFIT_CONTROL : constant Boolean := CPU = G45;
Nico Huber83693c82016-10-08 22:17:55 +020068
69 ----- Panel power: -----
70 Has_PP_Write_Protection : constant Boolean := CPU <= Ivybridge;
71 Has_PP_Port_Select : constant Boolean := CPU <= Ivybridge;
72 Use_PP_VDD_Override : constant Boolean := CPU <= Ivybridge;
Arthur Heymanse87d0d12018-03-28 17:02:49 +020073 Has_PCH_Panel_Power : constant Boolean := CPU >= Ironlake;
Nico Huber83693c82016-10-08 22:17:55 +020074
75 ----- PCH/FDI: ---------
Arthur Heymans73ea0322018-03-28 17:17:07 +020076 Has_PCH : constant Boolean := CPU /= Broxton and CPU /= G45;
Nico Huber83693c82016-10-08 22:17:55 +020077 Has_PCH_DAC : constant Boolean := CPU in Ironlake .. Ivybridge or
Nico Hubereb4e8f92018-06-09 00:00:46 +020078 (CPU in Haswell .. Broadwell
Nico Huber67cf6d82018-06-09 18:48:11 +020079 and not Is_ULT);
Nico Huber83693c82016-10-08 22:17:55 +020080
81 Has_PCH_Aux_Channels : constant Boolean := CPU in Ironlake .. Broadwell;
82
83 VGA_Has_Sync_Disable : constant Boolean := CPU <= Ivybridge;
84
85 Has_Trans_Timing_Ovrrde : constant Boolean := CPU >= Sandybridge;
86
87 Has_DPLL_SEL : constant Boolean := CPU in Ironlake .. Ivybridge;
88 Has_FDI_BPC : constant Boolean := CPU in Ironlake .. Ivybridge;
89 Has_FDI_Composite_Sel : constant Boolean := CPU = Ivybridge;
90 Has_Trans_DP_Ctl : constant Boolean := CPU in
91 Sandybridge .. Ivybridge;
92 Has_FDI_C : constant Boolean := CPU = Ivybridge;
93
94 Has_FDI_RX_Power_Down : constant Boolean := CPU in Haswell .. Broadwell;
95
Arthur Heymans73ea0322018-03-28 17:17:07 +020096 Has_GMCH_RawClk : constant Boolean := CPU = G45;
97
Nico Huber83693c82016-10-08 22:17:55 +020098 ----- DDI: -------------
99 End_EDP_Training_Late : constant Boolean := CPU in Haswell .. Broadwell;
100 Has_Per_DDI_Clock_Sel : constant Boolean := CPU in Haswell .. Broadwell;
101 Has_HOTPLUG_CTL : constant Boolean := CPU in Haswell .. Broadwell;
102 Has_SHOTPLUG_CTL_A : constant Boolean := (CPU in Haswell .. Broadwell
Nico Huber67cf6d82018-06-09 18:48:11 +0200103 and Is_ULT) or
Nico Huber83693c82016-10-08 22:17:55 +0200104 CPU >= Skylake;
105
Nico Huber19729a72017-07-30 01:05:05 +0200106 Has_DDI_PHYs : constant Boolean := CPU = Broxton;
107
108 Has_DDI_D : constant Boolean := CPU >= Haswell and
Nico Huber67cf6d82018-06-09 18:48:11 +0200109 not Is_ULT and
Nico Huber19729a72017-07-30 01:05:05 +0200110 not Has_DDI_PHYs;
Nico Huber907e4152017-07-29 21:18:59 +0200111 Has_DDI_E : constant Boolean := -- might be disabled by x4 eDP
112 Has_DDI_D;
Nico Huber83693c82016-10-08 22:17:55 +0200113
Nico Huber18ff0c12017-06-12 15:41:31 +0200114 Has_DDI_Buffer_Trans : constant Boolean := CPU >= Haswell and
115 CPU /= Broxton;
Nico Huber21da5742017-01-20 14:00:53 +0100116 Has_Low_Voltage_Swing : constant Boolean := CPU >= Broxton;
Nico Huber58afc202017-06-12 21:34:55 +0200117 Has_Iboost_Config : constant Boolean := CPU >= Skylake;
Nico Huber83693c82016-10-08 22:17:55 +0200118
119 Need_DP_Aux_Mutex : constant Boolean := False; -- Skylake & (PSR | GTC)
120
Nico Huber1c3b9282017-02-09 13:57:04 +0100121 ----- GMBUS: -----------
Nico Huber83693c82016-10-08 22:17:55 +0200122 Ungate_GMBUS_Unit_Level : constant Boolean := CPU >= Skylake;
Nico Huber1c3b9282017-02-09 13:57:04 +0100123 GMBUS_Alternative_Pins : constant Boolean := CPU = Broxton;
Arthur Heymans229ed1c2018-03-28 16:45:43 +0200124 Has_PCH_GMBUS : constant Boolean := CPU >= Ironlake;
Nico Huber83693c82016-10-08 22:17:55 +0200125
126 ----- Power: -----------
Nico Huber67cf6d82018-06-09 18:48:11 +0200127 Has_IPS : constant Boolean := (CPU = Haswell and Is_ULT) or
Nico Huber83693c82016-10-08 22:17:55 +0200128 CPU = Broadwell;
129 Has_IPS_CTL_Mailbox : constant Boolean := CPU = Broadwell;
130
131 Has_Per_Pipe_SRD : constant Boolean := CPU >= Broadwell;
132
Nico Huber21da5742017-01-20 14:00:53 +0100133 ----- GTT: -------------
Nico Huber83693c82016-10-08 22:17:55 +0200134 Fold_39Bit_GTT_PTE : constant Boolean := CPU <= Haswell;
135
136 ----------------------------------------------------------------------------
137
Nico Huber1b2c9a32016-11-20 03:42:08 +0100138 Max_Pipe : constant Pipe_Index :=
Nico Huberd58de7d2018-06-07 23:06:55 +0200139 (if Has_Tertiary_Pipe then Tertiary else Secondary);
Nico Huber83693c82016-10-08 22:17:55 +0200140
Nico Huber318bca12018-06-09 19:22:52 +0200141 Valid_Port : array (Port_Type) of Boolean := (others => False)
Nico Huber83693c82016-10-08 22:17:55 +0200142 with
143 Part_Of => GMA.Config_State;
Nico Huber83693c82016-10-08 22:17:55 +0200144
Nico Huberac455ad2017-02-14 14:41:19 +0100145 Last_Digital_Port : constant Digital_Port :=
Nico Huber208857d2017-07-29 21:30:24 +0200146 (if Has_DDI_E then DIGI_E else DIGI_C);
Nico Huberac455ad2017-02-14 14:41:19 +0100147
Nico Huber83693c82016-10-08 22:17:55 +0200148 ----------------------------------------------------------------------------
149
Nico Huber3c544ee2016-11-20 04:56:58 +0100150 type FDI_Per_Port is array (Port_Type) of Boolean;
151 Is_FDI_Port : constant FDI_Per_Port :=
152 (case CPU is
153 when Ironlake .. Ivybridge => FDI_Per_Port'
Nico Huber318bca12018-06-09 19:22:52 +0200154 (Internal => Internal_Is_LVDS,
Nico Huber3c544ee2016-11-20 04:56:58 +0100155 others => True),
Nico Huber208857d2017-07-29 21:30:24 +0200156 when Haswell .. Broadwell => FDI_Per_Port'
157 (Analog => Has_PCH_DAC,
Nico Huber3c544ee2016-11-20 04:56:58 +0100158 others => False),
Nico Huber21da5742017-01-20 14:00:53 +0100159 when others => FDI_Per_Port'
Nico Huber3c544ee2016-11-20 04:56:58 +0100160 (others => False));
Nico Huber83693c82016-10-08 22:17:55 +0200161
162 type FDI_Lanes_Per_Port is array (GPU_Port) of DP_Lane_Count;
163 FDI_Lane_Count : constant FDI_Lanes_Per_Port :=
164 (DIGI_D => DP_Lane_Count_2,
165 others =>
166 (if CPU in Ironlake .. Ivybridge then
167 DP_Lane_Count_4
168 else
169 DP_Lane_Count_2));
170
171 FDI_Training : constant FDI_Training_Type :=
172 (case CPU is
173 when Ironlake => Simple_Training,
174 when Sandybridge => Full_Training,
175 when others => Auto_Training);
176
Nico Huberf54d0962016-10-20 14:17:18 +0200177 ----------------------------------------------------------------------------
178
Nico Huber247adf32017-06-12 14:39:11 +0200179 Default_DDI_HDMI_Buffer_Translation : constant DDI_HDMI_Buf_Trans_Range :=
180 (case CPU is
Nico Huber730f17c2017-06-12 15:51:25 +0200181 when Haswell => 6,
182 when Broadwell => 7,
Nico Huber247adf32017-06-12 14:39:11 +0200183 when Broxton => 8,
Nico Huber18ff0c12017-06-12 15:41:31 +0200184 when Skylake => 8,
Nico Huber247adf32017-06-12 14:39:11 +0200185 when others => 0);
186
187 ----------------------------------------------------------------------------
188
Nico Huberabe3de22016-10-20 15:03:46 +0200189 Default_CDClk_Freq : constant Frequency_Type :=
190 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200191 when G45 => 320_000_000, -- unused
Nico Huberabe3de22016-10-20 15:03:46 +0200192 when Ironlake |
193 Haswell |
194 Broadwell => 450_000_000,
195 when Sandybridge |
196 Ivybridge => 400_000_000,
Nico Huber21da5742017-01-20 14:00:53 +0100197 when Broxton => 288_000_000,
Nico Huberabe3de22016-10-20 15:03:46 +0200198 when Skylake => 337_500_000);
199
Nico Huberf54d0962016-10-20 14:17:18 +0200200 Default_RawClk_Freq : constant Frequency_Type :=
201 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200202 when G45 => 100_000_000, -- unused, depends on FSB
Nico Huberf54d0962016-10-20 14:17:18 +0200203 when Ironlake |
204 Sandybridge |
205 Ivybridge => 125_000_000,
206 when Haswell |
Nico Huber67cf6d82018-06-09 18:48:11 +0200207 Broadwell => (if Is_ULT then 24_000_000 else 125_000_000),
Nico Huber21da5742017-01-20 14:00:53 +0100208 when Broxton => Frequency_Type'First, -- none needed
Nico Huberf54d0962016-10-20 14:17:18 +0200209 when Skylake => 24_000_000);
210
Arthur Heymansd1988d12018-03-28 16:27:57 +0200211 Raw_Clock : Frequency_Type := Default_RawClk_Freq
212 with Part_Of => GMA.Config_State;
213
Nico Huberdcd274b2016-11-03 20:15:39 +0100214 ----------------------------------------------------------------------------
215
216 -- Maximum source width with enabled scaler. This only accounts
217 -- for simple 1:1 pipe:scaler mappings.
218
Nico Huberc5c767a2018-06-03 01:09:04 +0200219 type Width_Per_Pipe is array (Pipe_Index) of Width_Type;
Nico Huberdcd274b2016-11-03 20:15:39 +0100220
221 Maximum_Scalable_Width : constant Width_Per_Pipe :=
222 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200223 when G45 => -- TODO: Is this true?
224 (Primary => 4096,
225 Secondary => 2048,
Nico Huberc5c767a2018-06-03 01:09:04 +0200226 Tertiary => Pos32'First),
Nico Huberdcd274b2016-11-03 20:15:39 +0100227 when Ironlake..Haswell =>
228 (Primary => 4096,
229 Secondary => 2048,
230 Tertiary => 2048),
231 when Broadwell..Skylake =>
232 (Primary => 4096,
233 Secondary => 4096,
234 Tertiary => 4096));
235
Nico Hubera02b2c62018-01-09 15:58:34 +0100236 -- Maximum X position of hardware cursors
237 Maximum_Cursor_X : constant := (case CPU is
238 when G45 .. Ivybridge => 4095,
239 when Haswell .. Skylake => 8191);
240
241 Maximum_Cursor_Y : constant := 4095;
242
Nico Huber74ec9622016-11-19 03:00:43 +0100243 ----------------------------------------------------------------------------
244
Nico Huber21da5742017-01-20 14:00:53 +0100245 -- FIXME: Unknown for Broxton, Linux' i915 contains a fixme too :-D
Nico Huber74ec9622016-11-19 03:00:43 +0100246 HDMI_Max_Clock_24bpp : constant Frequency_Type :=
247 (if CPU >= Haswell then 300_000_000 else 225_000_000);
248
Nico Huberb8ae6182017-07-15 20:03:56 +0200249 ----------------------------------------------------------------------------
250
251 GTT_Offset : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200252 when G45 .. Haswell => 16#0020_0000#,
Nico Huberb8ae6182017-07-15 20:03:56 +0200253 when Broadwell .. Skylake => 16#0080_0000#);
254
255 GTT_Size : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200256 when G45 .. Haswell => 16#0020_0000#,
Nico Huberb8ae6182017-07-15 20:03:56 +0200257 -- Limit Broadwell to 4MiB to have a stable
258 -- interface (i.e. same number of entries):
259 when Broadwell .. Skylake => 16#0040_0000#);
260
261 GTT_PTE_Size : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200262 when G45 .. Haswell => 4,
263 when Broadwell .. Skylake => 8);
Nico Huberb8ae6182017-07-15 20:03:56 +0200264
Nico Huberb03c8f12017-08-25 13:29:08 +0200265 Fence_Base : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200266 when G45 .. Ironlake => 16#0000_3000#,
Nico Huberb03c8f12017-08-25 13:29:08 +0200267 when Sandybridge .. Skylake => 16#0010_0000#);
268
269 Fence_Count : constant := (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200270 when G45 .. Sandybridge => 16,
Nico Huberb03c8f12017-08-25 13:29:08 +0200271 when Ivybridge .. Skylake => 32);
272
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200273 ----------------------------------------------------------------------------
274
275 use type HW.Word16;
276
277 function Is_Broadwell_H (Device_Id : Word16) return Boolean is
278 (Device_Id = 16#1612# or Device_Id = 16#1622# or Device_Id = 16#162a#);
279
280 function Is_Skylake_U (Device_Id : Word16) return Boolean is
281 (Device_Id = 16#1906# or Device_Id = 16#1916# or Device_Id = 16#1923# or
282 Device_Id = 16#1926# or Device_Id = 16#1927#);
283
284 -- Rather catch too much here than too little,
285 -- it's only used to distinguish generations.
286 function Is_GPU (Device_Id : Word16; CPU : CPU_Type; CPU_Var : CPU_Variant)
287 return Boolean is
288 (case CPU is
Arthur Heymans73ea0322018-03-28 17:17:07 +0200289 when G45 => (Device_Id and 16#ff02#) = 16#2e02# or
290 (Device_Id and 16#fffe#) = 16#2a42#,
Nico Hubere7ac6eb2017-09-04 23:54:13 +0200291 when Ironlake => (Device_Id and 16#fff3#) = 16#0042#,
292 when Sandybridge => (Device_Id and 16#ffc2#) = 16#0102#,
293 when Ivybridge => (Device_Id and 16#ffc3#) = 16#0142#,
294 when Haswell =>
295 (case CPU_Var is
296 when Normal => (Device_Id and 16#ffc3#) = 16#0402# or
297 (Device_Id and 16#ffc3#) = 16#0d02#,
298 when ULT => (Device_Id and 16#ffc3#) = 16#0a02#),
299 when Broadwell => ((Device_Id and 16#ffc3#) = 16#1602# or
300 (Device_Id and 16#ffcf#) = 16#160b# or
301 (Device_Id and 16#ffcf#) = 16#160d#) and
302 (case CPU_Var is
303 when Normal => Is_Broadwell_H (Device_Id),
304 when ULT => not Is_Broadwell_H (Device_Id)),
305 when Broxton => (Device_Id and 16#fffe#) = 16#5a84#,
306 when Skylake => ((Device_Id and 16#ffc3#) = 16#1902# or
307 (Device_Id and 16#ffcf#) = 16#190b# or
308 (Device_Id and 16#ffcf#) = 16#190d# or
309 (Device_Id and 16#fff9#) = 16#1921#) and
310 (case CPU_Var is
311 when Normal => not Is_Skylake_U (Device_Id),
312 when ULT => Is_Skylake_U (Device_Id)));
313
314 function Compatible_GPU (Device_Id : Word16) return Boolean is
315 (Is_GPU (Device_Id, CPU, CPU_Var));
316
Nico Huber83693c82016-10-08 22:17:55 +0200317end HW.GFX.GMA.Config;