diff options
Diffstat (limited to 'drivers/usb/gadget/fusb300_udc.c')
-rw-r--r-- | drivers/usb/gadget/fusb300_udc.c | 91 |
1 files changed, 8 insertions, 83 deletions
diff --git a/drivers/usb/gadget/fusb300_udc.c b/drivers/usb/gadget/fusb300_udc.c index 06353e7ba1fb..24a924330c81 100644 --- a/drivers/usb/gadget/fusb300_udc.c +++ b/drivers/usb/gadget/fusb300_udc.c | |||
@@ -767,56 +767,6 @@ static void fusb300_rdfifo(struct fusb300_ep *ep, | |||
767 | } while (!reg); | 767 | } while (!reg); |
768 | } | 768 | } |
769 | 769 | ||
770 | /* write data to fifo */ | ||
771 | static void fusb300_wrfifo(struct fusb300_ep *ep, | ||
772 | struct fusb300_request *req) | ||
773 | { | ||
774 | int i = 0; | ||
775 | u8 *tmp; | ||
776 | u32 data, reg; | ||
777 | struct fusb300 *fusb300 = ep->fusb300; | ||
778 | |||
779 | tmp = req->req.buf; | ||
780 | req->req.actual = req->req.length; | ||
781 | |||
782 | for (i = (req->req.length >> 2); i > 0; i--) { | ||
783 | data = *tmp | *(tmp + 1) << 8 | | ||
784 | *(tmp + 2) << 16 | *(tmp + 3) << 24; | ||
785 | |||
786 | iowrite32(data, fusb300->reg + | ||
787 | FUSB300_OFFSET_EPPORT(ep->epnum)); | ||
788 | tmp += 4; | ||
789 | } | ||
790 | |||
791 | switch (req->req.length % 4) { | ||
792 | case 1: | ||
793 | data = *tmp; | ||
794 | iowrite32(data, fusb300->reg + | ||
795 | FUSB300_OFFSET_EPPORT(ep->epnum)); | ||
796 | break; | ||
797 | case 2: | ||
798 | data = *tmp | *(tmp + 1) << 8; | ||
799 | iowrite32(data, fusb300->reg + | ||
800 | FUSB300_OFFSET_EPPORT(ep->epnum)); | ||
801 | break; | ||
802 | case 3: | ||
803 | data = *tmp | *(tmp + 1) << 8 | *(tmp + 2) << 16; | ||
804 | iowrite32(data, fusb300->reg + | ||
805 | FUSB300_OFFSET_EPPORT(ep->epnum)); | ||
806 | break; | ||
807 | default: | ||
808 | break; | ||
809 | } | ||
810 | |||
811 | do { | ||
812 | reg = ioread32(fusb300->reg + FUSB300_OFFSET_IGR1); | ||
813 | reg &= FUSB300_IGR1_SYNF0_EMPTY_INT; | ||
814 | if (i) | ||
815 | printk(KERN_INFO"sync fifo is not empty!\n"); | ||
816 | i++; | ||
817 | } while (!reg); | ||
818 | } | ||
819 | |||
820 | static u8 fusb300_get_epnstall(struct fusb300 *fusb300, u8 ep) | 770 | static u8 fusb300_get_epnstall(struct fusb300 *fusb300, u8 ep) |
821 | { | 771 | { |
822 | u8 value; | 772 | u8 value; |
@@ -1024,17 +974,6 @@ static int setup_packet(struct fusb300 *fusb300, struct usb_ctrlrequest *ctrl) | |||
1024 | return ret; | 974 | return ret; |
1025 | } | 975 | } |
1026 | 976 | ||
1027 | static void fusb300_set_ep_bycnt(struct fusb300_ep *ep, u32 bycnt) | ||
1028 | { | ||
1029 | struct fusb300 *fusb300 = ep->fusb300; | ||
1030 | u32 reg = ioread32(fusb300->reg + FUSB300_OFFSET_EPFFR(ep->epnum)); | ||
1031 | |||
1032 | reg &= ~FUSB300_FFR_BYCNT; | ||
1033 | reg |= bycnt & FUSB300_FFR_BYCNT; | ||
1034 | |||
1035 | iowrite32(reg, fusb300->reg + FUSB300_OFFSET_EPFFR(ep->epnum)); | ||
1036 | } | ||
1037 | |||
1038 | static void done(struct fusb300_ep *ep, struct fusb300_request *req, | 977 | static void done(struct fusb300_ep *ep, struct fusb300_request *req, |
1039 | int status) | 978 | int status) |
1040 | { | 979 | { |
@@ -1058,8 +997,8 @@ static void done(struct fusb300_ep *ep, struct fusb300_request *req, | |||
1058 | fusb300_set_cxdone(ep->fusb300); | 997 | fusb300_set_cxdone(ep->fusb300); |
1059 | } | 998 | } |
1060 | 999 | ||
1061 | void fusb300_fill_idma_prdtbl(struct fusb300_ep *ep, | 1000 | static void fusb300_fill_idma_prdtbl(struct fusb300_ep *ep, dma_addr_t d, |
1062 | struct fusb300_request *req) | 1001 | u32 len) |
1063 | { | 1002 | { |
1064 | u32 value; | 1003 | u32 value; |
1065 | u32 reg; | 1004 | u32 reg; |
@@ -1071,10 +1010,9 @@ void fusb300_fill_idma_prdtbl(struct fusb300_ep *ep, | |||
1071 | reg &= FUSB300_EPPRD0_H; | 1010 | reg &= FUSB300_EPPRD0_H; |
1072 | } while (reg); | 1011 | } while (reg); |
1073 | 1012 | ||
1074 | iowrite32((u32) req->req.buf, ep->fusb300->reg + | 1013 | iowrite32(d, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W1(ep->epnum)); |
1075 | FUSB300_OFFSET_EPPRD_W1(ep->epnum)); | ||
1076 | 1014 | ||
1077 | value = FUSB300_EPPRD0_BTC(req->req.length) | FUSB300_EPPRD0_H | | 1015 | value = FUSB300_EPPRD0_BTC(len) | FUSB300_EPPRD0_H | |
1078 | FUSB300_EPPRD0_F | FUSB300_EPPRD0_L | FUSB300_EPPRD0_I; | 1016 | FUSB300_EPPRD0_F | FUSB300_EPPRD0_L | FUSB300_EPPRD0_I; |
1079 | iowrite32(value, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W0(ep->epnum)); | 1017 | iowrite32(value, ep->fusb300->reg + FUSB300_OFFSET_EPPRD_W0(ep->epnum)); |
1080 | 1018 | ||
@@ -1111,13 +1049,12 @@ static void fusb300_set_idma(struct fusb300_ep *ep, | |||
1111 | struct fusb300_request *req) | 1049 | struct fusb300_request *req) |
1112 | { | 1050 | { |
1113 | dma_addr_t d; | 1051 | dma_addr_t d; |
1114 | u8 *tmp = NULL; | ||
1115 | 1052 | ||
1116 | d = dma_map_single(NULL, req->req.buf, req->req.length, DMA_TO_DEVICE); | 1053 | d = dma_map_single(NULL, req->req.buf, req->req.length, DMA_TO_DEVICE); |
1117 | 1054 | ||
1118 | if (dma_mapping_error(NULL, d)) { | 1055 | if (dma_mapping_error(NULL, d)) { |
1119 | kfree(req->req.buf); | ||
1120 | printk(KERN_DEBUG "dma_mapping_error\n"); | 1056 | printk(KERN_DEBUG "dma_mapping_error\n"); |
1057 | return; | ||
1121 | } | 1058 | } |
1122 | 1059 | ||
1123 | dma_sync_single_for_device(NULL, d, req->req.length, DMA_TO_DEVICE); | 1060 | dma_sync_single_for_device(NULL, d, req->req.length, DMA_TO_DEVICE); |
@@ -1125,17 +1062,11 @@ static void fusb300_set_idma(struct fusb300_ep *ep, | |||
1125 | fusb300_enable_bit(ep->fusb300, FUSB300_OFFSET_IGER0, | 1062 | fusb300_enable_bit(ep->fusb300, FUSB300_OFFSET_IGER0, |
1126 | FUSB300_IGER0_EEPn_PRD_INT(ep->epnum)); | 1063 | FUSB300_IGER0_EEPn_PRD_INT(ep->epnum)); |
1127 | 1064 | ||
1128 | tmp = req->req.buf; | 1065 | fusb300_fill_idma_prdtbl(ep, d, req->req.length); |
1129 | req->req.buf = (u8 *)d; | ||
1130 | |||
1131 | fusb300_fill_idma_prdtbl(ep, req); | ||
1132 | /* check idma is done */ | 1066 | /* check idma is done */ |
1133 | fusb300_wait_idma_finished(ep); | 1067 | fusb300_wait_idma_finished(ep); |
1134 | 1068 | ||
1135 | req->req.buf = tmp; | 1069 | dma_unmap_single(NULL, d, req->req.length, DMA_TO_DEVICE); |
1136 | |||
1137 | if (d) | ||
1138 | dma_unmap_single(NULL, d, req->req.length, DMA_TO_DEVICE); | ||
1139 | } | 1070 | } |
1140 | 1071 | ||
1141 | static void in_ep_fifo_handler(struct fusb300_ep *ep) | 1072 | static void in_ep_fifo_handler(struct fusb300_ep *ep) |
@@ -1143,14 +1074,8 @@ static void in_ep_fifo_handler(struct fusb300_ep *ep) | |||
1143 | struct fusb300_request *req = list_entry(ep->queue.next, | 1074 | struct fusb300_request *req = list_entry(ep->queue.next, |
1144 | struct fusb300_request, queue); | 1075 | struct fusb300_request, queue); |
1145 | 1076 | ||
1146 | if (req->req.length) { | 1077 | if (req->req.length) |
1147 | #if 0 | ||
1148 | fusb300_set_ep_bycnt(ep, req->req.length); | ||
1149 | fusb300_wrfifo(ep, req); | ||
1150 | #else | ||
1151 | fusb300_set_idma(ep, req); | 1078 | fusb300_set_idma(ep, req); |
1152 | #endif | ||
1153 | } | ||
1154 | done(ep, req, 0); | 1079 | done(ep, req, 0); |
1155 | } | 1080 | } |
1156 | 1081 | ||