SAMA5 Ethernet: Add support for PHY interrupts

This commit is contained in:
Gregory Nutt 2013-09-15 12:24:42 -06:00
parent 7c13790901
commit 45e4425687
3 changed files with 63 additions and 144 deletions

View File

@ -61,7 +61,7 @@
#include "chip.h"
#include "sam_pio.h"
#include "sam_emac.h"
#include "sam_ethernet.h"
#include <arch/board/board.h>
@ -2331,16 +2331,23 @@ static inline void sam_selectrmii(void)
static inline void sam_ethgpioconfig(FAR struct sam_emac_s *priv)
{
/* Configure GPIO pins to support Ethernet */
/* Configure PIO pins to support EMAC */
/* Configure EMAC PIO pins common to both MII and RMII */
#if defined(CONFIG_SAMA5_MII) || defined(CONFIG_SAMA5_RMII)
sam_configpio(PIO_EMAC_TX0);
sam_configpio(PIO_EMAC_TX1);
sam_configpio(PIO_EMAC_RX0);
sam_configpio(PIO_EMAC_RX1);
sam_configpio(PIO_EMAC_TXEN);
sam_configpio(PIO_EMAC_CRSDV);
sam_configpio(PIO_EMAC_RXER);
sam_configpio(PIO_EMAC_REFCK);
/* MDC and MDIO are common to both modes */
sam_configgpio(GPIO_EMAC_MDC);
sam_configgpio(GPIO_EMAC_MDIO);
/* Set up the MII interface */
sam_configpio(PIO_EMAC_MDC);
sam_configpio(PIO_EMAC_MDIO);
#if defined(CONFIG_SAMA5_MII)
@ -2348,60 +2355,11 @@ static inline void sam_ethgpioconfig(FAR struct sam_emac_s *priv)
sam_selectmii();
/* Provide clocking via MCO, MCO1 or MCO2:
*
* "MCO1 (microcontroller clock output), used to output HSI, LSE, HSE or PLL
* clock (through a configurable prescaler) on PA8 pin."
*
* "MCO2 (microcontroller clock output), used to output HSE, PLL, SYSCLK or
* PLLI2S clock (through a configurable prescaler) on PC9 pin."
*/
/* Provide clocking */
#warning Missing logic
# if defined(CONFIG_SAMA5_MII_MCO1)
/* Configure MC01 to drive the PHY. Board logic must provide MC01 clocking
* info.
*/
sam_configgpio(GPIO_MCO1);
sam_mco1config(BOARD_CFGR_MC01_SOURCE, BOARD_CFGR_MC01_DIVIDER);
# elif defined(CONFIG_SAMA5_MII_MCO2)
/* Configure MC02 to drive the PHY. Board logic must provide MC02 clocking
* info.
*/
sam_configgpio(GPIO_MCO2);
sam_mco2config(BOARD_CFGR_MC02_SOURCE, BOARD_CFGR_MC02_DIVIDER);
# elif defined(CONFIG_SAMA5_MII_MCO)
/* Setup MCO pin for alternative usage */
sam_configgpio(GPIO_MCO);
sam_mcoconfig(BOARD_CFGR_MCO_SOURCE);
# endif
/* MII interface pins (17):
*
* MII_TX_CLK, MII_TXD[3:0], MII_TX_EN, MII_RX_CLK, MII_RXD[3:0], MII_RX_ER,
* MII_RX_DV, MII_CRS, MII_COL, MDC, MDIO
*/
sam_configgpio(GPIO_EMAC_MII_COL);
sam_configgpio(GPIO_EMAC_MII_CRS);
sam_configgpio(GPIO_EMAC_MII_RXD0);
sam_configgpio(GPIO_EMAC_MII_RXD1);
sam_configgpio(GPIO_EMAC_MII_RXD2);
sam_configgpio(GPIO_EMAC_MII_RXD3);
sam_configgpio(GPIO_EMAC_MII_RX_CLK);
sam_configgpio(GPIO_EMAC_MII_RX_DV);
sam_configgpio(GPIO_EMAC_MII_RX_ER);
sam_configgpio(GPIO_EMAC_MII_TXD0);
sam_configgpio(GPIO_EMAC_MII_TXD1);
sam_configgpio(GPIO_EMAC_MII_TXD2);
sam_configgpio(GPIO_EMAC_MII_TXD3);
sam_configgpio(GPIO_EMAC_MII_TX_CLK);
sam_configgpio(GPIO_EMAC_MII_TX_EN);
/* Set up the RMII interface. */
#elif defined(CONFIG_SAMA5_RMII)
@ -2410,59 +2368,10 @@ static inline void sam_ethgpioconfig(FAR struct sam_emac_s *priv)
sam_selectrmii();
/* Provide clocking via MCO, MCO1 or MCO2:
*
* "MCO1 (microcontroller clock output), used to output HSI, LSE, HSE or PLL
* clock (through a configurable prescaler) on PA8 pin."
*
* "MCO2 (microcontroller clock output), used to output HSE, PLL, SYSCLK or
* PLLI2S clock (through a configurable prescaler) on PC9 pin."
*/
# if defined(CONFIG_SAMA5_RMII_MCO1)
/* Configure MC01 to drive the PHY. Board logic must provide MC01 clocking
* info.
*/
sam_configgpio(GPIO_MCO1);
sam_mco1config(BOARD_CFGR_MC01_SOURCE, BOARD_CFGR_MC01_DIVIDER);
# elif defined(CONFIG_SAMA5_RMII_MCO2)
/* Configure MC02 to drive the PHY. Board logic must provide MC02 clocking
* info.
*/
sam_configgpio(GPIO_MCO2);
sam_mco2config(BOARD_CFGR_MC02_SOURCE, BOARD_CFGR_MC02_DIVIDER);
# elif defined(CONFIG_SAMA5_RMII_MCO)
/* Setup MCO pin for alternative usage */
sam_configgpio(GPIO_MCO);
sam_mcoconfig(BOARD_CFGR_MCO_SOURCE);
# endif
/* RMII interface pins (7):
*
* RMII_TXD[1:0], RMII_TX_EN, RMII_RXD[1:0], RMII_CRS_DV, MDC, MDIO,
* RMII_REF_CLK
*/
sam_configgpio(GPIO_EMAC_RMII_CRS_DV);
sam_configgpio(GPIO_EMAC_RMII_REF_CLK);
sam_configgpio(GPIO_EMAC_RMII_RXD0);
sam_configgpio(GPIO_EMAC_RMII_RXD1);
sam_configgpio(GPIO_EMAC_RMII_TXD0);
sam_configgpio(GPIO_EMAC_RMII_TXD1);
/* sam_configgpio(GPIO_EMAC_RMII_TX_CLK); not needed? */
sam_configgpio(GPIO_EMAC_RMII_TX_EN);
/* Provide clocking */
#warning Missing logic
#endif
#endif
/* Enable pulse-per-second (PPS) output signal */
sam_configgpio(GPIO_EMAC_PPS_OUT);
}
/****************************************************************************
@ -2560,7 +2469,16 @@ static void sam_macaddress(FAR struct sam_emac_s *priv)
dev->d_mac.ether_addr_octet[4], dev->d_mac.ether_addr_octet[5]);
/* Set the MAC address */
#warning Missing logic
regval = (uint32_t)dev->d_mac.ether_addr_octet[0] |,
(uint32_t)dev->d_mac.ether_addr_octet[1] << 8 |,
(uint32_t)dev->d_mac.ether_addr_octet[2] << 16 |,
(uint32_t)dev->d_mac.ether_addr_octet[3] << 24 |,
sam_putreg(priv, SAM_GMAC_SAB1, regval);
regval = (uint32_t)dev->d_mac.ether_addr_octet[4] |,
(uint32_t)dev->d_mac.ether_addr_octet[5] << 8 |,
sam_putreg(priv, SAM_GMAC_SAT1, regval);
}
/****************************************************************************
@ -2719,7 +2637,7 @@ int sam_emac_initialize(void)
priv->txpoll = wd_create(); /* Create periodic poll timer */
priv->txtimeout = wd_create(); /* Create TX timeout timer */
/* Configure GPIO pins to support Ethernet */
/* Configure PIO pins to support EMAC */
sam_ethgpioconfig(priv);

