Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933029AbcCKQsF (ORCPT ); Fri, 11 Mar 2016 11:48:05 -0500 Received: from mail-pa0-f65.google.com ([209.85.220.65]:36299 "EHLO mail-pa0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932711AbcCKQrL (ORCPT ); Fri, 11 Mar 2016 11:47:11 -0500 From: David Daney To: "David S. Miller" , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Florian Fainelli , Robert Richter , Sunil Goutham , Kumar Gala , Ian Campbell , Mark Rutland , Pawel Moll , Rob Herring Cc: linux-kernel@vger.kernel.org, Radha Mohan Chintakuntla , David Daney Subject: [PATCH 1/3] net: thunderx: Cleanup PHY probing code. Date: Fri, 11 Mar 2016 08:47:00 -0800 Message-Id: <1457714822-5754-2-git-send-email-ddaney.cavm@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1457714822-5754-1-git-send-email-ddaney.cavm@gmail.com> References: <1457714822-5754-1-git-send-email-ddaney.cavm@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2374 Lines: 75 From: David Daney Remove the call to force the octeon-mdio driver to be loaded. Allow the standard driver loading mechanisms to load the PHY drivers, and use -EPROBE_DEFER to cause the BGX driver to be probed only after the PHY drivers are available. Reorder the setting of MAC addresses and PHY probing to allow BGX LMACs with no attached PHY to still be assigned a MAC address. Signed-off-by: David Daney --- drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 31 ++++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c index f8abdff..928c02b 100644 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c @@ -978,27 +978,31 @@ static int bgx_init_of_phy(struct bgx *bgx) const char *mac; device_for_each_child_node(&bgx->pdev->dev, fwn) { + struct phy_device *pd; struct device_node *phy_np; struct device_node *node = to_of_node(fwn); - /* If it is not an OF node we cannot handle it yet, so - * exit the loop. - */ - if (!node) - break; - - phy_np = of_parse_phandle(node, "phy-handle", 0); - if (!phy_np) - continue; - - bgx->lmac[lmac].phydev = of_phy_find_device(phy_np); - mac = of_get_mac_address(node); if (mac) ether_addr_copy(bgx->lmac[lmac].mac, mac); SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev); bgx->lmac[lmac].lmacid = lmac; + + phy_np = of_parse_phandle(node, "phy-handle", 0); + /* If there is no phy or defective firmware presents + * this cortina phy, for which there is no driver + * support, ignore it. + */ + if (phy_np && + !of_device_is_compatible(phy_np, "cortina,cs4223-slice")) { + /* Wait until the phy drivers are available */ + pd = of_phy_find_device(phy_np); + if (!pd) + return -EPROBE_DEFER; + bgx->lmac[lmac].phydev = pd; + } + lmac++; if (lmac == MAX_LMAC_PER_BGX) { of_node_put(node); @@ -1032,9 +1036,6 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) struct bgx *bgx = NULL; u8 lmac; - /* Load octeon mdio driver */ - octeon_mdiobus_force_mod_depencency(); - bgx = devm_kzalloc(dev, sizeof(*bgx), GFP_KERNEL); if (!bgx) return -ENOMEM; -- 1.7.11.7