blob: 6bd43e185bbc7da8644eb91441040b7436e41fae [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
35 procedure Initialize is
36 begin
37 -- ILK: enable non-spread spectrum clock, enable spread spectrum clock
38 Registers.Write
39 (Register => Registers.PCH_DREF_CONTROL,
40 Value => PCH_DREF_CONTROL_120MHZ_SSC_EN or
41 PCH_DREF_CONTROL_120MHZ_NONSSC_EN or
42 PCH_DREF_CONTROL_120MHZ_SSC_MODULATION_EN);
43 Registers.Posting_Read (Registers.PCH_DREF_CONTROL);
44 Time.U_Delay (1);
Nico Huber8beafd72020-01-07 14:59:44 +010045 if Config.Valid_Port (eDP) then
Nico Huber83693c82016-10-08 22:17:55 +020046 -- always use spread spectrum clock for CPU output
47 Registers.Set_Mask
48 (Register => Registers.PCH_DREF_CONTROL,
49 Mask => PCH_DREF_CONTROL_120MHZ_CPU_OUTPUT_SSC);
50 Registers.Posting_Read (Registers.PCH_DREF_CONTROL);
51 Time.U_Delay (20); -- DMI latency
52 end if;
Arthur Heymansd1988d12018-03-28 16:27:57 +020053
Nico Huber1eb5faa2019-09-29 00:35:55 +020054 Config.CDClk := Config.Default_CDClk_Freq;
55 Config.Max_CDClk := Config.Default_CDClk_Freq;
Arthur Heymansd1988d12018-03-28 16:27:57 +020056 Config.Raw_Clock := Config.Default_RawClk_Freq;
Nico Huber83693c82016-10-08 22:17:55 +020057 end Initialize;
58
Nico Huber1eb5faa2019-09-29 00:35:55 +020059 procedure Limit_Dotclocks
60 (Configs : in out Pipe_Configs;
61 CDClk_Switch : out Boolean)
62 is
63 begin
64 Config_Helpers.Limit_Dotclocks (Configs, Config.CDClk * 90 / 100);
65 CDClk_Switch := False;
66 end Limit_Dotclocks;
67
Angel Pons3318bf22020-07-19 18:38:32 +020068end HW.GFX.GMA.Power_And_Clocks;