提交 1313aaf0 编写于 作者: M Mario Six 提交者: Joe Hershberger

net: tsec: Make live-tree compatible

Make the tsec ethernet driver compatible with a live device tree.
Reviewed-by: NSimon Glass <sjg@chromium.org>
Acked-by: NJoe Hershberger <joe.hershberger@ni.com>
Signed-off-by: NMario Six <mario.six@gdsys.cc>
上级 5775f00e
...@@ -20,8 +20,6 @@ ...@@ -20,8 +20,6 @@
#include <asm/processor.h> #include <asm/processor.h>
#include <asm/io.h> #include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR;
#ifndef CONFIG_DM_ETH #ifndef CONFIG_DM_ETH
/* Default initializations for TSEC controllers. */ /* Default initializations for TSEC controllers. */
...@@ -779,45 +777,43 @@ int tsec_probe(struct udevice *dev) ...@@ -779,45 +777,43 @@ int tsec_probe(struct udevice *dev)
struct tsec_private *priv = dev_get_priv(dev); struct tsec_private *priv = dev_get_priv(dev);
struct eth_pdata *pdata = dev_get_platdata(dev); struct eth_pdata *pdata = dev_get_platdata(dev);
struct fsl_pq_mdio_info mdio_info; struct fsl_pq_mdio_info mdio_info;
int offset = 0; struct ofnode_phandle_args phandle_args;
int reg; ofnode parent;
const char *phy_mode; const char *phy_mode;
int ret; int ret;
pdata->iobase = (phys_addr_t)devfdt_get_addr(dev); pdata->iobase = (phys_addr_t)dev_read_addr(dev);
priv->regs = (struct tsec *)pdata->iobase; priv->regs = (struct tsec *)pdata->iobase;
offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
"phy-handle"); &phandle_args)) {
if (offset > 0) {
reg = fdtdec_get_int(gd->fdt_blob, offset, "reg", 0);
priv->phyaddr = reg;
} else {
debug("phy-handle does not exist under tsec %s\n", dev->name); debug("phy-handle does not exist under tsec %s\n", dev->name);
return -ENOENT; return -ENOENT;
} else {
int reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
priv->phyaddr = reg;
} }
offset = fdt_parent_offset(gd->fdt_blob, offset); parent = ofnode_get_parent(phandle_args.node);
if (offset > 0) { if (ofnode_valid(parent)) {
reg = fdtdec_get_int(gd->fdt_blob, offset, "reg", 0); int reg = ofnode_read_u32_default(parent, "reg", 0);
priv->phyregs_sgmii = (struct tsec_mii_mng *)(reg + 0x520); priv->phyregs_sgmii = (struct tsec_mii_mng *)(reg + 0x520);
} else { } else {
debug("No parent node for PHY?\n"); debug("No parent node for PHY?\n");
return -ENOENT; return -ENOENT;
} }
offset = fdtdec_lookup_phandle(gd->fdt_blob, dev_of_offset(dev), if (dev_read_phandle_with_args(dev, "tbi-handle", NULL, 0, 0,
"tbi-handle"); &phandle_args)) {
if (offset > 0) {
reg = fdtdec_get_int(gd->fdt_blob, offset, "reg",
CONFIG_SYS_TBIPA_VALUE);
priv->tbiaddr = reg;
} else {
priv->tbiaddr = CONFIG_SYS_TBIPA_VALUE; priv->tbiaddr = CONFIG_SYS_TBIPA_VALUE;
} else {
int reg = ofnode_read_u32_default(phandle_args.node, "reg",
CONFIG_SYS_TBIPA_VALUE);
priv->tbiaddr = reg;
} }
phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), phy_mode = dev_read_prop(dev, "phy-connection-type", NULL);
"phy-connection-type", NULL);
if (phy_mode) if (phy_mode)
pdata->phy_interface = phy_get_interface_by_name(phy_mode); pdata->phy_interface = phy_get_interface_by_name(phy_mode);
if (pdata->phy_interface == -1) { if (pdata->phy_interface == -1) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册