Lines Matching +full:reg +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0
7 * Author : Yuan-hsin Chen <yhchen@faraday-tech.com>
9 #include <linux/dma-mapping.h>
22 MODULE_AUTHOR("Yuan-Hsin Chen, Feng-Hsin Chiang <john453@faraday-tech.com>");
39 u32 reg = ioread32(fusb300->reg + offset); in fusb300_enable_bit() local
41 reg |= value; in fusb300_enable_bit()
42 iowrite32(reg, fusb300->reg + offset); in fusb300_enable_bit()
48 u32 reg = ioread32(fusb300->reg + offset); in fusb300_disable_bit() local
50 reg &= ~value; in fusb300_disable_bit()
51 iowrite32(reg, fusb300->reg + offset); in fusb300_disable_bit()
58 ep->epnum = info.epnum; in fusb300_ep_setting()
59 ep->type = info.type; in fusb300_ep_setting()
64 if (!ep->epnum) in fusb300_ep_release()
66 ep->epnum = 0; in fusb300_ep_release()
67 ep->stall = 0; in fusb300_ep_release()
68 ep->wedged = 0; in fusb300_ep_release()
75 u32 val = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET1(ep)); in fusb300_set_fifo_entry()
79 iowrite32(val, fusb300->reg + FUSB300_OFFSET_EPSET1(ep)); in fusb300_set_fifo_entry()
85 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET1(ep)); in fusb300_set_start_entry() local
86 u32 start_entry = fusb300->fifo_entry_num * FUSB300_FIFO_ENTRY_NUM; in fusb300_set_start_entry()
88 reg &= ~FUSB300_EPSET1_START_ENTRY_MSK ; in fusb300_set_start_entry()
89 reg |= FUSB300_EPSET1_START_ENTRY(start_entry); in fusb300_set_start_entry()
90 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPSET1(ep)); in fusb300_set_start_entry()
91 if (fusb300->fifo_entry_num == FUSB300_MAX_FIFO_ENTRY) { in fusb300_set_start_entry()
92 fusb300->fifo_entry_num = 0; in fusb300_set_start_entry()
93 fusb300->addrofs = 0; in fusb300_set_start_entry()
96 fusb300->fifo_entry_num++; in fusb300_set_start_entry()
103 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET2(info.epnum)); in fusb300_set_epaddrofs() local
105 reg &= ~FUSB300_EPSET2_ADDROFS_MSK; in fusb300_set_epaddrofs()
106 reg |= FUSB300_EPSET2_ADDROFS(fusb300->addrofs); in fusb300_set_epaddrofs()
107 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPSET2(info.epnum)); in fusb300_set_epaddrofs()
108 fusb300->addrofs += (info.maxpacket + 7) / 8 * FUSB300_FIFO_ENTRY_NUM; in fusb300_set_epaddrofs()
122 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET1(info.epnum)); in fusb300_set_eptype() local
124 reg &= ~FUSB300_EPSET1_TYPE_MSK; in fusb300_set_eptype()
125 reg |= FUSB300_EPSET1_TYPE(info.type); in fusb300_set_eptype()
126 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPSET1(info.epnum)); in fusb300_set_eptype()
132 u32 reg; in fusb300_set_epdir() local
136 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET1(info.epnum)); in fusb300_set_epdir()
137 reg &= ~FUSB300_EPSET1_DIR_MSK; in fusb300_set_epdir()
138 reg |= FUSB300_EPSET1_DIRIN; in fusb300_set_epdir()
139 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPSET1(info.epnum)); in fusb300_set_epdir()
145 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET1(ep)); in fusb300_set_ep_active() local
147 reg |= FUSB300_EPSET1_ACTEN; in fusb300_set_ep_active()
148 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPSET1(ep)); in fusb300_set_ep_active()
154 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET2(info.epnum)); in fusb300_set_epmps() local
156 reg &= ~FUSB300_EPSET2_MPS_MSK; in fusb300_set_epmps()
157 reg |= FUSB300_EPSET2_MPS(info.maxpacket); in fusb300_set_epmps()
158 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPSET2(info.epnum)); in fusb300_set_epmps()
164 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET1(info.epnum)); in fusb300_set_interval() local
166 reg &= ~FUSB300_EPSET1_INTERVAL(0x7); in fusb300_set_interval()
167 reg |= FUSB300_EPSET1_INTERVAL(info.interval); in fusb300_set_interval()
168 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPSET1(info.epnum)); in fusb300_set_interval()
174 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET1(info.epnum)); in fusb300_set_bwnum() local
176 reg &= ~FUSB300_EPSET1_BWNUM(0x3); in fusb300_set_bwnum()
177 reg |= FUSB300_EPSET1_BWNUM(info.bw_num); in fusb300_set_bwnum()
178 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPSET1(info.epnum)); in fusb300_set_bwnum()
200 struct fusb300 *fusb300 = ep->fusb300; in config_ep()
203 ep->ep.desc = desc; in config_ep()
209 info.type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; in config_ep()
210 info.dir_in = (desc->bEndpointAddress & USB_ENDPOINT_DIR_MASK) ? 1 : 0; in config_ep()
212 info.epnum = desc->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; in config_ep()
216 info.interval = desc->bInterval; in config_ep()
227 fusb300->ep[info.epnum] = ep; in config_ep()
239 if (ep->fusb300->reenum) { in fusb300_enable()
240 ep->fusb300->fifo_entry_num = 0; in fusb300_enable()
241 ep->fusb300->addrofs = 0; in fusb300_enable()
242 ep->fusb300->reenum = 0; in fusb300_enable()
258 while (!list_empty(&ep->queue)) { in fusb300_disable()
259 req = list_entry(ep->queue.next, struct fusb300_request, queue); in fusb300_disable()
260 spin_lock_irqsave(&ep->fusb300->lock, flags); in fusb300_disable()
261 done(ep, req, -ECONNRESET); in fusb300_disable()
262 spin_unlock_irqrestore(&ep->fusb300->lock, flags); in fusb300_disable()
276 INIT_LIST_HEAD(&req->queue); in fusb300_alloc_request()
278 return &req->req; in fusb300_alloc_request()
291 struct fusb300 *fusb300 = ep->fusb300; in enable_fifo_int()
293 if (ep->epnum) { in enable_fifo_int()
295 FUSB300_IGER0_EEPn_FIFO_INT(ep->epnum)); in enable_fifo_int()
298 return -EINVAL; in enable_fifo_int()
306 struct fusb300 *fusb300 = ep->fusb300; in disable_fifo_int()
308 if (ep->epnum) { in disable_fifo_int()
310 FUSB300_IGER0_EEPn_FIFO_INT(ep->epnum)); in disable_fifo_int()
313 return -EINVAL; in disable_fifo_int()
321 u32 reg; in fusb300_set_cxlen() local
323 reg = ioread32(fusb300->reg + FUSB300_OFFSET_CSR); in fusb300_set_cxlen()
324 reg &= ~FUSB300_CSR_LEN_MSK; in fusb300_set_cxlen()
325 reg |= FUSB300_CSR_LEN(length); in fusb300_set_cxlen()
326 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_CSR); in fusb300_set_cxlen()
329 /* write data to cx fifo */
335 u32 data; in fusb300_wrcxf() local
336 struct fusb300 *fusb300 = ep->fusb300; in fusb300_wrcxf()
337 u32 length = req->req.length - req->req.actual; in fusb300_wrcxf()
339 tmp = req->req.buf + req->req.actual; in fusb300_wrcxf()
343 for (i = (SS_CTL_MAX_PACKET_SIZE >> 2); i > 0; i--) { in fusb300_wrcxf()
344 data = *tmp | *(tmp + 1) << 8 | *(tmp + 2) << 16 | in fusb300_wrcxf()
346 iowrite32(data, fusb300->reg + FUSB300_OFFSET_CXPORT); in fusb300_wrcxf()
349 req->req.actual += SS_CTL_MAX_PACKET_SIZE; in fusb300_wrcxf()
352 for (i = length >> 2; i > 0; i--) { in fusb300_wrcxf()
353 data = *tmp | *(tmp + 1) << 8 | *(tmp + 2) << 16 | in fusb300_wrcxf()
355 printk(KERN_DEBUG " 0x%x\n", data); in fusb300_wrcxf()
356 iowrite32(data, fusb300->reg + FUSB300_OFFSET_CXPORT); in fusb300_wrcxf()
361 data = *tmp; in fusb300_wrcxf()
362 printk(KERN_DEBUG " 0x%x\n", data); in fusb300_wrcxf()
363 iowrite32(data, fusb300->reg + FUSB300_OFFSET_CXPORT); in fusb300_wrcxf()
366 data = *tmp | *(tmp + 1) << 8; in fusb300_wrcxf()
367 printk(KERN_DEBUG " 0x%x\n", data); in fusb300_wrcxf()
368 iowrite32(data, fusb300->reg + FUSB300_OFFSET_CXPORT); in fusb300_wrcxf()
371 data = *tmp | *(tmp + 1) << 8 | *(tmp + 2) << 16; in fusb300_wrcxf()
372 printk(KERN_DEBUG " 0x%x\n", data); in fusb300_wrcxf()
373 iowrite32(data, fusb300->reg + FUSB300_OFFSET_CXPORT); in fusb300_wrcxf()
378 req->req.actual += length; in fusb300_wrcxf()
390 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET0(ep)); in fusb300_clear_epnstall() local
392 if (reg & FUSB300_EPSET0_STL) { in fusb300_clear_epnstall()
394 reg |= FUSB300_EPSET0_STL_CLR; in fusb300_clear_epnstall()
395 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPSET0(ep)); in fusb300_clear_epnstall()
401 if (ep->fusb300->ep0_dir) { /* if IN */ in ep0_queue()
402 if (req->req.length) { in ep0_queue()
405 printk(KERN_DEBUG "%s : req->req.length = 0x%x\n", in ep0_queue()
406 __func__, req->req.length); in ep0_queue()
407 if ((req->req.length == req->req.actual) || in ep0_queue()
408 (req->req.actual < ep->ep.maxpacket)) in ep0_queue()
411 if (!req->req.length) in ep0_queue()
414 fusb300_enable_bit(ep->fusb300, FUSB300_OFFSET_IGER1, in ep0_queue()
430 if (ep->fusb300->gadget.speed == USB_SPEED_UNKNOWN) in fusb300_queue()
431 return -ESHUTDOWN; in fusb300_queue()
433 spin_lock_irqsave(&ep->fusb300->lock, flags); in fusb300_queue()
435 if (list_empty(&ep->queue)) in fusb300_queue()
438 list_add_tail(&req->queue, &ep->queue); in fusb300_queue()
440 req->req.actual = 0; in fusb300_queue()
441 req->req.status = -EINPROGRESS; in fusb300_queue()
443 if (ep->ep.desc == NULL) /* ep0 */ in fusb300_queue()
445 else if (request && !ep->stall) in fusb300_queue()
448 spin_unlock_irqrestore(&ep->fusb300->lock, flags); in fusb300_queue()
462 spin_lock_irqsave(&ep->fusb300->lock, flags); in fusb300_dequeue()
463 if (!list_empty(&ep->queue)) in fusb300_dequeue()
464 done(ep, req, -ECONNRESET); in fusb300_dequeue()
465 spin_unlock_irqrestore(&ep->fusb300->lock, flags); in fusb300_dequeue()
479 fusb300 = ep->fusb300; in fusb300_set_halt_and_wedge()
481 spin_lock_irqsave(&ep->fusb300->lock, flags); in fusb300_set_halt_and_wedge()
483 if (!list_empty(&ep->queue)) { in fusb300_set_halt_and_wedge()
484 ret = -EAGAIN; in fusb300_set_halt_and_wedge()
489 fusb300_set_epnstall(fusb300, ep->epnum); in fusb300_set_halt_and_wedge()
490 ep->stall = 1; in fusb300_set_halt_and_wedge()
492 ep->wedged = 1; in fusb300_set_halt_and_wedge()
494 fusb300_clear_epnstall(fusb300, ep->epnum); in fusb300_set_halt_and_wedge()
495 ep->stall = 0; in fusb300_set_halt_and_wedge()
496 ep->wedged = 0; in fusb300_set_halt_and_wedge()
500 spin_unlock_irqrestore(&ep->fusb300->lock, flags); in fusb300_set_halt_and_wedge()
537 iowrite32(value, fusb300->reg + offset); in fusb300_clear_int()
556 /* read data from cx fifo */
562 u32 data; in fusb300_rdcxf() local
566 for (i = (length >> 2); i > 0; i--) { in fusb300_rdcxf()
567 data = ioread32(fusb300->reg + FUSB300_OFFSET_CXPORT); in fusb300_rdcxf()
568 printk(KERN_DEBUG " 0x%x\n", data); in fusb300_rdcxf()
569 *tmp = data & 0xFF; in fusb300_rdcxf()
570 *(tmp + 1) = (data >> 8) & 0xFF; in fusb300_rdcxf()
571 *(tmp + 2) = (data >> 16) & 0xFF; in fusb300_rdcxf()
572 *(tmp + 3) = (data >> 24) & 0xFF; in fusb300_rdcxf()
578 data = ioread32(fusb300->reg + FUSB300_OFFSET_CXPORT); in fusb300_rdcxf()
579 printk(KERN_DEBUG " 0x%x\n", data); in fusb300_rdcxf()
580 *tmp = data & 0xFF; in fusb300_rdcxf()
583 data = ioread32(fusb300->reg + FUSB300_OFFSET_CXPORT); in fusb300_rdcxf()
584 printk(KERN_DEBUG " 0x%x\n", data); in fusb300_rdcxf()
585 *tmp = data & 0xFF; in fusb300_rdcxf()
586 *(tmp + 1) = (data >> 8) & 0xFF; in fusb300_rdcxf()
589 data = ioread32(fusb300->reg + FUSB300_OFFSET_CXPORT); in fusb300_rdcxf()
590 printk(KERN_DEBUG " 0x%x\n", data); in fusb300_rdcxf()
591 *tmp = data & 0xFF; in fusb300_rdcxf()
592 *(tmp + 1) = (data >> 8) & 0xFF; in fusb300_rdcxf()
593 *(tmp + 2) = (data >> 16) & 0xFF; in fusb300_rdcxf()
606 u32 data, reg; in fusb300_rdfifo() local
607 struct fusb300 *fusb300 = ep->fusb300; in fusb300_rdfifo()
609 tmp = req->req.buf + req->req.actual; in fusb300_rdfifo()
610 req->req.actual += length; in fusb300_rdfifo()
612 if (req->req.actual > req->req.length) in fusb300_rdfifo()
613 printk(KERN_DEBUG "req->req.actual > req->req.length\n"); in fusb300_rdfifo()
615 for (i = (length >> 2); i > 0; i--) { in fusb300_rdfifo()
616 data = ioread32(fusb300->reg + in fusb300_rdfifo()
617 FUSB300_OFFSET_EPPORT(ep->epnum)); in fusb300_rdfifo()
618 *tmp = data & 0xFF; in fusb300_rdfifo()
619 *(tmp + 1) = (data >> 8) & 0xFF; in fusb300_rdfifo()
620 *(tmp + 2) = (data >> 16) & 0xFF; in fusb300_rdfifo()
621 *(tmp + 3) = (data >> 24) & 0xFF; in fusb300_rdfifo()
627 data = ioread32(fusb300->reg + in fusb300_rdfifo()
628 FUSB300_OFFSET_EPPORT(ep->epnum)); in fusb300_rdfifo()
629 *tmp = data & 0xFF; in fusb300_rdfifo()
632 data = ioread32(fusb300->reg + in fusb300_rdfifo()
633 FUSB300_OFFSET_EPPORT(ep->epnum)); in fusb300_rdfifo()
634 *tmp = data & 0xFF; in fusb300_rdfifo()
635 *(tmp + 1) = (data >> 8) & 0xFF; in fusb300_rdfifo()
638 data = ioread32(fusb300->reg + in fusb300_rdfifo()
639 FUSB300_OFFSET_EPPORT(ep->epnum)); in fusb300_rdfifo()
640 *tmp = data & 0xFF; in fusb300_rdfifo()
641 *(tmp + 1) = (data >> 8) & 0xFF; in fusb300_rdfifo()
642 *(tmp + 2) = (data >> 16) & 0xFF; in fusb300_rdfifo()
649 reg = ioread32(fusb300->reg + FUSB300_OFFSET_IGR1); in fusb300_rdfifo()
650 reg &= FUSB300_IGR1_SYNF0_EMPTY_INT; in fusb300_rdfifo()
654 } while (!reg); in fusb300_rdfifo()
660 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPSET0(ep)); in fusb300_get_epnstall() local
662 value = reg & FUSB300_EPSET0_STL; in fusb300_get_epnstall()
670 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_CSR); in fusb300_get_cxstall() local
672 value = (reg & FUSB300_CSR_STL) >> 1; in fusb300_get_cxstall()
684 __releases(fusb300->lock) in get_status()
685 __acquires(fusb300->lock) in get_status()
689 u16 w_index = ctrl->wIndex; in get_status()
691 switch (ctrl->bRequestType & USB_RECIP_MASK) { in get_status()
714 fusb300->ep0_data = cpu_to_le16(status); in get_status()
715 fusb300->ep0_req->buf = &fusb300->ep0_data; in get_status()
716 fusb300->ep0_req->length = 2; in get_status()
718 spin_unlock(&fusb300->lock); in get_status()
719 fusb300_queue(fusb300->gadget.ep0, fusb300->ep0_req, GFP_KERNEL); in get_status()
720 spin_lock(&fusb300->lock); in get_status()
727 switch (ctrl->bRequestType & USB_RECIP_MASK) { in set_feature()
735 u16 w_index = le16_to_cpu(ctrl->wIndex); in set_feature()
760 fusb300->ep[ctrl->wIndex & USB_ENDPOINT_NUMBER_MASK]; in clear_feature()
762 switch (ctrl->bRequestType & USB_RECIP_MASK) { in clear_feature()
770 if (ctrl->wIndex & USB_ENDPOINT_NUMBER_MASK) { in clear_feature()
771 if (ep->wedged) { in clear_feature()
775 if (ep->stall) { in clear_feature()
776 ep->stall = 0; in clear_feature()
777 fusb300_clear_seqnum(fusb300, ep->epnum); in clear_feature()
778 fusb300_clear_epnstall(fusb300, ep->epnum); in clear_feature()
779 if (!list_empty(&ep->queue)) in clear_feature()
793 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_DAR); in fusb300_set_dev_addr() local
795 reg &= ~FUSB300_DAR_DRVADDR_MSK; in fusb300_set_dev_addr()
796 reg |= FUSB300_DAR_DRVADDR(addr); in fusb300_set_dev_addr()
798 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_DAR); in fusb300_set_dev_addr()
803 if (ctrl->wValue >= 0x0100) in set_address()
806 fusb300_set_dev_addr(fusb300, ctrl->wValue); in set_address()
815 memcpy(mem, *__src, (*__src)->bLength); \
816 mem += (*__src)->bLength; \
827 fusb300->ep0_dir = ctrl->bRequestType & USB_DIR_IN; in setup_packet()
828 fusb300->ep0_length = ctrl->wLength; in setup_packet()
831 if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_STANDARD) { in setup_packet()
832 switch (ctrl->bRequest) { in setup_packet()
851 fusb300->reenum = 1; in setup_packet()
867 list_del_init(&req->queue); in done()
870 if (ep->fusb300->gadget.speed == USB_SPEED_UNKNOWN) in done()
871 req->req.status = -ESHUTDOWN; in done()
873 req->req.status = status; in done()
875 spin_unlock(&ep->fusb300->lock); in done()
876 usb_gadget_giveback_request(&ep->ep, &req->req); in done()
877 spin_lock(&ep->fusb300->lock); in done()
879 if (ep->epnum) { in done()
881 if (!list_empty(&ep->queue)) in done()
884 fusb300_set_cxdone(ep->fusb300); in done()
891 u32 reg; in fusb300_fill_idma_prdtbl() local
895 reg = ioread32(ep->fusb300->reg + in fusb300_fill_idma_prdtbl()
896 FUSB300_OFFSET_EPPRD_W0(ep->epnum)); in fusb300_fill_idma_prdtbl()
897 reg &= FUSB300_EPPRD0_H; in fusb300_fill_idma_prdtbl()
898 } while (reg); in fusb300_fill_idma_prdtbl()
900 iowrite32(d, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W1(ep->epnum)); in fusb300_fill_idma_prdtbl()
904 iowrite32(value, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W0(ep->epnum)); in fusb300_fill_idma_prdtbl()
906 iowrite32(0x0, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W2(ep->epnum)); in fusb300_fill_idma_prdtbl()
908 fusb300_enable_bit(ep->fusb300, FUSB300_OFFSET_EPPRDRDY, in fusb300_fill_idma_prdtbl()
909 FUSB300_EPPRDR_EP_PRD_RDY(ep->epnum)); in fusb300_fill_idma_prdtbl()
914 u32 reg; in fusb300_wait_idma_finished() local
917 reg = ioread32(ep->fusb300->reg + FUSB300_OFFSET_IGR1); in fusb300_wait_idma_finished()
918 if ((reg & FUSB300_IGR1_VBUS_CHG_INT) || in fusb300_wait_idma_finished()
919 (reg & FUSB300_IGR1_WARM_RST_INT) || in fusb300_wait_idma_finished()
920 (reg & FUSB300_IGR1_HOT_RST_INT) || in fusb300_wait_idma_finished()
921 (reg & FUSB300_IGR1_USBRST_INT) in fusb300_wait_idma_finished()
924 reg = ioread32(ep->fusb300->reg + FUSB300_OFFSET_IGR0); in fusb300_wait_idma_finished()
925 reg &= FUSB300_IGR0_EPn_PRD_INT(ep->epnum); in fusb300_wait_idma_finished()
926 } while (!reg); in fusb300_wait_idma_finished()
928 fusb300_clear_int(ep->fusb300, FUSB300_OFFSET_IGR0, in fusb300_wait_idma_finished()
929 FUSB300_IGR0_EPn_PRD_INT(ep->epnum)); in fusb300_wait_idma_finished()
933 reg = ioread32(ep->fusb300->reg + FUSB300_OFFSET_IGER0); in fusb300_wait_idma_finished()
934 reg &= ~FUSB300_IGER0_EEPn_PRD_INT(ep->epnum); in fusb300_wait_idma_finished()
935 iowrite32(reg, ep->fusb300->reg + FUSB300_OFFSET_IGER0); in fusb300_wait_idma_finished()
943 ret = usb_gadget_map_request(&ep->fusb300->gadget, in fusb300_set_idma()
944 &req->req, DMA_TO_DEVICE); in fusb300_set_idma()
948 fusb300_enable_bit(ep->fusb300, FUSB300_OFFSET_IGER0, in fusb300_set_idma()
949 FUSB300_IGER0_EEPn_PRD_INT(ep->epnum)); in fusb300_set_idma()
951 fusb300_fill_idma_prdtbl(ep, req->req.dma, req->req.length); in fusb300_set_idma()
955 usb_gadget_unmap_request(&ep->fusb300->gadget, in fusb300_set_idma()
956 &req->req, DMA_TO_DEVICE); in fusb300_set_idma()
961 struct fusb300_request *req = list_entry(ep->queue.next, in in_ep_fifo_handler()
964 if (req->req.length) in in_ep_fifo_handler()
971 struct fusb300 *fusb300 = ep->fusb300; in out_ep_fifo_handler()
972 struct fusb300_request *req = list_entry(ep->queue.next, in out_ep_fifo_handler()
974 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPFFR(ep->epnum)); in out_ep_fifo_handler() local
975 u32 length = reg & FUSB300_FFR_BYCNT; in out_ep_fifo_handler()
980 if ((req->req.length == req->req.actual) || (length < ep->ep.maxpacket)) in out_ep_fifo_handler()
986 u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_GCR); in check_device_mode() local
988 switch (reg & FUSB300_GCR_DEVEN_MSK) { in check_device_mode()
990 fusb300->gadget.speed = USB_SPEED_SUPER; in check_device_mode()
993 fusb300->gadget.speed = USB_SPEED_HIGH; in check_device_mode()
996 fusb300->gadget.speed = USB_SPEED_FULL; in check_device_mode()
999 fusb300->gadget.speed = USB_SPEED_UNKNOWN; in check_device_mode()
1002 printk(KERN_INFO "dev_mode = %d\n", (reg & FUSB300_GCR_DEVEN_MSK)); in check_device_mode()
1008 struct fusb300_ep *ep = fusb300->ep[0]; in fusb300_ep0out()
1009 u32 reg; in fusb300_ep0out() local
1011 if (!list_empty(&ep->queue)) { in fusb300_ep0out()
1014 req = list_first_entry(&ep->queue, in fusb300_ep0out()
1016 if (req->req.length) in fusb300_ep0out()
1017 fusb300_rdcxf(ep->fusb300, req->req.buf, in fusb300_ep0out()
1018 req->req.length); in fusb300_ep0out()
1020 reg = ioread32(fusb300->reg + FUSB300_OFFSET_IGER1); in fusb300_ep0out()
1021 reg &= ~FUSB300_IGER1_CX_OUT_INT; in fusb300_ep0out()
1022 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_IGER1); in fusb300_ep0out()
1030 struct fusb300_ep *ep = fusb300->ep[0]; in fusb300_ep0in()
1032 if ((!list_empty(&ep->queue)) && (fusb300->ep0_dir)) { in fusb300_ep0in()
1033 req = list_entry(ep->queue.next, in fusb300_ep0in()
1035 if (req->req.length) in fusb300_ep0in()
1037 if ((req->req.length - req->req.actual) < ep->ep.maxpacket) in fusb300_ep0in()
1062 u32 int_grp1 = ioread32(fusb300->reg + FUSB300_OFFSET_IGR1); in fusb300_irq()
1063 u32 int_grp1_en = ioread32(fusb300->reg + FUSB300_OFFSET_IGER1); in fusb300_irq()
1064 u32 int_grp0 = ioread32(fusb300->reg + FUSB300_OFFSET_IGR0); in fusb300_irq()
1065 u32 int_grp0_en = ioread32(fusb300->reg + FUSB300_OFFSET_IGER0); in fusb300_irq()
1068 u32 reg; in fusb300_irq() local
1071 spin_lock(&fusb300->lock); in fusb300_irq()
1204 spin_unlock(&fusb300->lock); in fusb300_irq()
1205 if (fusb300->driver->setup(&fusb300->gadget, &ctrl) < 0) in fusb300_irq()
1207 spin_lock(&fusb300->lock); in fusb300_irq()
1240 reg = ioread32(fusb300->reg + in fusb300_irq()
1242 in = (reg & FUSB300_EPSET1_DIRIN) ? 1 : 0; in fusb300_irq()
1244 in_ep_fifo_handler(fusb300->ep[i]); in fusb300_irq()
1246 out_ep_fifo_handler(fusb300->ep[i]); in fusb300_irq()
1251 spin_unlock(&fusb300->lock); in fusb300_irq()
1259 u32 reg; in fusb300_set_u2_timeout() local
1261 reg = ioread32(fusb300->reg + FUSB300_OFFSET_TT); in fusb300_set_u2_timeout()
1262 reg &= ~0xff; in fusb300_set_u2_timeout()
1263 reg |= FUSB300_SSCR2_U2TIMEOUT(time); in fusb300_set_u2_timeout()
1265 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_TT); in fusb300_set_u2_timeout()
1271 u32 reg; in fusb300_set_u1_timeout() local
1273 reg = ioread32(fusb300->reg + FUSB300_OFFSET_TT); in fusb300_set_u1_timeout()
1274 reg &= ~(0xff << 8); in fusb300_set_u1_timeout()
1275 reg |= FUSB300_SSCR2_U1TIMEOUT(time); in fusb300_set_u1_timeout()
1277 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_TT); in fusb300_set_u1_timeout()
1282 u32 reg; in init_controller() local
1288 reg = ioread32(fusb300->reg + FUSB300_OFFSET_AHBCR); in init_controller()
1289 reg &= ~mask; in init_controller()
1290 reg |= val; in init_controller()
1291 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_AHBCR); in init_controller()
1293 /* enable high-speed LPM */ in init_controller()
1295 reg = ioread32(fusb300->reg + FUSB300_OFFSET_HSCR); in init_controller()
1296 reg &= ~mask; in init_controller()
1297 reg |= val; in init_controller()
1298 iowrite32(reg, fusb300->reg + FUSB300_OFFSET_HSCR); in init_controller()
1305 iowrite32(0xcfffff9f, fusb300->reg + FUSB300_OFFSET_IGER1); in init_controller()
1307 /*------------------------------------------------------------------------*/
1314 driver->driver.bus = NULL; in fusb300_udc_start()
1315 fusb300->driver = driver; in fusb300_udc_start()
1325 fusb300->driver = NULL; in fusb300_udc_stop()
1329 /*--------------------------------------------------------------------------*/
1347 usb_del_gadget_udc(&fusb300->gadget); in fusb300_remove()
1348 iounmap(fusb300->reg); in fusb300_remove()
1351 fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req); in fusb300_remove()
1353 kfree(fusb300->ep[i]); in fusb300_remove()
1362 void __iomem *reg = NULL; in fusb300_probe() local
1370 ret = -ENODEV; in fusb300_probe()
1377 ret = -ENODEV; in fusb300_probe()
1378 dev_err(&pdev->dev, in fusb300_probe()
1385 ret = -ENODEV; in fusb300_probe()
1386 dev_err(&pdev->dev, in fusb300_probe()
1391 reg = ioremap(res->start, resource_size(res)); in fusb300_probe()
1392 if (reg == NULL) { in fusb300_probe()
1393 ret = -ENOMEM; in fusb300_probe()
1401 ret = -ENOMEM; in fusb300_probe()
1408 ret = -ENOMEM; in fusb300_probe()
1411 fusb300->ep[i] = _ep[i]; in fusb300_probe()
1414 spin_lock_init(&fusb300->lock); in fusb300_probe()
1418 fusb300->gadget.ops = &fusb300_gadget_ops; in fusb300_probe()
1420 fusb300->gadget.max_speed = USB_SPEED_HIGH; in fusb300_probe()
1421 fusb300->gadget.name = udc_name; in fusb300_probe()
1422 fusb300->reg = reg; in fusb300_probe()
1424 ret = request_irq(ires->start, fusb300_irq, IRQF_SHARED, in fusb300_probe()
1431 ret = request_irq(ires1->start, fusb300_irq, in fusb300_probe()
1438 INIT_LIST_HEAD(&fusb300->gadget.ep_list); in fusb300_probe()
1441 struct fusb300_ep *ep = fusb300->ep[i]; in fusb300_probe()
1444 INIT_LIST_HEAD(&fusb300->ep[i]->ep.ep_list); in fusb300_probe()
1445 list_add_tail(&fusb300->ep[i]->ep.ep_list, in fusb300_probe()
1446 &fusb300->gadget.ep_list); in fusb300_probe()
1448 ep->fusb300 = fusb300; in fusb300_probe()
1449 INIT_LIST_HEAD(&ep->queue); in fusb300_probe()
1450 ep->ep.name = fusb300_ep_name[i]; in fusb300_probe()
1451 ep->ep.ops = &fusb300_ep_ops; in fusb300_probe()
1452 usb_ep_set_maxpacket_limit(&ep->ep, HS_BULK_MAX_PACKET_SIZE); in fusb300_probe()
1455 ep->ep.caps.type_control = true; in fusb300_probe()
1457 ep->ep.caps.type_iso = true; in fusb300_probe()
1458 ep->ep.caps.type_bulk = true; in fusb300_probe()
1459 ep->ep.caps.type_int = true; in fusb300_probe()
1462 ep->ep.caps.dir_in = true; in fusb300_probe()
1463 ep->ep.caps.dir_out = true; in fusb300_probe()
1465 usb_ep_set_maxpacket_limit(&fusb300->ep[0]->ep, HS_CTL_MAX_PACKET_SIZE); in fusb300_probe()
1466 fusb300->ep[0]->epnum = 0; in fusb300_probe()
1467 fusb300->gadget.ep0 = &fusb300->ep[0]->ep; in fusb300_probe()
1468 INIT_LIST_HEAD(&fusb300->gadget.ep0->ep_list); in fusb300_probe()
1470 fusb300->ep0_req = fusb300_alloc_request(&fusb300->ep[0]->ep, in fusb300_probe()
1472 if (fusb300->ep0_req == NULL) { in fusb300_probe()
1473 ret = -ENOMEM; in fusb300_probe()
1478 ret = usb_add_gadget_udc(&pdev->dev, &fusb300->gadget); in fusb300_probe()
1482 dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION); in fusb300_probe()
1487 fusb300_free_request(&fusb300->ep[0]->ep, fusb300->ep0_req); in fusb300_probe()
1490 free_irq(ires->start, fusb300); in fusb300_probe()
1494 if (fusb300->ep0_req) in fusb300_probe()
1495 fusb300_free_request(&fusb300->ep[0]->ep, in fusb300_probe()
1496 fusb300->ep0_req); in fusb300_probe()
1498 kfree(fusb300->ep[i]); in fusb300_probe()
1501 if (reg) in fusb300_probe()
1502 iounmap(reg); in fusb300_probe()