ppc4xx: Add PPC405EX support
[oweals/u-boot.git] / cpu / ppc4xx / speed.c
index cbd7b2455530a3d1d9f3b5b5e97c12a99f4f17f9..750b0958762610b5eade387baf4aa6c2f7f4cb94 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000
+ * (C) Copyright 2000-2007
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
 #include <ppc4xx.h>
 #include <asm/processor.h>
 
-/* ------------------------------------------------------------------------- */
+DECLARE_GLOBAL_DATA_PTR;
 
 #define ONE_BILLION        1000000000
-
+#ifdef DEBUG
+#define DEBUGF(fmt,args...) printf(fmt ,##args)
+#else
+#define DEBUGF(fmt,args...)
+#endif
 
 #if defined(CONFIG_405GP) || defined(CONFIG_405CR)
 
@@ -195,7 +199,8 @@ ulong get_PCI_freq (void)
 
 #elif defined(CONFIG_440)
 
-#if  defined(CONFIG_440EP) || defined(CONFIG_440GR)
+#if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
+    defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
 void get_sys_info (sys_info_t *sysInfo)
 {
        unsigned long temp;
@@ -258,7 +263,7 @@ void get_sys_info (sys_info_t *sysInfo)
        sysInfo->freqProcessor = sysInfo->freqVCOMhz/sysInfo->pllFwdDivA;
        sysInfo->freqPLB = sysInfo->freqVCOMhz/sysInfo->pllFwdDivB/prbdv0;
        sysInfo->freqOPB = sysInfo->freqPLB/sysInfo->pllOpbDiv;
-       sysInfo->freqEPB = sysInfo->freqPLB/sysInfo->pllExtBusDiv;
+       sysInfo->freqEBC = sysInfo->freqPLB/sysInfo->pllExtBusDiv;
        sysInfo->freqPCI = sysInfo->freqPLB/sysInfo->pllPciDiv;
 
        /* Figure which timer source to use */
@@ -283,7 +288,7 @@ ulong get_PCI_freq (void)
        return sys_info.freqPCI;
 }
 
-#elif !defined(CONFIG_440GX)
+#elif !defined(CONFIG_440GX) && !defined(CONFIG_440SP) && !defined(CONFIG_440SPE)
 void get_sys_info (sys_info_t * sysInfo)
 {
        unsigned long strp0;
@@ -312,7 +317,7 @@ void get_sys_info (sys_info_t * sysInfo)
        if( get_pvr() == PVR_440GP_RB ) /* Rev B divs an extra 2 -- geez! */
                sysInfo->freqPLB >>= 1;
        sysInfo->freqOPB = sysInfo->freqPLB/sysInfo->pllOpbDiv;
-       sysInfo->freqEPB = sysInfo->freqOPB/sysInfo->pllExtBusDiv;
+       sysInfo->freqEBC = sysInfo->freqOPB/sysInfo->pllExtBusDiv;
 
 }
 #else
@@ -326,6 +331,26 @@ void get_sys_info (sys_info_t * sysInfo)
        unsigned long m;
        unsigned long prbdv0;
 
+#if defined(CONFIG_YUCCA)
+       unsigned long sys_freq;
+       unsigned long sys_per=0;
+       unsigned long msr;
+       unsigned long pci_clock_per;
+       unsigned long sdr_ddrpll;
+
+       /*-------------------------------------------------------------------------+
+        | Get the system clock period.
+        +-------------------------------------------------------------------------*/
+       sys_per = determine_sysper();
+
+       msr = (mfmsr () & ~(MSR_EE));   /* disable interrupts */
+
+       /*-------------------------------------------------------------------------+
+        | Calculate the system clock speed from the period.
+        +-------------------------------------------------------------------------*/
+       sys_freq = (ONE_BILLION / sys_per) * 1000;
+#endif
+
        /* Extract configured divisors */
        mfsdr( sdr_sdstp0,strp0 );
        mfsdr( sdr_sdstp1,strp1 );
@@ -360,12 +385,237 @@ void get_sys_info (sys_info_t * sysInfo)
                m = sysInfo->pllExtBusDiv * sysInfo->pllOpbDiv * sysInfo->pllFwdDivB;
 
        /* Now calculate the individual clocks */
