From patchwork Mon Feb 5 04:45:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kumar, Udit" X-Patchwork-Id: 13544967 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 E087FC48291 for ; Mon, 5 Feb 2024 04:50:13 +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=MwpTEqkDII3YWVhpHOAieFldK9ZQzE4INCln2bE6JhY=; b=saekUgaBWLvVJ7 +o/IhIvnnlsEz4iOvkoSWVFgil8iYeNcAnLY5KiLJdGqJoCjOJbacQsnl3Ne01TDBVsl8j2iBugda 1jddtCdgSgmB33yMiRrj8rL0X6RdZErGhKv6p7RjTCqw51b38ACgcyXpMh3P9X1HJDMD3/IEPaKpM 0N+Jlg5Zu7Iavmv+YzsjDKUPfZEr+m4Yx6dZ/SOBtMWY/jr0mRDS9D3NENc+p48J6dAjzI+MLFsNA lp87QdxyI/9Lqb5Us/e+k8KUPenlh02j61ctd7wTGoSJ4I1pWGwGLQEfdR9JJVERs4J9K9vWC/jgw Go75/e4SMhnKRpR+6h2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWqve-000000021FP-03rP; Mon, 05 Feb 2024 04:49:58 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWqvc-000000021Ee-3ilX for linux-arm-kernel@bombadil.infradead.org; Mon, 05 Feb 2024 04:49:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Content-Transfer-Encoding :MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender:Reply-To:Content-ID: Content-Description:In-Reply-To:References; bh=Xtnfb8xnQNhu/YXCkFubO57gi1E2WQInflCGp92loXQ=; b=mDznqqlP4xJAQ4/vjLlRcAD34w 18W1+e2jaFtmZoc5iOtnwTFs7knO4b0LqPNZMcTYISsXU9Weol1Tg9hxRvU3Nmauwx2PaJpe/8MAP 8uPUltabzu28pZI0oSNKqq2BXM5W9BR+J+jhpNOKfyBGTaJMVW9WqrT5efBtzlLAJEwup6VysEMj6 TiybcFZSRZ0XDQD5MF4NuvVNUEuCSv6CSC0pkO0DEs1L5hGnEFbzEPsG5fFfZFv2xCMStYwznxQ3m FTYXxkNNL6BoDciiv8rGJOJ6NSoVm0/phSVlcALhJJyQGB9x5XpQWX/dlH8wouPspVn3vHjReZUhy Y1GtcQxg==; Received: from lelv0143.ext.ti.com ([198.47.23.248]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWqvG-0000000BcA9-2gci for linux-arm-kernel@lists.infradead.org; Mon, 05 Feb 2024 04:49:43 +0000 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 4154nElG022636; Sun, 4 Feb 2024 22:49:14 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1707108554; bh=Xtnfb8xnQNhu/YXCkFubO57gi1E2WQInflCGp92loXQ=; h=From:To:CC:Subject:Date; b=cOON0SHvZCUNGkGhchQdw7q+4bpaFV9mnhg0AQDO9GSCKkxzkOuEaWO4QqUa16+49 8k2/LwQs8SjG+mM/LxQCT4P5MFcvljlwbtCJQur5gjTgjPJ/wlsLXMot1TxnIoq7XD VEOLYb5P1K82DJE/Hbm4pkl6bK9Gv1MupKij/z+Q= Received: from DFLE101.ent.ti.com (dfle101.ent.ti.com [10.64.6.22]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 4154nE5h031263 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 4 Feb 2024 22:49:14 -0600 Received: from DFLE111.ent.ti.com (10.64.6.32) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Sun, 4 Feb 2024 22:49:13 -0600 Received: from lelvsmtp5.itg.ti.com (10.180.75.250) by DFLE111.ent.ti.com (10.64.6.32) 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; Sun, 4 Feb 2024 22:49:13 -0600 Received: from udit-HP-Z2-Tower-G9-Workstation-Desktop-PC.dhcp.ti.com (udit-hp-z2-tower-g9-workstation-desktop-pc.dhcp.ti.com [172.24.227.18]) by lelvsmtp5.itg.ti.com (8.15.2/8.15.2) with ESMTP id 4154nA0K035269; Sun, 4 Feb 2024 22:49:11 -0600 From: Udit Kumar To: , , CC: , , , , , , Udit Kumar Subject: [PATCH v1] clk: keystone: sci-clk: Adding support for non contiguous clocks Date: Mon, 5 Feb 2024 10:15:58 +0530 Message-ID: <20240205044557.3340848-1-u-kumar1@ti.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240205_044936_386611_2B948E04 X-CRM114-Status: GOOD ( 13.61 ) 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 Most of clocks and their parents are defined in contiguous range, But in few cases, there is gap in clock numbers[0]. Driver assumes clocks to be in contiguous range, and assigns accordingly. New firmware started returning error in case of non-available clock id. Therefore drivers throws error while re-calculate and other functions. In this fix, before assigning and adding clock in list, driver checks if given clock is valid or not. Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") [0] https://software-dl.ti.com/tisci/esd/latest/5_soc_doc/j7200/clocks.html Section Clocks for NAVSS0_CPTS_0 Device, clock id 12-15 and 18-19 not present Signed-off-by: Udit Kumar --- Original logs https://gist.github.com/uditkumarti/de4b36b21247fb36725ad909ce4812f6#file-original-logs Line 2630 for error Logs with fix https://gist.github.com/uditkumarti/de4b36b21247fb36725ad909ce4812f6#file-with-fix Line 2594 drivers/clk/keystone/sci-clk.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 35fe197dd303..d417ec018d82 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -517,6 +517,8 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) int num_clks = 0; int num_parents; int clk_id; + int max_clk_id; + u64 freq; const char * const clk_names[] = { "clocks", "assigned-clocks", "assigned-clock-parents", NULL }; @@ -584,6 +586,7 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) } clk_id = args.args[1] + 1; + max_clk_id = clk_id + num_parents; while (num_parents--) { sci_clk = devm_kzalloc(dev, @@ -592,11 +595,20 @@ static int ti_sci_scan_clocks_from_dt(struct sci_clk_provider *provider) if (!sci_clk) return -ENOMEM; sci_clk->dev_id = args.args[0]; - sci_clk->clk_id = clk_id++; - sci_clk->provider = provider; - list_add_tail(&sci_clk->node, &clks); + /* check if given clock id is valid by calling get_freq */ + /* loop over max possible ids */ + do { + sci_clk->clk_id = clk_id++; - num_clks++; + ret = provider->ops->get_freq(provider->sci, + sci_clk->dev_id, sci_clk->clk_id, &freq); + } while (ret != 0 && clk_id < max_clk_id); + + sci_clk->provider = provider; + if (ret == 0) { + list_add_tail(&sci_clk->node, &clks); + num_clks++; + } } }