From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7633CC48BD6 for ; Wed, 26 Jun 2019 13:48:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 507FD2085A for ; Wed, 26 Jun 2019 13:48:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="WQ9e4SON" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728074AbfFZNs1 (ORCPT ); Wed, 26 Jun 2019 09:48:27 -0400 Received: from smtprelay-out1.synopsys.com ([198.182.47.102]:51140 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727870AbfFZNry (ORCPT ); Wed, 26 Jun 2019 09:47:54 -0400 Received: from mailhost.synopsys.com (mdc-mailhost1.synopsys.com [10.225.0.209]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id B8980C0C47; Wed, 26 Jun 2019 13:47:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1561556874; bh=BHZi9tlrtLzVjp82tFDoiezzz8W/tFd5CHoGlftdzuY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=WQ9e4SONVoWDIF5qsCwGuH6eNP9Y3N1YVmTcFhEVNr1iDYYYigv0WOtcbIUZEuMjR r8Aec50VMdl6MbPvqNB4poaY2ZFPmTuqUvfkLmMb+d+6DPF6Cjt10evH6zbWQFD6Kq e9UcGtcdvBRsLBVvDZ48wlrC6EI0XNtrh7AcfiTiqqdXPMlnSM6+sHnAfB21d6nwaI rCZ4NdC/SJ4/Mg9WKg4su+slvwYruiVpPsYbolfBtjz2ZXV9b7m7sZHC+rx0gmzXTc OiXgEP0ydefIU/dPHj/ToVwjdflwiPzhw1CYNZ/igeSIKyhnnZ9hImsBD0rhFbLB2K HVfKSQYOCB7gQ== Received: from de02.synopsys.com (de02.internal.synopsys.com [10.225.17.21]) by mailhost.synopsys.com (Postfix) with ESMTP id 63A35A0075; Wed, 26 Jun 2019 13:47:52 +0000 (UTC) Received: from de02dwia024.internal.synopsys.com (de02dwia024.internal.synopsys.com [10.225.19.81]) by de02.synopsys.com (Postfix) with ESMTP id 53CBE3B57C; Wed, 26 Jun 2019 15:47:52 +0200 (CEST) From: Jose Abreu To: linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Jose Abreu , Joao Pinto , "David S . Miller" , Giuseppe Cavallaro , Alexandre Torgue Subject: [PATCH net-next 10/10] net: stmmac: Try to get C45 PHY if everything else fails Date: Wed, 26 Jun 2019 15:47:44 +0200 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On PCI based setups that are connected to C45 PHY we won't have DT bindings specifying what's the correct PHY type. Fallback to C45 if everything else fails when trying to acquire PHY. Signed-off-by: Jose Abreu Cc: Joao Pinto Cc: David S. Miller Cc: Giuseppe Cavallaro Cc: Alexandre Torgue --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index bc949665c529..e790ab79e819 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -1014,6 +1014,20 @@ static int stmmac_init_phy(struct net_device *dev) phydev = mdiobus_get_phy(priv->mii, addr); if (!phydev) { + /* Try C45 */ + phydev = get_phy_device(priv->mii, addr, true); + if (phydev && !IS_ERR(phydev)) { + ret = phy_device_register(phydev); + if (ret) { + phy_device_free(phydev); + phydev = NULL; + } + } else { + phydev = NULL; + } + } + + if (!phydev) { netdev_err(priv->dev, "no phy at addr %d\n", addr); return -ENODEV; } -- 2.7.4