Skip to contentSkip to conversation

powerpc/mpc86xx: Fix BAT register setup

PATCH New Becky Bruce 2 participants 5 messages Oct 4, 2011 – Oct 7, 2011 PowerPC

lore
Share & tools
lore
#0 lore raw

cover powerpc/mpc86xx: Fix BAT register setup

This set of 2 patches fixes the BAT register setup on mpc86xx. Currently, we overwrite a BAT register while running out of it which is dangerous and can cause problems like the system going into the weeds.

The first patch cleans up the SRIO config information used for setup of the SRIO BAT registers - there were duplicate defines there. The second changes the method used for setting up BATs to disable translation while we do the setup.

We have tested this on mpc8641, and I believe it is safe for the other 86xx platforms like the sbc, but I'd appreciate input.

Cheers,
Becky

 arch/powerpc/cpu/mpc86xx/cpu_init.c |   28 --------
 arch/powerpc/cpu/mpc86xx/start.S    |   69 ++++++++++++++++++-
 include/configs/MPC8641HPCN.h       |  128 ++++++++++++++++++++---------------
 include/mpc86xx.h                   |    1 +
 4 files changed, 142 insertions(+), 84 deletions(-)
#1 lore raw

PATCH 1/2 powerpc/mpc8641hpcn: fix SRIO BAT config

There were duplicate (and conflicting) defines for the BATs used to cover SRIO. Drop the bogus set.

---
 include/configs/MPC8641HPCN.h |    5 -----
 1 files changed, 0 insertions(+), 5 deletions(-)
include/configs/MPC8641HPCN.h +0 -5
index 0ddb76f..cd8e32c 100644
@@ -515,11 +515,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);
 				 | BATU_VS | BATU_VP)
 #define CONFIG_SYS_IBAT2L	(BAT_PHYS_ADDR(CONFIG_SYS_SRIO1_MEM_PHYS) \
 				 | BATL_PP_RW | BATL_CACHEINHIBIT)
-
-#define CONFIG_SYS_DBAT2L	(CONFIG_SYS_SRIO1_MEM_PHYS | BATL_PP_RW \
-			| BATL_CACHEINHIBIT | BATL_GUARDEDSTORAGE)
-#define CONFIG_SYS_DBAT2U	(CONFIG_SYS_SRIO1_MEM_PHYS | BATU_BL_512M | BATU_VS | BATU_VP)
-#define CONFIG_SYS_IBAT2L	(CONFIG_SYS_SRIO1_MEM_PHYS | BATL_PP_RW | BATL_CACHEINHIBIT)
 #define CONFIG_SYS_IBAT2U	CONFIG_SYS_DBAT2U
 #endif
 
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 2/2 powerpc/mpc86xx: Disable translation for BAT setup

We really shouldn't be overwriting bat registers with translation enabled, especially when we're executing code using one of them for translating the current instruction stream. Instead, disable address translation while doing the final BAT setup.

In order to do this, setup_bats has to move back to asm code, because we require translation to be enabled to have a stack for C code. The yucky thing about that is that the assembler doesn't like ULL so we have to switch to using HIGH/LOW pairs for physical addresses that are > 32 bits in length.

---
 arch/powerpc/cpu/mpc86xx/cpu_init.c |   28 --------
 arch/powerpc/cpu/mpc86xx/start.S    |   69 +++++++++++++++++++-
 include/configs/MPC8641HPCN.h       |  123 +++++++++++++++++++++--------------
 include/mpc86xx.h                   |    1 +
 4 files changed, 142 insertions(+), 79 deletions(-)
arch/powerpc/cpu/mpc86xx/cpu_init.c +0 -28
index 8022024..0375df2 100644
@@ -35,7 +35,6 @@
 #include <asm/mp.h>
 
 extern void srio_init(void);
-void setup_bats(void);
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -91,33 +90,6 @@ int cpu_init_r(void)
 	return 0;
 }
 
