2 * drivers/usb/gadget/lpc32xx_udc.h
4 * Author: Kevin Wells <kevin.wells@nxp.com>
6 * Copyright (C) 2009 NXP Semiconductors
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27 * Although the driver supports DMA, it is not yet working completely. It
28 * seems to work ok for serial ACM, but eventually bonks out for MSC and
29 * ether classes. Disabling this define will use FIFO mode for all EPs
31 //#define UDC_ENABLE_DMA
34 * controller driver data structures
37 /* 16 endpoints (not to be confused with 32 hardware endpoints) */
38 #define NUM_ENDPOINTS 16
41 * IRQ indices make reading the code a little easier
45 #define IRQ_USB_DEVDMA 2
48 #define EP_OUT 0 /* RX (from host) */
49 #define EP_IN 1 /* TX (to host) */
51 /* Returns the interrupt mask for the selected hardware endpoint */
52 #define EP_MASK_SEL(ep, dir) (1 << (((ep) * 2) + dir))
60 #define WAIT_FOR_SETUP 0 /* Wait for setup packet */
61 #define DATA_IN 1 /* Expect dev->host transfer */
62 #define DATA_OUT 2 /* Expect host->dev transfer */
63 #define WAIT_OUT 3 /* ??? */
65 /* DD (DMA Descriptor) structure, requires word alignment, this is already defined
66 in the LPC32XX USB device header file, but this version si slightly modified to
67 tag some work data with each DMA descriptor. */
68 struct lpc32xx_usbd_dd_gad;
69 struct lpc32xx_usbd_dd_gad
71 struct lpc32xx_usbd_dd_gad *dd_next_phy;
75 u32 *dd_iso_ps_mem_addr;
78 struct lpc32xx_usbd_dd_gad *dd_next_v;
82 * Logical endpoint structure
86 struct list_head queue;
87 struct lpc32xx_udc *udc;
89 u32 hwep_num_base; /* Physical hardware EP */
90 u32 hwep_num; /* Maps to hardware endpoint */
97 volatile u32 req_pending:1;
100 /* Statuses for proc, NAK and stall aren't used */
105 const struct usb_endpoint_descriptor *desc;
109 * Common UDC structure
112 struct usb_gadget gadget;
113 struct usb_gadget_driver *driver;
114 struct platform_device *pdev;
116 struct proc_dir_entry *pde;
119 /* Board and device specific */
120 struct lpc32xx_usbd_cfg *board;
123 void __iomem *udp_baseaddr;
125 struct clk *usb_pll_clk;
126 struct clk *usb_slv_clk;
131 struct dma_pool *dd_cache;
133 /* Common EP and control data */
135 u32 enabled_hwepints;
139 /* VBUS thread support */
140 struct task_struct *thread_task;
141 volatile int thread_wakeup_needed;
144 volatile int irq_asrtd;
146 /* USB device peripheral - various */
147 struct lpc32xx_ep ep[NUM_ENDPOINTS];
158 struct lpc32xx_request {
159 struct usb_request req;
160 struct list_head queue;
161 struct lpc32xx_usbd_dd_gad *dd_desc_ptr;
166 static inline struct lpc32xx_udc *to_udc(struct usb_gadget *g)
168 return container_of(g, struct lpc32xx_udc, gadget);
171 #define ep_dbg(epp, fmt, arg...) \
172 dev_dbg(epp->udc->dev, "%s:%s: " fmt, epp->ep.name, __func__, ## arg)
173 #define ep_err(epp, fmt, arg...) \
174 dev_err(epp->udc->dev, "%s:%s: " fmt, epp->ep.name, __func__, ## arg)
175 #define ep_info(epp, fmt, arg...) \
176 dev_info(epp->udc->dev, "%s:%s: " fmt, epp->ep.name, __func__, ## arg)
177 #define ep_warn(epp, fmt, arg...) \
178 dev_warn(epp->udc->dev, "%s:%s:" fmt, epp->ep.name, __func__, ## arg)