blob: bd7ebeb1449d5aa673e1479dbe352b7226533e11 [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
2-- Copyright (C) 2015-2016 secunet Security Networks AG
Nico Huberbe4eadd2016-10-13 21:39:28 +02003-- Copyright (C) 2016 Nico Huber <nico.h@gmx.de>
Nico Huber83693c82016-10-08 22:17:55 +02004--
5-- This program is free software; you can redistribute it and/or modify
6-- it under the terms of the GNU General Public License as published by
Nico Huber125a29e2016-10-18 00:23:54 +02007-- the Free Software Foundation; either version 2 of the License, or
8-- (at your option) any later version.
Nico Huber83693c82016-10-08 22:17:55 +02009--
10-- This program is distributed in the hope that it will be useful,
11-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-- GNU General Public License for more details.
14--
15
16with HW.GFX.GMA.Config;
17with HW.GFX.GMA.Registers;
18
19with HW.Debug;
20with GNAT.Source_Info;
21
22package body HW.GFX.GMA.PCH.LVDS is
23
Nico Huberbe4eadd2016-10-13 21:39:28 +020024 PCH_LVDS_ENABLE : constant := 1 * 2 ** 31;
25 PCH_LVDS_VSYNC_POLARITY_INVERT : constant := 1 * 2 ** 21;
26 PCH_LVDS_HSYNC_POLARITY_INVERT : constant := 1 * 2 ** 20;
27 PCH_LVDS_CLK_A_DATA_A0A2_POWER_MASK : constant := 3 * 2 ** 8;
28 PCH_LVDS_CLK_A_DATA_A0A2_POWER_DOWN : constant := 0 * 2 ** 8;
29 PCH_LVDS_CLK_A_DATA_A0A2_POWER_UP : constant := 3 * 2 ** 8;
30 PCH_LVDS_CLK_B_POWER_MASK : constant := 3 * 2 ** 4;
31 PCH_LVDS_CLK_B_POWER_DOWN : constant := 0 * 2 ** 4;
32 PCH_LVDS_CLK_B_POWER_UP : constant := 3 * 2 ** 4;
33 PCH_LVDS_DATA_B0B2_POWER_MASK : constant := 3 * 2 ** 2;
34 PCH_LVDS_DATA_B0B2_POWER_DOWN : constant := 0 * 2 ** 2;
35 PCH_LVDS_DATA_B0B2_POWER_UP : constant := 3 * 2 ** 2;
Nico Huber83693c82016-10-08 22:17:55 +020036
37 ----------------------------------------------------------------------------
38
39 procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type)
40 is
Nico Huberbe4eadd2016-10-13 21:39:28 +020041 Sync_Polarity : constant Word32 :=
42 (if Port_Cfg.Mode.H_Sync_Active_High then 0
43 else PCH_LVDS_HSYNC_POLARITY_INVERT) or
44 (if Port_Cfg.Mode.V_Sync_Active_High then 0
45 else PCH_LVDS_VSYNC_POLARITY_INVERT);
46
Nico Huber83693c82016-10-08 22:17:55 +020047 Two_Channel : constant Word32 :=
48 (if Port_Cfg.Mode.Dotclock >= Config.LVDS_Dual_Threshold then
Nico Huberbe4eadd2016-10-13 21:39:28 +020049 PCH_LVDS_CLK_B_POWER_UP or PCH_LVDS_DATA_B0B2_POWER_UP else 0);
Nico Huber83693c82016-10-08 22:17:55 +020050 begin
51 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
Nico Huberbe4eadd2016-10-13 21:39:28 +020052 pragma Debug (Port_Cfg.Mode.BPC /= 6, Debug.Put_Line
53 ("WARNING: Only 18bpp LVDS mode implemented."));
Nico Huber83693c82016-10-08 22:17:55 +020054
Nico Huberbe4eadd2016-10-13 21:39:28 +020055 Registers.Write
56 (Register => Registers.PCH_LVDS,
57 Value => PCH_LVDS_ENABLE or
58 PCH_TRANSCODER_SELECT (FDI_Port) or
59 Sync_Polarity or
60 PCH_LVDS_CLK_A_DATA_A0A2_POWER_UP or
61 Two_Channel);
Nico Huber83693c82016-10-08 22:17:55 +020062 end On;
63
64 ----------------------------------------------------------------------------
65
66 procedure Off
67 is
68 begin
69 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
70
Nico Huberbe4eadd2016-10-13 21:39:28 +020071 Registers.Write
72 (Register => Registers.PCH_LVDS,
73 Value => PCH_LVDS_CLK_A_DATA_A0A2_POWER_DOWN or
74 PCH_LVDS_CLK_B_POWER_DOWN or
75 PCH_LVDS_DATA_B0B2_POWER_DOWN);
Nico Huber83693c82016-10-08 22:17:55 +020076 end Off;
77
78end HW.GFX.GMA.PCH.LVDS;