summaryrefslogtreecommitdiff
path: root/include/kendryte
diff options
context:
space:
mode:
authorSean Anderson <seanga2@gmail.com>2020-06-24 13:41:11 +0300
committerAndes <uboot@andestech.com>2020-07-01 10:01:21 +0300
commitf9c7d4f99f51ac9c1cf513111c21395f93d2dd53 (patch)
treeba01f5f1a843d36582654975fd4ad3413e4f6e40 /include/kendryte
parent1a198cf8862b0540894ba6569c55244b1bd3e824 (diff)
downloadu-boot-f9c7d4f99f51ac9c1cf513111c21395f93d2dd53.tar.xz
clk: Add K210 clock support
Due to the large number of clocks, I decided to use the CCF. The overall structure is modeled after the imx code. Clocks parameters are stored in several arrays, and are then instantiated at run-time. There are some translation macros (FOOIFY()) which allow for more dense packing. Signed-off-by: Sean Anderson <seanga2@gmail.com> CC: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'include/kendryte')
-rw-r--r--include/kendryte/clk.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/kendryte/clk.h b/include/kendryte/clk.h
new file mode 100644
index 0000000000..9c6245d468
--- /dev/null
+++ b/include/kendryte/clk.h
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (C) 2019-20 Sean Anderson <seanga2@gmail.com>
+ */
+
+#ifndef K210_CLK_H
+#define K210_CLK_H
+
+#define LOG_CATEGORY UCLASS_CLK
+#include <linux/types.h>
+#include <linux/clk-provider.h>
+
+static inline struct clk *k210_clk_gate(const char *name,
+ const char *parent_name,
+ void __iomem *reg, u8 bit_idx)
+{
+ return clk_register_gate(NULL, name, parent_name, 0, reg, bit_idx, 0,
+ NULL);
+}
+
+static inline struct clk *k210_clk_half(const char *name,
+ const char *parent_name)
+{
+ return clk_register_fixed_factor(NULL, name, parent_name, 0, 1, 2);
+}
+
+static inline struct clk *k210_clk_div(const char *name,
+ const char *parent_name,
+ void __iomem *reg, u8 shift, u8 width)
+{
+ return clk_register_divider(NULL, name, parent_name, 0, reg, shift,
+ width, 0);
+}
+
+#endif /* K210_CLK_H */