Blackfin arch: Move all the silicon rev handling to one place
[sfrench/cifs-2.6.git] / arch / blackfin / kernel / setup.c
index 23e637eb78da8e7daab447c4b2f4ac849099f565..4267523912bd05761bd54db2becb23c833a9eaa2 100644 (file)
@@ -52,6 +52,8 @@ EXPORT_SYMBOL(mtd_size);
 #endif
 
 char __initdata command_line[COMMAND_LINE_SIZE];
+void __initdata *init_retx, *init_saved_retx, *init_saved_seqstat,
+       *init_saved_icplb_fault_addr, *init_saved_dcplb_fault_addr;
 
 /* boot memmap, for parsing "memmap=" */
 #define BFIN_MEMMAP_MAX                128 /* number of entries in bfin_memmap */
@@ -76,10 +78,10 @@ static struct change_member *change_point[2*BFIN_MEMMAP_MAX] __initdata;
 static struct bfin_memmap_entry *overlap_list[BFIN_MEMMAP_MAX] __initdata;
 static struct bfin_memmap_entry new_map[BFIN_MEMMAP_MAX] __initdata;
 
-void __init bf53x_cache_init(void)
+void __init bfin_cache_init(void)
 {
 #if defined(CONFIG_BFIN_DCACHE) || defined(CONFIG_BFIN_ICACHE)
-       generate_cpl_tables();
+       generate_cplb_tables();
 #endif
 
 #ifdef CONFIG_BFIN_ICACHE
@@ -99,7 +101,7 @@ void __init bf53x_cache_init(void)
 #endif
 }
 
-void __init bf53x_relocate_l1_mem(void)
+void __init bfin_relocate_l1_mem(void)
 {
        unsigned long l1_code_length;
        unsigned long l1_data_a_length;
@@ -131,14 +133,14 @@ void __init bf53x_relocate_l1_mem(void)
        dma_memcpy(_sdata_b_l1, _l1_lma_start + l1_code_length +
                        l1_data_a_length, l1_data_b_length);
 
-#ifdef L2_LENGTH
-       l2_length = _ebss_l2 - _stext_l2;
-       if (l2_length > L2_LENGTH)
-               panic("L2 SRAM Overflow\n");
+       if (L2_LENGTH != 0) {
+               l2_length = _ebss_l2 - _stext_l2;
+               if (l2_length > L2_LENGTH)
+                       panic("L2 SRAM Overflow\n");
 
-       /* Copy _stext_l2 to _edata_l2 to L2 SRAM */
-       dma_memcpy(_stext_l2, _l2_lma_start, l2_length);
-#endif
+               /* Copy _stext_l2 to _edata_l2 to L2 SRAM */
+               dma_memcpy(_stext_l2, _l2_lma_start, l2_length);
+       }
 }
 
 /* add_memory_region to memmap */
@@ -738,6 +740,16 @@ void __init setup_arch(char **cmdline_p)
 
        memory_setup();
 
+       /* Initialize Async memory banks */
+       bfin_write_EBIU_AMBCTL0(AMBCTL0VAL);
+       bfin_write_EBIU_AMBCTL1(AMBCTL1VAL);
+       bfin_write_EBIU_AMGCTL(AMGCTLVAL);
+#ifdef CONFIG_EBIU_MBSCTLVAL
+       bfin_write_EBIU_MBSCTL(CONFIG_EBIU_MBSCTLVAL);
+       bfin_write_EBIU_MODE(CONFIG_EBIU_MODEVAL);
+       bfin_write_EBIU_FCTL(CONFIG_EBIU_FCTLVAL);
+#endif
+
        cclk = get_cclk();
        sclk = get_sclk();
 
@@ -771,12 +783,25 @@ void __init setup_arch(char **cmdline_p)
 
        _bfin_swrst = bfin_read_SWRST();
 
-       /* If we double fault, reset the system - otherwise we hang forever */
-       bfin_write_SWRST(DOUBLE_FAULT);
+#ifdef CONFIG_DEBUG_DOUBLEFAULT_PRINT
+       bfin_write_SWRST(_bfin_swrst & ~DOUBLE_FAULT);
+#endif
+#ifdef CONFIG_DEBUG_DOUBLEFAULT_RESET
+       bfin_write_SWRST(_bfin_swrst | DOUBLE_FAULT);
+#endif
 
