blob: f92379857f7a0f1d2b198d59e1c3842378228b70 [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
2-- Copyright (C) 2016 secunet Security Networks AG
3--
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
15with HW.Time;
16with HW.GFX.GMA.Config;
17with HW.GFX.GMA.Registers;
18
Angel Pons3318bf22020-07-19 18:38:32 +020019package body HW.GFX.GMA.Power_And_Clocks is
Nico Huber83693c82016-10-08 22:17:55 +020020
21 PCH_DREF_CONTROL_120MHZ_CPU_OUTPUT_MASK : constant := 3 * 2 ** 13;
22 PCH_DREF_CONTROL_120MHZ_CPU_OUTPUT_SSC : constant := 2 * 2 ** 13;
23 PCH_DREF_CONTROL_120MHZ_CPU_OUTPUT_NONSSC : constant := 3 * 2 ** 13;
24 PCH_DREF_CONTROL_120MHZ_SSC_EN_MASK : constant := 3 * 2 ** 11;
25 PCH_DREF_CONTROL_120MHZ_SSC_EN : constant := 2 * 2 ** 11;
26 PCH_DREF_CONTROL_120MHZ_NONSSC_EN_MASK : constant := 3 * 2 ** 9;
27 PCH_DREF_CONTROL_120MHZ_NONSSC_EN : constant := 2 * 2 ** 9;
28 PCH_DREF_CONTROL_120MHZ_SSC4_EN_MASK : constant := 3 * 2 ** 7;
29 PCH_DREF_CONTROL_120MHZ_SSC4_EN : constant := 2 * 2 ** 7;
30 PCH_DREF_CONTROL_120MHZ_SSC4_DOWNSPREAD : constant := 0 * 2 ** 6;
31 PCH_DREF_CONTROL_120MHZ_SSC4_CENTERSPREAD : constant := 1 * 2 ** 6;
32 PCH_DREF_CONTROL_120MHZ_SSC_MODULATION_EN : constant := 1 * 2 ** 1;
33 PCH_DREF_CONTROL_120MHZ_SSC4_MODULATION_EN : constant := 1 * 2 ** 0;
34
Matt DeVillier6d971af2026-07-06 11:04:54 -050035 -- Same as Port_Detect.Initialize (DP_CTL_A, bit 2).
36 DP_PORT_DETECTED : constant := 1 * 2 ** 2;
37
Nico Huber83693c82016-10-08 22:17:55 +020038 procedure Initialize is
Matt DeVillier6d971af2026-07-06 11:04:54 -050039 eDP_Detected : Boolean;
Nico Huber83693c82016-10-08 22:17:55 +020040 begin
41 -- ILK: enable non-spread spectrum clock, enable spread spectrum clock
42 Registers.Write
43 (Register => Registers.PCH_DREF_CONTROL,
44 Value => PCH_DREF_CONTROL_120MHZ_SSC_EN or
45 PCH_DREF_CONTROL_120MHZ_NONSSC_EN or
46 PCH_DREF_CONTROL_120MHZ_SSC_MODULATION_EN);
47 Registers.Posting_Read (Registers.PCH_DREF_CONTROL);
48 Time.U_Delay (1);
Matt DeVillier6d971af2026-07-06 11:04:54 -050049
50 Registers.Is_Set_Mask
51 (Register => Registers.DP_CTL_A,
52 Mask => DP_PORT_DETECTED,
53 Result => eDP_Detected);
54 if eDP_Detected then
Nico Huber83693c82016-10-08 22:17:55 +020055 -- always use spread spectrum clock for CPU output
56 Registers.Set_Mask
57 (Register => Registers.PCH_DREF_CONTROL,
58 Mask => PCH_DREF_CONTROL_120MHZ_CPU_OUTPUT_SSC);
59 Registers.Posting_Read (Registers.PCH_DREF_CONTROL);
60 Time.U_Delay (20); -- DMI latency
61 end if;
Arthur Heymansd1988d12018-03-28 16:27:57 +020062
Nico Huber1eb5faa2019-09-29 00:35:55 +020063 Config.CDClk := Config.Default_CDClk_Freq;
64 Config.Max_CDClk := Config.Default_CDClk_Freq;
Arthur Heymansd1988d12018-03-28 16:27:57 +020065 Config.Raw_Clock := Config.Default_RawClk_Freq;
Nico Huber83693c82016-10-08 22:17:55 +020066 end Initialize;
67
Nico Huber1eb5faa2019-09-29 00:35:55 +020068 procedure Limit_Dotclocks
69 (Configs : in out Pipe_Configs;
70 CDClk_Switch : out Boolean)
71 is
72 begin
73 Config_Helpers.Limit_Dotclocks (Configs, Config.CDClk * 90 / 100);
74 CDClk_Switch := False;
75 end Limit_Dotclocks;
76
Nico Huber41e86742024-07-17 17:10:28 +020077 procedure Power_Up (Port : Active_Port_Type; Success : out Boolean) is
78 begin
79 Success := True;
80 end Power_Up;
81
Angel Pons3318bf22020-07-19 18:38:32 +020082end HW.GFX.GMA.Power_And_Clocks;