9
0
Fork 0

net macb: reset the IP at init

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Tested-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Jean-Christophe PLAGNIOL-VILLARD 2013-02-08 10:18:48 +01:00 committed by Sascha Hauer
parent 044cb6a298
commit 36bcee4892
1 changed files with 23 additions and 0 deletions

View File

@ -374,6 +374,23 @@ static int macb_set_ethaddr(struct eth_device *edev, unsigned char *adr)
return 0;
}
static void macb_reset_hw(struct macb_device *bp)
{
/* Disable RX and TX forcefully */
macb_writel(bp, NCR, 0);
/* Clear the stats registers (XXX: Update stats first?) */
macb_writel(bp, NCR, MACB_BIT(CLRSTAT));
/* Clear all status flags */
macb_writel(bp, TSR, -1);
macb_writel(bp, RSR, -1);
/* Disable all interrupts */
macb_writel(bp, IDR, -1);
macb_readl(bp, ISR);
}
static int macb_probe(struct device_d *dev)
{
struct eth_device *edev;
@ -433,6 +450,9 @@ static int macb_probe(struct device_d *dev)
}
clk_enable(pclk);
macb_reset_hw(macb);
macb_hz = clk_get_rate(pclk);
if (macb_hz < 20000000)
ncfgr = MACB_BF(CLK, MACB_CLK_DIV8);
@ -443,6 +463,9 @@ static int macb_probe(struct device_d *dev)
else
ncfgr = MACB_BF(CLK, MACB_CLK_DIV64);
ncfgr |= MACB_BIT(PAE); /* PAuse Enable */
ncfgr |= MACB_BIT(DRFCS); /* Discard Rx FCS */
macb_writel(macb, NCFGR, ncfgr);
macb_init(macb);