Skip to contentSkip to conversation

Fix FSL DDR clock adjust calculation.

PATCH New Joakim Tjernlund 2 participants 7 messages Sep 2, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix FSL DDR clock adjust calculation.

T1040 RM specifies CLK_ADJUST as 5 bits starting at bit pos 9 in DDR_DDR_SDRAM_CLK_CNTL, update code to match.

---
 drivers/ddr/fsl/ctrl_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/fsl/ctrl_regs.c +1 -1
index 3919257..57077e1 100644
@@ -1756,7 +1756,7 @@ static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr,
 	clk_adjust = popts->clk_adjust;
 	ddr->ddr_sdram_clk_cntl = (0
 				   | ((ss_en & 0x1) << 31)
-				   | ((clk_adjust & 0xF) << 23)
+				   | ((clk_adjust & 0x1F) << 22)
 				   );
 	debug("FSLDDR: clk_cntl = 0x%08x\n", ddr->ddr_sdram_clk_cntl);
 }
Signature · 1 line
2.4.6
#1 lore raw

PATCH 1/1 Fix FSL DDR clock adjust calculation.

Quoted 14 lines · Joakim Tjernlund

T1040 RM specifies CLK_ADJUST as 5 bits starting at bit pos 9 in DDR_DDR_SDRAM_CLK_CNTL, update code to match.

---
 drivers/ddr/fsl/ctrl_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/fsl/ctrl_regs.c +0 -0
index 3919257..57077e1 100644

drivers/ddr/fsl/ctrl_regs.c static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr, · line 1762

Quoted 8 lines
drivers/ddr/fsl/ctrl_regs.c +1 -1
@@ -1756,7 +1756,7 @@ static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr,
 	clk_adjust = popts->clk_adjust;
 	ddr->ddr_sdram_clk_cntl = (0
 				   | ((ss_en & 0x1) << 31)
-				   | ((clk_adjust & 0xF) << 23)
+				   | ((clk_adjust & 0x1F) << 22)
 				   );
 	debug("FSLDDR: clk_cntl = 0x%08x\n", ddr->ddr_sdram_clk_cntl);
 }

NACK. This is logically correct but it needs to consider all DDR controllers. Older controllers don't have the same bits for this field. So far we don't have to use this this fine granularity on clock adjustment.

York

#2 lore raw

PATCH 1/1 Fix FSL DDR clock adjust calculation.

Quoted 20 lines · York Sun
Quoted 18 lines · Joakim Tjernlund

T1040 RM specifies CLK_ADJUST as 5 bits starting at bit pos 9 in DDR_DDR_SDRAM_CLK_CNTL, update code to match.

---
 drivers/ddr/fsl/ctrl_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/fsl/ctrl_regs.c +1 -1
index 3919257..57077e1 100644
@@ -1756,7 +1756,7 @@ static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr,
 	clk_adjust = popts->clk_adjust;
 	ddr->ddr_sdram_clk_cntl = (0
 				   | ((ss_en & 0x1) << 31)
-				   | ((clk_adjust & 0xF) << 23)
+				   | ((clk_adjust & 0x1F) << 22)
Quoted 8 lines

drivers/ddr/fsl/ctrl_regs.c static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr, · line 1762

Quoted 4 lines
drivers/ddr/fsl/ctrl_regs.c +0 -0
 				   );
 	debug("FSLDDR: clk_cntl = 0x%08x\n", ddr->ddr_sdram_clk_cntl);
 }

NACK. This is logically correct but it needs to consider all DDR controllers. Older controllers don't have the same bits for this field. So far we don't have to use this this fine granularity on clock adjustment.

I have no idea what older controllers do with these bits so I leave it to you to find out.

Anyhow, current code is broken as the programmed value is doubled(we see this on our board which cannot boot linux without this fix)

Jocke

#3 lore raw

PATCH 1/1 Fix FSL DDR clock adjust calculation.

Quoted 30 lines · Joakim Tjernlund
Quoted 20 lines · York Sun
Quoted 18 lines · Joakim Tjernlund

T1040 RM specifies CLK_ADJUST as 5 bits starting at bit pos 9 in DDR_DDR_SDRAM_CLK_CNTL, update code to match.

---
 drivers/ddr/fsl/ctrl_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/fsl/ctrl_regs.c +1 -1
