net:wireless:Support eswin usb wifi ECR6600U
[platform/kernel/linux-starfive.git] / drivers / net / wireless / eswin / usb / usb.h
1 /**
2  ******************************************************************************
3  *
4  * @file usb.h
5  *
6  * @brief usb driver definitions
7  *
8  * Copyright (C) ESWIN 2015-2020
9  *
10  ******************************************************************************
11  */
12
13 #ifndef __USB_H
14 #define __USB_H
15
16 #include "ecrnx_defs.h"
17 #include <linux/usb.h>
18
19 #define USB_INFAC_DATA          0
20 #define USB_INFAC_MSG           1
21
22 #define USB_DIR_MASK    0x80
23 #define USB_NUM_MASK    0x7F
24
25 #define USB_DATA_URB_NUM 64
26 #define USB_MSG_URB_NUM 16
27
28 #define USB_DIR_RX              0
29 #define USB_DIR_TX              1
30
31 #define USB_RX_MAX_BUF_SIZE     4096
32
33 struct usb_infac_pipe {
34         int dir;
35         u32 urb_cnt;
36         struct usb_infac_data_t *infac;
37
38         struct usb_anchor urb_submitted;
39         unsigned int usb_pipe_handle;
40         struct list_head urb_list_head;
41         #ifdef CONFIG_ECRNX_WORKQUEUE
42         struct work_struct io_complete_work;
43         #endif
44         #ifdef CONFIG_ECRNX_TASKLET
45         struct tasklet_struct tx_tasklet;
46         struct tasklet_struct rx_tasklet;
47         #endif
48         struct sk_buff_head io_comp_queue;
49     unsigned int err_count;
50     int err_status;
51 };
52
53
54 struct usb_infac_data_t {
55         struct usb_interface *interface;
56         struct usb_device *udev;
57         u16 max_packet_size;
58
59         struct usb_infac_pipe pipe_rx;
60         struct usb_infac_pipe pipe_tx;
61 };
62
63 struct eswin_usb {
64         struct eswin * p_eswin;
65         struct device * dev;
66         struct usb_infac_data_t infac_data;
67         struct usb_infac_data_t infac_msg;
68         #ifdef CONFIG_ECRNX_KTHREAD
69         struct task_struct *kthread_tx_comp;
70         struct task_struct *kthread_rx_comp;
71
72         wait_queue_head_t wait_tx_comp;
73         wait_queue_head_t wait_rx_comp;
74         #endif
75         spinlock_t cs_lock;
76         u8 usb_enum_already;
77 };
78
79 struct usb_urb_context {
80         struct list_head link;
81         struct sk_buff *skb;
82     struct urb *urb;
83         struct usb_infac_pipe * pipe;
84 };
85
86
87 struct usb_ops {
88         int (*start)(struct eswin *tr);
89         int (*xmit)(struct eswin *tr, struct sk_buff *skb);
90         int (*suspend)(struct eswin *tr);
91         int (*resume)(struct eswin *tr);
92         int (*write)(struct eswin *tr, const void* data, const u32 len);
93         int (*wait_ack)(struct eswin *tr, void* data, const u32 len);
94 };
95
96
97
98 extern int ecrnx_usb_register_drv(void);
99 extern void ecrnx_usb_unregister_drv(void);
100
101 #endif /* __SDIO_H */