* [PATCH v3 0/5] ARM: sun9i: Add Allwinner A80 PRCM clock/reset support
@ 2015-11-24 9:32 Chen-Yu Tsai
2015-11-24 9:32 ` [PATCH v3 1/5] clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver Chen-Yu Tsai
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Chen-Yu Tsai @ 2015-11-24 9:32 UTC (permalink / raw)
To: linux-arm-kernel
Hi everyone,
This is v3 of the Allwinner A80 PRCM support series. v3 moves away
from the mfd approach, and just lists the various controls directly
under the "clocks" and "soc" nodes.
Changes since v2:
- Move away from mfd approach and directly list the clock and
reset controls as first class devices.
- Use the new clk-simple-gates driver for the apbs clock gates.
- Update clk code to use struct clk_request.
- Add 1wire clk node.
- Use GENMASK and always use shifted bitmasks in cpus clk driver.
Changes since v1:
- Added missing clock gates based on updated documents
- Added new cpus clock driver based on updated documents
- Added pll3 clock placeholder
- Added comments about 24M & 32k oscillators
The series adds support for the Power Reset and Clock Management
module on Allwinner's A80 SoC. The PRCM manages clocks and resets
for the "special" block of peripherals, or the R/RTC block in
earlier SoCs, as well as power domain and resets for various parts
of the SoC, such as the 2 processor clusters, the GPU and others.
The special peripherals include a standby processor core, a timer
block, a watchdog, pin controller, 1 wire interface, PS/2 interface,
a UART, the RSB controller, a DMA controller, a consumer IR receiver
block, 2 I2C controllers, and 2 I2S controllers. We do not have
documents for all the peripherals. Support will be added where
possible.
Patch 1 adds CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver.
This driver was used with the mfd approach for the A23/A33 PRCM. As
such it is a platform device driver.
Patch 2 adds a new compatible string for the apbs gates to the
clk-simple-gates driver.
Patch 3 adds a new driver for the cpus clock.
Patch 4 adds the various supported clock and reset control device nodes
to the A80 dtsi.
Patch 5 adds some TODO comments regarding the 2 system oscillators.
Regards
ChenYu
Chen-Yu Tsai (5):
clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver
clk: sunxi: Add sun9i A80 apbs gates support
clk: sunxi: Add sun9i A80 cpus (cpu special) clock support
ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes
ARM: dts: sun9i: Add TODO comments for the main and low power clocks
Documentation/devicetree/bindings/clock/sunxi.txt | 2 +
arch/arm/boot/dts/sun9i-a80.dtsi | 97 ++++++++-
drivers/clk/sunxi/Makefile | 5 +-
drivers/clk/sunxi/clk-simple-gates.c | 2 +
drivers/clk/sunxi/clk-sun8i-apb0.c | 43 ++++
drivers/clk/sunxi/clk-sun9i-cpus.c | 240 ++++++++++++++++++++++
6 files changed, 386 insertions(+), 3 deletions(-)
create mode 100644 drivers/clk/sunxi/clk-sun9i-cpus.c
--
2.6.2
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 1/5] clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver
2015-11-24 9:32 [PATCH v3 0/5] ARM: sun9i: Add Allwinner A80 PRCM clock/reset support Chen-Yu Tsai
@ 2015-11-24 9:32 ` Chen-Yu Tsai
2015-11-25 14:18 ` Maxime Ripard
2015-11-24 9:32 ` [PATCH v3 2/5] clk: sunxi: Add sun9i A80 apbs gates support Chen-Yu Tsai
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Chen-Yu Tsai @ 2015-11-24 9:32 UTC (permalink / raw)
To: linux-arm-kernel
The APBS clock on sun9i is the same as the APB0 clock on sun8i. With
sun9i we are supporting the PRCM clocks by using CLK_OF_DECLARE,
instead of through a PRCM mfd device and subdevices for each clock
and reset control. As such we need a CLK_OF_DECLARE version of
the sun8i-a23-apb0-clk driver.
Also, build it for all Allwinner/sunxi platforms, and not just for
configurations with MFD_SUN6I_PRCM enabled.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
drivers/clk/sunxi/Makefile | 4 ++--
drivers/clk/sunxi/clk-sun8i-apb0.c | 43 ++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index cb4c299214ce..121333ce34ea 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -10,11 +10,11 @@ obj-y += clk-a10-pll2.o
obj-y += clk-a20-gmac.o
obj-y += clk-mod0.o
obj-y += clk-simple-gates.o
+obj-y += clk-sun8i-apb0.o
obj-y += clk-sun8i-mbus.o
obj-y += clk-sun9i-core.o
obj-y += clk-sun9i-mmc.o
obj-y += clk-usb.o
obj-$(CONFIG_MFD_SUN6I_PRCM) += \
- clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o \
- clk-sun8i-apb0.o
+ clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o
diff --git a/drivers/clk/sunxi/clk-sun8i-apb0.c b/drivers/clk/sunxi/clk-sun8i-apb0.c
index 7ae5d2c2cde1..11b2f2fde245 100644
--- a/drivers/clk/sunxi/clk-sun8i-apb0.c
+++ b/drivers/clk/sunxi/clk-sun8i-apb0.c
@@ -17,8 +17,51 @@
#include <linux/clk-provider.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/platform_device.h>
+static void sun8i_a23_apb0_setup(struct device_node *node)
+{
+ const char *clk_name = node->name;
+ const char *clk_parent;
+ void __iomem *reg;
+ struct resource res;
+ struct clk *clk;
+ int ret;
+
+ reg = of_io_request_and_map(node, 0, of_node_full_name(node));
+ if (IS_ERR(reg))
+ return;
+
+ clk_parent = of_clk_get_parent_name(node, 0);
+ if (!clk_parent)
+ goto err_unmap;
+
+ of_property_read_string(node, "clock-output-names", &clk_name);
+
+ /* The A23 APB0 clock is a standard 2 bit wide divider clock */
+ clk = clk_register_divider(NULL, clk_name, clk_parent, 0, reg,
+ 0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
+ if (IS_ERR(clk))
+ goto err_unmap;
+
+ ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
+ if (ret)
+ goto err_unregister;
+
+ return;
+
+err_unregister:
+ clk_unregister_divider(clk);
+
+err_unmap:
+ iounmap(reg);
+ of_address_to_resource(node, 0, &res);
+ release_mem_region(res.start, resource_size(&res));
+}
+CLK_OF_DECLARE(sun8i_a23_apb0, "allwinner,sun8i-a23-apb0-clk",
+ sun8i_a23_apb0_setup);
+
static int sun8i_a23_apb0_clk_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
--
2.6.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 2/5] clk: sunxi: Add sun9i A80 apbs gates support
2015-11-24 9:32 [PATCH v3 0/5] ARM: sun9i: Add Allwinner A80 PRCM clock/reset support Chen-Yu Tsai
2015-11-24 9:32 ` [PATCH v3 1/5] clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver Chen-Yu Tsai
@ 2015-11-24 9:32 ` Chen-Yu Tsai
2015-11-24 9:32 ` [PATCH v3 3/5] clk: sunxi: Add sun9i A80 cpus (cpu special) clock support Chen-Yu Tsai
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Chen-Yu Tsai @ 2015-11-24 9:32 UTC (permalink / raw)
To: linux-arm-kernel
This patch adds support for the PRCM apbs clock gates found on the
Allwinner A80 SoC.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
drivers/clk/sunxi/clk-simple-gates.c | 2 ++
2 files changed, 3 insertions(+)
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index a94bb56a0e9e..b6859ed6913f 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -55,6 +55,7 @@ Required properties:
"allwinner,sun9i-a80-apb1-gates-clk" - for the APB1 gates on A80
"allwinner,sun6i-a31-apb2-gates-clk" - for the APB2 gates on A31
"allwinner,sun8i-a23-apb2-gates-clk" - for the APB2 gates on A23
+ "allwinner,sun9i-a80-apbs-gates-clk" - for the APBS gates on A80
"allwinner,sun5i-a13-mbus-clk" - for the MBUS clock on A13
"allwinner,sun4i-a10-mmc-clk" - for the MMC clock
"allwinner,sun9i-a80-mmc-clk" - for mmc module clocks on A80
diff --git a/drivers/clk/sunxi/clk-simple-gates.c b/drivers/clk/sunxi/clk-simple-gates.c
index 0214c6548afd..c8acc0612c15 100644
--- a/drivers/clk/sunxi/clk-simple-gates.c
+++ b/drivers/clk/sunxi/clk-simple-gates.c
@@ -140,6 +140,8 @@ CLK_OF_DECLARE(sun9i_a80_apb0, "allwinner,sun9i-a80-apb0-gates-clk",
sunxi_simple_gates_init);
CLK_OF_DECLARE(sun9i_a80_apb1, "allwinner,sun9i-a80-apb1-gates-clk",
sunxi_simple_gates_init);
+CLK_OF_DECLARE(sun9i_a80_apbs, "allwinner,sun9i-a80-apbs-gates-clk",
+ sunxi_simple_gates_init);
static const int sun4i_a10_ahb_critical_clocks[] __initconst = {
14, /* ahb_sdram */
--
2.6.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 3/5] clk: sunxi: Add sun9i A80 cpus (cpu special) clock support
2015-11-24 9:32 [PATCH v3 0/5] ARM: sun9i: Add Allwinner A80 PRCM clock/reset support Chen-Yu Tsai
2015-11-24 9:32 ` [PATCH v3 1/5] clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver Chen-Yu Tsai
2015-11-24 9:32 ` [PATCH v3 2/5] clk: sunxi: Add sun9i A80 apbs gates support Chen-Yu Tsai
@ 2015-11-24 9:32 ` Chen-Yu Tsai
2015-11-25 17:32 ` Maxime Ripard
2015-11-24 9:32 ` [PATCH v3 4/5] ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes Chen-Yu Tsai
2015-11-24 9:32 ` [PATCH v3 5/5] ARM: dts: sun9i: Add TODO comments for the main and low power clocks Chen-Yu Tsai
4 siblings, 1 reply; 12+ messages in thread
From: Chen-Yu Tsai @ 2015-11-24 9:32 UTC (permalink / raw)
To: linux-arm-kernel
The "cpus" clock is the clock for the embedded processor in the A80.
It is also part of the PRCM clock tree. This clock includes a pre-
divider on one of its inputs. For now we are using a custom clock
driver for it. In the future we may want to develop a generalized
driver for these types of clocks, which also includes the AHB clock
driver on sun[5678]i.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
Hi Maxime,
I'll do the factors clock refactoring mentioned during the discussion
around v2 later on.
---
Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
drivers/clk/sunxi/Makefile | 1 +
drivers/clk/sunxi/clk-sun9i-cpus.c | 240 ++++++++++++++++++++++
3 files changed, 242 insertions(+)
create mode 100644 drivers/clk/sunxi/clk-sun9i-cpus.c
diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
index b6859ed6913f..153ac72869e8 100644
--- a/Documentation/devicetree/bindings/clock/sunxi.txt
+++ b/Documentation/devicetree/bindings/clock/sunxi.txt
@@ -27,6 +27,7 @@ Required properties:
"allwinner,sun5i-a10s-ahb-gates-clk" - for the AHB gates on A10s
"allwinner,sun7i-a20-ahb-gates-clk" - for the AHB gates on A20
"allwinner,sun6i-a31-ar100-clk" - for the AR100 on A31
+ "allwinner,sun9i-a80-cpus-clk" - for the CPUS on A80
"allwinner,sun6i-a31-ahb1-clk" - for the AHB1 clock on A31
"allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31
"allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
index 121333ce34ea..07d914c3f6d1 100644
--- a/drivers/clk/sunxi/Makefile
+++ b/drivers/clk/sunxi/Makefile
@@ -13,6 +13,7 @@ obj-y += clk-simple-gates.o
obj-y += clk-sun8i-apb0.o
obj-y += clk-sun8i-mbus.o
obj-y += clk-sun9i-core.o
+obj-y += clk-sun9i-cpus.o
obj-y += clk-sun9i-mmc.o
obj-y += clk-usb.o
diff --git a/drivers/clk/sunxi/clk-sun9i-cpus.c b/drivers/clk/sunxi/clk-sun9i-cpus.c
new file mode 100644
index 000000000000..7626d2194b96
--- /dev/null
+++ b/drivers/clk/sunxi/clk-sun9i-cpus.c
@@ -0,0 +1,240 @@
+/*
+ * Copyright (C) 2015 Chen-Yu Tsai
+ *
+ * Chen-Yu Tsai <wens@csie.org>
+ *
+ * Allwinner A80 CPUS clock driver
+ *
+ */
+
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+
+static DEFINE_SPINLOCK(sun9i_a80_cpus_lock);
+
+/**
+ * sun9i_a80_cpus_clk_setup() - Setup function for a80 cpus composite clk
+ */
+
+#define SUN9I_CPUS_MAX_PARENTS 4
+#define SUN9I_CPUS_MUX_PARENT_PLL4 3
+#define SUN9I_CPUS_MUX_SHIFT 16
+#define SUN9I_CPUS_MUX_MASK GENMASK(17, 16)
+#define SUN9I_CPUS_MUX_GET_PARENT(reg) ((reg & SUN9I_CPUS_MUX_MASK) >> \
+ SUN9I_CPUS_MUX_SHIFT)
+
+#define SUN9I_CPUS_DIV_SHIFT 4
+#define SUN9I_CPUS_DIV_MASK GENMASK(5, 4)
+#define SUN9I_CPUS_DIV_GET(reg) ((reg & SUN9I_CPUS_DIV_MASK) >> \
+ SUN9I_CPUS_DIV_SHIFT)
+#define SUN9I_CPUS_DIV_SET(reg, div) ((reg & ~SUN9I_CPUS_DIV_MASK) | \
+ (div << SUN9I_CPUS_DIV_SHIFT))
+#define SUN9I_CPUS_PLL4_DIV_SHIFT 8
+#define SUN9I_CPUS_PLL4_DIV_MASK GENMASK(12, 8)
+#define SUN9I_CPUS_PLL4_DIV_GET(reg) ((reg & SUN9I_CPUS_PLL4_DIV_MASK) >> \
+ SUN9I_CPUS_PLL4_DIV_SHIFT)
+#define SUN9I_CPUS_PLL4_DIV_SET(reg, div) ((reg & ~SUN9I_CPUS_PLL4_DIV_MASK) | \
+ (div << SUN9I_CPUS_PLL4_DIV_SHIFT))
+
+struct sun9i_a80_cpus_clk {
+ struct clk_hw hw;
+ void __iomem *reg;
+};
+
+#define to_sun9i_a80_cpus_clk(_hw) container_of(_hw, struct sun9i_a80_cpus_clk, hw)
+
+static unsigned long sun9i_a80_cpus_clk_recalc_rate(struct clk_hw *hw,
+ unsigned long parent_rate)
+{
+ struct sun9i_a80_cpus_clk *cpus = to_sun9i_a80_cpus_clk(hw);
+ unsigned long rate;
+ u32 reg;
+
+ /* Fetch the register value */
+ reg = readl(cpus->reg);
+
+ /* apply pre-divider first if parent is pll4 */
+ if (SUN9I_CPUS_MUX_GET_PARENT(reg) == SUN9I_CPUS_MUX_PARENT_PLL4)
+ parent_rate /= SUN9I_CPUS_PLL4_DIV_GET(reg) + 1;
+
+ /* clk divider */
+ rate = parent_rate / (SUN9I_CPUS_DIV_GET(reg) + 1);
+
+ return rate;
+}
+
+static long sun9i_a80_cpus_clk_round(unsigned long rate, u8 *divp, u8 *pre_divp,
+ u8 parent, unsigned long parent_rate)
+{
+ u8 div, pre_div = 1;
+
+ /*
+ * clock can only divide, so we will never be able to achieve
+ * frequencies higher than the parent frequency
+ */
+ if (parent_rate && rate > parent_rate)
+ rate = parent_rate;
+
+ div = DIV_ROUND_UP(parent_rate, rate);
+
+ /* calculate pre-divider if parent is pll4 */
+ if (parent == SUN9I_CPUS_MUX_PARENT_PLL4 && div > 4) {
+ /* pre-divider is 1 ~ 32 */
+ if (div < 32) {
+ pre_div = div;
+ div = 1;
+ } else if (div < 64) {
+ pre_div = DIV_ROUND_UP(div, 2);
+ div = 2;
+ } else if (div < 96) {
+ pre_div = DIV_ROUND_UP(div, 3);
+ div = 3;
+ } else {
+ pre_div = DIV_ROUND_UP(div, 4);
+ div = 4;
+ }
+ }
+
+ /* we were asked to pass back divider values */
+ if (divp) {
+ *divp = div - 1;
+ *pre_divp = pre_div - 1;
+ }
+
+ return parent_rate / pre_div / div;
+}
+
+static int sun9i_a80_cpus_clk_determine_rate(struct clk_hw *clk,
+ struct clk_rate_request *req)
+{
+ struct clk_hw *parent, *best_parent = NULL;
+ int i, num_parents;
+ unsigned long parent_rate, best = 0, child_rate, best_child_rate = 0;
+ unsigned long rate = req->rate;
+
+ /* find the parent that can help provide the fastest rate <= rate */
+ num_parents = clk_hw_get_num_parents(clk);
+ for (i = 0; i < num_parents; i++) {
+ parent = clk_hw_get_parent_by_index(clk, i);
+ if (!parent)
+ continue;
+ if (clk_hw_get_flags(clk) & CLK_SET_RATE_PARENT)
+ parent_rate = clk_hw_round_rate(parent, rate);
+ else
+ parent_rate = clk_hw_get_rate(parent);
+
+ child_rate = sun9i_a80_cpus_clk_round(rate, NULL, NULL, i,
+ parent_rate);
+
+ if (child_rate <= rate && child_rate > best_child_rate) {
+ best_parent = parent;
+ best = parent_rate;
+ best_child_rate = child_rate;
+ }
+ }
+
+ if (!best_parent)
+ return -EINVAL;
+
+ req->best_parent_hw = best_parent;
+ req->best_parent_rate = best;
+ req->rate = best_child_rate;
+
+ return 0;
+}
+
+static int sun9i_a80_cpus_clk_set_rate(struct clk_hw *hw, unsigned long rate,
+ unsigned long parent_rate)
+{
+ struct sun9i_a80_cpus_clk *cpus = to_sun9i_a80_cpus_clk(hw);
+ unsigned long flags;
+ u8 div, pre_div, parent;
+ u32 reg;
+
+ spin_lock_irqsave(&sun9i_a80_cpus_lock, flags);
+
+ reg = readl(cpus->reg);
+
+ /* need to know which parent is used to apply pre-divider */
+ parent = SUN9I_CPUS_MUX_GET_PARENT(reg);
+ sun9i_a80_cpus_clk_round(rate, &div, &pre_div, parent, parent_rate);
+
+ reg = SUN9I_CPUS_DIV_SET(reg, div);
+ reg = SUN9I_CPUS_PLL4_DIV_SET(reg, pre_div);
+ writel(reg, cpus->reg);
+
+ spin_unlock_irqrestore(&sun9i_a80_cpus_lock, flags);
+
+ return 0;
+}
+
+static const struct clk_ops sun9i_a80_cpus_clk_ops = {
+ .determine_rate = sun9i_a80_cpus_clk_determine_rate,
+ .recalc_rate = sun9i_a80_cpus_clk_recalc_rate,
+ .set_rate = sun9i_a80_cpus_clk_set_rate,
+};
+
+static void sun9i_a80_cpus_setup(struct device_node *node)
+{
+ const char *clk_name = node->name;
+ const char *parents[SUN9I_CPUS_MAX_PARENTS];
+ struct resource res;
+ struct sun9i_a80_cpus_clk *cpus;
+ struct clk_mux *mux;
+ struct clk *clk;
+ int ret;
+
+ cpus = kzalloc(sizeof(*cpus), GFP_KERNEL);
+ if (!cpus)
+ return;
+
+ cpus->reg = of_io_request_and_map(node, 0, of_node_full_name(node));
+ if (IS_ERR(cpus->reg))
+ goto err_free_cpus;
+
+ of_property_read_string(node, "clock-output-names", &clk_name);
+
+ /* we have a mux, we will have >1 parents */
+ ret = of_clk_parent_fill(node, parents, SUN9I_CPUS_MAX_PARENTS);
+
+ mux = kzalloc(sizeof(*mux), GFP_KERNEL);
+ if (!mux)
+ goto err_unmap;
+
+ /* set up clock properties */
+ mux->reg = cpus->reg;
+ mux->shift = SUN9I_CPUS_MUX_SHIFT;
+ /* un-shifted mask is what mux_clk expects */
+ mux->mask = SUN9I_CPUS_MUX_MASK >> SUN9I_CPUS_MUX_SHIFT;
+ mux->lock = &sun9i_a80_cpus_lock;
+
+ clk = clk_register_composite(NULL, clk_name, parents, ret,
+ &mux->hw, &clk_mux_ops,
+ &cpus->hw, &sun9i_a80_cpus_clk_ops,
+ NULL, NULL, 0);
+ if (IS_ERR(clk))
+ goto err_free_mux;
+
+ ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
+ if (ret)
+ goto err_unregister;
+
+ return;
+
+err_unregister:
+ clk_unregister(clk);
+err_free_mux:
+ kfree(mux);
+err_unmap:
+ iounmap(cpus->reg);
+ of_address_to_resource(node, 0, &res);
+ release_mem_region(res.start, resource_size(&res));
+err_free_cpus:
+ kfree(cpus);
+}
+CLK_OF_DECLARE(sun9i_a80_cpus, "allwinner,sun9i-a80-cpus-clk",
+ sun9i_a80_cpus_setup);
--
2.6.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 4/5] ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes
2015-11-24 9:32 [PATCH v3 0/5] ARM: sun9i: Add Allwinner A80 PRCM clock/reset support Chen-Yu Tsai
` (2 preceding siblings ...)
2015-11-24 9:32 ` [PATCH v3 3/5] clk: sunxi: Add sun9i A80 cpus (cpu special) clock support Chen-Yu Tsai
@ 2015-11-24 9:32 ` Chen-Yu Tsai
2015-11-24 10:27 ` Jisheng Zhang
2015-11-24 9:32 ` [PATCH v3 5/5] ARM: dts: sun9i: Add TODO comments for the main and low power clocks Chen-Yu Tsai
4 siblings, 1 reply; 12+ messages in thread
From: Chen-Yu Tsai @ 2015-11-24 9:32 UTC (permalink / raw)
To: linux-arm-kernel
This adds the supported PRCM clocks and reset controls to the A80 dtsi.
The DAUDIO module clocks are not supported yet.
Also update clock and reset phandles for r_uart.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
arch/arm/boot/dts/sun9i-a80.dtsi | 79 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 78 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index 1118bf5cc4fb..a4ce348c0831 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -164,6 +164,14 @@
"usb_phy2", "usb_hsic_12M";
};
+ pll3: clk at 06000008 {
+ /* placeholder until implemented */
+ #clock-cells = <0>;
+ compatible = "fixed-clock";
+ clock-rate = <0>;
+ clock-output-names = "pll3";
+ };
+
pll4: clk at 0600000c {
#clock-cells = <0>;
compatible = "allwinner,sun9i-a80-pll4-clk";
@@ -350,6 +358,68 @@
"apb1_uart2", "apb1_uart3",
"apb1_uart4", "apb1_uart5";
};
+
+ cpus_clk: clk at 08001410 {
+ compatible = "allwinner,sun9i-a80-cpus-clk";
+ reg = <0x08001410 0x4>;
+ #clock-cells = <0>;
+ clocks = <&osc32k>, <&osc24M>, <&pll4>, <&pll3>;
+ clock-output-names = "cpus";
+ };
+
+ ahbs: ahbs_clk {
+ compatible = "fixed-factor-clock";
+ #clock-cells = <0>;
+ clock-div = <1>;
+ clock-mult = <1>;
+ clocks = <&cpus_clk>;
+ clock-output-names = "ahbs";
+ };
+
+ apbs: clk at 0800141c {
+ compatible = "allwinner,sun8i-a23-apb0-clk";
+ reg = <0x0800141c 0x4>;
+ #clock-cells = <0>;
+ clocks = <&ahbs>;
+ clock-output-names = "apbs";
+ };
+
+ apbs_gates: clk at 08001428 {
+ compatible = "allwinner,sun9i-a80-apbs-gates-clk";
+ reg = <0x08001428 0x4>;
+ #clock-cells = <1>;
+ clocks = <&apbs>;
+ clock-indices = <0>, <1>,
+ <2>, <3>,
+ <4>, <5>,
+ <6>, <7>,
+ <12>, <13>,
+ <16>, <17>,
+ <18>, <20>;
+ clock-output-names = "apbs_pio", "apbs_ir",
+ "apbs_timer", "apbs_rsb",
+ "apbs_uart", "apbs_1wire",
+ "apbs_i2c0", "apbs_i2c1",
+ "apbs_ps2_0", "apbs_ps2_1",
+ "apbs_dma", "apbs_i2s0",
+ "apbs_i2s1", "apbs_twd";
+ };
+
+ r_1wire_clk: clk at 08001450 {
+ reg = <0x08001450 0x4>;
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-a10-mod0-clk";
+ clocks = <&osc32k>, <&osc24M>;
+ clock-output-names = "r_1wire";
+ };
+
+ r_ir_clk: clk at 08001454 {
+ reg = <0x08001454 0x4>;
+ #clock-cells = <0>;
+ compatible = "allwinner,sun4i-a10-mod0-clk";
+ clocks = <&osc32k>, <&osc24M>;
+ clock-output-names = "r_ir";
+ };
};
soc {
@@ -764,13 +834,20 @@
interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
};
+ apbs_rst: reset at 080014b0 {
+ reg = <0x080014b0 0x4>;
+ compatible = "allwinner,sun6i-a31-clock-reset";
+ #reset-cells = <1>;
+ };
+
r_uart: serial at 08002800 {
compatible = "snps,dw-apb-uart";
reg = <0x08002800 0x400>;
interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
reg-shift = <2>;
reg-io-width = <4>;
- clocks = <&osc24M>;
+ clocks = <&apbs_gates 4>;
+ resets = <&apbs_rst 4>;
status = "disabled";
};
};
--
2.6.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 5/5] ARM: dts: sun9i: Add TODO comments for the main and low power clocks
2015-11-24 9:32 [PATCH v3 0/5] ARM: sun9i: Add Allwinner A80 PRCM clock/reset support Chen-Yu Tsai
` (3 preceding siblings ...)
2015-11-24 9:32 ` [PATCH v3 4/5] ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes Chen-Yu Tsai
@ 2015-11-24 9:32 ` Chen-Yu Tsai
4 siblings, 0 replies; 12+ messages in thread
From: Chen-Yu Tsai @ 2015-11-24 9:32 UTC (permalink / raw)
To: linux-arm-kernel
The main (24MHz) clock on the A80 is configurable via the PRCM address
space. The low power/speed (32kHz) clock is from an external chip, the
AC100.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
arch/arm/boot/dts/sun9i-a80.dtsi | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
index a4ce348c0831..eb69a62f6bc4 100644
--- a/arch/arm/boot/dts/sun9i-a80.dtsi
+++ b/arch/arm/boot/dts/sun9i-a80.dtsi
@@ -128,6 +128,17 @@
*/
ranges = <0 0 0 0x20000000>;
+ /*
+ * This clock is actually configurable from the PRCM address
+ * space. The external 24M oscillator can be turned off, and
+ * the clock switched to an internal 16M RC oscillator. Under
+ * normal operation there's no reason to do this, and the
+ * default is to use the external good one, so just model this
+ * as a fixed clock. Also it is not entirely clear if the
+ * osc24M mux in the PRCM affects the entire clock tree, which
+ * would also throw all the PLL clock rates off, or just the
+ * downstream clocks in the PRCM.
+ */
osc24M: osc24M_clk {
#clock-cells = <0>;
compatible = "fixed-clock";
@@ -135,6 +146,13 @@
clock-output-names = "osc24M";
};
+ /*
+ * The 32k clock is from an external source, normally the
+ * AC100 codec/RTC chip. This clock is by default enabled
+ * and clocked at 32768 Hz, from the oscillator connected
+ * to the AC100. It is configurable, but no such driver or
+ * bindings exist yet.
+ */
osc32k: osc32k_clk {
#clock-cells = <0>;
compatible = "fixed-clock";
--
2.6.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v3 4/5] ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes
2015-11-24 9:32 ` [PATCH v3 4/5] ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes Chen-Yu Tsai
@ 2015-11-24 10:27 ` Jisheng Zhang
2015-11-26 20:09 ` Maxime Ripard
0 siblings, 1 reply; 12+ messages in thread
From: Jisheng Zhang @ 2015-11-24 10:27 UTC (permalink / raw)
To: linux-arm-kernel
+ Sebastian
On Tue, 24 Nov 2015 17:32:15 +0800
Chen-Yu Tsai wrote:
> This adds the supported PRCM clocks and reset controls to the A80 dtsi.
> The DAUDIO module clocks are not supported yet.
>
> Also update clock and reset phandles for r_uart.
>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
> arch/arm/boot/dts/sun9i-a80.dtsi | 79 +++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 78 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
> index 1118bf5cc4fb..a4ce348c0831 100644
> --- a/arch/arm/boot/dts/sun9i-a80.dtsi
> +++ b/arch/arm/boot/dts/sun9i-a80.dtsi
> @@ -164,6 +164,14 @@
> "usb_phy2", "usb_hsic_12M";
> };
>
> + pll3: clk at 06000008 {
> + /* placeholder until implemented */
> + #clock-cells = <0>;
> + compatible = "fixed-clock";
> + clock-rate = <0>;
> + clock-output-names = "pll3";
> + };
> +
> pll4: clk at 0600000c {
> #clock-cells = <0>;
> compatible = "allwinner,sun9i-a80-pll4-clk";
> @@ -350,6 +358,68 @@
> "apb1_uart2", "apb1_uart3",
> "apb1_uart4", "apb1_uart5";
> };
> +
> + cpus_clk: clk at 08001410 {
> + compatible = "allwinner,sun9i-a80-cpus-clk";
> + reg = <0x08001410 0x4>;
> + #clock-cells = <0>;
> + clocks = <&osc32k>, <&osc24M>, <&pll4>, <&pll3>;
> + clock-output-names = "cpus";
> + };
> +
> + ahbs: ahbs_clk {
> + compatible = "fixed-factor-clock";
> + #clock-cells = <0>;
> + clock-div = <1>;
> + clock-mult = <1>;
> + clocks = <&cpus_clk>;
> + clock-output-names = "ahbs";
> + };
Dear Sebastian and all,
I just want to take the sunxi clk support in mainline for example.
I'm not sure I understand correctly, it seems to me that some maintainers draw a
line: "having a node for every clock" is a no, no[1]. But here we saw one node for
cpus_clk and apbs below. And <0x08001410 0x4>; <0x0800141c 0x4>; shows they
are close each other, so should we merge them into a single clock complex node
then use mfd, regmap in clk driver?
But IMHO, sunxi dts nodes really represent real HW, so I still can't understand
why we could not have each node for cpus_clk and apbs. Can you please kindly
teach me?
Another question: is "Not having a node for every clock" a rule, Would you
please confirm? if yes, I'll strictly follow this rule.
[1]http://lists.infradead.org/pipermail/linux-arm-kernel/2015-November/387335.html
Thank you very much,
Jisheng
> +
> + apbs: clk at 0800141c {
> + compatible = "allwinner,sun8i-a23-apb0-clk";
> + reg = <0x0800141c 0x4>;
> + #clock-cells = <0>;
> + clocks = <&ahbs>;
> + clock-output-names = "apbs";
> + };
> +
> + apbs_gates: clk at 08001428 {
> + compatible = "allwinner,sun9i-a80-apbs-gates-clk";
> + reg = <0x08001428 0x4>;
> + #clock-cells = <1>;
> + clocks = <&apbs>;
> + clock-indices = <0>, <1>,
> + <2>, <3>,
> + <4>, <5>,
> + <6>, <7>,
> + <12>, <13>,
> + <16>, <17>,
> + <18>, <20>;
> + clock-output-names = "apbs_pio", "apbs_ir",
> + "apbs_timer", "apbs_rsb",
> + "apbs_uart", "apbs_1wire",
> + "apbs_i2c0", "apbs_i2c1",
> + "apbs_ps2_0", "apbs_ps2_1",
> + "apbs_dma", "apbs_i2s0",
> + "apbs_i2s1", "apbs_twd";
> + };
This is for gate clocks, so we have a node for gateclks. gateclks are merged
into one node.
> +
> + r_1wire_clk: clk at 08001450 {
> + reg = <0x08001450 0x4>;
> + #clock-cells = <0>;
> + compatible = "allwinner,sun4i-a10-mod0-clk";
> + clocks = <&osc32k>, <&osc24M>;
> + clock-output-names = "r_1wire";
> + };
> +
> + r_ir_clk: clk at 08001454 {
> + reg = <0x08001454 0x4>;
> + #clock-cells = <0>;
> + compatible = "allwinner,sun4i-a10-mod0-clk";
> + clocks = <&osc32k>, <&osc24M>;
> + clock-output-names = "r_ir";
> + };
> };
>
> soc {
> @@ -764,13 +834,20 @@
> interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
> };
>
> + apbs_rst: reset at 080014b0 {
> + reg = <0x080014b0 0x4>;
> + compatible = "allwinner,sun6i-a31-clock-reset";
> + #reset-cells = <1>;
> + };
> +
> r_uart: serial at 08002800 {
> compatible = "snps,dw-apb-uart";
> reg = <0x08002800 0x400>;
> interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
> reg-shift = <2>;
> reg-io-width = <4>;
> - clocks = <&osc24M>;
> + clocks = <&apbs_gates 4>;
> + resets = <&apbs_rst 4>;
> status = "disabled";
> };
> };
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 1/5] clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver
2015-11-24 9:32 ` [PATCH v3 1/5] clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver Chen-Yu Tsai
@ 2015-11-25 14:18 ` Maxime Ripard
0 siblings, 0 replies; 12+ messages in thread
From: Maxime Ripard @ 2015-11-25 14:18 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Nov 24, 2015 at 05:32:12PM +0800, Chen-Yu Tsai wrote:
> The APBS clock on sun9i is the same as the APB0 clock on sun8i. With
> sun9i we are supporting the PRCM clocks by using CLK_OF_DECLARE,
> instead of through a PRCM mfd device and subdevices for each clock
> and reset control. As such we need a CLK_OF_DECLARE version of
> the sun8i-a23-apb0-clk driver.
>
> Also, build it for all Allwinner/sunxi platforms, and not just for
> configurations with MFD_SUN6I_PRCM enabled.
>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
> drivers/clk/sunxi/Makefile | 4 ++--
> drivers/clk/sunxi/clk-sun8i-apb0.c | 43 ++++++++++++++++++++++++++++++++++++++
> 2 files changed, 45 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
> index cb4c299214ce..121333ce34ea 100644
> --- a/drivers/clk/sunxi/Makefile
> +++ b/drivers/clk/sunxi/Makefile
> @@ -10,11 +10,11 @@ obj-y += clk-a10-pll2.o
> obj-y += clk-a20-gmac.o
> obj-y += clk-mod0.o
> obj-y += clk-simple-gates.o
> +obj-y += clk-sun8i-apb0.o
> obj-y += clk-sun8i-mbus.o
> obj-y += clk-sun9i-core.o
> obj-y += clk-sun9i-mmc.o
> obj-y += clk-usb.o
>
> obj-$(CONFIG_MFD_SUN6I_PRCM) += \
> - clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o \
> - clk-sun8i-apb0.o
> + clk-sun6i-ar100.o clk-sun6i-apb0.o clk-sun6i-apb0-gates.o
I'd really prefer not to build a driver that is used only on a few
SoCs if the support for these SoCs are not even enabled.
> diff --git a/drivers/clk/sunxi/clk-sun8i-apb0.c b/drivers/clk/sunxi/clk-sun8i-apb0.c
> index 7ae5d2c2cde1..11b2f2fde245 100644
> --- a/drivers/clk/sunxi/clk-sun8i-apb0.c
> +++ b/drivers/clk/sunxi/clk-sun8i-apb0.c
> @@ -17,8 +17,51 @@
> #include <linux/clk-provider.h>
> #include <linux/module.h>
> #include <linux/of.h>
> +#include <linux/of_address.h>
> #include <linux/platform_device.h>
>
> +static void sun8i_a23_apb0_setup(struct device_node *node)
> +{
> + const char *clk_name = node->name;
> + const char *clk_parent;
> + void __iomem *reg;
> + struct resource res;
> + struct clk *clk;
> + int ret;
> +
> + reg = of_io_request_and_map(node, 0, of_node_full_name(node));
> + if (IS_ERR(reg))
> + return;
> +
> + clk_parent = of_clk_get_parent_name(node, 0);
> + if (!clk_parent)
> + goto err_unmap;
> +
> + of_property_read_string(node, "clock-output-names", &clk_name);
> +
> + /* The A23 APB0 clock is a standard 2 bit wide divider clock */
> + clk = clk_register_divider(NULL, clk_name, clk_parent, 0, reg,
> + 0, 2, CLK_DIVIDER_POWER_OF_TWO, NULL);
> + if (IS_ERR(clk))
> + goto err_unmap;
> +
> + ret = of_clk_add_provider(node, of_clk_src_simple_get, clk);
> + if (ret)
> + goto err_unregister;
> +
> + return;
> +
> +err_unregister:
> + clk_unregister_divider(clk);
> +
> +err_unmap:
> + iounmap(reg);
> + of_address_to_resource(node, 0, &res);
> + release_mem_region(res.start, resource_size(&res));
> +}
> +CLK_OF_DECLARE(sun8i_a23_apb0, "allwinner,sun8i-a23-apb0-clk",
> + sun8i_a23_apb0_setup);
So, beside the memory request / mapping, everything else is
duplicated? Can't you just create a common function and call it from
both?
Thanks,
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151125/fa85ba80/attachment-0001.sig>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 3/5] clk: sunxi: Add sun9i A80 cpus (cpu special) clock support
2015-11-24 9:32 ` [PATCH v3 3/5] clk: sunxi: Add sun9i A80 cpus (cpu special) clock support Chen-Yu Tsai
@ 2015-11-25 17:32 ` Maxime Ripard
2015-11-27 7:13 ` Chen-Yu Tsai
0 siblings, 1 reply; 12+ messages in thread
From: Maxime Ripard @ 2015-11-25 17:32 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Tue, Nov 24, 2015 at 05:32:14PM +0800, Chen-Yu Tsai wrote:
> The "cpus" clock is the clock for the embedded processor in the A80.
> It is also part of the PRCM clock tree. This clock includes a pre-
> divider on one of its inputs. For now we are using a custom clock
> driver for it. In the future we may want to develop a generalized
> driver for these types of clocks, which also includes the AHB clock
> driver on sun[5678]i.
>
> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> ---
>
> Hi Maxime,
>
> I'll do the factors clock refactoring mentioned during the discussion
> around v2 later on.
I have no idea what you are talking about :)
>
> ---
> Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
> drivers/clk/sunxi/Makefile | 1 +
> drivers/clk/sunxi/clk-sun9i-cpus.c | 240 ++++++++++++++++++++++
> 3 files changed, 242 insertions(+)
> create mode 100644 drivers/clk/sunxi/clk-sun9i-cpus.c
>
> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
> index b6859ed6913f..153ac72869e8 100644
> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
> @@ -27,6 +27,7 @@ Required properties:
> "allwinner,sun5i-a10s-ahb-gates-clk" - for the AHB gates on A10s
> "allwinner,sun7i-a20-ahb-gates-clk" - for the AHB gates on A20
> "allwinner,sun6i-a31-ar100-clk" - for the AR100 on A31
> + "allwinner,sun9i-a80-cpus-clk" - for the CPUS on A80
> "allwinner,sun6i-a31-ahb1-clk" - for the AHB1 clock on A31
> "allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31
> "allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
> diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
> index 121333ce34ea..07d914c3f6d1 100644
> --- a/drivers/clk/sunxi/Makefile
> +++ b/drivers/clk/sunxi/Makefile
> @@ -13,6 +13,7 @@ obj-y += clk-simple-gates.o
> obj-y += clk-sun8i-apb0.o
> obj-y += clk-sun8i-mbus.o
> obj-y += clk-sun9i-core.o
> +obj-y += clk-sun9i-cpus.o
Same thing here, if it's only used in the A80, just compile it when
ARCH_SUN9I is compiled.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151125/a7280ddd/attachment.sig>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 4/5] ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes
2015-11-24 10:27 ` Jisheng Zhang
@ 2015-11-26 20:09 ` Maxime Ripard
2015-11-27 5:42 ` Jisheng Zhang
0 siblings, 1 reply; 12+ messages in thread
From: Maxime Ripard @ 2015-11-26 20:09 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Nov 24, 2015 at 06:27:09PM +0800, Jisheng Zhang wrote:
> + Sebastian
>
> On Tue, 24 Nov 2015 17:32:15 +0800
> Chen-Yu Tsai wrote:
>
> > This adds the supported PRCM clocks and reset controls to the A80 dtsi.
> > The DAUDIO module clocks are not supported yet.
> >
> > Also update clock and reset phandles for r_uart.
> >
> > Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> > ---
> > arch/arm/boot/dts/sun9i-a80.dtsi | 79 +++++++++++++++++++++++++++++++++++++++-
> > 1 file changed, 78 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
> > index 1118bf5cc4fb..a4ce348c0831 100644
> > --- a/arch/arm/boot/dts/sun9i-a80.dtsi
> > +++ b/arch/arm/boot/dts/sun9i-a80.dtsi
> > @@ -164,6 +164,14 @@
> > "usb_phy2", "usb_hsic_12M";
> > };
> >
> > + pll3: clk at 06000008 {
> > + /* placeholder until implemented */
> > + #clock-cells = <0>;
> > + compatible = "fixed-clock";
> > + clock-rate = <0>;
> > + clock-output-names = "pll3";
> > + };
> > +
> > pll4: clk at 0600000c {
> > #clock-cells = <0>;
> > compatible = "allwinner,sun9i-a80-pll4-clk";
> > @@ -350,6 +358,68 @@
> > "apb1_uart2", "apb1_uart3",
> > "apb1_uart4", "apb1_uart5";
> > };
> > +
> > + cpus_clk: clk at 08001410 {
> > + compatible = "allwinner,sun9i-a80-cpus-clk";
> > + reg = <0x08001410 0x4>;
> > + #clock-cells = <0>;
> > + clocks = <&osc32k>, <&osc24M>, <&pll4>, <&pll3>;
> > + clock-output-names = "cpus";
> > + };
> > +
> > + ahbs: ahbs_clk {
> > + compatible = "fixed-factor-clock";
> > + #clock-cells = <0>;
> > + clock-div = <1>;
> > + clock-mult = <1>;
> > + clocks = <&cpus_clk>;
> > + clock-output-names = "ahbs";
> > + };
>
> Dear Sebastian and all,
>
> I just want to take the sunxi clk support in mainline for example.
>
> I'm not sure I understand correctly, it seems to me that some maintainers draw a
> line: "having a node for every clock" is a no, no[1]. But here we saw one node for
> cpus_clk and apbs below. And <0x08001410 0x4>; <0x0800141c 0x4>; shows they
> are close each other, so should we merge them into a single clock complex node
> then use mfd, regmap in clk driver?
>
> But IMHO, sunxi dts nodes really represent real HW, so I still can't understand
> why we could not have each node for cpus_clk and apbs. Can you please kindly
> teach me?
I'm totally lacking any context, but I'll reply. My view on this is
that they both represent the hardware, simply with a different model.
This preference of the clk maintainers and active clk developers
regarding the model to choose has evolved over time. When we started
the sunxi support, having one node per clock was the preferred way to
do things.
Berlin came much later, and the preference at that time was to have
the entire clock controller represented as single opaque block to the
consumers.
Both have pros and cons. The approach we took allows for an easier mix
and match, especially if the clocks you have in one SoC are reused in
others, without modifying the source code (or barely). AFAIK, this is
also the approach took by mvebu, except that their clock tree is much
much much simpler.
The approach Berlin took allows to have an easier maintainance and
more flexibility, for example to deal with clock registration
ordering, or clocks that share registers.
Our approach works just fine in our case, and I feel no incentive to
move to the new model (quite the opposite actually), but I guess it
also depends on how your clock controller is built, how many SoCs you
have to support, and how much clocks they are sharing.
I hope it clears things up.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151126/8a0357c6/attachment.sig>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 4/5] ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes
2015-11-26 20:09 ` Maxime Ripard
@ 2015-11-27 5:42 ` Jisheng Zhang
0 siblings, 0 replies; 12+ messages in thread
From: Jisheng Zhang @ 2015-11-27 5:42 UTC (permalink / raw)
To: linux-arm-kernel
Dear Maxime,
On Thu, 26 Nov 2015 21:09:42 +0100
Maxime Ripard wrote:
> On Tue, Nov 24, 2015 at 06:27:09PM +0800, Jisheng Zhang wrote:
> > + Sebastian
> >
> > On Tue, 24 Nov 2015 17:32:15 +0800
> > Chen-Yu Tsai wrote:
> >
> > > This adds the supported PRCM clocks and reset controls to the A80 dtsi.
> > > The DAUDIO module clocks are not supported yet.
> > >
> > > Also update clock and reset phandles for r_uart.
> > >
> > > Signed-off-by: Chen-Yu Tsai <wens@csie.org>
> > > ---
> > > arch/arm/boot/dts/sun9i-a80.dtsi | 79 +++++++++++++++++++++++++++++++++++++++-
> > > 1 file changed, 78 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/arch/arm/boot/dts/sun9i-a80.dtsi b/arch/arm/boot/dts/sun9i-a80.dtsi
> > > index 1118bf5cc4fb..a4ce348c0831 100644
> > > --- a/arch/arm/boot/dts/sun9i-a80.dtsi
> > > +++ b/arch/arm/boot/dts/sun9i-a80.dtsi
> > > @@ -164,6 +164,14 @@
> > > "usb_phy2", "usb_hsic_12M";
> > > };
> > >
> > > + pll3: clk at 06000008 {
> > > + /* placeholder until implemented */
> > > + #clock-cells = <0>;
> > > + compatible = "fixed-clock";
> > > + clock-rate = <0>;
> > > + clock-output-names = "pll3";
> > > + };
> > > +
> > > pll4: clk at 0600000c {
> > > #clock-cells = <0>;
> > > compatible = "allwinner,sun9i-a80-pll4-clk";
> > > @@ -350,6 +358,68 @@
> > > "apb1_uart2", "apb1_uart3",
> > > "apb1_uart4", "apb1_uart5";
> > > };
> > > +
> > > + cpus_clk: clk at 08001410 {
> > > + compatible = "allwinner,sun9i-a80-cpus-clk";
> > > + reg = <0x08001410 0x4>;
> > > + #clock-cells = <0>;
> > > + clocks = <&osc32k>, <&osc24M>, <&pll4>, <&pll3>;
> > > + clock-output-names = "cpus";
> > > + };
> > > +
> > > + ahbs: ahbs_clk {
> > > + compatible = "fixed-factor-clock";
> > > + #clock-cells = <0>;
> > > + clock-div = <1>;
> > > + clock-mult = <1>;
> > > + clocks = <&cpus_clk>;
> > > + clock-output-names = "ahbs";
> > > + };
> >
> > Dear Sebastian and all,
> >
> > I just want to take the sunxi clk support in mainline for example.
> >
> > I'm not sure I understand correctly, it seems to me that some maintainers draw a
> > line: "having a node for every clock" is a no, no[1]. But here we saw one node for
> > cpus_clk and apbs below. And <0x08001410 0x4>; <0x0800141c 0x4>; shows they
> > are close each other, so should we merge them into a single clock complex node
> > then use mfd, regmap in clk driver?
> >
> > But IMHO, sunxi dts nodes really represent real HW, so I still can't understand
> > why we could not have each node for cpus_clk and apbs. Can you please kindly
> > teach me?
>
> I'm totally lacking any context, but I'll reply. My view on this is
> that they both represent the hardware, simply with a different model.
>
> This preference of the clk maintainers and active clk developers
> regarding the model to choose has evolved over time. When we started
> the sunxi support, having one node per clock was the preferred way to
> do things.
>
> Berlin came much later, and the preference at that time was to have
> the entire clock controller represented as single opaque block to the
> consumers.
>
> Both have pros and cons. The approach we took allows for an easier mix
> and match, especially if the clocks you have in one SoC are reused in
> others, without modifying the source code (or barely). AFAIK, this is
> also the approach took by mvebu, except that their clock tree is much
> much much simpler.
>
> The approach Berlin took allows to have an easier maintainance and
> more flexibility, for example to deal with clock registration
> ordering, or clocks that share registers.
>
> Our approach works just fine in our case, and I feel no incentive to
> move to the new model (quite the opposite actually), but I guess it
> also depends on how your clock controller is built, how many SoCs you
> have to support, and how much clocks they are sharing.
Great! Thank you a lot for the detailed explanation. Now I can understand
why the clk drivers follow different models, I think I get Sebastian and
Stephen's view points. Although the BG4CT clock/pll IP are shared in all
newer than BG2Q SoCs (the only difference is how many clocks, how many plls,
and their register address), I'll follow Sebastian's suggestions -- one
entire clock controller node for all clocks/plls block
>
> I hope it clears things up.
Yes, it's clear now. I knew the history and the reason why there are different
models in clk drivers.
Will cook a newer BG4CT clk series for review.
Thank you,
Jisheng
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v3 3/5] clk: sunxi: Add sun9i A80 cpus (cpu special) clock support
2015-11-25 17:32 ` Maxime Ripard
@ 2015-11-27 7:13 ` Chen-Yu Tsai
0 siblings, 0 replies; 12+ messages in thread
From: Chen-Yu Tsai @ 2015-11-27 7:13 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Nov 26, 2015 at 1:32 AM, Maxime Ripard
<maxime.ripard@free-electrons.com> wrote:
> Hi,
>
> On Tue, Nov 24, 2015 at 05:32:14PM +0800, Chen-Yu Tsai wrote:
>> The "cpus" clock is the clock for the embedded processor in the A80.
>> It is also part of the PRCM clock tree. This clock includes a pre-
>> divider on one of its inputs. For now we are using a custom clock
>> driver for it. In the future we may want to develop a generalized
>> driver for these types of clocks, which also includes the AHB clock
>> driver on sun[5678]i.
>>
>> Signed-off-by: Chen-Yu Tsai <wens@csie.org>
>> ---
>>
>> Hi Maxime,
>>
>> I'll do the factors clock refactoring mentioned during the discussion
>> around v2 later on.
>
> I have no idea what you are talking about :)
Then I guess I have more time to figure something out. :)
>>
>> ---
>> Documentation/devicetree/bindings/clock/sunxi.txt | 1 +
>> drivers/clk/sunxi/Makefile | 1 +
>> drivers/clk/sunxi/clk-sun9i-cpus.c | 240 ++++++++++++++++++++++
>> 3 files changed, 242 insertions(+)
>> create mode 100644 drivers/clk/sunxi/clk-sun9i-cpus.c
>>
>> diff --git a/Documentation/devicetree/bindings/clock/sunxi.txt b/Documentation/devicetree/bindings/clock/sunxi.txt
>> index b6859ed6913f..153ac72869e8 100644
>> --- a/Documentation/devicetree/bindings/clock/sunxi.txt
>> +++ b/Documentation/devicetree/bindings/clock/sunxi.txt
>> @@ -27,6 +27,7 @@ Required properties:
>> "allwinner,sun5i-a10s-ahb-gates-clk" - for the AHB gates on A10s
>> "allwinner,sun7i-a20-ahb-gates-clk" - for the AHB gates on A20
>> "allwinner,sun6i-a31-ar100-clk" - for the AR100 on A31
>> + "allwinner,sun9i-a80-cpus-clk" - for the CPUS on A80
>> "allwinner,sun6i-a31-ahb1-clk" - for the AHB1 clock on A31
>> "allwinner,sun6i-a31-ahb1-gates-clk" - for the AHB1 gates on A31
>> "allwinner,sun8i-a23-ahb1-gates-clk" - for the AHB1 gates on A23
>> diff --git a/drivers/clk/sunxi/Makefile b/drivers/clk/sunxi/Makefile
>> index 121333ce34ea..07d914c3f6d1 100644
>> --- a/drivers/clk/sunxi/Makefile
>> +++ b/drivers/clk/sunxi/Makefile
>> @@ -13,6 +13,7 @@ obj-y += clk-simple-gates.o
>> obj-y += clk-sun8i-apb0.o
>> obj-y += clk-sun8i-mbus.o
>> obj-y += clk-sun9i-core.o
>> +obj-y += clk-sun9i-cpus.o
>
> Same thing here, if it's only used in the A80, just compile it when
> ARCH_SUN9I is compiled.
Sure. Should I add a patch changing the ones already in? sun9i-core
and sun9i-mmc that is.
Thanks
ChenYu
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-11-27 7:13 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-24 9:32 [PATCH v3 0/5] ARM: sun9i: Add Allwinner A80 PRCM clock/reset support Chen-Yu Tsai
2015-11-24 9:32 ` [PATCH v3 1/5] clk: sunxi: Add CLK_OF_DECLARE support for sun8i-a23-apb0-clk driver Chen-Yu Tsai
2015-11-25 14:18 ` Maxime Ripard
2015-11-24 9:32 ` [PATCH v3 2/5] clk: sunxi: Add sun9i A80 apbs gates support Chen-Yu Tsai
2015-11-24 9:32 ` [PATCH v3 3/5] clk: sunxi: Add sun9i A80 cpus (cpu special) clock support Chen-Yu Tsai
2015-11-25 17:32 ` Maxime Ripard
2015-11-27 7:13 ` Chen-Yu Tsai
2015-11-24 9:32 ` [PATCH v3 4/5] ARM: dts: sun9i: Add A80 PRCM clocks and reset control nodes Chen-Yu Tsai
2015-11-24 10:27 ` Jisheng Zhang
2015-11-26 20:09 ` Maxime Ripard
2015-11-27 5:42 ` Jisheng Zhang
2015-11-24 9:32 ` [PATCH v3 5/5] ARM: dts: sun9i: Add TODO comments for the main and low power clocks Chen-Yu Tsai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).