| Arthur Heymans | 73ea032 | 2018-03-28 17:17:07 +0200 | [diff] [blame^] | 1 | -- |
| 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 |
| 6 | -- the Free Software Foundation; either version 2 of the License, or |
| 7 | -- (at your option) any later version. |
| 8 | -- |
| 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 | |
| 15 | with HW.Time; |
| 16 | with HW.GFX.GMA.Config; |
| 17 | with HW.GFX.GMA.Registers; |
| 18 | |
| 19 | package body HW.GFX.GMA.Power_And_Clocks is |
| 20 | |
| 21 | FSB_FREQ_SEL_MASK : constant := 7 * 2 ** 0; |
| 22 | CLKCFG_FSB_400 : constant Frequency_Type := 100_000_000; |
| 23 | CLKCFG_FSB_533 : constant Frequency_Type := 133_333_333; |
| 24 | CLKCFG_FSB_667 : constant Frequency_Type := 166_666_666; |
| 25 | CLKCFG_FSB_800 : constant Frequency_Type := 200_000_000; |
| 26 | CLKCFG_FSB_1067 : constant Frequency_Type := 266_666_666; |
| 27 | CLKCFG_FSB_1333 : constant Frequency_Type := 333_333_333; |
| 28 | |
| 29 | -- The Raw Freq is 1/4 of the FSB freq |
| 30 | procedure Initialize |
| 31 | is |
| 32 | CLK_CFG : Word32; |
| 33 | type Freq_Sel is new Natural range 0 .. 7; |
| 34 | begin |
| 35 | Registers.Read |
| 36 | (Register => Registers.GMCH_CLKCFG, |
| 37 | Value => CLK_CFG); |
| 38 | case Freq_Sel (CLK_CFG and FSB_FREQ_SEL_MASK) is |
| 39 | when 0 => Config.Raw_Clock := CLKCFG_FSB_1067; |
| 40 | when 1 => Config.Raw_Clock := CLKCFG_FSB_533; |
| 41 | when 2 => Config.Raw_Clock := CLKCFG_FSB_800; |
| 42 | when 3 => Config.Raw_Clock := CLKCFG_FSB_667; |
| 43 | when 4 => Config.Raw_Clock := CLKCFG_FSB_1333; |
| 44 | when 5 => Config.Raw_Clock := CLKCFG_FSB_400; |
| 45 | when 6 => Config.Raw_Clock := CLKCFG_FSB_1067; |
| 46 | when 7 => Config.Raw_Clock := CLKCFG_FSB_1333; |
| 47 | end case; |
| 48 | end Initialize; |
| 49 | |
| 50 | end HW.GFX.GMA.Power_And_Clocks; |