]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
FSL LAW: Keep track of LAW allocations
authorKumar Gala <galak@kernel.crashing.org>
Wed, 11 Jun 2008 05:44:10 +0000 (00:44 -0500)
committerAndrew Fleming-AFLEMING <afleming@freescale.com>
Wed, 11 Jun 2008 06:50:53 +0000 (01:50 -0500)
Make it so we keep track of which LAWs have allocated and provide
a function (set_next_law) which can allocate a LAW for us if one is
free.

In the future we will move to doing more "dynamic" LAW allocation
since the majority of users dont really care about what LAW number
they are at.

Also, add CONFIG_MPC8540 or CONFIG_MPC8560 to those boards which needed them

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Signed-off-by: Andy Fleming <afleming@freescale.com>
cpu/mpc85xx/cpu_init.c
drivers/misc/fsl_law.c
include/asm-ppc/fsl_law.h
include/asm-ppc/global_data.h
include/configs/MPC8560ADS.h
include/configs/SBC8540.h
include/configs/sbc8560.h
include/configs/stxgp3.h
include/configs/stxssa.h
lib_ppc/board.c

index 0fb36c4e36efe7f998dd9f044139d14faca4fcdf..736aef17256873ad1c6f9999a2da3e9f5457cbbe 100644 (file)
@@ -148,6 +148,12 @@ void cpu_init_early_f(void)
        }
 #endif
 
+       /* Pointer is writable since we allocated a register for it */
+       gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
+
+       /* Clear initial global data */
+       memset ((void *) gd, 0, sizeof (gd_t));
+
        init_laws();
        invalidate_tlb(0);
        init_tlbs();
@@ -168,12 +174,6 @@ void cpu_init_f (void)
        disable_tlb(14);
        disable_tlb(15);
 
-       /* Pointer is writable since we allocated a register for it */
-       gd = (gd_t *) (CFG_INIT_RAM_ADDR + CFG_GBL_DATA_OFFSET);
-
-       /* Clear initial global data */
-       memset ((void *) gd, 0, sizeof (gd_t));
-
 #ifdef CONFIG_CPM2
        config_8560_ioports((ccsr_cpm_t *)CFG_MPC85xx_CPM_ADDR);
 #endif
