1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (c) 2012 GCT Semiconductor, Inc. All rights reserved. */
3 
4 #ifndef _GDM_USB_H_
5 #define _GDM_USB_H_
6 
7 #include <linux/types.h>
8 #include <linux/usb.h>
9 #include <linux/list.h>
10 #include <linux/time.h>
11 
12 #include "gdm_endian.h"
13 #include "hci_packet.h"
14 
15 #define PM_NORMAL 0
16 #define PM_SUSPEND 1
17 #define AUTO_SUSPEND_TIMER 5000 /* ms */
18 
19 #define RX_BUF_SIZE		(1024 * 32)
20 #define TX_BUF_SIZE		(1024 * 32)
21 #define SDU_BUF_SIZE	2048
22 #define MAX_SDU_SIZE	(1024 * 30)
23 #define MAX_PACKET_IN_MULTI_SDU	256
24 
25 #define VID_GCT			0x1076
26 #define PID_GDM7240		0x8000
27 #define PID_GDM7243		0x9000
28 
29 #define NETWORK_INTERFACE 1
30 #define USB_SC_SCSI 0x06
31 #define USB_PR_BULK 0x50
32 
33 #define MAX_NUM_SDU_BUF	64
34 
35 struct usb_tx {
36 	struct list_head list;
37 	struct urb *urb;
38 	u8 *buf;
39 	u32 len;
40 	void (*callback)(void *cb_data);
41 	void *cb_data;
42 	struct tx_cxt *tx;
43 	u8 is_sdu;
44 };
45 
46 struct usb_tx_sdu {
47 	struct list_head list;
48 	u8 *buf;
49 	u32 len;
50 	void (*callback)(void *cb_data);
51 	void *cb_data;
52 };
53 
54 struct usb_rx {
55 	struct list_head to_host_list;
56 	struct list_head free_list;
57 	struct list_head rx_submit_list;
58 	struct rx_cxt	*rx;
59 	struct urb *urb;
60 	u8 *buf;
61 	int (*callback)(void *cb_data, void *data, int len, int context);
62 	void *cb_data;
63 	void *index;
64 };
65 
66 struct tx_cxt {
67 	struct list_head sdu_list;
68 	struct list_head hci_list;
69 	struct list_head free_list;
70 	u32 avail_count;
71 	spinlock_t lock;
72 };
73 
74 struct rx_cxt {
75 	struct list_head to_host_list;
76 	struct list_head rx_submit_list;
77 	struct list_head free_list;
78 	u32	avail_count;
79 	spinlock_t to_host_lock;
80 	spinlock_t rx_lock;
81 	spinlock_t submit_lock;
82 };
83 
84 struct lte_udev {
85 	struct usb_device *usbdev;
86 	struct tx_cxt tx;
87 	struct rx_cxt rx;
88 	struct delayed_work work_tx;
89 	struct delayed_work work_rx;
90 	u8 gdm_ed;
91 	u8 send_complete;
92 	u8 tx_stop;
93 	struct usb_interface *intf;
94 	int (*rx_cb)(void *cb_data, void *data, int len, int context);
95 	int usb_state;
96 	u8 request_mac_addr;
97 };
98 
99 #endif /* _GDM_USB_H_ */
100