]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - cpu/ppc4xx/start.S
Merge with /home/stefan/git/u-boot/acadia
[people/ms/u-boot.git] / cpu / ppc4xx / start.S
index f434e207d96e039f930e691f8d50f2b5e2ce7383..3b1586c0ae3d12df74ee3bfdb69cf1c5ccf9929f 100644 (file)
@@ -2,6 +2,7 @@
  *  Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
  *  Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
  *  Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de>
+ *  Copyright (C) 2007 Stefan Roese <sr@denx.de>, DENX Software Engineering
  *
  * See file CREDITS for list of people who contributed to this
  * project.
 
        .extern ext_bus_cntlr_init
        .extern sdram_init
+#ifdef CONFIG_NAND_U_BOOT
+       .extern reconfig_tlb0
+#endif
 
 /*
  * Set up GOT: Global Offset Table
  *
  * Use r14 to access the GOT
  */
+#if !defined(CONFIG_NAND_SPL)
        START_GOT
        GOT_ENTRY(_GOT2_TABLE_)
        GOT_ENTRY(_FIXUP_TABLE_)
        GOT_ENTRY(_end)
        GOT_ENTRY(__bss_start)
        END_GOT
+#endif /* CONFIG_NAND_SPL */
+
+#if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL)
+       /*
+        * NAND U-Boot image is started from offset 0
+        */
+       .text
+       bl      reconfig_tlb0
+       GET_GOT
+       bl      cpu_init_f      /* run low-level CPU init code     (from Flash) */
+       bl      board_init_f
+#endif
 
 /*
  * 440 Startup -- on reset only the top 4k of the effective
  */
 
 #if defined(CONFIG_440)
+#if !defined(CONFIG_NAND_SPL)
     .section .bootpg,"ax"
+#endif
     .globl _start_440
 
 /**************************************************************************/
 _start_440:
+       /*--------------------------------------------------------------------+
+       | 440EPX BUP Change - Hardware team request
+       +--------------------------------------------------------------------*/
+#if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
+       sync
+       nop
+       nop
+#endif
+       /*----------------------------------------------------------------+
+       | Core bug fix.  Clear the esr
+       +-----------------------------------------------------------------*/
+       li      r0,0
+       mtspr   esr,r0
        /*----------------------------------------------------------------*/
        /* Clear and set up some registers. */
        /*----------------------------------------------------------------*/
@@ -166,15 +198,31 @@ _start_440:
        mtspr   srr1,r0
        mtspr   csrr0,r0
        mtspr   csrr1,r0
-#if defined (CONFIG_440GX) /* NOTE: 440GX adds machine check status regs */
+       /* NOTE: 440GX adds machine check status regs */
+#if defined(CONFIG_440) && !defined(CONFIG_440GP)
        mtspr   mcsrr0,r0
        mtspr   mcsrr1,r0
-       mfspr   r1, mcsr
+       mfspr   r1,mcsr
        mtspr   mcsr,r1
 #endif
+
+       /*----------------------------------------------------------------*/
+       /* CCR0 init */
+       /*----------------------------------------------------------------*/
+       /* Disable store gathering & broadcast, guarantee inst/data
+       * cache block touch, force load/store alignment
+       * (see errata 1.12: 440_33)
+       */
+       lis     r1,0x0030       /* store gathering & broadcast disable */
+       ori     r1,r1,0x6000    /* cache touch */
+       mtspr   ccr0,r1
+
        /*----------------------------------------------------------------*/
        /* Initialize debug */
        /*----------------------------------------------------------------*/
+       mfspr   r1,dbcr0
+       andis.  r1, r1, 0x8000  /* test DBCR0[EDM] bit                  */
+       bne     skip_debug_init /* if set, don't clear debug register   */
        mtspr   dbcr0,r0
        mtspr   dbcr1,r0
        mtspr   dbcr2,r0
@@ -188,17 +236,32 @@ _start_440:
 
        mfspr   r1,dbsr
        mtspr   dbsr,r1         /* Clear all valid bits */
