void load_phy_firmware(void)
{
	int i;
	u8 phy_addr;
	struct phy_device *phy_dev;
	struct mii_dev *dev;
	phy_interface_t interface;

	/*Initialize and upload firmware for all the PHYs*/
	for (i = WRIOP1_DPMAC1; i <= WRIOP1_DPMAC8; i++) {
		interface = wriop_get_enet_if(i);
		if (interface == PHY_INTERFACE_MODE_XGMII) {
			dev = wriop_get_mdio(i);
			phy_addr = wriop_get_phy_address(i);
			phy_dev = phy_find_by_mask(dev, 1 << phy_addr,
						interface);
			if (!phy_dev) {
				printf("No phydev for phyaddr %d\n", phy_addr);
				continue;
			}

			/*Flash firmware for All CS4340 PHYS */
			if (phy_dev->phy_id == PHY_UID_CS4340)
				load_firmware_cortina(phy_dev);
		}
	}
}
Пример #2
0
int board_eth_init(bd_t *bis)
{
	uint32_t base = IMX_FEC_BASE;
	struct mii_dev *bus = NULL;
	struct phy_device *phydev = NULL;
	int ret;

	setup_iomux_enet();

#ifdef CONFIG_FEC_MXC
	bus = fec_get_miibus(base, -1);
	if (!bus)
		return 0;
	/* scan phy 4,5,6,7 */
	phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
	if (!phydev) {
		free(bus);
		return 0;
	}
	printf("using phy at %d\n", phydev->addr);
	ret  = fec_probe(bis, -1, base, bus, phydev);
	if (ret) {
		printf("FEC MXC: %s:failed\n", __func__);
		free(phydev);
		free(bus);
	}
#endif
	return 0;
}
int board_eth_init(bd_t *bis)
{
	uint32_t base = IMX_FEC_BASE;
	struct mii_dev *bus = NULL;
	struct phy_device *phydev = NULL;
	int ret;

	setup_iomux_enet();

	bus = fec_get_miibus(base, -1);
	if (!bus)
		return 0;

	/* scan phy 0 and 5 */
	phydev = phy_find_by_mask(bus, 0x21, PHY_INTERFACE_MODE_RGMII);
	if (!phydev) {
		free(bus);
		return 0;
	}

	/* depending on the phy address we can detect our board version */
	if (phydev->addr == 0)
		setenv("boardver", "");
	else
		setenv("boardver", "mr");

	printf("using phy at %d\n", phydev->addr);
	ret = fec_probe(bis, -1, base, bus, phydev);
	if (ret) {
		printf("FEC MXC: %s:failed\n", __func__);
		free(phydev);
		free(bus);
	}
	return 0;
}
Пример #4
0
int board_eth_init(bd_t *bis)
{
    uint32_t base = IMX_FEC_BASE;
    struct mii_dev *bus = NULL;
    struct phy_device *phydev = NULL;
    int ret;

    bus = fec_get_miibus(base, -1);
    if (!bus)
        return 0;
    /* scan phy */
    phydev = phy_find_by_mask(bus, (0xf << CONFIG_FEC_MXC_PHYADDR),
                              PHY_INTERFACE_MODE_RGMII);

    if (!phydev) {
        free(bus);
        puts("No phy found\n");
        return 0;
    }
    ret  = fec_probe(bis, -1, base, bus, phydev);
    if (ret) {
        puts("FEC MXC: probe failed\n");
        free(phydev);
        free(bus);
    }

    return 0;
}
/*
 * This function initializes the EMAC hardware.
 */
