mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
arch_phy_irq: Now returns int instead of xcpt_t oldhandler. The oldhandler is useless after the changes to the interrupt argument. Also access an argument for the PHY interrupt. phy_notify.c driver changed to exploit new interrupt argument passing.
This commit is contained in:
@@ -629,6 +629,7 @@ struct tiva_ethmac_s
|
|||||||
struct work_s work; /* For deferring work to the work queue */
|
struct work_s work; /* For deferring work to the work queue */
|
||||||
#ifdef CONFIG_TIVA_PHY_INTERRUPTS
|
#ifdef CONFIG_TIVA_PHY_INTERRUPTS
|
||||||
xcpt_t handler; /* Attached PHY interrupt handler */
|
xcpt_t handler; /* Attached PHY interrupt handler */
|
||||||
|
void *arg; /* Argument that accompanies the interrupt */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* This holds the information visible to the NuttX network */
|
/* This holds the information visible to the NuttX network */
|
||||||
@@ -2165,9 +2166,9 @@ static int tiva_interrupt(int irq, FAR void *context, FAR void *arg)
|
|||||||
|
|
||||||
/* Dispatch to the registered handler */
|
/* Dispatch to the registered handler */
|
||||||
|
|
||||||
if (priv->handler)
|
if (priv->handler != NULL)
|
||||||
{
|
{
|
||||||
(void)priv->handler(irq, context, arg);
|
(void)priv->handler(irq, context, priv->arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -4254,23 +4255,22 @@ void up_netinitialize(void)
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* in order to detach and disable the PHY interrupt.
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
* enable - A function pointer that be unsed to enable or disable the
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_TIVA_PHY_INTERRUPTS
|
#ifdef CONFIG_TIVA_PHY_INTERRUPTS
|
||||||
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
|
||||||
|
phy_enable_t *enable)
|
||||||
{
|
{
|
||||||
struct tiva_ethmac_s *priv;
|
struct tiva_ethmac_s *priv;
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
xcpt_t oldhandler;
|
|
||||||
|
|
||||||
DEBUGASSERT(intf);
|
DEBUGASSERT(intf);
|
||||||
ninfo("%s: handler=%p\n", intf, handler);
|
ninfo("%s: handler=%p\n", intf, handler);
|
||||||
@@ -4290,10 +4290,10 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Get the old interrupt handler and save the new one */
|
/* Save the new interrupt handler information */
|
||||||
|
|
||||||
oldhandler = priv->handler;
|
|
||||||
priv->handler = handler;
|
priv->handler = handler;
|
||||||
|
priv->arg = arg;
|
||||||
|
|
||||||
/* Return with the interrupt disabled in any case */
|
/* Return with the interrupt disabled in any case */
|
||||||
|
|
||||||
@@ -4306,10 +4306,8 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
*enable = handler ? tiva_phy_intenable : NULL;
|
*enable = handler ? tiva_phy_intenable : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the old handler (so that it can be restored) */
|
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_TIVA_PHY_INTERRUPTS */
|
#endif /* CONFIG_TIVA_PHY_INTERRUPTS */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/sam4e-ek/src/sam_ethernet.c
|
* configs/sam4e-ek/src/sam_ethernet.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -83,14 +83,6 @@
|
|||||||
# define phyinfo(x...)
|
# define phyinfo(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Private Data
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_SAM34_GPIOD_IRQ
|
|
||||||
static xcpt_t g_emac_handler;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
@@ -184,23 +176,21 @@ void weak_function sam_netinitialize(void)
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* in order to detach and disable the PHY interrupt.
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
* enable - A function pointer that be unsed to enable or disable the
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SAM34_GPIOD_IRQ
|
#ifdef CONFIG_SAM34_GPIOD_IRQ
|
||||||
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
|
||||||
|
phy_enable_t *enable)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
xcpt_t *phandler;
|
|
||||||
xcpt_t oldhandler;
|
|
||||||
gpio_pinset_t pinset;
|
gpio_pinset_t pinset;
|
||||||
phy_enable_t enabler;
|
phy_enable_t enabler;
|
||||||
int irq;
|
int irq;
|
||||||
@@ -213,7 +203,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
if (strcmp(intf, SAM34_EMAC_DEVNAME) == 0)
|
if (strcmp(intf, SAM34_EMAC_DEVNAME) == 0)
|
||||||
{
|
{
|
||||||
phyinfo("Select EMAC\n");
|
phyinfo("Select EMAC\n");
|
||||||
phandler = &g_emac_handler;
|
|
||||||
pinset = GPIO_PHY_IRQ;
|
pinset = GPIO_PHY_IRQ;
|
||||||
irq = SAM_PHY_IRQ;
|
irq = SAM_PHY_IRQ;
|
||||||
enabler = sam_emac_phy_enable;
|
enabler = sam_emac_phy_enable;
|
||||||
@@ -230,11 +219,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Get the old interrupt handler and save the new one */
|
|
||||||
|
|
||||||
oldhandler = *phandler;
|
|
||||||
*phandler = handler;
|
|
||||||
|
|
||||||
/* Configure the interrupt */
|
/* Configure the interrupt */
|
||||||
|
|
||||||
if (handler)
|
if (handler)
|
||||||
@@ -243,7 +227,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
sam_gpioirq(pinset);
|
sam_gpioirq(pinset);
|
||||||
|
|
||||||
phyinfo("Attach IRQ%d\n", irq);
|
phyinfo("Attach IRQ%d\n", irq);
|
||||||
(void)irq_attach(irq, handler, NULL);
|
(void)irq_attach(irq, handler, arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -266,7 +250,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
/* Return the old handler (so that it can be restored) */
|
/* Return the old handler (so that it can be restored) */
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SAM34_GPIOD_IRQ */
|
#endif /* CONFIG_SAM34_GPIOD_IRQ */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/sama5d3-xplained/src/sam_ethernet.c
|
* configs/sama5d3-xplained/src/sam_ethernet.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -93,19 +93,6 @@
|
|||||||
# define phyinfo(x...)
|
# define phyinfo(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Private Data
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
|
||||||
#ifdef CONFIG_SAMA5_EMACA
|
|
||||||
static xcpt_t g_emac_handler;
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_SAMA5_GMAC
|
|
||||||
static xcpt_t g_gmac_handler;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
@@ -255,23 +242,21 @@ void weak_function sam_netinitialize(void)
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* in order to detach and disable the PHY interrupt.
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
* enable - A function pointer that be unsed to enable or disable the
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
||||||
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
|
||||||
|
phy_enable_t *enable)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
xcpt_t *phandler;
|
|
||||||
xcpt_t oldhandler;
|
|
||||||
pio_pinset_t pinset;
|
pio_pinset_t pinset;
|
||||||
phy_enable_t enabler;
|
phy_enable_t enabler;
|
||||||
int irq;
|
int irq;
|
||||||
@@ -290,7 +275,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
if (strcmp(intf, SAMA5_EMAC_DEVNAME) == 0)
|
if (strcmp(intf, SAMA5_EMAC_DEVNAME) == 0)
|
||||||
{
|
{
|
||||||
phyinfo("Select EMAC\n");
|
phyinfo("Select EMAC\n");
|
||||||
phandler = &g_emac_handler;
|
|
||||||
pinset = PIO_INT_ETH1;
|
pinset = PIO_INT_ETH1;
|
||||||
irq = IRQ_INT_ETH1;
|
irq = IRQ_INT_ETH1;
|
||||||
enabler = sam_emac_phy_enable;
|
enabler = sam_emac_phy_enable;
|
||||||
@@ -301,7 +285,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
if (strcmp(intf, SAMA5_GMAC_DEVNAME) == 0)
|
if (strcmp(intf, SAMA5_GMAC_DEVNAME) == 0)
|
||||||
{
|
{
|
||||||
phyinfo("Select GMAC\n");
|
phyinfo("Select GMAC\n");
|
||||||
phandler = &g_gmac_handler;
|
|
||||||
pinset = PIO_INT_ETH0;
|
pinset = PIO_INT_ETH0;
|
||||||
irq = IRQ_INT_ETH0;
|
irq = IRQ_INT_ETH0;
|
||||||
enabler = sam_gmac_phy_enable;
|
enabler = sam_gmac_phy_enable;
|
||||||
@@ -319,11 +302,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Get the old interrupt handler and save the new one */
|
|
||||||
|
|
||||||
oldhandler = *phandler;
|
|
||||||
*phandler = handler;
|
|
||||||
|
|
||||||
/* Configure the interrupt */
|
/* Configure the interrupt */
|
||||||
|
|
||||||
if (handler)
|
if (handler)
|
||||||
@@ -332,7 +310,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
sam_pioirq(pinset);
|
sam_pioirq(pinset);
|
||||||
|
|
||||||
phyinfo("Attach IRQ%d\n", irq);
|
phyinfo("Attach IRQ%d\n", irq);
|
||||||
(void)irq_attach(irq, handler, NULL);
|
(void)irq_attach(irq, handler, arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -355,7 +333,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
/* Return the old handler (so that it can be restored) */
|
/* Return the old handler (so that it can be restored) */
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SAMA5_PIOE_IRQ */
|
#endif /* CONFIG_SAMA5_PIOE_IRQ */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/sama5d3x-ek/src/sam_ethernet.c
|
* configs/sama5d3x-ek/src/sam_ethernet.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013-2014, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -93,19 +93,6 @@
|
|||||||
# define phyinfo(x...)
|
# define phyinfo(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Private Data
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
|
||||||
#ifdef CONFIG_SAMA5_EMACA
|
|
||||||
static xcpt_t g_emac_handler;
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_SAMA5_GMAC
|
|
||||||
static xcpt_t g_gmac_handler;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
@@ -255,23 +242,21 @@ void weak_function sam_netinitialize(void)
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* in order to detach and disable the PHY interrupt.
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
* enable - A function pointer that be unsed to enable or disable the
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
||||||
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
|
||||||
|
phy_enable_t *enable)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
xcpt_t *phandler;
|
|
||||||
xcpt_t oldhandler;
|
|
||||||
pio_pinset_t pinset;
|
pio_pinset_t pinset;
|
||||||
phy_enable_t enabler;
|
phy_enable_t enabler;
|
||||||
int irq;
|
int irq;
|
||||||
@@ -290,7 +275,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
if (strcmp(intf, SAMA5_EMAC_DEVNAME) == 0)
|
if (strcmp(intf, SAMA5_EMAC_DEVNAME) == 0)
|
||||||
{
|
{
|
||||||
phyinfo("Select EMAC\n");
|
phyinfo("Select EMAC\n");
|
||||||
phandler = &g_emac_handler;
|
|
||||||
pinset = PIO_INT_ETH1;
|
pinset = PIO_INT_ETH1;
|
||||||
irq = IRQ_INT_ETH1;
|
irq = IRQ_INT_ETH1;
|
||||||
enabler = sam_emac_phy_enable;
|
enabler = sam_emac_phy_enable;
|
||||||
@@ -301,7 +285,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
if (strcmp(intf, SAMA5_GMAC_DEVNAME) == 0)
|
if (strcmp(intf, SAMA5_GMAC_DEVNAME) == 0)
|
||||||
{
|
{
|
||||||
phyinfo("Select GMAC\n");
|
phyinfo("Select GMAC\n");
|
||||||
phandler = &g_gmac_handler;
|
|
||||||
pinset = PIO_INT_ETH0;
|
pinset = PIO_INT_ETH0;
|
||||||
irq = IRQ_INT_ETH0;
|
irq = IRQ_INT_ETH0;
|
||||||
enabler = sam_gmac_phy_enable;
|
enabler = sam_gmac_phy_enable;
|
||||||
@@ -319,11 +302,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Get the old interrupt handler and save the new one */
|
|
||||||
|
|
||||||
oldhandler = *phandler;
|
|
||||||
*phandler = handler;
|
|
||||||
|
|
||||||
/* Configure the interrupt */
|
/* Configure the interrupt */
|
||||||
|
|
||||||
if (handler)
|
if (handler)
|
||||||
@@ -332,7 +310,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
sam_pioirq(pinset);
|
sam_pioirq(pinset);
|
||||||
|
|
||||||
phyinfo("Attach IRQ%d\n", irq);
|
phyinfo("Attach IRQ%d\n", irq);
|
||||||
(void)irq_attach(irq, handler, NULL);
|
(void)irq_attach(irq, handler, arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -355,7 +333,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
/* Return the old handler (so that it can be restored) */
|
/* Return the old handler (so that it can be restored) */
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SAMA5_PIOE_IRQ */
|
#endif /* CONFIG_SAMA5_PIOE_IRQ */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/sama5d4-ek/src/sam_ethernet.c
|
* configs/sama5d4-ek/src/sam_ethernet.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2014, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -93,19 +93,6 @@
|
|||||||
# define phyinfo(x...)
|
# define phyinfo(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Private Data
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
|
||||||
#ifdef CONFIG_SAMA5_EMAC0
|
|
||||||
static xcpt_t g_emac0_handler;
|
|
||||||
#endif
|
|
||||||
#ifdef CONFIG_SAMA5_EMAC1
|
|
||||||
static xcpt_t g_emac1_handler;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
@@ -224,23 +211,21 @@ void weak_function sam_netinitialize(void)
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* in order to detach and disable the PHY interrupt.
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
* enable - A function pointer that be unsed to enable or disable the
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
#ifdef CONFIG_SAMA5_PIOE_IRQ
|
||||||
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
|
||||||
|
phy_enable_t *enable)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
xcpt_t *phandler;
|
|
||||||
xcpt_t oldhandler;
|
|
||||||
pio_pinset_t pinset;
|
pio_pinset_t pinset;
|
||||||
phy_enable_t enabler;
|
phy_enable_t enabler;
|
||||||
int irq;
|
int irq;
|
||||||
@@ -259,7 +244,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
if (strcmp(intf, SAMA5_EMAC0_DEVNAME) == 0)
|
if (strcmp(intf, SAMA5_EMAC0_DEVNAME) == 0)
|
||||||
{
|
{
|
||||||
phyinfo("Select EMAC0\n");
|
phyinfo("Select EMAC0\n");
|
||||||
phandler = &g_emac0_handler;
|
|
||||||
pinset = PIO_INT_ETH0;
|
pinset = PIO_INT_ETH0;
|
||||||
irq = IRQ_INT_ETH0;
|
irq = IRQ_INT_ETH0;
|
||||||
enabler = sam_emac0_phy_enable;
|
enabler = sam_emac0_phy_enable;
|
||||||
@@ -270,7 +254,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
if (strcmp(intf, SAMA5_EMAC1_DEVNAME) == 0)
|
if (strcmp(intf, SAMA5_EMAC1_DEVNAME) == 0)
|
||||||
{
|
{
|
||||||
phyinfo("Select EMAC1\n");
|
phyinfo("Select EMAC1\n");
|
||||||
phandler = &g_emac1_handler;
|
|
||||||
pinset = PIO_INT_ETH1;
|
pinset = PIO_INT_ETH1;
|
||||||
irq = IRQ_INT_ETH1;
|
irq = IRQ_INT_ETH1;
|
||||||
enabler = sam_emac1_phy_enable;
|
enabler = sam_emac1_phy_enable;
|
||||||
@@ -288,11 +271,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Get the old interrupt handler and save the new one */
|
|
||||||
|
|
||||||
oldhandler = *phandler;
|
|
||||||
*phandler = handler;
|
|
||||||
|
|
||||||
/* Configure the interrupt */
|
/* Configure the interrupt */
|
||||||
|
|
||||||
if (handler)
|
if (handler)
|
||||||
@@ -301,7 +279,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
sam_pioirq(pinset);
|
sam_pioirq(pinset);
|
||||||
|
|
||||||
phyinfo("Attach IRQ%d\n", irq);
|
phyinfo("Attach IRQ%d\n", irq);
|
||||||
(void)irq_attach(irq, handler, NULL);
|
(void)irq_attach(irq, handler, arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -324,7 +302,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
/* Return the old handler (so that it can be restored) */
|
/* Return the old handler (so that it can be restored) */
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SAMA5_PIOE_IRQ */
|
#endif /* CONFIG_SAMA5_PIOE_IRQ */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/same70-xplained/src/sam_ethernet.c
|
* configs/same70-xplained/src/sam_ethernet.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -89,14 +89,6 @@
|
|||||||
# define phyinfo(x...)
|
# define phyinfo(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Private Data
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_SAMV7_GPIOA_IRQ
|
|
||||||
static xcpt_t g_emac0_handler;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
@@ -288,23 +280,21 @@ int sam_emac0_setmac(void)
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* in order to detach and disable the PHY interrupt.
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
* enable - A function pointer that be unsed to enable or disable the
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SAMV7_GPIOA_IRQ
|
#ifdef CONFIG_SAMV7_GPIOA_IRQ
|
||||||
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
|
||||||
|
phy_enable_t *enable)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
xcpt_t *phandler;
|
|
||||||
xcpt_t oldhandler;
|
|
||||||
gpio_pinset_t pinset;
|
gpio_pinset_t pinset;
|
||||||
phy_enable_t enabler;
|
phy_enable_t enabler;
|
||||||
int irq;
|
int irq;
|
||||||
@@ -317,7 +307,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
if (strcmp(intf, SAMV7_EMAC0_DEVNAME) == 0)
|
if (strcmp(intf, SAMV7_EMAC0_DEVNAME) == 0)
|
||||||
{
|
{
|
||||||
phyinfo("Select EMAC0\n");
|
phyinfo("Select EMAC0\n");
|
||||||
phandler = &g_emac0_handler;
|
|
||||||
pinset = GPIO_EMAC0_INT;
|
pinset = GPIO_EMAC0_INT;
|
||||||
irq = IRQ_EMAC0_INT;
|
irq = IRQ_EMAC0_INT;
|
||||||
enabler = sam_emac0_phy_enable;
|
enabler = sam_emac0_phy_enable;
|
||||||
@@ -334,11 +323,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Get the old interrupt handler and save the new one */
|
|
||||||
|
|
||||||
oldhandler = *phandler;
|
|
||||||
*phandler = handler;
|
|
||||||
|
|
||||||
/* Configure the interrupt */
|
/* Configure the interrupt */
|
||||||
|
|
||||||
if (handler)
|
if (handler)
|
||||||
@@ -347,7 +331,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
sam_gpioirq(pinset);
|
sam_gpioirq(pinset);
|
||||||
|
|
||||||
phyinfo("Attach IRQ%d\n", irq);
|
phyinfo("Attach IRQ%d\n", irq);
|
||||||
(void)irq_attach(irq, handler, NULL);
|
(void)irq_attach(irq, handler, arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -370,7 +354,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
/* Return the old handler (so that it can be restored) */
|
/* Return the old handler (so that it can be restored) */
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SAMV7_GPIOA_IRQ */
|
#endif /* CONFIG_SAMV7_GPIOA_IRQ */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/samv71-xult/src/sam_ethernet.c
|
* configs/samv71-xult/src/sam_ethernet.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2015-2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -89,14 +89,6 @@
|
|||||||
# define phyinfo(x...)
|
# define phyinfo(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Private Data
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_SAMV7_GPIOA_IRQ
|
|
||||||
static xcpt_t g_emac0_handler;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
@@ -292,23 +284,21 @@ int sam_emac0_setmac(void)
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* in order to detach and disable the PHY interrupt.
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
* enable - A function pointer that be unsed to enable or disable the
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_SAMV7_GPIOA_IRQ
|
#ifdef CONFIG_SAMV7_GPIOA_IRQ
|
||||||
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
|
||||||
|
phy_enable_t *enable)
|
||||||
{
|
{
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
xcpt_t *phandler;
|
|
||||||
xcpt_t oldhandler;
|
|
||||||
gpio_pinset_t pinset;
|
gpio_pinset_t pinset;
|
||||||
phy_enable_t enabler;
|
phy_enable_t enabler;
|
||||||
int irq;
|
int irq;
|
||||||
@@ -322,7 +312,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
{
|
{
|
||||||
phyinfo("Select EMAC0\n");
|
phyinfo("Select EMAC0\n");
|
||||||
|
|
||||||
phandler = &g_emac0_handler;
|
|
||||||
pinset = GPIO_EMAC0_INT;
|
pinset = GPIO_EMAC0_INT;
|
||||||
irq = IRQ_EMAC0_INT;
|
irq = IRQ_EMAC0_INT;
|
||||||
enabler = sam_emac0_phy_enable;
|
enabler = sam_emac0_phy_enable;
|
||||||
@@ -339,11 +328,6 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
|
|
||||||
/* Get the old interrupt handler and save the new one */
|
|
||||||
|
|
||||||
oldhandler = *phandler;
|
|
||||||
*phandler = handler;
|
|
||||||
|
|
||||||
/* Configure the interrupt */
|
/* Configure the interrupt */
|
||||||
|
|
||||||
if (handler)
|
if (handler)
|
||||||
@@ -352,7 +336,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
sam_gpioirq(pinset);
|
sam_gpioirq(pinset);
|
||||||
|
|
||||||
phyinfo("Attach IRQ%d\n", irq);
|
phyinfo("Attach IRQ%d\n", irq);
|
||||||
(void)irq_attach(irq, handler, NULL);
|
(void)irq_attach(irq, handler, arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -375,7 +359,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
/* Return the old handler (so that it can be restored) */
|
/* Return the old handler (so that it can be restored) */
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_SAMV7_GPIOA_IRQ */
|
#endif /* CONFIG_SAMV7_GPIOA_IRQ */
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* configs/stm32f4discovery/src/stm32_ethernet.c
|
* configs/stm32f4discovery/src/stm32_ethernet.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2015, 2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -94,6 +94,7 @@
|
|||||||
|
|
||||||
#ifdef HAVE_NETMONITOR
|
#ifdef HAVE_NETMONITOR
|
||||||
static xcpt_t g_ethmac_handler;
|
static xcpt_t g_ethmac_handler;
|
||||||
|
static void *g_ethmac_arg;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
@@ -113,7 +114,7 @@ static void stm32_emac0_phy_enable(bool enable)
|
|||||||
/* Attach and enable GPIO interrupt (and event) on the falling edge */
|
/* Attach and enable GPIO interrupt (and event) on the falling edge */
|
||||||
|
|
||||||
(void)stm32_gpiosetevent(GPIO_EMAC_NINT, false, true, true,
|
(void)stm32_gpiosetevent(GPIO_EMAC_NINT, false, true, true,
|
||||||
g_ethmac_handler, NULL);
|
g_ethmac_handler, g_ethmac_arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -203,22 +204,21 @@ void weak_function stm32_netinitialize(void)
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* in order to detach and disable the PHY interrupt.
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
* enable - A function pointer that be unsed to enable or disable the
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef HAVE_NETMONITOR
|
#ifdef HAVE_NETMONITOR
|
||||||
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
|
||||||
|
phy_enable_t *enable)
|
||||||
{
|
{
|
||||||
phy_enable_t enabler;
|
phy_enable_t enabler;
|
||||||
xcpt_t oldhandler;
|
|
||||||
irqstate_t flags;
|
irqstate_t flags;
|
||||||
|
|
||||||
ninfo("%s: handler=%p\n", intf, handler);
|
ninfo("%s: handler=%p\n", intf, handler);
|
||||||
@@ -226,13 +226,13 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
|
|
||||||
DEBUGASSERT(intf);
|
DEBUGASSERT(intf);
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = enter_critical_section();
|
||||||
oldhandler = g_ethmac_handler;
|
|
||||||
|
|
||||||
if (strcmp(intf, STM32_ETHMAC_DEVNAME) == 0)
|
if (strcmp(intf, STM32_ETHMAC_DEVNAME) == 0)
|
||||||
{
|
{
|
||||||
phyinfo("Select ETHMAC\n");
|
phyinfo("Select ETHMAC\n");
|
||||||
g_ethmac_handler = handler;
|
g_ethmac_handler = handler;
|
||||||
|
g_ethmac_arg = arg;
|
||||||
enabler = stm32_emac0_phy_enable;
|
enabler = stm32_emac0_phy_enable;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -247,7 +247,7 @@ xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
leave_critical_section(flags);
|
leave_critical_section(flags);
|
||||||
return oldhandler;
|
return OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+13
-65
@@ -102,7 +102,6 @@ struct phy_notify_s
|
|||||||
{
|
{
|
||||||
bool assigned;
|
bool assigned;
|
||||||
uint8_t signo;
|
uint8_t signo;
|
||||||
uint8_t index;
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
char intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1];
|
char intf[CONFIG_PHY_NOTIFICATION_MAXINTFLEN+1];
|
||||||
#endif
|
#endif
|
||||||
@@ -115,17 +114,11 @@ struct phy_notify_s
|
|||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int phy_handler(FAR struct phy_notify_s *client);
|
static void phy_semtake(void);
|
||||||
static int phy_handler_0(int irq, FAR void *context, FAR void *arg);
|
static FAR struct phy_notify_s *phy_find_unassigned(void);
|
||||||
#if CONFIG_PHY_NOTIFICATION_NCLIENTS > 1
|
static FAR struct phy_notify_s *phy_find_assigned(FAR const char *intf,
|
||||||
static int phy_handler_1(int irq, FAR void *context, FAR void *arg);
|
pid_t pid);
|
||||||
#if CONFIG_PHY_NOTIFICATION_NCLIENTS > 2
|
static int phy_handler(int irq, FAR void *context, FAR void *arg);
|
||||||
static int phy_handler_2(int irq, FAR void *context, FAR void *arg);
|
|
||||||
#if CONFIG_PHY_NOTIFICATION_NCLIENTS > 3
|
|
||||||
static int phy_handler_3(int irq, FAR void *context, FAR void *arg);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@@ -138,22 +131,6 @@ static sem_t g_notify_clients_sem = SEM_INITIALIZER(1);
|
|||||||
|
|
||||||
static struct phy_notify_s g_notify_clients[CONFIG_PHY_NOTIFICATION_NCLIENTS];
|
static struct phy_notify_s g_notify_clients[CONFIG_PHY_NOTIFICATION_NCLIENTS];
|
||||||
|
|
||||||
/* Handler addresses accessed with the same index as g_notify_clients[] */
|
|
||||||
|
|
||||||
static const xcpt_t g_notify_handler[CONFIG_PHY_NOTIFICATION_NCLIENTS] =
|
|
||||||
{
|
|
||||||
phy_handler_0
|
|
||||||
#if CONFIG_PHY_NOTIFICATION_NCLIENTS > 1
|
|
||||||
, phy_handler_1
|
|
||||||
#if CONFIG_PHY_NOTIFICATION_NCLIENTS > 2
|
|
||||||
, phy_handler_2
|
|
||||||
#if CONFIG_PHY_NOTIFICATION_NCLIENTS > 3
|
|
||||||
, phy_handler_3
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -197,7 +174,6 @@ static FAR struct phy_notify_s *phy_find_unassigned(void)
|
|||||||
|
|
||||||
client->assigned = true;
|
client->assigned = true;
|
||||||
client->signo = 0;
|
client->signo = 0;
|
||||||
client->index = i;
|
|
||||||
#ifdef CONFIG_NETDEV_MULTINIC
|
#ifdef CONFIG_NETDEV_MULTINIC
|
||||||
client->intf[0] = '\0';
|
client->intf[0] = '\0';
|
||||||
#endif
|
#endif
|
||||||
@@ -258,16 +234,16 @@ static FAR struct phy_notify_s *phy_find_assigned(FAR const char *intf,
|
|||||||
* Name: phy_handler
|
* Name: phy_handler
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int phy_handler(FAR struct phy_notify_s *client)
|
static int phy_handler(int irq, FAR void *context, FAR void *arg)
|
||||||
{
|
{
|
||||||
|
FAR struct phy_notify_s *client = (FAR struct phy_notify_s *)arg;
|
||||||
#ifdef CONFIG_CAN_PASS_STRUCTS
|
#ifdef CONFIG_CAN_PASS_STRUCTS
|
||||||
union sigval value;
|
union sigval value;
|
||||||
#endif
|
#endif
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
DEBUGASSERT(client && client->assigned && client->enable);
|
DEBUGASSERT(client != NULL && client->assigned && client->enable);
|
||||||
phyinfo("Entry client %d, signalling PID=%d with signal %d\n",
|
phyinfo("Signalling PID=%d with signal %d\n", client->pid, client->signo);
|
||||||
client->index, client->pid, client->signo);
|
|
||||||
|
|
||||||
/* Disable further interrupts */
|
/* Disable further interrupts */
|
||||||
|
|
||||||
@@ -294,36 +270,6 @@ static int phy_handler(FAR struct phy_notify_s *client)
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: phy_handler_0, phy_handler_1, ...
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int phy_handler_0(int irq, FAR void *context, FAR void *arg)
|
|
||||||
{
|
|
||||||
return phy_handler(&g_notify_clients[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CONFIG_PHY_NOTIFICATION_NCLIENTS > 1
|
|
||||||
static int phy_handler_1(int irq, FAR void *context, FAR void *arg)
|
|
||||||
{
|
|
||||||
return phy_handler(&g_notify_clients[1]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_PHY_NOTIFICATION_NCLIENTS > 2
|
|
||||||
static int phy_handler_2(int irq, FAR void *context, FAR void *arg)
|
|
||||||
{
|
|
||||||
return phy_handler(&g_notify_clients[2]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_PHY_NOTIFICATION_NCLIENTS > 3
|
|
||||||
static int phy_handler_3(int irq, FAR void *context, FAR void *arg)
|
|
||||||
{
|
|
||||||
return phy_handler(&g_notify_clients[3]);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -358,6 +304,8 @@ int phy_notify_subscribe(FAR const char *intf, pid_t pid, int signo,
|
|||||||
FAR void *arg)
|
FAR void *arg)
|
||||||
{
|
{
|
||||||
FAR struct phy_notify_s *client;
|
FAR struct phy_notify_s *client;
|
||||||
|
int ret = OK;
|
||||||
|
|
||||||
DEBUGASSERT(intf);
|
DEBUGASSERT(intf);
|
||||||
|
|
||||||
ninfo("%s: PID=%d signo=%d arg=%p\n", intf, pid, signo, arg);
|
ninfo("%s: PID=%d signo=%d arg=%p\n", intf, pid, signo, arg);
|
||||||
@@ -403,14 +351,14 @@ int phy_notify_subscribe(FAR const char *intf, pid_t pid, int signo,
|
|||||||
|
|
||||||
/* Attach/re-attach the PHY interrupt */
|
/* Attach/re-attach the PHY interrupt */
|
||||||
|
|
||||||
(void)arch_phy_irq(intf, g_notify_handler[client->index], &client->enable);
|
ret = arch_phy_irq(intf, phy_handler, client, &client->enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable/re-enable the PH interrupt */
|
/* Enable/re-enable the PH interrupt */
|
||||||
|
|
||||||
DEBUGASSERT(client->enable);
|
DEBUGASSERT(client->enable);
|
||||||
client->enable(true);
|
client->enable(true);
|
||||||
return OK;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -2247,19 +2247,19 @@ int up_rtc_settime(FAR const struct timespec *tp);
|
|||||||
* asserts an interrupt. Must reside in OS space, but can
|
* asserts an interrupt. Must reside in OS space, but can
|
||||||
* signal tasks in user space. A value of NULL can be passed
|
* signal tasks in user space. A value of NULL can be passed
|
||||||
* in order to detach and disable the PHY interrupt.
|
* in order to detach and disable the PHY interrupt.
|
||||||
|
* arg - The argument that will accompany the interrupt
|
||||||
* enable - A function pointer that be unsed to enable or disable the
|
* enable - A function pointer that be unsed to enable or disable the
|
||||||
* PHY interrupt.
|
* PHY interrupt.
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* The previous PHY interrupt handler address is returned. This allows you
|
* Zero (OK) returned on success; a negated errno value is returned on
|
||||||
* to temporarily replace an interrupt handler, then restore the original
|
* failure.
|
||||||
* interrupt handler. NULL is returned if there is was not handler in
|
|
||||||
* place when the call was made.
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_PHY_INTERRUPT
|
#ifdef CONFIG_ARCH_PHY_INTERRUPT
|
||||||
xcpt_t arch_phy_irq(FAR const char *intf, xcpt_t handler, phy_enable_t *enable);
|
int arch_phy_irq(FAR const char *intf, xcpt_t handler, void *arg,
|
||||||
|
phy_enable_t *enable);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user