sparc: leon2: Updates for generic board initialization
[oweals/u-boot.git] / arch / sparc / cpu / leon3 / cpu_init.c
index a0526cd36c5bf0a9b8aea64fcbb2bf0a424e5c42..9c7665783cb27930fa2ce0c06e93c131cb9878e9 100644 (file)
@@ -30,7 +30,6 @@ DECLARE_GLOBAL_DATA_PTR;
 ambapp_dev_irqmp *irqmp = NULL;
 ambapp_dev_gptimer *gptimer = NULL;
 unsigned int gptimer_irq = 0;
-int leon3_snooping_avail = 0;
 
 /*
  * Breath some life into the CPU...
@@ -48,19 +47,14 @@ void cpu_init_f(void)
 #endif
 }
 
-/* Routine called from start.S,
- *
- * Run from FLASH/PROM:
- *  - memory controller has already been setup up, stack can be used
- *  - global variables available for read/writing
- *  - constants avaiable
-        */
-void cpu_init_f2(void)
+/* If cache snooping is available in hardware the result will be set
+ * to 0x800000, otherwise 0.
+ */
+static unsigned int snoop_detect(void)
 {
-       /* Initialize the AMBA Plug & Play bus structure, the bus
-        * structure represents the AMBA bus that the CPU is located at.
-        */
-       ambapp_bus_init(CONFIG_AMBAPP_IOAREA, CONFIG_SYS_CLK_FREQ, &ambapp_plb);
+       unsigned int result;
+       asm("lda [%%g0] 2, %0" : "=r"(result));
+       return result & 0x00800000;
 }
 
 int arch_cpu_init(void)
@@ -69,6 +63,13 @@ int arch_cpu_init(void)
        gd->bus_clk = CONFIG_SYS_CLK_FREQ;
        gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
 
+       gd->arch.snooping_available = snoop_detect();
+
+       /* Initialize the AMBA Plug & Play bus structure, the bus
+        * structure represents the AMBA bus that the CPU is located at.
+        */
+       ambapp_bus_init(CONFIG_AMBAPP_IOAREA, CONFIG_SYS_CLK_FREQ, &ambapp_plb);
+
        return 0;
 }
 
@@ -78,7 +79,7 @@ int arch_cpu_init(void)
 int cpu_init_r(void)
 {
        ambapp_apbdev apbdev;
-       int index, cpu;
+       int index, cpu, ntimers, i;
        ambapp_dev_gptimer *timer = NULL;
        unsigned int bus_freq;
 
@@ -123,6 +124,14 @@ int cpu_init_r(void)
                timer->scalar = timer->scalar_reload =
                    (((bus_freq / 1000) + 500) / 1000) - 1;
 
+               /* Clear All Timers */
+               ntimers = timer->config & 0x7;
+               for (i = 0; i < ntimers; i++) {
+                       timer->e[i].ctrl = GPTIMER_CTRL_IP;
+                       timer->e[i].rld = 0;
+                       timer->e[i].ctrl = GPTIMER_CTRL_LD;
+               }
+
                index++;
        }
        if (!gptimer) {