summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/eswin/usb/usb.h
blob: 27e9592bf30c7f4c57b23a3a4443c3d605df6cad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
 ******************************************************************************
 *
 * @file usb.h
 *
 * @brief usb driver definitions
 *
 * Copyright (C) ESWIN 2015-2020
 *
 ******************************************************************************
 */

#ifndef __USB_H
#define __USB_H

#include "ecrnx_defs.h"
#include <linux/usb.h>

#define USB_INFAC_DATA		0
#define USB_INFAC_MSG		1

#define USB_DIR_MASK	0x80
#define USB_NUM_MASK    0x7F

#define USB_DATA_URB_NUM 64
#define USB_MSG_URB_NUM	16

#define USB_DIR_RX		0
#define USB_DIR_TX		1

#define USB_RX_MAX_BUF_SIZE 	4096

struct usb_infac_pipe {
	int dir;
	u32 urb_cnt;
	struct usb_infac_data_t *infac;

	struct usb_anchor urb_submitted;
	unsigned int usb_pipe_handle;
	struct list_head urb_list_head;
	#ifdef CONFIG_ECRNX_WORKQUEUE
	struct work_struct io_complete_work;
	#endif
	#ifdef CONFIG_ECRNX_TASKLET
	struct tasklet_struct tx_tasklet;
	struct tasklet_struct rx_tasklet;
	#endif
	struct sk_buff_head io_comp_queue;
    unsigned int err_count;
    int err_status;
};


struct usb_infac_data_t {
	struct usb_interface *interface;
	struct usb_device *udev;
	u16 max_packet_size;

	struct usb_infac_pipe pipe_rx;
	struct usb_infac_pipe pipe_tx;
};

struct eswin_usb {
	struct eswin * p_eswin;
	struct device * dev;
	struct usb_infac_data_t infac_data;
	struct usb_infac_data_t infac_msg;
	#ifdef CONFIG_ECRNX_KTHREAD
	struct task_struct *kthread_tx_comp;
	struct task_struct *kthread_rx_comp;

	wait_queue_head_t wait_tx_comp;
	wait_queue_head_t wait_rx_comp;
	#endif
	spinlock_t cs_lock;
	u8 usb_enum_already;
};

struct usb_urb_context {
	struct list_head link;
	struct sk_buff *skb;
    struct urb *urb;
	struct usb_infac_pipe * pipe;
};


struct usb_ops {
	int (*start)(struct eswin *tr);
	int (*xmit)(struct eswin *tr, struct sk_buff *skb);
	int (*suspend)(struct eswin *tr);
	int (*resume)(struct eswin *tr);
	int (*write)(struct eswin *tr, const void* data, const u32 len);
	int (*wait_ack)(struct eswin *tr, void* data, const u32 len);
};



extern int ecrnx_usb_register_drv(void);
extern void ecrnx_usb_unregister_drv(void);

#endif /* __SDIO_H */