ppc4xx: Big cleanup of PPC4xx defines
[platform/kernel/u-boot.git] / board / amcc / ocotea / ocotea.c
index d1a29c5..5e32e8a 100644 (file)
@@ -30,6 +30,8 @@
 #include <spd_sdram.h>
 #include <ppc4xx_enet.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 #define BOOT_SMALL_FLASH       32      /* 00100000 */
 #define FLASH_ONBD_N           2       /* 00000010 */
 #define FLASH_SRAM_SEL         1       /* 00000001 */
@@ -40,7 +42,7 @@ void fpga_init (void);
 int board_early_init_f (void)
 {
        unsigned long mfr;
-       unsigned char *fpga_base = (unsigned char *) CFG_FPGA_BASE;
+       unsigned char *fpga_base = (unsigned char *) CONFIG_SYS_FPGA_BASE;
        unsigned char switch_status;
        unsigned long cs0_base;
        unsigned long cs0_size;
@@ -52,7 +54,7 @@ int board_early_init_f (void)
        /*-------------------------------------------------------------------------+
          | Initialize EBC CONFIG
          +-------------------------------------------------------------------------*/
-       mtebc(xbcfg, EBC_CFG_LE_UNLOCK |
+       mtebc(EBC0_CFG, EBC_CFG_LE_UNLOCK |
              EBC_CFG_PTD_ENABLE | EBC_CFG_RTC_64PERCLK |
              EBC_CFG_ATC_PREVIOUS | EBC_CFG_DTC_PREVIOUS |
              EBC_CFG_CTC_PREVIOUS | EBC_CFG_EMC_NONDEFAULT |
@@ -61,14 +63,14 @@ int board_early_init_f (void)
        /*-------------------------------------------------------------------------+
          | FPGA. Initialize bank 7 with default values.
          +-------------------------------------------------------------------------*/
-       mtebc(pb7ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
+       mtebc(PB7AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
              EBC_BXAP_BCE_DISABLE|
              EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
              EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
              EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
              EBC_BXAP_BEM_WRITEONLY|
              EBC_BXAP_PEN_DISABLED);
-       mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48300000)|
+       mtebc(PB7CR, EBC_BXCR_BAS_ENCODE(0x48300000)|
              EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
 
        /* read FPGA base register FPGA_REG0 */
@@ -93,91 +95,103 @@ int board_early_init_f (void)
        /*-------------------------------------------------------------------------+
          | 1 MB FLASH / 1 MB SRAM. Initialize bank 0 with default values.
          +-------------------------------------------------------------------------*/
-       mtebc(pb0ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs0_twt)|
+       mtebc(PB0AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs0_twt)|
              EBC_BXAP_BCE_DISABLE|
              EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
              EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
              EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
              EBC_BXAP_BEM_WRITEONLY|
              EBC_BXAP_PEN_DISABLED);
-       mtebc(pb0cr, EBC_BXCR_BAS_ENCODE(cs0_base)|
+       mtebc(PB0CR, EBC_BXCR_BAS_ENCODE(cs0_base)|
              cs0_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
 
        /*-------------------------------------------------------------------------+
          | 8KB NVRAM/RTC. Initialize bank 1 with default values.
          +-------------------------------------------------------------------------*/
-       mtebc(pb1ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(10)|
+       mtebc(PB1AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(10)|
              EBC_BXAP_BCE_DISABLE|
              EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
              EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
              EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
              EBC_BXAP_BEM_WRITEONLY|
              EBC_BXAP_PEN_DISABLED);
-       mtebc(pb1cr, EBC_BXCR_BAS_ENCODE(0x48000000)|
+       mtebc(PB1CR, EBC_BXCR_BAS_ENCODE(0x48000000)|
              EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
 
        /*-------------------------------------------------------------------------+
          | 4 MB FLASH. Initialize bank 2 with default values.
          +-------------------------------------------------------------------------*/
-       mtebc(pb2ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs2_twt)|
+       mtebc(PB2AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs2_twt)|
              EBC_BXAP_BCE_DISABLE|
              EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
              EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
              EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
              EBC_BXAP_BEM_WRITEONLY|
              EBC_BXAP_PEN_DISABLED);
-       mtebc(pb2cr, EBC_BXCR_BAS_ENCODE(cs2_base)|
+       mtebc(PB2CR, EBC_BXCR_BAS_ENCODE(cs2_base)|
              cs2_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
 
        /*-------------------------------------------------------------------------+
          | FPGA. Initialize bank 7 with default values.
          +-------------------------------------------------------------------------*/
-       mtebc(pb7ap, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
+       mtebc(PB7AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)|
              EBC_BXAP_BCE_DISABLE|
              EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)|
              EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)|
              EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED|
              EBC_BXAP_BEM_WRITEONLY|
              EBC_BXAP_PEN_DISABLED);
-       mtebc(pb7cr, EBC_BXCR_BAS_ENCODE(0x48300000)|
+       mtebc(PB7CR, EBC_BXCR_BAS_ENCODE(0x48300000)|
              EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
 
        /*--------------------------------------------------------------------
         * Setup the interrupt controller polarities, triggers, etc.
         *-------------------------------------------------------------------*/
-       mtdcr (uic0sr, 0xffffffff);     /* clear all */
-       mtdcr (uic0er, 0x00000000);     /* disable all */
-       mtdcr (uic0cr, 0x00000009);     /* SMI & UIC1 crit are critical */
-       mtdcr (uic0pr, 0xfffffe13);     /* per ref-board manual */
-       mtdcr (uic0tr, 0x01c00008);     /* per ref-board manual */
-       mtdcr (uic0vr, 0x00000001);     /* int31 highest, base=0x000 */
-       mtdcr (uic0sr, 0xffffffff);     /* clear all */
-
+       /*
+        * Because of the interrupt handling rework to handle 440GX interrupts
+        * with the common code, we needed to change names of the UIC registers.
+        * Here the new relationship:
+        *
+        * U-Boot name  440GX name
+        * -----------------------
+        * UIC0         UICB0
+        * UIC1         UIC0
+        * UIC2         UIC1
+        * UIC3         UIC2
+        */
        mtdcr (uic1sr, 0xffffffff);     /* clear all */
        mtdcr (uic1er, 0x00000000);     /* disable all */
-       mtdcr (uic1cr, 0x00000000);     /* all non-critical */
-       mtdcr (uic1pr, 0xffffe0ff);     /* per ref-board manual */
-       mtdcr (uic1tr, 0x00ffc000);     /* per ref-board manual */
+       mtdcr (uic1cr, 0x00000009);     /* SMI & UIC1 crit are critical */
+       mtdcr (uic1pr, 0xfffffe13);     /* per ref-board manual */
+       mtdcr (uic1tr, 0x01c00008);     /* per ref-board manual */
        mtdcr (uic1vr, 0x00000001);     /* int31 highest, base=0x000 */
        mtdcr (uic1sr, 0xffffffff);     /* clear all */
 
        mtdcr (uic2sr, 0xffffffff);     /* clear all */
        mtdcr (uic2er, 0x00000000);     /* disable all */
        mtdcr (uic2cr, 0x00000000);     /* all non-critical */
-       mtdcr (uic2pr, 0xffffffff);     /* per ref-board manual */
-       mtdcr (uic2tr, 0x00ff8c0f);     /* per ref-board manual */
+       mtdcr (uic2pr, 0xffffe0ff);     /* per ref-board manual */
+       mtdcr (uic2tr, 0x00ffc000);     /* per ref-board manual */
        mtdcr (uic2vr, 0x00000001);     /* int31 highest, base=0x000 */
        mtdcr (uic2sr, 0xffffffff);     /* clear all */
 
-       mtdcr (uicb0sr, 0xfc000000); /* clear all */
-       mtdcr (uicb0er, 0x00000000); /* disable all */
-       mtdcr (uicb0cr, 0x00000000); /* all non-critical */
-       mtdcr (uicb0pr, 0xfc000000); /* */
-       mtdcr (uicb0tr, 0x00000000); /* */
-       mtdcr (uicb0vr, 0x00000001); /* */
-       mfsdr (sdr_mfr, mfr);
+       mtdcr (uic3sr, 0xffffffff);     /* clear all */
+       mtdcr (uic3er, 0x00000000);     /* disable all */
+       mtdcr (uic3cr, 0x00000000);     /* all non-critical */
+       mtdcr (uic3pr, 0xffffffff);     /* per ref-board manual */
+       mtdcr (uic3tr, 0x00ff8c0f);     /* per ref-board manual */
+       mtdcr (uic3vr, 0x00000001);     /* int31 highest, base=0x000 */
+       mtdcr (uic3sr, 0xffffffff);     /* clear all */
+
+       mtdcr (uic0sr, 0xfc000000); /* clear all */
+       mtdcr (uic0er, 0x00000000); /* disable all */
+       mtdcr (uic0cr, 0x00000000); /* all non-critical */
+       mtdcr (uic0pr, 0xfc000000); /* */
+       mtdcr (uic0tr, 0x00000000); /* */
+       mtdcr (uic0vr, 0x00000001); /* */
+       mfsdr (SDR0_MFR, mfr);
        mfr &= ~SDR0_MFR_ECS_MASK;
-/*     mtsdr(sdr_mfr, mfr); */
+/*     mtsdr(SDR0_MFR, mfr); */
        fpga_init();
 
        return 0;
@@ -199,12 +213,12 @@ int checkboard (void)
 }
 
 
-long int initdram (int board_type)
+phys_size_t initdram (int board_type)
 {
        long dram_size = 0;
 
 #if defined(CONFIG_SPD_EEPROM)
-       dram_size = spd_sdram (0);
+       dram_size = spd_sdram ();
 #else
        dram_size = fixed_sdram ();
 #endif
@@ -212,36 +226,6 @@ long int initdram (int board_type)
 }
 
 
-#if defined(CFG_DRAM_TEST)
-int testdram (void)
-{
-       uint *pstart = (uint *) 0x00000000;
-       uint *pend = (uint *) 0x08000000;
-       uint *p;
-
-       for (p = pstart; p < pend; p++)
-               *p = 0xaaaaaaaa;
-
-       for (p = pstart; p < pend; p++) {
-               if (*p != 0xaaaaaaaa) {
-                       printf ("SDRAM test fails at: %08x\n", (uint) p);
-                       return 1;
-               }
-       }
-
-       for (p = pstart; p < pend; p++)
-               *p = 0x55555555;
-
-       for (p = pstart; p < pend; p++) {
-               if (*p != 0x55555555) {
-                       printf ("SDRAM test fails at: %08x\n", (uint) p);
-                       return 1;
-               }
-       }
-       return 0;
-}
-#endif
-
 #if !defined(CONFIG_SPD_EEPROM)
 /*************************************************************************
  *  fixed sdram init -- doesn't use serial presence detect.
@@ -304,7 +288,7 @@ long int fixed_sdram (void)
  *     certain pre-initialization actions.
  *
  ************************************************************************/
-#if defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT)
+#if defined(CONFIG_PCI)
 int pci_pre_init(struct pci_controller * hose )
 {
        unsigned long strap;
@@ -313,7 +297,7 @@ int pci_pre_init(struct pci_controller * hose )
         *      The ocotea board is always configured as the host & requires the
         *      PCI arbiter to be enabled.
         *--------------------------------------------------------------------------*/
-       mfsdr(sdr_sdstp1, strap);
+       mfsdr(SDR0_SDSTP1, strap);
        if( (strap & SDR0_SDSTP1_PAE_MASK) == 0 ){
                printf("PCI: SDR0_STRP1[%08lX] - PCI Arbiter disabled.\n",strap);
                return 0;
@@ -321,7 +305,7 @@ int pci_pre_init(struct pci_controller * hose )
 
        return 1;
 }
-#endif /* defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT) */
+#endif /* defined(CONFIG_PCI) */
 
 /*************************************************************************
  *  pci_target_init
@@ -331,11 +315,9 @@ int pci_pre_init(struct pci_controller * hose )
  *     may not be sufficient for a given board.
  *
  ************************************************************************/
-#if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
+#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT)
 void pci_target_init(struct pci_controller * hose )
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        /*--------------------------------------------------------------------------+
         * Disable everything
         *--------------------------------------------------------------------------*/
@@ -348,7 +330,7 @@ void pci_target_init(struct pci_controller * hose )
         * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440 strapping
         * options to not support sizes such as 128/256 MB.
         *--------------------------------------------------------------------------*/
-       out32r( PCIX0_PIM0LAL, CFG_SDRAM_BASE );
+       out32r( PCIX0_PIM0LAL, CONFIG_SYS_SDRAM_BASE );
        out32r( PCIX0_PIM0LAH, 0 );
        out32r( PCIX0_PIM0SA, ~(gd->ram_size - 1) | 1 );
 
@@ -357,12 +339,12 @@ void pci_target_init(struct pci_controller * hose )
        /*--------------------------------------------------------------------------+
         * Program the board's subsystem id/vendor id
         *--------------------------------------------------------------------------*/
-       out16r( PCIX0_SBSYSVID, CFG_PCI_SUBSYS_VENDORID );
-       out16r( PCIX0_SBSYSID, CFG_PCI_SUBSYS_DEVICEID );
+       out16r( PCIX0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID );
+       out16r( PCIX0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID );
 
        out16r( PCIX0_CMD, in16r(PCIX0_CMD) | PCI_COMMAND_MEMORY );
 }
-#endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
+#endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */
 
 
 /*************************************************************************
@@ -397,8 +379,8 @@ void fpga_init(void)
        unsigned long sdr0_cust0;
        unsigned long pvr;
 
-       mfsdr (sdr_pfc0, sdr0_pfc0);
-       mfsdr (sdr_pfc1, sdr0_pfc1);
+       mfsdr (SDR0_PFC0, sdr0_pfc0);
+       mfsdr (SDR0_PFC1, sdr0_pfc1);
        group = SDR0_PFC1_EPS_DECODE(sdr0_pfc1);
        pvr = get_pvr ();
 
@@ -408,8 +390,8 @@ void fpga_init(void)
                sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_EMS;
                out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) |
                     FPGA_REG2_EXT_INTFACE_ENABLE);
-               mtsdr (sdr_pfc0, sdr0_pfc0);
-               mtsdr (sdr_pfc1, sdr0_pfc1);
+               mtsdr (SDR0_PFC0, sdr0_pfc0);
+               mtsdr (SDR0_PFC1, sdr0_pfc1);
        } else {
                sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_TRE_MASK) | SDR0_PFC0_TRE_ENABLE;
                switch (group)
@@ -421,8 +403,8 @@ void fpga_init(void)
                        out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) |
                             FPGA_REG2_EXT_INTFACE_ENABLE);
                        sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_EMS;
-                       mtsdr (sdr_pfc0, sdr0_pfc0);
-                       mtsdr (sdr_pfc1, sdr0_pfc1);
+                       mtsdr (SDR0_PFC0, sdr0_pfc0);
+                       mtsdr (SDR0_PFC1, sdr0_pfc1);
                        break;
                case 3:
                case 4:
@@ -430,8 +412,8 @@ void fpga_init(void)
                case 6:
                        /* CPU trace B - Over EBMI */
                        sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_CPUTRACE;
-                       mtsdr (sdr_pfc0, sdr0_pfc0);
-                       mtsdr (sdr_pfc1, sdr0_pfc1);
+                       mtsdr (SDR0_PFC0, sdr0_pfc0);
+                       mtsdr (SDR0_PFC1, sdr0_pfc1);
                        out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) |
                             FPGA_REG2_EXT_INTFACE_DISABLE);
                        break;
@@ -439,8 +421,8 @@ void fpga_init(void)
        }
 
        /* Initialize the ethernet specific functions in the fpga */
-       mfsdr(sdr_pfc1, sdr0_pfc1);
-       mfsdr(sdr_cust0, sdr0_cust0);
+       mfsdr(SDR0_PFC1, sdr0_pfc1);
+       mfsdr(SDR0_CUST0, sdr0_cust0);
        if ( (SDR0_PFC1_EPS_DECODE(sdr0_pfc1) == 4) &&
            ((SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_GMII) ||
             (SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_TBI)))