]> git.sur5r.net Git - u-boot/blobdiff - arch/blackfin/cpu/initcode.c
boot: change some arch ifdefs to feature ifdefs
[u-boot] / arch / blackfin / cpu / initcode.c
index 9453d5dc4dfc37bc0865bcf9dbd5a6b6fb2fbd87..433d477ddfa15c64b53a0ccec8fc5f191996de87 100644 (file)
@@ -101,6 +101,28 @@ static inline void serial_putc(char c)
                continue;
 }
 
+__attribute__((always_inline)) static inline void
+program_nmi_handler(void)
+{
+       u32 tmp1, tmp2;
+
+       /* Older bootroms don't create a dummy NMI handler,
+        * so make one ourselves ASAP in case it fires.
+        */
+       if (CONFIG_BFIN_BOOT_MODE != BFIN_BOOT_BYPASS && !ANOMALY_05000219)
+               return;
+
+       asm volatile (
+               "%0 = RETS;" /* Save current RETS */
+               "CALL 1f;"   /* Figure out current PC */
+               "RTN;"       /* The simple NMI handler */
+               "1:"
+               "%1 = RETS;" /* Load addr of NMI handler */
+               "RETS = %0;" /* Restore RETS */
+               "[%2] = %1;" /* Write NMI handler */
+               : "=r"(tmp1), "=r"(tmp2) : "ab"(EVT2)
+       );
+}
 
 /* Max SCLK can be 133MHz ... dividing that by (2*4) gives
  * us a freq of 16MHz for SPI which should generally be
@@ -369,7 +391,9 @@ program_clocks(ADI_BOOT_DATA *bs, bool put_into_srfs)
 
                /* Always programming PLL_LOCKCNT avoids Anomaly 05000430 */
                ADI_SYSCTRL_VALUES memory_settings;
-               uint32_t actions = SYSCTRL_WRITE | SYSCTRL_PLLCTL | SYSCTRL_PLLDIV | SYSCTRL_LOCKCNT;
+               uint32_t actions = SYSCTRL_WRITE | SYSCTRL_PLLCTL | SYSCTRL_LOCKCNT;
+               if (!ANOMALY_05000440)
+                       actions |= SYSCTRL_PLLDIV;
                if (CONFIG_HAS_VR) {
                        actions |= SYSCTRL_VRCTL;
                        if (CONFIG_VR_CTL_VAL & FREQ_MASK)
@@ -388,6 +412,8 @@ program_clocks(ADI_BOOT_DATA *bs, bool put_into_srfs)
                serial_putc('e');
                bfrom_SysControl(actions, &memory_settings, NULL);
                serial_putc('f');
+               if (ANOMALY_05000440)
+                       bfin_write_PLL_DIV(CONFIG_PLL_DIV_VAL);
 #if ANOMALY_05000432
                bfin_write_SIC_IWR1(-1);
 #endif
@@ -640,6 +666,9 @@ void initcode(ADI_BOOT_DATA *bs)
 {
        ADI_BOOT_DATA bootstruct_scratch;
 
+       /* Setup NMI handler before anything else */
+       program_nmi_handler();
+
        serial_init();
 
        serial_putc('A');