-
-       /*----------------------------------------------------------------*/
-       /* CCR0 init */
-       /*----------------------------------------------------------------*/
-       /* Disable store gathering & broadcast, guarantee inst/data
-       * cache block touch, force load/store alignment
-       * (see errata 1.12: 440_33)
-       */
-       lis     r1,0x0030       /* store gathering & broadcast disable */
-       ori     r1,r1,0x6000    /* cache touch */
-       mtspr   ccr0,r1
+skip_debug_init:
+
+#if defined (CONFIG_440SPE)
+       /*----------------------------------------------------------------+
+       | Initialize Core Configuration Reg1.
+       | a. ICDPEI: Record even parity. Normal operation.
+       | b. ICTPEI: Record even parity. Normal operation.
+       | c. DCTPEI: Record even parity. Normal operation.
+       | d. DCDPEI: Record even parity. Normal operation.
+       | e. DCUPEI: Record even parity. Normal operation.
+       | f. DCMPEI: Record even parity. Normal operation.
+       | g. FCOM:   Normal operation
+       | h. MMUPEI: Record even parity. Normal operation.
+       | i. FFF:    Flush only as much data as necessary.
+       | j. TCS:    Timebase increments from CPU clock.
+       +-----------------------------------------------------------------*/
+       li      r0,0
+       mtspr   ccr1, r0
+
+       /*----------------------------------------------------------------+
+       | Reset the timebase.
+       | The previous write to CCR1 sets the timebase source.
+       +-----------------------------------------------------------------*/
+       mtspr   tbl, r0
+       mtspr   tbu, r0
+#endif
 
        /*----------------------------------------------------------------*/
        /* Setup interrupt vectors */
@@ -261,20 +324,47 @@ _start_440:
        mtspr   ivlim,r1
        mtspr   dvlim,r1
 
+       /*----------------------------------------------------------------+
+       |Initialize MMUCR[STID] = 0.
+       +-----------------------------------------------------------------*/
+       mfspr   r0,mmucr
+       addis   r1,0,0xFFFF
+       ori     r1,r1,0xFF00
+       and     r0,r0,r1
+       mtspr   mmucr,r0
+
        /*----------------------------------------------------------------*/
        /* Clear all TLB entries -- TID = 0, TS = 0 */
        /*----------------------------------------------------------------*/
-       mtspr   mmucr,r0
+       addis   r0,0,0x0000
        li      r1,0x003f       /* 64 TLB entries */
        mtctr   r1
-0:     tlbwe   r0,r1,0x0000    /* Invalidate all entries (V=0)*/
+rsttlb:        tlbwe   r0,r1,0x0000    /* Invalidate all entries (V=0)*/
+       tlbwe   r0,r1,0x0001
+       tlbwe   r0,r1,0x0002
        subi    r1,r1,0x0001
-       bdnz    0b
+       bdnz    rsttlb
 
        /*----------------------------------------------------------------*/
        /* TLB entry setup -- step thru tlbtab */
        /*----------------------------------------------------------------*/
+#if defined(CONFIG_440SPE)
+       /*----------------------------------------------------------------*/
+       /* We have different TLB tables for revA and rev B of 440SPe */
+       /*----------------------------------------------------------------*/
+       mfspr   r1, PVR
+       lis     r0,0x5342
+       ori     r0,r0,0x1891
+       cmpw    r7,r1,r0
+       bne     r7,..revA
+       bl      tlbtabB
+       b       ..goon
+..revA:
+       bl      tlbtabA
+..goon:
+#else
        bl      tlbtab          /* Get tlbtab pointer */
+#endif
        mr      r5,r0
        li      r1,0x003f       /* 64 TLB entries max */
        mtctr   r1
@@ -295,7 +385,53 @@ _start_440:
        /*----------------------------------------------------------------*/
        /* Continue from 'normal' start */
        /*----------------------------------------------------------------*/
