blob: 371d31965a31ca652a9626594fa0347f953bff6f [file] [log] [blame]
Dixon Peterson32e70bb2011-12-16 13:26:45 -08001/* Copyright (c) 2008-2012, Code Aurora Forum. All rights reserved.
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -07002 *
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>
20#include <linux/workqueue.h>
21#include <mach/msm_smd.h>
22#include <asm/atomic.h>
23#include <asm/mach-types.h>
24/* Size of the USB buffers used for read and write*/
25#define USB_MAX_OUT_BUF 4096
26#define IN_BUF_SIZE 16384
27#define MAX_IN_BUF_SIZE 32768
28#define MAX_SYNC_OBJ_NAME_SIZE 32
29/* Size of the buffer used for deframing a packet
30 reveived from the PC tool*/
31#define HDLC_MAX 4096
32#define HDLC_OUT_BUF_SIZE 8192
33#define POOL_TYPE_COPY 1
34#define POOL_TYPE_HDLC 2
35#define POOL_TYPE_WRITE_STRUCT 4
36#define POOL_TYPE_ALL 7
37#define MODEM_DATA 1
38#define QDSP_DATA 2
39#define APPS_DATA 3
40#define SDIO_DATA 4
41#define WCNSS_DATA 5
Dixon Peterson32e70bb2011-12-16 13:26:45 -080042#define HSIC_DATA 6
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070043#define MODEM_PROC 0
44#define APPS_PROC 1
45#define QDSP_PROC 2
46#define WCNSS_PROC 3
47#define MSG_MASK_SIZE 8000
48#define LOG_MASK_SIZE 8000
49#define EVENT_MASK_SIZE 1000
Shalabh Jain69890aa2011-10-10 12:59:16 -070050#define USER_SPACE_DATA 8000
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070051#define PKT_SIZE 4096
52#define MAX_EQUIP_ID 12
53
54/* Maximum number of pkt reg supported at initialization*/
Shalabh Jainfe02b0c2012-02-21 14:48:03 -080055extern unsigned int diag_max_reg;
56extern unsigned int diag_threshold_reg;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -070057
58#define APPEND_DEBUG(ch) \
59do { \
60 diag_debug_buf[diag_debug_buf_idx] = ch; \
61 (diag_debug_buf_idx < 1023) ? \
62 (diag_debug_buf_idx++) : (diag_debug_buf_idx = 0); \
63} while (0)
64
65struct diag_master_table {
66 uint16_t cmd_code;
67 uint16_t subsys_id;
68 uint32_t client_id;
69 uint16_t cmd_code_lo;
70 uint16_t cmd_code_hi;
71 int process_id;
72};
73
74struct bindpkt_params_per_process {
75 /* Name of the synchronization object associated with this proc */
76 char sync_obj_name[MAX_SYNC_OBJ_NAME_SIZE];
77 uint32_t count; /* Number of entries in this bind */
78 struct bindpkt_params *params; /* first bind params */
79};
80
81struct bindpkt_params {
82 uint16_t cmd_code;
83 uint16_t subsys_id;
84 uint16_t cmd_code_lo;
85 uint16_t cmd_code_hi;
86 /* For Central Routing, used to store Processor number */
87 uint16_t proc_id;
88 uint32_t event_id;
89 uint32_t log_code;
90 /* For Central Routing, used to store SMD channel pointer */
91 uint32_t client_id;
92};
93
94struct diag_write_device {
95 void *buf;
96 int length;
97};
98
99struct diag_client_map {
100 char name[20];
101 int pid;
102};
103
104/* This structure is defined in USB header file */
105#ifndef CONFIG_DIAG_OVER_USB
106struct diag_request {
107 char *buf;
108 int length;
109 int actual;
110 int status;
111 void *context;
112};
113#endif
114
115struct diagchar_dev {
116
117 /* State for the char driver */
118 unsigned int major;
119 unsigned int minor_start;
120 int num;
121 struct cdev *cdev;
122 char *name;
123 int dropped_count;
124 struct class *diagchar_class;
125 int ref_count;
126 struct mutex diagchar_mutex;
127 wait_queue_head_t wait_q;
128 struct diag_client_map *client_map;
129 int *data_ready;
130 int num_clients;
Shalabh Jain3d29fc32012-02-09 17:15:59 -0800131 int polling_reg_flag;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700132 struct diag_write_device *buf_tbl;
133
134 /* Memory pool parameters */
135 unsigned int itemsize;
136 unsigned int poolsize;
137 unsigned int itemsize_hdlc;
138 unsigned int poolsize_hdlc;
139 unsigned int itemsize_write_struct;
140 unsigned int poolsize_write_struct;
141 unsigned int debug_flag;
142 /* State for the mempool for the char driver */
143 mempool_t *diagpool;
144 mempool_t *diag_hdlc_pool;
145 mempool_t *diag_write_struct_pool;
146 struct mutex diagmem_mutex;
147 int count;
148 int count_hdlc_pool;
149 int count_write_struct_pool;
150 int used;
Shalabh Jain2c783cb2012-01-15 11:09:29 +0530151
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700152 /* State for diag forwarding */
153 unsigned char *buf_in_1;
154 unsigned char *buf_in_2;
155 unsigned char *buf_in_cntl;
156 unsigned char *buf_in_qdsp_1;
157 unsigned char *buf_in_qdsp_2;
158 unsigned char *buf_in_qdsp_cntl;
159 unsigned char *buf_in_wcnss;
160 unsigned char *buf_in_wcnss_cntl;
161 unsigned char *usb_buf_out;
162 unsigned char *apps_rsp_buf;
Shalabh Jain69890aa2011-10-10 12:59:16 -0700163 unsigned char *user_space_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700164 smd_channel_t *ch;
165 smd_channel_t *ch_cntl;
166 smd_channel_t *chqdsp;
167 smd_channel_t *chqdsp_cntl;
168 smd_channel_t *ch_wcnss;
169 smd_channel_t *ch_wcnss_cntl;
170 int in_busy_1;
171 int in_busy_2;
172 int in_busy_qdsp_1;
173 int in_busy_qdsp_2;
174 int in_busy_wcnss;
175 int read_len_legacy;
176 unsigned char *hdlc_buf;
177 unsigned hdlc_count;
178 unsigned hdlc_escape;
179#ifdef CONFIG_DIAG_OVER_USB
180 int usb_connected;
181 struct usb_diag_ch *legacy_ch;
182 struct work_struct diag_proc_hdlc_work;
183 struct work_struct diag_read_work;
184#endif
185 struct workqueue_struct *diag_wq;
186 struct work_struct diag_drain_work;
187 struct work_struct diag_read_smd_work;
188 struct work_struct diag_read_smd_cntl_work;
189 struct work_struct diag_read_smd_qdsp_work;
190 struct work_struct diag_read_smd_qdsp_cntl_work;
191 struct work_struct diag_read_smd_wcnss_work;
192 struct work_struct diag_read_smd_wcnss_cntl_work;
193 uint8_t *msg_masks;
194 uint8_t *log_masks;
195 int log_masks_length;
196 uint8_t *event_masks;
197 struct diag_master_table *table;
198 uint8_t *pkt_buf;
199 int pkt_length;
200 struct diag_request *write_ptr_1;
201 struct diag_request *write_ptr_2;
202 struct diag_request *usb_read_ptr;
203 struct diag_request *write_ptr_svc;
204 struct diag_request *write_ptr_qdsp_1;
205 struct diag_request *write_ptr_qdsp_2;
206 struct diag_request *write_ptr_wcnss;
207 int logging_mode;
Shalabh Jainc236f982011-12-15 22:55:20 -0800208 int mask_check;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700209 int logging_process_id;
210#ifdef CONFIG_DIAG_SDIO_PIPE
211 unsigned char *buf_in_sdio;
212 unsigned char *usb_buf_mdm_out;
213 struct sdio_channel *sdio_ch;
214 int read_len_mdm;
215 int in_busy_sdio;
216 struct usb_diag_ch *mdm_ch;
217 struct work_struct diag_read_mdm_work;
218 struct workqueue_struct *diag_sdio_wq;
219 struct work_struct diag_read_sdio_work;
Shalabh Jain5d9ba342011-08-10 13:51:54 -0700220 struct work_struct diag_close_sdio_work;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700221 struct diag_request *usb_read_mdm_ptr;
222 struct diag_request *write_ptr_mdm;
223#endif
Dixon Peterson32e70bb2011-12-16 13:26:45 -0800224#ifdef CONFIG_DIAG_HSIC_PIPE
225 unsigned char *buf_in_hsic;
226 unsigned char *usb_buf_mdm_out;
227 int hsic_initialized;
228 int hsic_ch;
229 int hsic_device_enabled;
230 int hsic_device_opened;
231 int read_len_mdm;
232 int in_busy_hsic_read_on_mdm;
233 int in_busy_hsic_write_on_mdm;
234 int in_busy_hsic_write;
235 int in_busy_hsic_read;
236 int usb_mdm_connected;
237 struct usb_diag_ch *mdm_ch;
238 struct workqueue_struct *diag_hsic_wq;
239 struct work_struct diag_read_mdm_work;
240 struct work_struct diag_read_hsic_work;
241 struct diag_request *usb_read_mdm_ptr;
242 struct diag_request *write_ptr_mdm;
243#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700244};
245
246extern struct diagchar_dev *driver;
247#endif