From patchwork Mon Aug 7 19:31:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13344761 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80CECC001DB for ; Mon, 7 Aug 2023 19:32:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1ky6onDwx06YGBY2Zd6TyjFwI2d+JY8nSSApp6VVWXM=; b=a401CasuK9bpbd v6ga8YRDbujJZGGpenwfoFpr3OGsurEsr85tw9HINEvdL/9beV5OdtRT+RHfqHnx8P+M2kRKZE/ks NJRnFJoBOxT9/CcDsrmChXQsiIh3RIYFE910BzffPZdY1JkgUeSQYE4ejnE7HcF1XNoY6JKYvAoW1 BrG17RnhxaL+Vrkjp2ZCOItY1D+f3KwCmH3LpPZBCpHWOGMXCdNdzZPa/nnBipqHnkgrkN8igpSOP TyGjyvvBQ2V8chUiM3/yEFG2uzAlZRI9peKMdPSAhvf9+bWVTjnPEdar1nRSBQ+rrVSQ+prF1PqIs 33gLXJ/h5v4jUGt5mR+g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qT5x6-000Vj9-2n; Mon, 07 Aug 2023 19:31:40 +0000 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qT5x1-000Vgs-2a for linux-arm-kernel@lists.infradead.org; Mon, 07 Aug 2023 19:31:37 +0000 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-31783d02093so4267919f8f.0 for ; Mon, 07 Aug 2023 12:31:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1691436693; x=1692041493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=eAPKS4SAXmZKxicJb9ydkGPtaas2WIonOZ7to+HEfxA=; b=tOmh3T/d1Kx4g5+xfWbagK8zeGuje07up/l4PO1tcHXwuVmvIvKezEFEUOszEceBwv WLoDiMbUQkX8jTprThvfI+94af++yK1HBv5TLq1zf5liFa6GUHWuLrbyYBO0KyAAx0sW G2YMRuSYtUZkPA6TUkDb0scVx1tV5W+yGsHfFKU+iwvrWydYuU/0Yd+dyq0Z6CgdXhCl kxKph2hAcWnEy/TuTREzxTULR40oj+9vctCBPlWjIp1S+PjMazFOy9kN+l9V1dn6ae0X x8M6Hk9pZxtjeD89oR/plTnS6CIGysZeXPcQ6k/Tppw434ibY95fOMnSJJIDiU5GfYxO OpuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691436693; x=1692041493; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eAPKS4SAXmZKxicJb9ydkGPtaas2WIonOZ7to+HEfxA=; b=ffhcUCtlM7WP11fa9A1My4VX0b99ZZ7IyNP6nfyTnU17nown5YbxQRDjjbm4Fr4Okc 8rjJtosg5fibsj9rim07mQjr8ZxonYO56oE+LyfKqDR2mKWtbRC1rDMuALXXtDXN5z0J TwT4axmeH2y4SlfxDfURAV8QpFV2Uoyw67EmAnpbVvA8mIMGiWZ4QNEqSRGa8ueKH6ZD M7Y8xG87mNjYapang4uAS+UzAmooDrd3nUU62kNzHl5TTkOd3rJp/blnn28DtRjJaHg2 YVEJoOXyxJAKV024uCk19wfq4G2PvHUp3WKzEU5MEH+GQ/YtFXMBxBMRf3wRK9c0UofD p1Dg== X-Gm-Message-State: AOJu0Yz0FqBDQZfe7HjuqDHBCSQ96q7//IfdyLZVZGSnt9wVCH7bYbC7 A97CNDGLMvnGT1AAzacxXeztpQ== X-Google-Smtp-Source: AGHT+IFftT9bB5ixmjqvw1q7hvp1QMCeUhqraDuekV0noaWoXd5f9+2RWAbtpR5sMmr8DxPlkMO5oQ== X-Received: by 2002:a5d:6683:0:b0:317:67fa:eeb4 with SMTP id l3-20020a5d6683000000b0031767faeeb4mr7411809wru.57.1691436693519; Mon, 07 Aug 2023 12:31:33 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:b3d6:9e6:79d9:37cd]) by smtp.gmail.com with ESMTPSA id l7-20020a7bc347000000b003fbdbd0a7desm15985654wmj.27.2023.08.07.12.31.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 12:31:33 -0700 (PDT) From: Bartosz Golaszewski To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Andrew Halaney , Alex Elder , Srini Kandagatla Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski Subject: [PATCH 1/2] dt-bindings: net: snps,dwmac: document the snps,shared-mdio property Date: Mon, 7 Aug 2023 21:31:01 +0200 Message-Id: <20230807193102.6374-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230807193102.6374-1-brgl@bgdev.pl> References: <20230807193102.6374-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230807_123135_839099_5DA89983 X-CRM114-Status: GOOD ( 11.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski Two MACs may share one MDIO lines to their respective PHYs. In this case one of the MACs is the logical "owner" of the bus, while the other can be considered a secondary controller. Add a new property that allows one MAC node to reference the MDIO node on a different MAC over a phandle. Signed-off-by: Bartosz Golaszewski --- Documentation/devicetree/bindings/net/snps,dwmac.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/devicetree/bindings/net/snps,dwmac.yaml b/Documentation/devicetree/bindings/net/snps,dwmac.yaml index ddf9522a5dc2..f9c2285674d1 100644 --- a/Documentation/devicetree/bindings/net/snps,dwmac.yaml +++ b/Documentation/devicetree/bindings/net/snps,dwmac.yaml @@ -500,6 +500,12 @@ properties: required: - compatible + snps,shared-mdio: + $ref: /schemas/types.yaml#/definitions/phandle + description: + Phandle to the mdio node defined on a different MAC node which this + device shares. + stmmac-axi-config: type: object unevaluatedProperties: false From patchwork Mon Aug 7 19:31:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 13344762 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8BBEDC001DB for ; Mon, 7 Aug 2023 19:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zBITdIIwWugRMwmtfnf0uxrXsrg6hujgsAKHBKhENEo=; b=mnN15RYGlPmi1j 6oUkAyguuwuPC4w75A3sRHcBywdknWx6uUvj5XOMF1hl7KFRilrkik930ax8M1Xvf/8yjwVgHPdu/ zdNKICdhCwp3rIWgoHmhkUsBnpaaBgNasK1xilJqF88iM3RRgqJj86VPwR6t6LN4SUrse37XUCm6y 4QJ8qHcMThWK9J5DAyYHEh2RtiT+hr6LO/SkNFvq5jZWHcbA7RIca6zcVW19Wi6BFlz49mu1isJDZ SvzHkOQypH3H07hmPaWAsigVR87wsVTCtHBzhKXWL0sq4PGWmGkY9MjBwLpDxwtkv30fc0Y/GcOrH fjQHA3+xwadZ5HLxP9qA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qT5x7-000VjV-18; Mon, 07 Aug 2023 19:31:41 +0000 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qT5x3-000VhK-0f for linux-arm-kernel@lists.infradead.org; Mon, 07 Aug 2023 19:31:38 +0000 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-317716a4622so3858998f8f.1 for ; Mon, 07 Aug 2023 12:31:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20221208.gappssmtp.com; s=20221208; t=1691436695; x=1692041495; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gUv2dCmaY1HQ3Em9YoZBFw+fysyiFKPhrXvqJWxPFfc=; b=fwYEVPozF0KvOAt3mvF2iWylh9QmqRqt6P7UQtmErMGi7zH3ak4HGMUMpMJ2bZ1lXm VYM/qx/GA1gZswRwl/BrgW8MPuzikyAs9Uxg3IBlbTWatJ03xBxshTdi4JF1qsKXjU1Z /irX6Ft5wQ+jIRnRo1aHiCGv3cgH7YDlBandU2g9jE10W7Khmwr/xqTS4Fj3vUO9DuL0 JwJ2sEeD3P7L1CiXMTb1Sjq0RnceQPtkEL4ODMK8QJzK7EQlNwG4r2u8V2vuZ4wfRueI HkX0Rlz77K+vIPk4wurJ+N4egWqsykC0CyJYc+WeeM9z8hzqB5rMFP7iOL9imijzAxEK AUug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691436695; x=1692041495; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gUv2dCmaY1HQ3Em9YoZBFw+fysyiFKPhrXvqJWxPFfc=; b=G+o8PwtWj5yVTUtk543slX9kf1BuAP3tx2dT4mIPNj39vvQaxz6X7Ux6R68W06OBIe Q3o8Mh58wUN7joJePlc27sJWCNyrt6p1KKoZyLLeWLUi0jzFFsdMD5EOm/654gCoryKt akEqDNskdAEorzNt9Gbjdl0paBdr1VSk1nDrl0QPNonRswJj70cDJ9bh9eIJkTzmFv2w VUm8A3UeynqHsctxQ8pBf+w9E05/49qluTYzMT/z2R6ZP8PNO7ZcHHFR3IGx1Xd4UxpB Grj16nJ6lcyb4DBOeRVjpmqeVSTDxG72WyiQeVh56TB7QSIUbl0+AnBPE3kQ2sXSO8Vk Ab4Q== X-Gm-Message-State: AOJu0Ywjot9LdxLfZQ/GW1AiL71h7kGqaZ/EoOWssV+bgoHUAV10FDHW +sKa+Z/DN9RMaRp0ZpAuzYLolQ== X-Google-Smtp-Source: AGHT+IGKHNN7HjiGFusOQDWkTj+8K7D28pYI8N1+cBGqCVE35V0LUQ9gkEQ2lEJmnrAT6utfK07xtA== X-Received: by 2002:a5d:5912:0:b0:317:606d:c767 with SMTP id v18-20020a5d5912000000b00317606dc767mr5959349wrd.44.1691436694877; Mon, 07 Aug 2023 12:31:34 -0700 (PDT) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:b3d6:9e6:79d9:37cd]) by smtp.gmail.com with ESMTPSA id l7-20020a7bc347000000b003fbdbd0a7desm15985654wmj.27.2023.08.07.12.31.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 12:31:34 -0700 (PDT) From: Bartosz Golaszewski To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Torgue , Jose Abreu , Maxime Coquelin , Andrew Halaney , Alex Elder , Srini Kandagatla Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, Bartosz Golaszewski Subject: [PATCH 2/2] net: stmmac: support shared MDIO Date: Mon, 7 Aug 2023 21:31:02 +0200 Message-Id: <20230807193102.6374-3-brgl@bgdev.pl> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230807193102.6374-1-brgl@bgdev.pl> References: <20230807193102.6374-1-brgl@bgdev.pl> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230807_123137_259862_084D6BC3 X-CRM114-Status: GOOD ( 15.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Bartosz Golaszewski When two MACs share the MDIO lines to their respective PHYs, one is considered the logical "owner" of the bus. The secondary controller must wait until the MDIO bus is registered before trying to attach to the PHY. If the mdio node is not defined for given MAC, try to read the "snps,shared-mdio" property on its node. If it exists, parse the phandle and store the result as the MAC's mdio device-tree node. When registering the MDIO bus: if we know that we share it with another MAC, lookup the MDIO bus and if it's not up yet, defer probe until it is. Signed-off-by: Bartosz Golaszewski --- drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 8 ++++++++ drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 6 ++++++ include/linux/stmmac.h | 1 + 3 files changed, 15 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c index dd9e2fec5328..6a74b91595d0 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c @@ -543,6 +543,14 @@ int stmmac_mdio_register(struct net_device *ndev) if (!mdio_bus_data) return 0; + if (priv->plat->flags & STMMAC_FLAG_SHARED_MDIO) { + new_bus = of_mdio_find_bus(mdio_node); + if (!new_bus) + return -EPROBE_DEFER; + + goto bus_register_done; + } + new_bus = mdiobus_alloc(); if (!new_bus) return -ENOMEM; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index be8e79c7aa34..11a24b1c7beb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -340,6 +340,12 @@ static int stmmac_dt_phy(struct plat_stmmacenet_data *plat, } } + if (!plat->mdio_node) { + plat->mdio_node = of_parse_phandle(np, "snps,shared-mdio", 0); + if (plat->mdio_node) + plat->flags |= STMMAC_FLAG_SHARED_MDIO; + } + if (plat->mdio_node) { dev_dbg(dev, "Found MDIO subnode\n"); mdio = true; diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 3d0702510224..892f61051002 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -218,6 +218,7 @@ struct dwmac4_addrs { #define STMMAC_FLAG_INT_SNAPSHOT_EN BIT(9) #define STMMAC_FLAG_RX_CLK_RUNS_IN_LPI BIT(10) #define STMMAC_FLAG_EN_TX_LPI_CLOCKGATING BIT(11) +#define STMMAC_FLAG_SHARED_MDIO BIT(12) struct plat_stmmacenet_data { int bus_id;