-2:     bl      3f
+2:
+
+#if defined(CONFIG_NAND_SPL)
+       /*
+        * Enable internal SRAM
+        */
+       lis     r2,0x7fff
+       ori     r2,r2,0xffff
+       mfdcr   r1,isram0_dpc
+       and     r1,r1,r2                /* Disable parity check */
+       mtdcr   isram0_dpc,r1
+       mfdcr   r1,isram0_pmeg
+       and     r1,r1,r2                /* Disable pwr mgmt */
+       mtdcr   isram0_pmeg,r1
+
+       /*
+        * Copy SPL from cache into internal SRAM
+        */
+       li      r4,(CFG_NAND_BOOT_SPL_SIZE >> 2) - 1
+       mtctr   r4
+       lis     r2,CFG_NAND_BOOT_SPL_SRC@h
+       ori     r2,r2,CFG_NAND_BOOT_SPL_SRC@l
+       lis     r3,CFG_NAND_BOOT_SPL_DST@h
+       ori     r3,r3,CFG_NAND_BOOT_SPL_DST@l
+spl_loop:
+       lwzu    r4,4(r2)
+       stwu    r4,4(r3)
+       bdnz    spl_loop
+
+       /*
+        * Jump to code in RAM
+        */
+       bl      00f
+00:    mflr    r10
+       lis     r3,(CFG_NAND_BOOT_SPL_SRC - CFG_NAND_BOOT_SPL_DST)@h
+       ori     r3,r3,(CFG_NAND_BOOT_SPL_SRC - CFG_NAND_BOOT_SPL_DST)@l
+       sub     r10,r10,r3
+       addi    r10,r10,28
+       mtlr    r10
+       blr
+
+start_ram:
+       sync
+       isync
+#endif
+
+       bl      3f
        b       _start
 
 3:     li      r0,0
@@ -309,6 +445,7 @@ _start_440:
  * r3 - 1st arg to board_init(): IMMP pointer
  * r4 - 2nd arg to board_init(): boot flag
  */
+#ifndef CONFIG_NAND_SPL
        .text
        .long   0x27051956              /* U-Boot Magic Number                  */
        .globl  version_string
@@ -322,6 +459,7 @@ version_string:
  * location (0x100) is where the CriticalInput Execption should be.
  */
        . = EXC_OFF_SYS_RESET
+#endif
        .globl  _start
 _start:
 
@@ -340,23 +478,6 @@ _start:
        mtspr   tcr,r0                  /* disable all */
        mtspr   esr,r0                  /* clear exception syndrome register */
        mtxer   r0                      /* clear integer exception register */
-#if !defined(CONFIG_440GX)
-       lis     r1,0x0002               /* set CE bit (Critical Exceptions) */
-       ori     r1,r1,0x1000            /* set ME bit (Machine Exceptions) */
-       mtmsr   r1                      /* change MSR */
-#elif !defined(CONFIG_440EP) && !defined(CONFIG_440GR)
-       bl      __440gx_msr_set
-       b       __440gx_msr_continue
-
-__440gx_msr_set:
-       lis     r1, 0x0002              /* set CE bit (Critical Exceptions) */
-       ori     r1,r1,0x1000    /* set ME bit (Machine Exceptions) */
-       mtspr   srr1,r1
-       mflr    r1
-       mtspr   srr0,r1
-       rfi
-__440gx_msr_continue:
-#endif
 
        /*----------------------------------------------------------------*/
        /* Debug setup -- some (not very good) ice's need an event*/
@@ -377,7 +498,8 @@ __440gx_msr_continue:
        /* Setup the internal SRAM */
        /*----------------------------------------------------------------*/
        li      r0,0
-#if defined(CONFIG_440EP) || defined(CONFIG_440GR)
+
+#ifdef CFG_INIT_RAM_DCACHE
        /* Clear Dcache to use as RAM */
        addis   r3,r0,CFG_INIT_RAM_ADDR@h
        ori     r3,r3,CFG_INIT_RAM_ADDR@l
@@ -393,23 +515,26 @@ __440gx_msr_continue:
        dcbz    r0,r3
        addi    r3,r3,32
        bdnz    ..d_ag
-#else
-#if defined (CONFIG_440GX)
+#endif /* CFG_INIT_RAM_DCACHE */
+
+       /* 440EP & 440GR are only 440er PPC's without internal SRAM */
+#if !defined(CONFIG_440EP) && !defined(CONFIG_440GR)
+       /* not all PPC's have internal SRAM usable as L2-cache */
+#if defined(CONFIG_440GX) || defined(CONFIG_440SP) || defined(CONFIG_440SPE)
        mtdcr   l2_cache_cfg,r0         /* Ensure L2 Cache is off */
 #endif
-       mtdcr   isram0_sb1cr,r0         /* Disable bank 1 */
 
-       li      r2,0x7fff
+       lis     r2,0x7fff
        ori     r2,r2,0xffff
        mfdcr   r1,isram0_dpc
        and     r1,r1,r2                /* Disable parity check */
        mtdcr   isram0_dpc,r1
        mfdcr   r1,isram0_pmeg
