diff options
Diffstat (limited to 'drivers/net/ethernet/cadence/macb_main.c')
| -rw-r--r-- | drivers/net/ethernet/cadence/macb_main.c | 36 | 
1 files changed, 23 insertions, 13 deletions
| diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index dc09f9a8a49b..c6707ea2d751 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -482,11 +482,6 @@ static int macb_mii_probe(struct net_device *dev)  	if (np) {  		if (of_phy_is_fixed_link(np)) { -			if (of_phy_register_fixed_link(np) < 0) { -				dev_err(&bp->pdev->dev, -					"broken fixed-link specification\n"); -				return -ENODEV; -			}  			bp->phy_node = of_node_get(np);  		} else {  			bp->phy_node = of_parse_phandle(np, "phy-handle", 0); @@ -569,7 +564,7 @@ static int macb_mii_init(struct macb *bp)  {  	struct macb_platform_data *pdata;  	struct device_node *np; -	int err; +	int err = -ENXIO;  	/* Enable management port */  	macb_writel(bp, NCR, MACB_BIT(MPE)); @@ -592,12 +587,23 @@ static int macb_mii_init(struct macb *bp)  	dev_set_drvdata(&bp->dev->dev, bp->mii_bus);  	np = bp->pdev->dev.of_node; -	if (pdata) -		bp->mii_bus->phy_mask = pdata->phy_mask; +	if (np && of_phy_is_fixed_link(np)) { +		if (of_phy_register_fixed_link(np) < 0) { +			dev_err(&bp->pdev->dev, +				"broken fixed-link specification %pOF\n", np); +			goto err_out_free_mdiobus; +		} + +		err = mdiobus_register(bp->mii_bus); +	} else { +		if (pdata) +			bp->mii_bus->phy_mask = pdata->phy_mask; + +		err = of_mdiobus_register(bp->mii_bus, np); +	} -	err = of_mdiobus_register(bp->mii_bus, np);  	if (err) -		goto err_out_free_mdiobus; +		goto err_out_free_fixed_link;  	err = macb_mii_probe(bp->dev);  	if (err) @@ -607,6 +613,7 @@ static int macb_mii_init(struct macb *bp)  err_out_unregister_bus:  	mdiobus_unregister(bp->mii_bus); +err_out_free_fixed_link:  	if (np && of_phy_is_fixed_link(np))  		of_phy_deregister_fixed_link(np);  err_out_free_mdiobus: @@ -2028,14 +2035,17 @@ static void macb_reset_hw(struct macb *bp)  {  	struct macb_queue *queue;  	unsigned int q; +	u32 ctrl = macb_readl(bp, NCR);  	/* Disable RX and TX (XXX: Should we halt the transmission  	 * more gracefully?)  	 */ -	macb_writel(bp, NCR, 0); +	ctrl &= ~(MACB_BIT(RE) | MACB_BIT(TE));  	/* Clear the stats registers (XXX: Update stats first?) */ -	macb_writel(bp, NCR, MACB_BIT(CLRSTAT)); +	ctrl |= MACB_BIT(CLRSTAT); + +	macb_writel(bp, NCR, ctrl);  	/* Clear all status flags */  	macb_writel(bp, TSR, -1); @@ -2223,7 +2233,7 @@ static void macb_init_hw(struct macb *bp)  	}  	/* Enable TX and RX */ -	macb_writel(bp, NCR, MACB_BIT(RE) | MACB_BIT(TE) | MACB_BIT(MPE)); +	macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(RE) | MACB_BIT(TE));  }  /* The hash address register is 64 bits long and takes up two |