blob: 746f8c19d8a18e010874cbf1c879f0eb429d284e [file] [log] [blame]
Arthur Heymans73ea0322018-03-28 17:17:07 +02001--
2-- Copyright (C) 2015-2016 secunet Security Networks AG
3-- Copyright (C) 2016 Nico Huber <nico.h@gmx.de>
4--
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; either version 2 of the License, or
8-- (at your option) any later version.
9--
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.GMCH.LVDS is
23
24 LVDS_ENABLE : constant := 1 * 2 ** 31;
25 LVDS_DITHER_EN : constant := 1 * 2 ** 25;
26 LVDS_VSYNC_POLARITY_INVERT : constant := 1 * 2 ** 21;
27 LVDS_HSYNC_POLARITY_INVERT : constant := 1 * 2 ** 20;
28 LVDS_CLK_A_DATA_A0A2_POWER_MASK : constant := 3 * 2 ** 8;
29 LVDS_CLK_A_DATA_A0A2_POWER_DOWN : constant := 0 * 2 ** 8;
30 LVDS_CLK_A_DATA_A0A2_POWER_UP : constant := 3 * 2 ** 8;
31 LVDS_CLK_B_POWER_MASK : constant := 3 * 2 ** 4;
32 LVDS_CLK_B_POWER_DOWN : constant := 0 * 2 ** 4;
33 LVDS_CLK_B_POWER_UP : constant := 3 * 2 ** 4;
34 LVDS_DATA_B0B2_POWER_MASK : constant := 3 * 2 ** 2;
35 LVDS_DATA_B0B2_POWER_DOWN : constant := 0 * 2 ** 2;
36 LVDS_DATA_B0B2_POWER_UP : constant := 3 * 2 ** 2;
37
38 ----------------------------------------------------------------------------
39
40 procedure On (Port_Cfg : in Port_Config;
41 Pipe : in Pipe_Index)
42 is
43 Sync_Polarity : constant Word32 :=
44 (if Port_Cfg.Mode.H_Sync_Active_High then 0
45 else LVDS_HSYNC_POLARITY_INVERT) or
46 (if Port_Cfg.Mode.V_Sync_Active_High then 0
47 else LVDS_VSYNC_POLARITY_INVERT);
48
49 Two_Channel : constant Word32 :=
50 (if Port_Cfg.Mode.Dotclock >= Config.LVDS_Dual_Threshold then
51 LVDS_CLK_B_POWER_UP or LVDS_DATA_B0B2_POWER_UP else 0);
52 begin
53 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
54 pragma Debug (Port_Cfg.Mode.BPC /= 6, Debug.Put_Line
55 ("WARNING: Only 18bpp LVDS mode implemented."));
56
57 Registers.Write
58 (Register => Registers.GMCH_LVDS,
59 Value => LVDS_ENABLE or
60 GMCH_PORT_PIPE_SELECT(Pipe) or
61 Sync_Polarity or
62 LVDS_CLK_A_DATA_A0A2_POWER_UP or
63 Two_Channel or
64 LVDS_DITHER_EN);
65 end On;
66
67 ----------------------------------------------------------------------------
68
69 procedure Off
70 is
71 begin
72 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
73
74 Registers.Write
75 (Register => Registers.GMCH_LVDS,
76 Value => LVDS_CLK_A_DATA_A0A2_POWER_DOWN or
77 LVDS_CLK_B_POWER_DOWN or
78 LVDS_DATA_B0B2_POWER_DOWN);
79 end Off;
80
81end HW.GFX.GMA.GMCH.LVDS;