Exemplo n.º 1
0
unsigned int miiphy_getemac_offset (void)
{
	unsigned long zmii;
	unsigned long eoffset;

	/* Need to find out which mdi port we're using */
	zmii = in32 (ZMII_FER);

	if (zmii & (ZMII_FER_MDI << ZMII_FER_V (0))) {
		/* using port 0 */
		eoffset = 0;
	} else if (zmii & (ZMII_FER_MDI << ZMII_FER_V (1))) {
		/* using port 1 */
		eoffset = 0x100;
	} else if (zmii & (ZMII_FER_MDI << ZMII_FER_V (2))) {
		/* using port 2 */
		eoffset = 0x400;
	} else if (zmii & (ZMII_FER_MDI << ZMII_FER_V (3))) {
		/* using port 3 */
		eoffset = 0x600;
	} else {
		/* None of the mdi ports are enabled! */
		/* enable port 0 */
		zmii |= ZMII_FER_MDI << ZMII_FER_V (0);
		out32 (ZMII_FER, zmii);
		eoffset = 0;
		/* need to soft reset port 0 */
		zmii = in32 (EMAC_M0);
		zmii |= EMAC_M0_SRST;
		out32 (EMAC_M0, zmii);
	}

	return (eoffset);

}
Exemplo n.º 2
0
/* AMCC_TODO:
 * Find out of the choice for the emac for MDIO is from the bridges,
 * i.e. ZMII or RGMII as approporiate.  If the bridges are not used
 * to determine the emac for MDIO, then is the SDR0_ETH_CFG[MDIO_SEL]
 * used?  If so, then this routine below does not apply to the 460EX/GT.
 *
 * sr: Currently on 460EX only EMAC0 works with MDIO, so we always
 * return EMAC0 offset here
 */
unsigned int miiphy_getemac_offset (void)
{
#if (defined(CONFIG_440) && \
    !defined(CONFIG_440SP) && !defined(CONFIG_440SPE) && \
    !defined(CONFIG_460EX) && !defined(CONFIG_460GT)) && \
    defined(CONFIG_NET_MULTI)
	unsigned long zmii;
	unsigned long eoffset;

	/* Need to find out which mdi port we're using */
	zmii = in_be32((void *)ZMII_FER);

	if (zmii & (ZMII_FER_MDI << ZMII_FER_V (0)))
		/* using port 0 */
		eoffset = 0;

	else if (zmii & (ZMII_FER_MDI << ZMII_FER_V (1)))
		/* using port 1 */
		eoffset = 0x100;

	else if (zmii & (ZMII_FER_MDI << ZMII_FER_V (2)))
		/* using port 2 */
		eoffset = 0x400;

	else if (zmii & (ZMII_FER_MDI << ZMII_FER_V (3)))
		/* using port 3 */
		eoffset = 0x600;

	else {
		/* None of the mdi ports are enabled! */
		/* enable port 0 */
		zmii |= ZMII_FER_MDI << ZMII_FER_V (0);
		out_be32((void *)ZMII_FER, zmii);
		eoffset = 0;
		/* need to soft reset port 0 */
		zmii = in_be32((void *)EMAC_M0);
		zmii |= EMAC_M0_SRST;
		out_be32((void *)EMAC_M0, zmii);
	}

	return (eoffset);
#else

#if defined(CONFIG_NET_MULTI) && defined(CONFIG_405EX)
	unsigned long rgmii;
	int devnum = 1;

	rgmii = in_be32((void *)RGMII_FER);
	if (rgmii & (1 << (19 - devnum)))
		return 0x100;
#endif

	return 0;
#endif
}