Go to the documentation of this file.
14 #ifndef __LINUX_USB_GADGET_PXA27X_H
15 #define __LINUX_USB_GADGET_PXA27X_H
17 #include <linux/types.h>
27 #define UDCICR0 0x0004
28 #define UDCICR1 0x0008
29 #define UDCISR0 0x000C
30 #define UDCISR1 0x0010
32 #define UDCOTGICR 0x0018
35 #define UDCCSRn(x) (0x0100 + ((x)<<2))
36 #define UDCBCRn(x) (0x0200 + ((x)<<2))
37 #define UDCDRn(x) (0x0300 + ((x)<<2))
38 #define UDCCRn(x) (0x0400 + ((x)<<2))
40 #define UDCCR_OEN (1 << 31)
41 #define UDCCR_AALTHNP (1 << 30)
43 #define UDCCR_AHNP (1 << 29)
45 #define UDCCR_BHNP (1 << 28)
47 #define UDCCR_DWRE (1 << 16)
48 #define UDCCR_ACN (0x03 << 11)
49 #define UDCCR_ACN_S 11
50 #define UDCCR_AIN (0x07 << 8)
52 #define UDCCR_AAISN (0x07 << 5)
54 #define UDCCR_AAISN_S 5
55 #define UDCCR_SMAC (1 << 4)
57 #define UDCCR_EMCE (1 << 3)
59 #define UDCCR_UDR (1 << 2)
60 #define UDCCR_UDA (1 << 1)
61 #define UDCCR_UDE (1 << 0)
63 #define UDCICR_INT(n, intr) (((intr) & 0x03) << (((n) & 0x0F) * 2))
64 #define UDCICR1_IECC (1 << 31)
65 #define UDCICR1_IESOF (1 << 30)
66 #define UDCICR1_IERU (1 << 29)
67 #define UDCICR1_IESU (1 << 28)
68 #define UDCICR1_IERS (1 << 27)
69 #define UDCICR_FIFOERR (1 << 1)
70 #define UDCICR_PKTCOMPL (1 << 0)
71 #define UDCICR_INT_MASK (UDCICR_FIFOERR | UDCICR_PKTCOMPL)
73 #define UDCISR_INT(n, intr) (((intr) & 0x03) << (((n) & 0x0F) * 2))
74 #define UDCISR1_IRCC (1 << 31)
75 #define UDCISR1_IRSOF (1 << 30)
76 #define UDCISR1_IRRU (1 << 29)
77 #define UDCISR1_IRSU (1 << 28)
78 #define UDCISR1_IRRS (1 << 27)
79 #define UDCISR_INT_MASK (UDCICR_FIFOERR | UDCICR_PKTCOMPL)
81 #define UDCOTGICR_IESF (1 << 24)
82 #define UDCOTGICR_IEXR (1 << 17)
84 #define UDCOTGICR_IEXF (1 << 16)
86 #define UDCOTGICR_IEVV40R (1 << 9)
88 #define UDCOTGICR_IEVV40F (1 << 8)
90 #define UDCOTGICR_IEVV44R (1 << 7)
92 #define UDCOTGICR_IEVV44F (1 << 6)
94 #define UDCOTGICR_IESVR (1 << 5)
96 #define UDCOTGICR_IESVF (1 << 4)
98 #define UDCOTGICR_IESDR (1 << 3)
100 #define UDCOTGICR_IESDF (1 << 2)
102 #define UDCOTGICR_IEIDR (1 << 1)
104 #define UDCOTGICR_IEIDF (1 << 0)
108 #define UP2OCR_CPVEN (1 << 0)
109 #define UP2OCR_CPVPE (1 << 1)
111 #define UP2OCR_DPPDE (1 << 2)
112 #define UP2OCR_DMPDE (1 << 3)
113 #define UP2OCR_DPPUE (1 << 4)
114 #define UP2OCR_DMPUE (1 << 5)
115 #define UP2OCR_DPPUBE (1 << 6)
116 #define UP2OCR_DMPUBE (1 << 7)
117 #define UP2OCR_EXSP (1 << 8)
118 #define UP2OCR_EXSUS (1 << 9)
119 #define UP2OCR_IDON (1 << 10)
120 #define UP2OCR_HXS (1 << 16)
121 #define UP2OCR_HXOE (1 << 17)
122 #define UP2OCR_SEOS (1 << 24)
124 #define UDCCSR0_ACM (1 << 9)
125 #define UDCCSR0_AREN (1 << 8)
126 #define UDCCSR0_SA (1 << 7)
127 #define UDCCSR0_RNE (1 << 6)
128 #define UDCCSR0_FST (1 << 5)
129 #define UDCCSR0_SST (1 << 4)
130 #define UDCCSR0_DME (1 << 3)
131 #define UDCCSR0_FTF (1 << 2)
132 #define UDCCSR0_IPR (1 << 1)
133 #define UDCCSR0_OPC (1 << 0)
135 #define UDCCSR_DPE (1 << 9)
136 #define UDCCSR_FEF (1 << 8)
137 #define UDCCSR_SP (1 << 7)
138 #define UDCCSR_BNE (1 << 6)
139 #define UDCCSR_BNF (1 << 6)
140 #define UDCCSR_FST (1 << 5)
141 #define UDCCSR_SST (1 << 4)
142 #define UDCCSR_DME (1 << 3)
143 #define UDCCSR_TRN (1 << 2)
144 #define UDCCSR_PC (1 << 1)
145 #define UDCCSR_FS (1 << 0)
147 #define UDCCONR_CN (0x03 << 25)
148 #define UDCCONR_CN_S 25
149 #define UDCCONR_IN (0x07 << 22)
150 #define UDCCONR_IN_S 22
151 #define UDCCONR_AISN (0x07 << 19)
152 #define UDCCONR_AISN_S 19
153 #define UDCCONR_EN (0x0f << 15)
154 #define UDCCONR_EN_S 15
155 #define UDCCONR_ET (0x03 << 13)
156 #define UDCCONR_ET_S 13
157 #define UDCCONR_ET_INT (0x03 << 13)
158 #define UDCCONR_ET_BULK (0x02 << 13)
159 #define UDCCONR_ET_ISO (0x01 << 13)
160 #define UDCCONR_ET_NU (0x00 << 13)
161 #define UDCCONR_ED (1 << 12)
162 #define UDCCONR_MPS (0x3ff << 2)
163 #define UDCCONR_MPS_S 2
164 #define UDCCONR_DE (1 << 1)
165 #define UDCCONR_EE (1 << 0)
167 #define UDCCR_MASK_BITS (UDCCR_OEN | UDCCR_SMAC | UDCCR_UDR | UDCCR_UDE)
168 #define UDCCSR_WR_MASK (UDCCSR_DME | UDCCSR_FST)
169 #define UDC_FNR_MASK (0x7ff)
170 #define UDC_BCR_MASK (0x3ff)
178 #define ofs_UDCCR(ep) (UDCCRn(ep->idx))
179 #define ofs_UDCCSR(ep) (UDCCSRn(ep->idx))
180 #define ofs_UDCBCR(ep) (UDCBCRn(ep->idx))
181 #define ofs_UDCDR(ep) (UDCDRn(ep->idx))
184 #define udc_ep_readl(ep, reg) \
185 __raw_readl((ep)->dev->regs + ofs_##reg(ep))
186 #define udc_ep_writel(ep, reg, value) \
187 __raw_writel((value), ep->dev->regs + ofs_##reg(ep))
188 #define udc_ep_readb(ep, reg) \
189 __raw_readb((ep)->dev->regs + ofs_##reg(ep))
190 #define udc_ep_writeb(ep, reg, value) \
191 __raw_writeb((value), ep->dev->regs + ofs_##reg(ep))
192 #define udc_readl(dev, reg) \
193 __raw_readl((dev)->regs + (reg))
194 #define udc_writel(udc, reg, value) \
195 __raw_writel((value), (udc)->regs + (reg))
197 #define UDCCSR_MASK (UDCCSR_FST | UDCCSR_DME)
198 #define UDCCISR0_EP_MASK ~0
199 #define UDCCISR1_EP_MASK 0xffff
200 #define UDCCSR0_CTRL_REQ_MASK (UDCCSR0_OPC | UDCCSR0_SA | UDCCSR0_RNE)
202 #define EPIDX(ep) (ep->idx)
203 #define EPADDR(ep) (ep->addr)
204 #define EPXFERTYPE(ep) (ep->type)
205 #define EPNAME(ep) (ep->name)
206 #define is_ep0(ep) (!ep->idx)
207 #define EPXFERTYPE_is_ISO(ep) (EPXFERTYPE(ep) == USB_ENDPOINT_XFER_ISOC)
237 #define USB_EP_DEF(addr, bname, dir, type, maxpkt) \
238 { .usb_ep = { .name = bname, .ops = &pxa_ep_ops, .maxpacket = maxpkt, }, \
239 .desc = { .bEndpointAddress = addr | (dir ? USB_DIR_IN : 0), \
240 .bmAttributes = type, \
241 .wMaxPacketSize = maxpkt, }, \
244 #define USB_EP_BULK(addr, bname, dir) \
245 USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_BULK, BULK_FIFO_SIZE)
246 #define USB_EP_ISO(addr, bname, dir) \
247 USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_ISOC, ISO_FIFO_SIZE)
248 #define USB_EP_INT(addr, bname, dir) \
249 USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_INT, INT_FIFO_SIZE)
250 #define USB_EP_IN_BULK(n) USB_EP_BULK(n, "ep" #n "in-bulk", 1)
251 #define USB_EP_OUT_BULK(n) USB_EP_BULK(n, "ep" #n "out-bulk", 0)
252 #define USB_EP_IN_ISO(n) USB_EP_ISO(n, "ep" #n "in-iso", 1)
253 #define USB_EP_OUT_ISO(n) USB_EP_ISO(n, "ep" #n "out-iso", 0)
254 #define USB_EP_IN_INT(n) USB_EP_INT(n, "ep" #n "in-int", 1)
255 #define USB_EP_CTRL USB_EP_DEF(0, "ep0", 0, 0, EP0_FIFO_SIZE)
257 #define PXA_EP_DEF(_idx, _addr, dir, _type, maxpkt, _config, iface, altset) \
260 .name = "ep" #_idx, \
261 .idx = _idx, .enabled = 0, \
262 .dir_in = dir, .addr = _addr, \
263 .config = _config, .interface = iface, .alternate = altset, \
264 .type = _type, .fifo_size = maxpkt, \
266 #define PXA_EP_BULK(_idx, addr, dir, config, iface, alt) \
267 PXA_EP_DEF(_idx, addr, dir, USB_ENDPOINT_XFER_BULK, BULK_FIFO_SIZE, \
269 #define PXA_EP_ISO(_idx, addr, dir, config, iface, alt) \
270 PXA_EP_DEF(_idx, addr, dir, USB_ENDPOINT_XFER_ISOC, ISO_FIFO_SIZE, \
272 #define PXA_EP_INT(_idx, addr, dir, config, iface, alt) \
273 PXA_EP_DEF(_idx, addr, dir, USB_ENDPOINT_XFER_INT, INT_FIFO_SIZE, \
275 #define PXA_EP_IN_BULK(i, adr, c, f, a) PXA_EP_BULK(i, adr, 1, c, f, a)
276 #define PXA_EP_OUT_BULK(i, adr, c, f, a) PXA_EP_BULK(i, adr, 0, c, f, a)
277 #define PXA_EP_IN_ISO(i, adr, c, f, a) PXA_EP_ISO(i, adr, 1, c, f, a)
278 #define PXA_EP_OUT_ISO(i, adr, c, f, a) PXA_EP_ISO(i, adr, 0, c, f, a)
279 #define PXA_EP_IN_INT(i, adr, c, f, a) PXA_EP_INT(i, adr, 1, c, f, a)
280 #define PXA_EP_CTRL PXA_EP_DEF(0, 0, 0, 0, EP0_FIFO_SIZE, 0, 0, 0)
393 static char *ep0_state_name[] = {
394 "WAIT_FOR_SETUP",
"SETUP_STAGE",
"IN_DATA_STAGE",
"OUT_DATA_STAGE",
395 "IN_STATUS_STAGE",
"OUT_STATUS_STAGE",
"STALL",
396 "WAIT_ACK_SET_CONF_INTERF"
398 #define EP0_STNAME(udc) ep0_state_name[(udc)->ep0state]
400 #define EP0_FIFO_SIZE 16U
401 #define BULK_FIFO_SIZE 64U
402 #define ISO_FIFO_SIZE 256U
403 #define INT_FIFO_SIZE 16U
412 #define NR_USB_ENDPOINTS (1 + 5)
413 #define NR_PXA_ENDPOINTS (1 + 14)
469 #ifdef CONFIG_USB_GADGET_DEBUG_FS
470 struct dentry *debugfs_root;
472 struct dentry *debugfs_queues;
485 #define ep_dbg(ep, fmt, arg...) \
486 dev_dbg(ep->dev->dev, "%s:%s: " fmt, EPNAME(ep), __func__, ## arg)
487 #define ep_vdbg(ep, fmt, arg...) \
488 dev_vdbg(ep->dev->dev, "%s:%s: " fmt, EPNAME(ep), __func__, ## arg)
489 #define ep_err(ep, fmt, arg...) \
490 dev_err(ep->dev->dev, "%s:%s: " fmt, EPNAME(ep), __func__, ## arg)
491 #define ep_info(ep, fmt, arg...) \
492 dev_info(ep->dev->dev, "%s:%s: " fmt, EPNAME(ep), __func__, ## arg)
493 #define ep_warn(ep, fmt, arg...) \
494 dev_warn(ep->dev->dev, "%s:%s:" fmt, EPNAME(ep), __func__, ## arg)