From: Ahmad Fatoum <a.fatoum@barebox.org>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@barebox.org>
Subject: [PATCH v2 10/13] clk: implement clk_have_nonfixed_providers
Date: Wed, 13 Aug 2025 16:33:42 +0200 [thread overview]
Message-ID: <20250813143345.3758653-11-a.fatoum@barebox.org> (raw)
In-Reply-To: <20250813143345.3758653-1-a.fatoum@barebox.org>
This function will be called from the upcoming bfetch command to
determine whether the running barebox has a CCF clock tree that goes
beyond fixed clocks for board-level oscillators.
Signed-off-by: Ahmad Fatoum <a.fatoum@barebox.org>
---
v1 -> v2:
- fix typo in commit message s/regulators/clocks/
---
drivers/clk/clk-fixed.c | 7 +++++++
drivers/clk/clk-fixed.h | 11 +++++++++++
drivers/clk/clk.c | 14 ++++++++++++++
include/linux/clk.h | 9 +++++++++
4 files changed, 41 insertions(+)
create mode 100644 drivers/clk/clk-fixed.h
diff --git a/drivers/clk/clk-fixed.c b/drivers/clk/clk-fixed.c
index 6ec2feb84f9e..ea081d0f22de 100644
--- a/drivers/clk/clk-fixed.c
+++ b/drivers/clk/clk-fixed.c
@@ -9,6 +9,8 @@
#include <linux/clk.h>
#include <linux/err.h>
+#include "clk-fixed.h"
+
struct clk_fixed {
struct clk_hw hw;
unsigned long rate;
@@ -27,6 +29,11 @@ static struct clk_ops clk_fixed_ops = {
.is_enabled = clk_is_enabled_always,
};
+bool clk_is_fixed(struct clk *clk)
+{
+ return clk->ops == &clk_fixed_ops;
+}
+
struct clk *clk_register_fixed_rate(const char *name,
const char *parent_name, unsigned long flags,
unsigned long rate)
diff --git a/drivers/clk/clk-fixed.h b/drivers/clk/clk-fixed.h
new file mode 100644
index 000000000000..d7f7a12cb60d
--- /dev/null
+++ b/drivers/clk/clk-fixed.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _CLK_FIXED_H
+#define _CLK_FIXED_H
+
+#include <linux/types.h>
+
+struct clk;
+
+bool clk_is_fixed(struct clk *clk);
+
+#endif
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 1fa9027bc6cd..89a007a12c5b 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -14,8 +14,22 @@
#include <linux/clk/clk-conf.h>
#include <pinctrl.h>
+#include "clk-fixed.h"
+
static LIST_HEAD(clks);
+bool clk_have_nonfixed_providers(void)
+{
+ struct clk *c;
+
+ list_for_each_entry(c, &clks, list) {
+ if (!clk_is_fixed(c))
+ return true;
+ }
+
+ return false;
+}
+
static int clk_parent_enable(struct clk *clk)
{
struct clk *parent = clk_get_parent(clk);
diff --git a/include/linux/clk.h b/include/linux/clk.h
index f893d9071371..526641927754 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -11,6 +11,7 @@
#define __LINUX_CLK_H
#include <linux/err.h>
+#include <linux/types.h>
#include <linux/spinlock.h>
#include <linux/stringify.h>
#include <linux/string.h>
@@ -971,6 +972,9 @@ static inline void clk_hw_unregister(struct clk_hw *hw)
#ifdef CONFIG_COMMON_CLK
+bool clk_have_nonfixed_providers(void);
+
+
/**
* clk_bulk_get - lookup and obtain a number of references to clock producer.
* @dev: device for clock "consumer"
@@ -1085,6 +1089,11 @@ int __must_check clk_bulk_enable(int num_clks,
void clk_bulk_disable(int num_clks, const struct clk_bulk_data *clks);
#else
+static inline bool clk_have_nonfixed_providers(void)
+{
+ return false;
+}
+
static inline int __must_check clk_bulk_get(struct device *dev, int num_clks,
struct clk_bulk_data *clks)
{
--
2.39.5
next prev parent reply other threads:[~2025-08-13 14:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 14:33 [PATCH v2 00/13] commands: add bfetch/buds of command redirection Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 01/13] common: introduce structured I/O Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 02/13] ARM: cpuinfo: support structio output Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 03/13] commands: uptime: enable structured I/O Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 04/13] string: implement strv_length helper Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 05/13] ARM: psci: client: add PSCI version/method parameters Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 06/13] net: move netmask_to_prefix into header Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 07/13] optee: add revision info to tee devinfo output Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 08/13] tee: enable structured I/O in devinfo handler Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 09/13] security: blobgen: add easy way to check for existent providers Ahmad Fatoum
2025-08-13 14:33 ` Ahmad Fatoum [this message]
2025-08-13 14:33 ` [PATCH v2 11/13] commands: introduce bfetch command Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 12/13] configs: enable bfetch in some popular defconfigs Ahmad Fatoum
2025-08-13 14:33 ` [PATCH v2 13/13] hush: structio: silence missing command error message Ahmad Fatoum
2025-08-14 10:53 ` [PATCH v2 00/13] commands: add bfetch/buds of command redirection Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250813143345.3758653-11-a.fatoum@barebox.org \
--to=a.fatoum@barebox.org \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox