From 6bb69076e50b9dec9f3735fa8f9e168e99f6bba7 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 22 Nov 2012 14:44:38 +0000 Subject: Move some PHY initialization logic for Darcy git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5382 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/arm/src/stm32/Kconfig | 10 ++++++++++ nuttx/arch/arm/src/stm32/stm32_eth.c | 11 +++++++++++ nuttx/arch/arm/src/stm32/stm32_eth.h | 35 +++++++++++++++++++++++++++++------ 3 files changed, 50 insertions(+), 6 deletions(-) (limited to 'nuttx/arch/arm/src') diff --git a/nuttx/arch/arm/src/stm32/Kconfig b/nuttx/arch/arm/src/stm32/Kconfig index 4e369cb1a..2807e1a47 100644 --- a/nuttx/arch/arm/src/stm32/Kconfig +++ b/nuttx/arch/arm/src/stm32/Kconfig @@ -2058,6 +2058,16 @@ config STM32_PHYADDR ---help--- The 5-bit address of the PHY on the board. Default: 1 +config STM32_PHYINIT + bool "Board-specific PHY Initialization" + default n + ---help--- + Some boards require specialized initialization of the PHY before it can be used. + This may include such things as configuring GPIOs, resetting the PHY, etc. If + STM32_PHYINIT is defined in the configuration then the board specific logic must + provide stm32_phyinitialize(); The STM32 Ethernet driver will call this function + one time before it first uses the PHY. + config STM32_MII bool "Use MII interface" default n diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c index 3054142ce..006f67142 100644 --- a/nuttx/arch/arm/src/stm32/stm32_eth.c +++ b/nuttx/arch/arm/src/stm32/stm32_eth.c @@ -2594,6 +2594,17 @@ static int stm32_phyinit(FAR struct stm32_ethmac_s *priv) } up_mdelay(PHY_RESET_DELAY); + /* Perform any necessary, board-specific PHY initialization */ + +#ifdef CONFIG_STM32_PHYINIT + ret = stm32_phy_boardinitialize(0); + if (ret < 0) + { + ndbg("Failed to initialize the PHY: %d\n", ret); + return ret; + } +#endif + /* Special workaround for the Davicom DM9161 PHY is required. */ #ifdef CONFIG_PHY_DM9161 diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.h b/nuttx/arch/arm/src/stm32/stm32_eth.h index f0c14b5b1..4501712b1 100644 --- a/nuttx/arch/arm/src/stm32/stm32_eth.h +++ b/nuttx/arch/arm/src/stm32/stm32_eth.h @@ -66,14 +66,13 @@ extern "C" { * Function: stm32_ethinitialize * * Description: - * Initialize the Ethernet driver for one interface. If the STM32 chip - * supports multiple Ethernet controllers, then board specific logic - * must implement up_netinitialize() and call this function to initialize - * the desired interfaces. + * Initialize the Ethernet driver for one interface. If the STM32 chip supports + * multiple Ethernet controllers, then board specific logic must implement + * up_netinitialize() and call this function to initialize the desired interfaces. * * Parameters: - * intf - In the case where there are multiple EMACs, this value - * identifies which EMAC is to be initialized. + * intf - In the case where there are multiple EMACs, this value identifies which + * EMAC is to be initialized. * * Returned Value: * OK on success; Negated errno on failure. @@ -86,6 +85,30 @@ extern "C" { EXTERN int stm32_ethinitialize(int intf); #endif +/************************************************************************************ + * Function: stm32_phy_boardinitialize + * + * Description: + * Some boards require specialized initialization of the PHY before it can be used. + * This may include such things as configuring GPIOs, resetting the PHY, etc. If + * CONFIG_STM32_PHYINIT is defined in the configuration then the board specific + * logic must provide stm32_phyinitialize(); The STM32 Ethernet driver will call + * this function one time before it first uses the PHY. + * + * Parameters: + * intf - Always zero for now. + * + * Returned Value: + * OK on success; Negated errno on failure. + * + * Assumptions: + * + ************************************************************************************/ + +#ifdef CONFIG_STM32_PHYINIT +EXTERN int stm32_phy_boardinitialize(int intf); +#endif + #undef EXTERN #if defined(__cplusplus) } -- cgit v1.2.3