/****************************************************************** * Copyright 2005 Mentor Graphics Corporation * Copyright (C) 2005-2006 by Texas Instruments * * This file is part of the Inventra Controller Driver for Linux. * * The Inventra Controller Driver for Linux is free software; you * can redistribute it and/or modify it under the terms of the GNU * General Public License version 2 as published by the Free Software * Foundation. * * The Inventra Controller Driver for Linux is distributed in * the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * You should have received a copy of the GNU General Public License * along with The Inventra Controller Driver for Linux ; if not, * write to the Free Software Foundation, Inc., 59 Temple Place, * Suite 330, Boston, MA 02111-1307 USA * * ANY DOWNLOAD, USE, REPRODUCTION, MODIFICATION OR DISTRIBUTION * OF THIS DRIVER INDICATES YOUR COMPLETE AND UNCONDITIONAL ACCEPTANCE * OF THOSE TERMS.THIS DRIVER IS PROVIDED "AS IS" AND MENTOR GRAPHICS * MAKES NO WARRANTIES, EXPRESS OR IMPLIED, RELATED TO THIS DRIVER. * MENTOR GRAPHICS SPECIFICALLY DISCLAIMS ALL IMPLIED WARRANTIES * OF MERCHANTABILITY; FITNESS FOR A PARTICULAR PURPOSE AND * NON-INFRINGEMENT. MENTOR GRAPHICS DOES NOT PROVIDE SUPPORT * SERVICES OR UPDATES FOR THIS DRIVER, EVEN IF YOU ARE A MENTOR * GRAPHICS SUPPORT CUSTOMER. ******************************************************************/ #ifndef __MUSB_GADGET_H #define __MUSB_GADGET_H struct musb_request { struct usb_request request; struct musb_ep *ep; struct musb *musb; u8 bTx; /* endpoint direction */ u8 bEnd; u8 mapped; }; static inline struct musb_request *to_musb_request(struct usb_request *req) { return req ? container_of(req, struct musb_request, request) : NULL; } extern struct usb_request * musb_alloc_request(struct usb_ep *ep, gfp_t gfp_flags); extern void musb_free_request(struct usb_ep *ep, struct usb_request *req); /* * struct musb_ep - peripheral side view of endpoint rx or tx side */ struct musb_ep { /* stuff towards the head is basically write-once. */ struct usb_ep end_point; char name[12]; struct musb_hw_ep *hw_ep; struct musb *pThis; u8 bEndNumber; /* ... when enabled/disabled ... */ u8 type; u8 is_in; u16 wPacketSize; const struct usb_endpoint_descriptor *desc; struct dma_channel *dma; /* later things are modified based on usage */ struct list_head req_list; /* true if lock must be dropped but req_list may not be advanced */ u8 busy; }; static inline struct musb_ep *to_musb_ep(struct usb_ep *ep) { return ep ? container_of(ep, struct musb_ep, end_point) : NULL; } static inline struct usb_request *next_request(struct musb_ep *ep) { struct list_head *queue = &ep->req_list; if (list_empty(queue)) return NULL; return container_of(queue->next, struct usb_request, list); } extern void musb_g_tx(struct musb *pThis, u8 bEnd); extern void musb_g_rx(struct musb *pThis, u8 bEnd); extern const struct usb_ep_ops musb_g_ep0_ops; extern int musb_gadget_setup(struct musb *); extern void musb_gadget_cleanup(struct musb *); extern void musb_g_giveback(struct musb_ep *, struct usb_request *, int); extern int musb_gadget_set_halt(struct usb_ep *ep, int value); #endif /* __MUSB_GADGET_H */