summaryrefslogtreecommitdiff
path: root/nuttx/configs/sama5d3-xplained
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-08-17 14:07:53 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-08-17 14:07:53 -0600
commit1df5bbd77d50475fd2ecb33396a7e76212fbc21d (patch)
treedf11f258897f052a2344650f74671999623fdeef /nuttx/configs/sama5d3-xplained
parent6a084e35072ab635bf28f0dd91b2d390df9ec4c1 (diff)
downloadnuttx-1df5bbd77d50475fd2ecb33396a7e76212fbc21d.tar.gz
nuttx-1df5bbd77d50475fd2ecb33396a7e76212fbc21d.tar.bz2
nuttx-1df5bbd77d50475fd2ecb33396a7e76212fbc21d.zip
SAMA5 PHY: Add more debug instrumentation; Fix logic that would be used to disable PHY interrupts
Diffstat (limited to 'nuttx/configs/sama5d3-xplained')
-rw-r--r--nuttx/configs/sama5d3-xplained/src/sam_ethernet.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/nuttx/configs/sama5d3-xplained/src/sam_ethernet.c b/nuttx/configs/sama5d3-xplained/src/sam_ethernet.c
index 77b341ab8..4cb631495 100644
--- a/nuttx/configs/sama5d3-xplained/src/sam_ethernet.c
+++ b/nuttx/configs/sama5d3-xplained/src/sam_ethernet.c
@@ -39,6 +39,15 @@
#include <nuttx/config.h>
+/* Force verbose debug on in this file only to support unit-level testing. */
+
+#ifdef CONFIG_NETDEV_PHY_DEBUG
+# undef CONFIG_DEBUG_VERBOSE
+# define CONFIG_DEBUG_VERBOSE 1
+# undef CONFIG_DEBUG_NET
+# define CONFIG_DEBUG_NET 1
+#endif
+
#include <string.h>
#include <assert.h>
#include <debug.h>
@@ -69,6 +78,19 @@
# define SAMA5_EMAC_DEVNAME "eth1"
#endif
+/* Debug ********************************************************************/
+/* Extra, in-depth debug output that is only available if
+ * CONFIG_NETDEV_PHY_DEBUG us defined.
+ */
+
+#ifdef CONFIG_NETDEV_PHY_DEBUG
+# define phydbg dbg
+# define phylldbg lldbg
+#else
+# define phydbg(x...)
+# define phylldbg(x...)
+#endif
+
/************************************************************************************
* Private Data
************************************************************************************/
@@ -117,9 +139,10 @@ void weak_function sam_netinitialize(void)
* Speed Mode:100Mbps
* Nway Auto-Negotiation:Enable
*
- * The KSZ8051 PHY interrtup is available on PE30 INT_ETH1
+ * The KSZ8051 PHY interrupt is available on PE30 INT_ETH1
*/
+ phydbg("Configuring %08x\n", PIO_INT_ETH1);
sam_configpio(PIO_INT_ETH1);
#endif
@@ -136,6 +159,7 @@ void weak_function sam_netinitialize(void)
* The KSZ9021/31 interrupt is available on PB35 INT_GETH0
*/
+ phydbg("Configuring %08x\n", PIO_INT_ETH0);
sam_configpio(PIO_INT_ETH0);
#endif
}
@@ -204,9 +228,18 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler)
DEBUGASSERT(intf);
+ nvdbg("%s: handler=%p\n", intf, handler);
+#ifdef CONFIG_SAMA5_EMACA
+ phydbg("EMAC: devname=%s\n", SAMA5_EMAC_DEVNAME);
+#endif
+#ifdef CONFIG_SAMA5_GMAC
+ phydbg("GMAC: devname=%s\n", SAMA5_GMAC_DEVNAME);
+#endif
+
#ifdef CONFIG_SAMA5_EMACA
if (strcmp(intf, SAMA5_EMAC_DEVNAME) == 0)
{
+ phydbg("Select EMAC\n");
phandler = &g_emac_handler;
pinset = PIO_INT_ETH1;
irq = IRQ_INT_ETH1;
@@ -216,6 +249,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler)
#ifdef CONFIG_SAMA5_GMAC
if (strcmp(intf, SAMA5_GMAC_DEVNAME) == 0)
{
+ phydbg("Select GMAC\n");
phandler = &g_gmac_handler;
pinset = PIO_INT_ETH0;
irq = IRQ_INT_ETH0;
@@ -240,9 +274,21 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler)
/* Configure the interrupt */
- sam_pioirq(pinset);
- (void)irq_attach(irq, handler);
- sam_pioirqenable(irq);
+ if (handler)
+ {
+ phydbg("Configure pin: %08x\n", pinset);
+ sam_pioirq(pinset);
+
+ phydbg("Enable IRQ: %d\n", irq);
+ (void)irq_attach(irq, handler);
+ sam_pioirqenable(irq);
+ }
+ else
+ {
+ phydbg("Disable IRQ: %d\n", irq);
+ (void)irq_detach(irq);
+ sam_pioirqdisable(irq);
+ }
/* Return the old button handler (so that it can be restored) */