@@ -254,17 +254,6 @@ void cpu_init_f (void)
 
 int cpu_init_r(void)
 {
-#ifdef CONFIG_CLEAR_LAW0
-#ifdef CONFIG_FSL_LAW
-       disable_law(0);
-#else
-       volatile ccsr_local_ecm_t *ecm = (void *)(CFG_MPC85xx_ECM_ADDR);
-
-       /* clear alternate boot location LAW (used for sdram, or ddr bank) */
-       ecm->lawar0 = 0;
-#endif
-#endif
-
        puts ("L2:    ");
 
 #if defined(CONFIG_L2_CACHE)
index dca6a4da4a0ab83a2487b8c36e328876a1b2b1bb..d7d6c403baa583ff169315f2b3e384d941ad0a0a 100644 (file)
 #include <asm/fsl_law.h>
 #include <asm/io.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define LAWAR_EN       0x80000000
-#define FSL_HW_NUM_LAWS 10     /* number of LAWs in the hw implementation */
+/* number of LAWs in the hw implementation */
+#if defined(CONFIG_MPC8540) || defined(CONFIG_MPC8541) || \
+    defined(CONFIG_MPC8560) || defined(CONFIG_MPC8555)
+#define FSL_HW_NUM_LAWS 8
+#elif defined(CONFIG_MPC8548) || defined(CONFIG_MPC8544) || \
+      defined(CONFIG_MPC8568) || \
+      defined(CONFIG_MPC8641) || defined(CONFIG_MPC8610)
+#define FSL_HW_NUM_LAWS 10
+#elif defined(CONFIG_MPC8572)
+#define FSL_HW_NUM_LAWS 12
+#else
+#error FSL_HW_NUM_LAWS not defined for this platform
+#endif
 
 void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
 {
@@ -36,18 +50,34 @@ void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
        volatile u32 *lawbar = base + 8 * idx;
        volatile u32 *lawar = base + 8 * idx + 2;
 
+       gd->used_laws |= (1 << idx);
+
        out_be32(lawbar, addr >> 12);
        out_be32(lawar, LAWAR_EN | ((u32)id << 20) | (u32)sz);
 
        return ;
 }
 
+int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id)
+{
+       u32 idx = ffz(gd->used_laws);
+
+       if (idx >= FSL_HW_NUM_LAWS)
+               return -1;
+
+       set_law(idx, addr, sz, id);
+
+       return idx;
+}
+
 void disable_law(u8 idx)
 {
        volatile u32 *base = (volatile u32 *)(CFG_IMMR + 0xc08);
        volatile u32 *lawbar = base + 8 * idx;
        volatile u32 *lawar = base + 8 * idx + 2;
 
+       gd->used_laws &= ~(1 << idx);
+
        out_be32(lawar, 0);
        out_be32(lawbar, 0);
 
@@ -75,14 +105,16 @@ void print_laws(void)
 void init_laws(void)
 {
        int i;
-       u8 law_idx = 0;
 
-       for (i = 0; i < num_law_entries; i++) {
-               if (law_table[i].index != -1)
-                       law_idx = law_table[i].index;
+       gd->used_laws = ~((1 << FSL_HW_NUM_LAWS) - 1);
 
-               set_law(law_idx++, law_table[i].addr,
-                       law_table[i].size, law_table[i].trgt_id);
+       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,
+                                       law_table[i].trgt_id);
+               else
+                       set_law(law_table[i].index, law_table[i].addr,
+                               law_table[i].size, law_table[i].trgt_id);
        }
 
        return ;
index e955c756e8946609fb64f0b5aec4a3b63f0b17fc..6c445a471a9b8bcf7ffc83e66b3bb5f378cb5809 100644 (file)
@@ -6,6 +6,9 @@
 #define SET_LAW_ENTRY(idx, a, sz, trgt) \
        { .index = idx, .addr = a, .size = sz, .trgt_id = trgt }
 
+#define SET_LAW(a, sz, trgt) \
+       { .index = -1, .addr = a, .size = sz, .trgt_id = trgt }
+
 enum law_size {
        LAW_SIZE_4K = 0xb,
        LAW_SIZE_8K,
@@ -70,6 +73,7 @@ struct law_entry {
 };
 
 extern void set_law(u8 idx, phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
+extern int set_next_law(phys_addr_t addr, enum law_size sz, enum law_trgt_if id);
 extern void disable_law(u8 idx);
 extern void init_laws(void);
 extern void print_laws(void);
index ea702662f8a2fef500537f70f9b710ac896bc826..8cf7b6fb3d76d7f3e74bf0ac1caf16440671d649 100644 (file)
@@ -96,6 +96,9 @@ typedef       struct  global_data {
        uint mp_alloc_base;
        uint mp_alloc_top;
 #endif /* CONFIG_QE */
+#if defined(CONFIG_FSL_LAW)
+       u32 used_laws;
+#endif
 #if defined(CONFIG_MPC5xxx)
        unsigned long   ipb_clk;
        unsigned long   pci_clk;
index a3fcad35d2e2dd754b824551cac665eed6aaf1d5..edf8525179c08d74811b8689c885543843e78e88 100644 (file)
@@ -40,6 +40,7 @@
 #define CONFIG_MPC85xx         1       /* MPC8540/MPC8560 */
 #define CONFIG_CPM2            1       /* has CPM2 */
 #define CONFIG_MPC8560ADS      1       /* MPC8560ADS board specific */
+#define CONFIG_MPC8560         1
 
 #define CONFIG_PCI
 #define CONFIG_TSEC_ENET               /* tsec ethernet support */
index ff64378f201c8b16b6e45d2fb6fec7a6a839af1c..8a53fdd0cb875a26d664ff2af41726d1df860999 100644 (file)
@@ -49,6 +49,7 @@
 #define CONFIG_CPM2            1       /* has CPM2 */
 
 #define CONFIG_SBC8540         1       /* configuration for SBC8560 board */
+#define CONFIG_MPC8540         1
 
 #define CONFIG_MPC8560ADS      1       /* MPC8560ADS board specific (supplement)       */
 
index 81a1e072c6d93ffbf6b5688a19a9652811f7c019..146eafe9cca00b63c41e5f05bb3abd6922ab81a9 100644 (file)
@@ -42,6 +42,7 @@
 
 #define CONFIG_CPM2            1       /* has CPM2 */
 #define CONFIG_SBC8560         1       /* configuration for SBC8560 board */
+#define CONFIG_MPC8560         1
 
 /* XXX flagging this as something I might want to delete */
 #define CONFIG_MPC8560ADS      1       /* MPC8560ADS board specific    */
index ec04a30bec99a97ea7ed1d5f3f9ad93ffc4dda59..6e8213d72a5ed7cdfbeec57996569f7a9fd6dad8 100644 (file)
@@ -41,6 +41,7 @@
 #define CONFIG_MPC85xx         1       /* MPC8540/MPC8560      */
 #define CONFIG_CPM2            1       /* has CPM2 */
 #define CONFIG_STXGP3          1       /* Silicon Tx GPPP board specific*/
+#define CONFIG_MPC8560         1
 
 #undef  CONFIG_PCI                     /* pci ethernet support */
 #define CONFIG_TSEC_ENET               /* tsec ethernet support*/
index d033c866d73a7aaafde97296cc2d5ac2cc575c32..a1e9789ea01b512b1a1ea64c428ffc9f067c549e 100644 (file)
@@ -41,6 +41,7 @@
 #define CONFIG_MPC85xx         1       /* MPC8540/MPC8560      */
 #define CONFIG_CPM2            1       /* has CPM2 */
 #define CONFIG_STXSSA          1       /* Silicon Tx GPPP SSA board specific*/
+#define CONFIG_MPC8560         1
 
 #define CONFIG_PCI                     /* PCI ethernet support */
 #define CONFIG_TSEC_ENET               /* tsec ethernet support*/
index a90883162c2f6752cf06178bf2d5c4ca50a4d85a..c42e08862fc87321c86261fcf8fb14f5d7f86b1b 100644 (file)
@@ -421,7 +421,8 @@ void board_init_f (ulong bootflag)
        /* compiler optimization barrier needed for GCC >= 3.4 */
        __asm__ __volatile__("": : :"memory");
 
-#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX)
+#if !defined(CONFIG_CPM2) && !defined(CONFIG_MPC83XX) && \
+    !defined(CONFIG_MPC85xx) && !defined(CONFIG_MPC86xx)
        /* Clear initial global data */
        memset ((void *) gd, 0, sizeof (gd_t));
 #endif