-       if (_bfin_swrst & RESET_DOUBLE)
-               printk(KERN_INFO "Recovering from Double Fault event\n");
-       else if (_bfin_swrst & RESET_WDOG)
+       if (_bfin_swrst & RESET_DOUBLE) {
+               printk(KERN_EMERG "Recovering from DOUBLE FAULT event\n");
+#ifdef CONFIG_DEBUG_DOUBLEFAULT
+               /* We assume the crashing kernel, and the current symbol table match */
+               printk(KERN_EMERG " While handling exception (EXCAUSE = 0x%x) at %pF\n",
+                       (int)init_saved_seqstat & SEQSTAT_EXCAUSE, init_saved_retx);
+               printk(KERN_NOTICE "   DCPLB_FAULT_ADDR: %pF\n", init_saved_dcplb_fault_addr);
+               printk(KERN_NOTICE "   ICPLB_FAULT_ADDR: %pF\n", init_saved_icplb_fault_addr);
+#endif
+               printk(KERN_NOTICE " The instruction at %pF caused a double exception\n",
+                       init_retx);
+       } else if (_bfin_swrst & RESET_WDOG)
                printk(KERN_INFO "Recovering from Watchdog event\n");
        else if (_bfin_swrst & RESET_SOFTWARE)
                printk(KERN_NOTICE "Reset caused by Software reset\n");
@@ -796,9 +821,10 @@ void __init setup_arch(char **cmdline_p)
                        printk(KERN_ERR "Warning: Compiled for Rev %d, but running on Rev %d\n",
                               bfin_compiled_revid(), bfin_revid());
        }
-       if (bfin_revid() < SUPPORTED_REVID)
+       if (bfin_revid() <= CONFIG_BF_REV_MIN || bfin_revid() > CONFIG_BF_REV_MAX)
                printk(KERN_ERR "Warning: Unsupported Chip Revision ADSP-%s Rev 0.%d detected\n",
                       CPU, bfin_revid());
+
        printk(KERN_INFO "Blackfin Linux support by http://blackfin.uclinux.org/\n");
 
        printk(KERN_INFO "Processor Speed: %lu MHz core clock and %lu MHz System Clock\n",
@@ -835,7 +861,7 @@ void __init setup_arch(char **cmdline_p)
                != SAFE_USER_INSTRUCTION - FIXED_CODE_START);
 
        init_exception_vectors();
-       bf53x_cache_init();
+       bfin_cache_init();
 }
 
 static int __init topology_init(void)
@@ -975,7 +1001,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
                "cpu family\t: 0x%x\n"
                "model name\t: ADSP-%s %lu(MHz CCLK) %lu(MHz SCLK) (%s)\n"
                "stepping\t: %d\n",
-               0,
+               *(unsigned int *)v,
                vendor,
                (bfin_read_CHIPID() & CHIPID_FAMILY),
                cpu, cclk/1000000, sclk/1000000,
@@ -1023,7 +1049,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
        if ((bfin_read_DMEM_CONTROL() & (ENDCPLB | DMC_ENABLE)) != (ENDCPLB | DMC_ENABLE))
                dcache_size = 0;
 
-       if ((bfin_read_IMEM_CONTROL() & (IMC | ENICPLB)) == (IMC | ENICPLB))
+       if ((bfin_read_IMEM_CONTROL() & (IMC | ENICPLB)) != (IMC | ENICPLB))
                icache_size = 0;
 
        seq_printf(m, "cache size\t: %d KB(L1 icache) "
@@ -1049,7 +1075,7 @@ static int show_cpuinfo(struct seq_file *m, void *v)
                   dsup_banks, BFIN_DSUBBANKS, BFIN_DWAYS,
                   BFIN_DLINES);
 #ifdef CONFIG_BFIN_ICACHE_LOCK
-       switch (read_iloc()) {
+       switch ((bfin_read_IMEM_CONTROL() >> 3) & WAYALL_L) {
        case WAY0_L:
                seq_printf(m, "Way0 Locked-Down\n");
                break;
@@ -1112,12 +1138,18 @@ static int show_cpuinfo(struct seq_file *m, void *v)
 
 static void *c_start(struct seq_file *m, loff_t *pos)
 {
-       return *pos < NR_CPUS ? ((void *)0x12345678) : NULL;
+       if (*pos == 0)
+               *pos = first_cpu(cpu_online_map);
+       if (*pos >= num_online_cpus())
+               return NULL;
+
+       return pos;
 }
 
 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
 {
-       ++*pos;
+       *pos = next_cpu(*pos, cpu_online_map);
+
        return c_start(m, pos);
 }