Nico Huber would like Alexander Couzens to review this change.

View Change

gma: Split `Internal` port type into `eDP` & `LVDS`

We used to have a single type `Internal`, in the GMA interface, to
represent the port for any internal panel. This seemed suitable as
all mainboard targets used the additional panel logic (power se-
quencing, backlight) only with either one of the eDP and LVDS ports.

However, the hardware allows to combine the panel logic also with
other ports. And some of the regular DP ports are even mentioned as
alternatives to the dedicated eDP port.

As a first step towards supporting such less common combinations,
we get rid of the single `Internal` type. All the panel logic still
assumes that either the dedicated eDP or the LVDS port is used for
an internal display. We introduce `Internal_Port_Type` to represent
eDP and LVDS, for this. But it should vanish, once the panel logic
is adapted.

Change-Id: Iadf3c11bd35d085cf47a961e800b0d96b79f62f5
Signed-off-by: Nico Huber <nico.huber@secunet.com>
---
M common/broxton/hw-gfx-gma-power_and_clocks.adb
M common/g45/hw-gfx-gma-port_detect.adb
M common/haswell_shared/hw-gfx-gma-port_detect.adb
M common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb
M common/hw-gfx-gma-config.ads.template
M common/hw-gfx-gma-config_helpers.adb
M common/hw-gfx-gma-display_probing.adb
M common/hw-gfx-gma-display_probing.ads
M common/hw-gfx-gma.adb
M common/hw-gfx-gma.ads
M common/ironlake/hw-gfx-gma-port_detect.adb
M common/ironlake/hw-gfx-gma-power_and_clocks_ironlake.adb
M common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
13 files changed, 78 insertions(+), 77 deletions(-)

git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/39/38239/1
diff --git a/common/broxton/hw-gfx-gma-power_and_clocks.adb b/common/broxton/hw-gfx-gma-power_and_clocks.adb
index fe10208..07f0cc7 100644
--- a/common/broxton/hw-gfx-gma-power_and_clocks.adb
+++ b/common/broxton/hw-gfx-gma-power_and_clocks.adb
@@ -157,9 +157,9 @@
is
begin
return (case PD is
- when DDI_A => Configs (Primary).Port = Internal or
- Configs (Secondary).Port = Internal or
- Configs (Tertiary).Port = Internal,
+ when DDI_A => Configs (Primary).Port = eDP or
+ Configs (Secondary).Port = eDP or
+ Configs (Tertiary).Port = eDP,
when DDI_BC => Configs (Primary).Port = HDMI1 or
Configs (Primary).Port = DP1 or
Configs (Secondary).Port = HDMI1 or
@@ -173,7 +173,7 @@
Configs (Tertiary).Port = HDMI2 or
Configs (Tertiary).Port = DP2,
when PW2 => (Configs (Primary).Port /= Disabled and
- Configs (Primary).Port /= Internal) or
+ Configs (Primary).Port /= eDP) or
Configs (Secondary).Port /= Disabled or
Configs (Tertiary).Port /= Disabled);
end Need_PD;
diff --git a/common/g45/hw-gfx-gma-port_detect.adb b/common/g45/hw-gfx-gma-port_detect.adb
index 479b626..45ed2dd 100644
--- a/common/g45/hw-gfx-gma-port_detect.adb
+++ b/common/g45/hw-gfx-gma-port_detect.adb
@@ -74,7 +74,7 @@

