2 * Copyright (C) 2011 MediaTek, Inc.
4 * Author: Holmes Chiou <holmes.chiou@mediatek.com>
6 * This software is licensed under the terms of the GNU General Public
7 * License version 2, as published by the Free Software Foundation, and
8 * may be copied, distributed, and modified under those terms.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
17 #ifndef __MT_FREQHOPPING_H__
18 #define __MT_FREQHOPPING_H__
20 #define MT_FHPLL_MAX 6
21 #define MT_SSC_NR_PREDEFINE_SETTING 10 //TODO: is 10 a good number ?
27 #include <linux/xlog.h>
31 #define VERBOSE_DEBUG 0
34 #define FH_MSG(fmt, args...) \
36 printk( FHTAG""fmt" <- %s(): L<%d> PID<%s><%d>\n", \
37 ##args ,__FUNCTION__,__LINE__,current->comm,current->pid); \
41 #if 1 //log level is 6 xlog
42 #define FH_MSG(fmt, args...) \
44 xlog_printk(ANDROID_LOG_DEBUG, FHTAG, fmt, \
47 #else //log level is 4 (printk)
48 #define FH_MSG(fmt, args...) \
50 printk( FHTAG""fmt" \n", \
69 //TODO: FREQ_MODIFIED should not be here
70 // FH_PLL_STATUS_FREQ_MODIFIED = 3
76 FH_CMD_ENABLE_USR_DEFINED
,
77 FH_CMD_DISABLE_USR_DEFINED
,
78 FH_CMD_INTERNAL_MAX_CMD
,
79 /* TODO: do we need these cmds ?
82 FH_CMD_EXT_ALL_FULL_RANGE_CMD,
83 FH_CMD_EXT_ALL_HALF_RANGE_CMD,
84 FH_CMD_EXT_DISABLE_ALL_CMD,
85 FH_CMD_EXT_DESIGNATED_PLL_FULL_RANGE_CMD,
86 FH_CMD_EXT_DESIGNATED_PLL_AND_SETTING_CMD
92 FH_OPCODE_ENABLE_WITH_ID = 1,
93 FH_OPCODE_ENABLE_WITHOUT_ID,
99 MT658X_FH_MINIMUMM_PLL
= 0,
100 MT658X_FH_ARM_PLL
= MT658X_FH_MINIMUMM_PLL
,
101 MT658X_FH_MAIN_PLL
= 1,
102 MT658X_FH_MEM_PLL
= 2,
103 MT658X_FH_MSDC_PLL
= 3,
104 MT658X_FH_MM_PLL
= 4, //MT658X_FH_TVD_PLL = 4,
105 MT658X_FH_VENC_PLL
= 5, //MT658X_FH_LVDS_PLL = 5,
107 MT658X_FH_TVD_PLL
= 6, //MT658X_FH_TVD_PLL = 6,
108 MT658X_FH_LVDS_PLL
= 7, //MT658X_FH_LVDS_PLL = 7,
109 MT658X_FH_MAXIMUMM_PLL
= MT658X_FH_LVDS_PLL
,
111 MT658X_FH_PLL_TOTAL_NUM
114 //keep track the status of each PLL
115 //TODO: do we need another "uint mode" for Dynamic FH
117 unsigned int fh_status
;
118 unsigned int pll_status
;
119 unsigned int setting_id
;
120 unsigned int curr_freq
;
121 unsigned int user_defined
;
125 //Record the owner of enable freq hopping <==TBD
126 struct freqhopping_pll
{
128 int mt_pll
[MT_FHPLL_MAX
];
140 struct freqhopping_ssc
{
149 struct freqhopping_ioctl
{
151 struct freqhopping_ssc ssc_setting
; //used only when user-define
155 int freqhopping_config(unsigned int pll_id
, unsigned long vco_freq
, unsigned int enable
);
156 void mt_freqhopping_init(void);
157 void mt_freqhopping_pll_init(void);
158 int mt_h2l_mempll(void);
159 int mt_l2h_mempll(void);
160 int mt_h2l_dvfs_mempll(void);
161 int mt_l2h_dvfs_mempll(void);
162 int mt_dfs_armpll(unsigned int current_freq
, unsigned int target_freq
);
163 int mt_is_support_DFS_mode(void);
164 void mt_fh_popod_save(void);
165 void mt_fh_popod_restore(void);
166 int mt_fh_dram_overclock(int clk
);
167 int mt_fh_get_dramc(void);
169 #endif/* !__MT_FREQHOPPING_H__ */