ARM: tegra: clock: Make EMC BW request calculation common
Alex Frid [Sat, 30 Mar 2013 00:39:46 +0000 (17:39 -0700)]
Moved EMC bandwidth request calculation from Tegra11 specific code
to commmon tegra emc file.

Change-Id: Ia6f86cb0a4bf99328792baeeae027fa0931f2337
Signed-off-by: Alex Frid <afrid@nvidia.com>
Reviewed-on: http://git-master/r/215162
(cherry picked from commit d4d4f4b8555afd621c108beb9cf610d8f74d3208)
Reviewed-on: http://git-master/r/217121
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Jon Mayo <jmayo@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Yu-Huan Hsu <yhsu@nvidia.com>

arch/arm/mach-tegra/tegra11_clocks.c
arch/arm/mach-tegra/tegra_emc.c
arch/arm/mach-tegra/tegra_emc.h

index 8c40d34..82e2aad 100644 (file)
@@ -5136,21 +5136,9 @@ static unsigned long tegra11_clk_shared_bus_update(struct clk *bus,
                }
        }
 
-       if (bus->flags & PERIPH_EMC_ENB) {
-               u8 efficiency = tegra_emc_get_iso_share(usage_flags);
-               if (iso_bw && efficiency && (efficiency < 100)) {
-                       iso_bw /= efficiency;
-                       iso_bw = (iso_bw < bus->max_rate / 100) ?
-                                       (iso_bw * 100) : bus->max_rate;
-               }
-               efficiency = tegra_emc_bw_efficiency;
-               if (bw && efficiency && (efficiency < 100)) {
-                       bw = bw / efficiency;
-                       bw = (bw < bus->max_rate / 100) ?
-                               (bw * 100) : bus->max_rate;
-               }
-               bw = max(bw, iso_bw);
-       }
+       if (bus->flags & PERIPH_EMC_ENB)
+               bw = tegra_emc_apply_efficiency(
+                       bw, iso_bw, bus->max_rate, usage_flags);
 
        rate = override_rate ? : max(rate, bw);
        ceiling = override_rate ? bus->max_rate : ceiling;
index 54c1cb6..895dae4 100644 (file)
@@ -43,7 +43,7 @@ void __init tegra_emc_iso_usage_table_init(struct emc_iso_usage *table,
                       size * sizeof(struct emc_iso_usage));
 }
 
-u8 tegra_emc_get_iso_share(u32 usage_flags)
+static u8 tegra_emc_get_iso_share(u32 usage_flags)
 {
        int i;
        u8 iso_share = 100;
@@ -71,6 +71,25 @@ u8 tegra_emc_get_iso_share(u32 usage_flags)
        return iso_share;
 }
 
+unsigned long tegra_emc_apply_efficiency(unsigned long total_bw,
+       unsigned long iso_bw, unsigned long max_rate, u32 usage_flags)
+{
+       u8 efficiency = tegra_emc_get_iso_share(usage_flags);
+       if (iso_bw && efficiency && (efficiency < 100)) {
+               iso_bw /= efficiency;
+               iso_bw = (iso_bw < max_rate / 100) ?
+                               (iso_bw * 100) : max_rate;
+       }
+
+       efficiency = tegra_emc_bw_efficiency;
+       if (total_bw && efficiency && (efficiency < 100)) {
+               total_bw = total_bw / efficiency;
+               total_bw = (total_bw < max_rate / 100) ?
+                               (total_bw * 100) : max_rate;
+       }
+       return max(total_bw, iso_bw);
+}
+
 #ifdef CONFIG_DEBUG_FS
 
 #define USER_NAME(module) \
index ea7cd68..c674a0f 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * arch/arm/mach-tegra/tegra_emc.h
  *
- * Copyright (C) 2013 NVIDIA Corporation
+ * Copyright (c) 2013, NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -50,7 +50,8 @@ struct dentry;
 
 void tegra_emc_iso_usage_table_init(struct emc_iso_usage *table, int size);
 int  tegra_emc_iso_usage_debugfs_init(struct dentry *emc_debugfs_root);
-u8 tegra_emc_get_iso_share(u32 usage_flags);
+unsigned long tegra_emc_apply_efficiency(unsigned long total_bw,
+       unsigned long iso_bw, unsigned long max_rate, u32 usage_flags);
 void tegra_emc_dram_type_init(struct clk *c);
 int tegra_emc_get_dram_type(void);
 int tegra_emc_get_dram_temperature(void);