index 3919257..57077e1 100644
@@ -1756,7 +1756,7 @@ static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr,
 	clk_adjust = popts->clk_adjust;
 	ddr->ddr_sdram_clk_cntl = (0
 				   | ((ss_en & 0x1) << 31)
-				   | ((clk_adjust & 0xF) << 23)
+				   | ((clk_adjust & 0x1F) << 22)
Quoted 8 lines

drivers/ddr/fsl/ctrl_regs.c static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr, · line 1762

Quoted 4 lines
drivers/ddr/fsl/ctrl_regs.c +0 -0
 				   );
 	debug("FSLDDR: clk_cntl = 0x%08x\n", ddr->ddr_sdram_clk_cntl);
 }

NACK. This is logically correct but it needs to consider all DDR controllers. Older controllers don't have the same bits for this field. So far we don't have to use this this fine granularity on clock adjustment.

Quoted 4 lines

I have no idea what older controllers do with these bits so I leave it to you to find out.

Anyhow, current code is broken as the programmed value is doubled(we see this on our board which cannot boot linux without this fix)

Jocke,

Can you refer to Freescale board? You may be using correct clk_adjust value on your board. But when you use this driver, you may have to adjust the value by shifting 1 bit. You will lose some values but we haven't found it difficult. This value is important but can also tolerate a wide range.

York

#4 lore raw

PATCH 1/1 Fix FSL DDR clock adjust calculation.

Quoted 32 lines · York Sun
Quoted 30 lines · Joakim Tjernlund
Quoted 28 lines · York Sun
Quoted 14 lines · Joakim Tjernlund

T1040 RM specifies CLK_ADJUST as 5 bits starting at bit pos 9 in DDR_DDR_SDRAM_CLK_CNTL, update code to match.

---
 drivers/ddr/fsl/ctrl_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/fsl/ctrl_regs.c +0 -0
index 3919257..57077e1 100644

drivers/ddr/fsl/ctrl_regs.c static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr, · line 1762

Quoted 8 lines
drivers/ddr/fsl/ctrl_regs.c +1 -1
@@ -1756,7 +1756,7 @@ static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr,
 	clk_adjust = popts->clk_adjust;
 	ddr->ddr_sdram_clk_cntl = (0
 				   | ((ss_en & 0x1) << 31)
-				   | ((clk_adjust & 0xF) << 23)
+				   | ((clk_adjust & 0x1F) << 22)
 				   );
 	debug("FSLDDR: clk_cntl = 0x%08x\n", ddr->ddr_sdram_clk_cntl);
 }

NACK. This is logically correct but it needs to consider all DDR controllers. Older controllers don't have the same bits for this field. So far we don't have to use this this fine granularity on clock adjustment.

Quoted 8 lines
Quoted 4 lines

I have no idea what older controllers do with these bits so I leave it to you to find out.

Anyhow, current code is broken as the programmed value is doubled(we see this on our board which cannot boot linux without this fix)

Jocke,

Can you refer to Freescale board? You may be using correct clk_adjust value on

Custom board based on T1042RDB

Quoted 3 lines

your board. But when you use this driver, you may have to adjust the value by shifting 1 bit. You will lose some values but we haven't found it difficult. This value is important but can also tolerate a wide range.

Sure, but how should anyone know that beforehand? The clk_adjust was calculated using Freescales CW tool and added to table with the write lvl data.

Are the values for the T104x boards already compensated like you suggest? Then they will (possibly) break when this bug is fixed.

Jocke

#5 lore raw

PATCH 1/1 Fix FSL DDR clock adjust calculation.

Quoted 47 lines · Joakim Tjernlund
Quoted 32 lines · York Sun
Quoted 30 lines · Joakim Tjernlund
Quoted 28 lines · York Sun
Quoted 14 lines · Joakim Tjernlund

T1040 RM specifies CLK_ADJUST as 5 bits starting at bit pos 9 in DDR_DDR_SDRAM_CLK_CNTL, update code to match.

---
 drivers/ddr/fsl/ctrl_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/fsl/ctrl_regs.c +0 -0
index 3919257..57077e1 100644

drivers/ddr/fsl/ctrl_regs.c static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr, · line 1762

Quoted 8 lines
drivers/ddr/fsl/ctrl_regs.c +1 -1
@@ -1756,7 +1756,7 @@ static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr,
 	clk_adjust = popts->clk_adjust;
 	ddr->ddr_sdram_clk_cntl = (0
 				   | ((ss_en & 0x1) << 31)
-				   | ((clk_adjust & 0xF) << 23)
+				   | ((clk_adjust & 0x1F) << 22)
 				   );
 	debug("FSLDDR: clk_cntl = 0x%08x\n", ddr->ddr_sdram_clk_cntl);
 }

