]> rtime.felk.cvut.cz Git - can-eth-gw-linux.git/commitdiff
ARM: OMAP2xxx: clock: move virt_prcm_set code into clkt2xxx_virt_prcm_set.c
authorPaul Walmsley <paul@pwsan.com>
Tue, 30 Oct 2012 02:56:00 +0000 (20:56 -0600)
committerPaul Walmsley <paul@pwsan.com>
Thu, 8 Nov 2012 19:33:08 +0000 (12:33 -0700)
Collect all of the virt_prcm_set-specific clocktype code into
mach-omap2/clkt2xxx_virt_prcm_set.c.  Remove its dependency on the
'sclk' and 'vclk' global variables.  Those variables will be removed
by subsequent patches.

This is part of the process of cleaning up the OMAP2xxx clock code
and preparing for the removal of the omap_prcm_restart() function.

Signed-off-by: Paul Walmsley <paul@pwsan.com>
Tested-by: Vaibhav Hiremath <hvaibhav@ti.com>
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c
arch/arm/mach-omap2/clock2420_data.c
arch/arm/mach-omap2/clock2430_data.c
arch/arm/mach-omap2/clock2xxx.h

index 311599405bfa0347440874601b7e46e2d848aa53..ad658fc6baef8e0a17716db691e8982e99c91c0e 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * OMAP2xxx DVFS virtual clock functions
  *
- * Copyright (C) 2005-2008 Texas Instruments, Inc.
+ * Copyright (C) 2005-2008, 2012 Texas Instruments, Inc.
  * Copyright (C) 2004-2010 Nokia Corporation
  *
  * Contacts:
 const struct prcm_config *curr_prcm_set;
 const struct prcm_config *rate_table;
 
+/*
+ * sys_ck_rate: the rate of the external high-frequency clock
+ * oscillator on the board.  Set by the SoC-specific clock init code.
+ * Once set during a boot, will not change.
+ */
+static unsigned long sys_ck_rate;
+
 /**
  * omap2_table_mpu_recalc - just return the MPU speed
  * @clk: virt_prcm_set struct clk
@@ -67,15 +74,14 @@ unsigned long omap2_table_mpu_recalc(struct clk *clk)
 long omap2_round_to_table_rate(struct clk *clk, unsigned long rate)
 {
        const struct prcm_config *ptr;
-       long highest_rate, sys_clk_rate;
+       long highest_rate;
 
        highest_rate = -EINVAL;
-       sys_clk_rate = __clk_get_rate(sclk);
 
        for (ptr = rate_table; ptr->mpu_speed; ptr++) {
                if (!(ptr->flags & cpu_mask))
                        continue;
-               if (ptr->xtal_speed != sys_clk_rate)
+               if (ptr->xtal_speed != sys_ck_rate)
                        continue;
 
                highest_rate = ptr->mpu_speed;
@@ -94,15 +100,12 @@ int omap2_select_table_rate(struct clk *clk, unsigned long rate)
        const struct prcm_config *prcm;
        unsigned long found_speed = 0;
        unsigned long flags;
-       long sys_clk_rate;
-
-       sys_clk_rate = __clk_get_rate(sclk);
 
        for (prcm = rate_table; prcm->mpu_speed; prcm++) {
                if (!(prcm->flags & cpu_mask))
                        continue;
 
-               if (prcm->xtal_speed != sys_clk_rate)
+               if (prcm->xtal_speed != sys_ck_rate)
                        continue;
 
                if (prcm->mpu_speed <= rate) {
@@ -168,3 +171,50 @@ int omap2_select_table_rate(struct clk *clk, unsigned long rate)
 
        return 0;
 }
+
+/**
+ * omap2xxx_clkt_vps_check_bootloader_rate - determine which of the rate
+ * table sets matches the current CORE DPLL hardware rate
+ *
+ * Check the MPU rate set by bootloader.  Sets the 'curr_prcm_set'
+ * global to point to the active rate set when found; otherwise, sets
+ * it to NULL.  No return value;
+ */
+void omap2xxx_clkt_vps_check_bootloader_rates(void)
+{
+       const struct prcm_config *prcm = NULL;
+       unsigned long rate;
+
+       rate = omap2xxx_clk_get_core_rate();
+       for (prcm = rate_table; prcm->mpu_speed; prcm++) {
+               if (!(prcm->flags & cpu_mask))
+                       continue;
+               if (prcm->xtal_speed != sys_ck_rate)
+                       continue;
+               if (prcm->dpll_speed <= rate)
+                       break;
+       }
+       curr_prcm_set = prcm;
+}
+
+/**
+ * omap2xxx_clkt_vps_late_init - store a copy of the sys_ck rate
+ *
+ * Store a copy of the sys_ck rate for later use by the OMAP2xxx DVFS
+ * code.  (The sys_ck rate does not -- or rather, must not -- change
+ * during kernel runtime.)  Must be called after we have a valid
+ * sys_ck rate, but before the virt_prcm_set clock rate is
+ * recalculated.  No return value.
+ */
+void omap2xxx_clkt_vps_late_init(void)
+{
+       struct clk *c;
+
+       c = clk_get(NULL, "sys_ck");
+       if (IS_ERR(c)) {
+               WARN(1, "could not locate sys_ck\n");
+       } else {
+               sys_ck_rate = clk_get_rate(c);
+               clk_put(c);
+       }
+}
index d1034858b87a9bba34c5d5720b00792c381cffb4..1d1d77e510a3b921bd285e2cb3e5518121a3815a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * OMAP2420 clock data
  *
