コード例 #1
0
ファイル: b53_mdio.c プロジェクト: 2812015651/cuckoo
static int b53_phy_probe(struct phy_device *phydev)
{
	struct b53_device dev;
	int ret;

	/* allow the generic phy driver to take over */
	if (phydev->addr != B53_PSEUDO_PHY && phydev->addr != 0)
		return -ENODEV;

	dev.current_page = 0xff;
	dev.priv = phydev->bus;
	dev.ops = &b53_mdio_ops;
	dev.pdata = NULL;
	mutex_init(&dev.reg_mutex);

	ret = b53_switch_detect(&dev);
	if (ret)
		return ret;

	if (is5325(&dev) || is5365(&dev))
		phydev->supported = SUPPORTED_100baseT_Full;
	else
		phydev->supported = SUPPORTED_1000baseT_Full;

	phydev->advertising = phydev->supported;

	return 0;
}
コード例 #2
0
ファイル: b53_mdio.c プロジェクト: Noltari/lede
static int b53_phy_probe(struct phy_device *phydev)
{
	struct b53_device *dev;
	int ret;

	/* allow the generic phy driver to take over */
	if (phydev->mdio.addr != B53_PSEUDO_PHY && phydev->mdio.addr != 0)
		return -ENODEV;

	dev = b53_switch_alloc(&phydev->mdio.dev, &b53_mdio_ops, phydev->mdio.bus);
	if (!dev)
		return -ENOMEM;

	dev->current_page = 0xff;
	dev->priv = phydev->mdio.bus;
	dev->ops = &b53_mdio_ops;
	dev->pdata = NULL;
	mutex_init(&dev->reg_mutex);

	ret = b53_switch_detect(dev);
	if (ret)
		return ret;

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
	linkmode_zero(phydev->supported);
	if (is5325(dev) || is5365(dev))
		linkmode_set_bit(ETHTOOL_LINK_MODE_100baseT_Full_BIT, phydev->supported);
	else
		linkmode_set_bit(ETHTOOL_LINK_MODE_1000baseT_Full_BIT, phydev->supported);

	linkmode_copy(phydev->advertising, phydev->supported);
#else
	if (is5325(dev) || is5365(dev))
		phydev->supported = SUPPORTED_100baseT_Full;
	else
		phydev->supported = SUPPORTED_1000baseT_Full;

	phydev->advertising = phydev->supported;
#endif

	ret = b53_switch_register(dev);
	if (ret) {
		dev_err(dev->dev, "failed to register switch: %i\n", ret);
		return ret;
	}

	phydev->priv = dev;

	return 0;
}