Increase range of our main Frequency_Type

Increase `Frequency_Type` to 1MHz .. 2.5Ghz. We used to adapt it
whenever necessary, e.g. when a new generation supported higher
frequencies. But that got a little annoying. So let's choose a
broader range that will hopefully lower the noise for some time.

1MHz is low enough for VGA resolution at 24p, and 2.5GHz is high
enough for 8K at 60p. That should give us some margin.

Some corner cases required refactoring of some calculations and
proofs. And, admittedly, the calculation in `HW.GFX.GMA.PCH.VGA`
can in theory overflow. We prove absence of runtime errors by
deferring the potential overflow to the modular `Word32` type.
This is not perfect, but overflow or not, we have to expect to
be called with a sane frequency anyway.

Change-Id: I3a159bc11ccadcaba8ad04e126e6feadfd46008e
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/libgfxinit/+/35750
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
diff --git a/common/hw-gfx-dp_info.adb b/common/hw-gfx-dp_info.adb
index 7ac4556..d45826d 100644
--- a/common/hw-gfx-dp_info.adb
+++ b/common/hw-gfx-dp_info.adb
@@ -93,28 +93,11 @@
    with
       Depends => ((Link, Success) => (Link, Mode))
    is
-      function Link_Pixel_Per_Second
-        (Link_Rate : DP_Bandwidth)
-         return Positive
-      with
-         Post => Pos64 (Link_Pixel_Per_Second'Result) <=
-                  ((DP_Symbol_Rate_Type'Last * 8) / 3) / BPC_Type'First
-      is
-      begin
-         -- Link_Rate is brutto with 8/10 bit symbols; three colors
-         pragma Assert (Positive (DP_Symbol_Rate (Link_Rate)) <= (Positive'Last / 8) * 3);
-         pragma Assert ((Int64 (DP_Symbol_Rate (Link_Rate)) * 8) / 3
-                        >= Int64 (BPC_Type'Last));
-         return Positive
-           (((Int64 (DP_Symbol_Rate (Link_Rate)) * 8) / 3)
-            / Int64 (Mode.BPC));
-      end Link_Pixel_Per_Second;
-
-      Count : Natural;
+      Lane_Pixel_Per_Second : constant Pos64 :=
+        (((DP_Symbol_Rate (Link.Bandwidth) * 8) / 3) / Mode.BPC);
+      Count : constant Pos64 :=
+         Div_Round_Up (Mode.Dotclock, Lane_Pixel_Per_Second);
    begin
-      Count := Link_Pixel_Per_Second (Link.Bandwidth);
-      Count := (Positive (Mode.Dotclock) + Count - 1) / Count;
-
       Success := True;
       case Count is
          when 1      => Link.Lane_Count := DP_Lane_Count_1;
@@ -184,8 +167,8 @@
       DATA_N_MAX : constant := 16#800000#;
       LINK_N_MAX : constant := 16#100000#;
 
-      subtype Calc_M_Type is Int64 range 0 .. 2 ** 36;
-      subtype Calc_N_Type is Int64 range 0 .. 2 ** 36;
+      subtype Calc_M_Type is Int64 range 0 .. 2 ** 38;
+      subtype Calc_N_Type is Int64 range 0 .. 2 ** 38;
       subtype N_Rounded_Type is Int64 range
          0 .. Int64'Max (DATA_N_MAX, LINK_N_MAX);