treewide: remove duplicate includes
[linux-2.6.git] / drivers / staging / westbridge / astoria / gadget / cyasgadget.h
blob668e03f9e8ad8393b66eaebff87d91cffb7739b7
1 /* cyangadget.h - Linux USB Gadget driver file for the Cypress West Bridge
2 ## ===========================
3 ## Copyright (C) 2010 Cypress Semiconductor
4 ##
5 ## This program is free software; you can redistribute it and/or
6 ## modify it under the terms of the GNU General Public License
7 ## as published by the Free Software Foundation; either version 2
8 ## of the License, or (at your option) any later version.
9 ##
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program; if not, write to the Free Software
17 ## Foundation, Inc., 51 Franklin Street, Fifth Floor
18 ## Boston, MA 02110-1301, USA.
19 ## ===========================
23 * Cypress West Bridge high/full speed USB device controller code
24 * Based on the Netchip 2280 device controller by David Brownell
25 * in the linux 2.6.10 kernel
27 * linux/drivers/usb/gadget/net2280.h
31 * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
32 * Copyright (C) 2003 David Brownell
34 * This program is free software; you can redistribute it and/or modify
35 * it under the terms of the GNU General Public License as published by
36 * the Free Software Foundation; either version 2 of the License, or
37 * (at your option) any later version.
39 * This program is distributed in the hope that it will be useful,
40 * but WITHOUT ANY WARRANTY; without even the implied warranty of
41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42 * GNU General Public License for more details.
44 * You should have received a copy of the GNU General Public License
45 * along with this program; if not, write to the Free Software
46 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
49 #ifndef _INCLUDED_CYANGADGET_H_
50 #define _INCLUDED_CYANGADGET_H_
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 #include <linux/module.h>
58 #include <linux/init.h>
60 #include "../include/linux/westbridge/cyastoria.h"
61 #include "../include/linux/westbridge/cyashal.h"
62 #include "../include/linux/westbridge/cyasdevice.h"
63 #include "cyasgadget_ioctl.h"
65 /*char driver defines, revisit*/
66 #include <linux/fs.h> /* everything... */
67 #include <linux/errno.h> /* error codes */
68 #include <linux/types.h> /* size_t */
69 #include <linux/proc_fs.h>
70 #include <linux/fcntl.h> /* O_ACCMODE */
71 #include <linux/seq_file.h>
72 #include <linux/cdev.h>
73 #include <linux/scatterlist.h>
74 #include <linux/pagemap.h>
75 #include <linux/vmalloc.h> /* vmalloc(), vfree */
76 #include <linux/msdos_fs.h> /*fat_alloc_cluster*/
77 #include <linux/buffer_head.h>
78 #include <asm/system.h> /* cli(), *_flags */
79 #include <linux/uaccess.h> /* copy_*_user */
81 extern int mpage_cleardirty(struct address_space *mapping, int num_pages);
82 extern int fat_get_block(struct inode *, sector_t , struct buffer_head *, int);
83 extern cy_as_device_handle *cyasdevice_getdevhandle(void);
85 /* Driver data structures and utilities */
86 typedef struct cyasgadget_ep {
87 struct usb_ep usb_ep_inst;
88 struct cyasgadget *dev;
90 /* analogous to a host-side qh */
91 struct list_head queue;
92 const struct usb_endpoint_descriptor *desc;
93 unsigned num:8,
94 fifo_size:12,
95 in_fifo_validate:1,
96 out_overflow:1,
97 stopped:1,
98 is_in:1,
99 is_iso:1;
100 cy_as_usb_end_point_config cyepconfig;
101 } cyasgadget_ep;
103 typedef struct cyasgadget_req {
104 struct usb_request req;
105 struct list_head queue;
106 int ep_num;
107 unsigned mapped:1,
108 valid:1,
109 complete:1,
110 ep_stopped:1;
111 } cyasgadget_req;
113 typedef struct cyasgadget {
114 /* each device provides one gadget, several endpoints */
115 struct usb_gadget gadget;
116 spinlock_t lock;
117 struct cyasgadget_ep an_gadget_ep[16];
118 struct usb_gadget_driver *driver;
119 /* Handle to the West Bridge device */
120 cy_as_device_handle dev_handle;
121 unsigned enabled:1,
122 protocol_stall:1,
123 softconnect:1,
124 outsetupreq:1;
125 struct completion thread_complete;
126 wait_queue_head_t thread_wq;
127 struct semaphore thread_sem;
128 struct list_head thread_queue;
130 cy_bool tmtp_send_complete;
131 cy_bool tmtp_get_complete;
132 cy_bool tmtp_need_new_blk_tbl;
133 /* Data member used to store the SendObjectComplete event data */
134 cy_as_mtp_send_object_complete_data tmtp_send_complete_data;
135 /* Data member used to store the GetObjectComplete event data */
136 cy_as_mtp_get_object_complete_data tmtp_get_complete_data;
138 } cyasgadget;
140 static inline void set_halt(cyasgadget_ep *ep)
142 return;
145 static inline void clear_halt(cyasgadget_ep *ep)
147 return;
150 #define xprintk(dev, level, fmt, args...) \
151 printk(level "%s %s: " fmt, driver_name, \
152 pci_name(dev->pdev), ## args)
154 #ifdef DEBUG
155 #undef DEBUG
156 #define DEBUG(dev, fmt, args...) \
157 xprintk(dev, KERN_DEBUG, fmt, ## args)
158 #else
159 #define DEBUG(dev, fmt, args...) \
160 do { } while (0)
161 #endif /* DEBUG */
163 #ifdef VERBOSE
164 #define VDEBUG DEBUG
165 #else
166 #define VDEBUG(dev, fmt, args...) \
167 do { } while (0)
168 #endif /* VERBOSE */
170 #define ERROR(dev, fmt, args...) \
171 xprintk(dev, KERN_ERR, fmt, ## args)
172 #define GADG_WARN(dev, fmt, args...) \
173 xprintk(dev, KERN_WARNING, fmt, ## args)
174 #define INFO(dev, fmt, args...) \
175 xprintk(dev, KERN_INFO, fmt, ## args)
177 /*-------------------------------------------------------------------------*/
179 static inline void start_out_naking(struct cyasgadget_ep *ep)
181 return;
184 static inline void stop_out_naking(struct cyasgadget_ep *ep)
186 return;
189 #endif /* _INCLUDED_CYANGADGET_H_ */