diff options
37 files changed, 86 insertions, 2372 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 731b942a824b..14af6cce2fa2 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -1010,11 +1010,6 @@ endchoice | |||
1010 | config ARC32 | 1010 | config ARC32 |
1011 | bool | 1011 | bool |
1012 | 1012 | ||
1013 | config AU1X00_USB_DEVICE | ||
1014 | bool | ||
1015 | depends on MIPS_PB1500 || MIPS_PB1100 || MIPS_PB1000 | ||
1016 | default n | ||
1017 | |||
1018 | config BOOT_ELF32 | 1013 | config BOOT_ELF32 |
1019 | bool | 1014 | bool |
1020 | 1015 | ||
diff --git a/arch/mips/au1000/common/Makefile b/arch/mips/au1000/common/Makefile index bf682f50b859..4c35525edb4f 100644 --- a/arch/mips/au1000/common/Makefile +++ b/arch/mips/au1000/common/Makefile | |||
@@ -10,6 +10,5 @@ obj-y += prom.o irq.o puts.o time.o reset.o \ | |||
10 | au1xxx_irqmap.o clocks.o platform.o power.o setup.o \ | 10 | au1xxx_irqmap.o clocks.o platform.o power.o setup.o \ |
11 | sleeper.o cputable.o dma.o dbdma.o gpio.o | 11 | sleeper.o cputable.o dma.o dbdma.o gpio.o |
12 | 12 | ||
13 | obj-$(CONFIG_AU1X00_USB_DEVICE) += usbdev.o | ||
14 | obj-$(CONFIG_KGDB) += dbg_io.o | 13 | obj-$(CONFIG_KGDB) += dbg_io.o |
15 | obj-$(CONFIG_PCI) += pci.o | 14 | obj-$(CONFIG_PCI) += pci.o |
diff --git a/arch/mips/au1000/common/usbdev.c b/arch/mips/au1000/common/usbdev.c deleted file mode 100644 index 70dc82e536cd..000000000000 --- a/arch/mips/au1000/common/usbdev.c +++ /dev/null | |||
@@ -1,1552 +0,0 @@ | |||
1 | /* | ||
2 | * BRIEF MODULE DESCRIPTION | ||
3 | * Au1000 USB Device-Side (device layer) | ||
4 | * | ||
5 | * Copyright 2001-2002 MontaVista Software Inc. | ||
6 | * Author: MontaVista Software, Inc. | ||
7 | * stevel@mvista.com or source@mvista.com | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
15 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
17 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
20 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License along | ||
26 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
27 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 | */ | ||
29 | #include <linux/kernel.h> | ||
30 | #include <linux/ioport.h> | ||
31 | #include <linux/sched.h> | ||
32 | #include <linux/signal.h> | ||
33 | #include <linux/errno.h> | ||
34 | #include <linux/poll.h> | ||
35 | #include <linux/init.h> | ||
36 | #include <linux/slab.h> | ||
37 | #include <linux/fcntl.h> | ||
38 | #include <linux/module.h> | ||
39 | #include <linux/spinlock.h> | ||
40 | #include <linux/list.h> | ||
41 | #include <linux/smp_lock.h> | ||
42 | #define DEBUG | ||
43 | #include <linux/usb.h> | ||
44 | |||
45 | #include <asm/io.h> | ||
46 | #include <asm/uaccess.h> | ||
47 | #include <asm/irq.h> | ||
48 | #include <asm/mipsregs.h> | ||
49 | #include <asm/au1000.h> | ||
50 | #include <asm/au1000_dma.h> | ||
51 | #include <asm/au1000_usbdev.h> | ||
52 | |||
53 | #ifdef DEBUG | ||
54 | #undef VDEBUG | ||
55 | #ifdef VDEBUG | ||
56 | #define vdbg(fmt, arg...) printk(KERN_DEBUG __FILE__ ": " fmt "\n" , ## arg) | ||
57 | #else | ||
58 | #define vdbg(fmt, arg...) do {} while (0) | ||
59 | #endif | ||
60 | #else | ||
61 | #define vdbg(fmt, arg...) do {} while (0) | ||
62 | #endif | ||
63 | |||
64 | #define ALLOC_FLAGS (in_interrupt () ? GFP_ATOMIC : GFP_KERNEL) | ||
65 | |||
66 | #define EP_FIFO_DEPTH 8 | ||
67 | |||
68 | typedef enum { | ||
69 | SETUP_STAGE = 0, | ||
70 | DATA_STAGE, | ||
71 | STATUS_STAGE | ||
72 | } ep0_stage_t; | ||
73 | |||
74 | typedef struct { | ||
75 | int read_fifo; | ||
76 | int write_fifo; | ||
77 | int ctrl_stat; | ||
78 | int read_fifo_status; | ||
79 | int write_fifo_status; | ||
80 | } endpoint_reg_t; | ||
81 | |||
82 | typedef struct { | ||
83 | usbdev_pkt_t *head; | ||
84 | usbdev_pkt_t *tail; | ||
85 | int count; | ||
86 | } pkt_list_t; | ||
87 | |||
88 | typedef struct { | ||
89 | int active; | ||
90 | struct usb_endpoint_descriptor *desc; | ||
91 | endpoint_reg_t *reg; | ||
92 | /* Only one of these are used, unless this is the control ep */ | ||
93 | pkt_list_t inlist; | ||
94 | pkt_list_t outlist; | ||
95 | unsigned int indma, outdma; /* DMA channel numbers for IN, OUT */ | ||
96 | /* following are extracted from endpoint descriptor for easy access */ | ||
97 | int max_pkt_size; | ||
98 | int type; | ||
99 | int direction; | ||
100 | /* WE assign endpoint addresses! */ | ||
101 | int address; | ||
102 | spinlock_t lock; | ||
103 | } endpoint_t; | ||
104 | |||
105 | |||
106 | static struct usb_dev { | ||
107 | endpoint_t ep[6]; | ||
108 | ep0_stage_t ep0_stage; | ||
109 | |||
110 | struct usb_device_descriptor * dev_desc; | ||
111 | struct usb_interface_descriptor* if_desc; | ||
112 | struct usb_config_descriptor * conf_desc; | ||
113 | u8 * full_conf_desc; | ||
114 | struct usb_string_descriptor * str_desc[6]; | ||
115 | |||
116 | /* callback to function layer */ | ||
117 | void (*func_cb)(usbdev_cb_type_t type, unsigned long arg, | ||
118 | void *cb_data); | ||
119 | void* cb_data; | ||
120 | |||
121 | usbdev_state_t state; // device state | ||
122 | int suspended; // suspended flag | ||
123 | int address; // device address | ||
124 | int interface; | ||
125 | int num_ep; | ||
126 | u8 alternate_setting; | ||
127 | u8 configuration; // configuration value | ||
128 | int remote_wakeup_en; | ||
129 | } usbdev; | ||
130 | |||
131 | |||
132 | static endpoint_reg_t ep_reg[] = { | ||
133 | // FIFO's 0 and 1 are EP0 default control | ||
134 | {USBD_EP0RD, USBD_EP0WR, USBD_EP0CS, USBD_EP0RDSTAT, USBD_EP0WRSTAT }, | ||
135 | {0}, | ||
136 | // FIFO 2 is EP2, IN | ||
137 | { -1, USBD_EP2WR, USBD_EP2CS, -1, USBD_EP2WRSTAT }, | ||
138 | // FIFO 3 is EP3, IN | ||
139 | { -1, USBD_EP3WR, USBD_EP3CS, -1, USBD_EP3WRSTAT }, | ||
140 | // FIFO 4 is EP4, OUT | ||
141 | {USBD_EP4RD, -1, USBD_EP4CS, USBD_EP4RDSTAT, -1 }, | ||
142 | // FIFO 5 is EP5, OUT | ||
143 | {USBD_EP5RD, -1, USBD_EP5CS, USBD_EP5RDSTAT, -1 } | ||
144 | }; | ||
145 | |||
146 | static struct { | ||
147 | unsigned int id; | ||
148 | const char *str; | ||
149 | } ep_dma_id[] = { | ||
150 | { DMA_ID_USBDEV_EP0_TX, "USBDev EP0 IN" }, | ||
151 | { DMA_ID_USBDEV_EP0_RX, "USBDev EP0 OUT" }, | ||
152 | { DMA_ID_USBDEV_EP2_TX, "USBDev EP2 IN" }, | ||
153 | { DMA_ID_USBDEV_EP3_TX, "USBDev EP3 IN" }, | ||
154 | { DMA_ID_USBDEV_EP4_RX, "USBDev EP4 OUT" }, | ||
155 | { DMA_ID_USBDEV_EP5_RX, "USBDev EP5 OUT" } | ||
156 | }; | ||
157 | |||
158 | #define DIR_OUT 0 | ||
159 | #define DIR_IN (1<<3) | ||
160 | |||
161 | #define CONTROL_EP USB_ENDPOINT_XFER_CONTROL | ||
162 | #define BULK_EP USB_ENDPOINT_XFER_BULK | ||
163 | |||
164 | static inline endpoint_t * | ||
165 | epaddr_to_ep(struct usb_dev* dev, int ep_addr) | ||
166 | { | ||
167 | if (ep_addr >= 0 && ep_addr < 2) | ||
168 | return &dev->ep[0]; | ||
169 | if (ep_addr < 6) | ||
170 | return &dev->ep[ep_addr]; | ||
171 | return NULL; | ||
172 | } | ||
173 | |||
174 | static const char* std_req_name[] = { | ||
175 | "GET_STATUS", | ||
176 | "CLEAR_FEATURE", | ||
177 | "RESERVED", | ||
178 | "SET_FEATURE", | ||
179 | "RESERVED", | ||
180 | "SET_ADDRESS", | ||
181 | "GET_DESCRIPTOR", | ||
182 | "SET_DESCRIPTOR", | ||
183 | "GET_CONFIGURATION", | ||
184 | "SET_CONFIGURATION", | ||
185 | "GET_INTERFACE", | ||
186 | "SET_INTERFACE", | ||
187 | "SYNCH_FRAME" | ||
188 | }; | ||
189 | |||
190 | static inline const char* | ||
191 | get_std_req_name(int req) | ||
192 | { | ||
193 | return (req >= 0 && req <= 12) ? std_req_name[req] : "UNKNOWN"; | ||
194 | } | ||
195 | |||
196 | #if 0 | ||
197 | static void | ||
198 | dump_setup(struct usb_ctrlrequest* s) | ||
199 | { | ||
200 | dbg("%s: requesttype=%d", __FUNCTION__, s->requesttype); | ||
201 | dbg("%s: request=%d %s", __FUNCTION__, s->request, | ||
202 | get_std_req_name(s->request)); | ||
203 | dbg("%s: value=0x%04x", __FUNCTION__, s->wValue); | ||
204 | dbg("%s: index=%d", __FUNCTION__, s->index); | ||
205 | dbg("%s: length=%d", __FUNCTION__, s->length); | ||
206 | } | ||
207 | #endif | ||
208 | |||
209 | static inline usbdev_pkt_t * | ||
210 | alloc_packet(endpoint_t * ep, int data_size, void* data) | ||
211 | { | ||
212 | usbdev_pkt_t* pkt = kmalloc(sizeof(usbdev_pkt_t) + data_size, | ||
213 | ALLOC_FLAGS); | ||
214 | if (!pkt) | ||
215 | return NULL; | ||
216 | pkt->ep_addr = ep->address; | ||
217 | pkt->size = data_size; | ||
218 | pkt->status = 0; | ||
219 | pkt->next = NULL; | ||
220 | if (data) | ||
221 | memcpy(pkt->payload, data, data_size); | ||
222 | |||
223 | return pkt; | ||
224 | } | ||
225 | |||
226 | |||
227 | /* | ||
228 | * Link a packet to the tail of the enpoint's packet list. | ||
229 | * EP spinlock must be held when calling. | ||
230 | */ | ||
231 | static void | ||
232 | link_tail(endpoint_t * ep, pkt_list_t * list, usbdev_pkt_t * pkt) | ||
233 | { | ||
234 | if (!list->tail) { | ||
235 | list->head = list->tail = pkt; | ||
236 | list->count = 1; | ||
237 | } else { | ||
238 | list->tail->next = pkt; | ||
239 | list->tail = pkt; | ||
240 | list->count++; | ||
241 | } | ||
242 | } | ||
243 | |||
244 | /* | ||
245 | * Unlink and return a packet from the head of the given packet | ||
246 | * list. It is the responsibility of the caller to free the packet. | ||
247 | * EP spinlock must be held when calling. | ||
248 | */ | ||
249 | static usbdev_pkt_t * | ||
250 | unlink_head(pkt_list_t * list) | ||
251 | { | ||
252 | usbdev_pkt_t *pkt; | ||
253 | |||
254 | pkt = list->head; | ||
255 | if (!pkt || !list->count) { | ||
256 | return NULL; | ||
257 | } | ||
258 | |||
259 | list->head = pkt->next; | ||
260 | if (!list->head) { | ||
261 | list->head = list->tail = NULL; | ||
262 | list->count = 0; | ||
263 | } else | ||
264 | list->count--; | ||
265 | |||
266 | return pkt; | ||
267 | } | ||
268 | |||
269 | /* | ||
270 | * Create and attach a new packet to the tail of the enpoint's | ||
271 | * packet list. EP spinlock must be held when calling. | ||
272 | */ | ||
273 | static usbdev_pkt_t * | ||
274 | add_packet(endpoint_t * ep, pkt_list_t * list, int size) | ||
275 | { | ||
276 | usbdev_pkt_t *pkt = alloc_packet(ep, size, NULL); | ||
277 | if (!pkt) | ||
278 | return NULL; | ||
279 | |||
280 | link_tail(ep, list, pkt); | ||
281 | return pkt; | ||
282 | } | ||
283 | |||
284 | |||
285 | /* | ||
286 | * Unlink and free a packet from the head of the enpoint's | ||
287 | * packet list. EP spinlock must be held when calling. | ||
288 | */ | ||
289 | static inline void | ||
290 | free_packet(pkt_list_t * list) | ||
291 | { | ||
292 | kfree(unlink_head(list)); | ||
293 | } | ||
294 | |||
295 | /* EP spinlock must be held when calling. */ | ||
296 | static inline void | ||
297 | flush_pkt_list(pkt_list_t * list) | ||
298 | { | ||
299 | while (list->count) | ||
300 | free_packet(list); | ||
301 | } | ||
302 | |||
303 | /* EP spinlock must be held when calling */ | ||
304 | static inline void | ||
305 | flush_write_fifo(endpoint_t * ep) | ||
306 | { | ||
307 | if (ep->reg->write_fifo_status >= 0) { | ||
308 | au_writel(USBDEV_FSTAT_FLUSH | USBDEV_FSTAT_UF | | ||
309 | USBDEV_FSTAT_OF, | ||
310 | ep->reg->write_fifo_status); | ||
311 | //udelay(100); | ||
312 | //au_writel(USBDEV_FSTAT_UF | USBDEV_FSTAT_OF, | ||
313 | // ep->reg->write_fifo_status); | ||
314 | } | ||
315 | } | ||
316 | |||
317 | /* EP spinlock must be held when calling */ | ||
318 | static inline void | ||
319 | flush_read_fifo(endpoint_t * ep) | ||
320 | { | ||
321 | if (ep->reg->read_fifo_status >= 0) { | ||
322 | au_writel(USBDEV_FSTAT_FLUSH | USBDEV_FSTAT_UF | | ||
323 | USBDEV_FSTAT_OF, | ||
324 | ep->reg->read_fifo_status); | ||
325 | //udelay(100); | ||
326 | //au_writel(USBDEV_FSTAT_UF | USBDEV_FSTAT_OF, | ||
327 | // ep->reg->read_fifo_status); | ||
328 | } | ||
329 | } | ||
330 | |||
331 | |||
332 | /* EP spinlock must be held when calling. */ | ||
333 | static void | ||
334 | endpoint_flush(endpoint_t * ep) | ||
335 | { | ||
336 | // First, flush all packets | ||
337 | flush_pkt_list(&ep->inlist); | ||
338 | flush_pkt_list(&ep->outlist); | ||
339 | |||
340 | // Now flush the endpoint's h/w FIFO(s) | ||
341 | flush_write_fifo(ep); | ||
342 | flush_read_fifo(ep); | ||
343 | } | ||
344 | |||
345 | /* EP spinlock must be held when calling. */ | ||
346 | static void | ||
347 | endpoint_stall(endpoint_t * ep) | ||
348 | { | ||
349 | u32 cs; | ||
350 | |||
351 | warn("%s", __FUNCTION__); | ||
352 | |||
353 | cs = au_readl(ep->reg->ctrl_stat) | USBDEV_CS_STALL; | ||
354 | au_writel(cs, ep->reg->ctrl_stat); | ||
355 | } | ||
356 | |||
357 | /* EP spinlock must be held when calling. */ | ||
358 | static void | ||
359 | endpoint_unstall(endpoint_t * ep) | ||
360 | { | ||
361 | u32 cs; | ||
362 | |||
363 | warn("%s", __FUNCTION__); | ||
364 | |||
365 | cs = au_readl(ep->reg->ctrl_stat) & ~USBDEV_CS_STALL; | ||
366 | au_writel(cs, ep->reg->ctrl_stat); | ||
367 | } | ||
368 | |||
369 | static void | ||
370 | endpoint_reset_datatoggle(endpoint_t * ep) | ||
371 | { | ||
372 | // FIXME: is this possible? | ||
373 | } | ||
374 | |||
375 | |||
376 | /* EP spinlock must be held when calling. */ | ||
377 | static int | ||
378 | endpoint_fifo_read(endpoint_t * ep) | ||
379 | { | ||
380 | int read_count = 0; | ||
381 | u8 *bufptr; | ||
382 | usbdev_pkt_t *pkt = ep->outlist.tail; | ||
383 | |||
384 | if (!pkt) | ||
385 | return -EINVAL; | ||
386 | |||
387 | bufptr = &pkt->payload[pkt->size]; | ||
388 | while (au_readl(ep->reg->read_fifo_status) & USBDEV_FSTAT_FCNT_MASK) { | ||
389 | *bufptr++ = au_readl(ep->reg->read_fifo) & 0xff; | ||
390 | read_count++; | ||
391 | pkt->size++; | ||
392 | } | ||
393 | |||
394 | return read_count; | ||
395 | } | ||
396 | |||
397 | #if 0 | ||
398 | /* EP spinlock must be held when calling. */ | ||
399 | static int | ||
400 | endpoint_fifo_write(endpoint_t * ep, int index) | ||
401 | { | ||
402 | int write_count = 0; | ||
403 | u8 *bufptr; | ||
404 | usbdev_pkt_t *pkt = ep->inlist.head; | ||
405 | |||
406 | if (!pkt) | ||
407 | return -EINVAL; | ||
408 | |||
409 | bufptr = &pkt->payload[index]; | ||
410 | while ((au_readl(ep->reg->write_fifo_status) & | ||
411 | USBDEV_FSTAT_FCNT_MASK) < EP_FIFO_DEPTH) { | ||
412 | if (bufptr < pkt->payload + pkt->size) { | ||
413 | au_writel(*bufptr++, ep->reg->write_fifo); | ||
414 | write_count++; | ||
415 | } else { | ||
416 | break; | ||
417 | } | ||
418 | } | ||
419 | |||
420 | return write_count; | ||
421 | } | ||
422 | #endif | ||
423 | |||
424 | /* | ||
425 | * This routine is called to restart transmission of a packet. | ||
426 | * The endpoint's TSIZE must be set to the new packet's size, | ||
427 | * and DMA to the write FIFO needs to be restarted. | ||
428 | * EP spinlock must be held when calling. | ||
429 | */ | ||
430 | static void | ||
431 | kickstart_send_packet(endpoint_t * ep) | ||
432 | { | ||
433 | u32 cs; | ||
434 | usbdev_pkt_t *pkt = ep->inlist.head; | ||
435 | |||
436 | vdbg("%s: ep%d, pkt=%p", __FUNCTION__, ep->address, pkt); | ||
437 | |||
438 | if (!pkt) { | ||
439 | err("%s: head=NULL! list->count=%d", __FUNCTION__, | ||
440 | ep->inlist.count); | ||
441 | return; | ||
442 | } | ||
443 | |||
444 | dma_cache_wback_inv((unsigned long)pkt->payload, pkt->size); | ||
445 | |||
446 | /* | ||
447 | * make sure FIFO is empty | ||
448 | */ | ||
449 | flush_write_fifo(ep); | ||
450 | |||
451 | cs = au_readl(ep->reg->ctrl_stat) & USBDEV_CS_STALL; | ||
452 | cs |= (pkt->size << USBDEV_CS_TSIZE_BIT); | ||
453 | au_writel(cs, ep->reg->ctrl_stat); | ||
454 | |||
455 | if (get_dma_active_buffer(ep->indma) == 1) { | ||
456 | set_dma_count1(ep->indma, pkt->size); | ||
457 | set_dma_addr1(ep->indma, virt_to_phys(pkt->payload)); | ||
458 | enable_dma_buffer1(ep->indma); // reenable | ||
459 | } else { | ||
460 | set_dma_count0(ep->indma, pkt->size); | ||
461 | set_dma_addr0(ep->indma, virt_to_phys(pkt->payload)); | ||
462 | enable_dma_buffer0(ep->indma); // reenable | ||
463 | } | ||
464 | if (dma_halted(ep->indma)) | ||
465 | start_dma(ep->indma); | ||
466 | } | ||
467 | |||
468 | |||
469 | /* | ||
470 | * This routine is called when a packet in the inlist has been | ||
471 | * completed. Frees the completed packet and starts sending the | ||
472 | * next. EP spinlock must be held when calling. | ||
473 | */ | ||
474 | static usbdev_pkt_t * | ||
475 | send_packet_complete(endpoint_t * ep) | ||
476 | { | ||
477 | usbdev_pkt_t *pkt = unlink_head(&ep->inlist); | ||
478 | |||
479 | if (pkt) { | ||
480 | pkt->status = | ||
481 | (au_readl(ep->reg->ctrl_stat) & USBDEV_CS_NAK) ? | ||
482 | PKT_STATUS_NAK : PKT_STATUS_ACK; | ||
483 | |||
484 | vdbg("%s: ep%d, %s pkt=%p, list count=%d", __FUNCTION__, | ||
485 | ep->address, (pkt->status & PKT_STATUS_NAK) ? | ||
486 | "NAK" : "ACK", pkt, ep->inlist.count); | ||
487 | } | ||
488 | |||
489 | /* | ||
490 | * The write fifo should already be drained if things are | ||
491 | * working right, but flush it anyway just in case. | ||
492 | */ | ||
493 | flush_write_fifo(ep); | ||
494 | |||
495 | // begin transmitting next packet in the inlist | ||
496 | if (ep->inlist.count) { | ||
497 | kickstart_send_packet(ep); | ||
498 | } | ||
499 | |||
500 | return pkt; | ||
501 | } | ||
502 | |||
503 | /* | ||
504 | * Add a new packet to the tail of the given ep's packet | ||
505 | * inlist. The transmit complete interrupt frees packets from | ||
506 | * the head of this list. EP spinlock must be held when calling. | ||
507 | */ | ||
508 | static int | ||
509 | send_packet(struct usb_dev* dev, usbdev_pkt_t *pkt, int async) | ||
510 | { | ||
511 | pkt_list_t *list; | ||
512 | endpoint_t* ep; | ||
513 | |||
514 | if (!pkt || !(ep = epaddr_to_ep(dev, pkt->ep_addr))) | ||
515 | return -EINVAL; | ||
516 | |||
517 | if (!pkt->size) | ||
518 | return 0; | ||
519 | |||
520 | list = &ep->inlist; | ||
521 | |||
522 | if (!async && list->count) { | ||
523 | halt_dma(ep->indma); | ||
524 | flush_pkt_list(list); | ||
525 | } | ||
526 | |||
527 | link_tail(ep, list, pkt); | ||
528 | |||
529 | vdbg("%s: ep%d, pkt=%p, size=%d, list count=%d", __FUNCTION__, | ||
530 | ep->address, pkt, pkt->size, list->count); | ||
531 | |||
532 | if (list->count == 1) { | ||
533 | /* | ||
534 | * if the packet count is one, it means the list was empty, | ||
535 | * and no more data will go out this ep until we kick-start | ||
536 | * it again. | ||
537 | */ | ||
538 | kickstart_send_packet(ep); | ||
539 | } | ||
540 | |||
541 | return pkt->size; | ||
542 | } | ||
543 | |||
544 | /* | ||
545 | * This routine is called to restart reception of a packet. | ||
546 | * EP spinlock must be held when calling. | ||
547 | */ | ||
548 | static void | ||
549 | kickstart_receive_packet(endpoint_t * ep) | ||
550 | { | ||
551 | usbdev_pkt_t *pkt; | ||
552 | |||
553 | // get and link a new packet for next reception | ||
554 | if (!(pkt = add_packet(ep, &ep->outlist, ep->max_pkt_size))) { | ||
555 | err("%s: could not alloc new packet", __FUNCTION__); | ||
556 | return; | ||
557 | } | ||
558 | |||
559 | if (get_dma_active_buffer(ep->outdma) == 1) { | ||
560 | clear_dma_done1(ep->outdma); | ||
561 | set_dma_count1(ep->outdma, ep->max_pkt_size); | ||
562 | set_dma_count0(ep->outdma, 0); | ||
563 | set_dma_addr1(ep->outdma, virt_to_phys(pkt->payload)); | ||
564 | enable_dma_buffer1(ep->outdma); // reenable | ||
565 | } else { | ||
566 | clear_dma_done0(ep->outdma); | ||
567 | set_dma_count0(ep->outdma, ep->max_pkt_size); | ||
568 | set_dma_count1(ep->outdma, 0); | ||
569 | set_dma_addr0(ep->outdma, virt_to_phys(pkt->payload)); | ||
570 | enable_dma_buffer0(ep->outdma); // reenable | ||
571 | } | ||
572 | if (dma_halted(ep->outdma)) | ||
573 | start_dma(ep->outdma); | ||
574 | } | ||
575 | |||
576 | |||
577 | /* | ||
578 | * This routine is called when a packet in the outlist has been | ||
579 | * completed (received) and we need to prepare for a new packet | ||
580 | * to be received. Halts DMA and computes the packet size from the | ||
581 | * remaining DMA counter. Then prepares a new packet for reception | ||
582 | * and restarts DMA. FIXME: what if another packet comes in | ||
583 | * on top of the completed packet? Counter would be wrong. | ||
584 | * EP spinlock must be held when calling. | ||
585 | */ | ||
586 | static usbdev_pkt_t * | ||
587 | receive_packet_complete(endpoint_t * ep) | ||
588 | { | ||
589 | usbdev_pkt_t *pkt = ep->outlist.tail; | ||
590 | u32 cs; | ||
591 | |||
592 | halt_dma(ep->outdma); | ||
593 | |||
594 | cs = au_readl(ep->reg->ctrl_stat); | ||
595 | |||
596 | if (!pkt) | ||
597 | return NULL; | ||
598 | |||
599 | pkt->size = ep->max_pkt_size - get_dma_residue(ep->outdma); | ||
600 | if (pkt->size) | ||
601 | dma_cache_inv((unsigned long)pkt->payload, pkt->size); | ||
602 | /* | ||
603 | * need to pull out any remaining bytes in the FIFO. | ||
604 | */ | ||
605 | endpoint_fifo_read(ep); | ||
606 | /* | ||
607 | * should be drained now, but flush anyway just in case. | ||
608 | */ | ||
609 | flush_read_fifo(ep); | ||
610 | |||
611 | pkt->status = (cs & USBDEV_CS_NAK) ? PKT_STATUS_NAK : PKT_STATUS_ACK; | ||
612 | if (ep->address == 0 && (cs & USBDEV_CS_SU)) | ||
613 | pkt->status |= PKT_STATUS_SU; | ||
614 | |||
615 | vdbg("%s: ep%d, %s pkt=%p, size=%d", __FUNCTION__, | ||
616 | ep->address, (pkt->status & PKT_STATUS_NAK) ? | ||
617 | "NAK" : "ACK", pkt, pkt->size); | ||
618 | |||
619 | kickstart_receive_packet(ep); | ||
620 | |||
621 | return pkt; | ||
622 | } | ||
623 | |||
624 | |||
625 | /* | ||
626 | **************************************************************************** | ||
627 | * Here starts the standard device request handlers. They are | ||
628 | * all called by do_setup() via a table of function pointers. | ||
629 | **************************************************************************** | ||
630 | */ | ||
631 | |||
632 | static ep0_stage_t | ||
633 | do_get_status(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
634 | { | ||
635 | switch (setup->bRequestType) { | ||
636 | case 0x80: // Device | ||
637 | // FIXME: send device status | ||
638 | break; | ||
639 | case 0x81: // Interface | ||
640 | // FIXME: send interface status | ||
641 | break; | ||
642 | case 0x82: // End Point | ||
643 | // FIXME: send endpoint status | ||
644 | break; | ||
645 | default: | ||
646 | // Invalid Command | ||
647 | endpoint_stall(&dev->ep[0]); // Stall End Point 0 | ||
648 | break; | ||
649 | } | ||
650 | |||
651 | return STATUS_STAGE; | ||
652 | } | ||
653 | |||
654 | static ep0_stage_t | ||
655 | do_clear_feature(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
656 | { | ||
657 | switch (setup->bRequestType) { | ||
658 | case 0x00: // Device | ||
659 | if ((le16_to_cpu(setup->wValue) & 0xff) == 1) | ||
660 | dev->remote_wakeup_en = 0; | ||
661 | else | ||
662 | endpoint_stall(&dev->ep[0]); | ||
663 | break; | ||
664 | case 0x02: // End Point | ||
665 | if ((le16_to_cpu(setup->wValue) & 0xff) == 0) { | ||
666 | endpoint_t *ep = | ||
667 | epaddr_to_ep(dev, | ||
668 | le16_to_cpu(setup->wIndex) & 0xff); | ||
669 | |||
670 | endpoint_unstall(ep); | ||
671 | endpoint_reset_datatoggle(ep); | ||
672 | } else | ||
673 | endpoint_stall(&dev->ep[0]); | ||
674 | break; | ||
675 | } | ||
676 | |||
677 | return SETUP_STAGE; | ||
678 | } | ||
679 | |||
680 | static ep0_stage_t | ||
681 | do_reserved(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
682 | { | ||
683 | // Invalid request, stall End Point 0 | ||
684 | endpoint_stall(&dev->ep[0]); | ||
685 | return SETUP_STAGE; | ||
686 | } | ||
687 | |||
688 | static ep0_stage_t | ||
689 | do_set_feature(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
690 | { | ||
691 | switch (setup->bRequestType) { | ||
692 | case 0x00: // Device | ||
693 | if ((le16_to_cpu(setup->wValue) & 0xff) == 1) | ||
694 | dev->remote_wakeup_en = 1; | ||
695 | else | ||
696 | endpoint_stall(&dev->ep[0]); | ||
697 | break; | ||
698 | case 0x02: // End Point | ||
699 | if ((le16_to_cpu(setup->wValue) & 0xff) == 0) { | ||
700 | endpoint_t *ep = | ||
701 | epaddr_to_ep(dev, | ||
702 | le16_to_cpu(setup->wIndex) & 0xff); | ||
703 | |||
704 | endpoint_stall(ep); | ||
705 | } else | ||
706 | endpoint_stall(&dev->ep[0]); | ||
707 | break; | ||
708 | } | ||
709 | |||
710 | return SETUP_STAGE; | ||
711 | } | ||
712 | |||
713 | static ep0_stage_t | ||
714 | do_set_address(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
715 | { | ||
716 | int new_state = dev->state; | ||
717 | int new_addr = le16_to_cpu(setup->wValue); | ||
718 | |||
719 | dbg("%s: our address=%d", __FUNCTION__, new_addr); | ||
720 | |||
721 | if (new_addr > 127) { | ||
722 | // usb spec doesn't tell us what to do, so just go to | ||
723 | // default state | ||
724 | new_state = DEFAULT; | ||
725 | dev->address = 0; | ||
726 | } else if (dev->address != new_addr) { | ||
727 | dev->address = new_addr; | ||
728 | new_state = ADDRESS; | ||
729 | } | ||
730 | |||
731 | if (dev->state != new_state) { | ||
732 | dev->state = new_state; | ||
733 | /* inform function layer of usbdev state change */ | ||
734 | dev->func_cb(CB_NEW_STATE, dev->state, dev->cb_data); | ||
735 | } | ||
736 | |||
737 | return SETUP_STAGE; | ||
738 | } | ||
739 | |||
740 | static ep0_stage_t | ||
741 | do_get_descriptor(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
742 | { | ||
743 | int strnum, desc_len = le16_to_cpu(setup->wLength); | ||
744 | |||
745 | switch (le16_to_cpu(setup->wValue) >> 8) { | ||
746 | case USB_DT_DEVICE: | ||
747 | // send device descriptor! | ||
748 | desc_len = desc_len > dev->dev_desc->bLength ? | ||
749 | dev->dev_desc->bLength : desc_len; | ||
750 | dbg("sending device desc, size=%d", desc_len); | ||
751 | send_packet(dev, alloc_packet(&dev->ep[0], desc_len, | ||
752 | dev->dev_desc), 0); | ||
753 | break; | ||
754 | case USB_DT_CONFIG: | ||
755 | // If the config descr index in low-byte of | ||
756 | // setup->wValue is valid, send config descr, | ||
757 | // otherwise stall ep0. | ||
758 | if ((le16_to_cpu(setup->wValue) & 0xff) == 0) { | ||
759 | // send config descriptor! | ||
760 | if (desc_len <= USB_DT_CONFIG_SIZE) { | ||
761 | dbg("sending partial config desc, size=%d", | ||
762 | desc_len); | ||
763 | send_packet(dev, | ||
764 | alloc_packet(&dev->ep[0], | ||
765 | desc_len, | ||
766 | dev->conf_desc), | ||
767 | 0); | ||
768 | } else { | ||
769 | int len = le16_to_cpu(dev->conf_desc->wTotalLength); | ||
770 | dbg("sending whole config desc," | ||
771 | " size=%d, our size=%d", desc_len, len); | ||
772 | desc_len = desc_len > len ? len : desc_len; | ||
773 | send_packet(dev, | ||
774 | alloc_packet(&dev->ep[0], | ||
775 | desc_len, | ||
776 | dev->full_conf_desc), | ||
777 | 0); | ||
778 | } | ||
779 | } else | ||
780 | endpoint_stall(&dev->ep[0]); | ||
781 | break; | ||
782 | case USB_DT_STRING: | ||
783 | // If the string descr index in low-byte of setup->wValue | ||
784 | // is valid, send string descr, otherwise stall ep0. | ||
785 | strnum = le16_to_cpu(setup->wValue) & 0xff; | ||
786 | if (strnum >= 0 && strnum < 6) { | ||
787 | struct usb_string_descriptor *desc = | ||
788 | dev->str_desc[strnum]; | ||
789 | desc_len = desc_len > desc->bLength ? | ||
790 | desc->bLength : desc_len; | ||
791 | dbg("sending string desc %d", strnum); | ||
792 | send_packet(dev, | ||
793 | alloc_packet(&dev->ep[0], desc_len, | ||
794 | desc), 0); | ||
795 | } else | ||
796 | endpoint_stall(&dev->ep[0]); | ||
797 | break; | ||
798 | default: | ||
799 | // Invalid request | ||
800 | err("invalid get desc=%d, stalled", | ||
801 | le16_to_cpu(setup->wValue) >> 8); | ||
802 | endpoint_stall(&dev->ep[0]); // Stall endpoint 0 | ||
803 | break; | ||
804 | } | ||
805 | |||
806 | return STATUS_STAGE; | ||
807 | } | ||
808 | |||
809 | static ep0_stage_t | ||
810 | do_set_descriptor(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
811 | { | ||
812 | // TODO: implement | ||
813 | // there will be an OUT data stage (the descriptor to set) | ||
814 | return DATA_STAGE; | ||
815 | } | ||
816 | |||
817 | static ep0_stage_t | ||
818 | do_get_configuration(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
819 | { | ||
820 | // send dev->configuration | ||
821 | dbg("sending config"); | ||
822 | send_packet(dev, alloc_packet(&dev->ep[0], 1, &dev->configuration), | ||
823 | 0); | ||
824 | return STATUS_STAGE; | ||
825 | } | ||
826 | |||
827 | static ep0_stage_t | ||
828 | do_set_configuration(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
829 | { | ||
830 | // set active config to low-byte of setup->wValue | ||
831 | dev->configuration = le16_to_cpu(setup->wValue) & 0xff; | ||
832 | dbg("set config, config=%d", dev->configuration); | ||
833 | if (!dev->configuration && dev->state > DEFAULT) { | ||
834 | dev->state = ADDRESS; | ||
835 | /* inform function layer of usbdev state change */ | ||
836 | dev->func_cb(CB_NEW_STATE, dev->state, dev->cb_data); | ||
837 | } else if (dev->configuration == 1) { | ||
838 | dev->state = CONFIGURED; | ||
839 | /* inform function layer of usbdev state change */ | ||
840 | dev->func_cb(CB_NEW_STATE, dev->state, dev->cb_data); | ||
841 | } else { | ||
842 | // FIXME: "respond with request error" - how? | ||
843 | } | ||
844 | |||
845 | return SETUP_STAGE; | ||
846 | } | ||
847 | |||
848 | static ep0_stage_t | ||
849 | do_get_interface(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
850 | { | ||
851 | // interface must be zero. | ||
852 | if ((le16_to_cpu(setup->wIndex) & 0xff) || dev->state == ADDRESS) { | ||
853 | // FIXME: respond with "request error". how? | ||
854 | } else if (dev->state == CONFIGURED) { | ||
855 | // send dev->alternate_setting | ||
856 | dbg("sending alt setting"); | ||
857 | send_packet(dev, alloc_packet(&dev->ep[0], 1, | ||
858 | &dev->alternate_setting), 0); | ||
859 | } | ||
860 | |||
861 | return STATUS_STAGE; | ||
862 | |||
863 | } | ||
864 | |||
865 | static ep0_stage_t | ||
866 | do_set_interface(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
867 | { | ||
868 | if (dev->state == ADDRESS) { | ||
869 | // FIXME: respond with "request error". how? | ||
870 | } else if (dev->state == CONFIGURED) { | ||
871 | dev->interface = le16_to_cpu(setup->wIndex) & 0xff; | ||
872 | dev->alternate_setting = | ||
873 | le16_to_cpu(setup->wValue) & 0xff; | ||
874 | // interface and alternate_setting must be zero | ||
875 | if (dev->interface || dev->alternate_setting) { | ||
876 | // FIXME: respond with "request error". how? | ||
877 | } | ||
878 | } | ||
879 | |||
880 | return SETUP_STAGE; | ||
881 | } | ||
882 | |||
883 | static ep0_stage_t | ||
884 | do_synch_frame(struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
885 | { | ||
886 | // TODO | ||
887 | return SETUP_STAGE; | ||
888 | } | ||
889 | |||
890 | typedef ep0_stage_t (*req_method_t)(struct usb_dev* dev, | ||
891 | struct usb_ctrlrequest* setup); | ||
892 | |||
893 | |||
894 | /* Table of the standard device request handlers */ | ||
895 | static const req_method_t req_method[] = { | ||
896 | do_get_status, | ||
897 | do_clear_feature, | ||
898 | do_reserved, | ||
899 | do_set_feature, | ||
900 | do_reserved, | ||
901 | do_set_address, | ||
902 | do_get_descriptor, | ||
903 | do_set_descriptor, | ||
904 | do_get_configuration, | ||
905 | do_set_configuration, | ||
906 | do_get_interface, | ||
907 | do_set_interface, | ||
908 | do_synch_frame | ||
909 | }; | ||
910 | |||
911 | |||
912 | // SETUP packet request dispatcher | ||
913 | static void | ||
914 | do_setup (struct usb_dev* dev, struct usb_ctrlrequest* setup) | ||
915 | { | ||
916 | req_method_t m; | ||
917 | |||
918 | dbg("%s: req %d %s", __FUNCTION__, setup->bRequestType, | ||
919 | get_std_req_name(setup->bRequestType)); | ||
920 | |||
921 | if ((setup->bRequestType & USB_TYPE_MASK) != USB_TYPE_STANDARD || | ||
922 | (setup->bRequestType & USB_RECIP_MASK) != USB_RECIP_DEVICE) { | ||
923 | err("%s: invalid requesttype 0x%02x", __FUNCTION__, | ||
924 | setup->bRequestType); | ||
925 | return; | ||
926 | } | ||
927 | |||
928 | if ((setup->bRequestType & 0x80) == USB_DIR_OUT && setup->wLength) | ||
929 | dbg("%s: OUT phase! length=%d", __FUNCTION__, setup->wLength); | ||
930 | |||
931 | if (setup->bRequestType < sizeof(req_method)/sizeof(req_method_t)) | ||
932 | m = req_method[setup->bRequestType]; | ||
933 | else | ||
934 | m = do_reserved; | ||
935 | |||
936 | dev->ep0_stage = (*m)(dev, setup); | ||
937 | } | ||
938 | |||
939 | /* | ||
940 | * A SETUP, DATA0, or DATA1 packet has been received | ||
941 | * on the default control endpoint's fifo. | ||
942 | */ | ||
943 | static void | ||
944 | process_ep0_receive (struct usb_dev* dev) | ||
945 | { | ||
946 | endpoint_t *ep0 = &dev->ep[0]; | ||
947 | usbdev_pkt_t *pkt; | ||
948 | |||
949 | spin_lock(&ep0->lock); | ||
950 | |||
951 | // complete packet and prepare a new packet | ||
952 | pkt = receive_packet_complete(ep0); | ||
953 | if (!pkt) { | ||
954 | // FIXME: should put a warn/err here. | ||
955 | spin_unlock(&ep0->lock); | ||
956 | return; | ||
957 | } | ||
958 | |||
959 | // unlink immediately from endpoint. | ||
960 | unlink_head(&ep0->outlist); | ||
961 | |||
962 | // override current stage if h/w says it's a setup packet | ||
963 | if (pkt->status & PKT_STATUS_SU) | ||
964 | dev->ep0_stage = SETUP_STAGE; | ||
965 | |||
966 | switch (dev->ep0_stage) { | ||
967 | case SETUP_STAGE: | ||
968 | vdbg("SU bit is %s in setup stage", | ||
969 | (pkt->status & PKT_STATUS_SU) ? "set" : "not set"); | ||
970 | |||
971 | if (pkt->size == sizeof(struct usb_ctrlrequest)) { | ||
972 | #ifdef VDEBUG | ||
973 | if (pkt->status & PKT_STATUS_ACK) | ||
974 | vdbg("received SETUP"); | ||
975 | else | ||
976 | vdbg("received NAK SETUP"); | ||
977 | #endif | ||
978 | do_setup(dev, (struct usb_ctrlrequest*)pkt->payload); | ||
979 | } else | ||
980 | err("%s: wrong size SETUP received", __FUNCTION__); | ||
981 | break; | ||
982 | case DATA_STAGE: | ||
983 | /* | ||
984 | * this setup has an OUT data stage. Of the standard | ||
985 | * device requests, only set_descriptor has this stage, | ||
986 | * so this packet is that descriptor. TODO: drop it for | ||
987 | * now, set_descriptor not implemented. | ||
988 | * | ||
989 | * Need to place a byte in the write FIFO here, to prepare | ||
990 | * to send a zero-length DATA ack packet to the host in the | ||
991 | * STATUS stage. | ||
992 | */ | ||
993 | au_writel(0, ep0->reg->write_fifo); | ||
994 | dbg("received OUT stage DATAx on EP0, size=%d", pkt->size); | ||
995 | dev->ep0_stage = SETUP_STAGE; | ||
996 | break; | ||
997 | case STATUS_STAGE: | ||
998 | // this setup had an IN data stage, and host is ACK'ing | ||
999 | // the packet we sent during that stage. | ||
1000 | if (pkt->size != 0) | ||
1001 | warn("received non-zero ACK on EP0??"); | ||
1002 | #ifdef VDEBUG | ||
1003 | else | ||
1004 | vdbg("received ACK on EP0"); | ||
1005 | #endif | ||
1006 | dev->ep0_stage = SETUP_STAGE; | ||
1007 | break; | ||
1008 | } | ||
1009 | |||
1010 | spin_unlock(&ep0->lock); | ||
1011 | // we're done processing the packet, free it | ||
1012 | kfree(pkt); | ||
1013 | } | ||
1014 | |||
1015 | |||
1016 | /* | ||
1017 | * A DATA0/1 packet has been received on one of the OUT endpoints (4 or 5) | ||
1018 | */ | ||
1019 | static void | ||
1020 | process_ep_receive (struct usb_dev* dev, endpoint_t *ep) | ||
1021 | { | ||
1022 | usbdev_pkt_t *pkt; | ||
1023 | |||
1024 | spin_lock(&ep->lock); | ||
1025 | pkt = receive_packet_complete(ep); | ||
1026 | spin_unlock(&ep->lock); | ||
1027 | |||
1028 | dev->func_cb(CB_PKT_COMPLETE, (unsigned long)pkt, dev->cb_data); | ||
1029 | } | ||
1030 | |||
1031 | |||
1032 | |||
1033 | /* This ISR handles the receive complete and suspend events */ | ||
1034 | static void req_sus_intr (int irq, void *dev_id) | ||
1035 | { | ||
1036 | struct usb_dev *dev = (struct usb_dev *) dev_id; | ||
1037 | u32 status; | ||
1038 | |||
1039 | status = au_readl(USBD_INTSTAT); | ||
1040 | au_writel(status, USBD_INTSTAT); // ack'em | ||
1041 | |||
1042 | if (status & (1<<0)) | ||
1043 | process_ep0_receive(dev); | ||
1044 | if (status & (1<<4)) | ||
1045 | process_ep_receive(dev, &dev->ep[4]); | ||
1046 | if (status & (1<<5)) | ||
1047 | process_ep_receive(dev, &dev->ep[5]); | ||
1048 | } | ||
1049 | |||
1050 | |||
1051 | /* This ISR handles the DMA done events on EP0 */ | ||
1052 | static void dma_done_ep0_intr(int irq, void *dev_id) | ||
1053 | { | ||
1054 | struct usb_dev *dev = (struct usb_dev *) dev_id; | ||
1055 | usbdev_pkt_t* pkt; | ||
1056 | endpoint_t *ep0 = &dev->ep[0]; | ||
1057 | u32 cs0, buff_done; | ||
1058 | |||
1059 | spin_lock(&ep0->lock); | ||
1060 | cs0 = au_readl(ep0->reg->ctrl_stat); | ||
1061 | |||
1062 | // first check packet transmit done | ||
1063 | if ((buff_done = get_dma_buffer_done(ep0->indma)) != 0) { | ||
1064 | // transmitted a DATAx packet during DATA stage | ||
1065 | // on control endpoint 0 | ||
1066 | // clear DMA done bit | ||
1067 | if (buff_done & DMA_D0) | ||
1068 | clear_dma_done0(ep0->indma); | ||
1069 | if (buff_done & DMA_D1) | ||
1070 | clear_dma_done1(ep0->indma); | ||
1071 | |||
1072 | pkt = send_packet_complete(ep0); | ||
1073 | kfree(pkt); | ||
1074 | } | ||
1075 | |||
1076 | /* | ||
1077 | * Now check packet receive done. Shouldn't get these, | ||
1078 | * the receive packet complete intr should happen | ||
1079 | * before the DMA done intr occurs. | ||
1080 | */ | ||
1081 | if ((buff_done = get_dma_buffer_done(ep0->outdma)) != 0) { | ||
1082 | // clear DMA done bit | ||
1083 | if (buff_done & DMA_D0) | ||
1084 | clear_dma_done0(ep0->outdma); | ||
1085 | if (buff_done & DMA_D1) | ||
1086 | clear_dma_done1(ep0->outdma); | ||
1087 | |||
1088 | //process_ep0_receive(dev); | ||
1089 | } | ||
1090 | |||
1091 | spin_unlock(&ep0->lock); | ||
1092 | } | ||
1093 | |||
1094 | /* This ISR handles the DMA done events on endpoints 2,3,4,5 */ | ||
1095 | static void dma_done_ep_intr(int irq, void *dev_id) | ||
1096 | { | ||
1097 | struct usb_dev *dev = (struct usb_dev *) dev_id; | ||
1098 | int i; | ||
1099 | |||
1100 | for (i = 2; i < 6; i++) { | ||
1101 | u32 buff_done; | ||
1102 | usbdev_pkt_t* pkt; | ||
1103 | endpoint_t *ep = &dev->ep[i]; | ||
1104 | |||
1105 | if (!ep->active) continue; | ||
1106 | |||
1107 | spin_lock(&ep->lock); | ||
1108 | |||
1109 | if (ep->direction == USB_DIR_IN) { | ||
1110 | buff_done = get_dma_buffer_done(ep->indma); | ||
1111 | if (buff_done != 0) { | ||
1112 | // transmitted a DATAx pkt on the IN ep | ||
1113 | // clear DMA done bit | ||
1114 | if (buff_done & DMA_D0) | ||
1115 | clear_dma_done0(ep->indma); | ||
1116 | if (buff_done & DMA_D1) | ||
1117 | clear_dma_done1(ep->indma); | ||
1118 | |||
1119 | pkt = send_packet_complete(ep); | ||
1120 | |||
1121 | spin_unlock(&ep->lock); | ||
1122 | dev->func_cb(CB_PKT_COMPLETE, | ||
1123 | (unsigned long)pkt, | ||
1124 | dev->cb_data); | ||
1125 | spin_lock(&ep->lock); | ||
1126 | } | ||
1127 | } else { | ||
1128 | /* | ||
1129 | * Check packet receive done (OUT ep). Shouldn't get | ||
1130 | * these, the rx packet complete intr should happen | ||
1131 | * before the DMA done intr occurs. | ||
1132 | */ | ||
1133 | buff_done = get_dma_buffer_done(ep->outdma); | ||
1134 | if (buff_done != 0) { | ||
1135 | // received a DATAx pkt on the OUT ep | ||
1136 | // clear DMA done bit | ||
1137 | if (buff_done & DMA_D0) | ||
1138 | clear_dma_done0(ep->outdma); | ||
1139 | if (buff_done & DMA_D1) | ||
1140 | clear_dma_done1(ep->outdma); | ||
1141 | |||
1142 | //process_ep_receive(dev, ep); | ||
1143 | } | ||
1144 | } | ||
1145 | |||
1146 | spin_unlock(&ep->lock); | ||
1147 | } | ||
1148 | } | ||
1149 | |||
1150 | |||
1151 | /*************************************************************************** | ||
1152 | * Here begins the external interface functions | ||
1153 | *************************************************************************** | ||
1154 | */ | ||
1155 | |||
1156 | /* | ||
1157 | * allocate a new packet | ||
1158 | */ | ||
1159 | int | ||
1160 | usbdev_alloc_packet(int ep_addr, int data_size, usbdev_pkt_t** pkt) | ||
1161 | { | ||
1162 | endpoint_t * ep = epaddr_to_ep(&usbdev, ep_addr); | ||
1163 | usbdev_pkt_t* lpkt = NULL; | ||
1164 | |||
1165 | if (!ep || !ep->active || ep->address < 2) | ||
1166 | return -ENODEV; | ||
1167 | if (data_size > ep->max_pkt_size) | ||
1168 | return -EINVAL; | ||
1169 | |||
1170 | lpkt = *pkt = alloc_packet(ep, data_size, NULL); | ||
1171 | if (!lpkt) | ||
1172 | return -ENOMEM; | ||
1173 | return 0; | ||
1174 | } | ||
1175 | |||
1176 | |||
1177 | /* | ||
1178 | * packet send | ||
1179 | */ | ||
1180 | int | ||
1181 | usbdev_send_packet(int ep_addr, usbdev_pkt_t * pkt) | ||
1182 | { | ||
1183 | unsigned long flags; | ||
1184 | int count; | ||
1185 | endpoint_t * ep; | ||
1186 | |||
1187 | if (!pkt || !(ep = epaddr_to_ep(&usbdev, pkt->ep_addr)) || | ||
1188 | !ep->active || ep->address < 2) | ||
1189 | return -ENODEV; | ||
1190 | if (ep->direction != USB_DIR_IN) | ||
1191 | return -EINVAL; | ||
1192 | |||
1193 | spin_lock_irqsave(&ep->lock, flags); | ||
1194 | count = send_packet(&usbdev, pkt, 1); | ||
1195 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1196 | |||
1197 | return count; | ||
1198 | } | ||
1199 | |||
1200 | /* | ||
1201 | * packet receive | ||
1202 | */ | ||
1203 | int | ||
1204 | usbdev_receive_packet(int ep_addr, usbdev_pkt_t** pkt) | ||
1205 | { | ||
1206 | unsigned long flags; | ||
1207 | usbdev_pkt_t* lpkt = NULL; | ||
1208 | endpoint_t *ep = epaddr_to_ep(&usbdev, ep_addr); | ||
1209 | |||
1210 | if (!ep || !ep->active || ep->address < 2) | ||
1211 | return -ENODEV; | ||
1212 | if (ep->direction != USB_DIR_OUT) | ||
1213 | return -EINVAL; | ||
1214 | |||
1215 | spin_lock_irqsave(&ep->lock, flags); | ||
1216 | if (ep->outlist.count > 1) | ||
1217 | lpkt = unlink_head(&ep->outlist); | ||
1218 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1219 | |||
1220 | if (!lpkt) { | ||
1221 | /* no packet available */ | ||
1222 | *pkt = NULL; | ||
1223 | return -ENODATA; | ||
1224 | } | ||
1225 | |||
1226 | *pkt = lpkt; | ||
1227 | |||
1228 | return lpkt->size; | ||
1229 | } | ||
1230 | |||
1231 | |||
1232 | /* | ||
1233 | * return total queued byte count on the endpoint. | ||
1234 | */ | ||
1235 | int | ||
1236 | usbdev_get_byte_count(int ep_addr) | ||
1237 | { | ||
1238 | unsigned long flags; | ||
1239 | pkt_list_t *list; | ||
1240 | usbdev_pkt_t *scan; | ||
1241 | int count = 0; | ||
1242 | endpoint_t * ep = epaddr_to_ep(&usbdev, ep_addr); | ||
1243 | |||
1244 | if (!ep || !ep->active || ep->address < 2) | ||
1245 | return -ENODEV; | ||
1246 | |||
1247 | if (ep->direction == USB_DIR_IN) { | ||
1248 | list = &ep->inlist; | ||
1249 | |||
1250 | spin_lock_irqsave(&ep->lock, flags); | ||
1251 | for (scan = list->head; scan; scan = scan->next) | ||
1252 | count += scan->size; | ||
1253 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1254 | } else { | ||
1255 | list = &ep->outlist; | ||
1256 | |||
1257 | spin_lock_irqsave(&ep->lock, flags); | ||
1258 | if (list->count > 1) { | ||
1259 | for (scan = list->head; scan != list->tail; | ||
1260 | scan = scan->next) | ||
1261 | count += scan->size; | ||
1262 | } | ||
1263 | spin_unlock_irqrestore(&ep->lock, flags); | ||
1264 | } | ||
1265 | |||
1266 | return count; | ||
1267 | } | ||
1268 | |||
1269 | |||
1270 | void | ||
1271 | usbdev_exit(void) | ||
1272 | { | ||
1273 | endpoint_t *ep; | ||
1274 | int i; | ||
1275 | |||
1276 | au_writel(0, USBD_INTEN); // disable usb dev ints | ||
1277 | au_writel(0, USBD_ENABLE); // disable usb dev | ||
1278 | |||
1279 | free_irq(AU1000_USB_DEV_REQ_INT, &usbdev); | ||
1280 | free_irq(AU1000_USB_DEV_SUS_INT, &usbdev); | ||
1281 | |||
1282 | // free all control endpoint resources | ||
1283 | ep = &usbdev.ep[0]; | ||
1284 | free_au1000_dma(ep->indma); | ||
1285 | free_au1000_dma(ep->outdma); | ||
1286 | endpoint_flush(ep); | ||
1287 | |||
1288 | // free ep resources | ||
1289 | for (i = 2; i < 6; i++) { | ||
1290 | ep = &usbdev.ep[i]; | ||
1291 | if (!ep->active) continue; | ||
1292 | |||
1293 | if (ep->direction == USB_DIR_IN) { | ||
1294 | free_au1000_dma(ep->indma); | ||
1295 | } else { | ||
1296 | free_au1000_dma(ep->outdma); | ||
1297 | } | ||
1298 | endpoint_flush(ep); | ||
1299 | } | ||
1300 | |||
1301 | kfree(usbdev.full_conf_desc); | ||
1302 | } | ||
1303 | |||
1304 | int | ||
1305 | usbdev_init(struct usb_device_descriptor* dev_desc, | ||
1306 | struct usb_config_descriptor* config_desc, | ||
1307 | struct usb_interface_descriptor* if_desc, | ||
1308 | struct usb_endpoint_descriptor* ep_desc, | ||
1309 | struct usb_string_descriptor* str_desc[], | ||
1310 | void (*cb)(usbdev_cb_type_t, unsigned long, void *), | ||
1311 | void* cb_data) | ||
1312 | { | ||
1313 | endpoint_t *ep0; | ||
1314 | int i, ret=0; | ||
1315 | u8* fcd; | ||
1316 | |||
1317 | if (dev_desc->bNumConfigurations > 1 || | ||
1318 | config_desc->bNumInterfaces > 1 || | ||
1319 | if_desc->bNumEndpoints > 4) { | ||
1320 | err("Only one config, one i/f, and no more " | ||
1321 | "than 4 ep's allowed"); | ||
1322 | ret = -EINVAL; | ||
1323 | goto out; | ||
1324 | } | ||
1325 | |||
1326 | if (!cb) { | ||
1327 | err("Function-layer callback required"); | ||
1328 | ret = -EINVAL; | ||
1329 | goto out; | ||
1330 | } | ||
1331 | |||
1332 | if (dev_desc->bMaxPacketSize0 != USBDEV_EP0_MAX_PACKET_SIZE) { | ||
1333 | warn("EP0 Max Packet size must be %d", | ||
1334 | USBDEV_EP0_MAX_PACKET_SIZE); | ||
1335 | dev_desc->bMaxPacketSize0 = USBDEV_EP0_MAX_PACKET_SIZE; | ||
1336 | } | ||
1337 | |||
1338 | memset(&usbdev, 0, sizeof(struct usb_dev)); | ||
1339 | |||
1340 | usbdev.state = DEFAULT; | ||
1341 | usbdev.dev_desc = dev_desc; | ||
1342 | usbdev.if_desc = if_desc; | ||
1343 | usbdev.conf_desc = config_desc; | ||
1344 | for (i=0; i<6; i++) | ||
1345 | usbdev.str_desc[i] = str_desc[i]; | ||
1346 | usbdev.func_cb = cb; | ||
1347 | usbdev.cb_data = cb_data; | ||
1348 | |||
1349 | /* Initialize default control endpoint */ | ||
1350 | ep0 = &usbdev.ep[0]; | ||
1351 | ep0->active = 1; | ||
1352 | ep0->type = CONTROL_EP; | ||
1353 | ep0->max_pkt_size = USBDEV_EP0_MAX_PACKET_SIZE; | ||
1354 | spin_lock_init(&ep0->lock); | ||
1355 | ep0->desc = NULL; // ep0 has no descriptor | ||
1356 | ep0->address = 0; | ||
1357 | ep0->direction = 0; | ||
1358 | ep0->reg = &ep_reg[0]; | ||
1359 | |||
1360 | /* Initialize the other requested endpoints */ | ||
1361 | for (i = 0; i < if_desc->bNumEndpoints; i++) { | ||
1362 | struct usb_endpoint_descriptor* epd = &ep_desc[i]; | ||
1363 | endpoint_t *ep; | ||
1364 | |||
1365 | if ((epd->bEndpointAddress & 0x80) == USB_DIR_IN) { | ||
1366 | ep = &usbdev.ep[2]; | ||
1367 | ep->address = 2; | ||
1368 | if (ep->active) { | ||
1369 | ep = &usbdev.ep[3]; | ||
1370 | ep->address = 3; | ||
1371 | if (ep->active) { | ||
1372 | err("too many IN ep's requested"); | ||
1373 | ret = -ENODEV; | ||
1374 | goto out; | ||
1375 | } | ||
1376 | } | ||
1377 | } else { | ||
1378 | ep = &usbdev.ep[4]; | ||
1379 | ep->address = 4; | ||
1380 | if (ep->active) { | ||
1381 | ep = &usbdev.ep[5]; | ||
1382 | ep->address = 5; | ||
1383 | if (ep->active) { | ||
1384 | err("too many OUT ep's requested"); | ||
1385 | ret = -ENODEV; | ||
1386 | goto out; | ||
1387 | } | ||
1388 | } | ||
1389 | } | ||
1390 | |||
1391 | ep->active = 1; | ||
1392 | epd->bEndpointAddress &= ~0x0f; | ||
1393 | epd->bEndpointAddress |= (u8)ep->address; | ||
1394 | ep->direction = epd->bEndpointAddress & 0x80; | ||
1395 | ep->type = epd->bmAttributes & 0x03; | ||
1396 | ep->max_pkt_size = le16_to_cpu(epd->wMaxPacketSize); | ||
1397 | spin_lock_init(&ep->lock); | ||
1398 | ep->desc = epd; | ||
1399 | ep->reg = &ep_reg[ep->address]; | ||
1400 | } | ||
1401 | |||
1402 | /* | ||
1403 | * initialize the full config descriptor | ||
1404 | */ | ||
1405 | usbdev.full_conf_desc = fcd = kmalloc(le16_to_cpu(config_desc->wTotalLength), | ||
1406 | ALLOC_FLAGS); | ||
1407 | if (!fcd) { | ||
1408 | err("failed to alloc full config descriptor"); | ||
1409 | ret = -ENOMEM; | ||
1410 | goto out; | ||
1411 | } | ||
1412 | |||
1413 | memcpy(fcd, config_desc, USB_DT_CONFIG_SIZE); | ||
1414 | fcd += USB_DT_CONFIG_SIZE; | ||
1415 | memcpy(fcd, if_desc, USB_DT_INTERFACE_SIZE); | ||
1416 | fcd += USB_DT_INTERFACE_SIZE; | ||
1417 | for (i = 0; i < if_desc->bNumEndpoints; i++) { | ||
1418 | memcpy(fcd, &ep_desc[i], USB_DT_ENDPOINT_SIZE); | ||
1419 | fcd += USB_DT_ENDPOINT_SIZE; | ||
1420 | } | ||
1421 | |||
1422 | /* Now we're ready to enable the controller */ | ||
1423 | au_writel(0x0002, USBD_ENABLE); | ||
1424 | udelay(100); | ||
1425 | au_writel(0x0003, USBD_ENABLE); | ||
1426 | udelay(100); | ||
1427 | |||
1428 | /* build and send config table based on ep descriptors */ | ||
1429 | for (i = 0; i < 6; i++) { | ||
1430 | endpoint_t *ep; | ||
1431 | if (i == 1) | ||
1432 | continue; // skip dummy ep | ||
1433 | ep = &usbdev.ep[i]; | ||
1434 | if (ep->active) { | ||
1435 | au_writel((ep->address << 4) | 0x04, USBD_CONFIG); | ||
1436 | au_writel(((ep->max_pkt_size & 0x380) >> 7) | | ||
1437 | (ep->direction >> 4) | (ep->type << 4), | ||
1438 | USBD_CONFIG); | ||
1439 | au_writel((ep->max_pkt_size & 0x7f) << 1, USBD_CONFIG); | ||
1440 | au_writel(0x00, USBD_CONFIG); | ||
1441 | au_writel(ep->address, USBD_CONFIG); | ||
1442 | } else { | ||
1443 | u8 dir = (i==2 || i==3) ? DIR_IN : DIR_OUT; | ||
1444 | au_writel((i << 4) | 0x04, USBD_CONFIG); | ||
1445 | au_writel(((16 & 0x380) >> 7) | dir | | ||
1446 | (BULK_EP << 4), USBD_CONFIG); | ||
1447 | au_writel((16 & 0x7f) << 1, USBD_CONFIG); | ||
1448 | au_writel(0x00, USBD_CONFIG); | ||
1449 | au_writel(i, USBD_CONFIG); | ||
1450 | } | ||
1451 | } | ||
1452 | |||
1453 | /* | ||
1454 | * Enable Receive FIFO Complete interrupts only. Transmit | ||
1455 | * complete is being handled by the DMA done interrupts. | ||
1456 | */ | ||
1457 | au_writel(0x31, USBD_INTEN); | ||
1458 | |||
1459 | /* | ||
1460 | * Controller is now enabled, request DMA and IRQ | ||
1461 | * resources. | ||
1462 | */ | ||
1463 | |||
1464 | /* request the USB device transfer complete interrupt */ | ||
1465 | if (request_irq(AU1000_USB_DEV_REQ_INT, req_sus_intr, IRQF_DISABLED, | ||
1466 | "USBdev req", &usbdev)) { | ||
1467 | err("Can't get device request intr"); | ||
1468 | ret = -ENXIO; | ||
1469 | goto out; | ||
1470 | } | ||
1471 | /* request the USB device suspend interrupt */ | ||
1472 | if (request_irq(AU1000_USB_DEV_SUS_INT, req_sus_intr, IRQF_DISABLED, | ||
1473 | "USBdev sus", &usbdev)) { | ||
1474 | err("Can't get device suspend intr"); | ||
1475 | ret = -ENXIO; | ||
1476 | goto out; | ||
1477 | } | ||
1478 | |||
1479 | /* Request EP0 DMA and IRQ */ | ||
1480 | if ((ep0->indma = request_au1000_dma(ep_dma_id[0].id, | ||
1481 | ep_dma_id[0].str, | ||
1482 | dma_done_ep0_intr, | ||
1483 | IRQF_DISABLED, | ||
1484 | &usbdev)) < 0) { | ||
1485 | err("Can't get %s DMA", ep_dma_id[0].str); | ||
1486 | ret = -ENXIO; | ||
1487 | goto out; | ||
1488 | } | ||
1489 | if ((ep0->outdma = request_au1000_dma(ep_dma_id[1].id, | ||
1490 | ep_dma_id[1].str, | ||
1491 | NULL, 0, NULL)) < 0) { | ||
1492 | err("Can't get %s DMA", ep_dma_id[1].str); | ||
1493 | ret = -ENXIO; | ||
1494 | goto out; | ||
1495 | } | ||
1496 | |||
1497 | // Flush the ep0 buffers and FIFOs | ||
1498 | endpoint_flush(ep0); | ||
1499 | // start packet reception on ep0 | ||
1500 | kickstart_receive_packet(ep0); | ||
1501 | |||
1502 | /* Request DMA and IRQ for the other endpoints */ | ||
1503 | for (i = 2; i < 6; i++) { | ||
1504 | endpoint_t *ep = &usbdev.ep[i]; | ||
1505 | if (!ep->active) | ||
1506 | continue; | ||
1507 | |||
1508 | // Flush the endpoint buffers and FIFOs | ||
1509 | endpoint_flush(ep); | ||
1510 | |||
1511 | if (ep->direction == USB_DIR_IN) { | ||
1512 | ep->indma = | ||
1513 | request_au1000_dma(ep_dma_id[ep->address].id, | ||
1514 | ep_dma_id[ep->address].str, | ||
1515 | dma_done_ep_intr, | ||
1516 | IRQF_DISABLED, | ||
1517 | &usbdev); | ||
1518 | if (ep->indma < 0) { | ||
1519 | err("Can't get %s DMA", | ||
1520 | ep_dma_id[ep->address].str); | ||
1521 | ret = -ENXIO; | ||
1522 | goto out; | ||
1523 | } | ||
1524 | } else { | ||
1525 | ep->outdma = | ||
1526 | request_au1000_dma(ep_dma_id[ep->address].id, | ||
1527 | ep_dma_id[ep->address].str, | ||
1528 | NULL, 0, NULL); | ||
1529 | if (ep->outdma < 0) { | ||
1530 | err("Can't get %s DMA", | ||
1531 | ep_dma_id[ep->address].str); | ||
1532 | ret = -ENXIO; | ||
1533 | goto out; | ||
1534 | } | ||
1535 | |||
1536 | // start packet reception on OUT endpoint | ||
1537 | kickstart_receive_packet(ep); | ||
1538 | } | ||
1539 | } | ||
1540 | |||
1541 | out: | ||
1542 | if (ret) | ||
1543 | usbdev_exit(); | ||
1544 | return ret; | ||
1545 | } | ||
1546 | |||
1547 | EXPORT_SYMBOL(usbdev_init); | ||
1548 | EXPORT_SYMBOL(usbdev_exit); | ||
1549 | EXPORT_SYMBOL(usbdev_alloc_packet); | ||
1550 | EXPORT_SYMBOL(usbdev_receive_packet); | ||
1551 | EXPORT_SYMBOL(usbdev_send_packet); | ||
1552 | EXPORT_SYMBOL(usbdev_get_byte_count); | ||
diff --git a/arch/mips/au1000/db1x00/board_setup.c b/arch/mips/au1000/db1x00/board_setup.c index 7a79293f8527..8b08edb977be 100644 --- a/arch/mips/au1000/db1x00/board_setup.c +++ b/arch/mips/au1000/db1x00/board_setup.c | |||
@@ -58,11 +58,6 @@ void __init board_setup(void) | |||
58 | 58 | ||
59 | pin_func = 0; | 59 | pin_func = 0; |
60 | /* not valid for 1550 */ | 60 | /* not valid for 1550 */ |
61 | #ifdef CONFIG_AU1X00_USB_DEVICE | ||
62 | // 2nd USB port is USB device | ||
63 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8000); | ||
64 | au_writel(pin_func, SYS_PINFUNC); | ||
65 | #endif | ||
66 | 61 | ||
67 | #if defined(CONFIG_IRDA) && (defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100)) | 62 | #if defined(CONFIG_IRDA) && (defined(CONFIG_SOC_AU1000) || defined(CONFIG_SOC_AU1100)) |
68 | /* set IRFIRSEL instead of GPIO15 */ | 63 | /* set IRFIRSEL instead of GPIO15 */ |
diff --git a/arch/mips/au1000/mtx-1/board_setup.c b/arch/mips/au1000/mtx-1/board_setup.c index e917e54fc683..13f9bf5f91a6 100644 --- a/arch/mips/au1000/mtx-1/board_setup.c +++ b/arch/mips/au1000/mtx-1/board_setup.c | |||
@@ -51,15 +51,11 @@ void board_reset (void) | |||
51 | 51 | ||
52 | void __init board_setup(void) | 52 | void __init board_setup(void) |
53 | { | 53 | { |
54 | #if defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) | 54 | #ifdef CONFIG_USB_OHCI |
55 | #ifdef CONFIG_AU1X00_USB_DEVICE | ||
56 | // 2nd USB port is USB device | ||
57 | au_writel(au_readl(SYS_PINFUNC) & (u32)(~0x8000), SYS_PINFUNC); | ||
58 | #endif | ||
59 | // enable USB power switch | 55 | // enable USB power switch |
60 | au_writel( au_readl(GPIO2_DIR) | 0x10, GPIO2_DIR ); | 56 | au_writel( au_readl(GPIO2_DIR) | 0x10, GPIO2_DIR ); |
61 | au_writel( 0x100000, GPIO2_OUTPUT ); | 57 | au_writel( 0x100000, GPIO2_OUTPUT ); |
62 | #endif // defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) | 58 | #endif // defined (CONFIG_USB_OHCI) |
63 | 59 | ||
64 | #ifdef CONFIG_PCI | 60 | #ifdef CONFIG_PCI |
65 | #if defined(__MIPSEB__) | 61 | #if defined(__MIPSEB__) |
diff --git a/arch/mips/au1000/pb1000/board_setup.c b/arch/mips/au1000/pb1000/board_setup.c index 1cf18e16ab54..824cfafaff92 100644 --- a/arch/mips/au1000/pb1000/board_setup.c +++ b/arch/mips/au1000/pb1000/board_setup.c | |||
@@ -54,7 +54,7 @@ void __init board_setup(void) | |||
54 | au_writel(0, SYS_PINSTATERD); | 54 | au_writel(0, SYS_PINSTATERD); |
55 | udelay(100); | 55 | udelay(100); |
56 | 56 | ||
57 | #if defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) | 57 | #ifdef CONFIG_USB_OHCI |
58 | /* zero and disable FREQ2 */ | 58 | /* zero and disable FREQ2 */ |
59 | sys_freqctrl = au_readl(SYS_FREQCTRL0); | 59 | sys_freqctrl = au_readl(SYS_FREQCTRL0); |
60 | sys_freqctrl &= ~0xFFF00000; | 60 | sys_freqctrl &= ~0xFFF00000; |
@@ -105,22 +105,18 @@ void __init board_setup(void) | |||
105 | #ifdef CONFIG_USB_OHCI | 105 | #ifdef CONFIG_USB_OHCI |
106 | sys_clksrc |= ((4<<12) | (0<<11) | (0<<10)); | 106 | sys_clksrc |= ((4<<12) | (0<<11) | (0<<10)); |
107 | #endif | 107 | #endif |
108 | #ifdef CONFIG_AU1X00_USB_DEVICE | ||
109 | sys_clksrc |= ((4<<7) | (0<<6) | (0<<5)); | ||
110 | #endif | ||
111 | au_writel(sys_clksrc, SYS_CLKSRC); | 108 | au_writel(sys_clksrc, SYS_CLKSRC); |
112 | 109 | ||
113 | // configure pins GPIO[14:9] as GPIO | 110 | // configure pins GPIO[14:9] as GPIO |
114 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8080); | 111 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8080); |
115 | 112 | ||
116 | #ifndef CONFIG_AU1X00_USB_DEVICE | ||
117 | // 2nd USB port is USB host | 113 | // 2nd USB port is USB host |
118 | pin_func |= 0x8000; | 114 | pin_func |= 0x8000; |
119 | #endif | 115 | |
120 | au_writel(pin_func, SYS_PINFUNC); | 116 | au_writel(pin_func, SYS_PINFUNC); |
121 | au_writel(0x2800, SYS_TRIOUTCLR); | 117 | au_writel(0x2800, SYS_TRIOUTCLR); |
122 | au_writel(0x0030, SYS_OUTPUTCLR); | 118 | au_writel(0x0030, SYS_OUTPUTCLR); |
123 | #endif // defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) | 119 | #endif // defined (CONFIG_USB_OHCI) |
124 | 120 | ||
125 | // make gpio 15 an input (for interrupt line) | 121 | // make gpio 15 an input (for interrupt line) |
126 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x100); | 122 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x100); |
diff --git a/arch/mips/au1000/pb1100/board_setup.c b/arch/mips/au1000/pb1100/board_setup.c index db27b9331ff3..2d1533f116c0 100644 --- a/arch/mips/au1000/pb1100/board_setup.c +++ b/arch/mips/au1000/pb1100/board_setup.c | |||
@@ -55,7 +55,7 @@ void __init board_setup(void) | |||
55 | au_writel(0, SYS_PININPUTEN); | 55 | au_writel(0, SYS_PININPUTEN); |
56 | udelay(100); | 56 | udelay(100); |
57 | 57 | ||
58 | #if defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) | 58 | #ifdef CONFIG_USB_OHCI |
59 | // configure pins GPIO[14:9] as GPIO | 59 | // configure pins GPIO[14:9] as GPIO |
60 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x80); | 60 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x80); |
61 | 61 | ||
@@ -92,12 +92,10 @@ void __init board_setup(void) | |||
92 | 92 | ||
93 | // get USB Functionality pin state (device vs host drive pins) | 93 | // get USB Functionality pin state (device vs host drive pins) |
94 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8000); | 94 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8000); |
95 | #ifndef CONFIG_AU1X00_USB_DEVICE | ||
96 | // 2nd USB port is USB host | 95 | // 2nd USB port is USB host |
97 | pin_func |= 0x8000; | 96 | pin_func |= 0x8000; |
98 | #endif | ||
99 | au_writel(pin_func, SYS_PINFUNC); | 97 | au_writel(pin_func, SYS_PINFUNC); |
100 | #endif // defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) | 98 | #endif // defined (CONFIG_USB_OHCI) |
101 | 99 | ||
102 | /* Enable sys bus clock divider when IDLE state or no bus activity. */ | 100 | /* Enable sys bus clock divider when IDLE state or no bus activity. */ |
103 | au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL); | 101 | au_writel(au_readl(SYS_POWERCTRL) | (0x3 << 5), SYS_POWERCTRL); |
diff --git a/arch/mips/au1000/pb1500/board_setup.c b/arch/mips/au1000/pb1500/board_setup.c index 1a9a293de6ab..0ffdb4fd575b 100644 --- a/arch/mips/au1000/pb1500/board_setup.c +++ b/arch/mips/au1000/pb1500/board_setup.c | |||
@@ -56,7 +56,7 @@ void __init board_setup(void) | |||
56 | au_writel(0, SYS_PINSTATERD); | 56 | au_writel(0, SYS_PINSTATERD); |
57 | udelay(100); | 57 | udelay(100); |
58 | 58 | ||
59 | #if defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) | 59 | #ifdef CONFIG_USB_OHCI |
60 | 60 | ||
61 | /* GPIO201 is input for PCMCIA card detect */ | 61 | /* GPIO201 is input for PCMCIA card detect */ |
62 | /* GPIO203 is input for PCMCIA interrupt request */ | 62 | /* GPIO203 is input for PCMCIA interrupt request */ |
@@ -88,19 +88,14 @@ void __init board_setup(void) | |||
88 | #ifdef CONFIG_USB_OHCI | 88 | #ifdef CONFIG_USB_OHCI |
89 | sys_clksrc |= ((4<<12) | (0<<11) | (0<<10)); | 89 | sys_clksrc |= ((4<<12) | (0<<11) | (0<<10)); |
90 | #endif | 90 | #endif |
91 | #ifdef CONFIG_AU1X00_USB_DEVICE | ||
92 | sys_clksrc |= ((4<<7) | (0<<6) | (0<<5)); | ||
93 | #endif | ||
94 | au_writel(sys_clksrc, SYS_CLKSRC); | 91 | au_writel(sys_clksrc, SYS_CLKSRC); |
95 | 92 | ||
96 | 93 | ||
97 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8000); | 94 | pin_func = au_readl(SYS_PINFUNC) & (u32)(~0x8000); |
98 | #ifndef CONFIG_AU1X00_USB_DEVICE | ||
99 | // 2nd USB port is USB host | 95 | // 2nd USB port is USB host |
100 | pin_func |= 0x8000; | 96 | pin_func |= 0x8000; |
101 | #endif | ||
102 | au_writel(pin_func, SYS_PINFUNC); | 97 | au_writel(pin_func, SYS_PINFUNC); |
103 | #endif // defined (CONFIG_USB_OHCI) || defined (CONFIG_AU1X00_USB_DEVICE) | 98 | #endif // defined (CONFIG_USB_OHCI) |
104 | 99 | ||
105 | 100 | ||
106 | 101 | ||
diff --git a/arch/mips/configs/pb1100_defconfig b/arch/mips/configs/pb1100_defconfig index 741f8258075c..9e672f63a0aa 100644 --- a/arch/mips/configs/pb1100_defconfig +++ b/arch/mips/configs/pb1100_defconfig | |||
@@ -76,7 +76,6 @@ CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y | |||
76 | CONFIG_SOC_AU1100=y | 76 | CONFIG_SOC_AU1100=y |
77 | CONFIG_SOC_AU1X00=y | 77 | CONFIG_SOC_AU1X00=y |
78 | CONFIG_SWAP_IO_SPACE=y | 78 | CONFIG_SWAP_IO_SPACE=y |
79 | # CONFIG_AU1X00_USB_DEVICE is not set | ||
80 | CONFIG_MIPS_L1_CACHE_SHIFT=5 | 79 | CONFIG_MIPS_L1_CACHE_SHIFT=5 |
81 | 80 | ||
82 | # | 81 | # |
diff --git a/arch/mips/configs/pb1500_defconfig b/arch/mips/configs/pb1500_defconfig index 8576340714da..d0c0f4af1bff 100644 --- a/arch/mips/configs/pb1500_defconfig +++ b/arch/mips/configs/pb1500_defconfig | |||
@@ -75,7 +75,6 @@ CONFIG_CPU_LITTLE_ENDIAN=y | |||
75 | CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y | 75 | CONFIG_SYS_SUPPORTS_LITTLE_ENDIAN=y |
76 | CONFIG_SOC_AU1500=y | 76 | CONFIG_SOC_AU1500=y |
77 | CONFIG_SOC_AU1X00=y | 77 | CONFIG_SOC_AU1X00=y |
78 | # CONFIG_AU1X00_USB_DEVICE is not set | ||
79 | CONFIG_MIPS_L1_CACHE_SHIFT=5 | 78 | CONFIG_MIPS_L1_CACHE_SHIFT=5 |
80 | 79 | ||
81 | # | 80 | # |
diff --git a/arch/mips/dec/int-handler.S b/arch/mips/dec/int-handler.S index 55d60d5e0e86..31dd47d1002d 100644 --- a/arch/mips/dec/int-handler.S +++ b/arch/mips/dec/int-handler.S | |||
@@ -266,10 +266,8 @@ | |||
266 | handle_it: | 266 | handle_it: |
267 | LONG_L s0, TI_REGS($28) | 267 | LONG_L s0, TI_REGS($28) |
268 | LONG_S sp, TI_REGS($28) | 268 | LONG_S sp, TI_REGS($28) |
269 | jal do_IRQ | 269 | PTR_LA ra, ret_from_irq |
270 | LONG_S s0, TI_REGS($28) | 270 | j do_IRQ |
271 | |||
272 | j ret_from_irq | ||
273 | nop | 271 | nop |
274 | 272 | ||
275 | #ifdef CONFIG_32BIT | 273 | #ifdef CONFIG_32BIT |
@@ -279,9 +277,8 @@ fpu: | |||
279 | #endif | 277 | #endif |
280 | 278 | ||
281 | spurious: | 279 | spurious: |
282 | jal spurious_interrupt | 280 | PTR_LA ra, _ret_from_irq |
283 | nop | 281 | j spurious_interrupt |
284 | j ret_from_irq | ||
285 | nop | 282 | nop |
286 | END(plat_irq_dispatch) | 283 | END(plat_irq_dispatch) |
287 | 284 | ||
diff --git a/arch/mips/kernel/cpu-probe.c b/arch/mips/kernel/cpu-probe.c index 9fbf8430c849..8485af340ee1 100644 --- a/arch/mips/kernel/cpu-probe.c +++ b/arch/mips/kernel/cpu-probe.c | |||
@@ -135,7 +135,6 @@ static inline void check_wait(void) | |||
135 | case CPU_R5000: | 135 | case CPU_R5000: |
136 | case CPU_NEVADA: | 136 | case CPU_NEVADA: |
137 | case CPU_RM7000: | 137 | case CPU_RM7000: |
138 | case CPU_RM9000: | ||
139 | case CPU_4KC: | 138 | case CPU_4KC: |
140 | case CPU_4KEC: | 139 | case CPU_4KEC: |
141 | case CPU_4KSC: | 140 | case CPU_4KSC: |
@@ -164,6 +163,14 @@ static inline void check_wait(void) | |||
164 | } else | 163 | } else |
165 | printk(" unavailable.\n"); | 164 | printk(" unavailable.\n"); |
166 | break; | 165 | break; |
166 | case CPU_RM9000: | ||
167 | if ((c->processor_id & 0x00ff) >= 0x40) { | ||
168 | cpu_wait = r4k_wait; | ||
169 | printk(" available.\n"); | ||
170 | } else { | ||
171 | printk(" unavailable.\n"); | ||
172 | } | ||
173 | break; | ||
167 | default: | 174 | default: |
168 | printk(" unavailable.\n"); | 175 | printk(" unavailable.\n"); |
169 | break; | 176 | break; |
diff --git a/arch/mips/kernel/entry.S b/arch/mips/kernel/entry.S index e93e43e1f42d..417c08ac76eb 100644 --- a/arch/mips/kernel/entry.S +++ b/arch/mips/kernel/entry.S | |||
@@ -20,10 +20,7 @@ | |||
20 | #include <asm/mipsmtregs.h> | 20 | #include <asm/mipsmtregs.h> |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | #ifdef CONFIG_PREEMPT | 23 | #ifndef CONFIG_PREEMPT |
24 | .macro preempt_stop | ||
25 | .endm | ||
26 | #else | ||
27 | .macro preempt_stop | 24 | .macro preempt_stop |
28 | local_irq_disable | 25 | local_irq_disable |
29 | .endm | 26 | .endm |
@@ -32,9 +29,16 @@ | |||
32 | 29 | ||
33 | .text | 30 | .text |
34 | .align 5 | 31 | .align 5 |
32 | FEXPORT(ret_from_irq) | ||
33 | LONG_S s0, TI_REGS($28) | ||
34 | #ifdef CONFIG_PREEMPT | ||
35 | FEXPORT(ret_from_exception) | ||
36 | #else | ||
37 | b _ret_from_irq | ||
35 | FEXPORT(ret_from_exception) | 38 | FEXPORT(ret_from_exception) |
36 | preempt_stop | 39 | preempt_stop |
37 | FEXPORT(ret_from_irq) | 40 | #endif |
41 | FEXPORT(_ret_from_irq) | ||
38 | LONG_L t0, PT_STATUS(sp) # returning to kernel mode? | 42 | LONG_L t0, PT_STATUS(sp) # returning to kernel mode? |
39 | andi t0, t0, KU_USER | 43 | andi t0, t0, KU_USER |
40 | beqz t0, resume_kernel | 44 | beqz t0, resume_kernel |
diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S index 50ed77297728..5baca16993d0 100644 --- a/arch/mips/kernel/genex.S +++ b/arch/mips/kernel/genex.S | |||
@@ -133,9 +133,8 @@ NESTED(handle_int, PT_SIZE, sp) | |||
133 | 133 | ||
134 | LONG_L s0, TI_REGS($28) | 134 | LONG_L s0, TI_REGS($28) |
135 | LONG_S sp, TI_REGS($28) | 135 | LONG_S sp, TI_REGS($28) |
136 | jal plat_irq_dispatch | 136 | PTR_LA ra, ret_from_irq |
137 | LONG_S s0, TI_REGS($28) | 137 | j plat_irq_dispatch |
138 | j ret_from_irq | ||
139 | END(handle_int) | 138 | END(handle_int) |
140 | 139 | ||
141 | __INIT | 140 | __INIT |
@@ -224,9 +223,8 @@ NESTED(except_vec_vi_handler, 0, sp) | |||
224 | 223 | ||
225 | LONG_L s0, TI_REGS($28) | 224 | LONG_L s0, TI_REGS($28) |
226 | LONG_S sp, TI_REGS($28) | 225 | LONG_S sp, TI_REGS($28) |
227 | jalr v0 | ||
228 | LONG_S s0, TI_REGS($28) | ||
229 | PTR_LA ra, ret_from_irq | 226 | PTR_LA ra, ret_from_irq |
227 | jr v0 | ||
230 | END(except_vec_vi_handler) | 228 | END(except_vec_vi_handler) |
231 | 229 | ||
232 | /* | 230 | /* |
diff --git a/arch/mips/kernel/proc.c b/arch/mips/kernel/proc.c index 46ee5a68ab13..4ed37ba19731 100644 --- a/arch/mips/kernel/proc.c +++ b/arch/mips/kernel/proc.c | |||
@@ -107,7 +107,7 @@ static int show_cpuinfo(struct seq_file *m, void *v) | |||
107 | 107 | ||
108 | seq_printf(m, "processor\t\t: %ld\n", n); | 108 | seq_printf(m, "processor\t\t: %ld\n", n); |
109 | sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n", | 109 | sprintf(fmt, "cpu model\t\t: %%s V%%d.%%d%s\n", |
110 | cpu_has_fpu ? " FPU V%d.%d" : ""); | 110 | cpu_data[n].options & MIPS_CPU_FPU ? " FPU V%d.%d" : ""); |
111 | seq_printf(m, fmt, cpu_name[cpu_data[n].cputype <= CPU_LAST ? | 111 | seq_printf(m, fmt, cpu_name[cpu_data[n].cputype <= CPU_LAST ? |
112 | cpu_data[n].cputype : CPU_UNKNOWN], | 112 | cpu_data[n].cputype : CPU_UNKNOWN], |
113 | (version >> 4) & 0x0f, version & 0x0f, | 113 | (version >> 4) & 0x0f, version & 0x0f, |
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c index 045d987bc683..9f307eb1a31e 100644 --- a/arch/mips/kernel/process.c +++ b/arch/mips/kernel/process.c | |||
@@ -115,7 +115,7 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp) | |||
115 | status |= KU_USER; | 115 | status |= KU_USER; |
116 | regs->cp0_status = status; | 116 | regs->cp0_status = status; |
117 | clear_used_math(); | 117 | clear_used_math(); |
118 | lose_fpu(); | 118 | clear_fpu_owner(); |
119 | if (cpu_has_dsp) | 119 | if (cpu_has_dsp) |
120 | __init_dsp(); | 120 | __init_dsp(); |
121 | regs->cp0_epc = pc; | 121 | regs->cp0_epc = pc; |
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index 362d1728e531..258d74fd0b63 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c | |||
@@ -106,6 +106,7 @@ int ptrace_setregs (struct task_struct *child, __s64 __user *data) | |||
106 | int ptrace_getfpregs (struct task_struct *child, __u32 __user *data) | 106 | int ptrace_getfpregs (struct task_struct *child, __u32 __user *data) |
107 | { | 107 | { |
108 | int i; | 108 | int i; |
109 | unsigned int tmp; | ||
109 | 110 | ||
110 | if (!access_ok(VERIFY_WRITE, data, 33 * 8)) | 111 | if (!access_ok(VERIFY_WRITE, data, 33 * 8)) |
111 | return -EIO; | 112 | return -EIO; |
@@ -121,10 +122,10 @@ int ptrace_getfpregs (struct task_struct *child, __u32 __user *data) | |||
121 | 122 | ||
122 | __put_user (child->thread.fpu.fcr31, data + 64); | 123 | __put_user (child->thread.fpu.fcr31, data + 64); |
123 | 124 | ||
125 | preempt_disable(); | ||
124 | if (cpu_has_fpu) { | 126 | if (cpu_has_fpu) { |
125 | unsigned int flags, tmp; | 127 | unsigned int flags; |
126 | 128 | ||
127 | preempt_disable(); | ||
128 | if (cpu_has_mipsmt) { | 129 | if (cpu_has_mipsmt) { |
129 | unsigned int vpflags = dvpe(); | 130 | unsigned int vpflags = dvpe(); |
130 | flags = read_c0_status(); | 131 | flags = read_c0_status(); |
@@ -138,11 +139,11 @@ int ptrace_getfpregs (struct task_struct *child, __u32 __user *data) | |||
138 | __asm__ __volatile__("cfc1\t%0,$0" : "=r" (tmp)); | 139 | __asm__ __volatile__("cfc1\t%0,$0" : "=r" (tmp)); |
139 | write_c0_status(flags); | 140 | write_c0_status(flags); |
140 | } | 141 | } |
141 | preempt_enable(); | ||
142 | __put_user (tmp, data + 65); | ||
143 | } else { | 142 | } else { |
144 | __put_user ((__u32) 0, data + 65); | 143 | tmp = 0; |
145 | } | 144 | } |
145 | preempt_enable(); | ||
146 | __put_user (tmp, data + 65); | ||
146 | 147 | ||
147 | return 0; | 148 | return 0; |
148 | } | 149 | } |
@@ -245,16 +246,17 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) | |||
245 | unsigned int mtflags; | 246 | unsigned int mtflags; |
246 | #endif /* CONFIG_MIPS_MT_SMTC */ | 247 | #endif /* CONFIG_MIPS_MT_SMTC */ |
247 | 248 | ||
248 | if (!cpu_has_fpu) | 249 | preempt_disable(); |
250 | if (!cpu_has_fpu) { | ||
251 | preempt_enable(); | ||
249 | break; | 252 | break; |
253 | } | ||
250 | 254 | ||
251 | #ifdef CONFIG_MIPS_MT_SMTC | 255 | #ifdef CONFIG_MIPS_MT_SMTC |
252 | /* Read-modify-write of Status must be atomic */ | 256 | /* Read-modify-write of Status must be atomic */ |
253 | local_irq_save(irqflags); | 257 | local_irq_save(irqflags); |
254 | mtflags = dmt(); | 258 | mtflags = dmt(); |
255 | #endif /* CONFIG_MIPS_MT_SMTC */ | 259 | #endif /* CONFIG_MIPS_MT_SMTC */ |
256 | |||
257 | preempt_disable(); | ||
258 | if (cpu_has_mipsmt) { | 260 | if (cpu_has_mipsmt) { |
259 | unsigned int vpflags = dvpe(); | 261 | unsigned int vpflags = dvpe(); |
260 | flags = read_c0_status(); | 262 | flags = read_c0_status(); |
diff --git a/arch/mips/kernel/ptrace32.c b/arch/mips/kernel/ptrace32.c index f40ecd8be05f..d9a39c169450 100644 --- a/arch/mips/kernel/ptrace32.c +++ b/arch/mips/kernel/ptrace32.c | |||
@@ -175,7 +175,9 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data) | |||
175 | unsigned int mtflags; | 175 | unsigned int mtflags; |
176 | #endif /* CONFIG_MIPS_MT_SMTC */ | 176 | #endif /* CONFIG_MIPS_MT_SMTC */ |
177 | 177 | ||
178 | preempt_disable(); | ||
178 | if (!cpu_has_fpu) { | 179 | if (!cpu_has_fpu) { |
180 | preempt_enable(); | ||
179 | tmp = 0; | 181 | tmp = 0; |
180 | break; | 182 | break; |
181 | } | 183 | } |
@@ -186,7 +188,6 @@ asmlinkage int sys32_ptrace(int request, int pid, int addr, int data) | |||
186 | mtflags = dmt(); | 188 | mtflags = dmt(); |
187 | #endif /* CONFIG_MIPS_MT_SMTC */ | 189 | #endif /* CONFIG_MIPS_MT_SMTC */ |
188 | 190 | ||
189 | preempt_disable(); | ||
190 | if (cpu_has_mipsmt) { | 191 | if (cpu_has_mipsmt) { |
191 | unsigned int vpflags = dvpe(); | 192 | unsigned int vpflags = dvpe(); |
192 | flags = read_c0_status(); | 193 | flags = read_c0_status(); |
diff --git a/arch/mips/kernel/smp.c b/arch/mips/kernel/smp.c index 221895802dca..1af3612a1ce8 100644 --- a/arch/mips/kernel/smp.c +++ b/arch/mips/kernel/smp.c | |||
@@ -467,14 +467,18 @@ static DEFINE_PER_CPU(struct cpu, cpu_devices); | |||
467 | 467 | ||
468 | static int __init topology_init(void) | 468 | static int __init topology_init(void) |
469 | { | 469 | { |
470 | int cpu; | 470 | int i, ret; |
471 | int ret; | ||
472 | 471 | ||
473 | for_each_present_cpu(cpu) { | 472 | #ifdef CONFIG_NUMA |
474 | ret = register_cpu(&per_cpu(cpu_devices, cpu), cpu); | 473 | for_each_online_node(i) |
474 | register_one_node(i); | ||
475 | #endif /* CONFIG_NUMA */ | ||
476 | |||
477 | for_each_present_cpu(i) { | ||
478 | ret = register_cpu(&per_cpu(cpu_devices, i), i); | ||
475 | if (ret) | 479 | if (ret) |
476 | printk(KERN_WARNING "topology_init: register_cpu %d " | 480 | printk(KERN_WARNING "topology_init: register_cpu %d " |
477 | "failed (%d)\n", cpu, ret); | 481 | "failed (%d)\n", i, ret); |
478 | } | 482 | } |
479 | 483 | ||
480 | return 0; | 484 | return 0; |
diff --git a/arch/mips/kernel/smtc-asm.S b/arch/mips/kernel/smtc-asm.S index 76cb31d57482..1cb9441f1474 100644 --- a/arch/mips/kernel/smtc-asm.S +++ b/arch/mips/kernel/smtc-asm.S | |||
@@ -97,15 +97,12 @@ FEXPORT(__smtc_ipi_vector) | |||
97 | SAVE_ALL | 97 | SAVE_ALL |
98 | CLI | 98 | CLI |
99 | TRACE_IRQS_OFF | 99 | TRACE_IRQS_OFF |
100 | move a0,sp | ||
101 | /* Function to be invoked passed stack pad slot 5 */ | 100 | /* Function to be invoked passed stack pad slot 5 */ |
102 | lw t0,PT_PADSLOT5(sp) | 101 | lw t0,PT_PADSLOT5(sp) |
103 | /* Argument from sender passed in stack pad slot 4 */ | 102 | /* Argument from sender passed in stack pad slot 4 */ |
104 | lw a1,PT_PADSLOT4(sp) | 103 | lw a0,PT_PADSLOT4(sp) |
105 | jalr t0 | 104 | PTR_LA ra, _ret_from_irq |
106 | nop | 105 | jr t0 |
107 | j ret_from_irq | ||
108 | nop | ||
109 | 106 | ||
110 | /* | 107 | /* |
111 | * Called from idle loop to provoke processing of queued IPIs | 108 | * Called from idle loop to provoke processing of queued IPIs |
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index b7292a56d4cd..cce8313ec27d 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c | |||
@@ -66,7 +66,7 @@ extern asmlinkage void handle_mcheck(void); | |||
66 | extern asmlinkage void handle_reserved(void); | 66 | extern asmlinkage void handle_reserved(void); |
67 | 67 | ||
68 | extern int fpu_emulator_cop1Handler(struct pt_regs *xcp, | 68 | extern int fpu_emulator_cop1Handler(struct pt_regs *xcp, |
69 | struct mips_fpu_struct *ctx); | 69 | struct mips_fpu_struct *ctx, int has_fpu); |
70 | 70 | ||
71 | void (*board_be_init)(void); | 71 | void (*board_be_init)(void); |
72 | int (*board_be_handler)(struct pt_regs *regs, int is_fixup); | 72 | int (*board_be_handler)(struct pt_regs *regs, int is_fixup); |
@@ -641,7 +641,7 @@ asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31) | |||
641 | preempt_enable(); | 641 | preempt_enable(); |
642 | 642 | ||
643 | /* Run the emulator */ | 643 | /* Run the emulator */ |
644 | sig = fpu_emulator_cop1Handler (regs, ¤t->thread.fpu); | 644 | sig = fpu_emulator_cop1Handler (regs, ¤t->thread.fpu, 1); |
645 | 645 | ||
646 | preempt_disable(); | 646 | preempt_disable(); |
647 | 647 | ||
@@ -791,11 +791,13 @@ asmlinkage void do_cpu(struct pt_regs *regs) | |||
791 | set_used_math(); | 791 | set_used_math(); |
792 | } | 792 | } |
793 | 793 | ||
794 | preempt_enable(); | 794 | if (cpu_has_fpu) { |
795 | 795 | preempt_enable(); | |
796 | if (!cpu_has_fpu) { | 796 | } else { |
797 | int sig = fpu_emulator_cop1Handler(regs, | 797 | int sig; |
798 | ¤t->thread.fpu); | 798 | preempt_enable(); |
799 | sig = fpu_emulator_cop1Handler(regs, | ||
800 | ¤t->thread.fpu, 0); | ||
799 | if (sig) | 801 | if (sig) |
800 | force_sig(sig, current); | 802 | force_sig(sig, current); |
801 | #ifdef CONFIG_MIPS_MT_FPAFF | 803 | #ifdef CONFIG_MIPS_MT_FPAFF |
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c index 3f0d5d26d506..80531b35cd61 100644 --- a/arch/mips/math-emu/cp1emu.c +++ b/arch/mips/math-emu/cp1emu.c | |||
@@ -38,8 +38,6 @@ | |||
38 | 38 | ||
39 | #include <asm/inst.h> | 39 | #include <asm/inst.h> |
40 | #include <asm/bootinfo.h> | 40 | #include <asm/bootinfo.h> |
41 | #include <asm/cpu.h> | ||
42 | #include <asm/cpu-features.h> | ||
43 | #include <asm/processor.h> | 41 | #include <asm/processor.h> |
44 | #include <asm/ptrace.h> | 42 | #include <asm/ptrace.h> |
45 | #include <asm/signal.h> | 43 | #include <asm/signal.h> |
@@ -1233,7 +1231,8 @@ static int fpu_emu(struct pt_regs *xcp, struct mips_fpu_struct *ctx, | |||
1233 | return 0; | 1231 | return 0; |
1234 | } | 1232 | } |
1235 | 1233 | ||
1236 | int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx) | 1234 | int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx, |
1235 | int has_fpu) | ||
1237 | { | 1236 | { |
1238 | unsigned long oldepc, prevepc; | 1237 | unsigned long oldepc, prevepc; |
1239 | mips_instruction insn; | 1238 | mips_instruction insn; |
@@ -1263,7 +1262,7 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx) | |||
1263 | ieee754_csr.rm = mips_rm[ieee754_csr.rm]; | 1262 | ieee754_csr.rm = mips_rm[ieee754_csr.rm]; |
1264 | } | 1263 | } |
1265 | 1264 | ||
1266 | if (cpu_has_fpu) | 1265 | if (has_fpu) |
1267 | break; | 1266 | break; |
1268 | if (sig) | 1267 | if (sig) |
1269 | break; | 1268 | break; |
diff --git a/arch/mips/mips-boards/malta/malta_int.c b/arch/mips/mips-boards/malta/malta_int.c index ed221dc7f6ac..6244d0e2c7de 100644 --- a/arch/mips/mips-boards/malta/malta_int.c +++ b/arch/mips/mips-boards/malta/malta_int.c | |||
@@ -212,23 +212,23 @@ static inline unsigned int irq_ffs(unsigned int pending) | |||
212 | unsigned int a0 = 7; | 212 | unsigned int a0 = 7; |
213 | unsigned int t0; | 213 | unsigned int t0; |
214 | 214 | ||
215 | t0 = s0 & 0xf000; | 215 | t0 = pending & 0xf000; |
216 | t0 = t0 < 1; | 216 | t0 = t0 < 1; |
217 | t0 = t0 << 2; | 217 | t0 = t0 << 2; |
218 | a0 = a0 - t0; | 218 | a0 = a0 - t0; |
219 | s0 = s0 << t0; | 219 | pending = pending << t0; |
220 | 220 | ||
221 | t0 = s0 & 0xc000; | 221 | t0 = pending & 0xc000; |
222 | t0 = t0 < 1; | 222 | t0 = t0 < 1; |
223 | t0 = t0 << 1; | 223 | t0 = t0 << 1; |
224 | a0 = a0 - t0; | 224 | a0 = a0 - t0; |
225 | s0 = s0 << t0; | 225 | pending = pending << t0; |
226 | 226 | ||
227 | t0 = s0 & 0x8000; | 227 | t0 = pending & 0x8000; |
228 | t0 = t0 < 1; | 228 | t0 = t0 < 1; |
229 | //t0 = t0 << 2; | 229 | //t0 = t0 << 2; |
230 | a0 = a0 - t0; | 230 | a0 = a0 - t0; |
231 | //s0 = s0 << t0; | 231 | //pending = pending << t0; |
232 | 232 | ||
233 | return a0; | 233 | return a0; |
234 | #endif | 234 | #endif |
diff --git a/arch/mips/tx4927/common/tx4927_setup.c b/arch/mips/tx4927/common/tx4927_setup.c index 3ace4037343e..4658b2ae4833 100644 --- a/arch/mips/tx4927/common/tx4927_setup.c +++ b/arch/mips/tx4927/common/tx4927_setup.c | |||
@@ -53,19 +53,9 @@ void __init tx4927_time_init(void); | |||
53 | void dump_cp0(char *key); | 53 | void dump_cp0(char *key); |
54 | 54 | ||
55 | 55 | ||
56 | void (*__wbflush) (void); | ||
57 | |||
58 | static void tx4927_write_buffer_flush(void) | ||
59 | { | ||
60 | __asm__ __volatile__ | ||
61 | ("sync\n\t" "nop\n\t" "loop: bc0f loop\n\t" "nop\n\t"); | ||
62 | } | ||
63 | |||
64 | |||
65 | void __init plat_mem_setup(void) | 56 | void __init plat_mem_setup(void) |
66 | { | 57 | { |
67 | board_time_init = tx4927_time_init; | 58 | board_time_init = tx4927_time_init; |
68 | __wbflush = tx4927_write_buffer_flush; | ||
69 | 59 | ||
70 | #ifdef CONFIG_TOSHIBA_RBTX4927 | 60 | #ifdef CONFIG_TOSHIBA_RBTX4927 |
71 | { | 61 | { |
diff --git a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c index 3e24413d4c09..0c3c3f668230 100644 --- a/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c +++ b/arch/mips/tx4927/toshiba_rbtx4927/toshiba_rbtx4927_irq.c | |||
@@ -129,6 +129,7 @@ JP7 is not bus master -- do NOT use -- only 4 pci bus master's allowed -- SouthB | |||
129 | #include <asm/processor.h> | 129 | #include <asm/processor.h> |
130 | #include <asm/reboot.h> | 130 | #include <asm/reboot.h> |
131 | #include <asm/time.h> | 131 | #include <asm/time.h> |
132 | #include <asm/wbflush.h> | ||
132 | #include <linux/bootmem.h> | 133 | #include <linux/bootmem.h> |
133 | #include <linux/blkdev.h> | 134 | #include <linux/blkdev.h> |
134 | #ifdef CONFIG_RTC_DS1742 | 135 | #ifdef CONFIG_RTC_DS1742 |
diff --git a/arch/mips/tx4938/common/irq.c b/arch/mips/tx4938/common/irq.c index b6024749b8f4..77fe2454f5b9 100644 --- a/arch/mips/tx4938/common/irq.c +++ b/arch/mips/tx4938/common/irq.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <asm/irq.h> | 30 | #include <asm/irq.h> |
31 | #include <asm/mipsregs.h> | 31 | #include <asm/mipsregs.h> |
32 | #include <asm/system.h> | 32 | #include <asm/system.h> |
33 | #include <asm/wbflush.h> | ||
33 | #include <asm/tx4938/rbtx4938.h> | 34 | #include <asm/tx4938/rbtx4938.h> |
34 | 35 | ||
35 | /**********************************************************************************/ | 36 | /**********************************************************************************/ |
diff --git a/arch/mips/tx4938/common/setup.c b/arch/mips/tx4938/common/setup.c index 71859c4fee84..f415a1f18fba 100644 --- a/arch/mips/tx4938/common/setup.c +++ b/arch/mips/tx4938/common/setup.c | |||
@@ -41,29 +41,10 @@ void __init tx4938_setup(void); | |||
41 | void __init tx4938_time_init(void); | 41 | void __init tx4938_time_init(void); |
42 | void dump_cp0(char *key); | 42 | void dump_cp0(char *key); |
43 | 43 | ||
44 | void (*__wbflush) (void); | ||
45 | |||
46 | static void | ||
47 | tx4938_write_buffer_flush(void) | ||
48 | { | ||
49 | mmiowb(); | ||
50 | |||
51 | __asm__ __volatile__( | ||
52 | ".set push\n\t" | ||
53 | ".set noreorder\n\t" | ||
54 | "lw $0,%0\n\t" | ||
55 | "nop\n\t" | ||
56 | ".set pop" | ||
57 | : /* no output */ | ||
58 | : "m" (*(int *)KSEG1) | ||
59 | : "memory"); | ||
60 | } | ||
61 | |||
62 | void __init | 44 | void __init |
63 | plat_mem_setup(void) | 45 | plat_mem_setup(void) |
64 | { | 46 | { |
65 | board_time_init = tx4938_time_init; | 47 | board_time_init = tx4938_time_init; |
66 | __wbflush = tx4938_write_buffer_flush; | ||
67 | toshiba_rbtx4938_setup(); | 48 | toshiba_rbtx4938_setup(); |
68 | } | 49 | } |
69 | 50 | ||
diff --git a/arch/mips/tx4938/toshiba_rbtx4938/irq.c b/arch/mips/tx4938/toshiba_rbtx4938/irq.c index bbb3390e98f7..102e473c10a2 100644 --- a/arch/mips/tx4938/toshiba_rbtx4938/irq.c +++ b/arch/mips/tx4938/toshiba_rbtx4938/irq.c | |||
@@ -83,6 +83,7 @@ IRQ Device | |||
83 | #include <asm/processor.h> | 83 | #include <asm/processor.h> |
84 | #include <asm/reboot.h> | 84 | #include <asm/reboot.h> |
85 | #include <asm/time.h> | 85 | #include <asm/time.h> |
86 | #include <asm/wbflush.h> | ||
86 | #include <linux/bootmem.h> | 87 | #include <linux/bootmem.h> |
87 | #include <asm/tx4938/rbtx4938.h> | 88 | #include <asm/tx4938/rbtx4938.h> |
88 | 89 | ||
diff --git a/arch/powerpc/platforms/82xx/mpc82xx.c b/arch/powerpc/platforms/82xx/mpc82xx.c index 89d702de4863..0f5b30dc60da 100644 --- a/arch/powerpc/platforms/82xx/mpc82xx.c +++ b/arch/powerpc/platforms/82xx/mpc82xx.c | |||
@@ -11,7 +11,6 @@ | |||
11 | * option) any later version. | 11 | * option) any later version. |
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include <linux/config.h> | ||
15 | #include <linux/stddef.h> | 14 | #include <linux/stddef.h> |
16 | #include <linux/kernel.h> | 15 | #include <linux/kernel.h> |
17 | #include <linux/init.h> | 16 | #include <linux/init.h> |
diff --git a/arch/powerpc/platforms/82xx/mpc82xx_ads.c b/arch/powerpc/platforms/82xx/mpc82xx_ads.c index 0cea42a8053d..bb9acbb98176 100644 --- a/arch/powerpc/platforms/82xx/mpc82xx_ads.c +++ b/arch/powerpc/platforms/82xx/mpc82xx_ads.c | |||
@@ -12,8 +12,6 @@ | |||
12 | * option) any later version. | 12 | * option) any later version. |
13 | */ | 13 | */ |
14 | 14 | ||
15 | |||
16 | #include <linux/config.h> | ||
17 | #include <linux/stddef.h> | 15 | #include <linux/stddef.h> |
18 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
19 | #include <linux/init.h> | 17 | #include <linux/init.h> |
diff --git a/arch/powerpc/platforms/82xx/pq2ads.h b/arch/powerpc/platforms/82xx/pq2ads.h index a7348213508f..fb2f92bcd770 100644 --- a/arch/powerpc/platforms/82xx/pq2ads.h +++ b/arch/powerpc/platforms/82xx/pq2ads.h | |||
@@ -22,8 +22,6 @@ | |||
22 | #ifndef __MACH_ADS8260_DEFS | 22 | #ifndef __MACH_ADS8260_DEFS |
23 | #define __MACH_ADS8260_DEFS | 23 | #define __MACH_ADS8260_DEFS |
24 | 24 | ||
25 | #include <linux/config.h> | ||
26 | |||
27 | #include <asm/ppcboot.h> | 25 | #include <asm/ppcboot.h> |
28 | 26 | ||
29 | /* For our show_cpuinfo hooks. */ | 27 | /* For our show_cpuinfo hooks. */ |
diff --git a/arch/powerpc/sysdev/qe_lib/qe_io.c b/arch/powerpc/sysdev/qe_lib/qe_io.c index aea435970389..0afe6bfe3714 100644 --- a/arch/powerpc/sysdev/qe_lib/qe_io.c +++ b/arch/powerpc/sysdev/qe_lib/qe_io.c | |||
@@ -14,7 +14,6 @@ | |||
14 | * option) any later version. | 14 | * option) any later version. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/config.h> | ||
18 | #include <linux/stddef.h> | 17 | #include <linux/stddef.h> |
19 | #include <linux/kernel.h> | 18 | #include <linux/kernel.h> |
20 | #include <linux/init.h> | 19 | #include <linux/init.h> |
diff --git a/drivers/char/qtronix.c b/drivers/char/qtronix.c deleted file mode 100644 index 5c9477741a30..000000000000 --- a/drivers/char/qtronix.c +++ /dev/null | |||
@@ -1,605 +0,0 @@ | |||
1 | /* | ||
2 | * | ||
3 | * BRIEF MODULE DESCRIPTION | ||
4 | * Qtronix 990P infrared keyboard driver. | ||
5 | * | ||
6 | * | ||
7 | * Copyright 2001 MontaVista Software Inc. | ||
8 | * Author: MontaVista Software, Inc. | ||
9 | * ppopov@mvista.com or source@mvista.com | ||
10 | * | ||
11 | * | ||
12 | * The bottom portion of this driver was take from | ||
13 | * pc_keyb.c Please see that file for copyrights. | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or modify it | ||
16 | * under the terms of the GNU General Public License as published by the | ||
17 | * Free Software Foundation; either version 2 of the License, or (at your | ||
18 | * option) any later version. | ||
19 | * | ||
20 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
21 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
22 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
23 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
26 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
27 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
30 | * | ||
31 | * You should have received a copy of the GNU General Public License along | ||
32 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
33 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
34 | */ | ||
35 | |||
36 | |||
37 | /* | ||
38 | * NOTE: | ||
39 | * | ||
40 | * This driver has only been tested with the Consumer IR | ||
41 | * port of the ITE 8172 system controller. | ||
42 | * | ||
43 | * You do not need this driver if you are using the ps/2 or | ||
44 | * USB adapter that the keyboard ships with. You only need | ||
45 | * this driver if your board has a IR port and the keyboard | ||
46 | * data is being sent directly to the IR. In that case, | ||
47 | * you also need some low-level IR support. See it8172_cir.c. | ||
48 | * | ||
49 | */ | ||
50 | |||
51 | #ifdef CONFIG_QTRONIX_KEYBOARD | ||
52 | |||
53 | #include <linux/module.h> | ||
54 | #include <linux/types.h> | ||
55 | #include <linux/pci.h> | ||
56 | #include <linux/kernel.h> | ||
57 | |||
58 | #include <asm/it8172/it8172.h> | ||
59 | #include <asm/it8172/it8172_int.h> | ||
60 | #include <asm/it8172/it8172_cir.h> | ||
61 | |||
62 | #include <linux/spinlock.h> | ||
63 | #include <linux/sched.h> | ||
64 | #include <linux/interrupt.h> | ||
65 | #include <linux/tty.h> | ||
66 | #include <linux/mm.h> | ||
67 | #include <linux/signal.h> | ||
68 | #include <linux/init.h> | ||
69 | #include <linux/kbd_ll.h> | ||
70 | #include <linux/delay.h> | ||
71 | #include <linux/poll.h> | ||
72 | #include <linux/miscdevice.h> | ||
73 | #include <linux/slab.h> | ||
74 | #include <linux/kbd_kern.h> | ||
75 | #include <linux/smp_lock.h> | ||
76 | #include <asm/io.h> | ||
77 | #include <linux/pc_keyb.h> | ||
78 | |||
79 | #include <asm/keyboard.h> | ||
80 | #include <linux/bitops.h> | ||
81 | #include <asm/uaccess.h> | ||
82 | #include <asm/irq.h> | ||
83 | #include <asm/system.h> | ||
84 | |||
85 | #define leading1 0 | ||
86 | #define leading2 0xF | ||
87 | |||
88 | #define KBD_CIR_PORT 0 | ||
89 | #define AUX_RECONNECT 170 /* scancode when ps2 device is plugged (back) in */ | ||
90 | |||
91 | static int data_index; | ||
92 | struct cir_port *cir; | ||
93 | static unsigned char kbdbytes[5]; | ||
94 | static unsigned char cir_data[32]; /* we only need 16 chars */ | ||
95 | |||
96 | static void kbd_int_handler(int irq, void *dev_id); | ||
97 | static int handle_data(unsigned char *p_data); | ||
98 | static inline void handle_mouse_event(unsigned char scancode); | ||
99 | static inline void handle_keyboard_event(unsigned char scancode, int down); | ||
100 | static int __init psaux_init(void); | ||
101 | |||
102 | static struct aux_queue *queue; /* Mouse data buffer. */ | ||
103 | static int aux_count = 0; | ||
104 | |||
105 | /* | ||
106 | * Keys accessed through the 'Fn' key | ||
107 | * The Fn key does not produce a key-up sequence. So, the first | ||
108 | * time the user presses it, it will be key-down event. The key | ||
109 | * stays down until the user presses it again. | ||
110 | */ | ||
111 | #define NUM_FN_KEYS 56 | ||
112 | static unsigned char fn_keys[NUM_FN_KEYS] = { | ||
113 | 0,0,0,0,0,0,0,0, /* 0 7 */ | ||
114 | 8,9,10,93,0,0,0,0, /* 8 15 */ | ||
115 | 0,0,0,0,0,0,0,5, /* 16 23 */ | ||
116 | 6,7,91,0,0,0,0,0, /* 24 31 */ | ||
117 | 0,0,0,0,0,2,3,4, /* 32 39 */ | ||
118 | 92,0,0,0,0,0,0,0, /* 40 47 */ | ||
119 | 0,0,0,0,11,0,94,95 /* 48 55 */ | ||
120 | |||
121 | }; | ||
122 | |||
123 | void __init init_qtronix_990P_kbd(void) | ||
124 | { | ||
125 | int retval; | ||
126 | |||
127 | cir = (struct cir_port *)kmalloc(sizeof(struct cir_port), GFP_KERNEL); | ||
128 | if (!cir) { | ||
129 | printk("Unable to initialize Qtronix keyboard\n"); | ||
130 | return; | ||
131 | } | ||
132 | |||
133 | /* | ||
134 | * revisit | ||
135 | * this should be programmable, somehow by the, by the user. | ||
136 | */ | ||
137 | cir->port = KBD_CIR_PORT; | ||
138 | cir->baud_rate = 0x1d; | ||
139 | cir->rdwos = 0; | ||
140 | cir->rxdcr = 0x3; | ||
141 | cir->hcfs = 0; | ||
142 | cir->fifo_tl = 0; | ||
143 | cir->cfq = 0x1d; | ||
144 | cir_port_init(cir); | ||
145 | |||
146 | retval = request_irq(IT8172_CIR0_IRQ, kbd_int_handler, | ||
147 | (unsigned long )(IRQF_DISABLED|IRQF_SHARED), | ||
148 | (const char *)"Qtronix IR Keyboard", (void *)cir); | ||
149 | |||
150 | if (retval) { | ||
151 | printk("unable to allocate cir %d irq %d\n", | ||
152 | cir->port, IT8172_CIR0_IRQ); | ||
153 | } | ||
154 | #ifdef CONFIG_PSMOUSE | ||
155 | psaux_init(); | ||
156 | #endif | ||
157 | } | ||
158 | |||
159 | static inline unsigned char BitReverse(unsigned short key) | ||
160 | { | ||
161 | unsigned char rkey = 0; | ||
162 | rkey |= (key & 0x1) << 7; | ||
163 | rkey |= (key & 0x2) << 5; | ||
164 | rkey |= (key & 0x4) << 3; | ||
165 | rkey |= (key & 0x8) << 1; | ||
166 | rkey |= (key & 0x10) >> 1; | ||
167 | rkey |= (key & 0x20) >> 3; | ||
168 | rkey |= (key & 0x40) >> 5; | ||
169 | rkey |= (key & 0x80) >> 7; | ||
170 | return rkey; | ||
171 | |||
172 | } | ||
173 | |||
174 | |||
175 | static inline u_int8_t UpperByte(u_int8_t data) | ||
176 | { | ||
177 | return (data >> 4); | ||
178 | } | ||
179 | |||
180 | |||
181 | static inline u_int8_t LowerByte(u_int8_t data) | ||
182 | { | ||
183 | return (data & 0xF); | ||
184 | } | ||
185 | |||
186 | |||
187 | int CheckSumOk(u_int8_t byte1, u_int8_t byte2, | ||
188 | u_int8_t byte3, u_int8_t byte4, u_int8_t byte5) | ||
189 | { | ||
190 | u_int8_t CheckSum; | ||
191 | |||
192 | CheckSum = (byte1 & 0x0F) + byte2 + byte3 + byte4 + byte5; | ||
193 | if ( LowerByte(UpperByte(CheckSum) + LowerByte(CheckSum)) != UpperByte(byte1) ) | ||
194 | return 0; | ||
195 | else | ||
196 | return 1; | ||
197 | } | ||
198 | |||
199 | |||
200 | static void kbd_int_handler(int irq, void *dev_id) | ||
201 | { | ||
202 | struct cir_port *cir; | ||
203 | int j; | ||
204 | unsigned char int_status; | ||
205 | |||
206 | cir = (struct cir_port *)dev_id; | ||
207 | int_status = get_int_status(cir); | ||
208 | if (int_status & 0x4) { | ||
209 | clear_fifo(cir); | ||
210 | return; | ||
211 | } | ||
212 | |||
213 | while (cir_get_rx_count(cir)) { | ||
214 | |||
215 | cir_data[data_index] = cir_read_data(cir); | ||
216 | |||
217 | if (data_index == 0) {/* expecting first byte */ | ||
218 | if (cir_data[data_index] != leading1) { | ||
219 | //printk("!leading byte %x\n", cir_data[data_index]); | ||
220 | set_rx_active(cir); | ||
221 | clear_fifo(cir); | ||
222 | continue; | ||
223 | } | ||
224 | } | ||
225 | if (data_index == 1) { | ||
226 | if ((cir_data[data_index] & 0xf) != leading2) { | ||
227 | set_rx_active(cir); | ||
228 | data_index = 0; /* start over */ | ||
229 | clear_fifo(cir); | ||
230 | continue; | ||
231 | } | ||
232 | } | ||
233 | |||
234 | if ( (cir_data[data_index] == 0xff)) { /* last byte */ | ||
235 | //printk("data_index %d\n", data_index); | ||
236 | set_rx_active(cir); | ||
237 | #if 0 | ||
238 | for (j=0; j<=data_index; j++) { | ||
239 | printk("rx_data %d: %x\n", j, cir_data[j]); | ||
240 | } | ||
241 | #endif | ||
242 | data_index = 0; | ||
243 | handle_data(cir_data); | ||
244 | return; | ||
245 | } | ||
246 | else if (data_index>16) { | ||
247 | set_rx_active(cir); | ||
248 | #if 0 | ||
249 | printk("warning: data_index %d\n", data_index); | ||
250 | for (j=0; j<=data_index; j++) { | ||
251 | printk("rx_data %d: %x\n", j, cir_data[j]); | ||
252 | } | ||
253 | #endif | ||
254 | data_index = 0; | ||
255 | clear_fifo(cir); | ||
256 | return; | ||
257 | } | ||
258 | data_index++; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | |||
263 | #define NUM_KBD_BYTES 5 | ||
264 | static int handle_data(unsigned char *p_data) | ||
265 | { | ||
266 | u_int32_t bit_bucket; | ||
267 | u_int32_t i, j; | ||
268 | u_int32_t got_bits, next_byte; | ||
269 | int down = 0; | ||
270 | |||
271 | /* Reorganize the bit stream */ | ||
272 | for (i=0; i<16; i++) | ||
273 | p_data[i] = BitReverse(~p_data[i]); | ||
274 | |||
275 | /* | ||
276 | * We've already previously checked that p_data[0] | ||
277 | * is equal to leading1 and that (p_data[1] & 0xf) | ||
278 | * is equal to leading2. These twelve bits are the | ||
279 | * leader code. We can now throw them away (the 12 | ||
280 | * bits) and continue parsing the stream. | ||
281 | */ | ||
282 | bit_bucket = p_data[1] << 12; | ||
283 | got_bits = 4; | ||
284 | next_byte = 2; | ||
285 | |||
286 | /* | ||
287 | * Process four bits at a time | ||
288 | */ | ||
289 | for (i=0; i<NUM_KBD_BYTES; i++) { | ||
290 | |||
291 | kbdbytes[i]=0; | ||
292 | |||
293 | for (j=0; j<8; j++) /* 8 bits per byte */ | ||
294 | { | ||
295 | if (got_bits < 4) { | ||
296 | bit_bucket |= (p_data[next_byte++] << (8 - got_bits)); | ||
297 | got_bits += 8; | ||
298 | } | ||
299 | |||
300 | if ((bit_bucket & 0xF000) == 0x8000) { | ||
301 | /* Convert 1000b to 1 */ | ||
302 | kbdbytes[i] = 0x80 | (kbdbytes[i] >> 1); | ||
303 | got_bits -= 4; | ||
304 | bit_bucket = bit_bucket << 4; | ||
305 | } | ||
306 | else if ((bit_bucket & 0xC000) == 0x8000) { | ||
307 | /* Convert 10b to 0 */ | ||
308 | kbdbytes[i] = kbdbytes[i] >> 1; | ||
309 | got_bits -= 2; | ||
310 | bit_bucket = bit_bucket << 2; | ||
311 | } | ||
312 | else { | ||
313 | /* bad serial stream */ | ||
314 | return 1; | ||
315 | } | ||
316 | |||
317 | if (next_byte > 16) { | ||
318 | //printk("error: too many bytes\n"); | ||
319 | return 1; | ||
320 | } | ||
321 | } | ||
322 | } | ||
323 | |||
324 | |||
325 | if (!CheckSumOk(kbdbytes[0], kbdbytes[1], | ||
326 | kbdbytes[2], kbdbytes[3], kbdbytes[4])) { | ||
327 | //printk("checksum failed\n"); | ||
328 | return 1; | ||
329 | } | ||
330 | |||
331 | if (kbdbytes[1] & 0x08) { | ||
332 | //printk("m: %x %x %x\n", kbdbytes[1], kbdbytes[2], kbdbytes[3]); | ||
333 | handle_mouse_event(kbdbytes[1]); | ||
334 | handle_mouse_event(kbdbytes[2]); | ||
335 | handle_mouse_event(kbdbytes[3]); | ||
336 | } | ||
337 | else { | ||
338 | if (kbdbytes[2] == 0) down = 1; | ||
339 | #if 0 | ||
340 | if (down) | ||
341 | printk("down %d\n", kbdbytes[3]); | ||
342 | else | ||
343 | printk("up %d\n", kbdbytes[3]); | ||
344 | #endif | ||
345 | handle_keyboard_event(kbdbytes[3], down); | ||
346 | } | ||
347 | return 0; | ||
348 | } | ||
349 | |||
350 | |||
351 | DEFINE_SPINLOCK(kbd_controller_lock); | ||
352 | static unsigned char handle_kbd_event(void); | ||
353 | |||
354 | |||
355 | int kbd_setkeycode(unsigned int scancode, unsigned int keycode) | ||
356 | { | ||
357 | printk("kbd_setkeycode scancode %x keycode %x\n", scancode, keycode); | ||
358 | return 0; | ||
359 | } | ||
360 | |||
361 | int kbd_getkeycode(unsigned int scancode) | ||
362 | { | ||
363 | return scancode; | ||
364 | } | ||
365 | |||
366 | |||
367 | int kbd_translate(unsigned char scancode, unsigned char *keycode, | ||
368 | char raw_mode) | ||
369 | { | ||
370 | static int prev_scancode = 0; | ||
371 | |||
372 | if (scancode == 0x00 || scancode == 0xff) { | ||
373 | prev_scancode = 0; | ||
374 | return 0; | ||
375 | } | ||
376 | |||
377 | /* todo */ | ||
378 | if (!prev_scancode && scancode == 160) { /* Fn key down */ | ||
379 | //printk("Fn key down\n"); | ||
380 | prev_scancode = 160; | ||
381 | return 0; | ||
382 | } | ||
383 | else if (prev_scancode && scancode == 160) { /* Fn key up */ | ||
384 | //printk("Fn key up\n"); | ||
385 | prev_scancode = 0; | ||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | /* todo */ | ||
390 | if (prev_scancode == 160) { | ||
391 | if (scancode <= NUM_FN_KEYS) { | ||
392 | *keycode = fn_keys[scancode]; | ||
393 | //printk("fn keycode %d\n", *keycode); | ||
394 | } | ||
395 | else | ||
396 | return 0; | ||
397 | } | ||
398 | else if (scancode <= 127) { | ||
399 | *keycode = scancode; | ||
400 | } | ||
401 | else | ||
402 | return 0; | ||
403 | |||
404 | |||
405 | return 1; | ||
406 | } | ||
407 | |||
408 | char kbd_unexpected_up(unsigned char keycode) | ||
409 | { | ||
410 | //printk("kbd_unexpected_up\n"); | ||
411 | return 0; | ||
412 | } | ||
413 | |||
414 | static unsigned char kbd_exists = 1; | ||
415 | |||
416 | static inline void handle_keyboard_event(unsigned char scancode, int down) | ||
417 | { | ||
418 | kbd_exists = 1; | ||
419 | handle_scancode(scancode, down); | ||
420 | tasklet_schedule(&keyboard_tasklet); | ||
421 | } | ||
422 | |||
423 | |||
424 | void kbd_leds(unsigned char leds) | ||
425 | { | ||
426 | } | ||
427 | |||
428 | /* dummy */ | ||
429 | void kbd_init_hw(void) | ||
430 | { | ||
431 | } | ||
432 | |||
433 | |||
434 | |||
435 | static inline void handle_mouse_event(unsigned char scancode) | ||
436 | { | ||
437 | if(scancode == AUX_RECONNECT){ | ||
438 | queue->head = queue->tail = 0; /* Flush input queue */ | ||
439 | // __aux_write_ack(AUX_ENABLE_DEV); /* ping the mouse :) */ | ||
440 | return; | ||
441 | } | ||
442 | |||
443 | if (aux_count) { | ||
444 | int head = queue->head; | ||
445 | |||
446 | queue->buf[head] = scancode; | ||
447 | head = (head + 1) & (AUX_BUF_SIZE-1); | ||
448 | if (head != queue->tail) { | ||
449 | queue->head = head; | ||
450 | kill_fasync(&queue->fasync, SIGIO, POLL_IN); | ||
451 | wake_up_interruptible(&queue->proc_list); | ||
452 | } | ||
453 | } | ||
454 | } | ||
455 | |||
456 | static unsigned char get_from_queue(void) | ||
457 | { | ||
458 | unsigned char result; | ||
459 | unsigned long flags; | ||
460 | |||
461 | spin_lock_irqsave(&kbd_controller_lock, flags); | ||
462 | result = queue->buf[queue->tail]; | ||
463 | queue->tail = (queue->tail + 1) & (AUX_BUF_SIZE-1); | ||
464 | spin_unlock_irqrestore(&kbd_controller_lock, flags); | ||
465 | return result; | ||
466 | } | ||
467 | |||
468 | |||
469 | static inline int queue_empty(void) | ||
470 | { | ||
471 | return queue->head == queue->tail; | ||
472 | } | ||
473 | |||
474 | static int fasync_aux(int fd, struct file *filp, int on) | ||
475 | { | ||
476 | int retval; | ||
477 | |||
478 | //printk("fasync_aux\n"); | ||
479 | retval = fasync_helper(fd, filp, on, &queue->fasync); | ||
480 | if (retval < 0) | ||
481 | return retval; | ||
482 | return 0; | ||
483 | } | ||
484 | |||
485 | |||
486 | /* | ||
487 | * Random magic cookie for the aux device | ||
488 | */ | ||
489 | #define AUX_DEV ((void *)queue) | ||
490 | |||
491 | static int release_aux(struct inode * inode, struct file * file) | ||
492 | { | ||
493 | fasync_aux(-1, file, 0); | ||
494 | aux_count--; | ||
495 | return 0; | ||
496 | } | ||
497 | |||
498 | static int open_aux(struct inode * inode, struct file * file) | ||
499 | { | ||
500 | if (aux_count++) { | ||
501 | return 0; | ||
502 | } | ||
503 | queue->head = queue->tail = 0; /* Flush input queue */ | ||
504 | return 0; | ||
505 | } | ||
506 | |||
507 | /* | ||
508 | * Put bytes from input queue to buffer. | ||
509 | */ | ||
510 | |||
511 | static ssize_t read_aux(struct file * file, char * buffer, | ||
512 | size_t count, loff_t *ppos) | ||
513 | { | ||
514 | DECLARE_WAITQUEUE(wait, current); | ||
515 | ssize_t i = count; | ||
516 | unsigned char c; | ||
517 | |||
518 | if (queue_empty()) { | ||
519 | if (file->f_flags & O_NONBLOCK) | ||
520 | return -EAGAIN; | ||
521 | add_wait_queue(&queue->proc_list, &wait); | ||
522 | repeat: | ||
523 | set_current_state(TASK_INTERRUPTIBLE); | ||
524 | if (queue_empty() && !signal_pending(current)) { | ||
525 | schedule(); | ||
526 | goto repeat; | ||
527 | } | ||
528 | current->state = TASK_RUNNING; | ||
529 | remove_wait_queue(&queue->proc_list, &wait); | ||
530 | } | ||
531 | while (i > 0 && !queue_empty()) { | ||
532 | c = get_from_queue(); | ||
533 | put_user(c, buffer++); | ||
534 | i--; | ||
535 | } | ||
536 | if (count-i) { | ||
537 | struct inode *inode = file->f_dentry->d_inode; | ||
538 | inode->i_atime = current_fs_time(inode->i_sb); | ||
539 | return count-i; | ||
540 | } | ||
541 | if (signal_pending(current)) | ||
542 | return -ERESTARTSYS; | ||
543 | return 0; | ||
544 | } | ||
545 | |||
546 | /* | ||
547 | * Write to the aux device. | ||
548 | */ | ||
549 | |||
550 | static ssize_t write_aux(struct file * file, const char * buffer, | ||
551 | size_t count, loff_t *ppos) | ||
552 | { | ||
553 | /* | ||
554 | * The ITE boards this was tested on did not have the | ||
555 | * transmit wires connected. | ||
556 | */ | ||
557 | return count; | ||
558 | } | ||
559 | |||
560 | static unsigned int aux_poll(struct file *file, poll_table * wait) | ||
561 | { | ||
562 | poll_wait(file, &queue->proc_list, wait); | ||
563 | if (!queue_empty()) | ||
564 | return POLLIN | POLLRDNORM; | ||
565 | return 0; | ||
566 | } | ||
567 | |||
568 | struct file_operations psaux_fops = { | ||
569 | .read = read_aux, | ||
570 | .write = write_aux, | ||
571 | .poll = aux_poll, | ||
572 | .open = open_aux, | ||
573 | .release = release_aux, | ||
574 | .fasync = fasync_aux, | ||
575 | }; | ||
576 | |||
577 | /* | ||
578 | * Initialize driver. | ||
579 | */ | ||
580 | static struct miscdevice psaux_mouse = { | ||
581 | PSMOUSE_MINOR, "psaux", &psaux_fops | ||
582 | }; | ||
583 | |||
584 | static int __init psaux_init(void) | ||
585 | { | ||
586 | int retval; | ||
587 | |||
588 | retval = misc_register(&psaux_mouse); | ||
589 | if(retval < 0) | ||
590 | return retval; | ||
591 | |||
592 | queue = (struct aux_queue *) kmalloc(sizeof(*queue), GFP_KERNEL); | ||
593 | if (!queue) { | ||
594 | misc_deregister(&psaux_mouse); | ||
595 | return -ENOMEM; | ||
596 | } | ||
597 | |||
598 | memset(queue, 0, sizeof(*queue)); | ||
599 | queue->head = queue->tail = 0; | ||
600 | init_waitqueue_head(&queue->proc_list); | ||
601 | |||
602 | return 0; | ||
603 | } | ||
604 | module_init(init_qtronix_990P_kbd); | ||
605 | #endif | ||
diff --git a/drivers/char/rtc.c b/drivers/char/rtc.c index abee7a339462..66a7385bc34a 100644 --- a/drivers/char/rtc.c +++ b/drivers/char/rtc.c | |||
@@ -35,13 +35,13 @@ | |||
35 | * 1.09a Pete Zaitcev: Sun SPARC | 35 | * 1.09a Pete Zaitcev: Sun SPARC |
36 | * 1.09b Jeff Garzik: Modularize, init cleanup | 36 | * 1.09b Jeff Garzik: Modularize, init cleanup |
37 | * 1.09c Jeff Garzik: SMP cleanup | 37 | * 1.09c Jeff Garzik: SMP cleanup |
38 | * 1.10 Paul Barton-Davis: add support for async I/O | 38 | * 1.10 Paul Barton-Davis: add support for async I/O |
39 | * 1.10a Andrea Arcangeli: Alpha updates | 39 | * 1.10a Andrea Arcangeli: Alpha updates |
40 | * 1.10b Andrew Morton: SMP lock fix | 40 | * 1.10b Andrew Morton: SMP lock fix |
41 | * 1.10c Cesar Barros: SMP locking fixes and cleanup | 41 | * 1.10c Cesar Barros: SMP locking fixes and cleanup |
42 | * 1.10d Paul Gortmaker: delete paranoia check in rtc_exit | 42 | * 1.10d Paul Gortmaker: delete paranoia check in rtc_exit |
43 | * 1.10e Maciej W. Rozycki: Handle DECstation's year weirdness. | 43 | * 1.10e Maciej W. Rozycki: Handle DECstation's year weirdness. |
44 | * 1.11 Takashi Iwai: Kernel access functions | 44 | * 1.11 Takashi Iwai: Kernel access functions |
45 | * rtc_register/rtc_unregister/rtc_control | 45 | * rtc_register/rtc_unregister/rtc_control |
46 | * 1.11a Daniele Bellucci: Audit create_proc_read_entry in rtc_init | 46 | * 1.11a Daniele Bellucci: Audit create_proc_read_entry in rtc_init |
47 | * 1.12 Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer | 47 | * 1.12 Venkatesh Pallipadi: Hooks for emulating rtc on HPET base-timer |
diff --git a/include/asm-mips/fpu.h b/include/asm-mips/fpu.h index 58c561a9ec6b..efef843b93f0 100644 --- a/include/asm-mips/fpu.h +++ b/include/asm-mips/fpu.h | |||
@@ -134,9 +134,11 @@ static inline void restore_fp(struct task_struct *tsk) | |||
134 | 134 | ||
135 | static inline fpureg_t *get_fpu_regs(struct task_struct *tsk) | 135 | static inline fpureg_t *get_fpu_regs(struct task_struct *tsk) |
136 | { | 136 | { |
137 | if (cpu_has_fpu) { | 137 | if (tsk == current) { |
138 | if ((tsk == current) && __is_fpu_owner()) | 138 | preempt_disable(); |
139 | if (is_fpu_owner()) | ||
139 | _save_fp(current); | 140 | _save_fp(current); |
141 | preempt_enable(); | ||
140 | } | 142 | } |
141 | 143 | ||
142 | return tsk->thread.fpu.fpr; | 144 | return tsk->thread.fpu.fpr; |
diff --git a/include/asm-mips/mach-au1x00/au1000_usbdev.h b/include/asm-mips/mach-au1x00/au1000_usbdev.h deleted file mode 100644 index 05bc74bed0b1..000000000000 --- a/include/asm-mips/mach-au1x00/au1000_usbdev.h +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
1 | /* | ||
2 | * BRIEF MODULE DESCRIPTION | ||
3 | * Au1000 USB Device-Side Driver | ||
4 | * | ||
5 | * Copyright 2001 MontaVista Software Inc. | ||
6 | * Author: MontaVista Software, Inc. | ||
7 | * stevel@mvista.com or source@mvista.com | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License as published by the | ||
11 | * Free Software Foundation; either version 2 of the License, or (at your | ||
12 | * option) any later version. | ||
13 | * | ||
14 | * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED | ||
15 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | ||
16 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN | ||
17 | * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | ||
20 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
21 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||
23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
24 | * | ||
25 | * You should have received a copy of the GNU General Public License along | ||
26 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
27 | * 675 Mass Ave, Cambridge, MA 02139, USA. | ||
28 | */ | ||
29 | |||
30 | #define USBDEV_REV 0x0110 // BCD | ||
31 | #define USBDEV_EP0_MAX_PACKET_SIZE 64 | ||
32 | |||
33 | typedef enum { | ||
34 | ATTACHED = 0, | ||
35 | POWERED, | ||
36 | DEFAULT, | ||
37 | ADDRESS, | ||
38 | CONFIGURED | ||
39 | } usbdev_state_t; | ||
40 | |||
41 | typedef enum { | ||
42 | CB_NEW_STATE = 0, | ||
43 | CB_PKT_COMPLETE | ||
44 | } usbdev_cb_type_t; | ||
45 | |||
46 | |||
47 | typedef struct usbdev_pkt { | ||
48 | int ep_addr; // ep addr this packet routed to | ||
49 | int size; // size of payload in bytes | ||
50 | unsigned status; // packet status | ||
51 | struct usbdev_pkt* next; // function layer can't touch this | ||
52 | u8 payload[0]; // the payload | ||
53 | } usbdev_pkt_t; | ||
54 | |||
55 | #define PKT_STATUS_ACK (1<<0) | ||
56 | #define PKT_STATUS_NAK (1<<1) | ||
57 | #define PKT_STATUS_SU (1<<2) | ||
58 | |||
59 | extern int usbdev_init(struct usb_device_descriptor* dev_desc, | ||
60 | struct usb_config_descriptor* config_desc, | ||
61 | struct usb_interface_descriptor* if_desc, | ||
62 | struct usb_endpoint_descriptor* ep_desc, | ||
63 | struct usb_string_descriptor* str_desc[], | ||
64 | void (*cb)(usbdev_cb_type_t, unsigned long, void *), | ||
65 | void* cb_data); | ||
66 | |||
67 | extern void usbdev_exit(void); | ||
68 | |||
69 | extern int usbdev_alloc_packet (int ep_addr, int data_size, | ||
70 | usbdev_pkt_t** pkt); | ||
71 | extern int usbdev_send_packet (int ep_addr, usbdev_pkt_t* pkt); | ||
72 | extern int usbdev_receive_packet(int ep_addr, usbdev_pkt_t** pkt); | ||
73 | extern int usbdev_get_byte_count(int ep_addr); | ||
diff --git a/include/linux/config.h b/include/linux/config.h deleted file mode 100644 index 479ffb0a22d8..000000000000 --- a/include/linux/config.h +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | #ifndef _LINUX_CONFIG_H | ||
2 | #define _LINUX_CONFIG_H | ||
3 | /* This file is no longer in use and kept only for backward compatibility. | ||
4 | * autoconf.h is now included via -imacros on the commandline | ||
5 | */ | ||
6 | #warning Including config.h is deprecated. | ||
7 | #include <linux/autoconf.h> | ||
8 | |||
9 | #endif | ||