-       sysInfo->freqVCOMhz = (m * CONFIG_SYS_CLK_FREQ) + (m>>1);
+#if defined(CONFIG_YUCCA)
+       sysInfo->freqVCOMhz = (m * sys_freq) ;
+#else
+       sysInfo->freqVCOMhz = (m * CONFIG_SYS_CLK_FREQ) + (m >> 1);
+#endif
        sysInfo->freqProcessor = sysInfo->freqVCOMhz/sysInfo->pllFwdDivA;
        sysInfo->freqPLB = sysInfo->freqVCOMhz/sysInfo->pllFwdDivB/prbdv0;
        sysInfo->freqOPB = sysInfo->freqPLB/sysInfo->pllOpbDiv;
-       sysInfo->freqEPB = sysInfo->freqOPB/sysInfo->pllExtBusDiv;
+       sysInfo->freqEBC = sysInfo->freqOPB/sysInfo->pllExtBusDiv;
+
+#if defined(CONFIG_YUCCA)
+       /* Determine PCI Clock Period */
+       pci_clock_per = determine_pci_clock_per();
+       sysInfo->freqPCI = (ONE_BILLION/pci_clock_per) * 1000;
+       mfsdr(sdr_ddr0, sdr_ddrpll);
+       sysInfo->freqDDR = ((sysInfo->freqPLB) * SDR0_DDR0_DDRM_DECODE(sdr_ddrpll));
+#endif
+
 
