1 /* arch/arm/mach-rk30/rk30_dvfs.h
\r
3 * Copyright (C) 2012 ROCKCHIP, Inc.
\r
5 * This software is licensed under the terms of the GNU General Public
\r
6 * License version 2, as published by the Free Software Foundation, and
\r
7 * may be copied, distributed, and modified under those terms.
\r
9 * This program is distributed in the hope that it will be useful,
\r
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
12 * GNU General Public License for more details.
\r
15 #ifndef _RK30_DVFS_H_
\r
16 #define _RK30_DVFS_H_
\r
18 typedef int (*vd_dvfs_target_callback)(struct clk *clk, unsigned long rate);
\r
20 typedef int (*dvfs_set_rate_callback)(struct clk *clk, unsigned long rate);
\r
22 typedef int (*clk_dvfs_target_callback)(struct clk *clk, unsigned long rate,
\r
23 dvfs_set_rate_callback set_rate);
\r
26 * struct vd_node: To Store All Voltage Domains' info
\r
27 * @name: Voltage Domain's Name
\r
28 * @regulator_name: Voltage domain's regulator name
\r
29 * @cur_volt: Voltage Domain's Current Voltage
\r
30 * @regulator: Voltage Domain's regulator point
\r
31 * @node: Point of he Voltage Domain List Node
\r
32 * @pd_list: Head of Power Domain List Belongs to This Voltage Domain
\r
33 * @req_volt_list: The list of clocks requests
\r
35 * @vd_dvfs_target: Callback function
\r
40 char *regulator_name;
\r
42 struct regulator *regulator;
\r
43 struct list_head node;
\r
44 struct list_head pd_list;
\r
45 struct list_head req_volt_list;
\r
46 struct mutex dvfs_mutex;
\r
47 vd_dvfs_target_callback vd_dvfs_target;
\r
51 * struct pd_node: To Store All Power Domains' info
\r
52 * @name: Power Domain's Name
\r
53 * @cur_volt: Power Domain's Current Voltage
\r
54 * @pd_status: Power Domain's status
\r
55 * @vd: Voltage Domain the power domain belongs to
\r
56 * @pd_clk: Look power domain as a clock
\r
57 * @node: List node to Voltage Domain
\r
58 * @clk_list: Head of Power Domain's Clocks List
\r
63 unsigned char pd_status;
\r
65 //struct clk *pd_clk;
\r
66 struct list_head node;
\r
67 struct list_head clk_list;
\r
70 struct pd_node_lookup {
\r
75 struct clk_node *dvfs_clk;
\r
76 struct list_head node;
\r
80 struct clk_list clk_list;
\r
84 struct depend_list {
\r
86 struct clk_node *dvfs_clk;
\r
87 struct vd_node *dep_vd;
\r
88 struct list_head node2clk;
\r
89 struct list_head node2vd;
\r
90 struct cpufreq_frequency_table *dep_table;
\r
93 struct depend_lookup {
\r
95 struct clk_node *dvfs_clk;
\r
96 struct vd_node *dep_vd;
\r
97 struct depend_list dep_list;
\r
98 struct cpufreq_frequency_table *dep_table;
\r
102 * struct clk_node: To Store All dvfs clocks' info
\r
103 * @name: Dvfs clock's Name
\r
104 * @set_freq: Dvfs clock's Current Frequency
\r
105 * @set_volt: Dvfs clock's Current Voltage
\r
106 * @enable_dvfs: Sign if DVFS clock enable
\r
107 * @clk: System clk's point
\r
108 * @pds: Power Domains dvfs clock belongs to
\r
109 * @vd: Voltage Domains dvfs clock belongs to
\r
110 * @depend_list: Dvfs Clock depend list
\r
111 * @dvfs_nb: Notify list
\r
112 * @dvfs_table: Frequency and voltage table for dvfs
\r
113 * @clk_dvfs_target: Callback function
\r
117 int set_freq; //KHZ
\r
121 struct pds_list *pds;
\r
122 struct vd_node *vd;
\r
123 struct list_head depend_list;
\r
124 struct notifier_block *dvfs_nb;
\r
125 struct cpufreq_frequency_table *dvfs_table;
\r
126 clk_dvfs_target_callback clk_dvfs_target;
\r
128 struct dvfs_arm_table {
\r
129 unsigned int frequency; /* kHz - doesn't need to be in ascending
\r
131 unsigned int cpu_volt; /* any */
\r
133 unsigned int logic_volt;
\r
136 int rk30_dvfs_init(void);
\r
137 int is_support_dvfs(struct clk_node *dvfs_info);
\r
138 int dvfs_set_rate(struct clk *clk, unsigned long rate);
\r
139 int clk_enable_dvfs(struct clk *clk);
\r
140 int clk_disable_dvfs(struct clk *clk);
\r
141 void dvfs_clk_register_set_rate_callback(struct clk *clk, clk_dvfs_target_callback clk_dvfs_target);
\r
142 struct cpufreq_frequency_table *dvfs_get_freq_volt_table(struct clk *clk);
\r
143 int dvfs_set_freq_volt_table(struct clk *clk, struct cpufreq_frequency_table *table);
\r
144 int dvfs_set_depend_table(struct clk *clk, char *vd_name, struct cpufreq_frequency_table *table);
\r
146 static inline int rk30_dvfs_init(void) { return 0; }
\r
147 static inline int is_support_dvfs(struct clk_node *dvfs_info) { return 0; }
\r
148 static inline int dvfs_set_rate(struct clk *clk, unsigned long rate) { return 0; }
\r
149 static inline int clk_enable_dvfs(struct clk *clk) { return 0; }
\r
150 static inline int clk_disable_dvfs(struct clk *clk) { return 0; }
\r
151 static inline void dvfs_clk_register_set_rate_callback(struct clk *clk, clk_dvfs_target_callback clk_dvfs_target) {}
\r
152 static inline struct cpufreq_frequency_table *dvfs_get_freq_volt_table(struct clk *clk) { return NULL; }
\r
153 static inline int dvfs_set_freq_volt_table(struct clk *clk, struct cpufreq_frequency_table *table) { return 0; }
\r
154 static inline int dvfs_set_depend_table(struct clk *clk, char *vd_name, struct cpufreq_frequency_table *table) {return 0;}
\r