aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>2011-07-06 20:58:43 -0400
committerFelipe Balbi <balbi@ti.com>2011-07-08 18:08:39 -0400
commitbb59dbff4e5fb0ac14e3ee47d3f688490f128155 (patch)
tree1bf92ae02fd2e0b9a29c09a1229216285a6415b1
parent8ca137562a79f573f822f5a84a4e56a0d8cc6792 (diff)
usb: gadget: m66592-udc: add function for external controller
M66592 has the pin of WR0 and WR1. So, if one write-pin of CPU connects to the pins, we have to change the setting of FIFOSEL register in the controller. If we don't change the setting, the controller cannot send the data of odd length. Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/gadget/m66592-udc.c4
-rw-r--r--drivers/usb/gadget/m66592-udc.h38
-rw-r--r--include/linux/usb/m66592.h2
3 files changed, 25 insertions, 19 deletions
diff --git a/drivers/usb/gadget/m66592-udc.c b/drivers/usb/gadget/m66592-udc.c
index 40c2f7a4f8f..5c9c04d7aa7 100644
--- a/drivers/usb/gadget/m66592-udc.c
+++ b/drivers/usb/gadget/m66592-udc.c
@@ -781,7 +781,7 @@ static void irq_ep0_write(struct m66592_ep *ep, struct m66592_request *req)
781 /* write fifo */ 781 /* write fifo */
782 if (req->req.buf) { 782 if (req->req.buf) {
783 if (size > 0) 783 if (size > 0)
784 m66592_write_fifo(m66592, ep->fifoaddr, buf, size); 784 m66592_write_fifo(m66592, ep, buf, size);
785 if ((size == 0) || ((size % ep->ep.maxpacket) != 0)) 785 if ((size == 0) || ((size % ep->ep.maxpacket) != 0))
786 m66592_bset(m66592, M66592_BVAL, ep->fifoctr); 786 m66592_bset(m66592, M66592_BVAL, ep->fifoctr);
787 } 787 }
@@ -827,7 +827,7 @@ static void irq_packet_write(struct m66592_ep *ep, struct m66592_request *req)
827 827
828 /* write fifo */ 828 /* write fifo */
829 if (req->req.buf) { 829 if (req->req.buf) {
830 m66592_write_fifo(m66592, ep->fifoaddr, buf, size); 830 m66592_write_fifo(m66592, ep, buf, size);
831 if ((size == 0) 831 if ((size == 0)
832 || ((size % ep->ep.maxpacket) != 0) 832 || ((size % ep->ep.maxpacket) != 0)
833 || ((bufsize != ep->ep.maxpacket) 833 || ((bufsize != ep->ep.maxpacket)
diff --git a/drivers/usb/gadget/m66592-udc.h b/drivers/usb/gadget/m66592-udc.h
index b85e05b2e97..7b93d579af3 100644
--- a/drivers/usb/gadget/m66592-udc.h
+++ b/drivers/usb/gadget/m66592-udc.h
@@ -561,11 +561,26 @@ static inline void m66592_write(struct m66592 *m66592, u16 val,
561 iowrite16(val, m66592->reg + offset); 561 iowrite16(val, m66592->reg + offset);
562} 562}
563 563
564static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat,
565 unsigned long offset)
566{
567 u16 tmp;
568 tmp = m66592_read(m66592, offset);
569 tmp = tmp & (~pat);
570 tmp = tmp | val;
571 m66592_write(m66592, tmp, offset);
572}
573
574#define m66592_bclr(m66592, val, offset) \
575 m66592_mdfy(m66592, 0, val, offset)
576#define m66592_bset(m66592, val, offset) \
577 m66592_mdfy(m66592, val, 0, offset)
578
564static inline void m66592_write_fifo(struct m66592 *m66592, 579static inline void m66592_write_fifo(struct m66592 *m66592,
565 unsigned long offset, 580 struct m66592_ep *ep,
566 void *buf, unsigned long len) 581 void *buf, unsigned long len)
567{ 582{
568 void __iomem *fifoaddr = m66592->reg + offset; 583 void __iomem *fifoaddr = m66592->reg + ep->fifoaddr;
569 584
570 if (m66592->pdata->on_chip) { 585 if (m66592->pdata->on_chip) {
571 unsigned long count; 586 unsigned long count;
@@ -591,26 +606,15 @@ static inline void m66592_write_fifo(struct m66592 *m66592,
591 iowrite16_rep(fifoaddr, buf, len); 606 iowrite16_rep(fifoaddr, buf, len);
592 if (odd) { 607 if (odd) {
593 unsigned char *p = buf + len*2; 608 unsigned char *p = buf + len*2;
609 if (m66592->pdata->wr0_shorted_to_wr1)
610 m66592_bclr(m66592, M66592_MBW_16, ep->fifosel);
594 iowrite8(*p, fifoaddr); 611 iowrite8(*p, fifoaddr);
612 if (m66592->pdata->wr0_shorted_to_wr1)
613 m66592_bset(m66592, M66592_MBW_16, ep->fifosel);
595 } 614 }
596 } 615 }
597} 616}
598 617
599static inline void m66592_mdfy(struct m66592 *m66592, u16 val, u16 pat,
600 unsigned long offset)
601{
602 u16 tmp;
603 tmp = m66592_read(m66592, offset);
604 tmp = tmp & (~pat);
605 tmp = tmp | val;
606 m66592_write(m66592, tmp, offset);
607}
608
609#define m66592_bclr(m66592, val, offset) \
610 m66592_mdfy(m66592, 0, val, offset)
611#define m66592_bset(m66592, val, offset) \
612 m66592_mdfy(m66592, val, 0, offset)
613
614#endif /* ifndef __M66592_UDC_H__ */ 618#endif /* ifndef __M66592_UDC_H__ */
615 619
616 620
diff --git a/include/linux/usb/m66592.h b/include/linux/usb/m66592.h
index cda9625e7df..a4ba31ab2fe 100644
--- a/include/linux/usb/m66592.h
+++ b/include/linux/usb/m66592.h
@@ -38,6 +38,8 @@ struct m66592_platdata {
38 /* (external controller only) one = 3.3V, zero = 1.5V */ 38 /* (external controller only) one = 3.3V, zero = 1.5V */
39 unsigned vif:1; 39 unsigned vif:1;
40 40
41 /* (external controller only) set one = WR0_N shorted to WR1_N */
42 unsigned wr0_shorted_to_wr1:1;
41}; 43};
42 44
43#endif /* __LINUX_USB_M66592_H */ 45#endif /* __LINUX_USB_M66592_H */