> + /* Setup the cpu ports */
> + for (i = 0; i < DSA_MAX_PORTS; i++) {
> + struct net_device *netdev;
> + int phy_mode = -1;
> +
> + if (!dsa_is_cpu_port(ds, i))
> + continue;
> +
> + netdev = ds->dst->pd->chip->port_ethernet[i];
> + if (!netdev) {
> + pr_err("Can't find netdev for port%d\n", i);
> + return -ENODEV;
> + }
> +
> + /* Initialize CPU port pad mode (xMII type, delays...) */
> + phy_mode = of_get_phy_mode(netdev->dev.parent->of_node);
> + if (phy_mode < 0) {
> + pr_err("Can't find phy-mode for port:%d\n", i);
> + return phy_mode;
> + }
Hi John
We try to avoid having the switch drivers parse the DSA device
tree. There is code in the DSA core to do what you want here.
dsa.c: dsa_cpu_dsa_setup() will parse the phy-mode property, if you
have a fixed-phy node in the "cpu" or "dsa" node. It will then call
the drivers adjust_list_() function, which can then set the xMII type
etc.
The problem might be how to make use of this without breaking
backwards compatibility with older device tree blobs.
Andrew