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 | 5a26a30 | 2012-11-15 17:26:17 -0800 | [diff] [blame] | 110 | /* |
| 111 | * The status bit masks when received in a signal handler are to be |
| 112 | * used in conjunction with the peripheral list bit mask to determine the |
| 113 | * status for a peripheral. For instance, 0x00010002 would denote an open |
| 114 | * status on the MPSS |
| 115 | */ |
| 116 | #define DIAG_STATUS_OPEN (0x00010000) /* DCI channel open status mask */ |
| 117 | #define DIAG_STATUS_CLOSED (0x00020000) /* DCI channel closed status mask */ |
| 118 | |
Dixon Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 119 | #define MODE_REALTIME 1 |
| 120 | #define MODE_NONREALTIME 0 |
| 121 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 122 | #define NUM_SMD_DATA_CHANNELS 3 |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 123 | #define NUM_SMD_CONTROL_CHANNELS NUM_SMD_DATA_CHANNELS |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 124 | #define NUM_SMD_DCI_CHANNELS 1 |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 125 | #define NUM_SMD_CMD_CHANNELS 1 |
| 126 | #define NUM_SMD_DCI_CMD_CHANNELS 1 |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 127 | |
| 128 | #define SMD_DATA_TYPE 0 |
| 129 | #define SMD_CNTL_TYPE 1 |
| 130 | #define SMD_DCI_TYPE 2 |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 131 | #define SMD_CMD_TYPE 3 |
| 132 | #define SMD_DCI_CMD_TYPE 4 |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 133 | |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 134 | #define DIAG_PROC_DCI 1 |
| 135 | #define DIAG_PROC_MEMORY_DEVICE 2 |
| 136 | |
| 137 | /* Flags to vote the DCI or Memory device process up or down |
| 138 | when it becomes active or inactive */ |
| 139 | #define VOTE_DOWN 0 |
| 140 | #define VOTE_UP 1 |
| 141 | |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 142 | #define DIAG_TS_SIZE 50 |
| 143 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 144 | /* Maximum number of pkt reg supported at initialization*/ |
Mohit Aggarwal | 3aa4586 | 2013-03-05 18:37:58 +0530 | [diff] [blame] | 145 | extern int diag_max_reg; |
| 146 | extern int diag_threshold_reg; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 147 | |
| 148 | #define APPEND_DEBUG(ch) \ |
| 149 | do { \ |
| 150 | diag_debug_buf[diag_debug_buf_idx] = ch; \ |
| 151 | (diag_debug_buf_idx < 1023) ? \ |
| 152 | (diag_debug_buf_idx++) : (diag_debug_buf_idx = 0); \ |
| 153 | } while (0) |
| 154 | |
Ashay Jaiswal | a372f8c | 2012-12-12 14:02:38 +0530 | [diff] [blame] | 155 | /* List of remote processor supported */ |
| 156 | enum remote_procs { |
| 157 | MDM = 1, |
Dixon Peterson | f90f358 | 2013-01-26 18:14:17 -0800 | [diff] [blame] | 158 | MDM2 = 2, |
| 159 | MDM3 = 3, |
| 160 | MDM4 = 4, |
| 161 | QSC = 5, |
Ashay Jaiswal | a372f8c | 2012-12-12 14:02:38 +0530 | [diff] [blame] | 162 | }; |
| 163 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 164 | struct diag_master_table { |
| 165 | uint16_t cmd_code; |
| 166 | uint16_t subsys_id; |
| 167 | uint32_t client_id; |
| 168 | uint16_t cmd_code_lo; |
| 169 | uint16_t cmd_code_hi; |
| 170 | int process_id; |
| 171 | }; |
| 172 | |
| 173 | struct bindpkt_params_per_process { |
| 174 | /* Name of the synchronization object associated with this proc */ |
| 175 | char sync_obj_name[MAX_SYNC_OBJ_NAME_SIZE]; |
| 176 | uint32_t count; /* Number of entries in this bind */ |
| 177 | struct bindpkt_params *params; /* first bind params */ |
| 178 | }; |
| 179 | |
| 180 | struct bindpkt_params { |
| 181 | uint16_t cmd_code; |
| 182 | uint16_t subsys_id; |
| 183 | uint16_t cmd_code_lo; |
| 184 | uint16_t cmd_code_hi; |
| 185 | /* For Central Routing, used to store Processor number */ |
| 186 | uint16_t proc_id; |
| 187 | uint32_t event_id; |
| 188 | uint32_t log_code; |
| 189 | /* For Central Routing, used to store SMD channel pointer */ |
| 190 | uint32_t client_id; |
| 191 | }; |
| 192 | |
| 193 | struct diag_write_device { |
| 194 | void *buf; |
| 195 | int length; |
| 196 | }; |
| 197 | |
| 198 | struct diag_client_map { |
| 199 | char name[20]; |
| 200 | int pid; |
| 201 | }; |
| 202 | |
Dixon Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 203 | struct diag_nrt_wake_lock { |
| 204 | int enabled; |
| 205 | int ref_count; |
| 206 | int copy_count; |
| 207 | struct wake_lock read_lock; |
| 208 | spinlock_t read_spinlock; |
| 209 | }; |
| 210 | |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 211 | struct real_time_vote_t { |
| 212 | uint16_t proc; |
| 213 | uint8_t real_time_vote; |
| 214 | }; |
| 215 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 216 | /* This structure is defined in USB header file */ |
| 217 | #ifndef CONFIG_DIAG_OVER_USB |
| 218 | struct diag_request { |
| 219 | char *buf; |
| 220 | int length; |
| 221 | int actual; |
| 222 | int status; |
| 223 | void *context; |
| 224 | }; |
| 225 | #endif |
| 226 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 227 | struct diag_smd_info { |
| 228 | int peripheral; /* The peripheral this smd channel communicates with */ |
| 229 | int type; /* The type of smd channel (data, control, dci) */ |
| 230 | uint16_t peripheral_mask; |
Dixon Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 231 | 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] | 232 | |
| 233 | smd_channel_t *ch; |
| 234 | smd_channel_t *ch_save; |
| 235 | |
Dixon Peterson | 25f042b | 2013-02-27 13:00:08 -0800 | [diff] [blame] | 236 | struct mutex smd_ch_mutex; |
| 237 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 238 | int in_busy_1; |
| 239 | int in_busy_2; |
| 240 | |
| 241 | unsigned char *buf_in_1; |
| 242 | unsigned char *buf_in_2; |
| 243 | |
Dixon Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 244 | unsigned char *buf_in_1_raw; |
| 245 | unsigned char *buf_in_2_raw; |
| 246 | |
Dixon Peterson | d2309b4 | 2013-08-28 21:00:05 -0700 | [diff] [blame] | 247 | unsigned int buf_in_1_size; |
| 248 | unsigned int buf_in_2_size; |
| 249 | |
| 250 | unsigned int buf_in_1_raw_size; |
| 251 | unsigned int buf_in_2_raw_size; |
| 252 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 253 | struct diag_request *write_ptr_1; |
| 254 | struct diag_request *write_ptr_2; |
| 255 | |
Dixon Peterson | f2d449c | 2013-02-01 18:02:20 -0800 | [diff] [blame] | 256 | struct diag_nrt_wake_lock nrt_lock; |
| 257 | |
Dixon Peterson | bba99ca | 2013-07-10 17:25:20 -0700 | [diff] [blame] | 258 | struct workqueue_struct *wq; |
| 259 | |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 260 | struct work_struct diag_read_smd_work; |
| 261 | struct work_struct diag_notify_update_smd_work; |
| 262 | int notify_context; |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 263 | struct work_struct diag_general_smd_work; |
| 264 | int general_context; |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 265 | |
| 266 | /* |
| 267 | * Function ptr for function to call to process the data that |
| 268 | * was just read from the smd channel |
| 269 | */ |
| 270 | int (*process_smd_read_data)(struct diag_smd_info *smd_info, |
| 271 | void *buf, int num_bytes); |
| 272 | }; |
| 273 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 274 | struct diagchar_dev { |
| 275 | |
| 276 | /* State for the char driver */ |
| 277 | unsigned int major; |
| 278 | unsigned int minor_start; |
| 279 | int num; |
| 280 | struct cdev *cdev; |
| 281 | char *name; |
| 282 | int dropped_count; |
| 283 | struct class *diagchar_class; |
| 284 | int ref_count; |
| 285 | struct mutex diagchar_mutex; |
| 286 | wait_queue_head_t wait_q; |
Shalabh Jain | c70b3b6 | 2012-08-31 19:11:20 -0700 | [diff] [blame] | 287 | wait_queue_head_t smd_wait_q; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 288 | struct diag_client_map *client_map; |
| 289 | int *data_ready; |
| 290 | int num_clients; |
Shalabh Jain | 3d29fc3 | 2012-02-09 17:15:59 -0800 | [diff] [blame] | 291 | int polling_reg_flag; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 292 | struct diag_write_device *buf_tbl; |
Dixon Peterson | a6d9809 | 2013-05-16 12:26:26 -0700 | [diff] [blame] | 293 | unsigned int buf_tbl_size; |
Dixon Peterson | b4618a4 | 2012-02-29 18:56:31 -0800 | [diff] [blame] | 294 | int use_device_tree; |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 295 | int supports_separate_cmdrsp; |
Dixon Peterson | 9ce39c6 | 2013-02-21 13:00:52 -0800 | [diff] [blame] | 296 | int supports_apps_hdlc_encoding; |
Dixon Peterson | 15a6ecb | 2013-06-25 12:36:33 -0700 | [diff] [blame] | 297 | /* The state requested in the STM command */ |
| 298 | int stm_state_requested[NUM_STM_PROCESSORS]; |
| 299 | /* The current STM state */ |
| 300 | int stm_state[NUM_STM_PROCESSORS]; |
| 301 | /* Whether or not the peripheral supports STM */ |
| 302 | int peripheral_supports_stm[NUM_SMD_CONTROL_CHANNELS]; |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 303 | /* DCI related variables */ |
Ravi Aravamudhan | c94a473 | 2013-12-10 10:26:10 -0800 | [diff] [blame] | 304 | struct list_head dci_req_list; |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 305 | struct diag_dci_client_tbl *dci_client_tbl; |
Shalabh Jain | 1c99e4c | 2012-03-26 18:47:59 -0700 | [diff] [blame] | 306 | int dci_tag; |
| 307 | int dci_client_id; |
| 308 | struct mutex dci_mutex; |
| 309 | int num_dci_client; |
| 310 | unsigned char *apps_dci_buf; |
| 311 | int dci_state; |
Shalabh Jain | 1679490 | 2012-09-14 10:56:49 -0700 | [diff] [blame] | 312 | struct workqueue_struct *diag_dci_wq; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 313 | /* Memory pool parameters */ |
| 314 | unsigned int itemsize; |
| 315 | unsigned int poolsize; |
| 316 | unsigned int itemsize_hdlc; |
| 317 | unsigned int poolsize_hdlc; |
Dixon Peterson | 6dba757 | 2013-04-12 18:45:16 -0700 | [diff] [blame] | 318 | unsigned int itemsize_user; |
| 319 | unsigned int poolsize_user; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 320 | unsigned int itemsize_write_struct; |
| 321 | unsigned int poolsize_write_struct; |
| 322 | unsigned int debug_flag; |
| 323 | /* State for the mempool for the char driver */ |
| 324 | mempool_t *diagpool; |
| 325 | mempool_t *diag_hdlc_pool; |
Dixon Peterson | 6dba757 | 2013-04-12 18:45:16 -0700 | [diff] [blame] | 326 | mempool_t *diag_user_pool; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 327 | mempool_t *diag_write_struct_pool; |
Ravi Aravamudhan | 850b4c9 | 2013-07-03 17:57:52 -0700 | [diff] [blame] | 328 | spinlock_t diag_mem_lock; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 329 | int count; |
| 330 | int count_hdlc_pool; |
Dixon Peterson | 6dba757 | 2013-04-12 18:45:16 -0700 | [diff] [blame] | 331 | int count_user_pool; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 332 | int count_write_struct_pool; |
| 333 | int used; |
Shalabh Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 334 | /* Buffers for masks */ |
Shalabh Jain | a06c6d7 | 2012-04-30 13:40:35 -0700 | [diff] [blame] | 335 | struct mutex diag_cntl_mutex; |
Shalabh Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 336 | struct diag_ctrl_event_mask *event_mask; |
| 337 | struct diag_ctrl_log_mask *log_mask; |
| 338 | struct diag_ctrl_msg_mask *msg_mask; |
Ravi Aravamudhan | d09f877 | 2012-12-20 14:48:30 -0800 | [diff] [blame] | 339 | struct diag_ctrl_feature_mask *feature_mask; |
Ravi Aravamudhan | bbcb99f | 2013-11-06 19:43:03 -0800 | [diff] [blame] | 340 | struct mutex log_mask_mutex; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 341 | /* State for diag forwarding */ |
Dixon Peterson | 66fb11b | 2012-12-04 20:30:54 -0800 | [diff] [blame] | 342 | struct diag_smd_info smd_data[NUM_SMD_DATA_CHANNELS]; |
| 343 | struct diag_smd_info smd_cntl[NUM_SMD_CONTROL_CHANNELS]; |
| 344 | struct diag_smd_info smd_dci[NUM_SMD_DCI_CHANNELS]; |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 345 | struct diag_smd_info smd_cmd[NUM_SMD_CMD_CHANNELS]; |
| 346 | struct diag_smd_info smd_dci_cmd[NUM_SMD_DCI_CMD_CHANNELS]; |
Ravi Aravamudhan | 91391ce | 2013-10-01 17:09:50 -0700 | [diff] [blame] | 347 | int rcvd_feature_mask[NUM_SMD_CONTROL_CHANNELS]; |
Dixon Peterson | 3ff84ea | 2012-12-21 20:16:18 -0800 | [diff] [blame] | 348 | int separate_cmdrsp[NUM_SMD_CONTROL_CHANNELS]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 349 | unsigned char *usb_buf_out; |
| 350 | unsigned char *apps_rsp_buf; |
Mohit Aggarwal | a0118b1 | 2013-12-05 17:14:35 +0530 | [diff] [blame] | 351 | unsigned char *user_space_data_buf; |
Shalabh Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 352 | /* buffer for updating mask to peripherals */ |
| 353 | unsigned char *buf_msg_mask_update; |
| 354 | unsigned char *buf_log_mask_update; |
| 355 | unsigned char *buf_event_mask_update; |
Ravi Aravamudhan | d09f877 | 2012-12-20 14:48:30 -0800 | [diff] [blame] | 356 | unsigned char *buf_feature_mask_update; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 357 | int read_len_legacy; |
Dixon Peterson | 25f042b | 2013-02-27 13:00:08 -0800 | [diff] [blame] | 358 | struct mutex diag_hdlc_mutex; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 359 | unsigned char *hdlc_buf; |
| 360 | unsigned hdlc_count; |
| 361 | unsigned hdlc_escape; |
Ravi Aravamudhan | 72c5528 | 2013-03-20 19:29:01 -0700 | [diff] [blame] | 362 | int in_busy_pktdata; |
Ravi Aravamudhan | 37903fe | 2013-06-03 12:35:05 -0700 | [diff] [blame] | 363 | struct device *dci_device; |
| 364 | struct device *dci_cmd_device; |
Ravi Aravamudhan | 6a2da56 | 2013-06-17 16:01:34 -0700 | [diff] [blame] | 365 | /* Variables for non real time mode */ |
| 366 | int real_time_mode; |
| 367 | int real_time_update_busy; |
| 368 | uint16_t proc_active_mask; |
| 369 | uint16_t proc_rt_vote_mask; |
| 370 | struct mutex real_time_mutex; |
| 371 | struct work_struct diag_real_time_work; |
| 372 | struct workqueue_struct *diag_real_time_wq; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 373 | #ifdef CONFIG_DIAG_OVER_USB |
| 374 | int usb_connected; |
| 375 | struct usb_diag_ch *legacy_ch; |
| 376 | struct work_struct diag_proc_hdlc_work; |
| 377 | struct work_struct diag_read_work; |
Mohit Aggarwal | b446577 | 2013-04-18 13:08:07 +0530 | [diff] [blame] | 378 | struct work_struct diag_usb_connect_work; |
| 379 | struct work_struct diag_usb_disconnect_work; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 380 | #endif |
| 381 | struct workqueue_struct *diag_wq; |
| 382 | struct work_struct diag_drain_work; |
Shalabh Jain | 321c8b5 | 2012-02-22 12:37:06 -0800 | [diff] [blame] | 383 | struct workqueue_struct *diag_cntl_wq; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 384 | uint8_t *msg_masks; |
Ravi Aravamudhan | 987be23 | 2013-08-08 15:46:50 -0700 | [diff] [blame] | 385 | uint8_t msg_status; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 386 | uint8_t *log_masks; |
Ravi Aravamudhan | 987be23 | 2013-08-08 15:46:50 -0700 | [diff] [blame] | 387 | uint8_t log_status; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 388 | uint8_t *event_masks; |
Ravi Aravamudhan | 987be23 | 2013-08-08 15:46:50 -0700 | [diff] [blame] | 389 | uint8_t event_status; |
Ravi Aravamudhan | d09f877 | 2012-12-20 14:48:30 -0800 | [diff] [blame] | 390 | uint8_t log_on_demand_support; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 391 | struct diag_master_table *table; |
| 392 | uint8_t *pkt_buf; |
| 393 | int pkt_length; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 394 | struct diag_request *usb_read_ptr; |
| 395 | struct diag_request *write_ptr_svc; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 396 | int logging_mode; |
Shalabh Jain | c236f98 | 2011-12-15 22:55:20 -0800 | [diff] [blame] | 397 | int mask_check; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 398 | int logging_process_id; |
Dixon Peterson | 625ee65 | 2012-06-21 22:03:49 -0700 | [diff] [blame] | 399 | struct task_struct *socket_process; |
Shalabh Jain | 84e3034 | 2012-10-16 16:16:08 -0700 | [diff] [blame] | 400 | struct task_struct *callback_process; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 401 | #ifdef CONFIG_DIAG_SDIO_PIPE |
| 402 | unsigned char *buf_in_sdio; |
| 403 | unsigned char *usb_buf_mdm_out; |
| 404 | struct sdio_channel *sdio_ch; |
| 405 | int read_len_mdm; |
| 406 | int in_busy_sdio; |
| 407 | struct usb_diag_ch *mdm_ch; |
| 408 | struct work_struct diag_read_mdm_work; |
| 409 | struct workqueue_struct *diag_sdio_wq; |
| 410 | struct work_struct diag_read_sdio_work; |
Shalabh Jain | 5d9ba34 | 2011-08-10 13:51:54 -0700 | [diff] [blame] | 411 | struct work_struct diag_close_sdio_work; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 412 | struct diag_request *usb_read_mdm_ptr; |
| 413 | struct diag_request *write_ptr_mdm; |
| 414 | #endif |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 415 | #ifdef CONFIG_DIAGFWD_BRIDGE_CODE |
| 416 | /* common for all bridges */ |
Mohit Aggarwal | b446577 | 2013-04-18 13:08:07 +0530 | [diff] [blame] | 417 | struct work_struct diag_connect_work; |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 418 | struct work_struct diag_disconnect_work; |
Shalabh Jain | f7228dc | 2012-05-23 17:32:05 -0700 | [diff] [blame] | 419 | /* SGLTE variables */ |
| 420 | int lcid; |
| 421 | unsigned char *buf_in_smux; |
| 422 | int in_busy_smux; |
| 423 | int diag_smux_enabled; |
Ashay Jaiswal | 2d8daae | 2012-07-17 17:29:33 +0530 | [diff] [blame] | 424 | int smux_connected; |
Dixon Peterson | 938f860 | 2012-08-17 20:02:57 -0700 | [diff] [blame] | 425 | struct diag_request *write_ptr_mdm; |
Dixon Peterson | 32e70bb | 2011-12-16 13:26:45 -0800 | [diff] [blame] | 426 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 427 | }; |
| 428 | |
Shalabh Jain | 737fca7 | 2012-11-14 21:53:43 -0800 | [diff] [blame] | 429 | extern struct diag_bridge_dev *diag_bridge; |
Shalabh Jain | b0037c0 | 2013-01-18 12:47:40 -0800 | [diff] [blame] | 430 | extern struct diag_hsic_dev *diag_hsic; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 431 | extern struct diagchar_dev *driver; |
Ravi Aravamudhan | f55dc1d | 2012-12-27 11:51:42 -0800 | [diff] [blame] | 432 | |
| 433 | extern int wrap_enabled; |
| 434 | extern uint16_t wrap_count; |
| 435 | |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 436 | void diag_get_timestamp(char *time_str); |
Ravi Aravamudhan | 8081a13 | 2013-08-02 12:19:28 -0700 | [diff] [blame] | 437 | int diag_find_polling_reg(int i); |
Ravi Aravamudhan | 3dc6635 | 2013-06-14 10:46:19 -0700 | [diff] [blame] | 438 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 439 | #endif |