block: fix warning with calling smp_processor_id() in preemptible section
[pandora-kernel.git] / drivers / staging / westbridge / astoria / gadget / cyasgadget.h
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.
14 ##
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 ## ===========================
20 */
21
22 /*
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
26  *
27  * linux/drivers/usb/gadget/net2280.h
28  */
29
30 /*
31  * Copyright (C) 2002 NetChip Technology, Inc. (http://www.netchip.com)
32  * Copyright (C) 2003 David Brownell
33  *
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.
38  *
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.
43  *
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
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 /*char driver defines, revisit*/
67 #include <linux/module.h>
68 #include <linux/moduleparam.h>
69 #include <linux/init.h>
70 #include <linux/fs.h>           /* everything... */
71 #include <linux/errno.h>        /* error codes */
72 #include <linux/types.h>        /* size_t */
73 #include <linux/proc_fs.h>
74 #include <linux/fcntl.h>        /* O_ACCMODE */
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>        /* vmalloc(), vfree */
80 #include <linux/msdos_fs.h> /*fat_alloc_cluster*/
81 #include <linux/buffer_head.h>
82 #include <asm/system.h>         /* cli(), *_flags */
83 #include <linux/uaccess.h>      /* copy_*_user */
84
85 extern int mpage_cleardirty(struct address_space *mapping, int num_pages);
86 extern int fat_get_block(struct inode *, sector_t , struct buffer_head *, int);
87 extern cy_as_device_handle *cyasdevice_getdevhandle(void);
88
89 /* Driver data structures and utilities */
90 typedef struct cyasgadget_ep {
91         struct usb_ep                           usb_ep_inst;
92         struct cyasgadget                       *dev;
93
94         /* analogous to a host-side qh */
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
107 typedef 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
117 typedef struct cyasgadget {
118         /* each device provides one gadget, several endpoints */
119         struct usb_gadget                       gadget;
120         spinlock_t                                      lock;
121         struct cyasgadget_ep            an_gadget_ep[16];
122         struct usb_gadget_driver         *driver;
123         /* Handle to the West Bridge device */
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         /* Data member used to store the SendObjectComplete event data */
138         cy_as_mtp_send_object_complete_data tmtp_send_complete_data;
139         /* Data member used to store the GetObjectComplete event data */
140         cy_as_mtp_get_object_complete_data tmtp_get_complete_data;
141
142 } cyasgadget;
143
144 static inline void set_halt(cyasgadget_ep *ep)
145 {
146         return;
147 }
148
149 static 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 /* DEBUG */
166
167 #ifdef VERBOSE
168 #define VDEBUG DEBUG
169 #else
170 #define VDEBUG(dev, fmt, args...) \
171         do { } while (0)
172 #endif  /* VERBOSE */
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
183 static inline void start_out_naking(struct cyasgadget_ep *ep)
184 {
185         return;
186 }
187
188 static inline void stop_out_naking(struct cyasgadget_ep *ep)
189 {
190         return;
191 }
192
193 #endif  /* _INCLUDED_CYANGADGET_H_ */