soc/intel/common: Don't hardcode ramtop offset

The `ramtop` can be obtained from the `option.h`, so remove the
hardcoded value. Keep the check for the value being byte aligned.

Change-Id: I5327b5d4e78b715a85072e5d9a62cf8fd2ae92c0
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74511
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
Reviewed-by: Subrata Banik <subratabanik@google.com>
diff --git a/src/soc/intel/common/basecode/ramtop/ramtop.c b/src/soc/intel/common/basecode/ramtop/ramtop.c
index 568526f..bf85fa8 100644
--- a/src/soc/intel/common/basecode/ramtop/ramtop.c
+++ b/src/soc/intel/common/basecode/ramtop/ramtop.c
@@ -11,8 +11,6 @@
 
 #define RAMTOP_SIGNATURE   0x52544F50 /* 'RTOP' */
 
-#define RAMTOP_CMOS_OFFSET 0x64
-
 /*
  * Address of the ramtop byte in CMOS. Should be reserved
  * in mainboards' cmos.layout and not covered by checksum.
@@ -20,13 +18,18 @@
 
 #if CONFIG(USE_OPTION_TABLE)
 #include "option_table.h"
-#if CMOS_VSTART_ramtop != RAMTOP_CMOS_OFFSET * 8
-#error "CMOS start for RAMTOP_CMOS is not correct, check your cmos.layout"
-#endif
+
+#if CMOS_VSTART_ramtop % 8 != 0
+#error "The `ramtop` CMOS entry needs to be byte aligned, check your cmos.layout."
+#endif	// CMOS_VSTART_ramtop % 8 != 0
+
 #if CMOS_VLEN_ramtop != 12
 #error "CMOS length for RAMTOP_CMOS bytes are not correct, check your cmos.layout"
 #endif
-#endif
+
+#else
+#define CMOS_VSTART_ramtop 800
+#endif	// CONFIG(USE_OPTION_TABLE)
 
 struct ramtop_table {
 	uint32_t signature;
@@ -41,7 +44,7 @@
 	u16 csum;
 
 	for (p = (u8 *)ramtop, i = 0; i < sizeof(*ramtop); i++, p++)
-		*p = cmos_read(RAMTOP_CMOS_OFFSET + i);
+		*p = cmos_read((CMOS_VSTART_ramtop / 8) + i);
 
 	/* Verify signature */
 	if (ramtop->signature != RAMTOP_SIGNATURE) {
@@ -70,7 +73,7 @@
 		ramtop, offsetof(struct ramtop_table, checksum));
 
 	for (p = (u8 *)ramtop, i = 0; i < sizeof(*ramtop); i++, p++)
-		cmos_write(*p, RAMTOP_CMOS_OFFSET + i);
+		cmos_write(*p, (CMOS_VSTART_ramtop / 8) + i);
 }
 
 /* Update the RAMTOP if required based on the input top_of_ram address */