Message ID | 20201022070715.14759-4-padmarao.begari@microchip.com |
---|---|
State | Superseded |
Delegated to: | Andes |
Headers | show |
Series | Microchip PolarFire SoC support | expand |
On Thu, Oct 22, 2020 at 12:52 PM Padmarao Begari <padmarao.begari@microchip.com> wrote: > > Read phy address from device tree and use it to find the phy device > if not found then search in the range of 0 to 31. > > Signed-off-by: Padmarao Begari <padmarao.begari@microchip.com> > --- > drivers/net/macb.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/net/macb.c b/drivers/net/macb.c > index e0e86a274e..7f592d510c 100644 > --- a/drivers/net/macb.c > +++ b/drivers/net/macb.c > @@ -477,6 +477,12 @@ static int macb_phy_find(struct macb_device *macb, const char *name) > int i; > u16 phy_id; > > + phy_id = macb_mdio_read(macb, macb->phy_addr, MII_PHYSID1); > + if (phy_id != 0xffff) { > + printf("%s: PHY present at %d\n", name, macb->phy_addr); > + return 0; > + } > + > /* Search for PHY... */ > for (i = 0; i < 32; i++) { > macb->phy_addr = i; > @@ -1256,6 +1262,8 @@ static int macb_eth_probe(struct udevice *dev) > struct macb_device *macb = dev_get_priv(dev); > const char *phy_mode; > int ret; > + u32 phy_addr; > + ofnode node; > > phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", > NULL); > @@ -1266,6 +1274,13 @@ static int macb_eth_probe(struct udevice *dev) > return -EINVAL; > } > > + /* Look for a PHY node under the Ethernet node */ > + node = dev_read_subnode(dev, "ethernet-phy"); > + if (ofnode_valid(node)) { > + ofnode_read_u32(node, "reg", &phy_addr); > + macb->phy_addr = phy_addr; > + } > + Instead of custom DT property "ethernet-phy", we should use standard "phy-handle" DT property. (Refer, <linux_sources>/Documentation/devicetree/bindings/net/ethernet-controller.yaml) > macb->regs = (void *)pdata->iobase; > > macb->is_big_endian = (cpu_to_be32(0x12345678) == 0x12345678); > -- > 2.17.1 > Regards, Anup
Hi Anup, On Sun, Oct 25, 2020 at 11:50 AM Anup Patel <anup@brainfault.org> wrote: > On Thu, Oct 22, 2020 at 12:52 PM Padmarao Begari > <padmarao.begari@microchip.com> wrote: > > > > Read phy address from device tree and use it to find the phy device > > if not found then search in the range of 0 to 31. > > > > Signed-off-by: Padmarao Begari <padmarao.begari@microchip.com> > > --- > > drivers/net/macb.c | 15 +++++++++++++++ > > 1 file changed, 15 insertions(+) > > > > diff --git a/drivers/net/macb.c b/drivers/net/macb.c > > index e0e86a274e..7f592d510c 100644 > > --- a/drivers/net/macb.c > > +++ b/drivers/net/macb.c > > @@ -477,6 +477,12 @@ static int macb_phy_find(struct macb_device *macb, > const char *name) > > int i; > > u16 phy_id; > > > > + phy_id = macb_mdio_read(macb, macb->phy_addr, MII_PHYSID1); > > + if (phy_id != 0xffff) { > > + printf("%s: PHY present at %d\n", name, macb->phy_addr); > > + return 0; > > + } > > + > > /* Search for PHY... */ > > for (i = 0; i < 32; i++) { > > macb->phy_addr = i; > > @@ -1256,6 +1262,8 @@ static int macb_eth_probe(struct udevice *dev) > > struct macb_device *macb = dev_get_priv(dev); > > const char *phy_mode; > > int ret; > > + u32 phy_addr; > > + ofnode node; > > > > phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), > "phy-mode", > > NULL); > > @@ -1266,6 +1274,13 @@ static int macb_eth_probe(struct udevice *dev) > > return -EINVAL; > > } > > > > + /* Look for a PHY node under the Ethernet node */ > > + node = dev_read_subnode(dev, "ethernet-phy"); > > + if (ofnode_valid(node)) { > > + ofnode_read_u32(node, "reg", &phy_addr); > > + macb->phy_addr = phy_addr; > > + } > > + > > Instead of custom DT property "ethernet-phy", we should use standard > "phy-handle" DT property. > (Refer, > <linux_sources>/Documentation/devicetree/bindings/net/ethernet-controller.yaml) > > > macb->regs = (void *)pdata->iobase; > > > > macb->is_big_endian = (cpu_to_be32(0x12345678) == 0x12345678); > > -- > > 2.17.1 > > > > Ok Regards Padmarao > Regards, > Anup >
diff --git a/drivers/net/macb.c b/drivers/net/macb.c index e0e86a274e..7f592d510c 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -477,6 +477,12 @@ static int macb_phy_find(struct macb_device *macb, const char *name) int i; u16 phy_id; + phy_id = macb_mdio_read(macb, macb->phy_addr, MII_PHYSID1); + if (phy_id != 0xffff) { + printf("%s: PHY present at %d\n", name, macb->phy_addr); + return 0; + } + /* Search for PHY... */ for (i = 0; i < 32; i++) { macb->phy_addr = i; @@ -1256,6 +1262,8 @@ static int macb_eth_probe(struct udevice *dev) struct macb_device *macb = dev_get_priv(dev); const char *phy_mode; int ret; + u32 phy_addr; + ofnode node; phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", NULL); @@ -1266,6 +1274,13 @@ static int macb_eth_probe(struct udevice *dev) return -EINVAL; } + /* Look for a PHY node under the Ethernet node */ + node = dev_read_subnode(dev, "ethernet-phy"); + if (ofnode_valid(node)) { + ofnode_read_u32(node, "reg", &phy_addr); + macb->phy_addr = phy_addr; + } + macb->regs = (void *)pdata->iobase; macb->is_big_endian = (cpu_to_be32(0x12345678) == 0x12345678);
Read phy address from device tree and use it to find the phy device if not found then search in the range of 0 to 31. Signed-off-by: Padmarao Begari <padmarao.begari@microchip.com> --- drivers/net/macb.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)