cpufreq: acme: add API for ready callback.
authorChoonghoon Park <choong.park@samsung.com>
Mon, 19 Mar 2018 00:42:04 +0000 (09:42 +0900)
committerlakkyung.jung <lakkyung.jung@samsung.com>
Mon, 23 Jul 2018 05:59:26 +0000 (14:59 +0900)
Change-Id: I9b6e9041354be94b2be2a59905af7d4769aaf646

drivers/cpufreq/exynos-acme.c
drivers/cpufreq/exynos-acme.h

index 0d239f6a8ee9d7bfeb892f64f5b851d0ae0bf1f7..8bccc3485d9998fbc25de41482d1380e0c842b70 100644 (file)
@@ -16,7 +16,6 @@
 #include <linux/cpu.h>
 #include <linux/cpumask.h>
 #include <linux/cpufreq.h>
-#include <linux/pm_qos.h>
 #include <linux/debug-snapshot.h>
 #include <linux/pm_opp.h>
 #include <linux/cpu_cooling.h>
@@ -24,7 +23,6 @@
 #include <linux/ems.h>
 
 #include <soc/samsung/cal-if.h>
-#include <soc/samsung/exynos-dm.h>
 #include <soc/samsung/ect_parser.h>
 #include <soc/samsung/exynos-cpuhp.h>
 #include <soc/samsung/exynos-cpupm.h>
  */
 LIST_HEAD(domains);
 
+/*
+ * list head of units which have cpufreq policy dependancy
+ */
+LIST_HEAD(ready_list);
+
 /*********************************************************************
  *                          HELPER FUNCTION                          *
  *********************************************************************/
@@ -302,6 +305,17 @@ static int update_freq(struct exynos_cpufreq_domain *domain,
        return ret;
 }
 
+/*********************************************************************
+ *                     EXYNOS CPUFREQ DRIVER API                    *
+ *********************************************************************/
+void exynos_cpufreq_ready_list_add(struct exynos_cpufreq_ready_block *rb)
+{
+       if (!rb)
+               return;
+
+       list_add(&rb->list, &ready_list);
+}
+
 /*********************************************************************
  *                   EXYNOS CPUFREQ DRIVER INTERFACE                 *
  *********************************************************************/
@@ -485,6 +499,14 @@ static int exynos_cpufreq_resume(struct cpufreq_policy *policy)
 
 static void exynos_cpufreq_ready(struct cpufreq_policy *policy)
 {
+       struct exynos_cpufreq_ready_block *ready_block;
+
+       list_for_each_entry(ready_block, &ready_list, list) {
+               if (ready_block->update)
+                       ready_block->update(policy);
+               if (ready_block->get_target)
+                       ready_block->get_target(policy, exynos_cpufreq_target);
+       }
 }
 
 static int exynos_cpufreq_exit(struct cpufreq_policy *policy)
index d4e1e5ee307f2a47ba13b198abb061062abed751..69a5a6e164e468e5003b8f17989dc8c289169f05 100644 (file)
@@ -8,11 +8,26 @@
  * Exynos ACME(A Cpufreq that Meets Every chipset) driver implementation
  */
 
+#include <linux/pm_qos.h>
+#include <soc/samsung/exynos-dm.h>
+
 struct exynos_cpufreq_dm {
        struct list_head                list;
        struct exynos_dm_constraint     c;
 };
 
+typedef int (*target_fn)(struct cpufreq_policy *policy,
+                               unsigned int target_freq,
+                               unsigned int relation);
+
+struct exynos_cpufreq_ready_block {
+       struct list_head                list;
+
+       /* callback function to update policy-dependant data */
+       int (*update)(struct cpufreq_policy *policy);
+       int (*get_target)(struct cpufreq_policy *policy, target_fn target);
+};
+
 struct exynos_cpufreq_domain {
        /* list of domain */
        struct list_head                list;
@@ -73,3 +88,8 @@ struct exynos_cpufreq_domain {
  * two frequencies in nanoseconds
  */
 #define TRANSITION_LATENCY     5000000
+
+/*
+ * Exynos CPUFreq API
+ */
+extern void exynos_cpufreq_ready_list_add(struct exynos_cpufreq_ready_block *rb);