NACK. This is logically correct but it needs to consider all DDR controllers. Older controllers don't have the same bits for this field. So far we don't have to use this this fine granularity on clock adjustment.

Quoted 8 lines
Quoted 4 lines

I have no idea what older controllers do with these bits so I leave it to you to find out.

Anyhow, current code is broken as the programmed value is doubled(we see this on our board which cannot boot linux without this fix)

Jocke,

Can you refer to Freescale board? You may be using correct clk_adjust value on

Custom board based on T1042RDB

Quoted 3 lines

your board. But when you use this driver, you may have to adjust the value by shifting 1 bit. You will lose some values but we haven't found it difficult. This value is important but can also tolerate a wide range.

Quoted 5 lines

Sure, but how should anyone know that beforehand? The clk_adjust was calculated using Freescales CW tool and added to table with the write lvl data.

Are the values for the T104x boards already compensated like you suggest? Then they will (possibly) break when this bug is fixed.

Jocke,

I understand the frustration for having tools disconnected.
The CW tool gives:file you a suggestion but you have to put it in u-boot differently. Freescale boards including T104x have correct values, for example board/freescale/t104xrdb/ddr.h.

I don't consider it a bug for backward compatibility.

York

#6 lore raw

PATCH 1/1 Fix FSL DDR clock adjust calculation.

Quoted 55 lines · York Sun
Quoted 47 lines · Joakim Tjernlund
Quoted 32 lines · York Sun
Quoted 30 lines · Joakim Tjernlund
Quoted 28 lines · York Sun
Quoted 14 lines · Joakim Tjernlund

T1040 RM specifies CLK_ADJUST as 5 bits starting at bit pos 9 in DDR_DDR_SDRAM_CLK_CNTL, update code to match.

---
 drivers/ddr/fsl/ctrl_regs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/ddr/fsl/ctrl_regs.c +0 -0
index 3919257..57077e1 100644

drivers/ddr/fsl/ctrl_regs.c static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr, · line 1762

Quoted 8 lines
drivers/ddr/fsl/ctrl_regs.c +1 -1
@@ -1756,7 +1756,7 @@ static void set_ddr_sdram_clk_cntl(fsl_ddr_cfg_regs_t *ddr,
 	clk_adjust = popts->clk_adjust;
 	ddr->ddr_sdram_clk_cntl = (0
 				   | ((ss_en & 0x1) << 31)
-				   | ((clk_adjust & 0xF) << 23)
+				   | ((clk_adjust & 0x1F) << 22)
 				   );
 	debug("FSLDDR: clk_cntl = 0x%08x\n", ddr->ddr_sdram_clk_cntl);
 }

NACK. This is logically correct but it needs to consider all DDR controllers. Older controllers don't have the same bits for this field. So far we don't have to use this this fine granularity on clock adjustment.

Quoted 8 lines
Quoted 4 lines

I have no idea what older controllers do with these bits so I leave it to you to find out.

Anyhow, current code is broken as the programmed value is doubled(we see this on our board which cannot boot linux without this fix)

Jocke,

Can you refer to Freescale board? You may be using correct clk_adjust value on

Custom board based on T1042RDB

Quoted 3 lines

your board. But when you use this driver, you may have to adjust the value by shifting 1 bit. You will lose some values but we haven't found it difficult. This value is important but can also tolerate a wide range.

Quoted 5 lines

Sure, but how should anyone know that beforehand? The clk_adjust was calculated using Freescales CW tool and added to table with the write lvl data.

Are the values for the T104x boards already compensated like you suggest? Then they will (possibly) break when this bug is fixed.

Quoted 6 lines

Jocke,

I understand the frustration for having tools disconnected.
The CW tool gives:file you a suggestion but you have to put it in u-boot differently. Freescale boards including T104x have correct values, for example board/freescale/t104xrdb/ddr.h.

How would anyone know that these values are real clk_adjust/2 ?

Quoted 2 lines

I don't consider it a bug for backward compatibility.

Of course this is a bug that many will keep falling into! Costing lots of time to find too.

Just fix it and adjust old boards by doubling their values instead as a minimum fix.

I will adjust our value with /2 know that I know this bug and that be done.

Jocke