From patchwork Sat Oct 2 17:58:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 12532325 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23AAAC433F5 for ; Sat, 2 Oct 2021 17:58:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 055E361A6F for ; Sat, 2 Oct 2021 17:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233745AbhJBSAI (ORCPT ); Sat, 2 Oct 2021 14:00:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232043AbhJBSAH (ORCPT ); Sat, 2 Oct 2021 14:00:07 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27F55C0613EC; Sat, 2 Oct 2021 10:58:21 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id y23so12994454lfb.0; Sat, 02 Oct 2021 10:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JkjhFap2SaKbCVGK3B2tWxosThf62VIvzJlE9sE85OE=; b=oAVdA7Dmue10p33t50tGLK7NmxX7LZX/SLJlP2VjHiADCEAPRP1lUNWcgM+ZyeT2II UmY80EkAMBC0KGIt7OygVtjGOqcUYNM8riQeNjD7d5Q1Vte1iXH+u5kJDVMDVW7dt7Qb doINhDYzoHR/5HlRZdA8R3vL9aGQ3H4NloJqWgW2mFtA//F811UWGfloJ7ZEXks+DTQI 5m4Lt370Uqnbip+8+2PN7ZiVktJWGA8mxDL5SfUWMfFTUg83y9GNQAuzfCWvgS2vDUil sOFaYvy2NqpTgp7XhuorabRdExsXAXkNPGNNLG6mUaaX+8ytTfYc1CcJYgE7bmxe5WHN DGaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=JkjhFap2SaKbCVGK3B2tWxosThf62VIvzJlE9sE85OE=; b=rFCbVvh9O/1EKgspTVvMpGQgkv7ka15yHT3PLgzN9Gywa8e7KlPOhQf5fAbnBuMqyV sxlulXkZCiXfe21c7z84xfgm579I1SA7FI7W6wAtGWTRgNO77mzaJLPxYqJ4Kp9SntLT HDDNgf9XX0A79iQFpmtkijfYIpkxKzaS5BWC7O/gusvJ3jAqXqrniKylsDNVHz5+IMG6 wVHW7AKoiTsBYJaLmlsh3XxjmhBLDEc1N/PhhH+0O9Tf0m4IikASgMFcwLQwr7izuR6/ kLP6kBnFAF/9sMZvybHCln0KyKICzVTYXVZ6t2Gnx8aE2MeedrnG6jDGhrDCYmZGuEYG 2RNw== X-Gm-Message-State: AOAM533oAWdj1X81SqMejzYWRdtqCL0HzrYuwP3b1U1vrfNdm9DfYzSb CFLnv4cL10G/fqH5Vpg51RA= X-Google-Smtp-Source: ABdhPJx7j+bqqISG+zpYLqXO7exxTaMKYbSOJYhakMULTdwY1OZKxxSInen9GngredVEd7cyHpcIPA== X-Received: by 2002:a2e:d19:: with SMTP id 25mr4825511ljn.167.1633197499509; Sat, 02 Oct 2021 10:58:19 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t26sm1100043lfl.141.2021.10.02.10.58.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 10:58:18 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Florian Fainelli , devicetree@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 net-next 1/2] net: bgmac: improve handling PHY Date: Sat, 2 Oct 2021 19:58:11 +0200 Message-Id: <20211002175812.14384-1-zajec5@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Rafał Miłecki 1. Use info from DT if available It allows describing for example a fixed link. It's more accurate than just guessing there may be one (depending on a chipset). 2. Verify PHY ID before trying to connect PHY PHY addr 0x1e (30) is special in Broadcom routers and means a switch connected as MDIO devices instead of a real PHY. Don't try connecting to it. Signed-off-by: Rafał Miłecki Reviewed-by: Florian Fainelli --- V2: Promote it out of RFC and send together with MDIO patch per Florian's request. --- drivers/net/ethernet/broadcom/bgmac-bcma.c | 33 ++++++++++++++-------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma.c b/drivers/net/ethernet/broadcom/bgmac-bcma.c index 28759062d68d..7190e3f0da91 100644 --- a/drivers/net/ethernet/broadcom/bgmac-bcma.c +++ b/drivers/net/ethernet/broadcom/bgmac-bcma.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "bgmac.h" @@ -86,17 +87,28 @@ static int bcma_phy_connect(struct bgmac *bgmac) struct phy_device *phy_dev; char bus_id[MII_BUS_ID_SIZE + 3]; + /* DT info should be the most accurate */ + phy_dev = of_phy_get_and_connect(bgmac->net_dev, bgmac->dev->of_node, + bgmac_adjust_link); + if (phy_dev) + return 0; + /* Connect to the PHY */ - snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, bgmac->mii_bus->id, - bgmac->phyaddr); - phy_dev = phy_connect(bgmac->net_dev, bus_id, bgmac_adjust_link, - PHY_INTERFACE_MODE_MII); - if (IS_ERR(phy_dev)) { - dev_err(bgmac->dev, "PHY connection failed\n"); - return PTR_ERR(phy_dev); + if (bgmac->mii_bus && bgmac->phyaddr != BGMAC_PHY_NOREGS) { + snprintf(bus_id, sizeof(bus_id), PHY_ID_FMT, bgmac->mii_bus->id, + bgmac->phyaddr); + phy_dev = phy_connect(bgmac->net_dev, bus_id, bgmac_adjust_link, + PHY_INTERFACE_MODE_MII); + if (IS_ERR(phy_dev)) { + dev_err(bgmac->dev, "PHY connection failed\n"); + return PTR_ERR(phy_dev); + } + + return 0; } - return 0; + /* Assume a fixed link to the switch port */ + return bgmac_phy_connect_direct(bgmac); } static const struct bcma_device_id bgmac_bcma_tbl[] = { @@ -297,10 +309,7 @@ static int bgmac_probe(struct bcma_device *core) bgmac->cco_ctl_maskset = bcma_bgmac_cco_ctl_maskset; bgmac->get_bus_clock = bcma_bgmac_get_bus_clock; bgmac->cmn_maskset32 = bcma_bgmac_cmn_maskset32; - if (bgmac->mii_bus) - bgmac->phy_connect = bcma_phy_connect; - else - bgmac->phy_connect = bgmac_phy_connect_direct; + bgmac->phy_connect = bcma_phy_connect; err = bgmac_enet_probe(bgmac); if (err) From patchwork Sat Oct 2 17:58:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= X-Patchwork-Id: 12532327 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9FA6C433F5 for ; Sat, 2 Oct 2021 17:58:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D21A261B2F for ; Sat, 2 Oct 2021 17:58:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233789AbhJBSAL (ORCPT ); Sat, 2 Oct 2021 14:00:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233755AbhJBSAK (ORCPT ); Sat, 2 Oct 2021 14:00:10 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 786FAC0613F0; Sat, 2 Oct 2021 10:58:24 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id y23so17318909lfj.7; Sat, 02 Oct 2021 10:58:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gaRaKrEwRGzaX6BOqH5N99x59hBWZ2AV0k4uy5LgEBg=; b=XVjEd3id04JNAEcFq6xWLwCLJBBs9dz7ZxBHHe8ZFV+3zq3Ixc57dzgJVicmiD1gyg Rp3Hf6nEGujKg4eAc3kB0FC7qi/DBsVqS2G1KP2HjsisdEDV4n1oVI6Q3GD3TcwEdWCn Vso0mHgDlWgjIaZknrRGgqx9HmpQGjGv//IzhFlP/5PxUKjfoEQI4bg9bGr9HHYKmgRy uw+JX/TU7/p1EyuxogZ6pgVSCiXmZoBQA3ZUlucrU59e82Irv2+MD78YlPw8gtf/EdUL Pi+/Tkcq/8AXpixKc3sv3lbbVxq+0WDUl0xdg4DuN09Ra0AfBdmxB+WyEZaF10K9LHpf cjJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gaRaKrEwRGzaX6BOqH5N99x59hBWZ2AV0k4uy5LgEBg=; b=2YHvJA2rupJbXN2ydTd4d6pENJ6HfwifED54hnALhrNnCilV6IvKGh+ANNNT8SrA4I GsyUkLOWKqKQto6tSUcYAuMddGjQevqP5UAcCrpRmH7V3ZyKSi4FBjGAFmWLZv8SeokD RMurqnU754Jz1IW38Wz2t81QP9CYeJSCCIssCx4fgm36Pws8id0o5Z7gN1S8/4dvbtEI ii/GyIlGa7ojgJ+gBIkuUEGVZFutXxC5y/vgTHr3YBUPeXUnMhcbetCtluqq2ddG0IAt IoDZcTfblHpcGcMsQ8waBrDHsdgrC5gGuCGCS1xw8Wq/BK4vGPiiavHmSgrzRCNPDyNO H9Lw== X-Gm-Message-State: AOAM5337kIvqtpbpxgOi93BaeLpe89YO27gq4IMv90yaE88BMgEtgdWU V8RcQnp3Y4ITCCCykg807G8= X-Google-Smtp-Source: ABdhPJzbVgX6dyWALx2lhYNHzDYPScIyQ0eE4VJQDfdE2jmqtdnaSN17ldCOJ0mJGQ3eP9CjNlyqUA== X-Received: by 2002:a05:651c:1110:: with SMTP id d16mr4768779ljo.326.1633197502886; Sat, 02 Oct 2021 10:58:22 -0700 (PDT) Received: from localhost.lan (ip-194-187-74-233.konfederacka.maverick.com.pl. [194.187.74.233]) by smtp.gmail.com with ESMTPSA id t26sm1100043lfl.141.2021.10.02.10.58.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 10:58:22 -0700 (PDT) From: =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= To: "David S . Miller" , Jakub Kicinski Cc: netdev@vger.kernel.org, Florian Fainelli , devicetree@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH V2 net-next 2/2] net: bgmac: support MDIO described in DT Date: Sat, 2 Oct 2021 19:58:12 +0200 Message-Id: <20211002175812.14384-2-zajec5@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20211002175812.14384-1-zajec5@gmail.com> References: <20211002175812.14384-1-zajec5@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Rafał Miłecki Check ethernet controller DT node for "mdio" subnode and use it with of_mdiobus_register() when present. That allows specifying MDIO and its PHY devices in a standard DT based way. This is required for BCM53573 SoC support. That family is sometimes called Northstar (by marketing?) but is quite different from it. It uses different CPU(s) and many different hw blocks. One of shared blocks in BCM53573 is Ethernet controller. Switch however is not SRAB accessible (as it Northstar) but is MDIO attached. Signed-off-by: Rafał Miłecki --- V2: Update commit message to reference BCM53573. I thought it's worth it after Florian's question. Florian suggested I may need of_node_put() but it doesn't seem that of_get_child_by_name() or of_mdiobus_register() inc. any refcount. --- drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c index 6ce80cbcb48e..086739e4f40a 100644 --- a/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c +++ b/drivers/net/ethernet/broadcom/bgmac-bcma-mdio.c @@ -10,6 +10,7 @@ #include #include +#include #include "bgmac.h" static bool bcma_mdio_wait_value(struct bcma_device *core, u16 reg, u32 mask, @@ -211,6 +212,7 @@ struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac) { struct bcma_device *core = bgmac->bcma.core; struct mii_bus *mii_bus; + struct device_node *np; int err; mii_bus = mdiobus_alloc(); @@ -229,7 +231,9 @@ struct mii_bus *bcma_mdio_mii_register(struct bgmac *bgmac) mii_bus->parent = &core->dev; mii_bus->phy_mask = ~(1 << bgmac->phyaddr); - err = mdiobus_register(mii_bus); + np = of_get_child_by_name(core->dev.of_node, "mdio"); + + err = of_mdiobus_register(mii_bus, np); if (err) { dev_err(&core->dev, "Registration of mii bus failed\n"); goto err_free_bus;