From 66670c17381b071e45c6101452e015b4903d98d4 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 27 Mar 2015 10:47:03 -0600 Subject: [PATCH] SAMV7 Ethernet+USB Updates --- arch/arm/src/samv7/sam_emac.c | 5 +++-- arch/arm/src/samv7/sam_usbdevhs.c | 15 +++++++++++---- configs/samv71-xult/README.txt | 26 ++++++++++++++++++++------ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/arch/arm/src/samv7/sam_emac.c b/arch/arm/src/samv7/sam_emac.c index f1955f14c7..4a34bb6d82 100644 --- a/arch/arm/src/samv7/sam_emac.c +++ b/arch/arm/src/samv7/sam_emac.c @@ -1041,7 +1041,7 @@ static int sam_buffer_allocate(struct sam_emac_s *priv) priv->xfrq[0].txdesc = priv->attr->tx0desc; priv->xfrq[0].ntxbuffers = priv->attr->ntxbuffers; priv->xfrq[0].rxdesc = priv->attr->rx0desc; - priv->xfrq[0].nrxbuffers = priv->attr->rtxbuffers; + priv->xfrq[0].nrxbuffers = priv->attr->nrxbuffers; priv->xfrq[0].txbuffer = priv->attr->tx0buffer; priv->xfrq[0].txbufsize = EMAC_TX_UNITSIZE; @@ -1602,7 +1602,7 @@ static int sam_recvframe(struct sam_emac_s *priv, int qid) { if (rxndx == priv->xfrq[qid].rxndx) { - nllvdbg("ERROR: No EOF (Invalid of buffers too small)\n"); + nllvdbg("ERROR: No EOF (Invalid or buffers too small)\n"); do { /* Give ownership back to the EMAC */ @@ -1624,6 +1624,7 @@ static int sam_recvframe(struct sam_emac_s *priv, int qid) } } while (rxndx != priv->xfrq[qid].rxndx); + return -EIO; } diff --git a/arch/arm/src/samv7/sam_usbdevhs.c b/arch/arm/src/samv7/sam_usbdevhs.c index 7dc7c9a1b1..a957b3fa29 100644 --- a/arch/arm/src/samv7/sam_usbdevhs.c +++ b/arch/arm/src/samv7/sam_usbdevhs.c @@ -4209,7 +4209,7 @@ static int sam_pullup(FAR struct usbdev_s *dev, bool enable) { /* DETACH=1: USBHS is detached, UTMI transceiver is suspended. */ - regval = sam_getreg(SAM_USBHS_DEVCTRL); + regval = sam_getreg(SAM_USBHS_DEVCTRL); regval |= USBHS_DEVCTRL_DETACH; sam_putreg(regval, SAM_USBHS_DEVCTRL); @@ -4533,13 +4533,20 @@ static void sam_hw_shutdown(struct sam_usbdev_s *priv) sam_putreg(USBHS_DEVINT_ALL, SAM_USBHS_DEVICR); - /* Disconnect the device */ + /* DETACH=1: USBHS is detached, UTMI transceiver is suspended. */ - sam_pullup(&priv->usbdev, false); + regval = sam_getreg(SAM_USBHS_DEVCTRL); + regval |= USBHS_DEVCTRL_DETACH; + sam_putreg(regval, SAM_USBHS_DEVCTRL); + + /* Freeze clocking */ + + regval = sam_getreg(SAM_USBHS_CTRL); + regval |= USBHS_CTRL_FRZCLK; + sam_putreg(regval, SAM_USBHS_CTRL); /* Disable USB hardware */ - regval = sam_getreg(SAM_USBHS_CTRL); regval &= ~USBHS_CTRL_USBE; sam_putreg(regval, SAM_USBHS_CTRL); diff --git a/configs/samv71-xult/README.txt b/configs/samv71-xult/README.txt index a52fe1ee18..6870cbefa7 100644 --- a/configs/samv71-xult/README.txt +++ b/configs/samv71-xult/README.txt @@ -83,15 +83,25 @@ The BASIC nsh configuration is fully function (as desribed below under (of course with appropriate mounting and unmounting). I all not sure of this and need to do more testing to characterize if the issue. - 5. There is not yet any support for the following board features: QSPI, USB, - EMAC, AT24, or WM8904 nor for any non-board features). Most of these - drivers will port easily from either the SAM3/4 or from the SAMA5Dx. + 5. There is not yet any support for the following board features: QSPI or WM8904. + Many drivers will port easily from either the SAM3/4 or from the SAMA5Dx. So there is still plenty to be done. 6. There has been a quick'n'dirty port of the SAMA5D4-EK Ethernet logic - for the SAMV71-XULT. There are still some cache-related issues to - be verified. No testing has yet been performed and so the driver should - be considered non-functional. + for the SAMV71-XULT. It does not work properly. Data on the line + appears to be corrupted, probably at the level of the PHY. + + 7. The USBHS device controller driver (DCD) is complete but non-functional. + At this point, work has stopped because I am stuck. The problem is that + bus events are not occurring: Nothing is detected by the USBHS when the + host is connected; no activity is seen on the bus by a USB analyzer when + the host is connected. Possibilities: (1) the pullups on DM and DP are + not working. This would prevent the host from detecting the presence of + the device. the DETACH bit is, however, being correctly cleared or (2) + some issue with clocking or configuration of the UTMI. I see nothing + wrong this this case. I have done extensive comparison of the Atmel + sample code and study of the data sheet, but I have not found the key to + solving this. Serial Console ============== @@ -926,3 +936,7 @@ Configuration sub-directories # CONFIG_ARMV7M_ITCM is not set : Support not yet in place # CONFIG_ARMV7M_DTCM is not set : Support not yet in place + + Stack sizes are also large to simplify the bring-up and should be + tuned for better memory usages. +