int keystone2_emac_initialize(struct eth_priv_t *eth_priv)
{
	int res;
	struct eth_device *dev;
	struct phy_device *phy_dev;

	dev = malloc(sizeof(struct eth_device));
	if (dev == NULL)
		return -1;

	memset(dev, 0, sizeof(struct eth_device));

	strcpy(dev->name, eth_priv->int_name);
	dev->priv = eth_priv;

	keystone2_eth_read_mac_addr(dev);

	dev->iobase		= 0;
	dev->init		= keystone2_eth_open;
	dev->halt		= keystone2_eth_close;
	dev->send		= keystone2_eth_send_packet;
	dev->recv		= keystone2_eth_rcv_packet;
#ifdef CONFIG_MCAST_TFTP
	dev->mcast		= keystone2_eth_bcast_addr;
#endif

	eth_register(dev);

	/* Register MDIO bus if it's not registered yet */
	if (!mdio_bus) {
		mdio_bus	= mdio_alloc();
		mdio_bus->read	= keystone2_mdio_read;
		mdio_bus->write	= keystone2_mdio_write;
		mdio_bus->reset	= keystone2_mdio_reset;
		mdio_bus->priv	= (void *)EMAC_MDIO_BASE_ADDR;
		sprintf(mdio_bus->name, "ethernet-mdio");

		res = mdio_register(mdio_bus);
		if (res)
			return res;
	}

#ifndef CONFIG_SOC_K2G
	keystone2_net_serdes_setup();
#endif

	/* Create phy device and bind it with driver */
#ifdef CONFIG_KSNET_MDIO_PHY_CONFIG_ENABLE
	phy_dev = phy_connect(mdio_bus, eth_priv->phy_addr,
			      dev, eth_priv->phy_if);
	phy_config(phy_dev);
#else
	phy_dev = phy_find_by_mask(mdio_bus, 1 << eth_priv->phy_addr,
				   eth_priv->phy_if);
	phy_dev->dev = dev;
#endif
	eth_priv->phy_dev = phy_dev;

	return 0;
}
Пример #6
0
int board_eth_init(bd_t *bis)
{
	struct phy_device *phydev;
	struct mii_dev *bus;
	unsigned short id1, id2;
	int ret;

	iomux_v3_cfg_t enet_reset = MX6_PAD_EIM_D23__GPIO3_IO23 |
				    MUX_PAD_CTRL(NO_PAD_CTRL);

	/* check whether KSZ9031 or AR8035 has to be configured */
	imx_iomux_v3_setup_multiple_pads(enet_pads_ar8035,
					 ARRAY_SIZE(enet_pads_ar8035));
	imx_iomux_v3_setup_pad(enet_reset);

	/* phy reset */
	gpio_direction_output(IMX_GPIO_NR(3, 23), 0);
	udelay(2000);
	gpio_set_value(IMX_GPIO_NR(3, 23), 1);
	udelay(500);

	bus = fec_get_miibus(IMX_FEC_BASE, -1);
	if (!bus)
		return -EINVAL;
	phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
	if (!phydev) {
		printf("Error: phy device not found.\n");
		ret = -ENODEV;
		goto free_bus;
	}

	/* get the PHY id */
	id1 = phy_read(phydev, MDIO_DEVAD_NONE, 2);
	id2 = phy_read(phydev, MDIO_DEVAD_NONE, 3);

	if ((id1 == 0x22) && ((id2 & 0xFFF0) == 0x1620)) {
		/* re-configure for Micrel KSZ9031 */
		printf("configure Micrel KSZ9031 Ethernet Phy at address %d\n",
		       phydev->addr);

		/* phy reset: gpio3-23 */
		gpio_set_value(IMX_GPIO_NR(3, 23), 0);
		gpio_set_value(IMX_GPIO_NR(6, 30), (phydev->addr >> 2));
		gpio_set_value(IMX_GPIO_NR(6, 25), 1);
		gpio_set_value(IMX_GPIO_NR(6, 27), 1);
		gpio_set_value(IMX_GPIO_NR(6, 28), 1);
		gpio_set_value(IMX_GPIO_NR(6, 29), 1);
		imx_iomux_v3_setup_multiple_pads(enet_pads_ksz9031,
						 ARRAY_SIZE(enet_pads_ksz9031));
		gpio_set_value(IMX_GPIO_NR(6, 24), 1);
		udelay(500);
		gpio_set_value(IMX_GPIO_NR(3, 23), 1);
		imx_iomux_v3_setup_multiple_pads(enet_pads_final_ksz9031,
						 ARRAY_SIZE(enet_pads_final_ksz9031));
	} else if ((id1 == 0x004d) && (id2 == 0xd072)) {
Пример #7
0
int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)
{
	uint32_t base_mii;
	struct mii_dev *bus = NULL;
#ifdef CONFIG_PHYLIB
	struct phy_device *phydev = NULL;
#endif
	int ret;

#ifdef CONFIG_MX6
	if (mx6_enet_fused(addr)) {
		printf("Ethernet@0x%x is fused, disable it\n", addr);
		return -2;
	}
#endif

#ifdef CONFIG_MX28
	/*
	 * The i.MX28 has two ethernet interfaces, but they are not equal.
	 * Only the first one can access the MDIO bus.
	 */
	base_mii = MXS_ENET0_BASE;
#else
#ifdef CONFIG_FEC_MXC_MDIO_BASE
	base_mii = CONFIG_FEC_MXC_MDIO_BASE;
#else
	base_mii = addr;
#endif
#endif
	debug("eth_init: fec_probe(bd, %i, %i) @ %08x\n", dev_id, phy_id, addr);
	bus = fec_get_miibus(base_mii, dev_id);
	if (!bus)
		return -ENOMEM;
#ifdef CONFIG_PHYLIB
	phydev = phy_find_by_mask(bus, 1 << phy_id, PHY_INTERFACE_MODE_RGMII);
	if (!phydev) {
		free(bus);
		return -ENOMEM;
	}
	ret = fec_probe(bd, dev_id, addr, bus, phydev);
#else
	ret = fec_probe(bd, dev_id, addr, bus, phy_id);
#endif
	if (ret) {
#ifdef CONFIG_PHYLIB
		free(phydev);
#endif
		free(bus);
	}
	return ret;
}
void init_host_phys(struct mii_dev *bus)
{
	uint k;

	for (k = 0; k < 2; ++k) {
		struct phy_device *phydev;

		phydev = phy_find_by_mask(bus, 1 << k,
					  PHY_INTERFACE_MODE_SGMII);

		if (phydev)
			phy_config(phydev);
	}
}
Пример #9
0
static int fec_phy_init(struct fec_priv *priv, struct udevice *dev)
{
	struct phy_device *phydev;
	int mask = 0xffffffff;

#ifdef CONFIG_PHYLIB
	mask = 1 << CONFIG_FEC_MXC_PHYADDR;
#endif

	phydev = phy_find_by_mask(priv->bus, mask, priv->interface);
	if (!phydev)
		return -ENODEV;

	phy_connect_dev(phydev, dev);

	priv->phydev = phydev;
	phy_config(phydev);

	return 0;
}
Пример #10
0
static int pch_gbe_phy_init(struct eth_device *dev)
{
	struct pch_gbe_priv *priv = dev->priv;
	struct phy_device *phydev;
	int mask = 0xffffffff;

	phydev = phy_find_by_mask(priv->bus, mask, priv->interface);
	if (!phydev) {
		printf("pch_gbe: cannot find the phy\n");
		return -1;
	}

	phy_connect_dev(phydev, dev);

	phydev->supported &= PHY_GBIT_FEATURES;
	phydev->advertising = phydev->supported;

	priv->phydev = phydev;
	phy_config(phydev);

	return 1;
}
Пример #11
0
static int tse_phy_init(struct altera_tse_priv *priv, void *dev)
{
	struct phy_device *phydev;
	unsigned int mask = 0xffffffff;

	if (priv->phyaddr)
		mask = 1 << priv->phyaddr;

	phydev = phy_find_by_mask(priv->bus, mask, priv->interface);
	if (!phydev)
		return -ENODEV;

	phy_connect_dev(phydev, dev);

	phydev->supported &= PHY_GBIT_FEATURES;
	phydev->advertising = phydev->supported;

	priv->phydev = phydev;
	phy_config(phydev);

	return 0;
}
Пример #12
0
int board_eth_init(bd_t *bis)
{
	struct iomuxc *const iomuxc_regs = (struct iomuxc *)IOMUXC_BASE_ADDR;
	struct mii_dev *bus;
	struct phy_device *phydev;

	int ret = enable_fec_anatop_clock(0, ENET_25MHZ);
	if (ret)
		return ret;

	/* set gpr1[ENET_CLK_SEL] */
	setbits_le32(&iomuxc_regs->gpr[1], IOMUXC_GPR1_ENET_CLK_SEL_MASK);

	setup_iomux_enet();

	bus = fec_get_miibus(IMX_FEC_BASE, -1);
	if (!bus)
		return -EINVAL;

	phydev = phy_find_by_mask(bus, ETH_PHY_MASK, PHY_INTERFACE_MODE_RGMII);
	if (!phydev) {
		ret = -EINVAL;
		goto free_bus;
	}

	debug("using phy at address %d\n", phydev->addr);
	ret = fec_probe(bis, -1, IMX_FEC_BASE, bus, phydev);
	if (ret)
		goto free_phydev;

	return 0;

free_phydev:
	free(phydev);
free_bus:
	free(bus);
	return ret;
}
Пример #13
0
int board_eth_init(bd_t *bis)
{
	uint32_t base = IMX_FEC_BASE;
	struct mii_dev *bus = NULL;
	struct phy_device *phydev = NULL;
	int ret;

	setup_iomux_enet();

#ifdef CONFIG_FEC_MXC
	bus = fec_get_miibus(base, -1);
	if (!bus)
		return -EINVAL;
	/* scan phy 4,5,6,7 */
	phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII);
	if (!phydev) {
		ret = -EINVAL;
		goto free_bus;
	}
	printf("using phy at %d\n", phydev->addr);
	ret  = fec_probe(bis, -1, base, bus, phydev);
	if (ret)
		goto free_phydev;
#endif

#ifdef CONFIG_CI_UDC
	/* For otg ethernet*/
	usb_eth_initialize(bis);
#endif
	return 0;

free_phydev:
	free(phydev);
free_bus:
	free(bus);
	return ret;
}