-       andis.  r1,r1,r2                /* Disable pwr mgmt */
+       and     r1,r1,r2                /* Disable pwr mgmt */
        mtdcr   isram0_pmeg,r1
 
        lis     r1,0x8000               /* BAS = 8000_0000 */
-#if defined(CONFIG_440GX)
+#if defined(CONFIG_440GX) || defined(CONFIG_440SP)
        ori     r1,r1,0x0980            /* first 64k */
        mtdcr   isram0_sb0cr,r1
        lis     r1,0x8001
@@ -421,18 +546,31 @@ __440gx_msr_continue:
        lis     r1, 0x8003
        ori     r1,r1, 0x0980           /* fourth 64k */
        mtdcr   isram0_sb3cr,r1
-#else
+#elif defined(CONFIG_440SPE)
+       lis     r1,0x0000               /* BAS = 0000_0000 */
+       ori     r1,r1,0x0984            /* first 64k */
+       mtdcr   isram0_sb0cr,r1
+       lis     r1,0x0001
+       ori     r1,r1,0x0984            /* second 64k */
+       mtdcr   isram0_sb1cr,r1
+       lis     r1, 0x0002
+       ori     r1,r1, 0x0984           /* third 64k */
+       mtdcr   isram0_sb2cr,r1
+       lis     r1, 0x0003
+       ori     r1,r1, 0x0984           /* fourth 64k */
+       mtdcr   isram0_sb3cr,r1
+#elif defined(CONFIG_440GP)
        ori     r1,r1,0x0380            /* 8k rw */
        mtdcr   isram0_sb0cr,r1
+       mtdcr   isram0_sb1cr,r0         /* Disable bank 1 */
 #endif
-#endif
+#endif /* #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) */
 
        /*----------------------------------------------------------------*/
        /* Setup the stack in internal SRAM */
        /*----------------------------------------------------------------*/
        lis     r1,CFG_INIT_RAM_ADDR@h
        ori     r1,r1,CFG_INIT_SP_OFFSET@l
-
        li      r0,0
        stwu    r0,-4(r1)
        stwu    r0,-4(r1)               /* Terminate call chain */
@@ -443,8 +581,14 @@ __440gx_msr_continue:
        stwu    r1,-8(r1)               /* Save back chain and move SP */
        stw     r0,+12(r1)              /* Save return addr (underflow vect) */
 
+#ifdef CONFIG_NAND_SPL
+       bl      nand_boot               /* will not return */
+#else
        GET_GOT
+
+       bl      cpu_init_f      /* run low-level CPU init code     (from Flash) */
        bl      board_init_f
+#endif
 
 #endif /* CONFIG_440 */
 
@@ -457,9 +601,6 @@ __440gx_msr_continue:
        mtspr   esr,r0                  /* clear Exception Syndrome Reg */
        mttcr   r0                      /* timer control register */
        mtexier r0                      /* disable all interrupts */
-       addi    r4,r0,0x1000            /* set ME bit (Machine Exceptions) */
-       oris    r4,r4,0x2               /* set CE bit (Critical Exceptions) */
-       mtmsr   r4                      /* change MSR */
        addis   r4,r0,0xFFFF            /* set r4 to 0xFFFFFFFF (status in the */
        ori     r4,r4,0xFFFF            /* dbsr is cleared by setting bits to 1) */
        mtdbsr  r4                      /* clear/reset the dbsr */
@@ -559,7 +700,9 @@ __440gx_msr_continue:
 #endif /* CONFIG_IOP480 */
 
 /*****************************************************************************/
-#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405) || defined(CONFIG_405EP)
+#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
+    defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
+    defined(CONFIG_405)
        /*----------------------------------------------------------------------- */
        /* Clear and set up some registers. */
        /*----------------------------------------------------------------------- */
@@ -570,9 +713,6 @@ __440gx_msr_continue:
        mttcr   r4                      /* clear Timer Control Reg */
        mtxer   r4                      /* clear Fixed-Point Exception Reg */
        mtevpr  r4                      /* clear Exception Vector Prefix Reg */
-       addi    r4,r0,0x1000            /* set ME bit (Machine Exceptions) */
-       oris    r4,r4,0x0002            /* set CE bit (Critical Exceptions) */
-       mtmsr   r4                      /* change MSR */
        addi    r4,r0,(0xFFFF-0x10000)          /* set r4 to 0xFFFFFFFF (status in the */
                                        /* dbsr is cleared by setting bits to 1) */
        mtdbsr  r4                      /* clear/reset the dbsr */
