Duy Truong | 790f06d | 2013-02-13 16:38:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2011-2012, The Linux Foundation. All rights reserved. |
Hemant Kumar | 37c35e4 | 2011-09-14 23:44:19 -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 __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 | |
| 24 | struct 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 Kumar | 148c532 | 2012-09-07 15:57:38 -0700 | [diff] [blame] | 37 | struct usb_anchor rx_submitted; |
Hemant Kumar | 37c35e4 | 2011-09-14 23:44:19 -0700 | [diff] [blame] | 38 | 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 Kumar | 148c532 | 2012-09-07 15:57:38 -0700 | [diff] [blame] | 48 | struct workqueue_struct *wq; |
| 49 | struct work_struct get_encap_work; |
| 50 | |
Hemant Kumar | 37c35e4 | 2011-09-14 23:44:19 -0700 | [diff] [blame] | 51 | unsigned is_opened; |
| 52 | |
Hemant Kumar | 4a466c3 | 2012-06-25 14:52:24 -0700 | [diff] [blame] | 53 | bool is_connected; |
| 54 | |
Hemant Kumar | 37c35e4 | 2011-09-14 23:44:19 -0700 | [diff] [blame] | 55 | /*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 Kumar | 148c532 | 2012-09-07 15:57:38 -0700 | [diff] [blame] | 73 | unsigned int get_encap_failure_cnt; |
Hemant Kumar | 37c35e4 | 2011-09-14 23:44:19 -0700 | [diff] [blame] | 74 | unsigned int set_ctrl_line_state_cnt; |
| 75 | unsigned int tx_ctrl_err_cnt; |
Hemant Kumar | e175776 | 2012-04-13 16:53:09 -0700 | [diff] [blame] | 76 | unsigned int zlp_cnt; |
Hemant Kumar | 37c35e4 | 2011-09-14 23:44:19 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | extern struct rmnet_ctrl_dev *ctrl_dev[]; |
| 80 | |
Hemant Kumar | d9b4e69 | 2012-08-15 09:18:00 -0700 | [diff] [blame] | 81 | extern int rmnet_usb_ctrl_start_rx(struct rmnet_ctrl_dev *); |
Hemant Kumar | 148c532 | 2012-09-07 15:57:38 -0700 | [diff] [blame] | 82 | extern int rmnet_usb_ctrl_suspend(struct rmnet_ctrl_dev *dev); |
Hemant Kumar | 37c35e4 | 2011-09-14 23:44:19 -0700 | [diff] [blame] | 83 | extern int rmnet_usb_ctrl_init(void); |
| 84 | extern void rmnet_usb_ctrl_exit(void); |
| 85 | extern int rmnet_usb_ctrl_probe(struct usb_interface *intf, |
| 86 | struct usb_host_endpoint *status, |
| 87 | struct rmnet_ctrl_dev *dev); |
| 88 | extern void rmnet_usb_ctrl_disconnect(struct rmnet_ctrl_dev *); |
| 89 | |
| 90 | #endif /* __RMNET_USB_H*/ |