gma: Set tiled framebuffers up through Plane_Control

On platforms with Plane_Control registers (Broxton/Skylake+) we can
use X and Y tiled framebuffers for scanout (older platforms support
X tiling only). As our main use case is 90° rotation with Y tiled
framebuffers, we implement it for the newer platforms only for now.

We also set up a fence register for linear access to the tiled frame-
buffer through the aperture.

Change-Id: I913c82f62fd28b681a06ce13f41160a07e559799
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/22709
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Tested-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
diff --git a/common/hw-gfx-gma-config_helpers.adb b/common/hw-gfx-gma-config_helpers.adb
index 0f60375..6eff5d2 100644
--- a/common/hw-gfx-gma-config_helpers.adb
+++ b/common/hw-gfx-gma-config_helpers.adb
@@ -186,16 +186,14 @@
       Pipe        : Pipe_Index)
       return Boolean
    is
-      function To_Bytes (Pixels : Width_Type) return Pos32 is
-      begin
-         return Pos32 (Pixels) * 4 * Pos32 (Framebuffer.BPC) / 8;
-      end To_Bytes;
    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 a multiple of 64 bytes (ignored for VGA plane)
+      -- Stride must be big enough and a multiple of 64 bytes or the tile size
+      -- (ignored for VGA plane)
+      -- Tiling is only supported on newer generations (with Plane_Control)
       return
          ((Framebuffer.Width = Pos32 (Port_Cfg.Mode.H_Visible) and
            Framebuffer.Height = Pos32 (Port_Cfg.Mode.V_Visible)) or
@@ -205,8 +203,8 @@
          (Framebuffer.Offset /= VGA_PLANE_FRAMEBUFFER_OFFSET or Pipe = Primary)
          and
          (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
-          (Framebuffer.BPC = 8 and
-           To_Bytes (Framebuffer.Stride) mod 64 = 0));
+          (Framebuffer.BPC = 8 and Valid_Stride (Framebuffer) and
+           (Config.Has_Plane_Control or Framebuffer.Tiling = Linear)));
    end Validate_Config;
 
 end HW.GFX.GMA.Config_Helpers;