]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/usb/musb/musb_host.h
Merge omap-drivers
[linux-2.6-omap-h63xx.git] / drivers / usb / musb / musb_host.h
1 /******************************************************************
2  * Copyright 2005 Mentor Graphics Corporation
3  * Copyright (C) 2005-2006 by Texas Instruments
4  *
5  * This file is part of the Inventra Controller Driver for Linux.
6  *
7  * The Inventra Controller Driver for Linux is free software; you
8  * can redistribute it and/or modify it under the terms of the GNU
9  * General Public License version 2 as published by the Free Software
10  * Foundation.
11  *
12  * The Inventra Controller Driver for Linux is distributed in
13  * the hope that it will be useful, but WITHOUT ANY WARRANTY;
14  * without even the implied warranty of MERCHANTABILITY or
15  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
16  * License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with The Inventra Controller Driver for Linux ; if not,
20  * write to the Free Software Foundation, Inc., 59 Temple Place,
21  * Suite 330, Boston, MA  02111-1307  USA
22  *
23  * ANY DOWNLOAD, USE, REPRODUCTION, MODIFICATION OR DISTRIBUTION
24  * OF THIS DRIVER INDICATES YOUR COMPLETE AND UNCONDITIONAL ACCEPTANCE
25  * OF THOSE TERMS.THIS DRIVER IS PROVIDED "AS IS" AND MENTOR GRAPHICS
26  * MAKES NO WARRANTIES, EXPRESS OR IMPLIED, RELATED TO THIS DRIVER.
27  * MENTOR GRAPHICS SPECIFICALLY DISCLAIMS ALL IMPLIED WARRANTIES
28  * OF MERCHANTABILITY; FITNESS FOR A PARTICULAR PURPOSE AND
29  * NON-INFRINGEMENT.  MENTOR GRAPHICS DOES NOT PROVIDE SUPPORT
30  * SERVICES OR UPDATES FOR THIS DRIVER, EVEN IF YOU ARE A MENTOR
31  * GRAPHICS SUPPORT CUSTOMER.
32  ******************************************************************/
33
34 #ifndef _MUSB_HOST_H
35 #define _MUSB_HOST_H
36
37 static inline struct usb_hcd *musb_to_hcd(struct musb *musb)
38 {
39         return (struct usb_hcd *) (((void *)musb)
40                         - offsetof(struct usb_hcd, hcd_priv));
41 }
42
43 static inline struct musb *hcd_to_musb(struct usb_hcd *hcd)
44 {
45         return (void *) hcd->hcd_priv;
46 }
47
48 /* stored in "usb_host_endpoint.hcpriv" for scheduled endpoints
49  */
50 struct musb_qh {
51         struct usb_host_endpoint *hep;          /* usbcore info */
52         struct usb_device       *dev;
53         struct musb_hw_ep       *hw_ep;         /* current binding */
54
55         struct list_head        ring;           /* of musb_qh */
56         //struct musb_qh                *next;          /* for periodic tree */
57
58         unsigned                offset;         /* in urb->transfer_buffer */
59         unsigned                segsize;        /* current xfer fragment */
60
61         u8                      type_reg;       /* {rx,tx} type register */
62         u8                      intv_reg;       /* {rx,tx} interval register */
63         u8                      addr_reg;       /* device address register */
64         u8                      h_addr_reg;     /* hub address register */
65         u8                      h_port_reg;     /* hub port register */
66
67         u8                      is_ready;       /* safe to modify hw_ep */
68         u8                      type;           /* XFERTYPE_* */
69         u8                      epnum;
70         u16                     maxpacket;
71         u16                     frame;          /* for periodic schedule */
72         unsigned                iso_idx;        /* in urb->iso_frame_desc[] */
73 };
74
75 /* map from control or bulk queue head to the first qh on that ring */
76 static inline struct musb_qh *first_qh(struct list_head *q)
77 {
78         if (list_empty(q))
79                 return NULL;
80         return container_of(q->next, struct musb_qh, ring);
81 }
82
83
84 extern void musb_root_disconnect(struct musb *musb);
85
86 struct usb_hcd;
87
88 extern int musb_hub_status_data(struct usb_hcd *hcd, char *buf);
89 extern int musb_hub_control(struct usb_hcd *hcd,
90                         u16 typeReq, u16 wValue, u16 wIndex,
91                         char *buf, u16 wLength);
92
93 extern const struct hc_driver musb_hc_driver;
94
95 static inline struct urb *next_urb(struct musb_qh *qh)
96 {
97 #ifdef CONFIG_USB_MUSB_HDRC_HCD
98         struct list_head        *queue;
99
100         if (!qh)
101                 return NULL;
102         queue = &qh->hep->urb_list;
103         if (list_empty(queue))
104                 return NULL;
105         return container_of(queue->next, struct urb, urb_list);
106 #else
107         return NULL;
108 #endif
109 }
110
111 #endif                          /* _MUSB_HOST_H */