staging: gdm7240: adding LTE USB driver
[cascardo/linux.git] / drivers / staging / gdm724x / gdm_mux.h
1 /*
2  * Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved.
3  *
4  * This software is licensed under the terms of the GNU General Public
5  * License version 2, as published by the Free Software Foundation, and
6  * may be copied, distributed, and modified under those terms.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  */
13
14 #ifndef _GDM_MUX_H_
15 #define _GDM_MUX_H_
16
17 #include <linux/types.h>
18 #include <linux/usb.h>
19 #include <linux/list.h>
20
21 #define PM_NORMAL 0
22 #define PM_SUSPEND 1
23
24 #define USB_RT_ACM          (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
25
26 #define START_FLAG 0xA512485A
27 #define MUX_HEADER_SIZE 14
28 #define MUX_TX_MAX_SIZE (1024*10)
29 #define MUX_RX_MAX_SIZE (1024*30)
30 #define AT_PKT_TYPE 0xF011
31 #define DM_PKT_TYPE 0xF010
32
33 #define RETRY_TIMER 30 /* msec */
34
35 struct mux_pkt_header {
36         unsigned int start_flag;
37         unsigned int seq_num;
38         unsigned int payload_size;
39         unsigned short packet_type;
40         unsigned char data[0];
41 };
42
43 struct mux_tx {
44         struct urb *urb;
45         u8 *buf;
46         int  len;
47         void (*callback)(void *cb_data);
48         void *cb_data;
49 };
50
51 struct mux_rx {
52         struct list_head free_list;
53         struct list_head rx_submit_list;
54         struct list_head to_host_list;
55         struct urb *urb;
56         u8 *buf;
57         void *mux_dev;
58         u32 offset;
59         u32 len;
60         int (*callback)(void *data, int len, int tty_index, int minor, int complete);
61 };
62
63 struct rx_cxt {
64         struct list_head to_host_list;
65         struct list_head rx_submit_list;
66         struct list_head rx_free_list;
67         spinlock_t to_host_lock;
68         spinlock_t submit_list_lock;
69         spinlock_t free_list_lock;
70 };
71
72 struct mux_dev {
73         struct usb_device *usbdev;
74         struct usb_interface *control_intf;
75         struct usb_interface *data_intf;
76         struct rx_cxt   rx;
77         struct delayed_work work_rx;
78         struct usb_interface *intf;
79         int usb_state;
80         int (*rx_cb)(void *data, int len, int tty_index, int minor, int complete);
81         spinlock_t write_lock;
82         u8 minor[2];
83 };
84
85 #endif /* _GDM_MUX_H_ */