blob: 9867b2f677b22d8305d2e55f7ac602068b8f958d [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
7-- the Free Software Foundation; version 2 of the License.
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
15with HW.GFX.GMA.Config;
16with HW.GFX.GMA.Registers;
17
18with HW.Debug;
19with GNAT.Source_Info;
20
21package body HW.GFX.GMA.PCH.LVDS is
22
Nico Huberbe4eadd2016-10-13 21:39:28 +020023 PCH_LVDS_ENABLE : constant := 1 * 2 ** 31;
24 PCH_LVDS_VSYNC_POLARITY_INVERT : constant := 1 * 2 ** 21;
25 PCH_LVDS_HSYNC_POLARITY_INVERT : constant := 1 * 2 ** 20;
26 PCH_LVDS_CLK_A_DATA_A0A2_POWER_MASK : constant := 3 * 2 ** 8;
27 PCH_LVDS_CLK_A_DATA_A0A2_POWER_DOWN : constant := 0 * 2 ** 8;
28 PCH_LVDS_CLK_A_DATA_A0A2_POWER_UP : constant := 3 * 2 ** 8;
29 PCH_LVDS_CLK_B_POWER_MASK : constant := 3 * 2 ** 4;
30 PCH_LVDS_CLK_B_POWER_DOWN : constant := 0 * 2 ** 4;
31 PCH_LVDS_CLK_B_POWER_UP : constant := 3 * 2 ** 4;
32 PCH_LVDS_DATA_B0B2_POWER_MASK : constant := 3 * 2 ** 2;
33 PCH_LVDS_DATA_B0B2_POWER_DOWN : constant := 0 * 2 ** 2;
34 PCH_LVDS_DATA_B0B2_POWER_UP : constant := 3 * 2 ** 2;
Nico Huber83693c82016-10-08 22:17:55 +020035
36 ----------------------------------------------------------------------------
37
38 procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type)
39 is
Nico Huberbe4eadd2016-10-13 21:39:28 +020040 Sync_Polarity : constant Word32 :=
41 (if Port_Cfg.Mode.H_Sync_Active_High then 0
42 else PCH_LVDS_HSYNC_POLARITY_INVERT) or
43 (if Port_Cfg.Mode.V_Sync_Active_High then 0
44 else PCH_LVDS_VSYNC_POLARITY_INVERT);
45
Nico Huber83693c82016-10-08 22:17:55 +020046 Two_Channel : constant Word32 :=
47 (if Port_Cfg.Mode.Dotclock >= Config.LVDS_Dual_Threshold then
Nico Huberbe4eadd2016-10-13 21:39:28 +020048 PCH_LVDS_CLK_B_POWER_UP or PCH_LVDS_DATA_B0B2_POWER_UP else 0);
Nico Huber83693c82016-10-08 22:17:55 +020049 begin
50 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
Nico Huberbe4eadd2016-10-13 21:39:28 +020051 pragma Debug (Port_Cfg.Mode.BPC /= 6, Debug.Put_Line
52 ("WARNING: Only 18bpp LVDS mode implemented."));
Nico Huber83693c82016-10-08 22:17:55 +020053
Nico Huberbe4eadd2016-10-13 21:39:28 +020054 Registers.Write
55 (Register => Registers.PCH_LVDS,
56 Value => PCH_LVDS_ENABLE or
57 PCH_TRANSCODER_SELECT (FDI_Port) or
58 Sync_Polarity or
59 PCH_LVDS_CLK_A_DATA_A0A2_POWER_UP or
60 Two_Channel);
Nico Huber83693c82016-10-08 22:17:55 +020061 end On;
62
63 ----------------------------------------------------------------------------
64
65 procedure Off
66 is
67 begin
68 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
69
Nico Huberbe4eadd2016-10-13 21:39:28 +020070 Registers.Write
71 (Register => Registers.PCH_LVDS,
72 Value => PCH_LVDS_CLK_A_DATA_A0A2_POWER_DOWN or
73 PCH_LVDS_CLK_B_POWER_DOWN or
74 PCH_LVDS_DATA_B0B2_POWER_DOWN);
Nico Huber83693c82016-10-08 22:17:55 +020075 end Off;
76
77end HW.GFX.GMA.PCH.LVDS;