Shalabh Jain | b0037c0 | 2013-01-18 12:47:40 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2008-2013, The Linux Foundation. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | */ |
| 12 | |
| 13 | #ifndef DIAGCHAR_H |
| 14 | #define DIAGCHAR_H |
| 15 | |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/module.h> |
| 18 | #include <linux/mempool.h> |
| 19 | #include <linux/mutex.h> |
Dixon Peterson | 5db2e3c | 2012-09-06 19:13:14 -0700 | [diff] [blame] | 20 | #include <linux/spinlock.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 21 | #include <linux/workqueue.h> |
Shalabh Jain | 5e9a92b | 2012-06-07 21:53:49 -0700 | [diff] [blame] | 22 | #include <linux/sched.h> |
Dixon Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 23 | #include <linux/wakelock.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 24 | #include <mach/msm_smd.h> |
| 25 | #include <asm/atomic.h> |
| 26 | #include <asm/mach-types.h> |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 27 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 28 | /* Size of the USB buffers used for read and write*/ |
| 29 | #define USB_MAX_OUT_BUF 4096 |
Ravi Aravamudhan | cc994686 | 2013-07-15 13:31:11 -0700 | [diff] [blame] | 30 | #define APPS_BUF_SIZE 4096 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 31 | #define IN_BUF_SIZE 16384 |
| 32 | #define MAX_IN_BUF_SIZE 32768 |
| 33 | #define MAX_SYNC_OBJ_NAME_SIZE 32 |
| 34 | /* Size of the buffer used for deframing a packet |
| 35 | reveived from the PC tool*/ |
| 36 | #define HDLC_MAX 4096 |
| 37 | #define HDLC_OUT_BUF_SIZE 8192 |
| 38 | #define POOL_TYPE_COPY 1 |
| 39 | #define POOL_TYPE_HDLC 2 |
Dixon Peterson | 6dba757 | 2013-04-12 18:45:16 -0700 | [diff] [blame] | 40 | #define POOL_TYPE_USER 3 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 41 | #define POOL_TYPE_WRITE_STRUCT 4 |
Shalabh Jain | b0037c0 | 2013-01-18 12:47:40 -0800 | [diff] [blame] | 42 | #define POOL_TYPE_HSIC 5 |
| 43 | #define POOL_TYPE_HSIC_2 6 |
| 44 | #define POOL_TYPE_HSIC_WRITE 11 |
| 45 | #define POOL_TYPE_HSIC_2_WRITE 12 |
| 46 | #define POOL_TYPE_ALL 10 |
Ravi Aravamudhan | 46df7d2 | 2013-06-12 11:57:07 -0700 | [diff] [blame] | 47 | |
| 48 | #define POOL_COPY_IDX 0 |
| 49 | #define POOL_HDLC_IDX 1 |
| 50 | #define POOL_USER_IDX 2 |
| 51 | #define POOL_WRITE_STRUCT_IDX 3 |
| 52 | #define POOL_HSIC_IDX 4 |
| 53 | #define POOL_HSIC_2_IDX 5 |
| 54 | #define POOL_HSIC_3_IDX 6 |
| 55 | #define POOL_HSIC_4_IDX 7 |
| 56 | #define POOL_HSIC_WRITE_IDX 8 |
| 57 | #define POOL_HSIC_2_WRITE_IDX 9 |
| 58 | #define POOL_HSIC_3_WRITE_IDX 10 |
| 59 | #define POOL_HSIC_4_WRITE_IDX 11 |
| 60 | |
| 61 | #ifdef CONFIG_DIAGFWD_BRIDGE_CODE |
| 62 | #define NUM_MEMORY_POOLS 12 |
| 63 | #else |
| 64 | #define NUM_MEMORY_POOLS 4 |
| 65 | #endif |
| 66 | |
Ravi Aravamudhan | e131ce1 | 2013-08-21 20:44:50 -0700 | [diff] [blame] | 67 | #define MAX_SSID_PER_RANGE 200 |
| 68 | |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 69 | #define MODEM_DATA 0 |
| 70 | #define LPASS_DATA 1 |
| 71 | #define WCNSS_DATA 2 |
Ashay Jaiswal | 8be3ce8 | 2012-09-13 16:01:54 -0700 | [diff] [blame] | 72 | #define APPS_DATA 3 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 | #define SDIO_DATA 4 |
Dixon Peterson | eecbadb | 2012-12-10 21:59:28 -0800 | [diff] [blame] | 74 | #define HSIC_DATA 5 |
Shalabh Jain | b0037c0 | 2013-01-18 12:47:40 -0800 | [diff] [blame] | 75 | #define HSIC_2_DATA 6 |
| 76 | #define SMUX_DATA 10 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 77 | #define APPS_PROC 1 |
Ravi Aravamudhan | e131ce1 | 2013-08-21 20:44:50 -0700 | [diff] [blame] | 78 | /* |
| 79 | * Each row contains First (uint32_t), Last (uint32_t), Actual |
| 80 | * last (uint32_t) values along with the range of SSIDs |
| 81 | * (MAX_SSID_PER_RANGE*uint32_t). |
| 82 | * And there are MSG_MASK_TBL_CNT rows. |
| 83 | */ |
| 84 | #define MSG_MASK_SIZE ((MAX_SSID_PER_RANGE+3) * 4 * MSG_MASK_TBL_CNT) |
Ravi Aravamudhan | bbcb99f | 2013-11-06 19:43:03 -0800 | [diff] [blame] | 85 | #define MAX_EQUIP_ID 16 |
| 86 | #define MAX_ITEMS_PER_EQUIP_ID 512 |
| 87 | #define LOG_MASK_ITEM_SIZE (5 + MAX_ITEMS_PER_EQUIP_ID) |
| 88 | #define LOG_MASK_SIZE (MAX_EQUIP_ID * LOG_MASK_ITEM_SIZE) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 89 | #define EVENT_MASK_SIZE 1000 |
Dixon Peterson | 6dba757 | 2013-04-12 18:45:16 -0700 | [diff] [blame] | 90 | #define USER_SPACE_DATA 8192 |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 91 | #define PKT_SIZE 4096 |
Ravi Aravamudhan | bbcb99f | 2013-11-06 19:43:03 -0800 | [diff] [blame] | 92 | |
Shalabh Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 93 | #define DIAG_CTRL_MSG_LOG_MASK 9 |
| 94 | #define DIAG_CTRL_MSG_EVENT_MASK 10 |
| 95 | #define DIAG_CTRL_MSG_F3_MASK 11 |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 96 | #define CONTROL_CHAR 0x7E |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 97 | |
Shalabh Jain | 7b20eab | 2012-06-19 17:50:58 -0700 | [diff] [blame] | 98 | #define DIAG_CON_APSS (0x0001) /* Bit mask for APSS */ |
| 99 | #define DIAG_CON_MPSS (0x0002) /* Bit mask for MPSS */ |
| 100 | #define DIAG_CON_LPASS (0x0004) /* Bit mask for LPASS */ |
| 101 | #define DIAG_CON_WCNSS (0x0008) /* Bit mask for WCNSS */ |
| 102 | |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 103 | #define NUM_STM_PROCESSORS 4 |
| 104 | |
| 105 | #define DIAG_STM_MODEM 0x01 |
| 106 | #define DIAG_STM_LPASS 0x02 |
| 107 | #define DIAG_STM_WCNSS 0x04 |
| 108 | #define DIAG_STM_APPS 0x08 |
| 109 | |
Dixon Peterson | dd73a91 | 2014-02-13 18:45:11 -0800 | [diff] [blame] | 110 | #define DIAG_DIAG_STM 0x214 |
| 111 | |
| 112 | #define BAD_PARAM_RESPONSE_MESSAGE 20 |
| 113 | |
Dixon Peterson | 5a26a30 | 2012-11-15 17:26:17 -0800 | [diff] [blame] | 114 | /* |
| 115 | * The status bit masks when received in a signal handler are to be |
| 116 | * used in conjunction with the peripheral list bit mask to determine the |
| 117 | * status for a peripheral. For instance, 0x00010002 would denote an open |
| 118 | * status on the MPSS |
| 119 | */ |
| 120 | #define DIAG_STATUS_OPEN (0x00010000) /* DCI channel open status mask */ |
| 121 | #define DIAG_STATUS_CLOSED (0x00020000) /* DCI channel closed status mask */ |
| 122 | |
Dixon Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 123 | #define MODE_REALTIME 1 |
| 124 | #define MODE_NONREALTIME 0 |
| 125 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 126 | #define NUM_SMD_DATA_CHANNELS 3 |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 127 | #define NUM_SMD_CONTROL_CHANNELS NUM_SMD_DATA_CHANNELS |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 128 | #define NUM_SMD_DCI_CHANNELS 1 |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 129 | #define NUM_SMD_CMD_CHANNELS 1 |
| 130 | #define NUM_SMD_DCI_CMD_CHANNELS 1 |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 131 | |
| 132 | #define SMD_DATA_TYPE 0 |
| 133 | #define SMD_CNTL_TYPE 1 |
| 134 | #define SMD_DCI_TYPE 2 |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 135 | #define SMD_CMD_TYPE 3 |
| 136 | #define SMD_DCI_CMD_TYPE 4 |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 137 | |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 138 | #define DIAG_PROC_DCI 1 |
| 139 | #define DIAG_PROC_MEMORY_DEVICE 2 |
| 140 | |
| 141 | /* Flags to vote the DCI or Memory device process up or down |
| 142 | when it becomes active or inactive */ |
| 143 | #define VOTE_DOWN 0 |
| 144 | #define VOTE_UP 1 |
| 145 | |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 146 | #define DIAG_TS_SIZE 50 |
| 147 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 148 | /* Maximum number of pkt reg supported at initialization*/ |
Mohit Aggarwal | 3aa4586 | 2013-03-05 18:37:58 +0530 | [diff] [blame] | 149 | extern int diag_max_reg; |
| 150 | extern int diag_threshold_reg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 151 | |
| 152 | #define APPEND_DEBUG(ch) \ |
| 153 | do { \ |
| 154 | diag_debug_buf[diag_debug_buf_idx] = ch; \ |
| 155 | (diag_debug_buf_idx < 1023) ? \ |
| 156 | (diag_debug_buf_idx++) : (diag_debug_buf_idx = 0); \ |
| 157 | } while (0) |
| 158 | |
Ashay Jaiswal | a372f8c | 2012-12-12 14:02:38 +0530 | [diff] [blame] | 159 | /* List of remote processor supported */ |
| 160 | enum remote_procs { |
| 161 | MDM = 1, |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 162 | MDM2 = 2, |
| 163 | MDM3 = 3, |
| 164 | MDM4 = 4, |
| 165 | QSC = 5, |
Ashay Jaiswal | a372f8c | 2012-12-12 14:02:38 +0530 | [diff] [blame] | 166 | }; |
| 167 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 168 | struct diag_master_table { |
| 169 | uint16_t cmd_code; |
| 170 | uint16_t subsys_id; |
| 171 | uint32_t client_id; |
| 172 | uint16_t cmd_code_lo; |
| 173 | uint16_t cmd_code_hi; |
| 174 | int process_id; |
| 175 | }; |
| 176 | |
| 177 | struct bindpkt_params_per_process { |
| 178 | /* Name of the synchronization object associated with this proc */ |
| 179 | char sync_obj_name[MAX_SYNC_OBJ_NAME_SIZE]; |
| 180 | uint32_t count; /* Number of entries in this bind */ |
| 181 | struct bindpkt_params *params; /* first bind params */ |
| 182 | }; |
| 183 | |
| 184 | struct bindpkt_params { |
| 185 | uint16_t cmd_code; |
| 186 | uint16_t subsys_id; |
| 187 | uint16_t cmd_code_lo; |
| 188 | uint16_t cmd_code_hi; |
| 189 | /* For Central Routing, used to store Processor number */ |
| 190 | uint16_t proc_id; |
| 191 | uint32_t event_id; |
| 192 | uint32_t log_code; |
| 193 | /* For Central Routing, used to store SMD channel pointer */ |
| 194 | uint32_t client_id; |
| 195 | }; |
| 196 | |
| 197 | struct diag_write_device { |
| 198 | void *buf; |
| 199 | int length; |
| 200 | }; |
| 201 | |
| 202 | struct diag_client_map { |
| 203 | char name[20]; |
| 204 | int pid; |
| 205 | }; |
| 206 | |
Dixon Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 207 | struct diag_nrt_wake_lock { |
| 208 | int enabled; |
| 209 | int ref_count; |
| 210 | int copy_count; |
| 211 | struct wake_lock read_lock; |
| 212 | spinlock_t read_spinlock; |
| 213 | }; |
| 214 | |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 215 | struct real_time_vote_t { |
| 216 | uint16_t proc; |
| 217 | uint8_t real_time_vote; |
| 218 | }; |
| 219 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 220 | /* This structure is defined in USB header file */ |
| 221 | #ifndef CONFIG_DIAG_OVER_USB |
| 222 | struct diag_request { |
| 223 | char *buf; |
| 224 | int length; |
| 225 | int actual; |
| 226 | int status; |
| 227 | void *context; |
| 228 | }; |
| 229 | #endif |
| 230 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 231 | struct diag_smd_info { |
| 232 | int peripheral; /* The peripheral this smd channel communicates with */ |
| 233 | int type; /* The type of smd channel (data, control, dci) */ |
| 234 | uint16_t peripheral_mask; |
Dixon Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 235 | int encode_hdlc; /* Whether data is raw and needs to be hdlc encoded */ |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 236 | |
| 237 | smd_channel_t *ch; |
| 238 | smd_channel_t *ch_save; |
| 239 | |
Dixon Peterson | 25f042b | 2013-02-27 13:00:08 -0800 | [diff] [blame] | 240 | struct mutex smd_ch_mutex; |
| 241 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 242 | int in_busy_1; |
| 243 | int in_busy_2; |
| 244 | |
| 245 | unsigned char *buf_in_1; |
| 246 | unsigned char *buf_in_2; |
| 247 | |
Dixon Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 248 | unsigned char *buf_in_1_raw; |
| 249 | unsigned char *buf_in_2_raw; |
| 250 | |
Dixon Peterson | d2309b4 | 2013-08-28 21:00:05 -0700 | [diff] [blame] | 251 | unsigned int buf_in_1_size; |
| 252 | unsigned int buf_in_2_size; |
| 253 | |
| 254 | unsigned int buf_in_1_raw_size; |
| 255 | unsigned int buf_in_2_raw_size; |
| 256 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 257 | struct diag_request *write_ptr_1; |
| 258 | struct diag_request *write_ptr_2; |
| 259 | |
Dixon Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 260 | struct diag_nrt_wake_lock nrt_lock; |
| 261 | |
Dixon Peterson | bba99ca | 2013-07-10 17:25:20 -0700 | [diff] [blame] | 262 | struct workqueue_struct *wq; |
| 263 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 264 | struct work_struct diag_read_smd_work; |
| 265 | struct work_struct diag_notify_update_smd_work; |
| 266 | int notify_context; |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 267 | struct work_struct diag_general_smd_work; |
| 268 | int general_context; |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 269 | |
| 270 | /* |
| 271 | * Function ptr for function to call to process the data that |
| 272 | * was just read from the smd channel |
| 273 | */ |
| 274 | int (*process_smd_read_data)(struct diag_smd_info *smd_info, |
| 275 | void *buf, int num_bytes); |
| 276 | }; |
| 277 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 278 | struct diagchar_dev { |
| 279 | |
| 280 | /* State for the char driver */ |
| 281 | unsigned int major; |
| 282 | unsigned int minor_start; |
| 283 | int num; |
| 284 | struct cdev *cdev; |
| 285 | char *name; |
| 286 | int dropped_count; |
| 287 | struct class *diagchar_class; |
| 288 | int ref_count; |
| 289 | struct mutex diagchar_mutex; |
| 290 | wait_queue_head_t wait_q; |
Shalabh Jain | c70b3b6 | 2012-08-31 19:11:20 -0700 | [diff] [blame] | 291 | wait_queue_head_t smd_wait_q; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 292 | struct diag_client_map *client_map; |
| 293 | int *data_ready; |
| 294 | int num_clients; |
Shalabh Jain | 3d29fc3 | 2012-02-09 17:15:59 -0800 | [diff] [blame] | 295 | int polling_reg_flag; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 296 | struct diag_write_device *buf_tbl; |
Dixon Peterson | a6d9809 | 2013-05-16 12:26:26 -0700 | [diff] [blame] | 297 | unsigned int buf_tbl_size; |
Dixon Peterson | b4618a4 | 2012-02-29 18:56:31 -0800 | [diff] [blame] | 298 | int use_device_tree; |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 299 | int supports_separate_cmdrsp; |
Dixon Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 300 | int supports_apps_hdlc_encoding; |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 301 | /* The state requested in the STM command */ |
| 302 | int stm_state_requested[NUM_STM_PROCESSORS]; |
| 303 | /* The current STM state */ |
| 304 | int stm_state[NUM_STM_PROCESSORS]; |
| 305 | /* Whether or not the peripheral supports STM */ |
| 306 | int peripheral_supports_stm[NUM_SMD_CONTROL_CHANNELS]; |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 307 | /* DCI related variables */ |
Ravi Aravamudhan | c94a473 | 2013-12-10 10:26:10 -0800 | [diff] [blame] | 308 | struct list_head dci_req_list; |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 309 | struct diag_dci_client_tbl *dci_client_tbl; |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 310 | int dci_tag; |
| 311 | int dci_client_id; |
| 312 | struct mutex dci_mutex; |
| 313 | int num_dci_client; |
| 314 | unsigned char *apps_dci_buf; |
| 315 | int dci_state; |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 316 | struct workqueue_struct *diag_dci_wq; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 317 | /* Memory pool parameters */ |
| 318 | unsigned int itemsize; |
| 319 | unsigned int poolsize; |
| 320 | unsigned int itemsize_hdlc; |
| 321 | unsigned int poolsize_hdlc; |
Dixon Peterson | 6dba757 | 2013-04-12 18:45:16 -0700 | [diff] [blame] | 322 | unsigned int itemsize_user; |
| 323 | unsigned int poolsize_user; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 324 | unsigned int itemsize_write_struct; |
| 325 | unsigned int poolsize_write_struct; |
| 326 | unsigned int debug_flag; |
| 327 | /* State for the mempool for the char driver */ |
| 328 | mempool_t *diagpool; |
| 329 | mempool_t *diag_hdlc_pool; |
Dixon Peterson | 6dba757 | 2013-04-12 18:45:16 -0700 | [diff] [blame] | 330 | mempool_t *diag_user_pool; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 331 | mempool_t *diag_write_struct_pool; |
Ravi Aravamudhan | 850b4c9 | 2013-07-03 17:57:52 -0700 | [diff] [blame] | 332 | spinlock_t diag_mem_lock; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 333 | int count; |
| 334 | int count_hdlc_pool; |
Dixon Peterson | 6dba757 | 2013-04-12 18:45:16 -0700 | [diff] [blame] | 335 | int count_user_pool; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 336 | int count_write_struct_pool; |
| 337 | int used; |
Shalabh Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 338 | /* Buffers for masks */ |
Shalabh Jain | a06c6d7 | 2012-04-30 13:40:35 -0700 | [diff] [blame] | 339 | struct mutex diag_cntl_mutex; |
Shalabh Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 340 | struct diag_ctrl_event_mask *event_mask; |
| 341 | struct diag_ctrl_log_mask *log_mask; |
| 342 | struct diag_ctrl_msg_mask *msg_mask; |
Ravi Aravamudhan | d09f877 | 2012-12-20 14:48:30 -0800 | [diff] [blame] | 343 | struct diag_ctrl_feature_mask *feature_mask; |
Ravi Aravamudhan | bbcb99f | 2013-11-06 19:43:03 -0800 | [diff] [blame] | 344 | struct mutex log_mask_mutex; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 345 | /* State for diag forwarding */ |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 346 | struct diag_smd_info smd_data[NUM_SMD_DATA_CHANNELS]; |
| 347 | struct diag_smd_info smd_cntl[NUM_SMD_CONTROL_CHANNELS]; |
| 348 | struct diag_smd_info smd_dci[NUM_SMD_DCI_CHANNELS]; |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 349 | struct diag_smd_info smd_cmd[NUM_SMD_CMD_CHANNELS]; |
| 350 | struct diag_smd_info smd_dci_cmd[NUM_SMD_DCI_CMD_CHANNELS]; |
Ravi Aravamudhan | 91391ce | 2013-10-01 17:09:50 -0700 | [diff] [blame] | 351 | int rcvd_feature_mask[NUM_SMD_CONTROL_CHANNELS]; |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 352 | int separate_cmdrsp[NUM_SMD_CONTROL_CHANNELS]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 353 | unsigned char *usb_buf_out; |
| 354 | unsigned char *apps_rsp_buf; |
Mohit Aggarwal | a0118b1 | 2013-12-05 17:14:35 +0530 | [diff] [blame] | 355 | unsigned char *user_space_data_buf; |
Shalabh Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 356 | /* buffer for updating mask to peripherals */ |
| 357 | unsigned char *buf_msg_mask_update; |
| 358 | unsigned char *buf_log_mask_update; |
| 359 | unsigned char *buf_event_mask_update; |
Ravi Aravamudhan | d09f877 | 2012-12-20 14:48:30 -0800 | [diff] [blame] | 360 | unsigned char *buf_feature_mask_update; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 361 | int read_len_legacy; |
Dixon Peterson | 25f042b | 2013-02-27 13:00:08 -0800 | [diff] [blame] | 362 | struct mutex diag_hdlc_mutex; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 363 | unsigned char *hdlc_buf; |
| 364 | unsigned hdlc_count; |
| 365 | unsigned hdlc_escape; |
Ravi Aravamudhan | 72c5528 | 2013-03-20 19:29:01 -0700 | [diff] [blame] | 366 | int in_busy_pktdata; |
Ravi Aravamudhan | 37903fe | 2013-06-03 12:35:05 -0700 | [diff] [blame] | 367 | struct device *dci_device; |
| 368 | struct device *dci_cmd_device; |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 369 | /* Variables for non real time mode */ |
| 370 | int real_time_mode; |
| 371 | int real_time_update_busy; |
| 372 | uint16_t proc_active_mask; |
| 373 | uint16_t proc_rt_vote_mask; |
| 374 | struct mutex real_time_mutex; |
| 375 | struct work_struct diag_real_time_work; |
| 376 | struct workqueue_struct *diag_real_time_wq; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 377 | #ifdef CONFIG_DIAG_OVER_USB |
| 378 | int usb_connected; |
| 379 | struct usb_diag_ch *legacy_ch; |
| 380 | struct work_struct diag_proc_hdlc_work; |
| 381 | struct work_struct diag_read_work; |
Mohit Aggarwal | b446577 | 2013-04-18 13:08:07 +0530 | [diff] [blame] | 382 | struct work_struct diag_usb_connect_work; |
| 383 | struct work_struct diag_usb_disconnect_work; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 384 | #endif |
| 385 | struct workqueue_struct *diag_wq; |
| 386 | struct work_struct diag_drain_work; |
Shalabh Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 387 | struct workqueue_struct *diag_cntl_wq; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 388 | uint8_t *msg_masks; |
Ravi Aravamudhan | 987be23 | 2013-08-08 15:46:50 -0700 | [diff] [blame] | 389 | uint8_t msg_status; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 390 | uint8_t *log_masks; |
Ravi Aravamudhan | 987be23 | 2013-08-08 15:46:50 -0700 | [diff] [blame] | 391 | uint8_t log_status; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 392 | uint8_t *event_masks; |
Ravi Aravamudhan | 987be23 | 2013-08-08 15:46:50 -0700 | [diff] [blame] | 393 | uint8_t event_status; |
Ravi Aravamudhan | d09f877 | 2012-12-20 14:48:30 -0800 | [diff] [blame] | 394 | uint8_t log_on_demand_support; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 395 | struct diag_master_table *table; |
| 396 | uint8_t *pkt_buf; |
| 397 | int pkt_length; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 398 | struct diag_request *usb_read_ptr; |
| 399 | struct diag_request *write_ptr_svc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 400 | int logging_mode; |
Shalabh Jain | c236f98 | 2011-12-15 22:55:20 -0800 | [diff] [blame] | 401 | int mask_check; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 402 | int logging_process_id; |
Dixon Peterson | 625ee65 | 2012-06-21 22:03:49 -0700 | [diff] [blame] | 403 | struct task_struct *socket_process; |
Shalabh Jain | 84e3034 | 2012-10-16 16:16:08 -0700 | [diff] [blame] | 404 | struct task_struct *callback_process; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 405 | #ifdef CONFIG_DIAG_SDIO_PIPE |
| 406 | unsigned char *buf_in_sdio; |
| 407 | unsigned char *usb_buf_mdm_out; |
| 408 | struct sdio_channel *sdio_ch; |
| 409 | int read_len_mdm; |
| 410 | int in_busy_sdio; |
| 411 | struct usb_diag_ch *mdm_ch; |
| 412 | struct work_struct diag_read_mdm_work; |
| 413 | struct workqueue_struct *diag_sdio_wq; |
| 414 | struct work_struct diag_read_sdio_work; |
Shalabh Jain | 5d9ba34 | 2011-08-10 13:51:54 -0700 | [diff] [blame] | 415 | struct work_struct diag_close_sdio_work; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 416 | struct diag_request *usb_read_mdm_ptr; |
| 417 | struct diag_request *write_ptr_mdm; |
| 418 | #endif |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 419 | #ifdef CONFIG_DIAGFWD_BRIDGE_CODE |
| 420 | /* common for all bridges */ |
Mohit Aggarwal | b446577 | 2013-04-18 13:08:07 +0530 | [diff] [blame] | 421 | struct work_struct diag_connect_work; |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 422 | struct work_struct diag_disconnect_work; |
Shalabh Jain | f7228dc | 2012-05-23 17:32:05 -0700 | [diff] [blame] | 423 | /* SGLTE variables */ |
| 424 | int lcid; |
| 425 | unsigned char *buf_in_smux; |
| 426 | int in_busy_smux; |
| 427 | int diag_smux_enabled; |
Ashay Jaiswal | 2d8daae | 2012-07-17 17:29:33 +0530 | [diff] [blame] | 428 | int smux_connected; |
Dixon Peterson | 938f860 | 2012-08-17 20:02:57 -0700 | [diff] [blame] | 429 | struct diag_request *write_ptr_mdm; |
Dixon Peterson | 32e70bb | 2011-12-16 13:26:45 -0800 | [diff] [blame] | 430 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 431 | }; |
| 432 | |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 433 | extern struct diag_bridge_dev *diag_bridge; |
Shalabh Jain | b0037c0 | 2013-01-18 12:47:40 -0800 | [diff] [blame] | 434 | extern struct diag_hsic_dev *diag_hsic; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 435 | extern struct diagchar_dev *driver; |
Ravi Aravamudhan | f55dc1d | 2012-12-27 11:51:42 -0800 | [diff] [blame] | 436 | |
| 437 | extern int wrap_enabled; |
| 438 | extern uint16_t wrap_count; |
| 439 | |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 440 | void diag_get_timestamp(char *time_str); |
Ravi Aravamudhan | 8081a13 | 2013-08-02 12:19:28 -0700 | [diff] [blame] | 441 | int diag_find_polling_reg(int i); |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 442 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 443 | #endif |