Пример #1
0
unsigned Phy_Setup (XLlTemac *xlltemacp)
{
	unsigned link_speed = 1000;

	if (XLlTemac_GetPhysicalInterface(xlltemacp) ==
						XTE_PHY_TYPE_RGMII_1_3) {
		; /* Add PHY initialization code for RGMII 1.3 */
	} else if (XLlTemac_GetPhysicalInterface(xlltemacp) ==
						XTE_PHY_TYPE_RGMII_2_0) {
		; /* Add PHY initialization code for RGMII 2.0 */
	} else if (XLlTemac_GetPhysicalInterface(xlltemacp) ==
						XTE_PHY_TYPE_SGMII) {
		; /* Add PHY initialization code for SGMII */
	} else if (XLlTemac_GetPhysicalInterface(xlltemacp) ==
						XTE_PHY_TYPE_1000BASE_X) {
		; /* Add PHY initialization code for 1000 Base-X */
	}
/* set PHY <--> MAC data clock */
#ifdef  CONFIG_LINKSPEED_AUTODETECT
	link_speed = get_IEEE_phy_speed(xlltemacp);
	xil_printf("auto-negotiated link speed: %d\r\n", link_speed);
#elif	defined(CONFIG_LINKSPEED1000)
	link_speed = 1000;
	configure_IEEE_phy_speed(xlltemacp, link_speed);
	xil_printf("link speed: %d\r\n", link_speed);
#elif	defined(CONFIG_LINKSPEED100)
	link_speed = 100;
	configure_IEEE_phy_speed(xlltemacp, link_speed);
	xil_printf("link speed: %d\r\n", link_speed);
#elif	defined(CONFIG_LINKSPEED10)
	link_speed = 10;
	configure_IEEE_phy_speed(xlltemacp, link_speed);
	xil_printf("link speed: %d\r\n", link_speed);
#endif
	return link_speed;
}
unsigned Phy_Setup (XEmacPs *xemacpsp)
{
	unsigned link_speed = 1000;

/* set PHY <--> MAC data clock */
#ifdef  CONFIG_LINKSPEED_AUTODETECT
	/* SLCR unlock */
	*(unsigned int *)(SLCR_UNLOCK_ADDR) = SLCR_UNLOCK_KEY_VALUE;
	/* GEM module reset */
	*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x1;
	*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x0;
	/* GEM1 1G clock configuration*/
	*(unsigned int *)(SLCR_GEM0_CLK_CTRL_ADDR) = SLCR_GEM_1G_CLK_CTRL_VALUE;
	/* SLCR lock */
	*(unsigned int *)(SLCR_LOCK_ADDR) = SLCR_LOCK_KEY_VALUE;
	link_speed = get_IEEE_phy_speed(xemacpsp);
	xil_printf("auto-negotiated link speed: %d\r\n", link_speed);
	if (link_speed == 1000) {
		/* SLCR unlock */
		*(unsigned int *)(SLCR_UNLOCK_ADDR) = SLCR_UNLOCK_KEY_VALUE;
		/* GEM module reset */
		*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x1;
		*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x0;
		/* GEM1 1G clock configuration*/
		*(unsigned int *)(SLCR_GEM0_CLK_CTRL_ADDR) = SLCR_GEM_1G_CLK_CTRL_VALUE;
		/* SLCR lock */
		*(unsigned int *)(SLCR_LOCK_ADDR) = SLCR_LOCK_KEY_VALUE;
		configure_IEEE_phy_speed(xemacpsp, 1000);

	} else if (link_speed == 100) {
		/* SLCR unlock */
		*(unsigned int *)(SLCR_UNLOCK_ADDR) = SLCR_UNLOCK_KEY_VALUE;
		/* GEM module reset */
		*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x1;
		*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x0;
		/* GEM0 100M clock configuration*/
		*(unsigned int *)(SLCR_GEM0_CLK_CTRL_ADDR) = SLCR_GEM_100M_CLK_CTRL_VALUE;
		/* SLCR lock */
    		*(unsigned int *)(SLCR_LOCK_ADDR) = SLCR_LOCK_KEY_VALUE;
    		configure_IEEE_phy_speed(xemacpsp, 100);
	} else if (link_speed == 10) {
		/* SLCR unlock */
		*(unsigned int *)(SLCR_UNLOCK_ADDR) = SLCR_UNLOCK_KEY_VALUE;
		/* GEM0 10M clock configuration*/
		*(unsigned int *)(SLCR_GEM0_CLK_CTRL_ADDR) = SLCR_GEM_10M_CLK_CTRL_VALUE;
		/* SLCR lock */
		*(unsigned int *)(SLCR_LOCK_ADDR) = SLCR_LOCK_KEY_VALUE;
		configure_IEEE_phy_speed(xemacpsp, 10);
	}

#elif	defined(CONFIG_LINKSPEED1000)
	/* SLCR unlock */
	*(unsigned int *)(SLCR_UNLOCK_ADDR) = SLCR_UNLOCK_KEY_VALUE;
	/* GEM module reset */
	*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x1;
	*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x0;
	/* GEM1 1G clock configuration*/
	*(unsigned int *)(SLCR_GEM0_CLK_CTRL_ADDR) = SLCR_GEM_1G_CLK_CTRL_VALUE;
	/* SLCR lock */
	*(unsigned int *)(SLCR_LOCK_ADDR) = SLCR_LOCK_KEY_VALUE;
	link_speed = 1000;
	configure_IEEE_phy_speed(xemacpsp, link_speed);
	xil_printf("link speed: %d\r\n", link_speed);
#elif	defined(CONFIG_LINKSPEED100)
	/* SLCR unlock */
	*(unsigned int *)(SLCR_UNLOCK_ADDR) = SLCR_UNLOCK_KEY_VALUE;
	/* GEM module reset */
	*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x1;
	*(unsigned int *)(SLCR_ADDR_GEM_RST_CTRL) = 0x0;
	/* GEM0 100M clock configuration*/
	*(unsigned int *)(SLCR_GEM0_CLK_CTRL_ADDR) = SLCR_GEM_100M_CLK_CTRL_VALUE;
	/* SLCR lock */
    	*(unsigned int *)(SLCR_LOCK_ADDR) = SLCR_LOCK_KEY_VALUE;
	link_speed = 100;
	configure_IEEE_phy_speed(xemacpsp, link_speed);
	xil_printf("link speed: %d\r\n", link_speed);
#elif	defined(CONFIG_LINKSPEED10)
	/* SLCR unlock */
	*(unsigned int *)(SLCR_UNLOCK_ADDR) = SLCR_UNLOCK_KEY_VALUE;
	/* GEM0 10M clock configuration*/
	*(unsigned int *)(SLCR_GEM0_CLK_CTRL_ADDR) = SLCR_GEM_10M_CLK_CTRL_VALUE;
	/* SLCR lock */
	*(unsigned int *)(SLCR_LOCK_ADDR) = SLCR_LOCK_KEY_VALUE;
	link_speed = 10;
	configure_IEEE_phy_speed(xemacpsp, link_speed);
	xil_printf("link speed: %d\r\n", link_speed);
#endif
	return link_speed;
}