Lines Matching refs:ept
92 udc_endpoint_t *ept; in _udc_endpoint_alloc() local
95 ept = malloc(sizeof(*ept)); in _udc_endpoint_alloc()
96 ept->maxpkt = max_pkt; in _udc_endpoint_alloc()
97 ept->num = num; in _udc_endpoint_alloc()
98 ept->in = !!in; in _udc_endpoint_alloc()
99 ept->req = 0; in _udc_endpoint_alloc()
100 ept->last = 0; in _udc_endpoint_alloc()
101 ept->usb = usb; in _udc_endpoint_alloc()
105 if (ept->in) { in _udc_endpoint_alloc()
106 ept->bit = EPT_TX(ept->num); in _udc_endpoint_alloc()
108 ept->bit = EPT_RX(ept->num); in _udc_endpoint_alloc()
114 ept->head = usb->qh + (num * 2) + (ept->in); in _udc_endpoint_alloc()
115 ept->head->config = cfg; in _udc_endpoint_alloc()
116 ept->next = usb->ept_list; in _udc_endpoint_alloc()
117 usb->ept_list = ept; in _udc_endpoint_alloc()
120 num, in ? "in":"out", ept, ept->head, max_pkt, ept->bit); in _udc_endpoint_alloc()
122 return ept; in _udc_endpoint_alloc()
126 udc_endpoint_t *ept; in udc_endpoint_alloc() local
139 if ((ept = _udc_endpoint_alloc(&USB, n, in, maxpkt))) { in udc_endpoint_alloc()
142 return ept; in udc_endpoint_alloc()
147 void udc_endpoint_free(struct udc_endpoint *ept) { in udc_endpoint_free() argument
151 static void handle_ept_complete(struct udc_endpoint *ept);
153 static void endpoint_flush(usb_t *usb, udc_endpoint_t *ept) { in endpoint_flush() argument
154 if (ept->req) { in endpoint_flush()
156 writel(ept->bit, usb->base + USB_ENDPTFLUSH); in endpoint_flush()
158 while (ept->req) { in endpoint_flush()
159 handle_ept_complete(ept); in endpoint_flush()
164 static void endpoint_reset(usb_t *usb, udc_endpoint_t *ept) { in endpoint_reset() argument
165 unsigned n = readl(usb->base + USB_ENDPTCTRL(ept->num)); in endpoint_reset()
166 n |= ept->in ? EPCTRL_TXR : EPCTRL_RXR; in endpoint_reset()
167 writel(n, usb->base + USB_ENDPTCTRL(ept->num)); in endpoint_reset()
170 static void endpoint_enable(usb_t *usb, udc_endpoint_t *ept, unsigned yes) { in endpoint_enable() argument
171 unsigned n = readl(usb->base + USB_ENDPTCTRL(ept->num)); in endpoint_enable()
174 if (ept->in) { in endpoint_enable()
180 if (ept->num != 0) { in endpoint_enable()
183 ept->head->config = DQH_CFG_MAXPKT(512) | DQH_CFG_ZLT; in endpoint_enable()
185 ept->head->config = DQH_CFG_MAXPKT(64) | DQH_CFG_ZLT; in endpoint_enable()
189 writel(n, usb->base + USB_ENDPTCTRL(ept->num)); in endpoint_enable()
222 int udc_request_queue(udc_endpoint_t *ept, struct udc_request *_req) { in udc_request_queue() argument
239 spin_lock_irqsave(&ept->usb->lock, state); in udc_request_queue()
240 if (!USB.online && ept->num) { in udc_request_queue()
242 } else if (ept->req) { in udc_request_queue()
245 ept->last->next = req; in udc_request_queue()
247 ept->head->next_dtd = (unsigned) dtd; in udc_request_queue()
248 ept->head->dtd_config = 0; in udc_request_queue()
250 writel(ept->bit, ept->usb->base + USB_ENDPTPRIME); in udc_request_queue()
251 ept->req = req; in udc_request_queue()
253 ept->last = req; in udc_request_queue()
254 spin_unlock_irqrestore(&ept->usb->lock, state); in udc_request_queue()
256 DBG("ept%d %s queue req=%p\n", ept->num, ept->in ? "in" : "out", req); in udc_request_queue()
260 static void handle_ept_complete(struct udc_endpoint *ept) { in handle_ept_complete() argument
267 ept->num, ept->in ? "in" : "out", ept->req); in handle_ept_complete()
269 if ((req = ept->req)) { in handle_ept_complete()
272 ept->head->next_dtd = (unsigned) req->next->dtd; in handle_ept_complete()
273 ept->head->dtd_config = 0; in handle_ept_complete()
275 writel(ept->bit, ept->usb->base + USB_ENDPTPRIME); in handle_ept_complete()
276 ept->req = req->next; in handle_ept_complete()
278 ept->req = 0; in handle_ept_complete()
279 ept->last = 0; in handle_ept_complete()
286 ept->num, ept->in ? "in" : "out", dtd->config, dtd->bptr0); in handle_ept_complete()
385 struct udc_endpoint *ept; in handle_setup() local
387 for (ept = usb->ept_list; ept; ept = ept->next) { in handle_setup()
388 if (ept->num != 0) { in handle_setup()
389 endpoint_enable(usb, ept, 1); in handle_setup()
410 udc_endpoint_t *ept; in handle_setup() local
418 for (ept = usb->ept_list; ept; ept = ept->next) { in handle_setup()
419 if ((ept->num == num) && (ept->in == in)) { in handle_setup()
420 endpoint_flush(usb, ept); in handle_setup()
422 endpoint_reset(usb, ept); in handle_setup()
490 udc_endpoint_t *ept; in lpc43xx_USB0_IRQ() local
519 for (ept = usb->ept_list; ept; ept = ept->next) { in lpc43xx_USB0_IRQ()
520 if (ept->req) { in lpc43xx_USB0_IRQ()
521 ept->req->dtd->config = DTD_HALTED; in lpc43xx_USB0_IRQ()
522 handle_ept_complete(ept); in lpc43xx_USB0_IRQ()
537 for (ept = usb->ept_list; ept; ept = ept->next) { in lpc43xx_USB0_IRQ()
538 if (n & ept->bit) { in lpc43xx_USB0_IRQ()
539 handle_ept_complete(ept); in lpc43xx_USB0_IRQ()
576 void udc_ept_desc_fill(udc_endpoint_t *ept, unsigned char *data) { in udc_ept_desc_fill() argument
579 data[2] = ept->num | (ept->in ? 0x80 : 0x00); in udc_ept_desc_fill()
581 data[4] = ept->maxpkt; in udc_ept_desc_fill()
582 data[5] = ept->maxpkt >> 8; in udc_ept_desc_fill()
583 data[6] = ept->in ? 0x00 : 0x01; in udc_ept_desc_fill()