Merge branch 'master' of git://www.denx.de/git/u-boot-ppc4xx
[platform/kernel/u-boot.git] / cpu / mpc85xx / speed.c
index 12359a2..952f30c 100644 (file)
@@ -35,8 +35,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 void get_sys_info (sys_info_t * sysInfo)
 {
-       volatile immap_t    *immap = (immap_t *)CFG_IMMR;
-       volatile ccsr_gur_t *gur = &immap->im_gur;
+       volatile ccsr_gur_t *gur = (void *)(CFG_MPC85xx_GUTS_ADDR);
        uint plat_ratio,e500_ratio,half_freqSystemBus;
 
        plat_ratio = (gur->porpllsr) & 0x0000003e;
@@ -49,6 +48,15 @@ void get_sys_info (sys_info_t * sysInfo)
         * overflow for processor speeds above 2GHz */
        half_freqSystemBus = sysInfo->freqSystemBus/2;
        sysInfo->freqProcessor = e500_ratio*half_freqSystemBus;
+       sysInfo->freqDDRBus = sysInfo->freqSystemBus;
+
+#ifdef CONFIG_DDR_CLK_FREQ
+       {
+               u32 ddr_ratio = ((gur->porpllsr) & 0x00003e00) >> 9;
+               if (ddr_ratio != 0x7)
+                       sysInfo->freqDDRBus = ddr_ratio * CONFIG_DDR_CLK_FREQ;
+       }
+#endif
 }
 
 
@@ -56,17 +64,20 @@ int get_clocks (void)
 {
        sys_info_t sys_info;
 #if defined(CONFIG_CPM2)
-       volatile immap_t *immap = (immap_t *) CFG_IMMR;
+       volatile ccsr_cpm_t *cpm = (ccsr_cpm_t *)CFG_MPC85xx_CPM_ADDR;
        uint sccr, dfbrg;
 
        /* set VCO = 4 * BRG */
-       immap->im_cpm.im_cpm_intctl.sccr &= 0xfffffffc;
-       sccr = immap->im_cpm.im_cpm_intctl.sccr;
+       cpm->im_cpm_intctl.sccr &= 0xfffffffc;
+       sccr = cpm->im_cpm_intctl.sccr;
        dfbrg = (sccr & SCCR_DFBRG_MSK) >> SCCR_DFBRG_SHIFT;
 #endif
        get_sys_info (&sys_info);
        gd->cpu_clk = sys_info.freqProcessor;
        gd->bus_clk = sys_info.freqSystemBus;
+       gd->i2c1_clk = sys_info.freqSystemBus;
+       gd->i2c2_clk = sys_info.freqSystemBus;
+
 #if defined(CONFIG_CPM2)
        gd->vco_out = 2*sys_info.freqSystemBus;
        gd->cpm_clk = gd->vco_out / 2;
@@ -94,3 +105,19 @@ ulong get_bus_freq (ulong dummy)
 
        return val;
 }
+
+/********************************************
+ * get_ddr_freq
+ * return ddr bus freq in Hz
+ *********************************************/
+ulong get_ddr_freq (ulong dummy)
+{
+       ulong val;
+
+       sys_info_t sys_info;
+
+       get_sys_info (&sys_info);
+       val = sys_info.freqDDRBus;
+
+       return val;
+}