| 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 |
| 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 | |
| 15 | with HW.GFX.GMA.Config; |
| 16 | with HW.GFX.GMA.Registers; |
| 17 | |
| 18 | with HW.Debug; |
| 19 | with GNAT.Source_Info; |
| 20 | |
| 21 | package body HW.GFX.GMA.PCH.LVDS is |
| 22 | |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame^] | 23 | 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 35 | |
| 36 | ---------------------------------------------------------------------------- |
| 37 | |
| 38 | procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type) |
| 39 | is |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame^] | 40 | 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 46 | Two_Channel : constant Word32 := |
| 47 | (if Port_Cfg.Mode.Dotclock >= Config.LVDS_Dual_Threshold then |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame^] | 48 | 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] | 49 | begin |
| 50 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame^] | 51 | pragma Debug (Port_Cfg.Mode.BPC /= 6, Debug.Put_Line |
| 52 | ("WARNING: Only 18bpp LVDS mode implemented.")); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 53 | |
| Nico Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame^] | 54 | 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 61 | 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 Huber | be4eadd | 2016-10-13 21:39:28 +0200 | [diff] [blame^] | 70 | 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 75 | end Off; |
| 76 | |
| 77 | end HW.GFX.GMA.PCH.LVDS; |