#include <asm/arch/hardware.h>
#include <asm/arch/sys_proto.h>
+#if !defined(CONFIG_PHYLIB)
+# error XILINX_GEM_ETHERNET requires PHYLIB
+#endif
+
/* Bit/mask specification */
#define ZYNQ_GEM_PHYMNTNC_OP_MASK 0x40020000 /* operation mask bits */
#define ZYNQ_GEM_PHYMNTNC_OP_R_MASK 0x20000000 /* read operation */
ZYNQ_GEM_PHYMNTNC_OP_W_MASK, &data);
}
-#ifndef CONFIG_PHYLIB
-static int phy_rst(struct eth_device *dev)
-{
- struct zynq_gem_priv *priv = dev->priv;
- u16 tmp;
-
- puts("Resetting PHY...\n");
- phyread(dev, priv->phyaddr, 0, &tmp);
- tmp |= 0x8000;
- phywrite(dev, priv->phyaddr, 0, tmp);
-
- phyread(dev, priv->phyaddr, 0, &tmp);
- while (tmp & 0x8000) {
- putc('.');
- if (ctrlc())
- return 1;
- phyread(dev, priv->phyaddr, 0, &tmp);
- }
- puts("\nPHY reset complete.\n");
- return 0;
-}
-#endif
-
static void phy_detection(struct eth_device *dev)
{
int i;
#endif
phy_detection(dev);
-#ifdef CONFIG_PHYLIB
/* interface - look at tsec */
phydev = phy_connect(priv->bus, priv->phyaddr, dev,
PHY_INTERFACE_MODE_MII);
ZYNQ_GEM_BASEADDR0, clk_rate);
#endif
-#else
- /* PHY Setup */
- phywrite(dev, priv->phyaddr, 22, 2); /* page 2 */
-
- /* rx clock transition when data stable */
- phywrite(dev, priv->phyaddr, 21, 0x3030);
-
- phywrite(dev, priv->phyaddr, 22, 0); /* page 0 */
-
- u16 tmp;
-
- /* link speed advertisement for autonegotiation */
- phyread(dev, priv->phyaddr, 4, &tmp);
- tmp |= 0xd80; /* enable 100Mbps */
- tmp &= ~0x60; /* disable 10 Mbps */
- phywrite(dev, priv->phyaddr, 4, tmp);
-
- /* *disable* gigabit advertisement */
- phyread(dev, priv->phyaddr, 9, &tmp);
- tmp &= ~0x0300;
- phywrite(dev, priv->phyaddr, 9, tmp);
-
- /* enable autonegotiation, set 100Mbps, full-duplex, restart aneg */
- phyread(dev, priv->phyaddr, 0, &tmp);
- phywrite(dev, priv->phyaddr, 0, 0x3300 | (tmp & 0x1F));
-
- if (phy_rst(dev))
- return -1;
-
- puts("\nWaiting for PHY to complete autonegotiation.");
- do {
- phyread(dev, priv->phyaddr, 1, &tmp);
- } while (tmp & (1 << 5));
-
- puts("\nPHY claims autonegotiation complete...\n");
-
- puts("GEM link speed is 100Mbps\n");
- writel(ZYNQ_GEM_NWCFG_INIT | ZYNQ_GEM_NWCFG_SPEED100, ®s->nwcfg);
-#endif
-
/* set hardware address because of ... */
if (!is_valid_ether_addr(dev->enetaddr)) {
printf("%s: mac address is not valid\n", dev->name);