Skip to contentSkip to conversation

powerpc/8xxx: Fix LAW init to respect pre-initialized entries

PATCH Superseded Kumar Gala 2 participants 5 messages Feb 4, 2011 – Feb 10, 2011 Char and misc drivers

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 powerpc/8xxx: Fix LAW init to respect pre-initialized entries

If some pre-boot or earlier stage bootloader (NAND SPL) has setup LAW entries consider them good and mark them used.

In the NAND SPL case we skip re-initializing based on the law_table since the SPL phase already did that.

---
 drivers/misc/fsl_law.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/misc/fsl_law.c +20 -0
index 63c08bf..52b6666 100644
@@ -24,6 +24,7 @@
  */
 
 #include <common.h>
+#include <linux/compiler.h>
 #include <asm/fsl_law.h>
 #include <asm/io.h>
 
@@ -246,6 +247,25 @@ void init_laws(void)
 #error FSL_HW_NUM_LAWS can not be greater than 32 w/o code changes
 #endif
 
+	/* 
+	 * Any LAWs that where setup before we booted assume they are meant to
+	 * be around and mark them used.
+	 */
+	for (i = 0; i < FSL_HW_NUM_LAWS; i++) {
+		u32 lawar = in_be32(LAWAR_ADDR(i));
+		
+		if (lawar & LAW_EN)
+			gd->used_laws |= (1 << i);
+	}
+
+#ifndef CONFIG_NAND_SPL
+	/*
+	 * in NAND boot we've already parsed the law_table and setup those LAWs
+	 * so don't do it again.
+	 */
+	return;
+#endif
+
 	for (i = 0; i < num_law_entries; i++) {
 		if (law_table[i].index == -1)
 			set_next_law(law_table[i].addr, law_table[i].size,
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH 1/1 powerpc/8xxx: Fix LAW init to respect pre-initialized entries

Quoted 2 lines · Kumar Gala

+ ? ? ? ?* Any LAWs that where setup before we booted assume they are meant to
+ ? ? ? ?* be around and mark them used.

I think you mean "were set up". "setup" == noun, "set up" == verb.

Signature · 2 lines
Timur Tabi
Linux kernel developer at Freescale
author
#2 lore raw

PATCH v2 1/1 powerpc/8xxx: Fix LAW init to respect pre-initialized entries

In reply to Kumar Gala

If some pre-boot or earlier stage bootloader (NAND SPL) has setup LAW entries consider them good and mark them used.

In the NAND SPL case we skip re-initializing based on the law_table since the SPL phase already did that.

---
* Fixed wording in comment per Timur's feedback

 drivers/misc/fsl_law.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/misc/fsl_law.c +20 -0
index 63c08bf..8b37a2f 100644
@@ -24,6 +24,7 @@
  */
 
 #include <common.h>
+#include <linux/compiler.h>
 #include <asm/fsl_law.h>
 #include <asm/io.h>
 
@@ -246,6 +247,25 @@ void init_laws(void)
 #error FSL_HW_NUM_LAWS can not be greater than 32 w/o code changes
 #endif
 
+	/* 
+	 * Any LAWs that were set up before we booted assume they are meant to
+	 * be around and mark them used.
+	 */
+	for (i = 0; i < FSL_HW_NUM_LAWS; i++) {
+		u32 lawar = in_be32(LAWAR_ADDR(i));
+		
+		if (lawar & LAW_EN)
+			gd->used_laws |= (1 << i);
+	}
+
+#ifndef CONFIG_NAND_SPL
+	/*
+	 * in NAND boot we've already parsed the law_table and setup those LAWs
+	 * so don't do it again.
+	 */
+	return;
+#endif
+
 	for (i = 0; i < num_law_entries; i++) {
 		if (law_table[i].index == -1)
 			set_next_law(law_table[i].addr, law_table[i].size,
Signature · 1 line
1.7.2.3
author
#3 lore raw

PATCH v3 1/1 powerpc/8xxx: Fix LAW init to respect pre-initialized entries

In reply to Kumar Gala

If some pre-boot or earlier stage bootloader (NAND SPL) has setup LAW entries consider them good and mark them used.

In the NAND SPL case we skip re-initializing based on the law_table since the SPL phase already did that.

---
* Fix problem in non-NAND case we didn't set the law_table

 drivers/misc/fsl_law.c |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
drivers/misc/fsl_law.c +20 -0
index 63c08bf..e440d29 100644
@@ -24,6 +24,7 @@
  */
 
 #include <common.h>
+#include <linux/compiler.h>
 #include <asm/fsl_law.h>
 #include <asm/io.h>
 
@@ -246,6 +247,25 @@ void init_laws(void)
 #error FSL_HW_NUM_LAWS can not be greater than 32 w/o code changes
 #endif
 
+	/* 
+	 * Any LAWs that were set up before we booted assume they are meant to
+	 * be around and mark them used.
+	 */
+	for (i = 0; i < FSL_HW_NUM_LAWS; i++) {
+		u32 lawar = in_be32(LAWAR_ADDR(i));
+		
+		if (lawar & LAW_EN)
+			gd->used_laws |= (1 << i);
+	}
+
+#if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL)
+	/*
+	 * in NAND boot we've already parsed the law_table and setup those LAWs
+	 * so don't do it again.
+	 */
+	return;
+#endif
+
 	for (i = 0; i < num_law_entries; i++) {
 		if (law_table[i].index == -1)
 			set_next_law(law_table[i].addr, law_table[i].size,
Signature · 1 line
1.7.2.3
author Applied
#4 lore raw

PATCH v3 1/1 powerpc/8xxx: Fix LAW init to respect pre-initialized entries

Quoted 6 lines · Kumar Gala

If some pre-boot or earlier stage bootloader (NAND SPL) has setup LAW entries consider them good and mark them used.

In the NAND SPL case we skip re-initializing based on the law_table since the SPL phase already did that.

Quoted 6 lines

---
* Fix problem in non-NAND case we didn't set the law_table

drivers/misc/fsl_law.c | 20 ++++++++++++++++++++

1 files changed, 20 insertions(+), 0 deletions(-)

applied to 85xx next

- k