Date: Fri, 30 May 2014 16:44:04 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266892 - head/sys/dev/usb/controller Message-ID: <201405301644.s4UGi43p054926@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Fri May 30 16:44:03 2014 New Revision: 266892 URL: http://svnweb.freebsd.org/changeset/base/266892 Log: It appears the ISP/SAF1761 sometimes is busy when reading the status word of the PTD and simply returns a value of zero. Retry a few times before giving up. Sponsored by: DARPA, AFRL Modified: head/sys/dev/usb/controller/saf1761_otg.c Modified: head/sys/dev/usb/controller/saf1761_otg.c ============================================================================== --- head/sys/dev/usb/controller/saf1761_otg.c Fri May 30 15:46:10 2014 (r266891) +++ head/sys/dev/usb/controller/saf1761_otg.c Fri May 30 16:44:03 2014 (r266892) @@ -291,11 +291,23 @@ saf1761_host_channel_free(struct saf1761 } static uint32_t -saf1761_peek_host_memory_le_4(struct saf1761_otg_softc *sc, uint32_t offset) +saf1761_peek_host_status_le_4(struct saf1761_otg_softc *sc, uint32_t offset) { - SAF1761_WRITE_LE_4(sc, SOTG_MEMORY_REG, offset); - SAF1761_90NS_DELAY(sc); /* read prefetch time is 90ns */ - return (SAF1761_READ_LE_4(sc, offset)); + uint32_t x = 0; + while (1) { + uint32_t retval; + + SAF1761_WRITE_LE_4(sc, SOTG_MEMORY_REG, offset); + SAF1761_90NS_DELAY(sc); /* read prefetch time is 90ns */ + retval = SAF1761_READ_LE_4(sc, offset); + if (retval != 0) + return (retval); + if (++x == 8) { + DPRINTF("STAUS is zero at offset 0x%x\n", offset); + break; + } + } + return (0); } static void @@ -415,9 +427,7 @@ saf1761_host_setup_tx(struct saf1761_otg if (td->channel < SOTG_HOST_CHANNEL_MAX) { pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status); @@ -487,9 +497,7 @@ saf1761_host_bulk_data_rx(struct saf1761 pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status); @@ -591,9 +599,7 @@ saf1761_host_bulk_data_tx(struct saf1761 pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status); @@ -681,9 +687,7 @@ saf1761_host_intr_data_rx(struct saf1761 pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status); @@ -788,9 +792,7 @@ saf1761_host_intr_data_tx(struct saf1761 pdt_addr = SOTG_PTD(td->channel); - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); - if (status == 0) - status = saf1761_peek_host_memory_le_4(sc, pdt_addr + SOTG_PTD_DW3); + status = saf1761_peek_host_status_le_4(sc, pdt_addr + SOTG_PTD_DW3); DPRINTFN(5, "STATUS=0x%08x\n", status);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405301644.s4UGi43p054926>