Ejemplo n.º 1
0
Archivo: macb.c Proyecto: DFE/u-boot
static void macb_phy_reset(struct macb_device *macb)
{
	struct eth_device *netdev = &macb->netdev;
	int i;
	u16 status, adv;

	adv = ADVERTISE_CSMA | ADVERTISE_ALL;
	macb_mdio_write(macb, MII_ADVERTISE, adv);
	printf("%s: Starting autonegotiation...\n", netdev->name);
	macb_mdio_write(macb, MII_BMCR, (BMCR_ANENABLE
					 | BMCR_ANRESTART));

	for (i = 0; i < CONFIG_SYS_MACB_AUTONEG_TIMEOUT / 100; i++) {
		status = macb_mdio_read(macb, MII_BMSR);
		if (status & BMSR_ANEGCOMPLETE)
			break;
		udelay(100);
	}

	if (status & BMSR_ANEGCOMPLETE)
		printf("%s: Autonegotiation complete\n", netdev->name);
	else
		printf("%s: Autonegotiation timed out (status=0x%04x)\n",
		       netdev->name, status);
}
Ejemplo n.º 2
0
static void macb_phy_reset(struct macb_device *macb)
{
	struct eth_device *netdev = &macb->netdev;
	int i;
	u16 status, adv;
	int rmii_mode;
	unsigned min_hz;

#ifdef CONFIG_RMII
	rmii_mode = 1;
	min_hz = 50000000;
#else
	rmii_mode = 0;
	min_hz = 25000000;
#endif

	adv = ADVERTISE_CSMA | ADVERTISE_ALL ;

	if (get_hsb_clk_rate() < min_hz) {
		printf("%s: HSB clock < %u MHz in %s mode - "
		       "disabling 100mbit.\n", netdev->name, min_hz / 1000000,
		       (rmii_mode ? "RMII" : "MII"));

		adv &= ~ADVERTISE_100FULL;
		adv &= ~ADVERTISE_100HALF;
		adv &= ~ADVERTISE_100BASE4;
	}

	macb_mdio_write(macb, MII_ADVERTISE, adv);
	printf("%s: Starting autonegotiation...\n", netdev->name);
	macb_mdio_write(macb, MII_BMCR, (BMCR_ANENABLE
					 | BMCR_ANRESTART));

	for (i = 0; i < CFG_MACB_AUTONEG_TIMEOUT / 100; i++) {
		status = macb_mdio_read(macb, MII_BMSR);
		if (status & BMSR_ANEGCOMPLETE)
			break;
		udelay(100);
	}

	if (status & BMSR_ANEGCOMPLETE)
		printf("%s: Autonegotiation complete\n", netdev->name);
	else
		printf("%s: Autonegotiation timed out (status=0x%04x)\n",
		       netdev->name, status);
}
Ejemplo n.º 3
0
int macb_miiphy_write(const char *devname, u8 phy_adr, u8 reg, u16 value)
{
	struct eth_device *dev = eth_get_dev_by_name(devname);
	struct macb_device *macb = to_macb(dev);

	if ( macb->phy_addr != phy_adr )
		return -1;

	macb_mdio_write(macb, reg, value);

	return 0;
}
Ejemplo n.º 4
0
int macb_miiphy_write(struct mii_dev *bus, int phy_adr, int devad, int reg,
		      u16 value)
{
#ifdef CONFIG_DM_ETH
	struct udevice *dev = eth_get_dev_by_name(bus->name);
	struct macb_device *macb = dev_get_priv(dev);
#else
	struct eth_device *dev = eth_get_dev_by_name(bus->name);
	struct macb_device *macb = to_macb(dev);
#endif

	if (macb->phy_addr != phy_adr)
		return -1;

	arch_get_mdio_control(bus->name);
	macb_mdio_write(macb, reg, value);

	return 0;
}