blob: f493f79fd20041381026b4cd746d6f0103c91680 [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*/
55extern unsigned int diag_max_registration;
56extern unsigned int diag_threshold_registration;
57
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;
131 struct diag_write_device *buf_tbl;
132
133 /* Memory pool parameters */
134 unsigned int itemsize;
135 unsigned int poolsize;
136 unsigned int itemsize_hdlc;
137 unsigned int poolsize_hdlc;
138 unsigned int itemsize_write_struct;
139 unsigned int poolsize_write_struct;
140 unsigned int debug_flag;
141 /* State for the mempool for the char driver */
142 mempool_t *diagpool;
143 mempool_t *diag_hdlc_pool;
144 mempool_t *diag_write_struct_pool;
145 struct mutex diagmem_mutex;
146 int count;
147 int count_hdlc_pool;
148 int count_write_struct_pool;
149 int used;
150
151 /* State for diag forwarding */
152 unsigned char *buf_in_1;
153 unsigned char *buf_in_2;
154 unsigned char *buf_in_cntl;
155 unsigned char *buf_in_qdsp_1;
156 unsigned char *buf_in_qdsp_2;
157 unsigned char *buf_in_qdsp_cntl;
158 unsigned char *buf_in_wcnss;
159 unsigned char *buf_in_wcnss_cntl;
160 unsigned char *usb_buf_out;
161 unsigned char *apps_rsp_buf;
Shalabh Jain69890aa2011-10-10 12:59:16 -0700162 unsigned char *user_space_data;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700163 smd_channel_t *ch;
164 smd_channel_t *ch_cntl;
165 smd_channel_t *chqdsp;
166 smd_channel_t *chqdsp_cntl;
167 smd_channel_t *ch_wcnss;
168 smd_channel_t *ch_wcnss_cntl;
169 int in_busy_1;
170 int in_busy_2;
171 int in_busy_qdsp_1;
172 int in_busy_qdsp_2;
173 int in_busy_wcnss;
174 int read_len_legacy;
175 unsigned char *hdlc_buf;
176 unsigned hdlc_count;
177 unsigned hdlc_escape;
178#ifdef CONFIG_DIAG_OVER_USB
179 int usb_connected;
180 struct usb_diag_ch *legacy_ch;
181 struct work_struct diag_proc_hdlc_work;
182 struct work_struct diag_read_work;
183#endif
184 struct workqueue_struct *diag_wq;
185 struct work_struct diag_drain_work;
186 struct work_struct diag_read_smd_work;
187 struct work_struct diag_read_smd_cntl_work;
188 struct work_struct diag_read_smd_qdsp_work;
189 struct work_struct diag_read_smd_qdsp_cntl_work;
190 struct work_struct diag_read_smd_wcnss_work;
191 struct work_struct diag_read_smd_wcnss_cntl_work;
192 uint8_t *msg_masks;
193 uint8_t *log_masks;
194 int log_masks_length;
195 uint8_t *event_masks;
196 struct diag_master_table *table;
197 uint8_t *pkt_buf;
198 int pkt_length;
199 struct diag_request *write_ptr_1;
200 struct diag_request *write_ptr_2;
201 struct diag_request *usb_read_ptr;
202 struct diag_request *write_ptr_svc;
203 struct diag_request *write_ptr_qdsp_1;
204 struct diag_request *write_ptr_qdsp_2;
205 struct diag_request *write_ptr_wcnss;
206 int logging_mode;
207 int logging_process_id;
208#ifdef CONFIG_DIAG_SDIO_PIPE
209 unsigned char *buf_in_sdio;
210 unsigned char *usb_buf_mdm_out;
211 struct sdio_channel *sdio_ch;
212 int read_len_mdm;
213 int in_busy_sdio;
214 struct usb_diag_ch *mdm_ch;
215 struct work_struct diag_read_mdm_work;
216 struct workqueue_struct *diag_sdio_wq;
217 struct work_struct diag_read_sdio_work;
Shalabh Jain5d9ba342011-08-10 13:51:54 -0700218 struct work_struct diag_close_sdio_work;
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700219 struct diag_request *usb_read_mdm_ptr;
220 struct diag_request *write_ptr_mdm;
221#endif
Dixon Peterson32e70bb2011-12-16 13:26:45 -0800222#ifdef CONFIG_DIAG_HSIC_PIPE
223 unsigned char *buf_in_hsic;
224 unsigned char *usb_buf_mdm_out;
225 int hsic_initialized;
226 int hsic_ch;
227 int hsic_device_enabled;
228 int hsic_device_opened;
229 int read_len_mdm;
230 int in_busy_hsic_read_on_mdm;
231 int in_busy_hsic_write_on_mdm;
232 int in_busy_hsic_write;
233 int in_busy_hsic_read;
234 int usb_mdm_connected;
235 struct usb_diag_ch *mdm_ch;
236 struct workqueue_struct *diag_hsic_wq;
237 struct work_struct diag_read_mdm_work;
238 struct work_struct diag_read_hsic_work;
239 struct diag_request *usb_read_mdm_ptr;
240 struct diag_request *write_ptr_mdm;
241#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700242};
243
244extern struct diagchar_dev *driver;
245#endif