From: 陈亮 Date: Fri, 28 Feb 2014 09:27:21 +0000 (-0800) Subject: dvfs : move dvfs.h to include/linux/rockchip/ X-Git-Tag: firefly_0821_release~6241 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=53d5a0a18afa7dc16315b66d5a80247b01238feb;p=firefly-linux-kernel-4.4.55.git dvfs : move dvfs.h to include/linux/rockchip/ --- diff --git a/arch/arm/mach-rockchip/ddr_freq.c b/arch/arm/mach-rockchip/ddr_freq.c index 4385884489f0..b9c3b19e43ff 100644 --- a/arch/arm/mach-rockchip/ddr_freq.c +++ b/arch/arm/mach-rockchip/ddr_freq.c @@ -16,9 +16,9 @@ #include #include #include +#include #include -#include "dvfs.h" #include "common.h" enum { diff --git a/arch/arm/mach-rockchip/dvfs.c b/arch/arm/mach-rockchip/dvfs.c index 9701ecc78b54..943399653ec9 100644 --- a/arch/arm/mach-rockchip/dvfs.c +++ b/arch/arm/mach-rockchip/dvfs.c @@ -19,7 +19,7 @@ #include #include #include -#include "dvfs.h" +#include #define MHz (1000 * 1000) static LIST_HEAD(rk_dvfs_tree); diff --git a/arch/arm/mach-rockchip/dvfs.h b/arch/arm/mach-rockchip/dvfs.h deleted file mode 100644 index 9155786f572d..000000000000 --- a/arch/arm/mach-rockchip/dvfs.h +++ /dev/null @@ -1,195 +0,0 @@ -/* arch/arm/mach-rk30/rk30_dvfs.h - * - * Copyright (C) 2012 ROCKCHIP, Inc. - * - * This software is licensed under the terms of the GNU General Public - * License version 2, as published by the Free Software Foundation, and - * may be copied, distributed, and modified under those terms. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - */ -#ifndef _RK30_DVFS_H_ -#define _RK30_DVFS_H_ - -#include -#include - -struct dvfs_node; -typedef int (*dvfs_set_rate_callback)(struct dvfs_node *clk_dvfs_node, unsigned long rate); -typedef int (*clk_set_rate_callback)(struct clk *clk, unsigned long rate); - -/** - * struct vd_node: To Store All Voltage Domains' info - * @name: Voltage Domain's Name - * @regulator_name: Voltage domain's regulator name - * @cur_volt: Voltage Domain's Current Voltage - * @regulator: Voltage Domain's regulator point - * @node: Point of he Voltage Domain List Node - * @pd_list: Head of Power Domain List Belongs to This Voltage Domain - * @req_volt_list: The list of clocks requests - * @dvfs_mutex: Lock - * @vd_dvfs_target: Callback function - */ - #define VD_VOL_LIST_CNT (200) - #define VD_LIST_RELATION_L 0 - #define VD_LIST_RELATION_H 1 - -struct vd_node { - const char *name; - const char *regulator_name; - int volt_time_flag;// =0 ,is no initing checking ,>0 ,support,<0 not support - int mode_flag;// =0 ,is no initing checking ,>0 ,support,<0 not support - int cur_volt; - int volt_set_flag; - int suspend_volt; - struct regulator *regulator; - struct list_head node; - struct list_head pd_list; - struct mutex mutex; - dvfs_set_rate_callback vd_dvfs_target; - unsigned int n_voltages; - int volt_list[VD_VOL_LIST_CNT]; -}; - -/** - * struct pd_node: To Store All Power Domains' info - * @name: Power Domain's Name - * @cur_volt: Power Domain's Current Voltage - * @pd_status: Power Domain's status - * @vd: Voltage Domain the power domain belongs to - * @pd_clk: Look power domain as a clock - * @node: List node to Voltage Domain - * @clk_list: Head of Power Domain's Clocks List - */ -struct pd_node { - const char *name; - int cur_volt; - unsigned char pd_status; - struct vd_node *vd; - struct list_head node; - struct list_head clk_list; -}; - -/** - * struct dvfs_node: To Store All dvfs clocks' info - * @name: Dvfs clock's Name - * @set_freq: Dvfs clock's Current Frequency - * @set_volt: Dvfs clock's Current Voltage - * @enable_dvfs: Sign if DVFS clock enable - * @clk: System clk's point - * @pd: Power Domains dvfs clock belongs to - * @vd: Voltage Domains dvfs clock belongs to - * @dvfs_nb: Notify list - * @dvfs_table: Frequency and voltage table for dvfs - * @clk_dvfs_target: Callback function - */ -struct dvfs_node { - struct device dev; //for opp - const char *name; - int set_freq; //KHZ - int set_volt; //MV - int enable_count; - int freq_limit_en; //sign if use limit frequency - unsigned int min_rate; //limit min frequency - unsigned int max_rate; //limit max frequency - unsigned int last_set_rate; - struct clk *clk; - struct pd_node *pd; - struct vd_node *vd; - struct list_head node; - struct notifier_block *dvfs_nb; - struct cpufreq_frequency_table *dvfs_table; - struct cpufreq_frequency_table *condition_freq_table; - clk_set_rate_callback clk_dvfs_target; -}; - - - -#define DVFS_MHZ (1000*1000) -#define DVFS_KHZ (1000) - -#define DVFS_V (1000*1000) -#define DVFS_MV (1000) -#if 0 -#define DVFS_DBG(fmt, args...) printk(KERN_INFO "DVFS DBG:\t"fmt, ##args) -#else -#define DVFS_DBG(fmt, args...) {while(0);} -#endif - -#define DVFS_ERR(fmt, args...) printk(KERN_ERR "DVFS ERR:\t"fmt, ##args) -#define DVFS_LOG(fmt, args...) printk(KERN_DEBUG "DVFS LOG:\t"fmt, ##args) -#define DVFS_WARNING(fmt, args...) printk(KERN_WARNING "DVFS WARNING:\t"fmt, ##args) - -#define DVFS_SET_VOLT_FAILURE 1 -#define DVFS_SET_VOLT_SUCCESS 0 - -#define dvfs_regulator_get(dev,id) regulator_get((dev),(id)) -#define dvfs_regulator_put(regu) regulator_put((regu)) -#define dvfs_regulator_set_voltage(regu,min_uV,max_uV) regulator_set_voltage((regu),(min_uV),(max_uV)) -#define dvfs_regulator_get_voltage(regu) regulator_get_voltage((regu)) -#define dvfs_regulator_set_voltage_time(regu, old_uV, new_uV) regulator_set_voltage_time((regu), (old_uV), (new_uV)) -#define dvfs_regulator_set_mode(regu, mode) regulator_set_mode((regu), (mode)) -#define dvfs_regulator_get_mode(regu) regulator_get_mode((regu)) -#define dvfs_regulator_list_voltage(regu,selector) regulator_list_voltage((regu),(selector)) -#define dvfs_regulator_count_voltages(regu) regulator_count_voltages((regu)) - -#define clk_dvfs_node_get(a,b) clk_get((a),(b)) -#define clk_dvfs_node_get_rate_kz(a) (clk_get_rate((a))/1000) -#define clk_dvfs_node_set_rate(a,b) clk_set_rate((a),(b)) - -typedef void (*avs_init_fn)(void); -typedef u8 (*avs_get_val_fn)(void); -struct avs_ctr_st { - avs_init_fn avs_init; - avs_get_val_fn avs_get_val; -}; - -#ifdef CONFIG_DVFS -struct dvfs_node *clk_get_dvfs_node(char *clk_name); -void clk_put_dvfs_node(struct dvfs_node *clk_dvfs_node); -unsigned long dvfs_clk_get_rate(struct dvfs_node *clk_dvfs_node); -int dvfs_clk_set_rate(struct dvfs_node *clk_dvfs_node, unsigned long rate); -int dvfs_clk_enable(struct dvfs_node *clk_dvfs_node); -void dvfs_clk_disable(struct dvfs_node *clk_dvfs_node); -int dvfs_clk_prepare_enable(struct dvfs_node *clk_dvfs_node); -void dvfs_clk_disable_unprepare(struct dvfs_node *clk_dvfs_node); -int dvfs_set_freq_volt_table(struct dvfs_node *clk_dvfs_node, struct cpufreq_frequency_table *table); -int dvfs_clk_register_set_rate_callback(struct dvfs_node *clk_dvfs_node, clk_set_rate_callback clk_dvfs_target); -int dvfs_clk_enable_limit(struct dvfs_node *clk_dvfs_node, unsigned int min_rate, unsigned max_rate); -int dvfs_clk_disable_limit(struct dvfs_node *clk_dvfs_node); -int clk_disable_dvfs(struct dvfs_node *clk_dvfs_node); -int clk_enable_dvfs(struct dvfs_node *clk_dvfs_node); -struct cpufreq_frequency_table *dvfs_get_freq_volt_table(struct dvfs_node *clk_dvfs_node); -int rk_regist_vd(struct vd_node *vd); -int rk_regist_pd(struct pd_node *pd); -int rk_regist_clk(struct dvfs_node *clk_dvfs_node); -int of_dvfs_init(void); - -#else - -static inline struct dvfs_node *clk_get_dvfs_node(char *clk_name){ return NULL; }; -static inline void clk_put_dvfs_node(struct dvfs_node *clk_dvfs_node){ return; }; -static inline unsigned long dvfs_clk_get_rate(struct dvfs_node *clk_dvfs_node){ return 0; }; -static inline int dvfs_clk_set_rate(struct dvfs_node *clk_dvfs_node, unsigned long rate){ return 0; }; -static inline int dvfs_clk_enable(struct dvfs_node *clk_dvfs_node){ return 0; }; -static inline void dvfs_clk_disable(struct dvfs_node *clk_dvfs_node){ }; -static inline int dvfs_clk_prepare_enable(struct dvfs_node *clk_dvfs_node){ return 0; }; -static inline void dvfs_clk_disable_unprepare(struct dvfs_node *clk_dvfs_node){ }; -static inline int dvfs_set_freq_volt_table(struct dvfs_node *clk_dvfs_node, struct cpufreq_frequency_table *table){ return 0; }; -static inline int dvfs_clk_register_set_rate_callback(struct dvfs_node *clk_dvfs_node, clk_set_rate_callback clk_dvfs_target){ return 0; }; -static inline int dvfs_clk_enable_limit(struct dvfs_node *clk_dvfs_node, unsigned int min_rate, unsigned max_rate){ return 0; }; -static inline int dvfs_clk_disable_limit(struct dvfs_node *clk_dvfs_node){ return 0; }; -static inline int clk_disable_dvfs(struct dvfs_node *clk_dvfs_node){ return 0; }; -static inline int clk_enable_dvfs(struct dvfs_node *clk_dvfs_node){ return 0; }; -static inline struct cpufreq_frequency_table *dvfs_get_freq_volt_table(struct dvfs_node *clk_dvfs_node){ return NULL; }; -static inline int rk_regist_vd(struct vd_node *vd){ return 0; }; -static inline int rk_regist_pd(struct pd_node *pd){ return 0; }; -static inline int rk_regist_clk(struct dvfs_node *clk_dvfs_node){ return 0; }; -static inline int of_dvfs_init(void){ return 0; }; -#endif - -#endif diff --git a/arch/arm/mach-rockchip/rk3188-cpufreq.c b/arch/arm/mach-rockchip/rk3188-cpufreq.c index f9b5d9082fac..3a66589d0f29 100644 --- a/arch/arm/mach-rockchip/rk3188-cpufreq.c +++ b/arch/arm/mach-rockchip/rk3188-cpufreq.c @@ -26,12 +26,12 @@ #include #include #include +#include #include #include #include #include -#include "dvfs.h" #include "cpu.h" #define VERSION "2.2" diff --git a/arch/arm/mach-rockchip/rk3188.c b/arch/arm/mach-rockchip/rk3188.c index 9c23678188d4..e03253cf64c3 100644 --- a/arch/arm/mach-rockchip/rk3188.c +++ b/arch/arm/mach-rockchip/rk3188.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include "common.h" @@ -32,7 +33,6 @@ #include "loader.h" #include "pmu.h" #include "sram.h" -#include "dvfs.h" #define RK3188_DEVICE(name) \ { \ diff --git a/arch/arm/mach-rockchip/rk3288.c b/arch/arm/mach-rockchip/rk3288.c index efdccf114736..f1050c65c2d6 100644 --- a/arch/arm/mach-rockchip/rk3288.c +++ b/arch/arm/mach-rockchip/rk3288.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "common.h" #include "cpu.h" #include "cpu_axi.h" @@ -32,7 +33,6 @@ #include "loader.h" #include "pmu.h" #include "sram.h" -#include "dvfs.h" #define RK3288_DEVICE(name) \ { \ diff --git a/include/linux/rockchip/dvfs.h b/include/linux/rockchip/dvfs.h new file mode 100644 index 000000000000..9155786f572d --- /dev/null +++ b/include/linux/rockchip/dvfs.h @@ -0,0 +1,195 @@ +/* arch/arm/mach-rk30/rk30_dvfs.h + * + * Copyright (C) 2012 ROCKCHIP, Inc. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#ifndef _RK30_DVFS_H_ +#define _RK30_DVFS_H_ + +#include +#include + +struct dvfs_node; +typedef int (*dvfs_set_rate_callback)(struct dvfs_node *clk_dvfs_node, unsigned long rate); +typedef int (*clk_set_rate_callback)(struct clk *clk, unsigned long rate); + +/** + * struct vd_node: To Store All Voltage Domains' info + * @name: Voltage Domain's Name + * @regulator_name: Voltage domain's regulator name + * @cur_volt: Voltage Domain's Current Voltage + * @regulator: Voltage Domain's regulator point + * @node: Point of he Voltage Domain List Node + * @pd_list: Head of Power Domain List Belongs to This Voltage Domain + * @req_volt_list: The list of clocks requests + * @dvfs_mutex: Lock + * @vd_dvfs_target: Callback function + */ + #define VD_VOL_LIST_CNT (200) + #define VD_LIST_RELATION_L 0 + #define VD_LIST_RELATION_H 1 + +struct vd_node { + const char *name; + const char *regulator_name; + int volt_time_flag;// =0 ,is no initing checking ,>0 ,support,<0 not support + int mode_flag;// =0 ,is no initing checking ,>0 ,support,<0 not support + int cur_volt; + int volt_set_flag; + int suspend_volt; + struct regulator *regulator; + struct list_head node; + struct list_head pd_list; + struct mutex mutex; + dvfs_set_rate_callback vd_dvfs_target; + unsigned int n_voltages; + int volt_list[VD_VOL_LIST_CNT]; +}; + +/** + * struct pd_node: To Store All Power Domains' info + * @name: Power Domain's Name + * @cur_volt: Power Domain's Current Voltage + * @pd_status: Power Domain's status + * @vd: Voltage Domain the power domain belongs to + * @pd_clk: Look power domain as a clock + * @node: List node to Voltage Domain + * @clk_list: Head of Power Domain's Clocks List + */ +struct pd_node { + const char *name; + int cur_volt; + unsigned char pd_status; + struct vd_node *vd; + struct list_head node; + struct list_head clk_list; +}; + +/** + * struct dvfs_node: To Store All dvfs clocks' info + * @name: Dvfs clock's Name + * @set_freq: Dvfs clock's Current Frequency + * @set_volt: Dvfs clock's Current Voltage + * @enable_dvfs: Sign if DVFS clock enable + * @clk: System clk's point + * @pd: Power Domains dvfs clock belongs to + * @vd: Voltage Domains dvfs clock belongs to + * @dvfs_nb: Notify list + * @dvfs_table: Frequency and voltage table for dvfs + * @clk_dvfs_target: Callback function + */ +struct dvfs_node { + struct device dev; //for opp + const char *name; + int set_freq; //KHZ + int set_volt; //MV + int enable_count; + int freq_limit_en; //sign if use limit frequency + unsigned int min_rate; //limit min frequency + unsigned int max_rate; //limit max frequency + unsigned int last_set_rate; + struct clk *clk; + struct pd_node *pd; + struct vd_node *vd; + struct list_head node; + struct notifier_block *dvfs_nb; + struct cpufreq_frequency_table *dvfs_table; + struct cpufreq_frequency_table *condition_freq_table; + clk_set_rate_callback clk_dvfs_target; +}; + + + +#define DVFS_MHZ (1000*1000) +#define DVFS_KHZ (1000) + +#define DVFS_V (1000*1000) +#define DVFS_MV (1000) +#if 0 +#define DVFS_DBG(fmt, args...) printk(KERN_INFO "DVFS DBG:\t"fmt, ##args) +#else +#define DVFS_DBG(fmt, args...) {while(0);} +#endif + +#define DVFS_ERR(fmt, args...) printk(KERN_ERR "DVFS ERR:\t"fmt, ##args) +#define DVFS_LOG(fmt, args...) printk(KERN_DEBUG "DVFS LOG:\t"fmt, ##args) +#define DVFS_WARNING(fmt, args...) printk(KERN_WARNING "DVFS WARNING:\t"fmt, ##args) + +#define DVFS_SET_VOLT_FAILURE 1 +#define DVFS_SET_VOLT_SUCCESS 0 + +#define dvfs_regulator_get(dev,id) regulator_get((dev),(id)) +#define dvfs_regulator_put(regu) regulator_put((regu)) +#define dvfs_regulator_set_voltage(regu,min_uV,max_uV) regulator_set_voltage((regu),(min_uV),(max_uV)) +#define dvfs_regulator_get_voltage(regu) regulator_get_voltage((regu)) +#define dvfs_regulator_set_voltage_time(regu, old_uV, new_uV) regulator_set_voltage_time((regu), (old_uV), (new_uV)) +#define dvfs_regulator_set_mode(regu, mode) regulator_set_mode((regu), (mode)) +#define dvfs_regulator_get_mode(regu) regulator_get_mode((regu)) +#define dvfs_regulator_list_voltage(regu,selector) regulator_list_voltage((regu),(selector)) +#define dvfs_regulator_count_voltages(regu) regulator_count_voltages((regu)) + +#define clk_dvfs_node_get(a,b) clk_get((a),(b)) +#define clk_dvfs_node_get_rate_kz(a) (clk_get_rate((a))/1000) +#define clk_dvfs_node_set_rate(a,b) clk_set_rate((a),(b)) + +typedef void (*avs_init_fn)(void); +typedef u8 (*avs_get_val_fn)(void); +struct avs_ctr_st { + avs_init_fn avs_init; + avs_get_val_fn avs_get_val; +}; + +#ifdef CONFIG_DVFS +struct dvfs_node *clk_get_dvfs_node(char *clk_name); +void clk_put_dvfs_node(struct dvfs_node *clk_dvfs_node); +unsigned long dvfs_clk_get_rate(struct dvfs_node *clk_dvfs_node); +int dvfs_clk_set_rate(struct dvfs_node *clk_dvfs_node, unsigned long rate); +int dvfs_clk_enable(struct dvfs_node *clk_dvfs_node); +void dvfs_clk_disable(struct dvfs_node *clk_dvfs_node); +int dvfs_clk_prepare_enable(struct dvfs_node *clk_dvfs_node); +void dvfs_clk_disable_unprepare(struct dvfs_node *clk_dvfs_node); +int dvfs_set_freq_volt_table(struct dvfs_node *clk_dvfs_node, struct cpufreq_frequency_table *table); +int dvfs_clk_register_set_rate_callback(struct dvfs_node *clk_dvfs_node, clk_set_rate_callback clk_dvfs_target); +int dvfs_clk_enable_limit(struct dvfs_node *clk_dvfs_node, unsigned int min_rate, unsigned max_rate); +int dvfs_clk_disable_limit(struct dvfs_node *clk_dvfs_node); +int clk_disable_dvfs(struct dvfs_node *clk_dvfs_node); +int clk_enable_dvfs(struct dvfs_node *clk_dvfs_node); +struct cpufreq_frequency_table *dvfs_get_freq_volt_table(struct dvfs_node *clk_dvfs_node); +int rk_regist_vd(struct vd_node *vd); +int rk_regist_pd(struct pd_node *pd); +int rk_regist_clk(struct dvfs_node *clk_dvfs_node); +int of_dvfs_init(void); + +#else + +static inline struct dvfs_node *clk_get_dvfs_node(char *clk_name){ return NULL; }; +static inline void clk_put_dvfs_node(struct dvfs_node *clk_dvfs_node){ return; }; +static inline unsigned long dvfs_clk_get_rate(struct dvfs_node *clk_dvfs_node){ return 0; }; +static inline int dvfs_clk_set_rate(struct dvfs_node *clk_dvfs_node, unsigned long rate){ return 0; }; +static inline int dvfs_clk_enable(struct dvfs_node *clk_dvfs_node){ return 0; }; +static inline void dvfs_clk_disable(struct dvfs_node *clk_dvfs_node){ }; +static inline int dvfs_clk_prepare_enable(struct dvfs_node *clk_dvfs_node){ return 0; }; +static inline void dvfs_clk_disable_unprepare(struct dvfs_node *clk_dvfs_node){ }; +static inline int dvfs_set_freq_volt_table(struct dvfs_node *clk_dvfs_node, struct cpufreq_frequency_table *table){ return 0; }; +static inline int dvfs_clk_register_set_rate_callback(struct dvfs_node *clk_dvfs_node, clk_set_rate_callback clk_dvfs_target){ return 0; }; +static inline int dvfs_clk_enable_limit(struct dvfs_node *clk_dvfs_node, unsigned int min_rate, unsigned max_rate){ return 0; }; +static inline int dvfs_clk_disable_limit(struct dvfs_node *clk_dvfs_node){ return 0; }; +static inline int clk_disable_dvfs(struct dvfs_node *clk_dvfs_node){ return 0; }; +static inline int clk_enable_dvfs(struct dvfs_node *clk_dvfs_node){ return 0; }; +static inline struct cpufreq_frequency_table *dvfs_get_freq_volt_table(struct dvfs_node *clk_dvfs_node){ return NULL; }; +static inline int rk_regist_vd(struct vd_node *vd){ return 0; }; +static inline int rk_regist_pd(struct pd_node *pd){ return 0; }; +static inline int rk_regist_clk(struct dvfs_node *clk_dvfs_node){ return 0; }; +static inline int of_dvfs_init(void){ return 0; }; +#endif + +#endif