From patchwork Mon Sep 5 16:15:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12966491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 813E6ECAAD3 for ; Mon, 5 Sep 2022 19:56:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=A7pDPphzGVt5OKmGMoHnotMjeOLcyAqqJhptlatejHM=; b=k9+pVXg4SbjNiB bcDo+FjO1sVYeNIY04pfzPoTBqjR79sf55Og5+UTEtXdORLvEJkbCoVu4cxnISBPiLJt4oDhXAu48 ryZNUhjoZd212vanPUdYObU0VBgCH6XMbD7PPNdUh11v22h8G06lj9UI08Qp6QQpiQff22u5QbQAe EO8mPP0yNDSH3IGMcQd10UStbRe3ru8CodHfu4O4HfhWiOwlExQPTAxxFWtL9ZkvrayTYDEo3CS8y Q+QHxHkm1lG+eF7w4xYgdCF/J/Vf8UagoIUz2hQdJx1fL2uGsgjr1g/tjRB6KFLyV9MeoFjbUzYAO IMo1yATK3G51/5KcfTRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVICU-009ljV-0p; Mon, 05 Sep 2022 19:56:06 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVEl7-006gT3-A5 for linux-arm-kernel@bombadil.infradead.org; Mon, 05 Sep 2022 16:15:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:Content-Type :MIME-Version:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=GSz8QcnAF3KVd+oYRHdCdNqyO/6sC9qiC/oawbq6vX0=; b=qaqgMEThrnZB+XqyFfJIpjQ99q EkYPyXsMkfTxqSFeCU1TYCAAs7dVgWT9+4/INS0FlzOmjHEa/22PLV+uiijNmko1u+k1CZosCwjWh UwxKZPjd7E3bbA+OYAJ5oqFy5PIyy/7vy/CsObhTw1Gbdtzc7cLORB1izJKCTetg/bJQ/uw3yhW6N hpG8S+KQNjV2FmPKazUg3T6Q09lUYQsWmxEFJBGYr7RsKCzZssvI+y1dhJHclhgQIMzlmY21/LcTK d8XY4HjurxEhlVMOYcuquRcOsgY8pGWQvOUNDsGkroVuBwNS/NZOlB/q2UxUyJZ+wgfbHQdHfIjIA lY0JrIXw==; Received: from mail-pj1-x102f.google.com ([2607:f8b0:4864:20::102f]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVEke-009o6t-Ai for linux-arm-kernel@lists.infradead.org; Mon, 05 Sep 2022 16:15:11 +0000 Received: by mail-pj1-x102f.google.com with SMTP id q15-20020a17090a304f00b002002ac83485so5088626pjl.0 for ; Mon, 05 Sep 2022 09:15:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date; bh=GSz8QcnAF3KVd+oYRHdCdNqyO/6sC9qiC/oawbq6vX0=; b=TZlspr0pqC2LgAzFjuWe4hTt2KUJ4JXaZhVc97pt14ru5A7+owVex9/HAE7cIKz5Jz UMOivxgzlnQ+1ldJyqEJ2EZCqbC15900NmBQKqE4mor/fPRtzZ4t4vGm4PsRQVb9mD27 nPpg6eqkGVGT4kJX0t6Bo4JKFoWRFzmHN3naf7v5LIDEKD83UVYJP/e70P27NYnf5UpU gfqp4uyhs8Y6EPUSYszMQxSRmxVyurTGqqEeX83PVQFSU13neePKB3MjxYFuOix57JD+ aIbbA8cMHFT7NUE9Qo0nioOQD4G/Qp5THv624d9YDb76JfcRT0uPwt+Q5FJH/b9ZicLM +Bwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=GSz8QcnAF3KVd+oYRHdCdNqyO/6sC9qiC/oawbq6vX0=; b=CUDILSJHIkPz8z1Y1MMJUZ3y02shFRVm9reGEQy+HTAc6j7Nn/MCSPzu3vDXE9j0Yr woeqHY08Hw6KYFlvTKXjC4uJ9+W3StT7YD/oNtcOyKNk2Oa5pxP9tRLhcZFE8teK9Syf hPrPqaMBH64zzGdmBc7PCAfeF/65JcGKFJrP4OxNiulazb/LfLpSNBM0UgqgHcnjMguo t3CpI7Tu+hoBORWffV0qZex5wkIekDpjLMSii72xJ98FG+fp8tJxA0flA9wb0W5DvyxO c+T2DnZbuO6oHu7Li6oWjSAitq1Z1oFzfg9mv+qLYNMnRY4jxArQUapk9ujB4kG80z7k I2fQ== X-Gm-Message-State: ACgBeo0EGnmHYAMqTW3wCZWKVFeQiQ8mfloWgMHpHdD8XDDETxHnr//B EwTvVvJByfzIgdHlPjadf1I= X-Google-Smtp-Source: AA6agR6pRp+Oljy6r7Avsn/FovLn/AmM5J1ds+hM+Vy7Ewdg2DvGlA3YA4fF/rJfyRId1YnjOJ0oyQ== X-Received: by 2002:a17:902:f787:b0:172:f321:2fd1 with SMTP id q7-20020a170902f78700b00172f3212fd1mr48939853pln.121.1662394505225; Mon, 05 Sep 2022 09:15:05 -0700 (PDT) Received: from 7YHHR73.igp.broadcom.net (ip72-194-116-95.oc.oc.cox.net. [72.194.116.95]) by smtp.gmail.com with ESMTPSA id t12-20020a170902e84c00b0016d5b7fb02esm7817622plg.60.2022.09.05.09.15.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Sep 2022 09:15:04 -0700 (PDT) From: Florian Fainelli To: linux-clk@vger.kernel.org Cc: Florian Fainelli , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= , Michael Turquette , Stephen Boyd , Ray Jui , Scott Branden , Broadcom internal kernel review list , Allison Randal , Thomas Gleixner , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM IPROC ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] clk: iproc: Do not rely on node name for correct PLL setup Date: Mon, 5 Sep 2022 09:15:03 -0700 Message-Id: <20220905161504.1526-1-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220905_171508_433920_83F10440 X-CRM114-Status: GOOD ( 14.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org After commit 31fd9b79dc58 ("ARM: dts: BCM5301X: update CRU block description") a warning from clk-iproc-pll.c was generated due to a duplicate PLL name as well as the console stopped working. Upon closer inspection it became clear that iproc_pll_clk_setup() used the Device Tree node unit name as an unique identifier as well as a parent name to parent all clocks under the PLL. BCM5301X was the first platform on which that got noticed because of the DT node unit name renaming but the same assumptions hold true for any user of the iproc_pll_clk_setup() function. The first 'clock-output-names' property is always guaranteed to be unique as well as providing the actual desired PLL clock name, so we utilize that to register the PLL and as a parent name of all children clock. Fixes: 5fe225c105fd ("clk: iproc: add initial common clock support") Signed-off-by: Florian Fainelli Acked-by: Rafał Miłecki --- Changes in v2: - added Acked-by - remove empty newline drivers/clk/bcm/clk-iproc-pll.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/clk/bcm/clk-iproc-pll.c b/drivers/clk/bcm/clk-iproc-pll.c index 1a098db12062..680f9d8d357c 100644 --- a/drivers/clk/bcm/clk-iproc-pll.c +++ b/drivers/clk/bcm/clk-iproc-pll.c @@ -726,6 +726,7 @@ void iproc_pll_clk_setup(struct device_node *node, const char *parent_name; struct iproc_clk *iclk_array; struct clk_hw_onecell_data *clk_data; + const char *clk_name; if (WARN_ON(!pll_ctrl) || WARN_ON(!clk_ctrl)) return; @@ -773,7 +774,12 @@ void iproc_pll_clk_setup(struct device_node *node, iclk = &iclk_array[0]; iclk->pll = pll; - init.name = node->name; + ret = of_property_read_string_index(node, "clock-output-names", + 0, &clk_name); + if (WARN_ON(ret)) + goto err_pll_register; + + init.name = clk_name; init.ops = &iproc_pll_ops; init.flags = 0; parent_name = of_clk_get_parent_name(node, 0); @@ -793,13 +799,11 @@ void iproc_pll_clk_setup(struct device_node *node, goto err_pll_register; clk_data->hws[0] = &iclk->hw; + parent_name = clk_name; /* now initialize and register all leaf clocks */ for (i = 1; i < num_clks; i++) { - const char *clk_name; - memset(&init, 0, sizeof(init)); - parent_name = node->name; ret = of_property_read_string_index(node, "clock-output-names", i, &clk_name);