begin
Config.Valid_Port (Analog) := True;
- Config.Valid_Port (Internal) := Config.Internal_Is_LVDS;
+ Config.Valid_Port (LVDS) := Config.GMCH_GM45;
for HDMI_Port in GMCH_HDMI_Port loop
Registers.Is_Set_Mask
(Register => GMCH_HDMI (HDMI_Port),
diff --git a/common/haswell_shared/hw-gfx-gma-port_detect.adb b/common/haswell_shared/hw-gfx-gma-port_detect.adb
index 50c14cd..09136ff 100644
--- a/common/haswell_shared/hw-gfx-gma-port_detect.adb
+++ b/common/haswell_shared/hw-gfx-gma-port_detect.adb
@@ -87,41 +87,37 @@
Config.Valid_Port (Analog) := not (DDI_A_X4 or DAC_Disabled);
end if;

- if Config.Internal_Is_EDP then
- -- DDI_A
- if Config.Has_Presence_Straps then
- Registers.Is_Set_Mask
- (Register => Registers.DDI_BUF_CTL_A,
- Mask => DDI_PORT_DETECTED (DIGI_A),
- Result => Internal_Detected);
- else
- Internal_Detected := True; -- XXX: Linux' i915 contains a fixme.
- end if;
- if Internal_Detected then
- if Config.Has_HOTPLUG_CTL then
- Registers.Set_Mask
- (Register => Registers.HOTPLUG_CTL,
- Mask => HOTPLUG_CTL_DDI_A_HPD_INPUT_ENABLE or
- HOTPLUG_CTL_DDI_A_HPD_STATUS); -- clear status
- if Config.Has_SHOTPLUG_CTL_A then
- -- Have to enable south hotplug too on SoCs.
- Registers.Unset_And_Set_Mask
- (Register => Registers.SHOTPLUG_CTL,
- Mask_Unset => SHOTPLUG_CTL_DETECT_MASK,
- Mask_Set => SHOTPLUG_CTL_HPD_INPUT_ENABLE (DIGI_A));
- end if;
- else
+ -- DDI_A
+ if Config.Has_Presence_Straps then
+ Registers.Is_Set_Mask
+ (Register => Registers.DDI_BUF_CTL_A,
+ Mask => DDI_PORT_DETECTED (DIGI_A),
+ Result => Internal_Detected);
+ else
+ Internal_Detected := True; -- XXX: Linux' i915 contains a fixme.
+ end if;
+ if Internal_Detected then
+ if Config.Has_HOTPLUG_CTL then
+ Registers.Set_Mask
+ (Register => Registers.HOTPLUG_CTL,
+ Mask => HOTPLUG_CTL_DDI_A_HPD_INPUT_ENABLE or
+ HOTPLUG_CTL_DDI_A_HPD_STATUS); -- clear status
+ if Config.Has_SHOTPLUG_CTL_A then
+ -- Have to enable south hotplug too on SoCs.
Registers.Unset_And_Set_Mask
(Register => Registers.SHOTPLUG_CTL,
Mask_Unset => SHOTPLUG_CTL_DETECT_MASK,
- Mask_Set => SHOTPLUG_CTL_HPD_INPUT_ENABLE (DIGI_A) or
- SHOTPLUG_CTL_HPD_STATUS (DIGI_A)); -- clear
+ Mask_Set => SHOTPLUG_CTL_HPD_INPUT_ENABLE (DIGI_A));
end if;
+ else
+ Registers.Unset_And_Set_Mask
+ (Register => Registers.SHOTPLUG_CTL,
+ Mask_Unset => SHOTPLUG_CTL_DETECT_MASK,
+ Mask_Set => SHOTPLUG_CTL_HPD_INPUT_ENABLE (DIGI_A) or
+ SHOTPLUG_CTL_HPD_STATUS (DIGI_A)); -- clear
end if;
- else
- Internal_Detected := False;
end if;
- Config.Valid_Port (Internal) := Internal_Detected;
+ Config.Valid_Port (eDP) := Internal_Detected;

-- DDI_[BCD]
for Port in Ext_Digital_Port range
diff --git a/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb b/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb
index 44d9acd..252074e 100644
--- a/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb
+++ b/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb
@@ -203,9 +203,9 @@
begin
return
(Config.Use_PDW_For_EDP_Scaling and then
- (Primary.Port = Internal and Requires_Scaling (Primary)))
+ (Primary.Port = eDP and Requires_Scaling (Primary)))
or
- (Primary.Port /= Disabled and Primary.Port /= Internal)
+ (Primary.Port /= Disabled and Primary.Port /= eDP)
or
Checked_Configs (Secondary).Port /= Disabled
or
diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index 0e49943..db03a07 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -146,8 +146,6 @@
Have_HDMI_Buf_Override : constant Boolean := DDI_HDMI_Buffer_Translation >= 0;
Default_MMIO_Base_Set : constant Boolean := Default_MMIO_Base /= 0;

