blob: f0c169fc48e52370a5c3cf87936b82623ee87765 [file] [log] [blame]
Duy Truong790f06d2013-02-13 16:38:12 -08001/* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved.
Hemant Kumar37c35e42011-09-14 23:44:19 -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 __RMNET_USB_CTRL_H
14#define __RMNET_USB_CTRL_H
15
16#include <linux/mutex.h>
17#include <linux/usb.h>
18#include <linux/cdev.h>
19#include <linux/usb/ch9.h>
20#include <linux/usb/cdc.h>
21
22#define CTRL_DEV_MAX_LEN 10
23
24struct rmnet_ctrl_dev {
25
26 /*for debugging purpose*/
27 char name[CTRL_DEV_MAX_LEN];
28
29 struct cdev cdev;
30 struct device *devicep;
31
32 struct usb_interface *intf;
33 unsigned int int_pipe;
34 struct urb *rcvurb;
35 struct urb *inturb;
36 struct usb_anchor tx_submitted;
Hemant Kumar148c5322012-09-07 15:57:38 -070037 struct usb_anchor rx_submitted;
Hemant Kumar37c35e42011-09-14 23:44:19 -070038 void *rcvbuf;
39 void *intbuf;
40 struct usb_ctrlrequest *in_ctlreq;
41
42 spinlock_t rx_lock;
43 struct mutex dev_lock;
44 struct list_head rx_list;
45 wait_queue_head_t read_wait_queue;
46 wait_queue_head_t open_wait_queue;
47
Hemant Kumar148c5322012-09-07 15:57:38 -070048 struct workqueue_struct *wq;
49 struct work_struct get_encap_work;
50
Hemant Kumar37c35e42011-09-14 23:44:19 -070051 unsigned is_opened;
52
Hemant Kumar4a466c32012-06-25 14:52:24 -070053 bool is_connected;
54
Hemant Kumar37c35e42011-09-14 23:44:19 -070055 /*input control lines (DSR, CTS, CD, RI)*/
56 unsigned int cbits_tolocal;
57
58 /*output control lines (DTR, RTS)*/
59 unsigned int cbits_tomdm;
60
61 /*
62 * track first resp available from mdm when it boots up
63 * to avoid bigger timeout value used by qmuxd
64 */
65 bool resp_available;
66
67 unsigned int mdm_wait_timeout;
68
69 /*counters*/
70 unsigned int snd_encap_cmd_cnt;
71 unsigned int get_encap_resp_cnt;
72 unsigned int resp_avail_cnt;
Hemant Kumar148c5322012-09-07 15:57:38 -070073 unsigned int get_encap_failure_cnt;
Hemant Kumar37c35e42011-09-14 23:44:19 -070074 unsigned int set_ctrl_line_state_cnt;
75 unsigned int tx_ctrl_err_cnt;
Hemant Kumare1757762012-04-13 16:53:09 -070076 unsigned int zlp_cnt;
Hemant Kumar37c35e42011-09-14 23:44:19 -070077};
78
79extern struct rmnet_ctrl_dev *ctrl_dev[];
80
Hemant Kumard9b4e692012-08-15 09:18:00 -070081extern int rmnet_usb_ctrl_start_rx(struct rmnet_ctrl_dev *);
Hemant Kumar148c5322012-09-07 15:57:38 -070082extern int rmnet_usb_ctrl_suspend(struct rmnet_ctrl_dev *dev);
Hemant Kumar37c35e42011-09-14 23:44:19 -070083extern int rmnet_usb_ctrl_init(void);
84extern void rmnet_usb_ctrl_exit(void);
85extern int rmnet_usb_ctrl_probe(struct usb_interface *intf,
86 struct usb_host_endpoint *status,
87 struct rmnet_ctrl_dev *dev);
88extern void rmnet_usb_ctrl_disconnect(struct rmnet_ctrl_dev *);
89
90#endif /* __RMNET_USB_H*/