diff --git a/os/io/platforms/AT91SAM7X/mac_lld.c b/os/io/platforms/AT91SAM7X/mac_lld.c index 47167fa80..223d54342 100644 --- a/os/io/platforms/AT91SAM7X/mac_lld.c +++ b/os/io/platforms/AT91SAM7X/mac_lld.c @@ -174,16 +174,14 @@ void mac_lld_init(void) { AT91C_EMAC_CLRSTAT;/* Initial NCR settings.*/ mac_lld_set_address(Ð1, default_mac); -#if PHY_HARDWARE == PHY_MICREL_KS8721 /* * PHY device identification. */ AT91C_BASE_EMAC->EMAC_NCR |= AT91C_EMAC_MPE; - if ((miiGet(Ð1, MII_PHYSID1) != (MII_KS8721_ID >> 16)) || - ((miiGet(Ð1, MII_PHYSID2) & 0xFFF0) != (MII_KS8721_ID & 0xFFF0))) + if ((miiGet(Ð1, MII_PHYSID1) != (PHY_ID >> 16)) || + ((miiGet(Ð1, MII_PHYSID2) & 0xFFF0) != (PHY_ID & 0xFFF0))) chSysHalt(); AT91C_BASE_EMAC->EMAC_NCR &= ~AT91C_EMAC_MPE; -#endif /* * Interrupt configuration. diff --git a/os/io/platforms/AT91SAM7X/mii_lld.c b/os/io/platforms/AT91SAM7X/mii_lld.c index 56fd87a51..518190d4e 100644 --- a/os/io/platforms/AT91SAM7X/mii_lld.c +++ b/os/io/platforms/AT91SAM7X/mii_lld.c @@ -25,8 +25,8 @@ */ #include -#include #include +#include /** * @brief Low level MII driver initialization. @@ -62,8 +62,12 @@ void mii_lld_reset(MACDriver *macp) { */ AT91C_BASE_PIOB->PIO_OER = PIOB_PHY_PD_MASK; // Becomes an output. AT91C_BASE_PIOB->PIO_PPUDR = PIOB_PHY_PD_MASK; // Default pullup disabled. +#if (PHY_HARDWARE == PHY_DAVICOM_9161) + AT91C_BASE_PIOB->PIO_CODR = PIOB_PHY_PD_MASK; // Output to low level. +#else AT91C_BASE_PIOB->PIO_SODR = PIOB_PHY_PD_MASK; // Output to high level. #endif +#endif // PIOB_PHY_PD_MASK /* * PHY reset by pulsing the NRST pin. diff --git a/os/io/platforms/AT91SAM7X/mii_lld.h b/os/io/platforms/AT91SAM7X/mii_lld.h index f54ee0508..948999bb1 100644 --- a/os/io/platforms/AT91SAM7X/mii_lld.h +++ b/os/io/platforms/AT91SAM7X/mii_lld.h @@ -27,6 +27,9 @@ #ifndef _MII_LLD_H_ #define _MII_LLD_H_ +#include +#include "board.h" + /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ @@ -43,19 +46,30 @@ /*===========================================================================*/ #define PHY_MICREL_KS8721 0 - -#if PHY_HARDWARE == PHY_MICREL_KS8721 -#define PHY_ADDRESS 1 -#endif +#define PHY_DAVICOM_9161 1 /** * @brief Pins latched by the PHY at reset. */ +#if (PHY_HARDWARE == PHY_MICREL_KS8721) + +#define PHY_ADDRESS 1 +#define PHY_ID MII_KS8721_ID #define PHY_LATCHED_PINS (AT91C_PB4_ECRS | AT91C_PB5_ERX0 | \ AT91C_PB6_ERX1 | AT91C_PB7_ERXER | \ AT91C_PB13_ERX2 | AT91C_PB14_ERX3 | \ AT91C_PB15_ERXDV_ECRSDV | AT91C_PB16_ECOL | \ AT91C_PIO_PB26) +#elif (PHY_HARDWARE == PHY_DAVICOM_9161) + +#define PHY_ADDRESS 0 +#define PHY_ID MII_DM9161_ID +#define PHY_LATCHED_PINS (AT91C_PB4_ECRS | AT91C_PB5_ERX0 | \ + AT91C_PB6_ERX1 | AT91C_PB7_ERXER | \ + AT91C_PB13_ERX2 | AT91C_PB14_ERX3 | \ + AT91C_PB15_ERXDV_ECRSDV | AT91C_PB16_ECOL | \ + AT91C_PB17_ERXCK) +#endif /* PHY_HARDWARE */ /*===========================================================================*/ /* Driver data structures and types. */