Nico Huber has submitted this change. ( https://review.coreboot.org/c/libgfxinit/+/35711 )
Change subject: gma: Give GM45 its own designation (separate from G45)
......................................................................
gma: Give GM45 its own designation (separate from G45)
While G45 and GM45 have mostly the same display engine (seem to
only differ in the available outputs), they are driven by very
different clock sources. To derive the corret CDClk in a later
commit, we'll have to distinguish between the two.
Change-Id: I99bbd0582a03a9e2806ef2ebf63e466ec40133b3
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/35711
Reviewed-by: Patrick Georgi <pgeorgi(a)google.com>
Reviewed-by: Arthur Heymans <arthur(a)aheymans.xyz>
Reviewed-by: Angel Pons <th3fanbus(a)gmail.com>
---
M common/Makefile.inc
M common/hw-gfx-gma-config.ads.template
M common/hw-gfx-gma.ads
M configs/g45
4 files changed, 11 insertions(+), 11 deletions(-)
Approvals:
Nico Huber: Verified
Patrick Georgi: Looks good to me, approved
Arthur Heymans: Looks good to me, approved
Angel Pons: Looks good to me, approved
diff --git a/common/Makefile.inc b/common/Makefile.inc
index 67b6c17..4cbdaaa 100644
--- a/common/Makefile.inc
+++ b/common/Makefile.inc
@@ -54,9 +54,10 @@
CONFIG_GFX_GMA_ANALOG_I2C_PORT := $(call strip_quotes,$(CONFIG_GFX_GMA_ANALOG_I2C_PORT))
_GEN_NONCONST := $(strip \
+ $(if $(filter G45,$(CONFIG_GFX_GMA_GENERATION)),g45, \
$(if $(filter Ironlake,$(CONFIG_GFX_GMA_GENERATION)),ilk, \
$(if $(filter Haswell,$(CONFIG_GFX_GMA_GENERATION)),hsw, \
- $(if $(filter Skylake,$(CONFIG_GFX_GMA_GENERATION)),skl))))
+ $(if $(filter Skylake,$(CONFIG_GFX_GMA_GENERATION)),skl)))))
# GNATprove (GPL 2017) doesn't realize when a boolean expression
# that depends both on static values and variables can be evalu-
# ated at compile time (e.g. `False and then Variable` is always
@@ -76,9 +77,9 @@
-e's/<<DEFAULT_MMIO_BASE>>/$(CONFIG_GFX_GMA_DEFAULT_MMIO)/' \
-e'/constant Gen_CPU\(_Var\)\?/d' \
-e's/<genbool>/constant Boolean/' \
- -e's/<\(\(ilk\|hsw\|skl\)\(...\)\?\)bool>/<\1var> Boolean/' \
+ -e's/<\(\(g45\|ilk\|hsw\|skl\)\(...\)\?\)bool>/<\1var> Boolean/' \
$(if $(_GEN_NONCONST),-e's/<\(...\)\?$(_GEN_NONCONST)\(...\)\?var>/<cpufunc>/') \
- -e's/<\(ilk\|hsw\|skl\)\(...\)\?var>/$(_GEN_CONST_TARGET)/' \
+ -e's/<\(g45\|ilk\|hsw\|skl\)\(...\)\?var>/$(_GEN_CONST_TARGET)/' \
-e's/\(.*: *<cpufunc>.*:=\) *\(.*\);/\1\n (\2);/' \
-e's/\([^ ]\+\) *: *<cpufunc> \+\([^ ]*\) *:=/function \1 return \2 is/' \
-e's/<cpunull>//' \
@@ -94,8 +95,8 @@
-e's/<<DEFAULT_MMIO_BASE>>/$(CONFIG_GFX_GMA_DEFAULT_MMIO)/' \
-e":s$$(printf '\n ')/,$$/{N;s/,\n.*Dyn_CPU\(_Var\)\?[^,)]*//;ts$$(printf '\n ')P;D;}" \
-e'/Dyn_CPU\(_Var\)\?/d' \
- -e's/<\(gen\|\(ilk\|hsw\|skl\)\(...\)\?\)bool>/constant Boolean/' \
- -e's/<\(\(ilk\|hsw\|skl\)\(...\)\?\)var>/constant/' \
+ -e's/<\(gen\|\(g45\|ilk\|hsw\|skl\)\(...\)\?\)bool>/constant Boolean/' \
+ -e's/<\(\(g45\|ilk\|hsw\|skl\)\(...\)\?\)var>/constant/' \
-e's/<cpunull>/ is null/' \
$< >$@
endif
diff --git a/common/hw-gfx-gma-config.ads.template b/common/hw-gfx-gma-config.ads.template
index 8711e54..1f6fea6 100644
--- a/common/hw-gfx-gma-config.ads.template
+++ b/common/hw-gfx-gma-config.ads.template
@@ -27,7 +27,7 @@
when Skylake => Skylake);
CPU_Last : constant CPU_Type :=
(case Gen is
- when G45 => G45,
+ when G45 => GM45,
when Ironlake => Ivybridge,
when Haswell => Broadwell,
when Broxton => Broxton,
@@ -407,8 +407,8 @@
function Is_GPU (Device_Id : Word16; CPU : CPU_Type; CPU_Var : CPU_Variant)
return Boolean is
(case CPU is
- when G45 => (Device_Id and 16#ff02#) = 16#2e02# or
- (Device_Id and 16#fffe#) = 16#2a42#,
+ when G45 => (Device_Id and 16#ff02#) = 16#2e02#,
+ when GM45 => (Device_Id and 16#fffe#) = 16#2a42#,
when Ironlake => (Device_Id and 16#fff3#) = 16#0042#,
when Sandybridge => (Device_Id and 16#ffc2#) = 16#0102#,
when Ivybridge => (Device_Id and 16#ffc3#) = 16#0142#,
diff --git a/common/hw-gfx-gma.ads b/common/hw-gfx-gma.ads
index f9444e8..353ec4b 100644
--- a/common/hw-gfx-gma.ads
+++ b/common/hw-gfx-gma.ads
@@ -37,6 +37,7 @@
type CPU_Type is
(G45,
+ GM45,
Ironlake,
Sandybridge,
Ivybridge,
diff --git a/configs/g45 b/configs/g45
index 9d2da64..44404b9 100644
--- a/configs/g45
+++ b/configs/g45
@@ -1,7 +1,5 @@
-CONFIG_GFX_GMA_DYN_CPU =
+CONFIG_GFX_GMA_DYN_CPU = y
CONFIG_GFX_GMA_GENERATION = G45
-CONFIG_GFX_GMA_CPU = G45
-CONFIG_GFX_GMA_CPU_VARIANT = Normal # N/A
CONFIG_GFX_GMA_INTERNAL_PORT = LVDS
CONFIG_GFX_GMA_ANALOG_I2C_PORT = PCH_DAC
CONFIG_GFX_GMA_DEFAULT_MMIO = 16\#e000_0000\#
--
To view, visit https://review.coreboot.org/c/libgfxinit/+/35711
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: I99bbd0582a03a9e2806ef2ebf63e466ec40133b3
Gerrit-Change-Number: 35711
Gerrit-PatchSet: 5
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: merged
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/libgfxinit/+/35711 )
Change subject: gma: Give GM45 its own designation (separate from G45)
......................................................................
Patch Set 4:
(1 comment)
https://review.coreboot.org/c/libgfxinit/+/35711/3//COMMIT_MSG
Commit Message:
https://review.coreboot.org/c/libgfxinit/+/35711/3//COMMIT_MSG@8
PS3, Line 8:
> See this change's topic on gerrit: cdclk
Done
--
To view, visit https://review.coreboot.org/c/libgfxinit/+/35711
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: I99bbd0582a03a9e2806ef2ebf63e466ec40133b3
Gerrit-Change-Number: 35711
Gerrit-PatchSet: 4
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Comment-Date: Fri, 04 Oct 2019 22:15:49 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Angel Pons <th3fanbus(a)gmail.com>
Comment-In-Reply-To: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: comment
Nico Huber has posted comments on this change. ( https://review.coreboot.org/c/libgfxinit/+/35711 )
Change subject: gma: Give GM45 its own designation (separate from G45)
......................................................................
Patch Set 4: Verified+1
--
To view, visit https://review.coreboot.org/c/libgfxinit/+/35711
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: I99bbd0582a03a9e2806ef2ebf63e466ec40133b3
Gerrit-Change-Number: 35711
Gerrit-PatchSet: 4
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Comment-Date: Fri, 04 Oct 2019 22:15:14 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
Hello Angel Pons, Arthur Heymans, Matt DeVillier, Thomas Heijligen, Patrick Georgi, Martin Roth,
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/libgfxinit/+/35711
to look at the new patch set (#4).
Change subject: gma: Give GM45 its own designation (separate from G45)
......................................................................
gma: Give GM45 its own designation (separate from G45)
While G45 and GM45 have mostly the same display engine (seem to
only differ in the available outputs), they are driven by very
different clock sources. To derive the corret CDClk in a later
commit, we'll have to distinguish between the two.
Change-Id: I99bbd0582a03a9e2806ef2ebf63e466ec40133b3
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M common/Makefile.inc
M common/hw-gfx-gma-config.ads.template
M common/hw-gfx-gma.ads
M configs/g45
4 files changed, 11 insertions(+), 11 deletions(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/11/35711/4
--
To view, visit https://review.coreboot.org/c/libgfxinit/+/35711
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: I99bbd0582a03a9e2806ef2ebf63e466ec40133b3
Gerrit-Change-Number: 35711
Gerrit-PatchSet: 4
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-MessageType: newpatchset
Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/libgfxinit/+/35528 )
Change subject: gma: Refactor Update_Outputs()
......................................................................
gma: Refactor Update_Outputs()
In Update_Outputs(), we used to have two steps, iterating over
all available pipes: We disabled all pipes whose mode changed
or that would be disabled otherwise. Then, we enabled all pipes
with new modes.
As checks for validity of the configurations were only done on
demand in the second step, that left us with no knowledge about
what configs would actually be tried. To make this information
available for future work, we add a validation in between the
existing two. That gives us:
1. Disable pipes
- whose mode changed
- that were disconneced
2. Validate all new configs
3. Enable/update pipes with new configs
This way, we can make global decisions between 2. and 3. based
on the new, _valid_ configurations.
The `Loop_Invariant` of 2. allows us to keep the validation
in mind, to satisfy pre-conditions of the various steps ahead.
Change-Id: I079ae8f85c821a272b5d095c1ef437ee804aa9ac
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M common/hw-gfx-gma-config_helpers.ads
M common/hw-gfx-gma.adb
2 files changed, 60 insertions(+), 50 deletions(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/28/35528/1
diff --git a/common/hw-gfx-gma-config_helpers.ads b/common/hw-gfx-gma-config_helpers.ads
index 023b3e5..a2aeb06 100644
--- a/common/hw-gfx-gma-config_helpers.ads
+++ b/common/hw-gfx-gma-config_helpers.ads
@@ -33,7 +33,12 @@
Pipe : in Pipe_Index;
Port : in Port_Type;
Mode : in Mode_Type;
- Success : out Boolean);
+ Success : out Boolean)
+ with
+ Post =>
+ (if Success then
+ Port_Cfg.Mode.H_Visible = Mode.H_Visible and
+ Port_Cfg.Mode.V_Visible = Mode.V_Visible);
----------------------------------------------------------------------------
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index de79fd3..462f5c4 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -96,10 +96,11 @@
Pipe_Cfg : in Pipe_Config;
Success : out Boolean)
with
- Pre => Pipe_Cfg.Port in Active_Port_Type
+ Pre =>
+ Pipe_Cfg.Port in Active_Port_Type and
+ Config_Helpers.Valid_FB (Pipe_Cfg.Framebuffer, Pipe_Cfg.Mode, Pipe)
is
Port_Cfg : Port_Config;
- Scaler_Available : Boolean;
begin
pragma Debug (Debug.New_Line);
pragma Debug (Debug.Put_Line
@@ -109,12 +110,6 @@
(Port_Cfg, Pipe, Pipe_Cfg.Port, Pipe_Cfg.Mode, Success);
if Success then
- Display_Controller.Scaler_Available (Scaler_Available, Pipe);
- Success := Config_Helpers.Valid_Config
- (Pipe_Cfg.Framebuffer, Port_Cfg.Mode, Pipe, Scaler_Available);
- end if;
-
- if Success then
Connector_Info.Preferred_Link_Setting (Port_Cfg, Success);
end if;
@@ -221,19 +216,9 @@
end if;
end Check_HPD;
- Power_Changed : Boolean := False;
- Old_Configs : Pipe_Configs;
-
- -- Only called when we actually tried to change something
- -- so we don't congest the log with unnecessary messages.
- procedure Update_Power
- is
- begin
- if not Power_Changed then
- Power_And_Clocks.Power_Up (Old_Configs, Configs);
- Power_Changed := True;
- end if;
- end Update_Power;
+ Update_Power : Boolean := False;
+ Old_Configs,
+ New_Configs : Pipe_Configs;
function Full_Update (Cur_Config, New_Config : Pipe_Config) return Boolean
is
@@ -253,13 +238,14 @@
end Full_Update;
begin
Old_Configs := Cur_Configs;
+ New_Configs := Configs;
-- disable all pipes that changed or had a hot-plug event
for Pipe in Pipe_Index loop
declare
Unplug_Detected : Boolean;
Cur_Config : Pipe_Config renames Cur_Configs (Pipe);
- New_Config : Pipe_Config renames Configs (Pipe);
+ New_Config : Pipe_Config renames New_Configs (Pipe);
begin
if Cur_Config.Port /= Disabled then
Check_HPD (Cur_Config.Port, Unplug_Detected);
@@ -267,35 +253,60 @@
if Full_Update (Cur_Config, New_Config) or Unplug_Detected then
Disable_Output (Pipe, Cur_Config);
Cur_Config.Port := Disabled;
- Update_Power;
+ Update_Power := True;
end if;
end if;
end;
end loop;
+ -- validate new configs, filter invalid configs and those waiting for HPD
+ for Pipe in Pipe_Index loop
+ declare
+ Success : Boolean := True;
+ Scaler_Available : Boolean;
+ Cur_Config : Pipe_Config renames Cur_Configs (Pipe);
+ New_Config : Pipe_Config renames New_Configs (Pipe);
+ begin
+ if New_Config.Port /= Disabled then
+ if Wait_For_HPD (New_Config.Port) then
+ Check_HPD (New_Config.Port, Success);
+ Wait_For_HPD (New_Config.Port) := not Success;
+ end if;
+
+ if Success then
+ Display_Controller.Scaler_Available (Scaler_Available, Pipe);
+ Success := Config_Helpers.Valid_Config
+ (New_Config.Framebuffer, New_Config.Mode,
+ Pipe, Scaler_Available);
+ end if;
+
+ if not Success then
+ New_Config.Port := Disabled;
+ end if;
+ end if;
+ end;
+ pragma Loop_Invariant
+ (for all P in Pipe_Index'First .. Pipe =>
+ New_Configs (P).Port = Disabled or
+ Config_Helpers.Valid_FB
+ (New_Configs (P).Framebuffer, New_Configs (P).Mode, P));
+ end loop;
+
-- enable all pipes that changed and should be active
for Pipe in Pipe_Index loop
declare
Success : Boolean;
- Scaler_Available : Boolean;
Cur_Config : Pipe_Config renames Cur_Configs (Pipe);
- New_Config : Pipe_Config renames Configs (Pipe);
+ New_Config : Pipe_Config renames New_Configs (Pipe);
begin
+ -- full update
if New_Config.Port /= Disabled and
Full_Update (Cur_Config, New_Config)
then
- if Wait_For_HPD (New_Config.Port) then
- Check_HPD (New_Config.Port, Success);
- Wait_For_HPD (New_Config.Port) := not Success;
- else
- Success := True;
- end if;
+ Power_And_Clocks.Power_Up (Old_Configs, New_Configs);
+ Update_Power := True;
- if Success then
- Update_Power;
- Enable_Output (Pipe, New_Config, Success);
- end if;
-
+ Enable_Output (Pipe, New_Config, Success);
if Success then
Cur_Config := New_Config;
end if;
@@ -304,23 +315,17 @@
elsif New_Config.Port /= Disabled and
Cur_Config.Framebuffer /= New_Config.Framebuffer
then
- Display_Controller.Scaler_Available (Scaler_Available, Pipe);
- if Config_Helpers.Valid_Config
- (New_Config.Framebuffer, New_Config.Mode,
- Pipe, Scaler_Available)
- then
- Display_Controller.Setup_FB
- (Pipe, New_Config.Mode, New_Config.Framebuffer);
- Display_Controller.Update_Cursor
- (Pipe, New_Config.Framebuffer, New_Config.Cursor);
- Cur_Config := New_Config;
- end if;
+ Display_Controller.Setup_FB
+ (Pipe, New_Config.Mode, New_Config.Framebuffer);
+ Display_Controller.Update_Cursor
+ (Pipe, New_Config.Framebuffer, New_Config.Cursor);
+ Cur_Config := New_Config;
end if;
end;
end loop;
- if Power_Changed then
- Power_And_Clocks.Power_Down (Old_Configs, Configs, Cur_Configs);
+ if Update_Power then
+ Power_And_Clocks.Power_Down (Old_Configs, New_Configs, Cur_Configs);
end if;
end Update_Outputs;
--
To view, visit https://review.coreboot.org/c/libgfxinit/+/35528
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: I079ae8f85c821a272b5d095c1ef437ee804aa9ac
Gerrit-Change-Number: 35528
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: newchange
David Hendricks has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35734 )
Change subject: intel/fsp_broadwell_de: Rename from xx_DEV_FUNC
......................................................................
Patch Set 3:
(1 comment)
https://review.coreboot.org/c/coreboot/+/35734/1/src/soc/intel/fsp_broadwel…
File src/soc/intel/fsp_broadwell_de/include/soc/pci_devs.h:
https://review.coreboot.org/c/coreboot/+/35734/1/src/soc/intel/fsp_broadwel…
PS1, Line 53: #define PCH_DEVFN_VTD PCI_DEVFN(VTD_DEV, VTD_FUNC)
> VTD is directly located in the internal "Integrated I/O" block. […]
IIO sounds good to me as well.
--
To view, visit https://review.coreboot.org/c/coreboot/+/35734
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I1a8675a4e613a8efc135b05cde36f166acaa7ed4
Gerrit-Change-Number: 35734
Gerrit-PatchSet: 3
Gerrit-Owner: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Gerrit-Reviewer: David Hendricks <david.hendricks(a)gmail.com>
Gerrit-Reviewer: Frans Hendriks <fhendriks(a)eltan.com>
Gerrit-Reviewer: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: Philipp Deppenwiese <zaolin.daisuki(a)gmail.com>
Gerrit-Reviewer: Werner Zeh <werner.zeh(a)siemens.com>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-CC: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Comment-Date: Fri, 04 Oct 2019 22:01:13 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Werner Zeh <werner.zeh(a)siemens.com>
Comment-In-Reply-To: Kyösti Mälkki <kyosti.malkki(a)gmail.com>
Gerrit-MessageType: comment
Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/libgfxinit/+/35527 )
Change subject: gma config_helpers: Revise Validate_Config()
......................................................................
gma config_helpers: Revise Validate_Config()
Split it into Valid_FB() and Valid_Config() and make both expression
functions. This will make it easier to use them for proofs.
Change-Id: I0931217658000d3ff6d71515acb45aeb063768d5
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M common/hw-gfx-gma-config_helpers.adb
M common/hw-gfx-gma-config_helpers.ads
M common/hw-gfx-gma-pipe_setup.ads
M common/hw-gfx-gma.adb
4 files changed, 42 insertions(+), 58 deletions(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/27/35527/1
diff --git a/common/hw-gfx-gma-config_helpers.adb b/common/hw-gfx-gma-config_helpers.adb
index c95bebc..a86af9e 100644
--- a/common/hw-gfx-gma-config_helpers.adb
+++ b/common/hw-gfx-gma-config_helpers.adb
@@ -12,7 +12,6 @@
-- GNU General Public License for more details.
--
-with HW.GFX.GMA.Config;
with HW.GFX.GMA.Connector_Info;
with HW.GFX.GMA.DP_Info;
with HW.GFX.GMA.Registers;
@@ -182,40 +181,4 @@
end if;
end Fill_Port_Config;
- ----------------------------------------------------------------------------
-
- -- Validates that a given configuration should work with
- -- a given framebuffer.
- function Validate_Config
- (FB : Framebuffer_Type;
- Mode : Mode_Type;
- Pipe : Pipe_Index;
- Scaler_Available : Boolean)
- return Boolean
- is
- begin
- -- No downscaling
- -- Respect maximum scalable width
- -- VGA plane is only allowed on the primary pipe
- -- Only 32bpp RGB (ignored for VGA plane)
- -- Stride must be big enough and a multiple of 64 bytes or the tile size
- -- (ignored for VGA plane)
- -- Y-Tiling and rotation are only supported on newer generations (with
- -- Plane_Control)
- -- 90 degree rotations are only supported with Y-tiling
- return
- ((Rotated_Width (FB) = Mode.H_Visible and
- Rotated_Height (FB) = Mode.V_Visible) or
- (Scaler_Available and
- Rotated_Width (FB) <= Config.Maximum_Scalable_Width (Pipe) and
- Rotated_Width (FB) <= Mode.H_Visible and
- Rotated_Height (FB) <= Mode.V_Visible)) and
- (FB.Offset /= VGA_PLANE_FRAMEBUFFER_OFFSET or Pipe = Primary) and
- (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
- (FB.BPC = 8 and Valid_Stride (FB) and
- (Config.Has_Plane_Control or
- (FB.Tiling /= Y_Tiled and FB.Rotation = No_Rotation)) and
- (FB.Tiling = Y_Tiled or not Rotation_90 (FB))));
- end Validate_Config;
-
end HW.GFX.GMA.Config_Helpers;
diff --git a/common/hw-gfx-gma-config_helpers.ads b/common/hw-gfx-gma-config_helpers.ads
index d56be5e..023b3e5 100644
--- a/common/hw-gfx-gma-config_helpers.ads
+++ b/common/hw-gfx-gma-config_helpers.ads
@@ -14,6 +14,8 @@
with HW;
+with HW.GFX.GMA.Config;
+
private package HW.GFX.GMA.Config_Helpers
is
@@ -39,18 +41,44 @@
Reason => "Needed for older compiler versions");
use type HW.Pos32;
pragma Warnings (GNAT, On, """Integer_32"" is already use-visible *");
- function Validate_Config
+
+ -- Validate that a framebuffer is valid for a given mode and pipe.
+ function Valid_FB
+ (FB : Framebuffer_Type;
+ Mode : Mode_Type;
+ Pipe : Pipe_Index)
+ return Boolean is
+ (-- No downscaling
+ -- Respect maximum scalable width
+ -- VGA plane is only allowed on the primary pipe
+ -- Only 32bpp RGB (ignored for VGA plane)
+ -- Stride must be big enough and a multiple of 64 bytes or the tile size
+ -- (ignored for VGA plane)
+ -- Y-Tiling and rotation are only supported on newer generations (with
+ -- Plane_Control)
+ -- 90 degree rotations are only supported with Y-tiling
+ ((Rotated_Width (FB) = Mode.H_Visible and
+ Rotated_Height (FB) = Mode.V_Visible) or
+ (Rotated_Width (FB) <= Config.Maximum_Scalable_Width (Pipe) and
+ Rotated_Width (FB) <= Mode.H_Visible and
+ Rotated_Height (FB) <= Mode.V_Visible)) and
+ (FB.Offset /= VGA_PLANE_FRAMEBUFFER_OFFSET or Pipe = Primary) and
+ (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
+ (FB.BPC = 8 and Valid_Stride (FB) and
+ (Config.Has_Plane_Control or
+ (FB.Tiling /= Y_Tiled and FB.Rotation = No_Rotation)) and
+ (FB.Tiling = Y_Tiled or not Rotation_90 (FB)))));
+
+ -- Also validate that we only scale if a scaler is available.
+ function Valid_Config
(FB : Framebuffer_Type;
Mode : Mode_Type;
Pipe : Pipe_Index;
Scaler_Available : Boolean)
- return Boolean
- with
- Post =>
- (if Validate_Config'Result then
- Rotated_Width (FB) <= Mode.H_Visible and
- Rotated_Height (FB) <= Mode.V_Visible and
- (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
- FB.Height + FB.Start_Y <= FB.V_Stride));
+ return Boolean is
+ (Valid_FB (FB, Mode, Pipe) and
+ ((Rotated_Width (FB) = Mode.H_Visible and
+ Rotated_Height (FB) = Mode.V_Visible) or
+ Scaler_Available));
end HW.GFX.GMA.Config_Helpers;
diff --git a/common/hw-gfx-gma-pipe_setup.ads b/common/hw-gfx-gma-pipe_setup.ads
index 0edb0c9..990f306 100644
--- a/common/hw-gfx-gma-pipe_setup.ads
+++ b/common/hw-gfx-gma-pipe_setup.ads
@@ -13,6 +13,7 @@
--
with HW.GFX.GMA.Config;
+with HW.GFX.GMA.Config_Helpers;
with HW.GFX.GMA.Registers;
use type HW.Int32;
@@ -26,11 +27,7 @@
Framebuffer : Framebuffer_Type;
Cursor : Cursor_Type)
with
- Pre =>
- Rotated_Width (Framebuffer) <= Port_Cfg.Mode.H_Visible and
- Rotated_Height (Framebuffer) <= Port_Cfg.Mode.V_Visible and
- (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
- Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
+ Pre => Config_Helpers.Valid_FB (Framebuffer, Port_Cfg.Mode, Pipe);
procedure Off (Pipe : Pipe_Index);
@@ -43,11 +40,7 @@
Mode : Mode_Type;
Framebuffer : Framebuffer_Type)
with
- Pre =>
- Rotated_Width (Framebuffer) <= Mode.H_Visible and
- Rotated_Height (Framebuffer) <= Mode.V_Visible and
- (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
- Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
+ Pre => Config_Helpers.Valid_FB (Framebuffer, Mode, Pipe);
procedure Update_Cursor
(Pipe : Pipe_Index;
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 15d234a..de79fd3 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -110,7 +110,7 @@
if Success then
Display_Controller.Scaler_Available (Scaler_Available, Pipe);
- Success := Config_Helpers.Validate_Config
+ Success := Config_Helpers.Valid_Config
(Pipe_Cfg.Framebuffer, Port_Cfg.Mode, Pipe, Scaler_Available);
end if;
@@ -305,7 +305,7 @@
Cur_Config.Framebuffer /= New_Config.Framebuffer
then
Display_Controller.Scaler_Available (Scaler_Available, Pipe);
- if Config_Helpers.Validate_Config
+ if Config_Helpers.Valid_Config
(New_Config.Framebuffer, New_Config.Mode,
Pipe, Scaler_Available)
then
--
To view, visit https://review.coreboot.org/c/libgfxinit/+/35527
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: I0931217658000d3ff6d71515acb45aeb063768d5
Gerrit-Change-Number: 35527
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-MessageType: newchange
Hello Arthur Heymans, Matt DeVillier, Thomas Heijligen,
I'd like you to do a code review. Please visit
https://review.coreboot.org/c/libgfxinit/+/35710
to review the following change.
Change subject: gma pcode: Move and revise mailbox handling
......................................................................
gma pcode: Move and revise mailbox handling
Unify the PCODE mailbox implementations (Linux' i915 uses the same
implementation since Sandy Bridge, too) and add `Wait` and `Success`
parameters so we can act correctly if something failed. This adds
a lot of boilerplate. But we keep it contained in the new package
`PCode` and the code outside it looks cleaner and handles errors
more gracefully.
In GNATprove, we track state of the mailbox' readiness in a ghost
variable `Mailbox_Ready`. This allows us to skip the initial wait
loop if we know that we already waited at the end of a previous
call. The first call to a mailbox procedure has to be made with
`Wait_Ready => True`.
Also, start to experiment with a `use` clause for the `Register`
package. It allows us to write a little more condensed code, with-
out sacrificing much (in this program we can expect that `Read`/
`Write` means register access?) So far it looks good?
Change-Id: I5daa3effb7ab774e4a35bd8794b0f67f57e4caa4
Signed-off-by: Nico Huber <nico.h(a)gmx.de>
---
M common/Makefile.inc
M common/broxton/hw-gfx-gma-power_and_clocks.adb
M common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.adb
M common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.ads
A common/hw-gfx-gma-pcode.adb
A common/hw-gfx-gma-pcode.ads
M common/hw-gfx-gma.adb
M common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
8 files changed, 234 insertions(+), 63 deletions(-)
git pull ssh://review.coreboot.org:29418/libgfxinit refs/changes/10/35710/1
diff --git a/common/Makefile.inc b/common/Makefile.inc
index 7c5403b..67b6c17 100644
--- a/common/Makefile.inc
+++ b/common/Makefile.inc
@@ -31,6 +31,8 @@
gfxinit-y += hw-gfx-gma-pch-vga.adb
gfxinit-y += hw-gfx-gma-pch-vga.ads
gfxinit-y += hw-gfx-gma-pch.ads
+gfxinit-y += hw-gfx-gma-pcode.adb
+gfxinit-y += hw-gfx-gma-pcode.ads
gfxinit-y += hw-gfx-gma-pipe_setup.adb
gfxinit-y += hw-gfx-gma-pipe_setup.ads
gfxinit-y += hw-gfx-gma-port_detect.ads
diff --git a/common/broxton/hw-gfx-gma-power_and_clocks.adb b/common/broxton/hw-gfx-gma-power_and_clocks.adb
index f6576d9..77f6b35 100644
--- a/common/broxton/hw-gfx-gma-power_and_clocks.adb
+++ b/common/broxton/hw-gfx-gma-power_and_clocks.adb
@@ -17,6 +17,7 @@
with HW.Debug;
with HW.GFX.GMA.Config;
with HW.GFX.GMA.Registers;
+with HW.GFX.GMA.PCode;
with HW.GFX.GMA.Power_And_Clocks_Haswell;
with HW.GFX.GMA.DDI_Phy;
@@ -242,10 +243,19 @@
when others => CDCLK_CD2X_DIV_SEL_1); -- for CDClk = CDClk_Ref
CDCLK_CD2X_SSA_Precharge : constant Word32 :=
(if Freq >= 500_000_000 then CDCLK_CD2X_SSA_PRECHARGE_ENABLE else 0);
+
+ Success : Boolean;
begin
- Power_And_Clocks_Haswell.GT_Mailbox_Write
+ PCode.Mailbox_Write
(MBox => BXT_PCODE_CDCLK_CONTROL,
- Value => BXT_CDCLK_PREPARE_FOR_CHANGE);
+ Command => BXT_CDCLK_PREPARE_FOR_CHANGE,
+ Wait_Ready => True,
+ Success => Success);
+ if not Success then
+ pragma Debug (Debug.Put_Line
+ ("ERROR: PCODE didn't acknowledge frequency change."));
+ return;
+ end if;
Write
(Register => BXT_DE_PLL_ENABLE,
@@ -274,9 +284,9 @@
CDCLK_CD2X_SSA_Precharge or
CDCLK_CTL_CD_FREQ_DECIMAL (Freq));
- Power_And_Clocks_Haswell.GT_Mailbox_Write
- (MBox => BXT_PCODE_CDCLK_CONTROL,
- Value => Word32 ((Freq + (25_000_000 - 1)) / 25_000_000));
+ PCode.Mailbox_Write
+ (MBox => BXT_PCODE_CDCLK_CONTROL,
+ Command => Word64 ((Freq + (25_000_000 - 1)) / 25_000_000));
end Set_CDClk;
----------------------------------------------------------------------------
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 1c23254..332c3df 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
@@ -17,6 +17,7 @@
with HW.Time;
with HW.Debug;
with HW.GFX.GMA.Config;
+with HW.GFX.GMA.PCode;
with HW.GFX.GMA.Registers;
package body HW.GFX.GMA.Power_And_Clocks_Haswell is
@@ -55,8 +56,6 @@
IPS_CTL_ENABLE : constant := 1 * 2 ** 31;
DISPLAY_IPS_CONTROL : constant := 16#19#;
- GT_MAILBOX_READY : constant := 1 * 2 ** 31;
-
----------------------------------------------------------------------------
procedure PSR_Off
@@ -88,18 +87,6 @@
----------------------------------------------------------------------------
- procedure GT_Mailbox_Write (MBox : Word32; Value : Word32) is
- begin
- pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
-
- Registers.Wait_Unset_Mask (Registers.GT_MAILBOX, GT_MAILBOX_READY);
- Registers.Write (Registers.GT_MAILBOX_DATA, Value);
- Registers.Write (Registers.GT_MAILBOX, GT_MAILBOX_READY or MBox);
-
- Registers.Wait_Unset_Mask (Registers.GT_MAILBOX, GT_MAILBOX_READY);
- Registers.Write (Registers.GT_MAILBOX_DATA, 0);
- end GT_Mailbox_Write;
-
procedure IPS_Off
is
Enabled : Boolean;
@@ -110,7 +97,7 @@
Registers.Is_Set_Mask (Registers.IPS_CTL, IPS_CTL_ENABLE, Enabled);
if Enabled then
if Config.Has_IPS_CTL_Mailbox then
- GT_Mailbox_Write (DISPLAY_IPS_CONTROL, 0);
+ PCode.Mailbox_Write (DISPLAY_IPS_CONTROL, 0, Wait_Ready => True);
Registers.Wait_Unset_Mask
(Register => Registers.IPS_CTL,
Mask => IPS_CTL_ENABLE,
diff --git a/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.ads b/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.ads
index 87f5d07..7c5a647 100644
--- a/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.ads
+++ b/common/haswell_shared/hw-gfx-gma-power_and_clocks_haswell.ads
@@ -15,7 +15,6 @@
private package HW.GFX.GMA.Power_And_Clocks_Haswell is
procedure PSR_Off;
- procedure GT_Mailbox_Write (MBox : Word32; Value : Word32);
procedure Pre_All_Off;
procedure Post_All_Off is null;
diff --git a/common/hw-gfx-gma-pcode.adb b/common/hw-gfx-gma-pcode.adb
new file mode 100644
index 0000000..dd0fc6e
--- /dev/null
+++ b/common/hw-gfx-gma-pcode.adb
@@ -0,0 +1,138 @@
+--
+-- Copyright (C) 2014-2016, 2019 secunet Security Networks AG
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+
+with GNAT.Source_Info;
+
+with HW.Debug;
+with HW.GFX.GMA.Registers;
+
+use HW.GFX.GMA.Registers;
+
+package body HW.GFX.GMA.PCode is
+
+ GT_MAILBOX_READY : constant := 1 * 2 ** 31;
+
+ -- Send a command and optionally wait for and return the reply.
+ procedure Mailbox_Write_Read
+ (MBox : in Word32;
+ Command : in Word64;
+ Reply : out Word64;
+ Wait_Ready : in Boolean := False;
+ Wait_Ack : in Boolean := True;
+ Success : out Boolean)
+ with
+ Pre => Mailbox_Ready or Wait_Ready,
+ Post => (if Wait_Ack and Success then Mailbox_Ready)
+ is
+ use type HW.Word64;
+
+ Data : Word32;
+ begin
+ pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
+
+ Reply := 0;
+ Success := True;
+
+ if Wait_Ready then
+ Wait_Unset_Mask (GT_MAILBOX, GT_MAILBOX_READY, Success => Success);
+ if not Success then
+ return;
+ end if;
+ end if;
+
+ Write (GT_MAILBOX_DATA, Word32 (Command and 16#ffff_ffff#));
+ Write (GT_MAILBOX_DATA_1, Word32 (Shift_Right (Command, 32)));
+ Write (GT_MAILBOX, GT_MAILBOX_READY or MBox);
+ Mailbox_Ready := False;
+
+ if Wait_Ack then
+ Wait_Unset_Mask (GT_MAILBOX, GT_MAILBOX_READY, Success => Success);
+ Mailbox_Ready := Success;
+
+ Read (GT_MAILBOX_DATA, Data);
+ Reply := Word64 (Data);
+ Read (GT_MAILBOX_DATA_1, Data);
+ Reply := Shift_Left (Word64 (Data), 32) or Reply;
+
+ Write (GT_MAILBOX_DATA, 0);
+ Write (GT_MAILBOX_DATA_1, 0);
+ end if;
+ end Mailbox_Write_Read;
+
+ procedure Mailbox_Write
+ (MBox : in Word32;
+ Command : in Word64;
+ Wait_Ready : in Boolean := False;
+ Wait_Ack : in Boolean := True;
+ Success : out Boolean)
+ is
+ pragma Warnings (GNATprove, Off, "unused assignment to ""Ignored_R""");
+ Ignored_R : Word64;
+ begin
+ Mailbox_Write_Read
+ (MBox, Command, Ignored_R, Wait_Ready, Wait_Ack, Success);
+ end Mailbox_Write;
+
+ procedure Mailbox_Request
+ (MBox : in Word32;
+ Command : in Word64;
+ Reply_Mask : in Word64;
+ Reply : in Word64 := 16#ffff_ffff_ffff_ffff#;
+ TOut_MS : in Natural := Registers.Default_Timeout_MS;
+ Wait_Ready : in Boolean := False;
+ Success : out Boolean)
+ is
+ use type HW.Word64;
+
+ Timeout : constant Time.T := Time.MS_From_Now (TOut_MS);
+ Timed_Out : Boolean := False;
+
+ Received_Reply : Word64;
+ begin
+ Success := False;
+ loop
+ pragma Loop_Invariant ((not Success and Wait_Ready) or Mailbox_Ready);
+ Mailbox_Write_Read
+ (MBox => MBox,
+ Command => Command,
+ Reply => Received_Reply,
+ Wait_Ready => not Success and Wait_Ready,
+ Success => Success);
+ exit when not Success;
+
+ if (Received_Reply and Reply_Mask) = (Reply and Reply_Mask) then
+ -- Ignore timeout if we succeeded anyway.
+ Timed_Out := False;
+ exit;
+ end if;
+ exit when Timed_Out;
+
+ Timed_Out := Time.Timed_Out (Timeout);
+ end loop;
+
+ Success := Success and then not Timed_Out;
+ end Mailbox_Request;
+
+ procedure Mailbox_Write
+ (MBox : Word32;
+ Command : Word64;
+ Wait_Ready : Boolean := False)
+ is
+ pragma Warnings (GNATprove, Off, "unused assignment to ""Ignored_S""");
+ Ignored_S : Boolean;
+ begin
+ Mailbox_Write (MBox, Command, Wait_Ready, False, Ignored_S);
+ end Mailbox_Write;
+
+end HW.GFX.GMA.PCode;
diff --git a/common/hw-gfx-gma-pcode.ads b/common/hw-gfx-gma-pcode.ads
new file mode 100644
index 0000000..ef2564a
--- /dev/null
+++ b/common/hw-gfx-gma-pcode.ads
@@ -0,0 +1,60 @@
+--
+-- Copyright (C) 2016, 2019 secunet Security Networks AG
+--
+-- This program is free software; you can redistribute it and/or modify
+-- it under the terms of the GNU General Public License as published by
+-- the Free Software Foundation; either version 2 of the License, or
+-- (at your option) any later version.
+--
+-- This program is distributed in the hope that it will be useful,
+-- but WITHOUT ANY WARRANTY; without even the implied warranty of
+-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+-- GNU General Public License for more details.
+--
+
+with HW.GFX.GMA.Registers;
+
+private package HW.GFX.GMA.PCode is
+
+ -- We have to ensure that previous usage of the mailbox finished
+ -- (Wait_Ready) or know that we already did so (Mailbox_Ready).
+ --
+ -- If we wait for the other side to acknowledge (Wait_Ack), we
+ -- know that it's ready (=> Mailbox_Ready).
+
+ -- XXX: Supposed to be a `Ghost` variable, but GNAT seems too broken?
+ Mailbox_Ready : Boolean with Part_Of => HW.GFX.GMA.State;
+
+ -- Just send a command, discard the reply.
+ procedure Mailbox_Write
+ (MBox : in Word32;
+ Command : in Word64;
+ Wait_Ready : in Boolean := False;
+ Wait_Ack : in Boolean := True;
+ Success : out Boolean)
+ with
+ Pre => Mailbox_Ready or Wait_Ready,
+ Post => (if Wait_Ack and Success then Mailbox_Ready);
+
+ -- Repeatedly send a request command the expected reply is received.
+ procedure Mailbox_Request
+ (MBox : in Word32;
+ Command : in Word64;
+ Reply_Mask : in Word64;
+ Reply : in Word64 := 16#ffff_ffff_ffff_ffff#;
+ TOut_MS : in Natural := Registers.Default_Timeout_MS;
+ Wait_Ready : in Boolean := False;
+ Success : out Boolean)
+ with
+ Pre => Mailbox_Ready or Wait_Ready,
+ Post => (if Success then Mailbox_Ready);
+
+ -- For final mailbox commands that don't have to wait.
+ procedure Mailbox_Write
+ (MBox : Word32;
+ Command : Word64;
+ Wait_Ready : Boolean := False)
+ with
+ Pre => Mailbox_Ready or Wait_Ready;
+
+end HW.GFX.GMA.PCode;
diff --git a/common/hw-gfx-gma.adb b/common/hw-gfx-gma.adb
index 15d234a..dbdee5c 100644
--- a/common/hw-gfx-gma.adb
+++ b/common/hw-gfx-gma.adb
@@ -21,6 +21,7 @@
with HW.GFX.GMA.Config;
with HW.GFX.GMA.Config_Helpers;
with HW.GFX.GMA.Registers;
+with HW.GFX.GMA.PCode;
with HW.GFX.GMA.Power_And_Clocks;
with HW.GFX.GMA.Panel;
with HW.GFX.GMA.PLLs;
@@ -39,6 +40,7 @@
(State =>
(Dev.Address_State,
Registers.Address_State,
+ PCode.Mailbox_Ready,
PLLs.State, Panel.Panel_State,
Cur_Configs, Allocated_PLLs,
HPD_Delay, Wait_For_HPD,
@@ -376,6 +378,7 @@
(Config.Variable,
Dev.Address_State,
Registers.Address_State,
+ PCode.Mailbox_Ready,
PLLs.State, Panel.Panel_State,
Cur_Configs, Allocated_PLLs,
HPD_Delay, Wait_For_HPD,
@@ -435,6 +438,7 @@
pragma Debug (Debug.Set_Register_Write_Delay (Write_Delay));
Linear_FB_Base := 0;
+ PCode.Mailbox_Ready := False;
Wait_For_HPD := HPD_Type'(others => False);
HPD_Delay := HPD_Delay_Type'(others => Now);
Allocated_PLLs := (others => PLLs.Invalid);
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 c6eb2cf..2ab7f21 100644
--- a/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
+++ b/common/skylake/hw-gfx-gma-power_and_clocks_skylake.adb
@@ -18,6 +18,7 @@
with HW.Debug;
with HW.GFX.GMA.Config;
with HW.GFX.GMA.Registers;
+with HW.GFX.GMA.PCode;
with HW.GFX.GMA.Power_And_Clocks_Haswell;
use type HW.Word64;
@@ -86,8 +87,6 @@
SKL_CDCLK_PREPARE_FOR_CHANGE : constant := 3;
SKL_CDCLK_READY_FOR_CHANGE : constant := 1;
- GT_MAILBOX_READY : constant := 1 * 2 ** 31;
-
function CDCLK_CTL_CD_FREQ_DECIMAL
(Freq : Pos16;
Plus_Half : Boolean)
@@ -98,22 +97,6 @@
----------------------------------------------------------------------------
- procedure GT_Mailbox_Write (MBox : Word32; Value : Word64) is
- begin
- pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
-
- Registers.Wait_Unset_Mask (Registers.GT_MAILBOX, GT_MAILBOX_READY);
- Registers.Write
- (Registers.GT_MAILBOX_DATA, Word32 (Value and 16#ffff_ffff#));
- Registers.Write
- (Registers.GT_MAILBOX_DATA_1, Word32 (Shift_Right (Value, 32)));
- Registers.Write (Registers.GT_MAILBOX, GT_MAILBOX_READY or MBox);
-
- Registers.Wait_Unset_Mask (Registers.GT_MAILBOX, GT_MAILBOX_READY);
- end GT_Mailbox_Write;
-
- ----------------------------------------------------------------------------
-
procedure PD_Off (PD : Power_Domain)
is
Ctl1, Ctl2, Ctl3, Ctl4 : Word32;
@@ -251,10 +234,7 @@
procedure Initialize
is
- CDClk_Change_Timeout : Time.T;
- Timed_Out : Boolean;
-
- MBox_Data0 : Word32;
+ Success : Boolean;
begin
Registers.Set_Mask
(Register => Registers.NDE_RSTWRN_OPT,
@@ -282,29 +262,20 @@
(Register => Registers.LCPLL1_CTL,
Mask => LCPLL1_CTL_PLL_LOCK);
- CDClk_Change_Timeout := Time.MS_From_Now (3);
- Timed_Out := False;
- loop
- GT_Mailbox_Write
- (MBox => SKL_PCODE_CDCLK_CONTROL,
- Value => SKL_CDCLK_PREPARE_FOR_CHANGE);
- Registers.Read (Registers.GT_MAILBOX_DATA, MBox_Data0);
- if (MBox_Data0 and SKL_CDCLK_READY_FOR_CHANGE) /= 0 then
- -- Ignore timeout if we succeeded anyway.
- Timed_Out := False;
- exit;
- end if;
- exit when Timed_Out;
+ PCode.Mailbox_Request
+ (MBox => SKL_PCODE_CDCLK_CONTROL,
+ Command => SKL_CDCLK_PREPARE_FOR_CHANGE,
+ Reply_Mask => SKL_CDCLK_READY_FOR_CHANGE,
+ Wait_Ready => True,
+ Success => Success);
- Timed_Out := Time.Timed_Out (CDClk_Change_Timeout);
- end loop;
- pragma Debug (Timed_Out, Debug.Put_Line
- ("ERROR: PCODE not ready for frequency change after 3ms."));
+ pragma Debug (not Success, Debug.Put_Line
+ ("ERROR: PCODE not ready for frequency change."));
- if not Timed_Out then
- GT_Mailbox_Write
+ if Success then
+ PCode.Mailbox_Write
(MBox => SKL_PCODE_CDCLK_CONTROL,
- Value => 16#0000_0000#); -- 0 - 337.5MHz
+ Command => 16#0000_0000#); -- 0 - 337.5MHz
-- 1 - 450.0MHz
-- 2 - 540.0MHz
-- 3 - 675.0MHz
--
To view, visit https://review.coreboot.org/c/libgfxinit/+/35710
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: libgfxinit
Gerrit-Branch: master
Gerrit-Change-Id: I5daa3effb7ab774e4a35bd8794b0f67f57e4caa4
Gerrit-Change-Number: 35710
Gerrit-PatchSet: 1
Gerrit-Owner: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Martin Roth <martinroth(a)google.com>
Gerrit-Reviewer: Matt DeVillier <matt.devillier(a)gmail.com>
Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de>
Gerrit-Reviewer: Patrick Georgi <pgeorgi(a)google.com>
Gerrit-Reviewer: Thomas Heijligen <src(a)posteo.de>
Gerrit-MessageType: newchange
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/35773 )
Change subject: nb/intel/nehalem: Don't run graphic init on S3 resume
......................................................................
Patch Set 8: Code-Review+2
--
To view, visit https://review.coreboot.org/c/coreboot/+/35773
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I36219e6d04db561d4f2ddb6e962166c598d5bc4f
Gerrit-Change-Number: 35773
Gerrit-PatchSet: 8
Gerrit-Owner: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Angel Pons <th3fanbus(a)gmail.com>
Gerrit-Reviewer: Arthur Heymans <arthur(a)aheymans.xyz>
Gerrit-Reviewer: Patrick Rudolph <siro(a)das-labor.org>
Gerrit-Reviewer: Paul Menzel <paulepanter(a)users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org>
Gerrit-Comment-Date: Fri, 04 Oct 2019 21:19:10 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment