Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2459574rdb; Mon, 12 Feb 2024 05:50:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGsTPqbfXC98JYC/cueeO7+pwyxW8z5YA8QYVZLIs3XAfQpJquK6BHab1grQjr1hztQtg0K X-Received: by 2002:a05:6870:a548:b0:21a:3083:5114 with SMTP id p8-20020a056870a54800b0021a30835114mr9370552oal.2.1707745833570; Mon, 12 Feb 2024 05:50:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707745833; cv=pass; d=google.com; s=arc-20160816; b=t6uVTcxo0vqJC4NCjo26NWT7CHZqTBvoP7EcSPfJYHEjBRwPQGjyjyu3UkrAhv7gFx yi2Co6CeOmdmOLxuklGG73oWmIPzq2X5DABHKjG990gwyufviVoh2sFBTaAYz20ha3sC NBF5PrgYhc1+7LwVcNxcH1FkTdou+4kJJI/66oP1254Wh13pfUE60ywArW27Z3kZA+hC 00rxud6/cGbMrP8K49lVaUm32lkBlsAEZzhbWHQ1PcrDo5j8lkaAXNzDdJOM9eajWHXP w6bx6R03Lsoi058ChN5ws0Y8702wVVTxp8w41d60lqs0TQIsIEV//30/Nyot+wdJV3mn xG5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=pM6whmgyRwSqq5DhU05BK7t5rD5rPlWu1apIXMRZECI=; fh=OiFbKxRZ9MOMn+pIYjd/1HISf+8BLPRH4hwR6XXVGi0=; b=AkOa1hVVCgIXR3sGiFzXbeeoeYUpjPO0SSwcbuyFPxPeD48RNM6Ep3iiFvAtu6HpR8 I/BIttQ2p1m7z2A97Ar4Jk1RAy1ni6fCmR19PYOajIRf1G8oyB79aqBQvOZLkjrX1Yle oNYnXV2lVJqI121ot+UtasQvSeBoK90Rqb+TO4mdk6pfevzG+8HmmG5gV0wSUJ5haJoR 61+RQQiqmNi5oq9gKakNQMemsxkz5n13Q7X8GWbbjFIBYFK0EZNN9utxJv4w+MjYh82U VzBgxMRPzOOO6Y4jhYEqDDLhZFC+/aVzFK0JIqxxzC0qPIdEszJ79eG9XttdvpFIQeUI 3K+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DawKnAGW; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-61730-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61730-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com X-Forwarded-Encrypted: i=2; AJvYcCWTkMARaZUdqNJZnASbK6gKZAqHU5q/Ihktj5/2I3BeRnfcaPRMLDh3cNmZ9XU340NE1iqq85+oX+TEvU/iCU86rjPrGhEYeaxKHntpNg== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x4-20020a656aa4000000b005cdf8b4d2fesi264536pgu.747.2024.02.12.05.50.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:50:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61730-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=DawKnAGW; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-61730-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61730-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3643828666B for ; Mon, 12 Feb 2024 13:50:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9CA13D97A; Mon, 12 Feb 2024 13:44:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="DawKnAGW" Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C15E3D549; Mon, 12 Feb 2024 13:44:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707745479; cv=none; b=kp8G6oZl23FWmdt34dBTMEq/dJiJZzoqo+HfEgnzJcymznA6LCW6hvE8Yjn/f+olL+fNvTLF0cw5trwOZiHj41Pj0cDv0jnGCioAg9Es+rfCxCgq1zFkWGZqEW0wfJp6/AyDKtdQcNZ5lCAGIgRY5p3E+SDbbrjaVWhxgZQDgqo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707745479; c=relaxed/simple; bh=YIEKqK5MI7C6wgG1cBeAfL6H69SH6ljkSO16YrF7vPc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bQiw0lfs62VVIzpDI5GcRrKZEQSyW97tZSj6US0XbBkP+JoniAq5SmS6UL/h3Lsxu95sZD3YLRGMB93j+WqFkoKDSShMyCd2PJy6PskEqcXgBYfkfwLDgCYXEzahR3mLxFSefZWCAjYTACPAAgOgmgNvE40cSxF34CLbQdiQFiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=DawKnAGW; arc=none smtp.client-ip=217.70.183.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 5ECEDFF802; Mon, 12 Feb 2024 13:44:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1707745475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pM6whmgyRwSqq5DhU05BK7t5rD5rPlWu1apIXMRZECI=; b=DawKnAGWiKXF0FSl4Sd28dy7tSWbsS9R1KLVoe+V4yFPbSIP8wOP3BE3bT64jf6cqe1jlf 8xsTa/OKgwb7eq2PqqByT8w3gmCtaBgG9a6PTV3GZfGu/gIWBMmY1uiM/sITT86ZIUdTsx 7LF/DYVEUUdLS/qM8l8LHPpT8IbtMGqBUv5s/+XieiCt0bf7/NEwcFrloOxhMAwYHhYKcA CVLe8sEHuNjkHT32aArX8gjbCsHC9HtonUl9aIxhbYQ57h47zfQPWW9NMvaZnnw5FvYn4M 9WT95vBiJVcgxK4CEELa4OVs6CCW7yZkrJpmMSvJugWqrigDRBCN3vmLB22aJg== From: =?utf-8?q?Th=C3=A9o_Lebrun?= Date: Mon, 12 Feb 2024 14:44:32 +0100 Subject: [PATCH v6 01/13] clk: fixed-factor: add optional accuracy support Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20240212-mbly-clk-v6-1-c46fa1f93839@bootlin.com> References: <20240212-mbly-clk-v6-0-c46fa1f93839@bootlin.com> In-Reply-To: <20240212-mbly-clk-v6-0-c46fa1f93839@bootlin.com> To: Gregory CLEMENT , Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Thomas Bogendoerfer , Linus Walleij , =?utf-8?q?Rafa=C5=82_Mi=C5=82ecki?= , Philipp Zabel Cc: Vladimir Kondratiev , linux-mips@vger.kernel.org, linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Thomas Petazzoni , Tawfik Bayouk , linux-gpio@vger.kernel.org, =?utf-8?q?Th=C3=A9o_Lebrun?= X-Mailer: b4 0.12.4 X-GND-Sasl: theo.lebrun@bootlin.com Fixed factor clock reports the parent clock accuracy. Add flags and acc fields to `struct clk_fixed_factor` to support setting a fixed accuracy. The default if no flag is set is not changed: use the parent clock accuracy. Signed-off-by: Théo Lebrun --- drivers/clk/clk-fixed-factor.c | 28 +++++++++++++++++++++------- include/linux/clk-provider.h | 12 +++++++++++- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c index b3e66202b942..bc2644a9bd7d 100644 --- a/drivers/clk/clk-fixed-factor.c +++ b/drivers/clk/clk-fixed-factor.c @@ -57,10 +57,22 @@ static int clk_factor_set_rate(struct clk_hw *hw, unsigned long rate, return 0; } +static unsigned long clk_factor_recalc_accuracy(struct clk_hw *hw, + unsigned long parent_accuracy) +{ + struct clk_fixed_factor *fix = to_clk_fixed_factor(hw); + + if (fix->flags & CLK_FIXED_FACTOR_FIXED_ACCURACY) + return fix->acc; + + return parent_accuracy; +} + const struct clk_ops clk_fixed_factor_ops = { .round_rate = clk_factor_round_rate, .set_rate = clk_factor_set_rate, .recalc_rate = clk_factor_recalc_rate, + .recalc_accuracy = clk_factor_recalc_accuracy, }; EXPORT_SYMBOL_GPL(clk_fixed_factor_ops); @@ -81,7 +93,7 @@ __clk_hw_register_fixed_factor(struct device *dev, struct device_node *np, const char *name, const char *parent_name, const struct clk_hw *parent_hw, int index, unsigned long flags, unsigned int mult, unsigned int div, - bool devm) + unsigned long acc, unsigned int fixflags, bool devm) { struct clk_fixed_factor *fix; struct clk_init_data init = { }; @@ -105,6 +117,8 @@ __clk_hw_register_fixed_factor(struct device *dev, struct device_node *np, fix->mult = mult; fix->div = div; fix->hw.init = &init; + fix->acc = acc; + fix->flags = fixflags; init.name = name; init.ops = &clk_fixed_factor_ops; @@ -152,7 +166,7 @@ struct clk_hw *devm_clk_hw_register_fixed_factor_index(struct device *dev, unsigned int mult, unsigned int div) { return __clk_hw_register_fixed_factor(dev, NULL, name, NULL, NULL, index, - flags, mult, div, true); + flags, mult, div, 0, 0, true); } EXPORT_SYMBOL_GPL(devm_clk_hw_register_fixed_factor_index); @@ -174,7 +188,7 @@ struct clk_hw *devm_clk_hw_register_fixed_factor_parent_hw(struct device *dev, unsigned long flags, unsigned int mult, unsigned int div) { return __clk_hw_register_fixed_factor(dev, NULL, name, NULL, parent_hw, - -1, flags, mult, div, true); + -1, flags, mult, div, 0, 0, true); } EXPORT_SYMBOL_GPL(devm_clk_hw_register_fixed_factor_parent_hw); @@ -184,7 +198,7 @@ struct clk_hw *clk_hw_register_fixed_factor_parent_hw(struct device *dev, { return __clk_hw_register_fixed_factor(dev, NULL, name, NULL, parent_hw, -1, flags, mult, div, - false); + 0, 0, false); } EXPORT_SYMBOL_GPL(clk_hw_register_fixed_factor_parent_hw); @@ -193,7 +207,7 @@ struct clk_hw *clk_hw_register_fixed_factor(struct device *dev, unsigned int mult, unsigned int div) { return __clk_hw_register_fixed_factor(dev, NULL, name, parent_name, NULL, -1, - flags, mult, div, false); + flags, mult, div, 0, 0, false); } EXPORT_SYMBOL_GPL(clk_hw_register_fixed_factor); @@ -240,7 +254,7 @@ struct clk_hw *devm_clk_hw_register_fixed_factor(struct device *dev, unsigned int mult, unsigned int div) { return __clk_hw_register_fixed_factor(dev, NULL, name, parent_name, NULL, -1, - flags, mult, div, true); + flags, mult, div, 0, 0, true); } EXPORT_SYMBOL_GPL(devm_clk_hw_register_fixed_factor); @@ -267,7 +281,7 @@ static struct clk_hw *_of_fixed_factor_clk_setup(struct device_node *node) of_property_read_string(node, "clock-output-names", &clk_name); hw = __clk_hw_register_fixed_factor(NULL, node, clk_name, NULL, NULL, 0, - 0, mult, div, false); + 0, mult, div, 0, 0, false); if (IS_ERR(hw)) { /* * Clear OF_POPULATED flag so that clock registration can be diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h index 1293c38ddb7f..7ddc952c8c67 100644 --- a/include/linux/clk-provider.h +++ b/include/linux/clk-provider.h @@ -1084,18 +1084,28 @@ void of_fixed_factor_clk_setup(struct device_node *node); * @hw: handle between common and hardware-specific interfaces * @mult: multiplier * @div: divider + * @acc: fixed accuracy in ppb + * @flags: behavior modifying flags * * Clock with a fixed multiplier and divider. The output frequency is the * parent clock rate divided by div and multiplied by mult. - * Implements .recalc_rate, .set_rate and .round_rate + * Implements .recalc_rate, .set_rate, .round_rate and .recalc_accuracy + * + * Flags: + * * CLK_FIXED_FACTOR_FIXED_ACCURACY - Use the value in @acc instead of the + * parent clk accuracy. */ struct clk_fixed_factor { struct clk_hw hw; unsigned int mult; unsigned int div; + unsigned long acc; + unsigned int flags; }; +#define CLK_FIXED_FACTOR_FIXED_ACCURACY BIT(0) + #define to_clk_fixed_factor(_hw) container_of(_hw, struct clk_fixed_factor, hw) extern const struct clk_ops clk_fixed_factor_ops; -- 2.43.0