From patchwork Thu Dec 15 22:38:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 1716307 X-Patchwork-Delegate: trini@ti.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=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=vVc+AWHn; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.a=rsa-sha256 header.s=phobos-20191101 header.b=yddB5Dsw; 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 4NY6Zy2DT7z23yr for ; Fri, 16 Dec 2022 09:38:34 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 0301385355; Thu, 15 Dec 2022 23:38:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1671143908; bh=3jp7Ln9OSX38PiT9XSpz9Fu9NOEZraiM6TlEuZZRtfs=; h=From:To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=vVc+AWHn/xBLByrPatCqyHMeaJ5oK5taCBGvxnOXwu2hLej0q/QlgJcy/EIVocJ+u FH/bYCgGrLgos/b3PApzsQkNQCNET3uFwb7pP7iubwqlmwkZpXowKzre8hA9+TylJZ 3nF1Quh4IZbWrms4RYLuLwBUC/WwPnGxislAaGPnQFHn50CBW7ckP14yq71eZyZJGU qaM5C5V33qyQUbvUl0Q38SwVM8Z6KVJn2gmU5Wedi8U1The0moC9KxqhuGycZOcPfB 9pfxF9vhTbbqC4FJozrzodWLcHFtUhOD8IyksFkii2DlQ00guYf9JSrw45uP4TKFkF Mj4XuMFTfRmbA== Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 13A8D8532F; Thu, 15 Dec 2022 23:38:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1671143906; bh=3jp7Ln9OSX38PiT9XSpz9Fu9NOEZraiM6TlEuZZRtfs=; h=From:To:Cc:Subject:Date:From; b=yddB5DswMZ/BfcV6vdYCU77E4HzTMp7shSYI4eobznmzvehoITivdo7svYeoOdePZ 9CzxX8IjMBzhdc25FR4ATIV7E62kL834/GZPl9kD2HpUfb0pyFuPJF5bh2K5eLJ8bv Z+fSTBhFFOQ0e4q/9Do8uUTVZJssTqMWGq10jpcGzH8U5ObxPwmylPzM+elP2kF6Yc NGnD2pwG5slLFEDjr2n4P6Qggou4BfaU+IYVgz23m/Qx+brlaLSQTkRzfU6daDhmJm mQLXRSbBFtRd3d8BkiBe78rr4L4j0lf7JpVCxgtrnXdpNTk2+ewxVPu03m1BDP2CwE UYqe28kiopN4g== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Angus Ainslie , Bin Meng , Fabio Estevam , Kunihiko Hayashi , Michal Simek , Peng Fan , Stefano Babic Subject: [PATCH] usb: dwc3: Look up reference clock DT phandle in both controller DT nodes Date: Thu, 15 Dec 2022 23:38:22 +0100 Message-Id: <20221215223822.137739-1-marex@denx.de> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 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.6 at phobos.denx.de X-Virus-Status: Clean There are currently four disparate placement possibilities of DWC3 reference clock phandle in SoC DTs: - in top level glue node, with generic subnode without clock (ZynqMP) - in top level generic node, with no subnode (i.MX8MQ) - in generic subnode, with other clock in top level node (i.MX8MP) - in both top level node and generic subnode (Rockchip) Cover all the possibilities here by looking into both nodes, start with the top level node as that seems to be used in majority of DTs to reference the clock. Signed-off-by: Marek Vasut --- Cc: Angus Ainslie Cc: Bin Meng Cc: Fabio Estevam Cc: Kunihiko Hayashi Cc: Michal Simek Cc: Peng Fan Cc: Stefano Babic --- drivers/usb/dwc3/dwc3-generic.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 78966718d01..42e92478f25 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -68,10 +68,27 @@ static int dwc3_generic_probe(struct udevice *dev, #if CONFIG_IS_ENABLED(OF_CONTROL) dwc3_of_parse(dwc3); + /* + * There are currently four disparate placement possibilities of DWC3 + * reference clock phandle in SoC DTs: + * - in top level glue node, with generic subnode without clock (ZynqMP) + * - in top level generic node, with no subnode (i.MX8MQ) + * - in generic subnode, with other clock in top level node (i.MX8MP) + * - in both top level node and generic subnode (Rockchip) + * Cover all the possibilities here by looking into both nodes, start + * with the top level node as that seems to be used in majority of DTs + * to reference the clock. + */ node = dev_ofnode(dev->parent); index = ofnode_stringlist_search(node, "clock-names", "ref"); if (index < 0) index = ofnode_stringlist_search(node, "clock-names", "ref_clk"); + if (index < 0) { + node = dev_ofnode(dev); + index = ofnode_stringlist_search(node, "clock-names", "ref"); + if (index < 0) + index = ofnode_stringlist_search(node, "clock-names", "ref_clk"); + } if (index >= 0) dwc3->ref_clk = &glue->clks.clks[index]; #endif