Re: [U-Boot] [PATCH v4 3/7] drivers: net: designware: Add reading of DT phy-handle node

2018-08-28 Thread Grygorii Strashko



On 08/28/2018 01:25 AM, Janine Hagemann wrote:

Add the ability to read the phy-handle node of the
gmac.  Upon reading this handle the phy-id
can be stored based on the reg node in the DT.

The phy-handle also needs to be stored and passed
to the phy to access any phy data that is available.

Signed-off-by: Janine Hagemann 
Acked-by: Joe Hershberger 
---
v4: Change used function from dev_set_of_offset( ) to
 offset_to_ofnode( )
---
  drivers/net/designware.c | 11 ++-
  drivers/net/designware.h |  1 +
  2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 19db0a8..bba12f2 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -477,7 +477,7 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
  {
struct phy_device *phydev;
int mask = 0x, ret;
-
+   struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev);
  #ifdef CONFIG_PHY_ADDR
mask = 1 << CONFIG_PHY_ADDR;
  #endif
@@ -496,6 +496,11 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
}
phydev->advertising = phydev->supported;
  
+#ifdef CONFIG_DM_ETH

+   if (dw_pdata->phy_of_handle)
+   phydev->node  = offset_to_ofnode(dw_pdata->phy_of_handle);
+#endif
+


Above part looks good now. thank you.

--
regards,
-grygorii
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v4 3/7] drivers: net: designware: Add reading of DT phy-handle node

2018-08-28 Thread Janine Hagemann
Add the ability to read the phy-handle node of the
gmac.  Upon reading this handle the phy-id
can be stored based on the reg node in the DT.

The phy-handle also needs to be stored and passed
to the phy to access any phy data that is available.

Signed-off-by: Janine Hagemann 
Acked-by: Joe Hershberger 
---
v4: Change used function from dev_set_of_offset( ) to
offset_to_ofnode( )
---
 drivers/net/designware.c | 11 ++-
 drivers/net/designware.h |  1 +
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 19db0a8..bba12f2 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -477,7 +477,7 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
 {
struct phy_device *phydev;
int mask = 0x, ret;
-
+   struct dw_eth_pdata *dw_pdata = dev_get_platdata(dev);
 #ifdef CONFIG_PHY_ADDR
mask = 1 << CONFIG_PHY_ADDR;
 #endif
@@ -496,6 +496,11 @@ static int dw_phy_init(struct dw_eth_dev *priv, void *dev)
}
phydev->advertising = phydev->supported;
 
+#ifdef CONFIG_DM_ETH
+   if (dw_pdata->phy_of_handle)
+   phydev->node  = offset_to_ofnode(dw_pdata->phy_of_handle);
+#endif
+
priv->phydev = phydev;
phy_config(phydev);
 
@@ -803,6 +808,7 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
int reset_flags = GPIOD_IS_OUT;
 #endif
int ret = 0;
+   int node = dev_of_offset(dev);
 
pdata->iobase = dev_read_addr(dev);
pdata->phy_interface = -1;
@@ -814,6 +820,9 @@ int designware_eth_ofdata_to_platdata(struct udevice *dev)
return -EINVAL;
}
 
+   dw_pdata->phy_of_handle = fdtdec_lookup_phandle(gd->fdt_blob, node,
+"phy-handle");
+
pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0);
 
 #ifdef CONFIG_DM_GPIO
diff --git a/drivers/net/designware.h b/drivers/net/designware.h
index dea12b7..a6b0443 100644
--- a/drivers/net/designware.h
+++ b/drivers/net/designware.h
@@ -255,6 +255,7 @@ extern const struct eth_ops designware_eth_ops;
 struct dw_eth_pdata {
struct eth_pdata eth_pdata;
u32 reset_delays[3];
+   int phy_of_handle;
 };
 
 int designware_eth_init(struct dw_eth_dev *priv, u8 *enetaddr);
-- 
2.7.4

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot