Skip to content

Commit df1d63e

Browse files
teikhengtienfong
authored andcommitted
HSD #22016711608: ddr: altera: iossm: Read emif_ready signal before accessing IO96B CSR
Poll the system manager ecc_intstatus_derr and ecc_intstatus_serr for ddr0 and ddr1. The i_ckgena_lock and i_ckgenb_lock from each iossm will confirm IO96B is ready and that transactions can proceed Signed-off-by: Teik Heng Chong <[email protected]>
1 parent df8159c commit df1d63e

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

drivers/ddr/altera/iossm_mailbox.c

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,49 @@
11
// SPDX-License-Identifier: GPL-2.0
22
/*
3-
* Copyright (C) 2022 Intel Corporation <www.intel.com>
3+
* Copyright (C) 2022-2023 Intel Corporation <www.intel.com>
44
*
55
*/
66

77
#define DEBUG
88
#include <common.h>
99
#include <hang.h>
10+
#include <wait_bit.h>
1011
#include <asm/io.h>
1112
#include "iossm_mailbox.h"
12-
#include <wait_bit.h>
13+
14+
#define ECC_INTSTATUS_SERR SOCFPGA_SYSMGR_ADDRESS + 0x9C
15+
#define ECC_INISTATUS_DERR SOCFPGA_SYSMGR_ADDRESS + 0xA0
16+
#define DDR_CSR_CLKGEN_LOCKED_IO96B0_MASK BIT(16)
17+
#define DDR_CSR_CLKGEN_LOCKED_IO96B1_MASK BIT(17)
1318

1419
/* supported DDR type list */
1520
static const char *ddr_type_list[7] = {
1621
"DDR4", "DDR5", "DDR5_RDIMM", "LPDDR4", "LPDDR5", "QDRIV", "UNKNOWN"
1722
};
1823

24+
static int is_ddr_csr_clkgen_locked(u32 clkgen_mask)
25+
{
26+
int ret;
27+
28+
ret = wait_for_bit_le32((const void *)(ECC_INTSTATUS_SERR)
29+
, clkgen_mask, true, TIMEOUT, false);
30+
31+
if (ret) {
32+
debug("%s: ddr csr clkgena locked is timeout\n", __func__);
33+
return ret;
34+
}
35+
36+
ret = wait_for_bit_le32((const void *)(ECC_INISTATUS_DERR)
37+
, clkgen_mask, true, TIMEOUT, false);
38+
39+
if (ret) {
40+
debug("%s: ddr csr clkgenb locked is timeout\n", __func__);
41+
return ret;
42+
}
43+
44+
return 0;
45+
}
46+
1947
/* Mailbox request function
2048
* This function will send the request to IOSSM mailbox and wait for response return
2149
*
@@ -280,6 +308,11 @@ void init_mem_cal(struct io96b_info *io96b_ctrl)
280308
for (i = 0; i < io96b_ctrl->num_instance; i++) {
281309
switch (i) {
282310
case 0:
311+
ret = is_ddr_csr_clkgen_locked(DDR_CSR_CLKGEN_LOCKED_IO96B0_MASK);
312+
if (ret) {
313+
printf("%s: ckgena_lock iossm IO96B_0 is not locked\n", __func__);
314+
hang();
315+
}
283316
ret = io96b_cal_status(io96b_ctrl->io96b_0.io96b_csr_addr);
284317
if (ret) {
285318
io96b_ctrl->io96b_0.cal_status = false;
@@ -292,6 +325,11 @@ void init_mem_cal(struct io96b_info *io96b_ctrl)
292325
count++;
293326
break;
294327
case 1:
328+
ret = is_ddr_csr_clkgen_locked(DDR_CSR_CLKGEN_LOCKED_IO96B1_MASK);
329+
if (ret) {
330+
printf("%s: ckgena_lock iossm IO96B_1 is not locked\n", __func__);
331+
hang();
332+
}
295333
ret = io96b_cal_status(io96b_ctrl->io96b_1.io96b_csr_addr);
296334
if (ret) {
297335
io96b_ctrl->io96b_1.cal_status = false;

0 commit comments

Comments
 (0)