+}
+
+#endif
+
+#if defined(CONFIG_YUCCA)
+unsigned long determine_sysper(void)
+{
+       unsigned int fpga_clocking_reg;
+       unsigned int master_clock_selection;
+       unsigned long master_clock_per = 0;
+       unsigned long fb_div_selection;
+       unsigned int vco_div_reg_value;
+       unsigned long vco_div_selection;
+       unsigned long sys_per = 0;
+       int extClkVal;
+
+       /*-------------------------------------------------------------------------+
+        | Read FPGA reg 0 and reg 1 to get FPGA reg information
+        +-------------------------------------------------------------------------*/
+       fpga_clocking_reg = in16(FPGA_REG16);
+
+
+       /* Determine Master Clock Source Selection */
+       master_clock_selection = fpga_clocking_reg & FPGA_REG16_MASTER_CLK_MASK;
+
+       switch(master_clock_selection) {
+               case FPGA_REG16_MASTER_CLK_66_66:
+                       master_clock_per = PERIOD_66_66MHZ;
+                       break;
+               case FPGA_REG16_MASTER_CLK_50:
+                       master_clock_per = PERIOD_50_00MHZ;
+                       break;
+               case FPGA_REG16_MASTER_CLK_33_33:
+                       master_clock_per = PERIOD_33_33MHZ;
+                       break;
+               case FPGA_REG16_MASTER_CLK_25:
+                       master_clock_per = PERIOD_25_00MHZ;
+                       break;
+               case FPGA_REG16_MASTER_CLK_EXT:
+                       if ((extClkVal==EXTCLK_33_33)
+                                       && (extClkVal==EXTCLK_50)
+                                       && (extClkVal==EXTCLK_66_66)
+                                       && (extClkVal==EXTCLK_83)) {
+                               /* calculate master clock period from external clock value */
+                               master_clock_per=(ONE_BILLION/extClkVal) * 1000;
+                       } else {
+                               /* Unsupported */
+                               DEBUGF ("%s[%d] *** master clock selection failed ***\n", __FUNCTION__,__LINE__);
+                               hang();
+                       }
+                       break;
+               default:
+                       /* Unsupported */
+                       DEBUGF ("%s[%d] *** master clock selection failed ***\n", __FUNCTION__,__LINE__);
+                       hang();
+                       break;
+       }
+
+       /* Determine FB divisors values */
+       if ((fpga_clocking_reg & FPGA_REG16_FB1_DIV_MASK) == FPGA_REG16_FB1_DIV_LOW) {
+               if ((fpga_clocking_reg & FPGA_REG16_FB2_DIV_MASK) == FPGA_REG16_FB2_DIV_LOW)
+                       fb_div_selection = FPGA_FB_DIV_6;
+               else
+                       fb_div_selection = FPGA_FB_DIV_12;
+       } else {
+               if ((fpga_clocking_reg & FPGA_REG16_FB2_DIV_MASK) == FPGA_REG16_FB2_DIV_LOW)
+                       fb_div_selection = FPGA_FB_DIV_10;
+               else
+                       fb_div_selection = FPGA_FB_DIV_20;
+       }
+
+       /* Determine VCO divisors values */
+       vco_div_reg_value = fpga_clocking_reg & FPGA_REG16_VCO_DIV_MASK;
+
+       switch(vco_div_reg_value) {
+               case FPGA_REG16_VCO_DIV_4:
+                       vco_div_selection = FPGA_VCO_DIV_4;
+                       break;
+               case FPGA_REG16_VCO_DIV_6:
+                       vco_div_selection = FPGA_VCO_DIV_6;
+                       break;
+               case FPGA_REG16_VCO_DIV_8:
+                       vco_div_selection = FPGA_VCO_DIV_8;
+                       break;
+               case FPGA_REG16_VCO_DIV_10:
+               default:
+                       vco_div_selection = FPGA_VCO_DIV_10;
+                       break;
+       }
+
+       if (master_clock_selection == FPGA_REG16_MASTER_CLK_EXT) {
+               switch(master_clock_per) {
+                       case PERIOD_25_00MHZ:
+                               if (fb_div_selection == FPGA_FB_DIV_12) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_4)
+                                               sys_per = PERIOD_75_00MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_6)
+                                               sys_per = PERIOD_50_00MHZ;
+                               }
+                               break;
+                       case PERIOD_33_33MHZ:
+                               if (fb_div_selection == FPGA_FB_DIV_6) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_4)
+                                               sys_per = PERIOD_50_00MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_6)
+                                               sys_per = PERIOD_33_33MHZ;
+                               }
+                               if (fb_div_selection == FPGA_FB_DIV_10) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_4)
+                                               sys_per = PERIOD_83_33MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_10)
+                                               sys_per = PERIOD_33_33MHZ;
+                               }
+                               if (fb_div_selection == FPGA_FB_DIV_12) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_4)
+                                               sys_per = PERIOD_100_00MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_6)
+                                               sys_per = PERIOD_66_66MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_8)
+                                               sys_per = PERIOD_50_00MHZ;
+                               }
+                               break;
+                       case PERIOD_50_00MHZ:
+                               if (fb_div_selection == FPGA_FB_DIV_6) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_4)
+                                               sys_per = PERIOD_75_00MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_6)
+                                               sys_per = PERIOD_50_00MHZ;
+                               }
+                               if (fb_div_selection == FPGA_FB_DIV_10) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_6)
+                                               sys_per = PERIOD_83_33MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_10)
+                                               sys_per = PERIOD_50_00MHZ;
+                               }
+                               if (fb_div_selection == FPGA_FB_DIV_12) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_6)
+                                               sys_per = PERIOD_100_00MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_8)
+                                               sys_per = PERIOD_75_00MHZ;
+                               }
+                               break;
+                       case PERIOD_66_66MHZ:
+                               if (fb_div_selection == FPGA_FB_DIV_6) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_4)
+                                               sys_per = PERIOD_100_00MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_6)
+                                               sys_per = PERIOD_66_66MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_8)
+                                               sys_per = PERIOD_50_00MHZ;
+                               }
+                               if (fb_div_selection == FPGA_FB_DIV_10) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_8)
+                                               sys_per = PERIOD_83_33MHZ;
+                                       if (vco_div_selection == FPGA_VCO_DIV_10)
+                                               sys_per = PERIOD_66_66MHZ;
+                               }
+                               if (fb_div_selection == FPGA_FB_DIV_12) {
+                                       if (vco_div_selection == FPGA_VCO_DIV_8)
+                                               sys_per = PERIOD_100_00MHZ;
+                               }
+                               break;
+                       default:
+                               break;
+               }
+
+               if (sys_per == 0) {
+                       /* Other combinations are not supported */
+                       DEBUGF ("%s[%d] *** sys period compute failed ***\n", __FUNCTION__,__LINE__);
+                       hang();
+               }
+       } else {
+               /* calcul system clock without cheking */
+               /* if engineering option clock no check is selected */
+               /* sys_per = master_clock_per * vco_div_selection / fb_div_selection */
+               sys_per = (master_clock_per/fb_div_selection) * vco_div_selection;
+       }
+
+       return(sys_per);
+}
+
+/*-------------------------------------------------------------------------+
+| determine_pci_clock_per.
++-------------------------------------------------------------------------*/
+unsigned long determine_pci_clock_per(void)
+{
+       unsigned long pci_clock_selection,  pci_period;
+
+       /*-------------------------------------------------------------------------+
+        | Read FPGA reg 6 to get PCI 0 FPGA reg information
+        +-------------------------------------------------------------------------*/
+       pci_clock_selection = in16(FPGA_REG16); /* was reg6 averifier */
+
+
+       pci_clock_selection = pci_clock_selection & FPGA_REG16_PCI0_CLK_MASK;
+
+       switch (pci_clock_selection) {
+               case FPGA_REG16_PCI0_CLK_133_33:
+                       pci_period = PERIOD_133_33MHZ;
+                       break;
+               case FPGA_REG16_PCI0_CLK_100:
+                       pci_period = PERIOD_100_00MHZ;
+                       break;
+               case FPGA_REG16_PCI0_CLK_66_66:
+                       pci_period = PERIOD_66_66MHZ;
+                       break;
+               default:
+                       pci_period = PERIOD_33_33MHZ;;
+                       break;
+       }
+
+       return(pci_period);
 }
 #endif
 