@@ -590,13 +730,13 @@ __440gx_msr_continue:
        /*----------------------------------------------------------------------- */
        /* Enable two 128MB cachable regions. */
        /*----------------------------------------------------------------------- */
-       addis   r4,r0,0x8000
-       addi    r4,r4,0x0001
+       lis     r4,0x8000
+       ori     r4,r4,0x0001
        mticcr  r4                      /* instruction cache */
        isync
 
-       addis   r4,r0,0x0000
-       addi    r4,r4,0x0000
+       lis     r4,0x0000
+       ori     r4,r4,0x0000
        mtdccr  r4                      /* data cache */
 
 #if !(defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
@@ -618,6 +758,35 @@ __440gx_msr_continue:
 #endif /* CONFIG_405EP */
 
 #if defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE)
+#if defined(CONFIG_405EZ)
+       /********************************************************************
+        * Setup OCM - On Chip Memory - PPC405EZ uses OCM Controller V2
+        *******************************************************************/
+       /*
+        * We can map the OCM on the PLB3, so map it at
+        * CFG_OCM_DATA_ADDR + 0x8000
+        */
+       lis     r3,CFG_OCM_DATA_ADDR@h  /* OCM location */
+       ori     r3,r3,CFG_OCM_DATA_ADDR@l
+       ori     r3,r3,0x8270    /* 32K Offset, 16K for Bank 1, R/W/Enable */
+       mtdcr   ocmplb3cr1,r3           /* Set PLB Access */
+       ori     r3,r3,0x4000            /* Add 0x4000 for bank 2 */
+       mtdcr   ocmplb3cr2,r3           /* Set PLB Access */
+       isync
+
+       lis     r3,CFG_OCM_DATA_ADDR@h  /* OCM location */
+       ori     r3,r3,CFG_OCM_DATA_ADDR@l
+       ori     r3,r3,0x0270            /* 16K for Bank 1, R/W/Enable */
+       mtdcr   ocmdscr1, r3            /* Set Data Side */
+       mtdcr   ocmiscr1, r3            /* Set Instruction Side */
+       ori     r3,r3,0x4000            /* Add 0x4000 for bank 2 */
+       mtdcr   ocmdscr2, r3            /* Set Data Side */
+       mtdcr   ocmiscr2, r3            /* Set Instruction Side */
+       addis   r3,0,0x0800             /* OCM Data Parity Disable - 1 Wait State */
+       mtdcr   ocmdsisdpc,r4
+
+       isync
+#else /* CONFIG_405EZ */
        /********************************************************************
         * Setup OCM - On Chip Memory
         *******************************************************************/
@@ -625,18 +794,20 @@ __440gx_msr_continue:
        lis     r0, 0x7FFF
        ori     r0, r0, 0xFFFF
        mfdcr   r3, ocmiscntl           /* get instr-side IRAM config */
-       mfdcr   r4, ocmdscntl   /* get data-side IRAM config */
-       and     r3, r3, r0      /* disable data-side IRAM */
-       and     r4, r4, r0      /* disable data-side IRAM */
-       mtdcr   ocmiscntl, r3   /* set instr-side IRAM config */
-       mtdcr   ocmdscntl, r4   /* set data-side IRAM config */
+       mfdcr   r4, ocmdscntl           /* get data-side IRAM config */
+       and     r3, r3, r0              /* disable data-side IRAM */
+       and     r4, r4, r0              /* disable data-side IRAM */
+       mtdcr   ocmiscntl, r3           /* set instr-side IRAM config */
+       mtdcr   ocmdscntl, r4           /* set data-side IRAM config */
        isync
 
-       addis   r3, 0, CFG_OCM_DATA_ADDR@h /* OCM location */
+       lis     r3,CFG_OCM_DATA_ADDR@h  /* OCM location */
+       ori     r3,r3,CFG_OCM_DATA_ADDR@l
        mtdcr   ocmdsarc, r3
        addis   r4, 0, 0xC000           /* OCM data area enabled */
        mtdcr   ocmdscntl, r4
        isync
+#endif /* CONFIG_405EZ */
 #endif
 
        /*----------------------------------------------------------------------- */
@@ -760,6 +931,7 @@ __440gx_msr_continue:
        /*----------------------------------------------------------------------- */
 
 
