From: Beniamino Galvani <b.galvani@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 08/11] clk: add rockchip clock gate driver
Date: Sun, 27 Apr 2014 11:30:41 +0200 [thread overview]
Message-ID: <1398591044-3616-9-git-send-email-b.galvani@gmail.com> (raw)
In-Reply-To: <1398591044-3616-1-git-send-email-b.galvani@gmail.com>
Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
---
arch/arm/Kconfig | 3 ++
drivers/clk/Makefile | 1 +
drivers/clk/rockchip/Makefile | 1 +
drivers/clk/rockchip/clk-rockchip.c | 86 +++++++++++++++++++++++++++++++++++
4 files changed, 91 insertions(+)
create mode 100644 drivers/clk/rockchip/Makefile
create mode 100644 drivers/clk/rockchip/clk-rockchip.c
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index a7db86c..580faa0 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -129,6 +129,9 @@ config ARCH_ROCKCHIP
bool "Rockchip RX3xxx"
select CPU_V7
select ARM_SMP_TWD
+ select COMMON_CLK
+ select CLKDEV_LOOKUP
+ select COMMON_CLK_OF_PROVIDER
config ARCH_SOCFPGA
bool "Altera SOCFPGA cyclone5"
diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 0687b3c..fa707dd 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_CLKDEV_LOOKUP) += clkdev.o
obj-$(CONFIG_ARCH_MVEBU) += mvebu/
obj-$(CONFIG_ARCH_MXS) += mxs/
+obj-$(CONFIG_ARCH_ROCKCHIP) += rockchip/
obj-$(CONFIG_ARCH_TEGRA) += tegra/
obj-$(CONFIG_CLK_SOCFPGA) += socfpga.o
obj-$(CONFIG_MACH_MIPS_ATH79) += clk-ar933x.o
diff --git a/drivers/clk/rockchip/Makefile b/drivers/clk/rockchip/Makefile
new file mode 100644
index 0000000..1c5271f
--- /dev/null
+++ b/drivers/clk/rockchip/Makefile
@@ -0,0 +1 @@
+obj-y += clk-rockchip.o
\ No newline at end of file
diff --git a/drivers/clk/rockchip/clk-rockchip.c b/drivers/clk/rockchip/clk-rockchip.c
new file mode 100644
index 0000000..99f836c
--- /dev/null
+++ b/drivers/clk/rockchip/clk-rockchip.c
@@ -0,0 +1,86 @@
+/*
+ * Clock gate driver for Rockchip SoCs
+ *
+ * Based on Linux driver:
+ * Copyright (c) 2013 MundoReader S.L.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <driver.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <of_address.h>
+#include <malloc.h>
+
+static void __init rk2928_gate_clk_init(struct device_node *node)
+{
+ struct clk_onecell_data *clk_data;
+ const char *clk_parent;
+ const char *clk_name;
+ void __iomem *reg;
+ void __iomem *reg_idx;
+ int flags;
+ int qty;
+ int reg_bit;
+ int clkflags = CLK_SET_RATE_PARENT;
+ int i;
+
+ qty = of_property_count_strings(node, "clock-output-names");
+ if (qty < 0) {
+ pr_err("%s: error in clock-output-names %d\n", __func__, qty);
+ return;
+ }
+
+ if (qty == 0) {
+ pr_info("%s: nothing to do\n", __func__);
+ return;
+ }
+
+ reg = of_iomap(node, 0);
+
+ clk_data = kzalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
+ if (!clk_data)
+ return;
+
+ clk_data->clks = kzalloc(qty * sizeof(struct clk *), GFP_KERNEL);
+ if (!clk_data->clks) {
+ kfree(clk_data);
+ return;
+ }
+
+ flags = CLK_GATE_HIWORD_MASK | CLK_GATE_INVERTED;
+
+ for (i = 0; i < qty; i++) {
+ of_property_read_string_index(node, "clock-output-names",
+ i, &clk_name);
+
+ /* ignore empty slots */
+ if (!strcmp("reserved", clk_name))
+ continue;
+
+ clk_parent = of_clk_get_parent_name(node, i);
+
+ reg_idx = reg + 4 * (i / 16);
+ reg_bit = i % 16;
+
+ clk_data->clks[i] = clk_gate(clk_name, clk_parent, reg_idx,
+ reg_bit, clkflags, flags);
+ WARN_ON(IS_ERR(clk_data->clks[i]));
+ }
+
+ clk_data->clk_num = qty;
+
+ of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+}
+CLK_OF_DECLARE(rk2928_gate, "rockchip,rk2928-gate-clk", rk2928_gate_clk_init);
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-04-27 9:31 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-27 9:30 [PATCH 00/11] ARM: add initial support for Rockchip boards Beniamino Galvani
2014-04-27 9:30 ` [PATCH 01/11] net: add ARC EMAC driver Beniamino Galvani
2014-04-27 9:30 ` [PATCH 02/11] mfd: add act8846 driver Beniamino Galvani
2014-04-27 9:30 ` [PATCH 03/11] ARM: add basic support for Rockchip SoCs Beniamino Galvani
2014-04-27 9:30 ` [PATCH 04/11] ARM: rockchip: add PLL initialization function Beniamino Galvani
2014-04-27 9:30 ` [PATCH 05/11] clk: gate: add flags argument to clock gate constructor Beniamino Galvani
2014-04-27 9:30 ` [PATCH 06/11] clk: gate: unify enable and disable functions handling Beniamino Galvani
2014-04-27 9:30 ` [PATCH 07/11] clk: gate: add CLK_GATE_HIWORD_MASK flag Beniamino Galvani
2014-04-27 9:30 ` Beniamino Galvani [this message]
2014-04-27 9:30 ` [PATCH 09/11] pinctrl: add rockchip pinctrl and gpio drivers Beniamino Galvani
2014-04-27 9:30 ` [PATCH 10/11] ARM: dts: add Rockchip devicetree files Beniamino Galvani
2014-04-27 9:30 ` [PATCH 11/11] ARM: rockchip: add radxa-rock board Beniamino Galvani
2014-04-28 7:26 ` [PATCH 00/11] ARM: add initial support for Rockchip boards Sascha Hauer
2014-04-28 20:54 ` Beniamino Galvani
2014-04-29 7:05 ` Sascha Hauer
2014-04-29 21:13 ` Beniamino Galvani
2014-04-29 21:59 ` Heiko Stübner
2014-05-01 7:48 ` Beniamino Galvani
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=1398591044-3616-9-git-send-email-b.galvani@gmail.com \
--to=b.galvani@gmail.com \
--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