85xx: Move LAW init code into C

Move the initialization of the LAWs into C code and provide an API
to allow modification of LAWs after init.

Board code is responsible to provide a law_table and num_law_entries.

We should be able to use the same code on 86xx as well.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
diff --git a/cpu/mpc85xx/spd_sdram.c b/cpu/mpc85xx/spd_sdram.c
index adc9c4d..bb5dc1f 100644
--- a/cpu/mpc85xx/spd_sdram.c
+++ b/cpu/mpc85xx/spd_sdram.c
@@ -27,6 +27,7 @@
 #include <i2c.h>
 #include <spd.h>
 #include <asm/mmu.h>
+#include <asm/fsl_law.h>
 
 
 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
@@ -1022,7 +1023,9 @@
 static unsigned int
 setup_laws_and_tlbs(unsigned int memsize)
 {
+#ifndef CONFIG_FSL_LAW
 	volatile ccsr_local_ecm_t *ecm = (void *)(CFG_MPC85xx_ECM_ADDR);
+#endif
 	unsigned int tlb_size;
 	unsigned int law_size;
 	unsigned int ram_tlb_index;
@@ -1098,12 +1101,17 @@
 	/*
 	 * Set up LAWBAR for all of DDR.
 	 */
+
+#ifdef CONFIG_FSL_LAW
+	set_law(1, CFG_DDR_SDRAM_BASE, law_size, LAW_TRGT_IF_DDR);
+#else
 	ecm->lawbar1 = ((CFG_DDR_SDRAM_BASE >> 12) & 0xfffff);
 	ecm->lawar1 = (LAWAR_EN
 		       | LAWAR_TRGT_IF_DDR
 		       | (LAWAR_SIZE & law_size));
 	debug("DDR: LAWBAR1=0x%08x\n", ecm->lawbar1);
 	debug("DDR: LARAR1=0x%08x\n", ecm->lawar1);
+#endif
 
 	/*
 	 * Confirm that the requested amount of memory was mapped.