Changeset View
Changeset View
Standalone View
Standalone View
head/sys/arm/ti/cpsw/if_cpsw.c
Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
#include <arm/ti/ti_scm.h> | #include <arm/ti/ti_scm.h> | ||||
#include <arm/ti/am335x/am335x_scm.h> | #include <arm/ti/am335x/am335x_scm.h> | ||||
#include <dev/mii/mii.h> | #include <dev/mii/mii.h> | ||||
#include <dev/mii/miivar.h> | #include <dev/mii/miivar.h> | ||||
#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> | ||||
#include "etherswitch_if.h" | #include "etherswitch_if.h" | ||||
#endif | #endif | ||||
#include "if_cpswreg.h" | #include "if_cpswreg.h" | ||||
#include "if_cpswvar.h" | #include "if_cpswvar.h" | ||||
▲ Show 20 Lines • Show All 643 Lines • ▼ Show 20 Lines | |||||
cpsw_get_fdt_data(struct cpsw_softc *sc, int port) | cpsw_get_fdt_data(struct cpsw_softc *sc, int port) | ||||
{ | { | ||||
char *name; | char *name; | ||||
int len, phy, vlan; | int len, phy, vlan; | ||||
pcell_t phy_id[3], vlan_id; | pcell_t phy_id[3], vlan_id; | ||||
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)) { | ||||
if (OF_getprop_alloc(child, "name", (void **)&name) < 0) | if (OF_getprop_alloc(child, "name", (void **)&name) < 0) | ||||
continue; | continue; | ||||
if (sscanf(name, "slave@%lx", &mdio_child_addr) != 1) { | if (sscanf(name, "slave@%lx", &mdio_child_addr) != 1) { | ||||
OF_prop_free(name); | OF_prop_free(name); | ||||
continue; | continue; | ||||
} | } | ||||
OF_prop_free(name); | OF_prop_free(name); | ||||
if (mdio_child_addr != slave_mdio_addr[port]) | if (mdio_child_addr != slave_mdio_addr[port]) | ||||
continue; | continue; | ||||
if (fdt_get_phyaddr(child, NULL, &phy, NULL) != 0){ | |||||
/* Users with old DTB will have phy_id instead */ | |||||
phy = -1; | |||||
len = OF_getproplen(child, "phy_id"); | len = OF_getproplen(child, "phy_id"); | ||||
if (len / sizeof(pcell_t) == 2) { | if (len / sizeof(pcell_t) == 2) { | ||||
/* Get phy address from fdt */ | /* Get phy address from fdt */ | ||||
if (OF_getencprop(child, "phy_id", phy_id, len) > 0) | if (OF_getencprop(child, "phy_id", phy_id, len) > 0) | ||||
phy = phy_id[1]; | phy = phy_id[1]; | ||||
} | |||||
} | } | ||||
len = OF_getproplen(child, "dual_emac_res_vlan"); | len = OF_getproplen(child, "dual_emac_res_vlan"); | ||||
if (len / sizeof(pcell_t) == 1) { | if (len / sizeof(pcell_t) == 1) { | ||||
/* Get phy address from fdt */ | /* Get phy address from fdt */ | ||||
if (OF_getencprop(child, "dual_emac_res_vlan", | if (OF_getencprop(child, "dual_emac_res_vlan", | ||||
&vlan_id, len) > 0) { | &vlan_id, len) > 0) { | ||||
vlan = vlan_id; | vlan = vlan_id; | ||||
▲ Show 20 Lines • Show All 2,218 Lines • Show Last 20 Lines |