+#ifndef CONFIG_NAND_SPL
 /*****************************************************************************/
        .globl  _start_of_vectors
 _start_of_vectors:
@@ -965,6 +1137,7 @@ crit_return:
        lwz     r1,GPR1(r1)
        SYNC
        rfci
+#endif /* CONFIG_NAND_SPL */
 
 /* Cache functions.
 */
@@ -975,12 +1148,8 @@ invalidate_icache:
 invalidate_dcache:
        addi    r6,0,0x0000             /* clear GPR 6 */
        /* Do loop for # of dcache congruence classes. */
-#if defined(CONFIG_440GX) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
        lis     r7, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@ha       /* TBS for large sized cache */
        ori     r7, r7, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@l
-#else
-       addi    r7,r0, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)
-#endif
                                        /* NOTE: dccci invalidates both */
        mtctr   r7                      /* ways in the D cache */
 ..dcloop:
@@ -1001,15 +1170,10 @@ flush_dcache:
        mtdccr  r10
 
        /* do loop for # of congruence classes. */
-#if defined(CONFIG_440GX) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
        lis     r10,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@ha       /* TBS: for large cache sizes */
        ori     r10,r10,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@l
        lis     r11,(CFG_DCACHE_SIZE / 2)@ha /* D cache set size - 2 way sets */
        ori     r11,r11,(CFG_DCACHE_SIZE / 2)@l /* D cache set size - 2 way sets */
-#else
-       addi    r10,r0,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)
-       addi    r11,r0,(CFG_DCACHE_SIZE / 2) /* D cache set size - 2 way sets */
-#endif
        mtctr   r10
        addi    r10,r0,(0xE000-0x10000) /* start at 0xFFFFE000 */
        add     r11,r10,r11             /* add to get to other side of cache line */
@@ -1215,6 +1379,7 @@ ppcSync:
 
 /*------------------------------------------------------------------------------*/
 
+#ifndef CONFIG_NAND_SPL
 /*
  * void relocate_code (addr_sp, gd, addr_moni)
  *
@@ -1228,13 +1393,22 @@ ppcSync:
  */
        .globl  relocate_code
 relocate_code:
-#if defined(CONFIG_440EP) || defined(CONFIG_440GR)
-       dccci   0,0                         /* Invalidate data cache, now no longer our stack */
+#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
+    defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
+    defined(CONFIG_440SP) || defined(CONFIG_440SPE)
+       /*
+        * On some 440er platforms the cache is enabled in the first TLB (Boot-CS)
+        * to speed up the boot process. Now this cache needs to be disabled.
+        */
+       iccci   0,0                     /* Invalidate inst cache */
+       dccci   0,0                     /* Invalidate data cache, now no longer our stack */
        sync
-       addi    r1,r0,0x0000        /* Tlb entry #0 */
+       isync
+       addi    r1,r0,0x0000            /* TLB entry #0 */
        tlbre   r0,r1,0x0002            /* Read contents */
-       ori     r0,r0,0x0c00        /* Or in the inhibit, write through bit */
+       ori     r0,r0,0x0c00            /* Or in the inhibit, write through bit */
        tlbwe   r0,r1,0x0002            /* Save it out */
+       sync
        isync
 #endif
        mr      r1,  r3         /* Set new stack pointer                */
@@ -1436,6 +1610,24 @@ trap_init:
        cmplw   0, r7, r8
        blt     4b
 
+#if !defined(CONFIG_440)
+       addi    r7,r0,0x1000            /* set ME bit (Machine Exceptions) */
+       oris    r7,r7,0x0002            /* set CE bit (Critical Exceptions) */
+       mtmsr   r7                      /* change MSR */
+#else
+       bl      __440_msr_set
+       b       __440_msr_continue
+
+__440_msr_set:
+       addi    r7,r0,0x1000            /* set ME bit (Machine Exceptions) */
+       oris    r7,r7,0x0002            /* set CE bit (Critical Exceptions) */
+       mtspr   srr1,r7
+       mflr    r7
+       mtspr   srr0,r7
+       rfi
+__440_msr_continue:
+#endif
+
        mtlr    r4                      /* restore link register        */
        blr
 
@@ -1452,6 +1644,7 @@ trap_reloc:
        stw     r0, 4(r7)
 
        blr
+#endif /* CONFIG_NAND_SPL */
 
 
 /**************************************************************************/