- * Copyright (C) 2005-2009 Texas Instruments, Inc.
+ * Copyright (C) 2005-2009, 2012 Texas Instruments, Inc.
  * Copyright (C) 2004-2011 Nokia Corporation
  *
  * Contacts:
@@ -1925,9 +1925,7 @@ static struct omap_clk omap2420_clks[] = {
 
 int __init omap2420_clk_init(void)
 {
-       const struct prcm_config *prcm;
        struct omap_clk *c;
-       u32 clkrate;
 
        prcm_clksrc_ctrl = OMAP2420_PRCM_CLKSRC_CTRL;
        cm_idlest_pll = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST);
@@ -1950,20 +1948,13 @@ int __init omap2420_clk_init(void)
                omap2_init_clk_clkdm(c->lk.clk);
        }
 
+       omap2xxx_clkt_vps_late_init();
+
        /* Disable autoidle on all clocks; let the PM code enable it later */
        omap_clk_disable_autoidle_all();
 
-       /* Check the MPU rate set by bootloader */
-       clkrate = omap2xxx_clk_get_core_rate();
-       for (prcm = rate_table; prcm->mpu_speed; prcm++) {
-               if (!(prcm->flags & cpu_mask))
-                       continue;
-               if (prcm->xtal_speed != sys_ck.rate)
-                       continue;
-               if (prcm->dpll_speed <= clkrate)
-                       break;
-       }
-       curr_prcm_set = prcm;
+       /* XXX Can this be done from the virt_prcm_set clk init function? */
+       omap2xxx_clkt_vps_check_bootloader_rates();
 
        recalculate_root_clocks();
 
index 3e16eab4691d57cefcdcc420f171ed1038b49f2c..15d859ae283bf19750ca5b9a2fe80f96859db512 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * OMAP2430 clock data
  *
- * Copyright (C) 2005-2009 Texas Instruments, Inc.
+ * Copyright (C) 2005-2009, 2012 Texas Instruments, Inc.
  * Copyright (C) 2004-2011 Nokia Corporation
  *
  * Contacts:
@@ -2024,9 +2024,7 @@ static struct omap_clk omap2430_clks[] = {
 
 int __init omap2430_clk_init(void)
 {
-       const struct prcm_config *prcm;
        struct omap_clk *c;
-       u32 clkrate;
 
        prcm_clksrc_ctrl = OMAP2430_PRCM_CLKSRC_CTRL;
        cm_idlest_pll = OMAP_CM_REGADDR(PLL_MOD, CM_IDLEST);
@@ -2049,20 +2047,13 @@ int __init omap2430_clk_init(void)
                omap2_init_clk_clkdm(c->lk.clk);
        }
 
+       omap2xxx_clkt_vps_late_init();
+
        /* Disable autoidle on all clocks; let the PM code enable it later */
        omap_clk_disable_autoidle_all();
 
-       /* Check the MPU rate set by bootloader */
-       clkrate = omap2xxx_clk_get_core_rate();
-       for (prcm = rate_table; prcm->mpu_speed; prcm++) {
-               if (!(prcm->flags & cpu_mask))
-                       continue;
-               if (prcm->xtal_speed != sys_ck.rate)
-                       continue;
-               if (prcm->dpll_speed <= clkrate)
-                       break;
-       }
-       curr_prcm_set = prcm;
+       /* XXX Can this be done from the virt_prcm_set clk init function? */
+       omap2xxx_clkt_vps_check_bootloader_rates();
 
        recalculate_root_clocks();
 
index 19dc065901c73fcb250323d413c094a4817238a3..25b8d020752705d1107e4f39736589b2f12f5ae1 100644 (file)
@@ -20,6 +20,8 @@ u32 omap2xxx_get_apll_clkin(void);
 u32 omap2xxx_get_sysclkdiv(void);
 void omap2xxx_clk_prepare_for_reboot(void);
 void omap2xxx_clkt_dpllcore_init(struct clk *clk);
+void omap2xxx_clkt_vps_check_bootloader_rates(void);
+void omap2xxx_clkt_vps_late_init(void);
 
 #ifdef CONFIG_SOC_OMAP2420
 int omap2420_clk_init(void);