cpsw: use phy-handle
in FDT to find PHY address
In r337703 DTS files were updated to Linux 4.18, including Linux commit 4d8b032d3c03f4e9788a18bbb51b10e6c9e8a56b which removed the `phy_id` property from am335x-bone-common (as the property was deprecated). Use `phy-handle` via fdt_get_phyaddr, keeping the existing code as a fallback for old DTBs. PR: 236624 Submitted by: manu, Gerald Aryeetey <aryeeteygerald_rogers.com> Reported by: Gerald Aryeetey Reviewed by: manu MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D19814
This commit is contained in:
parent
a53136e314
commit
2ef79738b1
@ -82,6 +82,8 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <dev/ofw/ofw_bus.h>
|
#include <dev/ofw/ofw_bus.h>
|
||||||
#include <dev/ofw/ofw_bus_subr.h>
|
#include <dev/ofw/ofw_bus_subr.h>
|
||||||
|
|
||||||
|
#include <dev/fdt/fdt_common.h>
|
||||||
|
|
||||||
#ifdef CPSW_ETHERSWITCH
|
#ifdef CPSW_ETHERSWITCH
|
||||||
#include <dev/etherswitch/etherswitch.h>
|
#include <dev/etherswitch/etherswitch.h>
|
||||||
@ -742,7 +744,7 @@ cpsw_get_fdt_data(struct cpsw_softc *sc, int port)
|
|||||||
phandle_t child;
|
phandle_t child;
|
||||||
unsigned long mdio_child_addr;
|
unsigned long mdio_child_addr;
|
||||||
|
|
||||||
/* Find any slave with phy_id */
|
/* Find any slave with phy-handle/phy_id */
|
||||||
phy = -1;
|
phy = -1;
|
||||||
vlan = -1;
|
vlan = -1;
|
||||||
for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) {
|
for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) {
|
||||||
@ -756,11 +758,15 @@ cpsw_get_fdt_data(struct cpsw_softc *sc, int port)
|
|||||||
if (mdio_child_addr != slave_mdio_addr[port])
|
if (mdio_child_addr != slave_mdio_addr[port])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
len = OF_getproplen(child, "phy_id");
|
if (fdt_get_phyaddr(child, NULL, &phy, NULL) != 0){
|
||||||
if (len / sizeof(pcell_t) == 2) {
|
/* Users with old DTB will have phy_id instead */
|
||||||
/* Get phy address from fdt */
|
phy = -1;
|
||||||
if (OF_getencprop(child, "phy_id", phy_id, len) > 0)
|
len = OF_getproplen(child, "phy_id");
|
||||||
phy = phy_id[1];
|
if (len / sizeof(pcell_t) == 2) {
|
||||||
|
/* Get phy address from fdt */
|
||||||
|
if (OF_getencprop(child, "phy_id", phy_id, len) > 0)
|
||||||
|
phy = phy_id[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
len = OF_getproplen(child, "dual_emac_res_vlan");
|
len = OF_getproplen(child, "dual_emac_res_vlan");
|
||||||
|
@ -399,6 +399,9 @@ fdt_get_phyaddr(phandle_t node, device_t dev, int *phy_addr, void **phy_sc)
|
|||||||
|
|
||||||
*phy_addr = phy_reg;
|
*phy_addr = phy_reg;
|
||||||
|
|
||||||
|
if (phy_sc == NULL)
|
||||||
|
return (0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Search for softc used to communicate with phy.
|
* Search for softc used to communicate with phy.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user