- Has_Internal_Display : constant Boolean := Internal_Display /= None;
- Internal_Is_LVDS : constant Boolean := Internal_Display = LVDS;
Internal_Is_EDP : constant Boolean := Internal_Display = DP;
Have_DVI_I : constant Boolean := Analog_I2C_Port /= PCH_DAC;

@@ -265,7 +263,8 @@
type FDI_Per_Port is array (Port_Type) of Boolean;
Is_FDI_Port : <hswvar> FDI_Per_Port :=
(Disabled => False,
- Internal => Gen_Ironlake and Internal_Is_LVDS,
+ eDP => False,
+ LVDS => Gen_Ironlake,
DP1 .. HDMI3 => Gen_Ironlake,
Analog => Has_PCH_DAC);

diff --git a/common/hw-gfx-gma-config_helpers.adb b/common/hw-gfx-gma-config_helpers.adb
index ede140c..07fa087 100644
--- a/common/hw-gfx-gma-config_helpers.adb
+++ b/common/hw-gfx-gma-config_helpers.adb
@@ -32,13 +32,14 @@
(case Config.Gen is
when G45 => -- everything on GMCH
(case Port is
- when Internal => LVDS,
+ when LVDS => LVDS,
+ when eDP => DIGI_A, -- n/a, actually
when HDMI1 | DP1 => DIGI_B,
when HDMI2 | DP2 => DIGI_C,
when HDMI3 | DP3 => DIGI_D,
when Analog => VGA),
when Ironlake => -- everything but eDP through FDI/PCH
- (if Config.Internal_Is_EDP and then Port = Internal then
+ (if Port = eDP then
DIGI_A
else
(case Pipe is -- FDIs are fixed to the CPU pipe
@@ -47,7 +48,8 @@
when Tertiary => DIGI_D)),
when others => -- everything but VGA directly on CPU
(case Port is
- when Internal => DIGI_A, -- LVDS not available
+ when LVDS => LVDS, -- n/a, actually
+ when eDP => DIGI_A,
when HDMI1 | DP1 => DIGI_B,
when HDMI2 | DP2 => DIGI_C,
when HDMI3 | DP3 => DIGI_D,
@@ -59,7 +61,8 @@
begin
return
(case Port is
- when Internal => PCH_LVDS, -- will be ignored if Internal is DP
+ when LVDS => PCH_LVDS,
+ when eDP => PCH_LVDS, -- n/a, actually
when Analog => PCH_DAC,
when HDMI1 => PCH_HDMI_B,
when HDMI2 => PCH_HDMI_C,
@@ -74,7 +77,8 @@
begin
return Display_Type'
(case Port is
- when Internal => Config.Internal_Display,
+ when LVDS => LVDS,
+ when eDP => DP,
when Analog => VGA,
when HDMI1 .. HDMI3 => HDMI,
when DP1 .. DP3 => DP);
diff --git a/common/hw-gfx-gma-display_probing.adb b/common/hw-gfx-gma-display_probing.adb
index 0d7cd37..df88492 100644
--- a/common/hw-gfx-gma-display_probing.adb
+++ b/common/hw-gfx-gma-display_probing.adb
@@ -76,7 +76,7 @@
declare
DP_Port : constant GMA.DP_Port :=
(case Port is
- when Internal => DP_A,
+ when eDP => DP_A,
when DP1 => DP_B,
when DP2 => DP_C,
when DP3 => DP_D,
@@ -118,7 +118,7 @@
Success := Config.Valid_Port (Port);

if Success then
- if Port = Internal then
+ if Port in Internal_Port_Type then
Panel.Wait_On;
end if;
Read_EDID (Raw_EDID, Port, Success);
@@ -176,7 +176,7 @@
-- Turn panel on early to probe other ports during the power on delay.
for Idx in Port_List_Range loop
exit when Ports (Idx) = Disabled;
- if Ports (Idx) = Internal then
+ if Ports (Idx) in Internal_Port_Type then
Panel.On (Wait => False);
Probe_Internal := True;
exit;
@@ -211,7 +211,9 @@
end if;

-- Turn panel power off if probing failed.
- if Probe_Internal and not Port_Configured (Configs, Internal) then
+ if Probe_Internal and not
+ (Port_Configured (Configs, eDP) or Port_Configured (Configs, LVDS))
+ then
Panel.Off;
end if;
end Scan_Ports;
diff --git a/common/hw-gfx-gma-display_probing.ads b/common/hw-gfx-gma-display_probing.ads
index 5e8abe4..5dcdbd4 100644
--- a/common/hw-gfx-gma-display_probing.ads
+++ b/common/hw-gfx-gma-display_probing.ads
@@ -17,10 +17,10 @@
package HW.GFX.GMA.Display_Probing
is

- type Port_List_Range is range 0 .. 7;
+ type Port_List_Range is range 0 .. 8;
type Port_List is array (Port_List_Range) of Port_Type;
All_Ports : constant Port_List :=
- (DP1, DP2, DP3, HDMI1, HDMI2, HDMI3, Analog, Internal);
+ (DP1, DP2, DP3, HDMI1, HDMI2, HDMI3, Analog, LVDS, eDP);

procedure Read_EDID
(Raw_EDID : out EDID.Raw_EDID_Data;
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 0fe360d..d0f296e 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -57,7 +57,8 @@
type Port_Name_Array is array (Port_Type) of Port_Name;
Port_Names : constant Port_Name_Array :=
(Disabled => "Disabled",
- Internal => "Internal",
+ LVDS => "LVDS ",
+ eDP => "eDP ",
DP1 => "DP1 ",
DP2 => "DP2 ",
DP3 => "DP3 ",
@@ -178,7 +179,7 @@
("Enabled port " & Port_Names (Pipe_Cfg.Port)));
else
Wait_For_HPD (Pipe_Cfg.Port) := True;
- if Pipe_Cfg.Port = Internal then
+ if Pipe_Cfg.Port in Internal_Port_Type then
Panel.Off;
end if;
end if;
@@ -236,7 +237,7 @@
Cur_Config.Mode /= New_Config.Mode
or else
(Config.Use_PDW_For_EDP_Scaling and then
- (Cur_Config.Port = Internal and
+ (Cur_Config.Port = eDP and
Requires_Scaling (Cur_Config) /= Requires_Scaling (New_Config)))
or else
(Config.Has_GMCH_PFIT_CONTROL and then
diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads
index bdc4704..fcd8804 100644
--- a/common/hw-gfx-gma.ads
+++ b/common/hw-gfx-gma.ads
@@ -51,7 +51,8 @@

type Port_Type is
(Disabled,
- Internal,
+ LVDS,
+ eDP,
DP1,
DP2,
DP3,
@@ -61,6 +62,7 @@
Analog);
subtype Active_Port_Type is Port_Type
range Port_Type'Succ (Disabled) .. Port_Type'Last;
+ subtype Internal_Port_Type is Port_Type range LVDS .. eDP;

type Cursor_Mode is (No_Cursor, ARGB_Cursor);
type Cursor_Size is (Cursor_64x64, Cursor_128x128, Cursor_256x256);
diff --git a/common/ironlake/hw-gfx-gma-port_detect.adb b/common/ironlake/hw-gfx-gma-port_detect.adb
index 5af2e84..7efadeb 100644
--- a/common/ironlake/hw-gfx-gma-port_detect.adb
+++ b/common/ironlake/hw-gfx-gma-port_detect.adb
@@ -55,7 +55,8 @@

procedure Initialize
is
- Internal_Detected,
+ LVDS_Detected,
+ eDP_Detected,
HDMI_Detected,
DP_Detected : Boolean;

@@ -71,23 +72,19 @@
begin
Config.Valid_Port (Analog) := True;

- case Config.Internal_Display is
- when LVDS =>
- -- PCH_LVDS
- Registers.Is_Set_Mask
- (Register => Registers.PCH_LVDS,
- Mask => PCH_LVDS_PORT_DETECTED,
- Result => Internal_Detected);
- when DP =>
- -- eDP
- Registers.Is_Set_Mask
- (Register => Registers.DP_CTL_A,
- Mask => DP_PORT_DETECTED,
- Result => Internal_Detected);
- when None =>
- Internal_Detected := False;
- end case;
- Config.Valid_Port (Internal) := Internal_Detected;
+ -- PCH_LVDS
+ Registers.Is_Set_Mask
+ (Register => Registers.PCH_LVDS,
+ Mask => PCH_LVDS_PORT_DETECTED,
+ Result => LVDS_Detected);
+ Config.Valid_Port (LVDS) := LVDS_Detected;
+
+ -- eDP
+ Registers.Is_Set_Mask
+ (Register => Registers.DP_CTL_A,
+ Mask => DP_PORT_DETECTED,
+ Result => eDP_Detected);
+ Config.Valid_Port (eDP) := eDP_Detected;

-- PCH_HDMI_[BCD], PCH_DP_[BCD] share hotplug registers
for PCH_Port in PCH_HDMI_Port loop
diff --git a/common/ironlake/hw-gfx-gma-power_and_clocks_ironlake.adb b/common/ironlake/hw-gfx-gma-power_and_clocks_ironlake.adb
index 42aabbd..9bc5544 100644
--- a/common/ironlake/hw-gfx-gma-power_and_clocks_ironlake.adb
+++ b/common/ironlake/hw-gfx-gma-power_and_clocks_ironlake.adb
@@ -42,7 +42,7 @@
PCH_DREF_CONTROL_120MHZ_SSC_MODULATION_EN);
Registers.Posting_Read (Registers.PCH_DREF_CONTROL);
Time.U_Delay (1);
- if Config.Internal_Is_EDP then -- TODO: check for presence
+ if Config.Valid_Port (eDP) then
-- always use spread spectrum clock for CPU output
Registers.Set_Mask
(Register => Registers.PCH_DREF_CONTROL,
diff --git a/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb b/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
index e8087ed..93d8d18 100644
--- a/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
+++ b/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
@@ -178,9 +178,9 @@
is
begin
return (case PD is
- when DDI_AE => Configs (Primary).Port = Internal or
- Configs (Secondary).Port = Internal or
- Configs (Tertiary).Port = Internal,
+ when DDI_AE => Configs (Primary).Port = eDP or
+ Configs (Secondary).Port = eDP or
+ Configs (Tertiary).Port = eDP,
when DDI_B => Configs (Primary).Port = HDMI1 or
Configs (Primary).Port = DP1 or
Configs (Secondary).Port = HDMI1 or
@@ -200,7 +200,7 @@
Configs (Tertiary).Port = HDMI3 or
Configs (Tertiary).Port = DP3,
when PW2 => (Configs (Primary).Port /= Disabled and
- Configs (Primary).Port /= Internal) or
+ Configs (Primary).Port /= eDP) or
Configs (Secondary).Port /= Disabled or
Configs (Tertiary).Port /= Disabled);
end Need_PD;

To view, visit change 38239. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: Iadf3c11bd35d085cf47a961e800b0d96b79f62f5
Gerrit-Change-Number: 38239
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h@gmx.de>
Gerrit-Reviewer: Alexander Couzens <lynxis@fe80.eu>
Gerrit-MessageType: newchange