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#ifndef _INCLUDED_CYANGADGET_H_
50#define _INCLUDED_CYANGADGET_H_
51
52#include <linux/device.h>
53#include <linux/moduleparam.h>
54#include <linux/usb/ch9.h>
55#include <linux/usb/gadget.h>
56#include <linux/sched.h>
57
58#include "../include/linux/westbridge/cyastoria.h"
59#include "../include/linux/westbridge/cyashal.h"
60#include "../include/linux/westbridge/cyasdevice.h"
61#include "cyasgadget_ioctl.h"
62
63#include <linux/module.h>
64#include <linux/init.h>
65
66
67#include <linux/module.h>
68#include <linux/moduleparam.h>
69#include <linux/init.h>
70#include <linux/fs.h>
71#include <linux/errno.h>
72#include <linux/types.h>
73#include <linux/proc_fs.h>
74#include <linux/fcntl.h>
75#include <linux/seq_file.h>
76#include <linux/cdev.h>
77#include <linux/scatterlist.h>
78#include <linux/pagemap.h>
79#include <linux/vmalloc.h>
80#include <linux/msdos_fs.h>
81#include <linux/buffer_head.h>
82#include <asm/system.h>
83#include <linux/uaccess.h>
84
85extern int mpage_cleardirty(struct address_space *mapping, int num_pages);
86extern int fat_get_block(struct inode *, sector_t , struct buffer_head *, int);
87extern cy_as_device_handle *cyasdevice_getdevhandle(void);
88
89
90typedef struct cyasgadget_ep {
91 struct usb_ep usb_ep_inst;
92 struct cyasgadget *dev;
93
94
95 struct list_head queue;
96 const struct usb_endpoint_descriptor *desc;
97 unsigned num:8,
98 fifo_size:12,
99 in_fifo_validate:1,
100 out_overflow:1,
101 stopped:1,
102 is_in:1,
103 is_iso:1;
104 cy_as_usb_end_point_config cyepconfig;
105} cyasgadget_ep;
106
107typedef struct cyasgadget_req {
108 struct usb_request req;
109 struct list_head queue;
110 int ep_num;
111 unsigned mapped:1,
112 valid:1,
113 complete:1,
114 ep_stopped:1;
115} cyasgadget_req;
116
117typedef struct cyasgadget {
118
119 struct usb_gadget gadget;
120 spinlock_t lock;
121 struct cyasgadget_ep an_gadget_ep[16];
122 struct usb_gadget_driver *driver;
123
124 cy_as_device_handle dev_handle;
125 unsigned enabled:1,
126 protocol_stall:1,
127 softconnect:1,
128 outsetupreq:1;
129 struct completion thread_complete;
130 wait_queue_head_t thread_wq;
131 struct semaphore thread_sem;
132 struct list_head thread_queue;
133
134 cy_bool tmtp_send_complete;
135 cy_bool tmtp_get_complete;
136 cy_bool tmtp_need_new_blk_tbl;
137
138 cy_as_mtp_send_object_complete_data tmtp_send_complete_data;
139
140 cy_as_mtp_get_object_complete_data tmtp_get_complete_data;
141
142} cyasgadget;
143
144static inline void set_halt(cyasgadget_ep *ep)
145{
146 return;
147}
148
149static inline void clear_halt(cyasgadget_ep *ep)
150{
151 return;
152}
153
154#define xprintk(dev, level, fmt, args...) \
155 printk(level "%s %s: " fmt, driver_name, \
156 pci_name(dev->pdev), ## args)
157
158#ifdef DEBUG
159#undef DEBUG
160#define DEBUG(dev, fmt, args...) \
161 xprintk(dev, KERN_DEBUG, fmt, ## args)
162#else
163#define DEBUG(dev, fmt, args...) \
164 do { } while (0)
165#endif
166
167#ifdef VERBOSE
168#define VDEBUG DEBUG
169#else
170#define VDEBUG(dev, fmt, args...) \
171 do { } while (0)
172#endif
173
174#define ERROR(dev, fmt, args...) \
175 xprintk(dev, KERN_ERR, fmt, ## args)
176#define GADG_WARN(dev, fmt, args...) \
177 xprintk(dev, KERN_WARNING, fmt, ## args)
178#define INFO(dev, fmt, args...) \
179 xprintk(dev, KERN_INFO, fmt, ## args)
180
181
182
183static inline void start_out_naking(struct cyasgadget_ep *ep)
184{
185 return;
186}
187
188static inline void stop_out_naking(struct cyasgadget_ep *ep)
189{
190 return;
191}
192
193#endif
194