コード例 #1
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);
}
コード例 #2
0
static struct tag *setup_clock_tags(struct tag *params)
{
	params->hdr.tag = ATAG_CLOCK;
	params->hdr.size = tag_size(tag_clock);
	params->u.clock.clock_id = ACLOCK_BOOTCPU;
	params->u.clock.clock_flags = 0;
	params->u.clock.clock_hz = gd->cpu_hz;

#ifdef CONFIG_AT32AP7000
	/*
	 * New kernels don't need this, but we should be backwards
	 * compatible for a while...
	 */
	params = tag_next(params);

	params->hdr.tag = ATAG_CLOCK;
	params->hdr.size = tag_size(tag_clock);
	params->u.clock.clock_id = ACLOCK_HSB;
	params->u.clock.clock_flags = 0;
	params->u.clock.clock_hz = get_hsb_clk_rate();
#endif

	return tag_next(params);
}