Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

stmmac: add fixed-link device-tree support

In case DT is used, this change adds the ability to the stmmac driver to
detect a fixed-link PHY, instanciate it, and use it during
phy_connect().

Fixed link PHYs DT usage is described in:
Documentation/devicetree/bindings/net/fixed-link.txt

Signed-off-by: Mathieu Olivari <mathieu@codeaurora.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Mathieu Olivari and committed by
David S. Miller
27732381 5790cf3c

+12 -2
+1 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 856 856 * device as well. 857 857 * Note: phydev->phy_id is the result of reading the UID PHY registers. 858 858 */ 859 - if (phydev->phy_id == 0) { 859 + if (!priv->plat->phy_node && phydev->phy_id == 0) { 860 860 phy_disconnect(phydev); 861 861 return -ENODEV; 862 862 }
+11 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
··· 148 148 /* If we find a phy-handle property, use it as the PHY */ 149 149 plat->phy_node = of_parse_phandle(np, "phy-handle", 0); 150 150 151 + /* If phy-handle is not specified, check if we have a fixed-phy */ 152 + if (!plat->phy_node && of_phy_is_fixed_link(np)) { 153 + if ((of_phy_register_fixed_link(np) < 0)) 154 + return -ENODEV; 155 + 156 + plat->phy_node = of_node_get(np); 157 + } 158 + 151 159 /* "snps,phy-addr" is not a standard property. Mark it as deprecated 152 160 * and warn of its use. Remove this when phy node support is added. 153 161 */ ··· 220 212 if (of_find_property(np, "snps,pbl", NULL)) { 221 213 dma_cfg = devm_kzalloc(&pdev->dev, sizeof(*dma_cfg), 222 214 GFP_KERNEL); 223 - if (!dma_cfg) 215 + if (!dma_cfg) { 216 + of_node_put(np); 224 217 return -ENOMEM; 218 + } 225 219 plat->dma_cfg = dma_cfg; 226 220 of_property_read_u32(np, "snps,pbl", &dma_cfg->pbl); 227 221 dma_cfg->fixed_burst =