mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-21 04:14:34 +00:00
net: eqos: add function to get phy node and address
Since new atheros PHY driver needs to access its PHY node through phy device, we have to assign the phy node in ethernet controller driver. Otherwise the PHY driver will fail to get some nodes and properties. Signed-off-by: Ye Li <ye.li@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com>
This commit is contained in:
parent
5fc783b5d9
commit
a6acf95508
2 changed files with 21 additions and 3 deletions
|
@ -719,6 +719,24 @@ static int eqos_read_rom_hwaddr(struct udevice *dev)
|
||||||
return !is_valid_ethaddr(pdata->enetaddr);
|
return !is_valid_ethaddr(pdata->enetaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int eqos_get_phy_addr(struct eqos_priv *priv, struct udevice *dev)
|
||||||
|
{
|
||||||
|
struct ofnode_phandle_args phandle_args;
|
||||||
|
int reg;
|
||||||
|
|
||||||
|
if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
|
||||||
|
&phandle_args)) {
|
||||||
|
debug("Failed to find phy-handle");
|
||||||
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->phy_of_node = phandle_args.node;
|
||||||
|
|
||||||
|
reg = ofnode_read_u32_default(phandle_args.node, "reg", 0);
|
||||||
|
|
||||||
|
return reg;
|
||||||
|
}
|
||||||
|
|
||||||
static int eqos_start(struct udevice *dev)
|
static int eqos_start(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct eqos_priv *eqos = dev_get_priv(dev);
|
struct eqos_priv *eqos = dev_get_priv(dev);
|
||||||
|
@ -767,9 +785,7 @@ static int eqos_start(struct udevice *dev)
|
||||||
*/
|
*/
|
||||||
if (!eqos->phy) {
|
if (!eqos->phy) {
|
||||||
int addr = -1;
|
int addr = -1;
|
||||||
#ifdef CONFIG_DM_ETH_PHY
|
addr = eqos_get_phy_addr(eqos, dev);
|
||||||
addr = eth_phy_get_addr(dev);
|
|
||||||
#endif
|
|
||||||
#ifdef DWC_NET_PHYADDR
|
#ifdef DWC_NET_PHYADDR
|
||||||
addr = DWC_NET_PHYADDR;
|
addr = DWC_NET_PHYADDR;
|
||||||
#endif
|
#endif
|
||||||
|
@ -788,6 +804,7 @@ static int eqos_start(struct udevice *dev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
eqos->phy->node = eqos->phy_of_node;
|
||||||
ret = phy_config(eqos->phy);
|
ret = phy_config(eqos->phy);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
pr_err("phy_config() failed: %d", ret);
|
pr_err("phy_config() failed: %d", ret);
|
||||||
|
|
|
@ -261,6 +261,7 @@ struct eqos_priv {
|
||||||
struct clk clk_slave_bus;
|
struct clk clk_slave_bus;
|
||||||
struct mii_dev *mii;
|
struct mii_dev *mii;
|
||||||
struct phy_device *phy;
|
struct phy_device *phy;
|
||||||
|
ofnode phy_of_node;
|
||||||
u32 max_speed;
|
u32 max_speed;
|
||||||
void *descs;
|
void *descs;
|
||||||
int tx_desc_idx, rx_desc_idx;
|
int tx_desc_idx, rx_desc_idx;
|
||||||
|
|
Loading…
Add table
Reference in a new issue