From patchwork Thu Nov 17 15:51:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13046996 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5951EC433FE for ; Thu, 17 Nov 2022 15:51:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239679AbiKQPvP (ORCPT ); Thu, 17 Nov 2022 10:51:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234851AbiKQPvK (ORCPT ); Thu, 17 Nov 2022 10:51:10 -0500 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51A3270A06; Thu, 17 Nov 2022 07:51:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668700269; x=1700236269; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=BWDzsCwCXR7fUBoOm58dEqg3TsEeYspRHu9MmmNT8XE=; b=TUVfhWZ9+tB1Q2263cJigbnWMLw5ULJCLWiLWvAn0A7KATLeXKvWpAbx 5v42wCp/ShxZ0uLUc8S6lOw3YYQ6TxbEex5c7AcDknYRWIcUOcNP1goho lmyDOj5+6sh32A/TQfQoh/6awqo42P+kY8zmcxF71zni9xzf8m7wm/J3V DGnEEnlRzXxth/ozquYHumyfbQUdwajqqqanzkEX8aukpVGBPDgkPXAKA A876czyXojg3QgqpttynY9s3O2pzEjkr7Pl0CMUy17DFbi18sUYzYPZEw YRaT7i1OEuWr5qsInqqa1jcVkDQGvVrNLCiFvJUVlqn8OHYlh2xt5+R2L g==; X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="375016483" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="375016483" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 07:50:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="814557612" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="814557612" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga005.jf.intel.com with ESMTP; 17 Nov 2022 07:50:49 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id E9D8A2B7; Thu, 17 Nov 2022 17:51:13 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Turquette , Stephen Boyd Subject: [PATCH v1 1/3] clk: fractional-divider: Split out clk_fd_get_div() helper Date: Thu, 17 Nov 2022 17:51:03 +0200 Message-Id: <20221117155105.1486-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org Split out clk_fd_get_div() helper for the future use elsewhere. Signed-off-by: Andy Shevchenko --- drivers/clk/clk-fractional-divider.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c index 8efa5142ff8c..5c6f1d0f8fb4 100644 --- a/drivers/clk/clk-fractional-divider.c +++ b/drivers/clk/clk-fractional-divider.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -63,14 +64,12 @@ static inline void clk_fd_writel(struct clk_fractional_divider *fd, u32 val) writel(val, fd->reg); } -static unsigned long clk_fd_recalc_rate(struct clk_hw *hw, - unsigned long parent_rate) +static void clk_fd_get_div(struct clk_hw *hw, struct u32_fract *fract) { struct clk_fractional_divider *fd = to_clk_fd(hw); unsigned long flags = 0; unsigned long m, n; u32 val; - u64 ret; if (fd->lock) spin_lock_irqsave(fd->lock, flags); @@ -92,11 +91,22 @@ static unsigned long clk_fd_recalc_rate(struct clk_hw *hw, n++; } - if (!n || !m) + fract->numerator = m; + fract->denominator = n; +} + +static unsigned long clk_fd_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) +{ + struct u32_fract fract; + u64 ret; + + clk_fd_get_div(hw, &fract); + + if (!fract.numerator || !fract.denominator) return parent_rate; - ret = (u64)parent_rate * m; - do_div(ret, n); + ret = (u64)parent_rate * fract.numerator; + do_div(ret, fract.denominator); return ret; } From patchwork Thu Nov 17 15:51:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13046995 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B109C433FE for ; Thu, 17 Nov 2022 15:51:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234893AbiKQPvD (ORCPT ); Thu, 17 Nov 2022 10:51:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234851AbiKQPvB (ORCPT ); Thu, 17 Nov 2022 10:51:01 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F64E701B1; Thu, 17 Nov 2022 07:51:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668700260; x=1700236260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6MgUUvyelCWY06xmow9rc5WGciB3OvxEMw2tLw+abCI=; b=QvD1DJK3SUgCU5a0bnz3FiSqhtlwyE93sWDISpJ8HKzGMwzeD+s9zs8Y uDqJseOqu2wWqhEsjU11/GzXtwK6jMTV7TEMTfeYaPMXjUyqMJfMdR0QM n6w78EBI5gIhfaxdNqWuguf7XOJqWaH2LiyCf7FBsoBAtf+wCaeBotnuC SXSQlsU6AQ9+yAMrO+vjY9SzXBV4MFTbc93JLoCZEj1EBfCwxumEptULe JGfE/JLPZiGe/Jl/tWcCA0Fx+tDcFvqr8Yj8prdic3WtYiQ5a2IlSpOY0 lFZ/x79gXgrMgSEraHGwXSgenwrbAh72XWmU53Zhlj0Fhb86MHVGlk/7O w==; X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="312898973" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="312898973" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 07:50:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="968919505" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="968919505" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 17 Nov 2022 07:50:49 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 023D6B7; Thu, 17 Nov 2022 17:51:13 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Turquette , Stephen Boyd Subject: [PATCH v1 2/3] clk: fractional-divider: Show numerator and denominator in debugfs Date: Thu, 17 Nov 2022 17:51:04 +0200 Message-Id: <20221117155105.1486-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221117155105.1486-1-andriy.shevchenko@linux.intel.com> References: <20221117155105.1486-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org It's very useful to see what are the values of the fractional divider. For that, add respective debugfs files. Signed-off-by: Andy Shevchenko --- drivers/clk/clk-fractional-divider.c | 36 ++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c index 5c6f1d0f8fb4..b6b52b79d671 100644 --- a/drivers/clk/clk-fractional-divider.c +++ b/drivers/clk/clk-fractional-divider.c @@ -39,6 +39,7 @@ */ #include +#include #include #include #include @@ -193,10 +194,45 @@ static int clk_fd_set_rate(struct clk_hw *hw, unsigned long rate, return 0; } +#ifdef CONFIG_DEBUG_FS +static int clk_fd_numerator_get(void *hw, u64 *val) +{ + struct u32_fract fract; + + clk_fd_get_div(hw, &fract); + + *val = fract.numerator; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(clk_fd_numerator_fops, clk_fd_numerator_get, NULL, "%llu\n"); + +static int clk_fd_denominator_get(void *hw, u64 *val) +{ + struct u32_fract fract; + + clk_fd_get_div(hw, &fract); + + *val = fract.denominator; + + return 0; +} +DEFINE_DEBUGFS_ATTRIBUTE(clk_fd_denominator_fops, clk_fd_denominator_get, NULL, "%llu\n"); + +static void clk_fd_debug_init(struct clk_hw *hw, struct dentry *dentry) +{ + debugfs_create_file("numerator", 0444, dentry, hw, &clk_fd_numerator_fops); + debugfs_create_file("denominator", 0444, dentry, hw, &clk_fd_denominator_fops); +} +#endif + const struct clk_ops clk_fractional_divider_ops = { .recalc_rate = clk_fd_recalc_rate, .round_rate = clk_fd_round_rate, .set_rate = clk_fd_set_rate, +#ifdef CONFIG_DEBUG_FS + .debug_init = clk_fd_debug_init, +#endif }; EXPORT_SYMBOL_GPL(clk_fractional_divider_ops); From patchwork Thu Nov 17 15:51:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 13046994 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0FA9BC4332F for ; Thu, 17 Nov 2022 15:51:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233202AbiKQPvB (ORCPT ); Thu, 17 Nov 2022 10:51:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232330AbiKQPvA (ORCPT ); Thu, 17 Nov 2022 10:51:00 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7BAA701A3; Thu, 17 Nov 2022 07:50:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1668700260; x=1700236260; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=cYyJRRqnn9LuozWNUU94VNSroJbrg0Ie5N7Qf+vQFFo=; b=i07X19J3FLnKXHXXo2G24rT3ifV8NOgsOb3hlsjIm/VJ5m5VV3FBXQeD jpwSmhHHMiBc7ekkzuoRZaZ6l221UGRs3loAKzrVJCfPuXHIaOfHSOg0J aB5vJR1GtsZFTzNlHWBRn+PTwzr+yfVbzI4Si6gSdorKYo768zg4BDuqX FDhv8merY8So21tUclfQEX/2RP3AJ+4ZShZf/UpTdgqAn4ScRfMROKmsH jaS+WjFPE532tJtHqT9pX2VBHeh3fODiXuIwhAAayCHb0bS+UByTDZ1/r wWZbo/qW59OCkTylgff+d2SLFcbTjMpH2Jtc1X+fFEIqAybM48JqwOt61 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="312898971" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="312898971" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Nov 2022 07:50:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10534"; a="968919504" X-IronPort-AV: E=Sophos;i="5.96,171,1665471600"; d="scan'208";a="968919504" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 17 Nov 2022 07:50:48 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 0EEEC385; Thu, 17 Nov 2022 17:51:14 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Michael Turquette , Stephen Boyd Subject: [PATCH v1 3/3] clk: fractional-divider: Regroup inclusions Date: Thu, 17 Nov 2022 17:51:05 +0200 Message-Id: <20221117155105.1486-3-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221117155105.1486-1-andriy.shevchenko@linux.intel.com> References: <20221117155105.1486-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org For the better maintenance regroup inclusions as follows: - split CCF related headers in its own group - order groups from generic to particular - sort each group alphabetically Signed-off-by: Andy Shevchenko --- drivers/clk/clk-fractional-divider.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/clk/clk-fractional-divider.c b/drivers/clk/clk-fractional-divider.c index b6b52b79d671..ebd007f5ce5d 100644 --- a/drivers/clk/clk-fractional-divider.c +++ b/drivers/clk/clk-fractional-divider.c @@ -40,12 +40,14 @@ #include #include +#include #include #include #include -#include -#include #include +#include + +#include #include "clk-fractional-divider.h"