@@ -30,6 +30,12 @@
#define SMMU_SID_SDM2HPS_PSI_BE 0
+#define SDM2HPS_PSI_BE_ADDR_BASE 0
+/* PSI BE 512MB address window */
+#define SDM2HPS_PSI_BE_WINDOW_SZ 0x20000000
+#define SDM2HPS_PSI_BE_ADDR_END \
+ (SDM2HPS_PSI_BE_ADDR_BASE + SDM2HPS_PSI_BE_WINDOW_SZ - 1)
+
void socfpga_init_smmu(void);
int is_smmu_bypass(void);
int is_smmu_stream_id_enabled(u32 stream_id);
@@ -9,6 +9,7 @@
#include <watchdog.h>
#include <asm/arch/mailbox_s10.h>
#include <asm/arch/smc_api.h>
+#include <asm/arch/smmu_s10.h>
#include <linux/delay.h>
#include <linux/intel-smc.h>
@@ -394,6 +395,18 @@ int intel_sdm_mb_load(Altera_desc *desc, const void *rbf_data, size_t rbf_size)
u32 resp_len = 2;
u32 resp_buf[2];
+ /*
+ * Don't start the FPGA reconfiguration if bitstream location exceed the
+ * PSI BE 512MB address window and SMMU is not setup for PSI BE address
+ * translation.
+ */
+ if (((u64)rbf_data + rbf_size) >= SDM2HPS_PSI_BE_ADDR_END &&
+ !is_smmu_stream_id_enabled(SMMU_SID_SDM2HPS_PSI_BE)) {
+ printf("Failed: Bitstream location must not exceed 0x%08x\n",
+ SDM2HPS_PSI_BE_ADDR_END);
+ return -EINVAL;
+ }
+
debug("Sending MBOX_RECONFIG...\n");
ret = mbox_send_cmd(MBOX_ID_UBOOT, MBOX_RECONFIG, MBOX_CMD_DIRECT, 0,
NULL, 0, &resp_len, resp_buf);