import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / eemcs / eemcs_expt.h
1 #ifndef __EEMCS_EXPT_H__
2 #define __EEMCS_EXPT_H__
3 #include <linux/kernel.h>
4 #include <linux/skbuff.h>
5 #include <asm/atomic.h>
6
7 #include "eemcs_ccci.h"
8 #include "eemcs_char.h"
9 #include "lte_df_main.h"
10
11 /* Exception message magic number*/
12 #define MD_EX_MAGIC 0x5745444D //"MDEX"
13
14 /* Exception Mode Enumeration */
15 #define EEMCS_EX_MODE_MASK (0xF0000000)
16
17 /* Exception show string length*/
18 #define EE_BUF_LEN (256)
19
20 /* Exception dump flag*/
21 #define CCCI_AED_DUMP_EX_MEM (1<<0)
22 #define CCCI_AED_DUMP_MD_IMG_MEM (1<<1)
23
24 /* Modem boot up init stage number*/
25 #define MD_TSID_MAGIC 0x43525442 //"BTRC"
26
27
28 enum {
29 MD_INIT_START_BOOT = 0x00000000,
30 MD_INIT_CHK_ID = 0x5555FFFF,
31 MD_EX = 0x00000004,
32 MD_EX_CHK_ID = 0x45584350,
33 MD_EX_REC_OK = 0x00000006,
34 MD_EX_REC_OK_CHK_ID = 0x45524543,
35 MD_EX_RESUME_CHK_ID = 0x7,
36 CCCI_DRV_VER_ERROR = 0x5,
37 // System channel, MD --> AP message start from 0x1000
38 MD_WDT_MONITOR = 0x1000,
39 MD_WAKEN_UP = 0x10000,
40 };
41
42 enum {
43 MD_EE_CASE_NORMAL = 0,
44 MD_EE_CASE_ONLY_EX,
45 MD_EE_CASE_ONLY_EX_OK,
46 MD_EE_CASE_TX_TRG,
47 MD_EE_CASE_ISR_TRG,
48 MD_EE_CASE_NO_RESPONSE,
49 MD_EE_CASE_AP_MASK_I_BIT_TOO_LONG,
50 };
51
52
53 enum {
54 MD_EX_TYPE_INVALID = 0,
55 MD_EX_TYPE_UNDEF = 1,
56 MD_EX_TYPE_SWI = 2,
57 MD_EX_TYPE_PREF_ABT = 3,
58 MD_EX_TYPE_DATA_ABT = 4,
59 MD_EX_TYPE_ASSERT = 5,
60 MD_EX_TYPE_FATALERR_TASK = 6,
61 MD_EX_TYPE_FATALERR_BUF = 7,
62 MD_EX_TYPE_LOCKUP = 8,
63 MD_EX_TYPE_ASSERT_DUMP = 9,
64 MD_EX_TYPE_ASSERT_FAIL = 10,
65 DSP_EX_TYPE_ASSERT = 11,
66 DSP_EX_TYPE_EXCEPTION = 12,
67 DSP_EX_FATAL_ERROR = 13,
68 NUM_EXCEPTION
69 };
70
71 #define MD_EX_TYPE_EMI_CHECK 99
72
73 /* MODEM MAUI Exception header (4 bytes)*/
74 typedef struct _exception_record_header_t
75 {
76 unsigned char ex_type;
77 unsigned char ex_nvram;
78 unsigned short ex_serial_num;
79 }EX_HEADER_T;
80
81 /* MODEM MAUI Environment information (164 bytes) */
82 typedef struct _ex_environment_info_t
83 {
84 unsigned char boot_mode;
85 unsigned char reserved1[8];
86 unsigned char execution_unit[8];
87 unsigned char reserved2[147];
88 }EX_ENVINFO_T;
89
90 /* MODEM MAUI Special for fatal error (8 bytes)*/
91 typedef struct _ex_fatalerror_code_t
92 {
93 unsigned int code1;
94 unsigned int code2;
95 }EX_FATALERR_CODE_T;
96
97 /* MODEM MAUI fatal error (296 bytes)*/
98 typedef struct _ex_fatalerror_t
99 {
100 EX_FATALERR_CODE_T error_code;
101 unsigned char reserved1[288];
102 }EX_FATALERR_T;
103
104 /* MODEM MAUI Assert fail (296 bytes)*/
105 typedef struct _ex_assert_fail_t
106 {
107 unsigned char filename[24];
108 unsigned int linenumber;
109 unsigned int parameters[3];
110 unsigned char reserved1[256];
111 }EX_ASSERTFAIL_T;
112
113 /* MODEM MAUI Globally exported data structure (300 bytes) */
114 typedef union
115 {
116 EX_FATALERR_T fatalerr;
117 EX_ASSERTFAIL_T assert;
118 }EX_CONTENT_T;
119
120 /* MODEM MAUI Standard structure of an exception log ( */
121 typedef struct _ex_exception_log_t
122 {
123 EX_HEADER_T header;
124 unsigned char reserved1[12];
125 EX_ENVINFO_T envinfo;
126 unsigned char reserved2[36];
127 EX_CONTENT_T content;
128 }EX_LOG_T;
129
130 typedef struct dump_debug_info
131 {
132 unsigned int type;
133 char *name;
134 unsigned int more_info;
135 union {
136 struct {
137
138 char file_name[30];
139 int line_num;
140 unsigned int parameters[3];
141 } assert;
142 struct {
143 int err_code1;
144 int err_code2;
145
146 }fatal_error;
147 CCCI_BUFF_T data;
148 struct {
149 unsigned char execution_unit[9]; // 8+1
150 char file_name[30];
151 int line_num;
152 unsigned int parameters[3];
153 }dsp_assert;
154 struct {
155 unsigned char execution_unit[9];
156 unsigned int code1;
157 }dsp_exception;
158 struct {
159 unsigned char execution_unit[9];
160 unsigned int err_code[2];
161 }dsp_fatal_err;
162 };
163 int *ext_mem;
164 size_t ext_size;
165 int *md_image;
166 size_t md_size;
167 void *platform_data;
168 void (*platform_call)(void *data);
169 }DEBUG_INFO_T ;
170
171
172 typedef enum EEMCS_EXCEPTION_STATE_e {
173 EEMCS_EX_INVALID = -1,
174 EEMCS_EX_NONE = 0,
175 EEMCS_EX_INIT = 1,
176 EEMCS_EX_DHL_DL_RDY = 2,
177 EEMCS_EX_INIT_DONE = 3,
178 EEMCS_EX_MSG_OK = 4,
179 EEMCS_EX_REC_MSG_OK = 5,
180 } EEMCS_EXCEPTION_STATE;
181
182
183 typedef struct
184 {
185 KAL_UINT32 hif_type;
186 KAL_UINT32 expt_txq_id;
187 KAL_UINT32 expt_rxq_id;
188 }ccci_expt_port_cfg;
189
190 typedef struct EEMCS_EXCEPTION_RECORD_st {
191 KAL_UINT32 id; // qno for Q, port id for port
192 struct sk_buff_head skb_list;
193 atomic_t pkt_cnt;
194 } EEMCS_EXCEPTION_RECORD;
195
196 typedef void (*EEMCS_CCCI_EXCEPTION_IND_CALLBACK)(KAL_UINT32 msg_id);
197
198 //#define CCCI_CDEV_NUM (END_OF_CCCI_CDEV - START_OF_CCCI_CDEV)
199 #define CCCI_CDEV_NUM (CCCI_PORT_NUM_MAX - START_OF_CCCI_CDEV)
200 #define CCCI_PORT_NUM CCCI_PORT_NUM_MAX
201 typedef struct EEMCS_EXCEPTION_SET_st {
202 int md_ex_type;
203 spinlock_t expt_cb_lock;
204 struct timer_list md_ex_monitor;
205 EEMCS_CCCI_EXCEPTION_IND_CALLBACK expt_cb[CCCI_PORT_NUM_MAX];
206 KAL_UINT8 *expt_info_mem;
207
208 EEMCS_EXCEPTION_RECORD txq[SDIO_TX_Q_NUM];
209 EEMCS_EXCEPTION_RECORD rxq[SDIO_RX_Q_NUM];
210 EEMCS_EXCEPTION_RECORD port[CCCI_PORT_NUM]; // Record CHAR DEV DL PKTs
211 atomic_t ptx_blk_cnt[CCCI_PORT_NUM]; // Tx operation blocked in DEVICE layer
212 atomic_t prx_blk_cnt[CCCI_PORT_NUM]; // Rx operation blocked in DEVICE layer
213 atomic_t ptx_drp_cnt[CCCI_PORT_NUM]; // Tx operation dropped in DEVICE layer
214 atomic_t prx_drp_cnt[CCCI_PORT_NUM]; // Rx operation dropped in DEVICE layer
215 atomic_t ccci_tx_drp_cnt[CCCI_PORT_NUM]; // Tx operation dropped in CCCI layer
216 atomic_t ccci_rx_drp_cnt[CCCI_PORT_NUM]; // Rx operation dropped in CCCI layer
217 } EEMCS_EXCEPTION_SET;
218
219 typedef struct{
220 KAL_UINT32 TsId;
221 KAL_UINT32 TimeStp;
222 } MD_BOOTUP_TRACE;
223
224 /*******************************************************************************
225 * A P I s
226 ********************************************************************************/
227 KAL_INT32 eemcs_expt_handshake(struct sk_buff *skb);
228 KAL_INT32 eemcs_bootup_trace(struct sk_buff *skb);
229 void eemcs_aed(unsigned int dump_flag, char *aed_str);
230 KAL_INT32 get_md_expt_type(void);
231
232 KAL_INT32 eemcs_expt_mod_init(void);
233 void eemcs_expt_exit(void);
234 KAL_UINT32 eemcs_register_expt_callback(EEMCS_CCCI_EXCEPTION_IND_CALLBACK func_ptr);
235 KAL_UINT32 eemcs_unregister_expt_callback(KAL_UINT32 id);
236 KAL_INT32 eemcs_expt_log_port(struct sk_buff *skb, KAL_UINT32 port_id);
237
238 void eemcs_expt_dev_tx_block(KAL_UINT32 port_id);
239 void eemcs_expt_dev_tx_drop(KAL_UINT32 port_id);
240 void eemcs_expt_dev_rx_block(KAL_UINT32 port_id);
241 void eemcs_expt_dev_rx_drop(KAL_UINT32 port_id);
242 void eemcs_expt_ccci_tx_drop(KAL_UINT32 port_id);
243 void eemcs_expt_ccci_rx_drop(KAL_UINT32 port_id);
244 KAL_INT32 eemcs_expt_flush(void);
245 void eemcs_expt_reset(void);
246
247 kal_bool set_exception_mode(EEMCS_EXCEPTION_STATE mode);
248 kal_bool is_exception_mode(EEMCS_EXCEPTION_STATE *mode);
249 kal_bool is_valid_exception_port(KAL_UINT32 port_id, kal_bool is_rx);
250 kal_bool is_valid_exception_tx_channel(CCCI_CHANNEL_T chn);
251 ccci_expt_port_cfg* get_expt_port_info(KAL_UINT32 port_id);
252
253 ssize_t eemcs_expt_show_statistics(char *buf);
254 void eemcs_expt_reset_statistics(void);
255
256
257 #define hif_expt_dl_pkt_in_swq mtlte_df_DL_pkt_in_swq
258 #define hif_expt_dl_read_swq mtlte_df_DL_read_skb_from_swq
259 #define hif_expt_dl_pkt_handle_complete mtlte_df_DL_pkt_handle_complete
260 #define hif_expt_ul_pkt_in_swq mtlte_df_UL_pkt_in_swq
261 //#define hif_expt_ul_read_swq mtlte_df_UL_read_skb_from_swq
262
263
264
265 #endif // __EEMCS_EXPT_H__