From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB8E2C48BD1 for ; Fri, 11 Jun 2021 08:46:46 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1591061019 for ; Fri, 11 Jun 2021 08:46:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1591061019 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A37D780371; Fri, 11 Jun 2021 10:46:05 +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="SimiMdAi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 89CA3801DE; Fri, 11 Jun 2021 10:45:50 +0200 (CEST) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) (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 5EF1A800A5 for ; Fri, 11 Jun 2021 10:45:46 +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=kristo@kernel.org Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B324613C6; Fri, 11 Jun 2021 08:45:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1623401146; bh=6rEArvyRL1Q7AWVqWlJpk+ixFi3nYHlOAqBhuaNao/A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SimiMdAiiKWuLVQJejNkVHruOE6qJ9BXDbGzqFoClkWNls5gSo3ZSsToGSdJ0wAYt BXEIX29RirK4HU9kf5DSlgf1NoRTPARlRyJkVHNl23oToJ0ysqlgyXP2BoIBo12ikC WlwObCHhLf2QyCgwfxperUlaHvENGQOJOvPt8CV5L95pleDwpsjA7pAF+VMo3Ct9A0 USAFNFVSTh0hXHgItIVcN4NhYCmbeFjTzOrqsQ/CWQ2n0nE6KfbKEcc1NKYj7KTZ4y 6ir7PVGszBwllc/pG/whit8S4jM7dZCh62uyqK8XNSbj6kW48Sm14cHAOT0lddFrP4 LHzgEqZONPa0g== From: Tero Kristo To: lokeshvutla@ti.com, trini@konsulko.com, u-boot@lists.denx.de Subject: [PATCHv6 06/26] clk: fix clock tree dump to properly dump out every registered clock Date: Fri, 11 Jun 2021 11:45:07 +0300 Message-Id: <20210611084527.7048-7-kristo@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210611084527.7048-1-kristo@kernel.org> References: <20210611084527.7048-1-kristo@kernel.org> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean From: Tero Kristo Some clocks are not associated to a DM node, so just parsing the DM is not enough. This is especially true for root clocks, which typically don't have any parents. Instead, fetch every registered UCLASS_CLK instance, and dump these out. Signed-off-by: Tero Kristo Signed-off-by: Tero Kristo --- cmd/clk.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/cmd/clk.c b/cmd/clk.c index e3c3d2f9bb..0245b97136 100644 --- a/cmd/clk.c +++ b/cmd/clk.c @@ -18,11 +18,14 @@ static void show_clks(struct udevice *dev, int depth, int last_flag) { int i, is_last; struct udevice *child; - struct clk *clkp; + struct clk *clkp, *parent; u32 rate; clkp = dev_get_clk_ptr(dev); if (device_get_uclass_id(dev) == UCLASS_CLK && clkp) { + parent = clk_get_parent(clkp); + if (!IS_ERR(parent) && depth == -1) + return; depth++; rate = clk_get_rate(clkp); @@ -47,6 +50,9 @@ static void show_clks(struct udevice *dev, int depth, int last_flag) } list_for_each_entry(child, &dev->child_head, sibling_node) { + if (child == dev) + continue; + is_last = list_is_last(&child->sibling_node, &dev->child_head); show_clks(child, depth, (last_flag << 1) | is_last); } @@ -54,14 +60,19 @@ static void show_clks(struct udevice *dev, int depth, int last_flag) int __weak soc_clk_dump(void) { - struct udevice *root; + struct udevice *dev; + struct uclass *uc; + int ret; - root = dm_root(); - if (root) { - printf(" Rate Usecnt Name\n"); - printf("------------------------------------------\n"); - show_clks(root, -1, 0); - } + ret = uclass_get(UCLASS_CLK, &uc); + if (ret) + return ret; + + printf(" Rate Usecnt Name\n"); + printf("------------------------------------------\n"); + + uclass_foreach_dev(dev, uc) + show_clks(dev, -1, 0); return 0; } -- 2.17.1