From patchwork Mon Jul 24 13:57:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 1811837 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=85.214.62.61; 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=P3Fc4814; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R8hdb61bwz1yZw for ; Tue, 25 Jul 2023 00:00:51 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0267B86872; Mon, 24 Jul 2023 16:00:44 +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="P3Fc4814"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6E608688B; Mon, 24 Jul 2023 15:59:24 +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 23EA08686E for ; Mon, 24 Jul 2023 15:58:40 +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 4EAD86120E; Mon, 24 Jul 2023 13:57:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D35CC433C7; Mon, 24 Jul 2023 13:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690207056; bh=F2Rg6COqS7pa0PFn/rXTzfJ46mnuDjJguHH0UN1NYE8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=P3Fc4814QCB2g4KlhmQ1j4LuuCCWXkSu+IeHCBFrKV7fzlBmZbBeP6CnAZZZsS5xH EePhOIDrlm+6AnosYJdssZcPaJ4gML+cskIs3Imr+nReO+NBjEJCTO+kSvmNNolSk+ Mg8Movlrgc+vsYkD87RtZbmL2GgMWaxT79fgxqKeZkdcQrFC9wScLZZKadzbbRSW1T IzxCkYWfPLv7qB6Q1e5BHmvquvIH7XXZrAreqOO8HPQxsZRbltdGn30sVJjczAfQO1 9YBX3f1gIcpEPcc56dPRwHzuy7IZt3s5jBKZTgB1I8LQlYd2cSAnOfZ3oAS2ZcrAob pFyuF8QFSPtUg== From: Maxime Ripard Date: Mon, 24 Jul 2023 15:57:30 +0200 Subject: [PATCH v4 1/2] net: ti: am65-cpsw-nuss: Enforce pinctrl state on the MDIO child node MIME-Version: 1.0 Message-Id: <20230724-ti-mdio-pinmux-v4-1-18541f976501@kernel.org> References: <20230724-ti-mdio-pinmux-v4-0-18541f976501@kernel.org> In-Reply-To: <20230724-ti-mdio-pinmux-v4-0-18541f976501@kernel.org> To: Joe Hershberger , Nishanth Menon , Ramon Fried , Ravi Gunasekaran , Roger Quadros , Simon Glass 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=3819; i=mripard@kernel.org; h=from:subject:message-id; bh=F2Rg6COqS7pa0PFn/rXTzfJ46mnuDjJguHH0UN1NYE8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCn7mr1EhF98u8iwf3HH5wd+h2bcdNXcZ/3M92aph9sPv 7i3zDqvOkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRTBdGhlMbrpxlPrt+BzPL hl8cR6/eKdlQJV+vMk1Adc65wivHwg8yMlz+kxEs7shfsT9DfOfT3d/MDAWfvf2i039w/aElbz4 tXsgEAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D 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 some device trees that will put some pinctrl states on the MDIO device tree node, like the SK-AM62 Device Tree does. Let's rework the driver a bit to create a dummy MDIO driver that we will then get during our initialization to force the core to select the right muxing. Signed-off-by: Maxime Ripard Reviewed-by: Siddharth Vadapalli Acked-by: Roger Quadros Acked-by: Nishanth Menon --- drivers/net/ti/Kconfig | 1 + drivers/net/ti/am65-cpsw-nuss.c | 60 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/drivers/net/ti/Kconfig b/drivers/net/ti/Kconfig index d9f1c019a885..02660e4fbb44 100644 --- a/drivers/net/ti/Kconfig +++ b/drivers/net/ti/Kconfig @@ -41,6 +41,7 @@ endchoice config TI_AM65_CPSW_NUSS bool "TI K3 AM65x MCU CPSW Nuss Ethernet controller driver" depends on ARCH_K3 + imply DM_MDIO imply MISC_INIT_R imply MISC imply SYSCON diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c index ce52106e5238..51a8167d14a9 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 @@ -605,14 +606,62 @@ static const struct soc_attr k3_mdio_soc_data[] = { { /* sentinel */ }, }; +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_mdio_setup(struct udevice *dev) +{ + struct am65_cpsw_priv *priv = dev_get_priv(dev); + struct am65_cpsw_common *cpsw_common = priv->cpsw_common; + struct udevice *mdio_dev; + ofnode mdio; + int ret; + + mdio = am65_cpsw_find_mdio(dev_ofnode(cpsw_common->dev)); + if (!ofnode_valid(mdio)) + return 0; + + /* + * The MDIO controller is represented in the DT binding by a + * subnode of the MAC controller. + * + * We don't have a DM driver for the MDIO device yet, and thus any + * pinctrl setting on its node will be ignored. + * + * However, we do need to make sure the pins states tied to the + * MDIO node are configured properly. Fortunately, the core DM + * does that for use when we get a device, so we can work around + * that whole issue by just requesting a dummy MDIO driver to + * probe, and our pins will get muxed. + */ + ret = uclass_get_device_by_ofnode(UCLASS_MDIO, mdio, &mdio_dev); + if (ret) + return ret; + + return 0; +} + static int am65_cpsw_mdio_init(struct udevice *dev) { struct am65_cpsw_priv *priv = dev_get_priv(dev); struct am65_cpsw_common *cpsw_common = priv->cpsw_common; + int ret; if (!priv->has_phy || cpsw_common->bus) return 0; + ret = am65_cpsw_mdio_setup(dev); + if (ret) + return ret; + cpsw_common->bus = cpsw_mdio_init(dev->name, cpsw_common->mdio_base, cpsw_common->bus_freq, @@ -868,3 +917,14 @@ U_BOOT_DRIVER(am65_cpsw_nuss_port) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA | DM_FLAG_OS_PREPARE, }; + +static const struct udevice_id am65_cpsw_mdio_ids[] = { + { .compatible = "ti,cpsw-mdio" }, + { } +}; + +U_BOOT_DRIVER(am65_cpsw_mdio) = { + .name = "am65_cpsw_mdio", + .id = UCLASS_MDIO, + .of_match = am65_cpsw_mdio_ids, +}; From patchwork Mon Jul 24 13:57:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 1811841 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=GBp4U9EB; 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)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4R8hfW2YVGz1yZw for ; Tue, 25 Jul 2023 00:01:39 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8D558868B5; Mon, 24 Jul 2023 16:01:02 +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="GBp4U9EB"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D61538688B; Mon, 24 Jul 2023 15:59:22 +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 245518686F for ; Mon, 24 Jul 2023 15:58:40 +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 3E43461212; Mon, 24 Jul 2023 13:57:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 402B1C433C8; Mon, 24 Jul 2023 13:57:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690207059; bh=HdWM2DonklQuHNRLk0wp15xXXoXFmgHaum8heQtJ4FQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GBp4U9EBkmoqaJyMOUxE1pCBNAE9VfkdneRbjmBX3Y3ZigSZBWXx6WbJfa3s+pg0X nL3lkjMXakMnWG75RlyLZihhjscThSx5ggd8NnuG71uaw+HA/KlHYnZgvdm+7ViXUd UO5JIBn72T8Pie+DNh5HcoRugGk0VY6Hf4zflB2C+7Cw0LbuerL4lN0eHFhcmmfp3J XQJqM6Qhfqnqgh44KMhSYYv2uE3SyvBoXSGWx+yEXr/5PlFl4WRtpmIS8KZ6g63Msd cDNvA2JSRDueHImR/P3OijXPzcAsh9f6nFcRpOrGfFfpI2IY18XSHNL5WbCT1zsy47 dzCWFiktUaNjg== From: Maxime Ripard Date: Mon, 24 Jul 2023 15:57:31 +0200 Subject: [PATCH v4 2/2] fixup! arm: dts: k3-am62: Bump dtsi from linux v6.5-rc1 MIME-Version: 1.0 Message-Id: <20230724-ti-mdio-pinmux-v4-2-18541f976501@kernel.org> References: <20230724-ti-mdio-pinmux-v4-0-18541f976501@kernel.org> In-Reply-To: <20230724-ti-mdio-pinmux-v4-0-18541f976501@kernel.org> To: Joe Hershberger , Nishanth Menon , Ramon Fried , Ravi Gunasekaran , Roger Quadros , Simon Glass 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=760; i=mripard@kernel.org; h=from:subject:message-id; bh=HdWM2DonklQuHNRLk0wp15xXXoXFmgHaum8heQtJ4FQ=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDCn7mr0YE87nBzAEbTG5qd34cFJVjN6WD6FGkinlloXOe dd1o6s6SlkYxLgYZMUUWWKEzZfEnZr1upONbx7MHFYmkCEMXJwCMJGNlowMr+9sc1CdXGE0bcHS I6FtEWKr7We45H3tld1oG6T/4MRfUYa/Yimfe/jWay+brWlh9Zjn3OsPCz5FMR/Zo/Ph333jy9G reAA= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D 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 MDIO pinctrl nodes can't be duplicated between the child and device, because if we ever boot Linux with our DT it will try to attach that pinctrl configuration to both the MAC and MDIO devices, which will result in failure to probe. Signed-off-by: Maxime Ripard --- arch/arm/dts/k3-am625-sk-u-boot.dtsi | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/dts/k3-am625-sk-u-boot.dtsi b/arch/arm/dts/k3-am625-sk-u-boot.dtsi index a3f207baa304..c1685bc9ca39 100644 --- a/arch/arm/dts/k3-am625-sk-u-boot.dtsi +++ b/arch/arm/dts/k3-am625-sk-u-boot.dtsi @@ -120,7 +120,6 @@ &cpsw3g { bootph-pre-ram; - pinctrl-0 = <&main_mdio1_pins_default &main_rgmii1_pins_default>; }; &cpsw_port1 {