]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
drivers: ddr: altera: Check IOSSM mailbox compatibility
authorNaresh Kumar Ravulapalli <nareshkumar.ravulapalli@altera.com>
Fri, 8 Aug 2025 09:36:59 +0000 (02:36 -0700)
committerTien Fong Chee <tien.fong.chee@intel.com>
Tue, 30 Sep 2025 06:29:53 +0000 (14:29 +0800)
Compatibility check of IOSSM mailbox with U-Boot is performed
by verifying the mailbox specification version. If check fails,
appropriate error message is displayed.

Signed-off-by: Naresh Kumar Ravulapalli <nareshkumar.ravulapalli@altera.com>
Reviewed-by: Tien Fong Chee <tien.fong.chee@altera.com>
drivers/ddr/altera/iossm_mailbox.c

index 21f94959a040655f45067b011d0a5aae7c54de93..2a2f86a650e5d918072ebc9a36391654e32cc96e 100644 (file)
@@ -38,6 +38,8 @@
 #define IOSSM_STATUS_CMD_RESPONSE_ERROR(n)     FIELD_GET(IOSSM_STATUS_CMD_RESPONSE_ERROR_MASK, n)
 #define IOSSM_STATUS_GENERAL_ERROR_MASK                GENMASK(4, 1)
 #define IOSSM_STATUS_GENERAL_ERROR(n)          FIELD_GET(IOSSM_STATUS_GENERAL_ERROR_MASK, n)
+#define IOSSM_MAILBOX_SPEC_VERSION_MASK                GENMASK(2, 0)
+#define IOSSM_MAILBOX_SPEC_VERSION(n)          FIELD_GET(IOSSM_MAILBOX_SPEC_VERSION_MASK, n)
 
 /* Offset of Mailbox Read-only Registers  */
 #define IOSSM_MAILBOX_HEADER_OFFSET                    0x0
@@ -383,6 +385,23 @@ err:
        return ret;
 }
 
+static bool is_mailbox_spec_compatible(struct io96b_info *io96b_ctrl)
+{
+       u32 mailbox_header;
+       u8 mailbox_spec_ver;
+
+       mailbox_header = readl(io96b_ctrl->io96b[0].io96b_csr_addr +
+                               IOSSM_MAILBOX_HEADER_OFFSET);
+       mailbox_spec_ver = IOSSM_MAILBOX_SPEC_VERSION(mailbox_header);
+       printf("%s: IOSSM mailbox version: %d\n", __func__, mailbox_spec_ver);
+
+       /* for now there are two mailbox spec versions, 0 and 1; only version 1 is compatible */
+       if (!mailbox_spec_ver)
+               return false;
+
+       return true;
+}
+
 /*
  * Initial function to be called to set memory interface IP type and instance ID
  * IP type and instance ID need to be determined before sending mailbox command
@@ -392,6 +411,11 @@ void io96b_mb_init(struct io96b_info *io96b_ctrl)
        int i, j;
        u32 mem_intf_info_0, mem_intf_info_1;
 
+       if (!is_mailbox_spec_compatible(io96b_ctrl)) {
+               printf("DDR: Failed to get compatible mailbox version\n");
+               hang();
+       }
+
        debug("%s: num_instance %d\n", __func__, io96b_ctrl->num_instance);
 
        for (i = 0; i < io96b_ctrl->num_instance; i++) {