View File

@ -1,5 +1,5 @@
/****************************************************************************
* arch/arm/src/sama5/sam_eth.c
* arch/arm/src/sama5/sam_ethernet.c
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -39,7 +39,7 @@
#include <nuttx/config.h>
#include <debug.h>
#include "sam_emac.h"
#include "sam_ethernet.h"
#ifdef CONFIG_NET

View File

@ -1,5 +1,5 @@
/************************************************************************************
* arch/arm/src/sama5/sam_eth.h
* arch/arm/src/sama5/sam_ethernet.h
*
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
@ -33,8 +33,8 @@
*
************************************************************************************/
#ifndef __ARCH_ARM_SRC_SAMA5_SAM_EMAC_H
#define __ARCH_ARM_SRC_SAMA5_SAM_EMAC_H
#ifndef __ARCH_ARM_SRC_SAMA5_SAM_ETHERNET_H
#define __ARCH_ARM_SRC_SAMA5_SAM_ETHERNET_H
/************************************************************************************
* Included Files
@ -44,6 +44,7 @@
#include "chip.h"
#include "chip/sam_emac.h"
#include "chip/sam_gmac.h"
/************************************************************************************
* Pre-processor Definitions
@ -139,5 +140,5 @@ int sam_phy_boardinitialize(int intf);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMA5_SAM_EMAC_H */
#endif /* __ARCH_ARM_SRC_SAMA5_SAM_ETHERNET_H */