@@ -483,6 +733,8 @@ void get_sys_info (PPC405_SYS_INFO * sysInfo)
         * Determine PLB clock frequency
         */
        sysInfo->freqPLB = sysInfo->freqProcessor / sysInfo->pllPlbDiv;
+
+       sysInfo->freqEBC = sysInfo->freqPLB / sysInfo->pllExtBusDiv;
 }
 
 
@@ -517,13 +769,285 @@ ulong get_PCI_freq (void)
        return val;
 }
 
+#elif defined(CONFIG_405EZ)
+void get_sys_info (PPC405_SYS_INFO * sysInfo)
+{
+       unsigned long cpr_plld;
+       unsigned long cpr_pllc;
+       unsigned long cpr_primad;
+       unsigned long sysClkPeriodPs = ONE_BILLION / (CONFIG_SYS_CLK_FREQ/1000);
+       unsigned long primad_cpudv;
+       unsigned long m;
+
+       /*
+        * Read PLL Mode registers
+        */
+       mfcpr(cprplld, cpr_plld);
+       mfcpr(cprpllc, cpr_pllc);
+
+       /*
+        * Determine forward divider A
+        */
+       sysInfo->pllFwdDiv = ((cpr_plld & PLLD_FWDVA_MASK) >> 16);
+
+       /*
+        * Determine forward divider B
+        */
+       sysInfo->pllFwdDivB = ((cpr_plld & PLLD_FWDVB_MASK) >> 8);
+       if (sysInfo->pllFwdDivB == 0)
+               sysInfo->pllFwdDivB = 8;
+
+       /*
+        * Determine FBK_DIV.
+        */
+       sysInfo->pllFbkDiv = ((cpr_plld & PLLD_FBDV_MASK) >> 24);
+       if (sysInfo->pllFbkDiv == 0)
+               sysInfo->pllFbkDiv = 256;
+
+       /*
+        * Read CPR_PRIMAD register
+        */
+       mfcpr(cprprimad, cpr_primad);
+       /*
+        * Determine PLB_DIV.
+        */
+       sysInfo->pllPlbDiv = ((cpr_primad & PRIMAD_PLBDV_MASK) >> 16);
+       if (sysInfo->pllPlbDiv == 0)
+               sysInfo->pllPlbDiv = 16;
+
+       /*
+        * Determine EXTBUS_DIV.
+        */
+       sysInfo->pllExtBusDiv = (cpr_primad & PRIMAD_EBCDV_MASK);
+       if (sysInfo->pllExtBusDiv == 0)
+               sysInfo->pllExtBusDiv = 16;
+
+       /*
+        * Determine OPB_DIV.
+        */
+       sysInfo->pllOpbDiv = ((cpr_primad & PRIMAD_OPBDV_MASK) >> 8);
+       if (sysInfo->pllOpbDiv == 0)
+               sysInfo->pllOpbDiv = 16;
+
+       /*
+        * Determine the M factor
+        */
+       if (cpr_pllc & PLLC_SRC_MASK)
+               m = sysInfo->pllFbkDiv * sysInfo->pllFwdDivB;
+       else
+               m = sysInfo->pllFbkDiv * sysInfo->pllFwdDiv;
+
+       /*
+        * Determine VCO clock frequency
+        */
+       sysInfo->freqVCOHz = (1000000000000LL * (unsigned long long)m) /
+               (unsigned long long)sysClkPeriodPs;
+
+       /*
+        * Determine CPU clock frequency
+        */
+       primad_cpudv = ((cpr_primad & PRIMAD_CPUDV_MASK) >> 24);
+       if (primad_cpudv == 0)
+               primad_cpudv = 16;
+
+       sysInfo->freqProcessor = (CONFIG_SYS_CLK_FREQ * m) /
+               sysInfo->pllFwdDiv / primad_cpudv;
+
+       /*
+        * Determine PLB clock frequency
+        */
+       sysInfo->freqPLB = (CONFIG_SYS_CLK_FREQ * m) /
+               sysInfo->pllFwdDiv / sysInfo->pllPlbDiv;
+
+       sysInfo->freqEBC = (CONFIG_SYS_CLK_FREQ * sysInfo->pllFbkDiv) /
+               sysInfo->pllExtBusDiv;
+}
+
+/********************************************
+ * get_OPB_freq
+ * return OPB bus freq in Hz
+ *********************************************/
+ulong get_OPB_freq (void)
+{
+       ulong val = 0;
+
+       PPC405_SYS_INFO sys_info;
+
+       get_sys_info (&sys_info);
+       val = (CONFIG_SYS_CLK_FREQ * sys_info.pllFbkDiv) / sys_info.pllOpbDiv;
+
+       return val;
+}
+
+#elif defined(CONFIG_405EX)
+
+/*
+ * TODO: We need to get the CPR registers and calculate these values correctly!!!!
+ *   We need the specs!!!!
+ */
+static unsigned char get_fbdv(unsigned char index)
+{
+       unsigned char ret = 0;
+       /* This is table should be 256 bytes.
+        * Only take first 52 values.
+        */
+       unsigned char fbdv_tb[] = {
+               0x00, 0xff, 0x7f, 0xfd,
+               0x7a, 0xf5, 0x6a, 0xd5,
+               0x2a, 0xd4, 0x29, 0xd3,
+               0x26, 0xcc, 0x19, 0xb3,
+               0x67, 0xce, 0x1d, 0xbb,
+               0x77, 0xee, 0x5d, 0xba,
+               0x74, 0xe9, 0x52, 0xa5,
+               0x4b, 0x96, 0x2c, 0xd8,
+               0x31, 0xe3, 0x46, 0x8d,
+               0x1b, 0xb7, 0x6f, 0xde,
+               0x3d, 0xfb, 0x76, 0xed,
+               0x5a, 0xb5, 0x6b, 0xd6,
+               0x2d, 0xdb, 0x36, 0xec,
+
+       };
+
+       if ((index & 0x7f) == 0)
+               return 1;
+       while (ret < sizeof (fbdv_tb)) {
+               if (fbdv_tb[ret] == index)
+                       break;
+               ret++;
+       }
+       ret++;
+
+       return ret;
+}
+
+#define PLL_FBK_PLL_LOCAL      0
+#define PLL_FBK_CPU            1
+#define PLL_FBK_PERCLK         5
+
+void get_sys_info (sys_info_t * sysInfo)
+{
+       unsigned long sysClkPeriodPs = ONE_BILLION / (CONFIG_SYS_CLK_FREQ / 1000);
+       unsigned long m = 1;
+       unsigned int  tmp;
+       unsigned char fwdva[16] = {
+               1, 2, 14, 9, 4, 11, 16, 13,
+               12, 5, 6, 15, 10, 7, 8, 3,
+       };
+       unsigned char sel, cpudv0, plb2xDiv;
+
+       mfcpr(cpr0_plld, tmp);
+
+       /*
+        * Determine forward divider A
+        */
+       sysInfo->pllFwdDiv = fwdva[((tmp >> 16) & 0x0f)];       /* FWDVA */
+
+       /*
+        * Determine FBK_DIV.
+        */
+       sysInfo->pllFbkDiv = get_fbdv(((tmp >> 24) & 0x0ff)); /* FBDV */
+
+       /*
+        * Determine PLBDV0
+        */
+       sysInfo->pllPlbDiv = 2;
+
+       /*
+        * Determine PERDV0
+        */
+       mfcpr(cpr0_perd, tmp);
+       tmp = (tmp >> 24) & 0x03;
+       sysInfo->pllExtBusDiv = (tmp == 0) ? 4 : tmp;
+
+       /*
+        * Determine OPBDV0
+        */
+       mfcpr(cpr0_opbd, tmp);
+       tmp = (tmp >> 24) & 0x03;
+       sysInfo->pllOpbDiv = (tmp == 0) ? 4 : tmp;
+
+       /* Determine PLB2XDV0 */
+       mfcpr(cpr0_plbd, tmp);
+       tmp = (tmp >> 16) & 0x07;
+       plb2xDiv = (tmp == 0) ? 8 : tmp;
+
+       /* Determine CPUDV0 */
+       mfcpr(cpr0_cpud, tmp);
+       tmp = (tmp >> 24) & 0x07;
+       cpudv0 = (tmp == 0) ? 8 : tmp;
+
+       /* Determine SEL(5:7) in CPR0_PLLC */
+       mfcpr(cpr0_pllc, tmp);
+       sel = (tmp >> 24) & 0x07;
+
+       /*
+        * Determine the M factor
+        * PLL local: M = FBDV
+        * CPU clock: M = FBDV * FWDVA * CPUDV0
+        * PerClk       : M = FBDV * FWDVA * PLB2XDV0 * PLBDV0(2) * OPBDV0 * PERDV0
+        *
+        */
+       switch (sel) {
+       case PLL_FBK_CPU:
+               m = sysInfo->pllFwdDiv * cpudv0;
+               break;
+       case PLL_FBK_PERCLK:
+               m = sysInfo->pllFwdDiv * plb2xDiv * 2
+                       * sysInfo->pllOpbDiv * sysInfo->pllExtBusDiv;
+               break;
+       case PLL_FBK_PLL_LOCAL:
+               break;
+       default:
+               printf("%s unknown m\n", __FUNCTION__);
+               return;
+
+       }
+       m *= sysInfo->pllFbkDiv;
+
+       /*
+        * Determine VCO clock frequency
+        */
+       sysInfo->freqVCOHz = (1000000000000LL * (unsigned long long)m) /
+               (unsigned long long)sysClkPeriodPs;
+
+       /*
+        * Determine CPU clock frequency
+        */
+       sysInfo->freqProcessor = sysInfo->freqVCOHz / (sysInfo->pllFwdDiv * cpudv0);
+
+       /*
+        * Determine PLB clock frequency, ddr1x should be the same
+        */
+       sysInfo->freqPLB = sysInfo->freqVCOHz / (sysInfo->pllFwdDiv * plb2xDiv * 2);
+       sysInfo->freqOPB = sysInfo->freqPLB/sysInfo->pllOpbDiv;
+       sysInfo->freqDDR = sysInfo->freqPLB;
+       sysInfo->freqEBC = sysInfo->freqOPB / sysInfo->pllExtBusDiv;
+}
+
+/********************************************
+ * get_OPB_freq
+ * return OPB bus freq in Hz
+ *********************************************/
+ulong get_OPB_freq (void)
+{
+       ulong val = 0;
+
+       PPC405_SYS_INFO sys_info;
+
+       get_sys_info (&sys_info);
+       val = sys_info.freqPLB / sys_info.pllOpbDiv;
+
+       return val;
+}
+
 #endif
 
 int get_clocks (void)
 {
-#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_440) || defined(CONFIG_405) || defined(CONFIG_405EP)
-       DECLARE_GLOBAL_DATA_PTR;
-
+#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
+    defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
+    defined(CONFIG_405EX) || defined(CONFIG_405) || \
+    defined(CONFIG_440)
        sys_info_t sys_info;
 
        get_sys_info (&sys_info);
@@ -533,8 +1057,6 @@ int get_clocks (void)
 #endif /* defined(CONFIG_405GP) || defined(CONFIG_405CR) */
 
 #ifdef CONFIG_IOP480
-       DECLARE_GLOBAL_DATA_PTR;
-
        gd->cpu_clk = 66000000;
        gd->bus_clk = 66000000;
 #endif
@@ -550,7 +1072,10 @@ ulong get_bus_freq (ulong dummy)
 {
        ulong val;
 
-#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405) || defined(CONFIG_440) || defined(CONFIG_405EP)
+#if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
+    defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
+    defined(CONFIG_405EX) || defined(CONFIG_405) || \
+    defined(CONFIG_440)
        sys_info_t sys_info;
 
        get_sys_info (&sys_info);