usb: gadget: fotg210: workaround & new hardware support
cover usb: gadget: fotg210: workaround & new hardware support
From: Kuo-Jung Su <[email protected]>
1. It's known that EP0 fifo empty indication is not reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
2. Since hardware revision 1.11.0, some fields of interrupt status registers are now write-1-clear.
Kuo-Jung Su (2):
usb: gadget: fotg210: add w1c interrupt status support
usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
drivers/usb/gadget/fotg210.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
--
1.7.9.5
PATCH 1/2 usb: gadget: fotg210: add w1c interrupt status support
From: Kuo-Jung Su <[email protected]>
Since hardware revision 1.11.0, the following interrupt status registers are now write-1-clear (w1c):
1. Interrupt Source Group 0 Register (0x144) (EP0 Abort: BIT5)
2. Interrupt Source Group 2 Register (0x14C) (All bits)
--- drivers/usb/gadget/fotg210.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/usb/gadget/fotg210.c +8 -2
@@ -847,8 +847,11 @@ int usb_gadget_handle_interrupts(void)/* CX interrupts */ if (gisr &GISR_GRP0 ) { st =readl (®s->gisr0); +#ifdef CONFIG_USB_GADGET_FOTG210_ISRW1C +writel (st &GISR0_CXABORT , ®s->gisr0); +#else writel (0 , ®s->gisr0); - +#endif if (st &GISR0_CXERR )printf ("fotg210: cmd error\n" );
@@ -873,8 +876,11 @@ int usb_gadget_handle_interrupts(void)/* Device Status Interrupts */ if (gisr &GISR_GRP2 ) { st =readl (®s->gisr2); +#ifdef CONFIG_USB_GADGET_FOTG210_ISRW1C +writel (st, ®s->gisr2); +#else writel (0 , ®s->gisr2); - +#endif if (st &GISR2_RESET )printf ("fotg210: reset by host\n" );else if (st &GISR2_SUSPEND )
Signature · 1 line
1.7.9.5
PATCH v2 1/2 usb: gadget: fotg210: add w1c interrupt status support
Quoted 4 lines · Kuo-Jung Su
From: Kuo-Jung Su <[email protected]>
Since hardware revision 1.11.0, the following interrupt status registers are now write-1-clear (w1c):
What did they look like before ?
Quoted 14 lines
1. Interrupt Source Group 0 Register (
0x144) (EP0 Abort: BIT5)
2. Interrupt Source Group 2 Register (0x14C) (All bits)Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>--- drivers/usb/gadget/fotg210.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/usb/gadget/fotg210.c +0
-0
drivers/usb/gadget/fotg210.c int usb_gadget_handle_interrupts(void) · line 850
Quoted 4 lines
drivers/usb/gadget/fotg210.c +1
-0@@ -847,8 +847,11 @@ int usb_gadget_handle_interrupts(void)/* CX interrupts */ if (gisr &GISR_GRP0 ) { st =readl (®s->gisr0); +#ifdef CONFIG_USB_GADGET_FOTG210_ISRW1C
Can we not get rid of this ifdef somehow please ? Like detect the revision on- the-fly and handle the bit accordingly or such ?
Best regards,
Marek Vasut
PATCH 1/2 usb: gadget: fotg210: add w1c interrupt status support
2013/12/18 Marek Vasut <[email protected]>:
Quoted 8 lines · Kuo-Jung Su
Quoted 4 lines
From: Kuo-Jung Su <[email protected]>
Since hardware revision 1.11.0, the following interrupt status registers are now write-1-clear (w1c):
What did they look like before ?
They were r/w registers. i.e., software must write a zero to clear the status. I'll add the comment in next version.
Quoted 9 lines
Quoted 9 lines
1. Interrupt Source Group 0 Register (
0x144) (EP0 Abort: BIT5)
2. Interrupt Source Group 2 Register (0x14C) (All bits)Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>--- drivers/usb/gadget/fotg210.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
Quoted 13 lines
drivers/usb/gadget/fotg210.c int usb_gadget_handle_interrupts(void) · line 850
Quoted 9 lines
drivers/usb/gadget/fotg210.c +1
-0@@ -847,8 +847,11 @@ int usb_gadget_handle_interrupts(void)/* CX interrupts */ if (gisr &GISR_GRP0 ) { st =readl (®s->gisr0); +#ifdef CONFIG_USB_GADGET_FOTG210_ISRW1C Can we not get rid of this ifdef somehow please ? Like detect the revision on- the-fly and handle the bit accordingly or such ?
Unfortunately there is no revision id register in this hardware, so I have to do it manually.
Quoted 2 lines
Best regards,
Marek Vasut
Signature · 2 lines
Best wishes, Kuo-Jung Su
PATCH v2 1/2 usb: gadget: fotg210: add w1c interrupt status support
Quoted 11 lines · Kuo-Jung Su
2013/12/18 Marek Vasut <[email protected]>:
Quoted 7 lines · Kuo-Jung Su
Quoted 5 lines
From: Kuo-Jung Su <[email protected]>
Since hardware revision 1.11.0, the following interrupt status registers
are now write-1-clear (w1c):
What did they look like before ?
They were r/w registers. i.e., software must write a zero to clear the status. I'll add the comment in next version.
OK.
Quoted 21 lines
Quoted 21 lines
Quoted 21 lines
1. Interrupt Source Group 0 Register (
0x144) (EP0 Abort: BIT5)
2. Interrupt Source Group 2 Register (0x14C) (All bits)Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>---
drivers/usb/gadget/fotg210.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/usb/gadget/fotg210.c +0
-0@@ -847,8 +847,11 @@ int usb_gadget_handle_interrupts(void)/* CX interrupts */ if (gisr &GISR_GRP0 ) { st =readl (®s->gisr0);
Quoted 7 lines
Quoted 4 lines
drivers/usb/gadget/fotg210.c int usb_gadget_handle_interrupts(void) · line 853
Quoted 1 line
drivers/usb/gadget/fotg210.c +1
-0+#ifdef CONFIG_USB_GADGET_FOTG210_ISRW1C Can we not get rid of this ifdef somehow please ? Like detect the revision on- the-fly and handle the bit accordingly or such ?
Unfortunately there is no revision id register in this hardware, so I have to do it manually.
So what would happen if you write 1, then write 0 into them ? ;-) Won't that handle both cases? Writing one will make sure the clean them on new hardware, writing zero afterwards will clean them on old hardware.
Best regards,
Marek Vasut
PATCH 1/2 usb: gadget: fotg210: add w1c interrupt status support
2013/12/19 Marek Vasut <[email protected]>:
Quoted 41 lines · Kuo-Jung Su
Quoted 11 lines
2013/12/18 Marek Vasut <[email protected]>:
Quoted 7 lines · Kuo-Jung Su
Quoted 5 lines
From: Kuo-Jung Su <[email protected]>
Since hardware revision 1.11.0, the following interrupt status registers
are now write-1-clear (w1c):
What did they look like before ?
They were r/w registers. i.e., software must write a zero to clear the status. I'll add the comment in next version.
OK.
Quoted 26 lines
Quoted 25 lines
Quoted 15 lines
1. Interrupt Source Group 0 Register (
0x144) (EP0 Abort: BIT5)
2. Interrupt Source Group 2 Register (0x14C) (All bits)Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>---
drivers/usb/gadget/fotg210.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/usb/gadget/fotg210.c +0
-0drivers/usb/gadget/fotg210.c int usb_gadget_handle_interrupts(void) · line 853
Quoted 7 lines
drivers/usb/gadget/fotg210.c +1
-0@@ -847,8 +847,11 @@ int usb_gadget_handle_interrupts(void)/* CX interrupts */ if (gisr &GISR_GRP0 ) { st =readl (®s->gisr0); +#ifdef CONFIG_USB_GADGET_FOTG210_ISRW1C Can we not get rid of this ifdef somehow please ? Like detect the revision on- the-fly and handle the bit accordingly or such ?
Quoted 7 lines
Quoted 2 lines
Unfortunately there is no revision id register in this hardware, so I have to do it manually.
So what would happen if you write 1, then write 0 into them ? ;-) Won't that handle both cases? Writing one will make sure the clean them on new hardware, writing zero afterwards will clean them on old hardware.
Good idea! I think it should work just fine.
I'll make sure if does work, and then prepare for the new patch.
Quoted 2 lines
Best regards,
Marek Vasut
Signature · 2 lines
Best wishes, Kuo-Jung Su
PATCH v2 1/2 usb: gadget: fotg210: add w1c interrupt status support
Quoted 46 lines · Kuo-Jung Su
2013/12/19 Marek Vasut <[email protected]>:
Quoted 45 lines · Kuo-Jung Su
Quoted 4 lines
2013/12/18 Marek Vasut <[email protected]>:
Quoted 3 lines · Kuo-Jung Su
Quoted 2 lines
From: Kuo-Jung Su <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Since hardware revision 1.11.0, the following interrupt status registers
are now write-1-clear (w1c):
What did they look like before ?
They were r/w registers. i.e., software must write a zero to clear the status. I'll add the comment in next version.
OK.
Quoted 28 lines
Quoted 19 lines
Quoted 19 lines
1. Interrupt Source Group 0 Register (
0x144) (EP0 Abort: BIT5)
2. Interrupt Source Group 2 Register (0x14C) (All bits)Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>---
drivers/usb/gadget/fotg210.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/fotg210.cindex 6e19db1..e3a61cc 100644drivers/usb/gadget/fotg210.c +0
-0@@ -847,8 +847,11 @@ int usb_gadget_handle_interrupts(void)/* CX interrupts */ if (gisr &GISR_GRP0 ) {Quoted 6 lines
drivers/usb/gadget/fotg210.c int usb_gadget_handle_interrupts(void)
Quoted 3 lines
drivers/usb/gadget/fotg210.c +1
-0st =readl (®s->gisr0); +#ifdef CONFIG_USB_GADGET_FOTG210_ISRW1C Can we not get rid of this ifdef somehow please ? Like detect the revision on- the-fly and handle the bit accordingly or such ?
Unfortunately there is no revision id register in this hardware, so I have to do it manually.
Quoted 6 lines
Quoted 3 lines
So what would happen if you write 1, then write 0 into them ? ;-) Won't that handle both cases? Writing one will make sure the clean them on new hardware, writing zero afterwards will clean them on old hardware.
Good idea! I think it should work just fine.
I'll make sure if does work, and then prepare for the new patch.
Thanks :)
Best regards,
Marek Vasut
PATCH 2/2 usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
In reply to Kuo-Jung SuFrom: Kuo-Jung Su <[email protected]>
Because the EP0 fifo empty indication is non-reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
This workaround should be applied to all hardware revisions.
--- drivers/usb/gadget/fotg210.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/fotg210.c +1 -0
@@ -245,6 +245,7 @@ static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req)if (ep->id ==0 ) {/* Wait until cx/ep0 fifo empty */ fotg210_cxwait (chip,CXFIFO_CXFIFOE ); +udelay_masked (1 );writel (DMAFIFO_CX , ®s->dma_fifo); }else {/* Wait until epx fifo empty */
Signature · 1 line
1.7.9.5
PATCH v2 2/2 usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
Quoted 19 lines · Kuo-Jung Su
From: Kuo-Jung Su <[email protected]>
Because the EP0 fifo empty indication is non-reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
This workaround should be applied to all hardware revisions.
Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>--- drivers/usb/gadget/fotg210.c | 1 + 1 file changed, 1 insertion(+)drivers/usb/gadget/fotg210.c +0
-0
drivers/usb/gadget/fotg210.c static int fotg210_dma(struct fotg210_ep *ep, struct · line 248
Quoted 4 lines
drivers/usb/gadget/fotg210.c +1
-0@@ -245,6 +245,7 @@ static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) if (ep->id == 0) {/* Wait until cx/ep0 fifo empty */ fotg210_cxwait (chip,CXFIFO_CXFIFOE ); +udelay_masked (1 );
Why don't you use regular udelay() here please ? Also, how exactly does the delay help solving the unreliability problem please?
drivers/usb/gadget/fotg210.c static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) · line 251
Quoted 3 lines
drivers/usb/gadget/fotg210.c +0
-0writel (DMAFIFO_CX , ®s->dma_fifo); }else {/* Wait until epx fifo empty */
Best regards,
Marek Vasut
PATCH 2/2 usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
2013/12/18 Marek Vasut <[email protected]>:
Quoted 15 lines · Kuo-Jung Su
Quoted 14 lines
From: Kuo-Jung Su <[email protected]>
Because the EP0 fifo empty indication is non-reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
This workaround should be applied to all hardware revisions.
Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>--- drivers/usb/gadget/fotg210.c | 1 + 1 file changed, 1 insertion(+)
Quoted 13 lines
drivers/usb/gadget/fotg210.c static int fotg210_dma(struct fotg210_ep *ep, struct · line 248
Quoted 9 lines
drivers/usb/gadget/fotg210.c +1
-0@@ -245,6 +245,7 @@ static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) if (ep->id == 0) {/* Wait until cx/ep0 fifo empty */ fotg210_cxwait (chip,CXFIFO_CXFIFOE ); +udelay_masked (1 );Why don't you use regular
udelay()here please ? Also, how exactly does the delay help solving the unreliability problem please?
1. No specific reason at all, I'll use regular udelay() in next version. :)
2. The fifo size of ep0 is 64 bytes, and my driver is supposed to make sure the fifo empty
before filling up the fifo. However there is a hardware bug that
the fifo empty indication is somehow
a bit earlier than fifo reset. So if I don't add an extra delay
here, the data might be corrupted (i.e., 1 byte missing.)
And after a couple of tests, it looks like that 1 usec is good
enough for this.
Quoted 6 lines
drivers/usb/gadget/fotg210.c static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) · line 251
Quoted 3 lines
drivers/usb/gadget/fotg210.c +0
-0writel (DMAFIFO_CX , ®s->dma_fifo); }else {/* Wait until epx fifo empty */ Best regards,
Marek Vasut
Signature · 2 lines
Best wishes, Kuo-Jung Su
PATCH v2 2/2 usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
Quoted 34 lines · Kuo-Jung Su
2013/12/18 Marek Vasut <[email protected]>:
Quoted 23 lines · Kuo-Jung Su
Quoted 22 lines
From: Kuo-Jung Su <[email protected]>
Because the EP0 fifo empty indication is non-reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
This workaround should be applied to all hardware revisions.
Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>---
drivers/usb/gadget/fotg210.c | 1 + 1 file changed, 1 insertion(+)drivers/usb/gadget/fotg210.c +0
-0@@ -245,6 +245,7 @@ static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) if (ep->id == 0) {Quoted 7 lines
drivers/usb/gadget/fotg210.c static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) · line 248
Quoted 4 lines
drivers/usb/gadget/fotg210.c +1
-0/* Wait until cx/ep0 fifo empty */ fotg210_cxwait (chip,CXFIFO_CXFIFOE ); +udelay_masked (1 );Why don't you use regular
udelay()here please ? Also, how exactly does the delay help solving the unreliability problem please?1. No specific reason at all, I'll use regular
udelay()in next version. :)
Quoted 8 lines
2. The fifo size of ep0 is 64 bytes, and my driver is supposed to make sure the fifo empty
before filling up the fifo. However there is a hardware bug that
the fifo empty indication is somehow
a bit earlier than fifo reset. So if I don't add an extra delay
here, the data might be corrupted (i.e., 1 byte missing.)
And after a couple of tests, it looks like that 1 usec is good
enough for this.
Ick, but I guess you guys know the IP blocks' sourcecode.
Best regards,
Marek Vasut
PATCH 2/2 usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
2013/12/19 Marek Vasut <[email protected]>:
Quoted 44 lines · Kuo-Jung Su
Quoted 34 lines
2013/12/18 Marek Vasut <[email protected]>:
Quoted 23 lines · Kuo-Jung Su
Quoted 22 lines
From: Kuo-Jung Su <[email protected]>
Because the EP0 fifo empty indication is non-reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
This workaround should be applied to all hardware revisions.
Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>---
drivers/usb/gadget/fotg210.c | 1 + 1 file changed, 1 insertion(+)drivers/usb/gadget/fotg210.c +0
-0@@ -245,6 +245,7 @@ static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) if (ep->id == 0) {Quoted 7 lines
drivers/usb/gadget/fotg210.c static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) · line 248
Quoted 4 lines
drivers/usb/gadget/fotg210.c +1
-0/* Wait until cx/ep0 fifo empty */ fotg210_cxwait (chip,CXFIFO_CXFIFOE ); +udelay_masked (1 );Why don't you use regular
udelay()here please ? Also, how exactly does the delay help solving the unreliability problem please?1. No specific reason at all, I'll use regular
udelay()in next version. :)Quoted 8 lines
2. The fifo size of ep0 is 64 bytes, and my driver is supposed to make sure the fifo empty
before filling up the fifo. However there is a hardware bug that
the fifo empty indication is somehow
a bit earlier than fifo reset. So if I don't add an extra delay
here, the data might be corrupted (i.e., 1 byte missing.)
And after a couple of tests, it looks like that 1 usec is good
enough for this.
Quoted 2 lines
Ick, but I guess you guys know the IP blocks' sourcecode.
Yes, but I don't have the access permission , and I'm not a member of the IP verification team......
Anyway I'll try to call the IP owner see if he's willing to do FPGA verification.
Quoted 2 lines
Best regards,
Marek Vasut
Signature · 2 lines
Best wishes, Kuo-Jung Su
PATCH v2 2/2 usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
Quoted 52 lines · Kuo-Jung Su
2013/12/19 Marek Vasut <[email protected]>:
Quoted 51 lines · Kuo-Jung Su
Quoted 49 lines
2013/12/18 Marek Vasut <[email protected]>:
Quoted 23 lines · Kuo-Jung Su
Quoted 22 lines
From: Kuo-Jung Su <[email protected]>
Because the EP0 fifo empty indication is non-reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
This workaround should be applied to all hardware revisions.
Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>---
drivers/usb/gadget/fotg210.c | 1 + 1 file changed, 1 insertion(+)(quoted diff) +0
-0
b/drivers/usb/gadget/fotg210.cindex e3a61cc..14bfec6 100644drivers/usb/gadget/fotg210.c +0
-0@@ -245,6 +245,7 @@ static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) if (ep->id == 0) {Quoted 7 lines
drivers/usb/gadget/fotg210.c static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) · line 248
Quoted 4 lines
drivers/usb/gadget/fotg210.c +1
-0/* Wait until cx/ep0 fifo empty */ fotg210_cxwait (chip,CXFIFO_CXFIFOE ); +udelay_masked (1 );Why don't you use regular
udelay()here please ? Also, how exactly does the delay help solving the unreliability problem please?1. No specific reason at all, I'll use regular
udelay()in next version. :)2. The fifo size of ep0 is 64 bytes, and my driver is supposed to make sure the fifo empty
before filling up the fifo. However there is a hardware bug that
the fifo empty indication is somehow
a bit earlier than fifo reset. So if I don't add an extra delay
here, the data might be corrupted (i.e., 1 byte missing.)
And after a couple of tests, it looks like that 1 usec is good
enough for this.
Quoted 7 lines
Quoted 1 line
Ick, but I guess you guys know the IP blocks' sourcecode.
Yes, but I don't have the access permission , and I'm not a member of the IP verification team......
Anyway I'll try to call the IP owner see if he's willing to do FPGA verification.
Would be nice, but I dont mind picking it even without such confirmation. Thanks!
Best regards,
Marek Vasut
PATCH 2/2 usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
2013/12/19 Marek Vasut <[email protected]>:
Quoted 58 lines · Kuo-Jung Su
Quoted 57 lines
2013/12/19 Marek Vasut <[email protected]>:
Quoted 45 lines · Kuo-Jung Su
Quoted 44 lines
2013/12/18 Marek Vasut <[email protected]>:
Quoted 23 lines · Kuo-Jung Su
Quoted 22 lines
From: Kuo-Jung Su <[email protected]>
Because the EP0 fifo empty indication is non-reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
This workaround should be applied to all hardware revisions.
Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>---
drivers/usb/gadget/fotg210.c | 1 + 1 file changed, 1 insertion(+)(quoted diff) +0
-0
b/drivers/usb/gadget/fotg210.cindex e3a61cc..14bfec6 100644drivers/usb/gadget/fotg210.c +0
-0@@ -245,6 +245,7 @@ static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) if (ep->id == 0) {Quoted 7 lines
drivers/usb/gadget/fotg210.c static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) · line 248
Quoted 4 lines
drivers/usb/gadget/fotg210.c +1
-0/* Wait until cx/ep0 fifo empty */ fotg210_cxwait (chip,CXFIFO_CXFIFOE ); +udelay_masked (1 );Why don't you use regular
udelay()here please ? Also, how exactly does the delay help solving the unreliability problem please?1. No specific reason at all, I'll use regular
udelay()in next version. :)2. The fifo size of ep0 is 64 bytes, and my driver is supposed to make sure the fifo empty
before filling up the fifo. However there is a hardware bug that
the fifo empty indication is somehow
a bit earlier than fifo reset. So if I don't add an extra delay
Quoted 7 lines
Quoted 5 lines
here, the data might be corrupted (i.e., 1 byte missing.)
And after a couple of tests, it looks like that 1 usec is good
enough for this.
Ick, but I guess you guys know the IP blocks' sourcecode.
Yes, but I don't have the access permission , and I'm not a member of the IP verification team......
Quoted 8 lines
Quoted 2 lines
Anyway I'll try to call the IP owner see if he's willing to do FPGA verification.
Would be nice, but I dont mind picking it even without such confirmation. Thanks!
Best regards,
Marek Vasut
Sorry, this bug is schedule as a lowest priority.
Because I'm the only one who have this issue in Faraday. i.e., I'm the only one to configure the FOTG210 as an Ethernet gadget, while others always configure it as an bulk-only mass storage gadget. And only under Ethernet gadget mode, we'll have to handle EP0 packets with size greater than 64Bytes.
So I can't clearly figure out the root cause of the buggy Faraday FOTG210.
Signature · 2 lines
Best wishes, Kuo-Jung Su
PATCH v2 2/2 usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
Quoted 70 lines · Kuo-Jung Su
2013/12/19 Marek Vasut <[email protected]>:
Quoted 60 lines · Kuo-Jung Su
Quoted 59 lines
2013/12/19 Marek Vasut <[email protected]>:
Quoted 47 lines · Kuo-Jung Su
Quoted 46 lines
2013/12/18 Marek Vasut <[email protected]>:
Quoted 23 lines · Kuo-Jung Su
Quoted 22 lines
From: Kuo-Jung Su <[email protected]>
Because the EP0 fifo empty indication is non-reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
This workaround should be applied to all hardware revisions.
Signed-off-by Kuo-Jung Su <[email protected]>CC Marek Vasut <[email protected]>---
drivers/usb/gadget/fotg210.c | 1 + 1 file changed, 1 insertion(+)(quoted diff) +0
-0
b/drivers/usb/gadget/fotg210.cindex e3a61cc..14bfec6 100644drivers/usb/gadget/fotg210.c +0
-0@@ -245,6 +245,7 @@ static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req) if (ep->id == 0) {Quoted 7 lines
drivers/usb/gadget/fotg210.c static int fotg210_dma(struct fotg210_ep *ep, · line 250
Quoted 4 lines
drivers/usb/gadget/fotg210.c +1
-0/* Wait until cx/ep0 fifo empty */ fotg210_cxwait (chip,CXFIFO_CXFIFOE ); +udelay_masked (1 );Why don't you use regular
udelay()here please ? Also, how exactly does the delay help solving the unreliability problem please?1. No specific reason at all, I'll use regular
udelay()in next version.:)
2. The fifo size of ep0 is 64 bytes, and my driver is supposed to make sure the fifo empty
before filling up the fifo. However there is a hardware bug that
the fifo empty indication is somehow
a bit earlier than fifo reset. So if I don't add an extra delay
Quoted 7 lines
Quoted 5 lines
here, the data might be corrupted (i.e., 1 byte missing.)
And after a couple of tests, it looks like that 1 usec is good
enough for this.
Ick, but I guess you guys know the IP blocks' sourcecode.
Yes, but I don't have the access permission , and I'm not a member of the IP verification team......
Quoted 8 lines
Quoted 2 lines
Anyway I'll try to call the IP owner see if he's willing to do FPGA verification.
Would be nice, but I dont mind picking it even without such confirmation. Thanks!
Best regards,
Marek Vasut
Quoted 8 lines
Sorry, this bug is schedule as a lowest priority.
Because I'm the only one who have this issue in Faraday. i.e., I'm the only one to configure the FOTG210 as an Ethernet gadget, while others always configure it as an bulk-only mass storage gadget. And only under Ethernet gadget mode, we'll have to handle EP0 packets with size greater than 64Bytes.So I can't clearly figure out the root cause of the buggy Faraday FOTG210.
OK, don't worry about it. Thanks for checking!
Best regards,
v2 cover usb: gadget: fotg210: workaround & new hardware support
In reply to Kuo-Jung SuFrom: Kuo-Jung Su <[email protected]>
1. It's known that EP0 fifo empty indication is not reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
2. Since hardware revision 1.11.0, some fields of interrupt status registers are now write-1-clear.
Changes for v2:
- usb: gadget: fotg210: add w1c interrupt status support:
By writting 1 then 0 to get rid of the use of CONFIG_USB_GADGET_FOTG210_ISRW1C.
Thanks for Marek's comments.
- usb: gadget: fotg210: EP0 fifo empty indication is non-reliable udelay_masked() -> udelay(), and patch comment updates.
Kuo-Jung Su (2):
usb: gadget: fotg210: add w1c interrupt status support
usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
drivers/usb/gadget/fotg210.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
--
1.7.9.5
PATCH v2 1/2 usb: gadget: fotg210: add w1c interrupt status support
From: Kuo-Jung Su <[email protected]>
Since hardware revision 1.11.0, the following interrupt status registers are now W1C (i.e., write 1 clear):
1. Interrupt Source Group 0 Register (0x144) (EP0 Abort: BIT5)
2. Interrupt Source Group 2 Register (0x14C) (All bits)
And before revision 1.11.0, these registers are all R/W. Which means software must write a 0 to clear the status.
---
Changes for v2:
- By writting 1 then 0 to get rid of the use of CONFIG_USB_GADGET_FOTG210_ISRW1C. Thanks for Marek's comments.
drivers/usb/gadget/fotg210.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/usb/gadget/fotg210.c +14 -0
@@ -847,6 +847,13 @@ int usb_gadget_handle_interrupts(void)/* CX interrupts */ if (gisr &GISR_GRP0 ) { st =readl (®s->gisr0); +/* +* Write 1 and then 0 works for both W1C & RW. +* +* HW v1.11.0+: It's a W1C register (write 1 clear) +* HW v1.10.0-: It's a R/W register (write 0 clear) +*/ +writel (st &GISR0_CXABORT , ®s->gisr0);writel (0 , ®s->gisr0);if (st &GISR0_CXERR )
@@ -873,6 +880,13 @@ int usb_gadget_handle_interrupts(void)/* Device Status Interrupts */ if (gisr &GISR_GRP2 ) { st =readl (®s->gisr2); +/* +* Write 1 and then 0 works for both W1C & RW. +* +* HW v1.11.0+: It's a W1C register (write 1 clear) +* HW v1.10.0-: It's a R/W register (write 0 clear) +*/ +writel (st, ®s->gisr2);writel (0 , ®s->gisr2);if (st &GISR2_RESET )
--
1.7.9.5
PATCH v2 2/2 usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
In reply to Kuo-Jung SuFrom: Kuo-Jung Su <[email protected]>
The fifo size of ep0 is 64 bytes, and if the packet size grater than 64 bytes, the driver would have to fill up the fifo multiple times, and before filling up the fifo, the driver should make sure the fifo is empty by checking fifo empty indication.
However there is a hardware bug that the fifo empty indication is somehow a bit earlier than fifo reset. So if I don't add an extra delay here, the data might be corrupted. (i.e., 1 byte missing)
After a couple of tests, it truns out that 1 usec is good enough.
This workaround should be applied to all hardware revisions.
---
Changes for v2:
- udelay_masked() -> udelay(), and patch comment updates.
drivers/usb/gadget/fotg210.c | 1 + 1 file changed, 1 insertion(+)
drivers/usb/gadget/fotg210.c +1 -0
@@ -245,6 +245,7 @@ static int fotg210_dma(struct fotg210_ep *ep, struct fotg210_request *req)if (ep->id ==0 ) {/* Wait until cx/ep0 fifo empty */ fotg210_cxwait (chip,CXFIFO_CXFIFOE ); +udelay (1 );writel (DMAFIFO_CX , ®s->dma_fifo); }else {/* Wait until epx fifo empty */
--
1.7.9.5
Marek Vasut
Appliedv2 cover usb: gadget: fotg210: workaround & new hardware support
In reply to Kuo-Jung SuQuoted 17 lines · Kuo-Jung Su
From: Kuo-Jung Su <[email protected]>
1. It's known that EP0 fifo empty indication is not reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
2. Since hardware revision 1.11.0, some fields of interrupt status registers are now write-1-clear.
Changes for v2:
- usb: gadget: fotg210: add w1c interrupt status support:
By writting 1 then 0 to get rid of the use ofCONFIG_USB_GADGET_FOTG210_ISRW1C.
Thanks for Marek's comments.
- usb: gadget: fotg210: EP0 fifo empty indication is non-reliableudelay_masked()->udelay(), and patch comment updates.
Quoted 6 lines
Kuo-Jung Su (2):
usb: gadget: fotg210: add w1c interrupt status support
usb: gadget: fotg210: EP0 fifo empty indication is non-reliabledrivers/usb/gadget/fotg210.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
Applied both , thanks!
btw. is this FOTG210 stuff used by any platform or is this just a dead code ?
Best regards,
Marek Vasut
v2 cover usb: gadget: fotg210: workaround & new hardware support
2013/12/20 Marek Vasut <[email protected]>:
Quoted 22 lines · Kuo-Jung Su
Quoted 21 lines
From: Kuo-Jung Su <[email protected]>
1. It's known that EP0 fifo empty indication is not reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
2. Since hardware revision 1.11.0, some fields of interrupt status registers are now write-1-clear.
Changes for v2:
- usb: gadget: fotg210: add w1c interrupt status support:
By writting 1 then 0 to get rid of the use ofCONFIG_USB_GADGET_FOTG210_ISRW1C.
Thanks for Marek's comments.
- usb: gadget: fotg210: EP0 fifo empty indication is non-reliableudelay_masked()->udelay(), and patch comment updates.Kuo-Jung Su (2):
usb: gadget: fotg210: add w1c interrupt status support
usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
Quoted 7 lines
Quoted 2 lines
drivers/usb/gadget/fotg210.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)Applied both , thanks!
btw. is this FOTG210 stuff used by any platform or is this just a dead code ?
It's still an active IP, and the only USB 2.0 (host, device, otg) controller we have currently in Faraday.
It's used in upcoming Faraday A369 SoC patch set (I'm still waiting for the dependant NAND driver: ftnandc021 to be commited),
and the new SoC platforms (For politics reason, they won't be released by myself.) in year 2013.
Signature · 2 lines
Best wishes, Kuo-Jung Su
v2 cover usb: gadget: fotg210: workaround & new hardware support
Quoted 33 lines · Kuo-Jung Su
2013/12/20 Marek Vasut <[email protected]>:
Quoted 24 lines · Kuo-Jung Su
Quoted 23 lines
From: Kuo-Jung Su <[email protected]>
1. It's known that EP0 fifo empty indication is not reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
2. Since hardware revision 1.11.0, some fields of interrupt status registers are now write-1-clear.
Changes for v2:
- usb: gadget: fotg210: add w1c interrupt status support:
By writting 1 then 0 to get rid of the use ofCONFIG_USB_GADGET_FOTG210_ISRW1C.
Thanks for Marek's comments.- usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
udelay_masked()->udelay(), and patch comment updates.Kuo-Jung Su (2):
usb: gadget: fotg210: add w1c interrupt status support
usb: gadget: fotg210: EP0 fifo empty indication is non-reliableQuoted 7 lines
Quoted 2 lines
drivers/usb/gadget/fotg210.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)Applied both , thanks!
btw. is this FOTG210 stuff used by any platform or is this just a dead code ?
Quoted 8 lines
It's still an active IP, and the only USB 2.0 (host, device, otg) controller we have currently in Faraday.
It's used in upcoming Faraday A369 SoC patch set (I'm still waiting for the dependant NAND driver: ftnandc021 to be commited),
and the new SoC platforms (For politics reason, they won't be released by myself.) in year 2013.
OK, glad to see this won't be dead code soon. Next time, I suppose it'd be better to commit platform first, drivers afterwards, so we dont have dead code for an extended period of time.
Best regards,
Marek Vasut
v2 cover usb: gadget: fotg210: workaround & new hardware support
2013/12/23 Marek Vasut <[email protected]>:
Quoted 40 lines · Kuo-Jung Su
Quoted 39 lines
2013/12/20 Marek Vasut <[email protected]>:
Quoted 24 lines · Kuo-Jung Su
Quoted 23 lines
From: Kuo-Jung Su <[email protected]>
1. It's known that EP0 fifo empty indication is not reliable, an extra delay is necessary to avoid data corruption while handling packets with size greater than 64 bytes.
2. Since hardware revision 1.11.0, some fields of interrupt status registers are now write-1-clear.
Changes for v2:
- usb: gadget: fotg210: add w1c interrupt status support:
By writting 1 then 0 to get rid of the use ofCONFIG_USB_GADGET_FOTG210_ISRW1C.
Thanks for Marek's comments.- usb: gadget: fotg210: EP0 fifo empty indication is non-reliable
udelay_masked()->udelay(), and patch comment updates.Kuo-Jung Su (2):
usb: gadget: fotg210: add w1c interrupt status support
usb: gadget: fotg210: EP0 fifo empty indication is non-reliableQuoted 7 lines
Quoted 2 lines
drivers/usb/gadget/fotg210.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)Applied both , thanks!
btw. is this FOTG210 stuff used by any platform or is this just a dead code ?
It's still an active IP, and the only USB 2.0 (host, device, otg) controller we have currently in Faraday.
It's used in upcoming Faraday A369 SoC patch set (I'm still waiting for the dependant NAND driver: ftnandc021 to be commited),
Quoted 7 lines
Quoted 2 lines
and the new SoC platforms (For politics reason, they won't be released by myself.) in year 2013.
OK, glad to see this won't be dead code soon. Next time, I suppose it'd be better to commit platform first, drivers afterwards, so we dont have dead code for an extended period of time.
Got it, thanks
Signature · 2 lines
Best wishes, Kuo-Jung Su