Commit 3969406b1bc1d11ec362b61ee5c48d551e51fed3

Authored by Nishanth Menon
Committed by Afzal Mohammed
1 parent 0c7242c21a
Exists in master

OMAP2+: DVFS: provide ability to know if dvfs is scaling for a domain

Provide mechanism to know if DVFS is scaling on a specific domain.
This API will allow us to detect transition and take appropriate
measures in idle path

Acked-by: Todd Poynor <toddpoynor@google.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
[vaibhav.bedia@ti.com: Pull in for AM33xx]
Signed-off-by: Vaibhav Bedia <vaibhav.bedia@ti.com>

Showing 2 changed files with 47 additions and 0 deletions Side-by-side Diff

arch/arm/mach-omap2/dvfs.c
... ... @@ -174,6 +174,8 @@
174 174 * @vdd_user_list: The vdd user list
175 175 * @voltdm: Voltage domains for which dvfs info stored
176 176 * @dev_list: Device list maintained per domain
  177 + * @is_scaling: flag to store information about scaling in progress or not
  178 + * this flag is already protected by the global mutex.
177 179 *
178 180 * This is a fundamental structure used to store all the required
179 181 * DVFS related information for a vdd.
... ... @@ -185,6 +187,7 @@
185 187 struct plist_head vdd_user_list;
186 188 struct voltagedomain *voltdm;
187 189 struct list_head dev_list;
  190 + bool is_scaling;
188 191 };
189 192  
190 193 static LIST_HEAD(omap_dvfs_info_list);
... ... @@ -694,6 +697,11 @@
694 697 }
695 698 vdd = voltdm->vdd;
696 699  
  700 + /* Mark that we are scaling for this device */
  701 + tdvfs_info->is_scaling = true;
  702 + /* let the other CPU know as well */
  703 + smp_wmb();
  704 +
697 705 /* Find the highest voltage being requested */
698 706 node = plist_last(&tdvfs_info->vdd_user_list);
699 707 new_volt = node->prio;
... ... @@ -790,6 +798,11 @@
790 798 /* Re-enable Smartreflex module */
791 799 omap_sr_enable(voltdm);
792 800  
  801 + /* Mark done */
  802 + tdvfs_info->is_scaling = false;
  803 + /* let the other CPU know as well */
  804 + smp_wmb();
  805 +
793 806 return ret;
794 807 }
795 808  
... ... @@ -881,6 +894,34 @@
881 894 return ret;
882 895 }
883 896 EXPORT_SYMBOL(omap_device_scale);
  897 +
  898 +/**
  899 + * omap_dvfs_is_scaling() - Tells the caller if the domain is scaling
  900 + * @voltdm: voltage domain we are interested in
  901 + *
  902 + * Returns true if the domain is in the middle of scale operation,
  903 + * returns false if there is no scale operation is in progress or an
  904 + * invalid parameter was passed.
  905 + */
  906 +bool omap_dvfs_is_scaling(struct voltagedomain *voltdm)
  907 +{
  908 + struct omap_vdd_dvfs_info *dvfs_info;
  909 +
  910 + if (IS_ERR_OR_NULL(voltdm)) {
  911 + pr_err("%s: bad voltdm\n", __func__);
  912 + return false;
  913 + }
  914 +
  915 + dvfs_info = _voltdm_to_dvfs_info(voltdm);
  916 + if (IS_ERR_OR_NULL(dvfs_info)) {
  917 + pr_err("%s: no dvfsinfo for voltdm %s\n",
  918 + __func__, voltdm->name);
  919 + return false;
  920 + }
  921 +
  922 + return dvfs_info->is_scaling;
  923 +}
  924 +EXPORT_SYMBOL(omap_dvfs_is_scaling);
884 925  
885 926 #ifdef CONFIG_PM_DEBUG
886 927 static int dvfs_dump_vdd(struct seq_file *sf, void *unused)
arch/arm/plat-omap/include/plat/dvfs.h
... ... @@ -21,6 +21,8 @@
21 21 char *clk_name);
22 22 int omap_device_scale(struct device *req_dev, struct device *target_dev,
23 23 unsigned long rate);
  24 +
  25 +bool omap_dvfs_is_scaling(struct voltagedomain *voltdm);
24 26 #else
25 27 static inline int omap_dvfs_register_device(struct omap_hwmod *oh,
26 28 struct device *dev)
... ... @@ -33,6 +35,10 @@
33 35 struct device *target_dev, unsigned long rate)
34 36 {
35 37 return -EINVAL;
  38 +}
  39 +static inline bool omap_dvfs_is_scaling(struct voltagedomain *voltdm)
  40 +{
  41 + return false;
36 42 }
37 43 #endif
38 44 #endif