| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 1 | -- |
| 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame] | 3 | -- Copyright (C) 2016 Nico Huber <nico.h@gmx.de> |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 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 |
| Nico Huber | 125a29e | 2016-10-18 00:23:54 +0200 | [diff] [blame^] | 7 | -- the Free Software Foundation; either version 2 of the License, or |
| 8 | -- (at your option) any later version. |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 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 | |
| 16 | with HW.GFX.GMA.Config; |
| 17 | with HW.GFX.GMA.Registers; |
| 18 | |
| 19 | with HW.Debug; |
| 20 | with GNAT.Source_Info; |
| 21 | |
| 22 | package body HW.GFX.GMA.PCH.LVDS is |
| 23 | |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame] | 24 | 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 36 | |
| 37 | ---------------------------------------------------------------------------- |
| 38 | |
| 39 | procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type) |
| 40 | is |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame] | 41 | 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 47 | Two_Channel : constant Word32 := |
| 48 | (if Port_Cfg.Mode.Dotclock >= Config.LVDS_Dual_Threshold then |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame] | 49 | PCH_LVDS_CLK_B_POWER_UP or PCH_LVDS_DATA_B0B2_POWER_UP else 0); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 50 | begin |
| 51 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame] | 52 | pragma Debug (Port_Cfg.Mode.BPC /= 6, Debug.Put_Line |
| 53 | ("WARNING: Only 18bpp LVDS mode implemented.")); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 54 | |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame] | 55 | 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 62 | 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 Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame] | 71 | 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 76 | end Off; |
| 77 | |
| 78 | end HW.GFX.GMA.PCH.LVDS; |