From patchwork Thu Jul 20 09:55:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 1810492 X-Patchwork-Delegate: rfried.dev@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=h99DYmgJ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R6F5x6PR6z1yYm for ; Fri, 21 Jul 2023 00:13:25 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 48C48867EA; Thu, 20 Jul 2023 16:13:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="h99DYmgJ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9F0CB8672B; Thu, 20 Jul 2023 11:56:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 10D498637D for ; Thu, 20 Jul 2023 11:56:09 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=mripard@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE9B3619E1; Thu, 20 Jul 2023 09:56:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC5E7C433C8; Thu, 20 Jul 2023 09:56:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689846967; bh=s/XTtK0O6O/zqTP1Z+4SURv2RLQnjLwDBFnOruZkr7w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=h99DYmgJTTCTdGWmbK7WtHPjMJfPd2LDXvEdLwP8Grs158pLvydrn1o8pZ8hftxAc wp0JyNP9ARE1qqEBqId7RdnnAIntpFQS6zkuDBPydgijTXxMfculCbcJuxDry2quyZ ukgCwekMasPWHelnuQ6IeGYdWBg5+JtR4DcvuO2uj1dfdhc89TwpImTcaVOcrszP0D cjgVXcneP5BIW4kMTDM6ygsNq82CuVEcQfScpIHHCzxe+8ksIinpNTlzjlVmCbtgpD jzNr4rL7mFCZHLHzshV5udDPhtfVOjFW8Ib6CW698KiWn1m2CYeQUAIuJQ9PXVClNR Ud2pInm7ZRiUQ== From: Maxime Ripard Date: Thu, 20 Jul 2023 11:55:57 +0200 Subject: [PATCH 2/4] net: ti: am65-cpsw-nuss: Enforce pinctrl state on the MDIO child node MIME-Version: 1.0 Message-Id: <20230720-ti-mdio-pinmux-v1-2-0bd3bd1cf759@kernel.org> References: <20230720-ti-mdio-pinmux-v1-0-0bd3bd1cf759@kernel.org> In-Reply-To: <20230720-ti-mdio-pinmux-v1-0-0bd3bd1cf759@kernel.org> To: Simon Glass , Joe Hershberger , Ramon Fried , Nishanth Menon , Ravi Gunasekaran Cc: Javier Martinez Canillas , Peter Robinson , u-boot@lists.denx.de, Maxime Ripard X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=2792; i=mripard@kernel.org; h=from:subject:message-id; bh=s/XTtK0O6O/zqTP1Z+4SURv2RLQnjLwDBFnOruZkr7w=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCk7WdZpKFVI3pp/qJ81mDnUflPcsdIZOWeW7LRR+PChZ gFHtp5YRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACbCYsPIMEPr2ckNdU8rwy+9 Xjjf2X1fl+TU5Va2MQsPt2UtuHvx2hKGf5o/26898zkmUl+5jGHpeostac/PCxyXa32md3u297p CTgYA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-Mailman-Approved-At: Thu, 20 Jul 2023 16:12:58 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The binding represents the MDIO controller as a child device tree node of the MAC device tree node. The U-Boot driver mostly ignores that child device tree node and just hardcodes the resources it uses to support both the MAC and MDIO in a single driver. However, some resources like pinctrl muxing states are thus ignored. This has been a problem with device trees since Linux 6.5-rc1 which will put some pinctrl states on the MDIO device tree node. Let's rework the driver a bit to fetch the pinctrl state from the MDIO node and apply it. Signed-off-by: Maxime Ripard --- drivers/net/ti/am65-cpsw-nuss.c | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c index f674b0baa359..2d579bf4af2c 100644 --- a/drivers/net/ti/am65-cpsw-nuss.c +++ b/drivers/net/ti/am65-cpsw-nuss.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -696,6 +697,50 @@ out: return ret; } +static ofnode am65_cpsw_find_mdio(ofnode parent) +{ + ofnode node; + + ofnode_for_each_subnode(node, parent) + if (ofnode_device_is_compatible(node, "ti,cpsw-mdio")) + return node; + + return ofnode_null(); +} + +static int am65_cpsw_setup_mdio(struct udevice *dev) +{ + ofnode mdio; + int ret; + + mdio = am65_cpsw_find_mdio(dev_ofnode(dev)); + if (!ofnode_valid(mdio)) + return -ENODEV; + + /* + * The MDIO controller is represented in the DT binding by a + * subnode of the MAC controller. + * + * Our driver largely ignores that and supports MDIO by + * hardcoding the register offsets. + * + * However, some resources (clocks, pinctrl) might be tied to + * the MDIO node, and thus ignored. + * + * Clocks are not a concern at the moment since it's shared + * between the MAC and MDIO, so the driver handles both at the + * same time. + * + * However, we do need to make sure the pins states tied to the + * MDIO node are configured properly. + */ + ret = pinctrl_select_state_by_ofnode(dev, mdio, "default"); + if (ret) + return ret; + + return 0; +} + static int am65_cpsw_probe_nuss(struct udevice *dev) { struct am65_cpsw_common *cpsw_common = dev_get_priv(dev); @@ -728,6 +773,10 @@ static int am65_cpsw_probe_nuss(struct udevice *dev) AM65_CPSW_CPSW_NU_ALE_BASE; cpsw_common->mdio_base = cpsw_common->ss_base + AM65_CPSW_MDIO_BASE; + ret = am65_cpsw_setup_mdio(dev); + if (ret) + goto out; + ports_np = dev_read_subnode(dev, "ethernet-ports"); if (!ofnode_valid(ports_np)) { ret = -ENOENT;