-/* Set up BAT registers */
-void setup_bats(void)
-{
-#if defined(CONFIG_SYS_DBAT0U) && defined(CONFIG_SYS_DBAT0L)
-	write_bat(DBAT0, CONFIG_SYS_DBAT0U, CONFIG_SYS_DBAT0L);
-#endif
-#if defined(CONFIG_SYS_IBAT0U) && defined(CONFIG_SYS_IBAT0L)
-	write_bat(IBAT0, CONFIG_SYS_IBAT0U, CONFIG_SYS_IBAT0L);
-#endif
-	write_bat(DBAT1, CONFIG_SYS_DBAT1U, CONFIG_SYS_DBAT1L);
-	write_bat(IBAT1, CONFIG_SYS_IBAT1U, CONFIG_SYS_IBAT1L);
-	write_bat(DBAT2, CONFIG_SYS_DBAT2U, CONFIG_SYS_DBAT2L);
-	write_bat(IBAT2, CONFIG_SYS_IBAT2U, CONFIG_SYS_IBAT2L);
-	write_bat(DBAT3, CONFIG_SYS_DBAT3U, CONFIG_SYS_DBAT3L);
-	write_bat(IBAT3, CONFIG_SYS_IBAT3U, CONFIG_SYS_IBAT3L);
-	write_bat(DBAT4, CONFIG_SYS_DBAT4U, CONFIG_SYS_DBAT4L);
-	write_bat(IBAT4, CONFIG_SYS_IBAT4U, CONFIG_SYS_IBAT4L);
-	write_bat(DBAT5, CONFIG_SYS_DBAT5U, CONFIG_SYS_DBAT5L);
-	write_bat(IBAT5, CONFIG_SYS_IBAT5U, CONFIG_SYS_IBAT5L);
-	write_bat(DBAT6, CONFIG_SYS_DBAT6U, CONFIG_SYS_DBAT6L);
-	write_bat(IBAT6, CONFIG_SYS_IBAT6U, CONFIG_SYS_IBAT6L);
-	write_bat(DBAT7, CONFIG_SYS_DBAT7U, CONFIG_SYS_DBAT7L);
-	write_bat(IBAT7, CONFIG_SYS_IBAT7U, CONFIG_SYS_IBAT7L);
-
-	return;
-}
-
 #ifdef CONFIG_ADDR_MAP
 /* Initialize address mapping array */
 void init_addr_map(void)
arch/powerpc/cpu/mpc86xx/start.S +68 -1

79 lines not on this page · raw message

include/configs/MPC8641HPCN.h +73 -50

251 lines not on this page · raw message

include/mpc86xx.h +1 -0
index eb85d60..31e83f2 100644
@@ -84,6 +84,7 @@ static __inline__ unsigned long get_l2cr (void)
 }
 
 void setup_ddr_bat(phys_addr_t dram_size);
+extern void setup_bats(void);
 
 #endif  /* _ASMLANGUAGE */
 #endif	/* __MPC86xx_H__ */
Signature · 1 line
1.5.6.5
Applied
#3 lore raw

PATCH 2/2 powerpc/mpc86xx: Disable translation for BAT setup

Quoted 11 lines · Becky Bruce

We really shouldn't be overwriting bat registers with translation enabled, especially when we're executing code using one of them for translating the current instruction stream. Instead, disable address translation while doing the final BAT setup.

In order to do this, setup_bats has to move back to asm code, because we require translation to be enabled to have a stack for C code. The yucky thing about that is that the assembler doesn't like ULL so we have to switch to using HIGH/LOW pairs for physical addresses that are > 32 bits in length.

Quoted 8 lines

---

arch/powerpc/cpu/mpc86xx/cpu_init.c |   28 --------
arch/powerpc/cpu/mpc86xx/start.S    |   69 +++++++++++++++++++-
include/configs/MPC8641HPCN.h       |  123 +++++++++++++++++++++--------------
include/mpc86xx.h                   |    1 +
4 files changed, 142 insertions(+), 79 deletions(-)

applied to 85xx

- k

Applied
#4 lore raw

PATCH 1/2 powerpc/mpc8641hpcn: fix SRIO BAT config

In reply to Becky Bruce
Quoted 7 lines · Becky Bruce

There were duplicate (and conflicting) defines for the BATs used to cover SRIO. Drop the bogus set.

---
include/configs/MPC8641HPCN.h | 5 -----

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

applied to 85xx

- k