From patchwork Wed Jan 24 06:49:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MD Danish Anwar X-Patchwork-Id: 1890278 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; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256 header.s=ti-com-17Q1 header.b=ny3bR0q/; dkim-atps=neutral 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=patchwork.ozlabs.org) 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 (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TKkD02Z54z23dy for ; Wed, 24 Jan 2024 23:44:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3EB9987D03; Wed, 24 Jan 2024 13:42:16 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="ny3bR0q/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DB42C87BDB; Wed, 24 Jan 2024 07:50:11 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id BA33C87BC3 for ; Wed, 24 Jan 2024 07:50:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=danishanwar@ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 40O6nsn3046290; Wed, 24 Jan 2024 00:49:54 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1706078994; bh=x7aY9ffWo9JhqOF3C72DnKKwvNRELhyVld2cFIeWDZI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ny3bR0q/tbT4+d/VnwPVjlDFSsI2egBDGNzax0ZonOOQbdcCsk3HnIDbDamh9x6xS PJRYZ4JEM0he15YSzI12PtzhV2Q8Xs7GVisEau96BuSEf6QqhOTF4ItsAV9i/91rv7 h3h4dXLK5r/uXz3R49QBONmAgDfvreSXSCyuTpdM= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 40O6nsRT069040 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 24 Jan 2024 00:49:54 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 24 Jan 2024 00:49:53 -0600 Received: from fllvsmtp7.itg.ti.com (10.64.40.31) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 24 Jan 2024 00:49:53 -0600 Received: from lelv0854.itg.ti.com (lelv0854.itg.ti.com [10.181.64.140]) by fllvsmtp7.itg.ti.com (8.15.2/8.15.2) with ESMTP id 40O6nr9h098836; Wed, 24 Jan 2024 00:49:53 -0600 Received: from localhost (danish-tpc.dhcp.ti.com [10.24.69.25]) by lelv0854.itg.ti.com (8.14.7/8.14.7) with ESMTP id 40O6nqum010998; Wed, 24 Jan 2024 00:49:53 -0600 From: MD Danish Anwar To: Dan Carpenter , Maxime Ripard , Siddharth Vadapalli , Roger Quadros , Matthias Schiffer , Stefan Roese , Qu Wenruo , Bryan Brattlof , Sean Anderson , Martyn Welch , Heinrich Schuchardt , Christian Gmeiner , Nishanth Menon , Vignesh Raghavendra , Nikhil M Jain , Kamlesh Gurudasani , Manorit Chawdhry , Neha Malcom Francis , Andrew Davis , Simon Glass , MD Danish Anwar , FUKAUMI Naoki , Christian Hewitt , Hai Pham , Svyatoslav Ryhel , Jonas Karlman , Neil Armstrong , Marek Vasut , Michal Simek , Kever Yang , Ramon Fried , Joe Hershberger CC: , , Subject: [RFC PATCH v3 09/15] net: ti: icssg: Enforce pinctrl state on the MDIO child node Date: Wed, 24 Jan 2024 12:19:24 +0530 Message-ID: <20240124064930.1787929-10-danishanwar@ti.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240124064930.1787929-1-danishanwar@ti.com> References: <20240124064930.1787929-1-danishanwar@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Wed, 24 Jan 2024 13:42:05 +0100 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. 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: MD Danish Anwar --- drivers/net/ti/Kconfig | 1 + drivers/net/ti/icssg_prueth.c | 59 +++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/drivers/net/ti/Kconfig b/drivers/net/ti/Kconfig index 9fead2c7ce..6935b70e12 100644 --- a/drivers/net/ti/Kconfig +++ b/drivers/net/ti/Kconfig @@ -53,6 +53,7 @@ config TI_AM65_CPSW_NUSS config TI_ICSSG_PRUETH bool "TI Gigabit PRU Ethernet driver" depends on ARCH_K3 + imply DM_MDIO select PHYLIB help Support Gigabit Ethernet ports over the ICSSG PRU Subsystem diff --git a/drivers/net/ti/icssg_prueth.c b/drivers/net/ti/icssg_prueth.c index 50af9a2bc6..225928e477 100644 --- a/drivers/net/ti/icssg_prueth.c +++ b/drivers/net/ti/icssg_prueth.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -103,9 +104,56 @@ static int icssg_phy_init(struct udevice *dev) return ret; } +static ofnode prueth_find_mdio(ofnode parent) +{ + ofnode node; + + ofnode_for_each_subnode(node, parent) + if (ofnode_device_is_compatible(node, "ti,davinci_mdio")) + return node; + + return ofnode_null(); +} + +static int prueth_mdio_setup(struct udevice *dev) +{ + struct prueth *priv = dev_get_priv(dev); + struct udevice *mdio_dev; + ofnode mdio; + int ret; + + mdio = prueth_find_mdio(dev_ofnode(priv->pruss)); + 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 icssg_mdio_init(struct udevice *dev) { struct prueth *prueth = dev_get_priv(dev); + int ret; + + ret = prueth_mdio_setup(dev); + if (ret) + return ret; prueth->bus = cpsw_mdio_init(dev->name, prueth->mdio_base, prueth->mdio_freq, @@ -701,3 +749,14 @@ U_BOOT_DRIVER(prueth) = { .plat_auto = sizeof(struct eth_pdata), .flags = DM_FLAG_ALLOC_PRIV_DMA, }; + +static const struct udevice_id prueth_mdio_ids[] = { + { .compatible = "ti,davinci_mdio" }, + { } +}; + +U_BOOT_DRIVER(prueth_mdio) = { + .name = "prueth_mdio", + .id = UCLASS_MDIO, + .of_match = prueth_mdio_ids, +};