@@ -1539,7 +1732,8 @@ ppc405ep_init:
        mtdcr   ebccfgd,r3
 #endif
 
-       addi    r3,0,CPC0_PCI_HOST_CFG_EN
+#ifndef CFG_CPC0_PCI
+       li      r3,CPC0_PCI_HOST_CFG_EN
 #ifdef CONFIG_BUBINGA
        /*
        !-----------------------------------------------------------------------
@@ -1554,6 +1748,9 @@ ppc405ep_init:
        beq     ..pci_cfg_set             /* if not set, then bypass reg write*/
 #endif
        ori     r3,r3,CPC0_PCI_ARBIT_EN
+#else /* CFG_CPC0_PCI */
+       li      r3,CFG_CPC0_PCI
+#endif /* CFG_CPC0_PCI */
 ..pci_cfg_set:
        mtdcr   CPC0_PCI, r3             /* Enable internal arbiter*/
 
@@ -1693,3 +1890,103 @@ pll_wait:
                                     /* execution will continue from the poweron */
                                     /* vector of 0xfffffffc */
 #endif /* CONFIG_405EP */
+
+#if defined(CONFIG_440)
+#define function_prolog(func_name)      .text; \
+                                       .align 2; \
+                                       .globl func_name; \
+                                       func_name:
+#define function_epilog(func_name)      .type func_name,@function; \
+                                       .size func_name,.-func_name
+
+/*----------------------------------------------------------------------------+
+| mttlb3.
++----------------------------------------------------------------------------*/
+       function_prolog(mttlb3)
+       TLBWE(4,3,2)
+       blr
+       function_epilog(mttlb3)
+
+/*----------------------------------------------------------------------------+
+| mftlb3.
++----------------------------------------------------------------------------*/
+       function_prolog(mftlb3)
+       TLBRE(3,3,2)
+       blr
+       function_epilog(mftlb3)
+
+/*----------------------------------------------------------------------------+
+| mttlb2.
++----------------------------------------------------------------------------*/
+       function_prolog(mttlb2)
+       TLBWE(4,3,1)
+       blr
+       function_epilog(mttlb2)
+
+/*----------------------------------------------------------------------------+
+| mftlb2.
++----------------------------------------------------------------------------*/
+       function_prolog(mftlb2)
+       TLBRE(3,3,1)
+       blr
+       function_epilog(mftlb2)
+
+/*----------------------------------------------------------------------------+
+| mttlb1.
++----------------------------------------------------------------------------*/
+       function_prolog(mttlb1)
+       TLBWE(4,3,0)
+       blr
+       function_epilog(mttlb1)
+
+/*----------------------------------------------------------------------------+
+| mftlb1.
++----------------------------------------------------------------------------*/
+       function_prolog(mftlb1)
+       TLBRE(3,3,0)
+       blr
+       function_epilog(mftlb1)
+
+/*----------------------------------------------------------------------------+
+| dcbz_area.
++----------------------------------------------------------------------------*/
+       function_prolog(dcbz_area)
+       rlwinm. r5,r4,0,27,31
+       rlwinm  r5,r4,27,5,31
+       beq     ..d_ra2
+       addi    r5,r5,0x0001
+..d_ra2:mtctr   r5
+..d_ag2:dcbz    r0,r3
+       addi    r3,r3,32
+       bdnz    ..d_ag2
+       sync
+       blr
+       function_epilog(dcbz_area)
+
+/*----------------------------------------------------------------------------+
+| dflush.  Assume 32K at vector address is cachable.
++----------------------------------------------------------------------------*/
+       function_prolog(dflush)
+       mfmsr   r9
+       rlwinm  r8,r9,0,15,13
+       rlwinm  r8,r8,0,17,15
+       mtmsr   r8
+       addi    r3,r0,0x0000
+       mtspr   dvlim,r3
+       mfspr   r3,ivpr
+       addi    r4,r0,1024
+       mtctr   r4
+..dflush_loop:
+       lwz     r6,0x0(r3)
+       addi    r3,r3,32
+       bdnz    ..dflush_loop
+       addi    r3,r3,-32
+       mtctr   r4
+..ag:   dcbf    r0,r3
+       addi    r3,r3,-32
+       bdnz    ..ag
+       sync
+       mtmsr   r9
+       blr
+       function_epilog(dflush)
+#endif /* CONFIG_440 */