return NULL;\r
}\r
\r
+int dvfs_get_rate_range(struct clk *clk)\r
+{\r
+ struct clk_node *dvfs_clk = clk_get_dvfs_info(clk);\r
+ struct cpufreq_frequency_table *table;\r
+ int i = 0;\r
+\r
+ if (!dvfs_clk)\r
+ return -1;\r
+\r
+ dvfs_clk->min_rate = 0;\r
+ dvfs_clk->max_rate = 0;\r
+\r
+ table = dvfs_clk->dvfs_table;\r
+ for (i = 0; table[i].frequency != CPUFREQ_TABLE_END; i++) {\r
+ dvfs_clk->max_rate = table[i].frequency / 1000 * 1000 * 1000;\r
+ if (i == 0)\r
+ dvfs_clk->min_rate = table[i].frequency / 1000 * 1000 * 1000;\r
+ }\r
+\r
+ DVFS_DBG("%s: clk %s, limit rate [min, max] = [%lu, %lu]\n",\r
+ __func__, dvfs_clk->name, dvfs_clk->min_rate, dvfs_clk->max_rate);\r
+\r
+ return 0;\r
+}\r
+\r
/**************************************dvfs clocks functions***************************************/\r
int dvfs_clk_enable_limit(struct clk *clk, unsigned int min_rate, unsigned max_rate)\r
{\r
if (dvfs_clk->vd && dvfs_clk->vd->vd_dvfs_target){\r
mutex_lock(&rk_dvfs_mutex);\r
/* To reset dvfs_clk->min_rate/max_rate */\r
- dvfs_set_freq_volt_table(clk, dvfs_clk->dvfs_table);\r
+ dvfs_get_rate_range(clk);\r
\r
dvfs_clk->freq_limit_en = 0;\r
ret = dvfs_clk->vd->vd_dvfs_target(clk, clk->last_set_rate);\r
int dvfs_set_freq_volt_table(struct clk *clk, struct cpufreq_frequency_table *table)\r
{\r
struct clk_node *info = clk_get_dvfs_info(clk);\r
- int i=0;\r
\r
if (!info)\r
return -1; \r
\r
mutex_lock(&mutex);\r
info->dvfs_table = table;\r
- if(table[0].frequency!= CPUFREQ_TABLE_END)\r
- {\r
-\r
- info->min_rate=(table[0].frequency/1000)*1000*1000;//to hz\r
- }\r
- else\r
- {\r
- info->min_rate=0; \r
- info->max_rate=0; \r
- mutex_unlock(&mutex);\r
- return -1;\r
- }\r
-\r
- for(i=0;table[i].frequency!= CPUFREQ_TABLE_END;i++)\r
- {\r
- \r
- } \r
- info->max_rate=(table[i-1].frequency/1000)*1000*1000;\r
-\r
- DVFS_DBG("%s,clk %s,limit max=%lu,min=%lu\n",__FUNCTION__,info->name,info->max_rate,info->min_rate);\r
-\r
+ dvfs_get_rate_range(clk);\r
mutex_unlock(&mutex);\r
+\r
dvfs_table_round_clk_rate(info);\r
dvfs_table_round_volt(info);\r
return 0;\r