From 5e339ed58edda5a4c473973d224e464d74b66a0c Mon Sep 17 00:00:00 2001 From: Choonghoon Park Date: Mon, 19 Mar 2018 09:42:04 +0900 Subject: [PATCH] cpufreq: acme: add API for ready callback. Change-Id: I9b6e9041354be94b2be2a59905af7d4769aaf646 --- drivers/cpufreq/exynos-acme.c | 26 ++++++++++++++++++++++++-- drivers/cpufreq/exynos-acme.h | 20 ++++++++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/exynos-acme.c b/drivers/cpufreq/exynos-acme.c index 0d239f6a8ee9..8bccc3485d99 100644 --- a/drivers/cpufreq/exynos-acme.c +++ b/drivers/cpufreq/exynos-acme.c @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #include @@ -24,7 +23,6 @@ #include #include -#include #include #include #include @@ -37,6 +35,11 @@ */ 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) diff --git a/drivers/cpufreq/exynos-acme.h b/drivers/cpufreq/exynos-acme.h index d4e1e5ee307f..69a5a6e164e4 100644 --- a/drivers/cpufreq/exynos-acme.h +++ b/drivers/cpufreq/exynos-acme.h @@ -8,11 +8,26 @@ * Exynos ACME(A Cpufreq that Meets Every chipset) driver implementation */ +#include +#include + 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); -- 2.20.1