Beispiel #1
0
int __init rgmii_attach(void *emac)
{
	struct ocp_enet_private *dev = emac;
	struct ocp_func_emac_data *emacdata = dev->def->additions;

	/* Check if we need to attach to a RGMII */
	if (emacdata->rgmii_idx >= 0 && rgmii_valid_mode(emacdata->phy_mode)) {
		dev->rgmii_input = emacdata->rgmii_mux;
		dev->rgmii_dev =
		    ocp_find_device(OCP_VENDOR_IBM, OCP_FUNC_RGMII,
				    emacdata->rgmii_idx);
		if (!dev->rgmii_dev) {
			printk(KERN_ERR "emac%d: unknown rgmii%d!\n",
			       dev->def->index, emacdata->rgmii_idx);
			return -ENODEV;
		}
		if (rgmii_init
		    (dev->rgmii_dev, dev->rgmii_input, emacdata->phy_mode)) {
			printk(KERN_ERR
			       "emac%d: rgmii%d initialization failed!\n",
			       dev->def->index, emacdata->rgmii_idx);
			return -ENODEV;
		}
	}
	return 0;
}
Beispiel #2
0
int __devinit rgmii_attach(struct of_device *ofdev, int input, int mode)
{
	struct rgmii_instance *dev = dev_get_drvdata(&ofdev->dev);
	struct rgmii_regs __iomem *p = dev->base;

	RGMII_DBG(dev, "attach(%d)" NL, input);

	/* Check if we need to attach to a RGMII */
	if (input < 0 || !rgmii_valid_mode(mode)) {
		printk(KERN_ERR "%s: unsupported settings !\n",
		       ofdev->node->full_name);
		return -ENODEV;
	}

	mutex_lock(&dev->lock);

	/* Enable this input */
	out_be32(&p->fer, in_be32(&p->fer) | rgmii_mode_mask(mode, input));

	printk(KERN_NOTICE "%s: input %d in %s mode\n",
	       ofdev->node->full_name, input, rgmii_mode_name(mode));

	++dev->users;

	mutex_unlock(&dev->lock);

	return 0;
}