9
0
Fork 0

net: fec: probe phy_mode from devicetree

This allows to parse the phy mode from the devicetree.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2013-03-09 16:35:40 +01:00
parent f72a4fd370
commit 9b1d226a79
1 changed files with 26 additions and 1 deletions

View File

@ -26,6 +26,7 @@
#include <linux/phy.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <of_net.h>
#include <asm/mmu.h>
@ -628,6 +629,25 @@ static int fec_alloc_receive_packets(struct fec_priv *fec, int count, int size)
return 0;
}
#ifdef CONFIG_OFDEVICE
static int fec_probe_dt(struct device_d *dev, struct fec_priv *fec)
{
int ret;
ret = of_get_phy_mode(dev->device_node);
if (ret < 0)
fec->interface = PHY_INTERFACE_MODE_MII;
else
fec->interface = ret;
return 0;
}
#else
static int fec_probe_dt(struct device_d *dev, struct fec_priv *fec)
{
return -ENODEV;
}
#endif
static int fec_probe(struct device_d *dev)
{
struct fec_platform_data *pdata = (struct fec_platform_data *)dev->platform_data;
@ -685,7 +705,9 @@ static int fec_probe(struct device_d *dev)
fec_alloc_receive_packets(fec, FEC_RBD_NUM, FEC_MAX_PKT_SIZE);
if (pdata) {
if (dev->device_node) {
ret = fec_probe_dt(dev, fec);
} else if (pdata) {
fec->interface = pdata->xcv_type;
fec->phy_init = pdata->phy_init;
fec->phy_addr = pdata->phy_addr;
@ -694,6 +716,9 @@ static int fec_probe(struct device_d *dev)
fec->phy_addr = -1;
}
if (ret)
goto err_free;
fec_init(edev);
fec->miibus.read = fec_miibus_read;