Skip to contentSkip to conversation

core, cpu and gated clocks for mvebu

PATCH New Andrew Lunn 1 participant 10 messages Nov 17, 2012

Subsystems (7)
lore
Share & tools
lore

Andrew Lunn

author maintainer
#0 lore raw

v2 cover core, cpu and gated clocks for mvebu

This patchset combines code from Gregory Clement, Sebastian Hesselbarth and myself to implement core clks, cpu clock and gated clocks on Marvel MVEBU SoCs.

The Armada 370/XP core clock code is a refactored version of the already submitted and ACKed code from Gregory. It has been made to fit inside a framework developed by Sebastian which can handle all MVEBU SoCs. The Armada 370/XP SoCs have more core clocks than the older SoCs, and the framework needs to handle this. Rather than specify the clock frequencies in DT, a Sample At Reset register is used, which describes each core clock frequency.

Armada XP is an SMP processor, with each CPU having its own clock. Gregories code for this has been taken as is.

The Armada 370/XP clock source has been converted to the common clock framework.

Dove, Kirkword, and Armada 370/XP have the ability to gate clocks to various blocks. A clk-gate clock is created for each of the gateable clocks on Dove and Kirkwood and Armada 370/XP.

This code has been tested on:

Kirkwood based QNAP TS219
Armada 370 based mirabox
Armada XP based OpenBlocks
Dove based Cubox.

v1 -> v2
Moved some patch hunks into the correct patch
Added armada_ prefix to a number of symbols
renamed clk_gate to gate_clk
renamed *-clock-gating to *-gating-clock
Add gating-clock implementation for Armada 370/XP Add Tested-by from Gregory
Documented required clock property in armada-370-xp-timer.txt

Andrew Lunn (1):
ARM: Kirkwood: switch to DT clock providers

Gregory CLEMENT (5):
clk: mvebu: add armada-370-xp CPU specific clocks
clk: armada-370-xp: add support for clock framework
clocksource: convert time-armada-370-xp to clk framework
clk: mvebu: armada 370/XP add clock gating control provider for DT
arm: mvebu: armada 370/XP adding clock gating support: dt binding

Sebastian Hesselbarth (3):
clk: mvebu: add mvebu core clocks.
clk: mvebu: add clock gating control provider for DT
ARM: dove: switch to DT clock providers

 .../bindings/arm/armada-370-xp-timer.txt           |    1 +
 .../devicetree/bindings/clock/mvebu-core-clock.txt |   47 ++
 .../devicetree/bindings/clock/mvebu-cpu-clock.txt  |   21 +
 .../bindings/clock/mvebu-gated-clock.txt           |  119 ++++
 arch/arm/Kconfig                                   |    1 +
 arch/arm/boot/dts/armada-370-db.dts                |    4 -
 arch/arm/boot/dts/armada-370-xp.dtsi               |    1 +
 arch/arm/boot/dts/armada-370.dtsi                  |   15 +
 arch/arm/boot/dts/armada-xp.dtsi                   |   49 ++
 arch/arm/boot/dts/dove.dtsi                        |   20 +
 arch/arm/boot/dts/kirkwood.dtsi                    |   22 +
 arch/arm/mach-dove/Kconfig                         |    2 +
 arch/arm/mach-dove/common.c                        |   64 +-
 arch/arm/mach-kirkwood/Kconfig                     |    2 +
 arch/arm/mach-kirkwood/board-dt.c                  |   72 ++-
 arch/arm/mach-mvebu/Kconfig                        |    4 +
 arch/arm/mach-mvebu/armada-370-xp.c                |    9 +-
 arch/arm/plat-orion/include/plat/common.h          |    1 +
 drivers/clk/Kconfig                                |    2 +
 drivers/clk/Makefile                               |    1 +
 drivers/clk/mvebu/Kconfig                          |    8 +
 drivers/clk/mvebu/Makefile                         |    3 +
 drivers/clk/mvebu/clk-core.c                       |  675 ++++++++++++++++++++
 drivers/clk/mvebu/clk-core.h                       |   18 +
 drivers/clk/mvebu/clk-cpu.c                        |  155 +++++
 drivers/clk/mvebu/clk-cpu.h                        |   18 +
 drivers/clk/mvebu/clk-gating-ctrl.c                |  238 +++++++
 drivers/clk/mvebu/clk.c                            |   37 ++
 drivers/clocksource/time-armada-370-xp.c           |   11 +-
 include/linux/clk/mvebu.h                          |   23 +
 30 files changed, 1605 insertions(+), 38 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/mvebu-core-clock.txt
 create mode 100644 Documentation/devicetree/bindings/clock/mvebu-cpu-clock.txt
 create mode 100644 Documentation/devicetree/bindings/clock/mvebu-gated-clock.txt
 create mode 100644 drivers/clk/mvebu/Kconfig
 create mode 100644 drivers/clk/mvebu/Makefile
 create mode 100644 drivers/clk/mvebu/clk-core.c
 create mode 100644 drivers/clk/mvebu/clk-core.h
 create mode 100644 drivers/clk/mvebu/clk-cpu.c
 create mode 100644 drivers/clk/mvebu/clk-cpu.h
 create mode 100644 drivers/clk/mvebu/clk-gating-ctrl.c
 create mode 100644 drivers/clk/mvebu/clk.c
 create mode 100644 include/linux/clk/mvebu.h
Signature · 1 line
1.7.10.4
author maintainer
#1 lore raw

PATCH v2 1/9 clk: mvebu: add mvebu core clocks.

From: Sebastian Hesselbarth <[email protected]>

This driver allows to provide DT clocks for core clocks found on Marvell Kirkwood, Dove & 370/XP SoCs. The core clock frequencies and ratios are determined by decoding the Sample-At-Reset registers.

Although technically correct, using a divider of 0 will lead to div_by_zero panic. Let's use a ratio of 0/1 instead to fail later with a zero clock.

Tested-by Gregory CLEMENT <[email protected]>

---
 .../devicetree/bindings/clock/mvebu-core-clock.txt |   47 ++
 drivers/clk/Kconfig                                |    2 +
 drivers/clk/Makefile                               |    1 +
 drivers/clk/mvebu/Kconfig                          |    3 +
 drivers/clk/mvebu/Makefile                         |    1 +
 drivers/clk/mvebu/clk-core.c                       |  675 ++++++++++++++++++++
 drivers/clk/mvebu/clk-core.h                       |   18 +
 drivers/clk/mvebu/clk.c                            |   23 +
 include/linux/clk/mvebu.h                          |   22 +
 9 files changed, 792 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/mvebu-core-clock.txt
 create mode 100644 drivers/clk/mvebu/Kconfig
 create mode 100644 drivers/clk/mvebu/Makefile
 create mode 100644 drivers/clk/mvebu/clk-core.c
 create mode 100644 drivers/clk/mvebu/clk-core.h
 create mode 100644 drivers/clk/mvebu/clk.c
 create mode 100644 include/linux/clk/mvebu.h
Documentation/devicetree/bindings/clock/mvebu-core-clock.txt new file +47 -0
new file mode 100644
index 0000000..ffb3d69
@@ -0,0 +1,47 @@
+* Core Clock bindings for Marvell MVEBU SoCs
+
+Marvell MVEBU SoCs usually allow to determine core clock frequencies by
+reading the Sample-At-Reset (SAR) register. The core clock consumer should
+specify the desired clock by having the clock ID in its "clocks" phandle cell.
+
+The following is a list of provided IDs and clock names on Armada 370/XP:
+ 0 = tclk    (Internal Bus clock)
+ 1 = cpuclk  (CPU clock)
+ 2 = nbclk   (L2 Cache clock)
+ 3 = hclk    (DRAM control clock)
+ 4 = dramclk (DDR clock)
+
+The following is a list of provided IDs and clock names on Kirkwood and Dove:
+ 0 = tclk   (Internal Bus clock)
+ 1 = cpuclk (CPU0 clock)
+ 2 = l2clk  (L2 Cache clock derived from CPU0 clock)
+ 3 = ddrclk (DDR controller clock derived from CPU0 clock)
+
+Required properties:
+- compatible : shall be one of the following:
+	"marvell,armada-370-core-clocks" - For Armada 370 SoC core clocks
+	"marvell,armada-xp-core-clocks" - For Armada XP SoC core clocks
+	"marvell,dove-core-clocks" - for Dove SoC core clocks
+	"marvell,kirkwood-core-clocks" - for Kirkwood SoC (except mv88f6180)
+	"marvell,mv88f6180-core-clocks" - for Kirkwood MV88f6180 SoC
+- reg : shall be the register address of the Sample-At-Reset (SAR) register
+- #clock-cells : from common clock binding; shall be set to 1
+
+Optional properties:
+- clock-output-names : from common clock binding; allows overwrite default clock
+	output names ("tclk", "cpuclk", "l2clk", "ddrclk")
+
+Example:
+
+core_clk: core-clocks at d0214 {
+	compatible = "marvell,dove-core-clocks";
+	reg = <0xd0214 0x4>;
+	#clock-cells = <1>;
+};
+
+spi0: spi at 10600 {
+	compatible = "marvell,orion-spi";
+	/* ... */
+	/* get tclk from core clock provider */
+	clocks = <&core_clk 0>;
+};
drivers/clk/Kconfig +2 -0
index bace9e9..60427c0 100644
@@ -54,3 +54,5 @@ config COMMON_CLK_MAX77686
 	  This driver supports Maxim 77686 crystal oscillator clock. 
 
 endmenu
+
+source "drivers/clk/mvebu/Kconfig"
drivers/clk/Makefile +1 -0
index 71a25b9..d0a14ae 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_PLAT_SPEAR)	+= spear/
 obj-$(CONFIG_ARCH_U300)		+= clk-u300.o
 obj-$(CONFIG_COMMON_CLK_VERSATILE) += versatile/
 obj-$(CONFIG_ARCH_PRIMA2)	+= clk-prima2.o
+obj-$(CONFIG_PLAT_ORION)	+= mvebu/
 ifeq ($(CONFIG_COMMON_CLK), y)
 obj-$(CONFIG_ARCH_MMP)		+= mmp/
 endif
drivers/clk/mvebu/Kconfig new file +3 -0
new file mode 100644
index 0000000..fd7bf97
@@ -0,0 +1,3 @@
+config MVEBU_CLK_CORE
+       bool
+
drivers/clk/mvebu/Makefile new file +1 -0
new file mode 100644
index 0000000..de1d961
@@ -0,0 +1 @@
+obj-$(CONFIG_MVEBU_CLK_CORE) 	+= clk.o clk-core.o
drivers/clk/mvebu/clk-core.c new file +675 -0

675 lines not on this page · raw message

drivers/clk/mvebu/clk-core.h new file +18 -0
new file mode 100644
index 0000000..28b5e02
@@ -0,0 +1,18 @@
+/*
+ *  * Marvell EBU clock core handling defined at reset
+ *
+ * Copyright (C) 2012 Marvell
+ *
+ * Gregory CLEMENT <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef __MVEBU_CLK_CORE_H
+#define __MVEBU_CLK_CORE_H
+
+void __init mvebu_core_clk_init(void);
+
+#endif
drivers/clk/mvebu/clk.c new file +23 -0
new file mode 100644
index 0000000..e6742ac
@@ -0,0 +1,23 @@
+/*
+ * Marvell EBU SoC clock handling.
+ *
+ * Copyright (C) 2012 Marvell
+ *
+ * Gregory CLEMENT <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>
+#include <linux/clk/mvebu.h>
+#include <linux/of.h>
+#include "clk-core.h"
+
+void __init mvebu_clocks_init(void)
+{
+	mvebu_core_clk_init();
+}
include/linux/clk/mvebu.h new file +22 -0
new file mode 100644
index 0000000..8c4ae71
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __CLK_MVEBU_H_
+#define __CLK_MVEBU_H_
+
+void __init mvebu_clocks_init(void);
+
+#endif
Signature · 1 line
1.7.10.4
author maintainer
#2 lore raw

PATCH v2 2/9 clk: mvebu: add armada-370-xp CPU specific clocks

In reply to Andrew Lunn

From: Gregory CLEMENT <[email protected]>

Add Armada 370/XP specific CPU clocks

Tested-by Gregory CLEMENT <[email protected]>

---
 .../devicetree/bindings/clock/mvebu-cpu-clock.txt  |   21 +++
 drivers/clk/mvebu/Kconfig                          |    3 +
 drivers/clk/mvebu/Makefile                         |    1 +
 drivers/clk/mvebu/clk-cpu.c                        |  155 ++++++++++++++++++++
 drivers/clk/mvebu/clk-cpu.h                        |   18 +++
 drivers/clk/mvebu/clk.c                            |   14 ++
 6 files changed, 212 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/mvebu-cpu-clock.txt
 create mode 100644 drivers/clk/mvebu/clk-cpu.c
 create mode 100644 drivers/clk/mvebu/clk-cpu.h
Documentation/devicetree/bindings/clock/mvebu-cpu-clock.txt new file +21 -0
new file mode 100644
index 0000000..1fb5a64
@@ -0,0 +1,21 @@
+Device Tree Clock bindings for cpu clock of Marvell EBU platforms
+
+Required properties:
+- compatible : shall be one of the following:
+	"marvell,armada-xp-cpu-clockctrl" - cpu clocks for Armada XP
+- reg : Address and length of the clock complex register set
+- #clock-cells : should be set to 1.
+- clocks : shall be the input parent clock phandle for the clock.
+
+cpuclk: clock-complex at d0018700 {
+	#clock-cells = <1>;
+	compatible = "marvell,armada-xp-cpu-clockctrl";
+	reg = <0xd0018700 0xA0>;
+	clocks = <&coreclk 1>;
+}
+
+cpu at 0 {
+	compatible = "marvell,sheeva-v7";
+	reg = <0>;
+	clocks = <&cpuclk 0>;
+};
drivers/clk/mvebu/Kconfig +3 -0
index fd7bf97..1dd93ad 100644
@@ -1,3 +1,6 @@
 config MVEBU_CLK_CORE
        bool
 
+config MVEBU_CLK_CPU
+       bool
+
drivers/clk/mvebu/Makefile +1 -0
index de1d961..93da083 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_MVEBU_CLK_CORE) 	+= clk.o clk-core.o
+obj-$(CONFIG_MVEBU_CLK_CPU) 	+= clk-cpu.o
drivers/clk/mvebu/clk-cpu.c new file +155 -0

155 lines not on this page · raw message

drivers/clk/mvebu/clk-cpu.h new file +18 -0
new file mode 100644
index 0000000..e208336
@@ -0,0 +1,18 @@
+/*
+ * Marvell MVEBU CPU clock handling.
+ *
+ * Copyright (C) 2012 Marvell
+ *
+ * Gregory CLEMENT <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#ifndef __MVEBU_CLK_CPU_H
+#define __MVEBU_CLK_CPU_H
+
+void __init of_cpu_clk_setup(struct device_node *node);
+
+#endif
drivers/clk/mvebu/clk.c +14 -0
index e6742ac..dc310d6 100644
@@ -16,8 +16,22 @@
 #include <linux/clk/mvebu.h>
 #include <linux/of.h>
 #include "clk-core.h"
+#include "clk-cpu.h"
+
+static const __initconst struct of_device_id clk_match[] = {
+#ifdef CONFIG_MVEBU_CLK_CPU
+	{
+		.compatible = "marvell,armada-xp-cpu-clockctrl",
+		.data = of_cpu_clk_setup,
+	},
+#endif
+	{
+		/* sentinel */
+	}
+};
 
 void __init mvebu_clocks_init(void)
 {
 	mvebu_core_clk_init();
+	of_clk_init(clk_match);
 }
Signature · 1 line
1.7.10.4
author maintainer
#3 lore raw

PATCH v2 3/9 clk: armada-370-xp: add support for clock framework

In reply to Andrew Lunn

From: Gregory CLEMENT <[email protected]>

Tested-by Gregory CLEMENT <[email protected]>

---
 arch/arm/boot/dts/armada-370.dtsi   |    7 ++++++
 arch/arm/boot/dts/armada-xp.dtsi    |   42 +++++++++++++++++++++++++++++++++++
 arch/arm/mach-mvebu/Kconfig         |    3 +++
 arch/arm/mach-mvebu/armada-370-xp.c |    9 +++++++-
 4 files changed, 60 insertions(+), 1 deletion(-)
arch/arm/boot/dts/armada-370.dtsi +7 -0
index 2069151..dae966c 100644
@@ -75,5 +75,12 @@
 			#interrupts-cells = <2>;
 			interrupts = <91>;
 		};
+
+		coreclk: mvebu-sar at d0018230 {
+			compatible = "marvell,armada-370-core-clocks";
+			reg = <0xd0018230 0x08>;
+			#clock-cells = <1>;
+		};
+
 	};
 };
arch/arm/boot/dts/armada-xp.dtsi +42 -0

54 lines not on this page · raw message

arch/arm/mach-mvebu/Kconfig +3 -0
index 416d46e..c7b8404 100644
@@ -9,6 +9,9 @@ config ARCH_MVEBU
 	select PINCTRL
 	select PLAT_ORION
 	select SPARSE_IRQ
+	select CLKDEV_LOOKUP
+	select MVEBU_CLK_CORE
+	select MVEBU_CLK_CPU
 
 if ARCH_MVEBU
 
arch/arm/mach-mvebu/armada-370-xp.c +8 -1
index 49d7915..3292d6d 100644
@@ -17,6 +17,7 @@
 #include <linux/of_platform.h>
 #include <linux/io.h>
 #include <linux/time-armada-370-xp.h>
+#include <linux/clk/mvebu.h>
 #include <asm/mach/arch.h>
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
@@ -37,8 +38,14 @@ void __init armada_370_xp_map_io(void)
 	iotable_init(armada_370_xp_io_desc, ARRAY_SIZE(armada_370_xp_io_desc));
 }
 
+void __init armada_370_xp_timer_and_clk_init(void)
+{
+	mvebu_clocks_init();
+	armada_370_xp_timer_init();
+}
+
 struct sys_timer armada_370_xp_timer = {
-	.init		= armada_370_xp_timer_init,
+	.init		= armada_370_xp_timer_and_clk_init,
 };
 
 static void __init armada_370_xp_dt_init(void)
Signature · 1 line
1.7.10.4
author maintainer
#4 lore raw

PATCH v2 4/9 clocksource: convert time-armada-370-xp to clk framework

In reply to Andrew Lunn

From: Gregory CLEMENT <[email protected]>

Tested-by Gregory CLEMENT <[email protected]>

---
 .../devicetree/bindings/arm/armada-370-xp-timer.txt         |    1 +
 arch/arm/boot/dts/armada-370-db.dts                         |    4 ----
 arch/arm/boot/dts/armada-370-xp.dtsi                        |    1 +
 drivers/clocksource/time-armada-370-xp.c                    |   11 ++++++-----
 4 files changed, 8 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/arm/armada-370-xp-timer.txt +1 -0
index 8b6ea22..6483011 100644
@@ -5,6 +5,7 @@ Required properties:
 - compatible: Should be "marvell,armada-370-xp-timer"
 - interrupts: Should contain the list of Global Timer interrupts
 - reg: Should contain the base address of the Global Timer registers
+- clocks: clock driving the timer hardware
 
 Optional properties:
 - marvell,timer-25Mhz: Tells whether the Global timer supports the 25
arch/arm/boot/dts/armada-370-db.dts +0 -4
index fffd5c2..4a31b03 100644
@@ -34,9 +34,5 @@
 			clock-frequency = <200000000>;
 			status = "okay";
 		};
-		timer at d0020300 {
-			clock-frequency = <600000000>;
-			status = "okay";
-		};
 	};
 };
arch/arm/boot/dts/armada-370-xp.dtsi +1 -0
index 16cc82c..94b4b9e 100644
@@ -62,6 +62,7 @@
 			       compatible = "marvell,armada-370-xp-timer";
 			       reg = <0xd0020300 0x30>;
 			       interrupts = <37>, <38>, <39>, <40>;
+			       clocks = <&coreclk 2>;
 		};
 
 		addr-decoding at d0020000 {
drivers/clocksource/time-armada-370-xp.c +6 -5
index 4674f94..a4605fd 100644
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/kernel.h>
+#include <linux/clk.h>
 #include <linux/timer.h>
 #include <linux/clockchips.h>
 #include <linux/interrupt.h>
@@ -167,7 +168,6 @@ void __init armada_370_xp_timer_init(void)
 	u32 u;
 	struct device_node *np;
 	unsigned int timer_clk;
-	int ret;
 	np = of_find_compatible_node(NULL, NULL, "marvell,armada-370-xp-timer");
 	timer_base = of_iomap(np, 0);
 	WARN_ON(!timer_base);
@@ -179,13 +179,14 @@ void __init armada_370_xp_timer_init(void)
 		       timer_base + TIMER_CTRL_OFF);
 		timer_clk = 25000000;
 	} else {
-		u32 clk = 0;
-		ret = of_property_read_u32(np, "clock-frequency", &clk);
-		WARN_ON(!clk || ret < 0);
+		unsigned long rate = 0;
+		struct clk *clk = of_clk_get(np, 0);
+		WARN_ON(IS_ERR(clk));
+		rate =  clk_get_rate(clk);
 		u = readl(timer_base + TIMER_CTRL_OFF);
 		writel(u & ~(TIMER0_25MHZ | TIMER1_25MHZ),
 		       timer_base + TIMER_CTRL_OFF);
-		timer_clk = clk / TIMER_DIVIDER;
+		timer_clk = rate / TIMER_DIVIDER;
 	}
 
 	/* We use timer 0 as clocksource, and timer 1 for
Signature · 1 line
1.7.10.4
author maintainer
#5 lore raw

PATCH v2 5/9 clk: mvebu: add clock gating control provider for DT

In reply to Andrew Lunn

From: Sebastian Hesselbarth <[email protected]>

This driver allows to provide DT clocks for clock gates found on Marvell Dove and Kirkwood SoCs. The clock gates are referenced by the phandle index of the corresponding bit in the clock gating control register to ease lookup in the datasheet.

---
 .../bindings/clock/mvebu-gated-clock.txt           |   76 +++++++++
 drivers/clk/mvebu/Kconfig                          |    2 +
 drivers/clk/mvebu/Makefile                         |    1 +
 drivers/clk/mvebu/clk-gating-ctrl.c                |  177 ++++++++++++++++++++
 include/linux/clk/mvebu.h                          |    1 +
 5 files changed, 257 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/mvebu-gated-clock.txt
 create mode 100644 drivers/clk/mvebu/clk-gating-ctrl.c
Documentation/devicetree/bindings/clock/mvebu-gated-clock.txt new file +76 -0
new file mode 100644
index 0000000..4ad8ccd
@@ -0,0 +1,76 @@
+* Gated Clock bindings for Marvell Orion SoCs
+
+Marvell Dove and Kirkwood allow some peripheral clocks to be gated to save
+some power. The clock consumer should specify the desired clock by having
+the clock ID in its "clocks" phandle cell. The clock ID is directly mapped to
+the corresponding clock gating control bit in HW to ease manual clock lookup
+in datasheet.
+
+The following is a list of provided IDs for Dove:
+ID	Clock	Peripheral
+-----------------------------------
+0	usb0	USB Host 0
+1	usb1	USB Host 1
+2	ge	Gigabit Ethernet
+3	sata	SATA Host
+4	pex0	PCIe Cntrl 0
+5	pex1	PCIe Cntrl 1
+8	sdio0	SDHCI Host 0
+9	sdio1	SDHCI Host 1
+10	nand	NAND Cntrl
+11	camera	Camera Cntrl
+12	i2s0	I2S Cntrl 0
+13	i2s1	I2S Cntrl 1
+15	crypto	CESA engine
+21	ac97	AC97 Cntrl
+22	pdma	Peripheral DMA
+23	xor0	XOR DMA 0
+24	xor1	XOR DMA 1
+30	gephy	Gigabit Ethernel PHY
+Note: gephy(30) is implemented as a parent clock of ge(2)
+
+The following is a list of provided IDs for Kirkwood:
+ID	Clock	Peripheral
+-----------------------------------
+0	ge0	Gigabit Ethernet 0
+2	pex0	PCIe Cntrl 0
+3	usb0	USB Host 0
+4	sdio	SDIO Cntrl
+5	tsu	Transp. Stream Unit
+6	dunit	SDRAM Cntrl
+7	runit	Runit
+8	xor0	XOR DMA 0
+9	audio	I2S Cntrl 0
+14	sata0	SATA Host 0
+15	sata1	SATA Host 1
+16	xor1	XOR DMA 1
+17	crypto	CESA engine
+18	pex1	PCIe Cntrl 1
+19	ge1	Gigabit Ethernet 0
+20	tdm	Time Division Mplx
+
+Required properties:
+- compatible : shall be one of the following:
+	"marvell,dove-gating-clock" - for Dove SoC clock gating
+	"marvell,kirkwood-gating-clock" - for Kirkwood SoC clock gating
+- reg : shall be the register address of the Clock Gating Control register
+- #clock-cells : from common clock binding; shall be set to 1
+
+Optional properties:
+- clocks : default parent clock phandle (e.g. tclk)
+
+Example:
+
+gate_clk: clock-gating-control at d0038 {
+	compatible = "marvell,dove-gating-clock";
+	reg = <0xd0038 0x4>;
+	/* default parent clock is tclk */
+	clocks = <&core_clk 0>;
+	#clock-cells = <1>;
+};
+
+sdio0: sdio at 92000 {
+	compatible = "marvell,dove-sdhci";
+	/* get clk gate bit 8 (sdio0) */
+	clocks = <&gate_clk 8>;
+};
drivers/clk/mvebu/Kconfig +2 -0
index 1dd93ad..57323fd 100644
@@ -4,3 +4,5 @@ config MVEBU_CLK_CORE
 config MVEBU_CLK_CPU
        bool
 
+config MVEBU_CLK_GATING
+       bool
drivers/clk/mvebu/Makefile +1 -0
index 93da083..58df3dc 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_MVEBU_CLK_CORE) 	+= clk.o clk-core.o
 obj-$(CONFIG_MVEBU_CLK_CPU) 	+= clk-cpu.o
+obj-$(CONFIG_MVEBU_CLK_GATING) 	+= clk-gating-ctrl.o
drivers/clk/mvebu/clk-gating-ctrl.c new file +177 -0

177 lines not on this page · raw message

include/linux/clk/mvebu.h +1 -0
index 8c4ae71..70c366f 100644
@@ -18,5 +18,6 @@
 #define __CLK_MVEBU_H_
 
 void __init mvebu_clocks_init(void);
+void mvebu_clk_gating_init(void);
 
 #endif
Signature · 1 line
1.7.10.4
author maintainer
#6 lore raw

PATCH v2 6/9 ARM: dove: switch to DT clock providers

In reply to Andrew Lunn

From: Sebastian Hesselbarth <[email protected]>

With true DT clock providers available switch Dove clock setup in DT- enabled boards. While AUXDATA can be removed completely from bus probing, some devices still don't know about DT at all. Therefore, some clock aliases are created until the devices also move to DT.

---
 arch/arm/Kconfig            |    1 +
 arch/arm/boot/dts/dove.dtsi |   20 ++++++++++++++
 arch/arm/mach-dove/Kconfig  |    2 ++
 arch/arm/mach-dove/common.c |   64 +++++++++++++++++++++++++++++++++----------
 4 files changed, 72 insertions(+), 15 deletions(-)
arch/arm/Kconfig +1 -0
index ade7e92..0590099 100644
@@ -533,6 +533,7 @@ config ARCH_IXP4XX
 config ARCH_DOVE
 	bool "Marvell Dove"
 	select ARCH_REQUIRE_GPIOLIB
+	select COMMON_CLK_DOVE
 	select CPU_V7
 	select GENERIC_CLOCKEVENTS
 	select MIGHT_HAVE_PCI
arch/arm/boot/dts/dove.dtsi +20 -0
index 5a00022..8c8ab62 100644
@@ -31,6 +31,19 @@
 			reg = <0x20204 0x04>, <0x20214 0x04>;
 		};
 
+		core_clk: core-clocks at d0214 {
+			compatible = "marvell,dove-core-clocks";
+			reg = <0xd0214 0x4>;
+			#clock-cells = <1>;
+		};
+
+		gate_clk: clock-gating-control at d0038 {
+			compatible = "marvell,dove-gating-clock";
+			reg = <0xd0038 0x4>;
+			clocks = <&core_clk 0>;
+			#clock-cells = <1>;
+		};
+
 		uart0: serial at 12000 {
 			compatible = "ns16550a";
 			reg = <0x12000 0x100>;
@@ -100,6 +113,7 @@
 			cell-index = <0>;
 			interrupts = <6>;
 			reg = <0x10600 0x28>;
+			clocks = <&core_clk 0>;
 			status = "disabled";
 		};
 
@@ -110,6 +124,7 @@
 			cell-index = <1>;
 			interrupts = <5>;
 			reg = <0x14600 0x28>;
+			clocks = <&core_clk 0>;
 			status = "disabled";
 		};
 
@@ -121,6 +136,7 @@
 			interrupts = <11>;
 			clock-frequency = <400000>;
 			timeout-ms = <1000>;
+			clocks = <&core_clk 0>;
 			status = "disabled";
 		};
 
@@ -128,6 +144,7 @@
 			compatible = "marvell,dove-sdhci";
 			reg = <0x92000 0x100>;
 			interrupts = <35>, <37>;
+			clocks = <&gate_clk 8>;
 			status = "disabled";
 		};
 
@@ -135,6 +152,7 @@
 			compatible = "marvell,dove-sdhci";
 			reg = <0x90000 0x100>;
 			interrupts = <36>, <38>;
+			clocks = <&gate_clk 9>;
 			status = "disabled";
 		};
 
@@ -142,6 +160,7 @@
 			compatible = "marvell,orion-sata";
 			reg = <0xa0000 0x2400>;
 			interrupts = <62>;
+			clocks = <&gate_clk 3>;
 			nr-ports = <1>;
 			status = "disabled";
 		};
@@ -152,6 +171,7 @@
 			      <0xc8000000 0x800>;
 			reg-names = "regs", "sram";
 			interrupts = <31>;
+			clocks = <&gate_clk 15>;
 			status = "okay";
 		};
 	};
arch/arm/mach-dove/Kconfig +2 -0
index 00154e7..603c5fd 100644
@@ -17,6 +17,8 @@ config MACH_CM_A510
 
 config MACH_DOVE_DT
 	bool "Marvell Dove Flattened Device Tree"
+	select MVEBU_CLK_CORE
+	select MVEBU_CLK_GATING
 	select USE_OF
 	help
 	  Say 'Y' here if you want your kernel to support the
arch/arm/mach-dove/common.c +49 -15

89 lines not on this page · raw message

Signature · 1 line
1.7.10.4
author maintainer
#7 lore raw

PATCH v2 7/9 ARM: Kirkwood: switch to DT clock providers

In reply to Andrew Lunn

With true DT clock providers available switch Kirkwood clock setup in DT- enabled boards. While AUXDATA can be removed completely from bus probing, some devices still don't know about DT. Therefore, some clkdev aliases are created until these devices also move to DT.

---
 arch/arm/boot/dts/kirkwood.dtsi           |   22 +++++++++
 arch/arm/mach-kirkwood/Kconfig            |    2 +
 arch/arm/mach-kirkwood/board-dt.c         |   72 +++++++++++++++++++++++------
 arch/arm/plat-orion/include/plat/common.h |    1 +
 4 files changed, 84 insertions(+), 13 deletions(-)
arch/arm/boot/dts/kirkwood.dtsi +22 -0
index 4e5b815..e5ebf42 100644
@@ -19,6 +19,12 @@
 		#address-cells = <1>;
 		#size-cells = <1>;
 
+		core_clk: core-clocks at 10030 {
+                	compatible = "marvell,kirkwood-core-clocks";
+			reg = <0x10030 0x4>;
+	        	#clock-cells = <1>;
+		};
+
 		gpio0: gpio at 10100 {
 			compatible = "marvell,orion-gpio";
 			#gpio-cells = <2>;
@@ -42,6 +48,7 @@
 			reg = <0x12000 0x100>;
 			reg-shift = <2>;
 			interrupts = <33>;
+			clocks = <&gate_clk 7>;
 			/* set clock-frequency in board dts */
 			status = "disabled";
 		};
@@ -51,6 +58,7 @@
 			reg = <0x12100 0x100>;
 			reg-shift = <2>;
 			interrupts = <34>;
+			clocks = <&gate_clk 7>;
 			/* set clock-frequency in board dts */
 			status = "disabled";
 		};
@@ -68,12 +76,21 @@
 			cell-index = <0>;
 			interrupts = <23>;
 			reg = <0x10600 0x28>;
+			clocks = <&gate_clk 7>;
 			status = "disabled";
 		};
 
+		gate_clk: clock-gating-control at 2011c {
+			compatible = "marvell,kirkwood-gating-clock";
+			reg = <0x2011c 0x4>;
+			clocks = <&core_clk 0>;
+			#clock-cells = <1>;
+		};
+
 		wdt at 20300 {
 			compatible = "marvell,orion-wdt";
 			reg = <0x20300 0x28>;
+			clocks = <&gate_clk 7>;
 			status = "okay";
 		};
 
@@ -81,6 +98,8 @@
 			compatible = "marvell,orion-sata";
 			reg = <0x80000 0x5000>;
 			interrupts = <21>;
+			clocks = <&gate_clk 14>, <&gate_clk 15>;
+			clock-names = "0", "1";
 			status = "disabled";
 		};
 
@@ -94,6 +113,7 @@
 			reg = <0x3000000 0x400>;
 			chip-delay = <25>;
 			/* set partition map and/or chip-delay in board dts */
+			clocks = <&gate_clk 7>;
 			status = "disabled";
 		};
 
@@ -104,6 +124,7 @@
 			#size-cells = <0>;
 			interrupts = <29>;
 			clock-frequency = <100000>;
+			clocks = <&gate_clk 7>;
 			status = "disabled";
 		};
 
@@ -113,6 +134,7 @@
 			      <0xf5000000 0x800>;
 			reg-names = "regs", "sram";
 			interrupts = <22>;
+			clocks = <&gate_clk 17>;
 			status = "okay";
 		};
 	};
arch/arm/mach-kirkwood/Kconfig +2 -0
index 50bca50..2833492 100644
@@ -46,6 +46,8 @@ config MACH_GURUPLUG
 
 config ARCH_KIRKWOOD_DT
 	bool "Marvell Kirkwood Flattened Device Tree"
+	select MVEBU_CLK_CORE
+	select MVEBU_CLK_GATING
 	select USE_OF
 	help
 	  Say 'Y' here if you want your kernel to support the
arch/arm/mach-kirkwood/board-dt.c +59 -13

101 lines not on this page · raw message

arch/arm/plat-orion/include/plat/common.h +1 -0
index 6bbc3fe..e06fc5f 100644
@@ -12,6 +12,7 @@
 #include <linux/mv643xx_eth.h>
 
 struct dsa_platform_data;
+struct mv_sata_platform_data;
 
 void __init orion_uart0_init(void __iomem *membase,
 			     resource_size_t mapbase,
Signature · 1 line
1.7.10.4
author maintainer
#8 lore raw

PATCH v2 8/9 clk: mvebu: armada 370/XP add clock gating control provider for DT

In reply to Andrew Lunn

From: Gregory CLEMENT <[email protected]>

---
 .../bindings/clock/mvebu-gated-clock.txt           |   43 ++++++++++++++
 arch/arm/mach-mvebu/Kconfig                        |    1 +
 drivers/clk/mvebu/clk-gating-ctrl.c                |   61 ++++++++++++++++++++
 3 files changed, 105 insertions(+)
Documentation/devicetree/bindings/clock/mvebu-gated-clock.txt +43 -0
index 4ad8ccd..7337005 100644
@@ -6,6 +6,49 @@ the clock ID in its "clocks" phandle cell. The clock ID is directly mapped to
 the corresponding clock gating control bit in HW to ease manual clock lookup
 in datasheet.
 
+The following is a list of provided IDs for Armada 370:
+ID	Clock	Peripheral
+-----------------------------------
+0	Audio	AC97 Cntrl
+1	pex0_en	PCIe 0 Clock out
+2	pex1_en	PCIe 1 Clock out
+3	ge1	Gigabit Ethernet 1
+4	ge0	Gigabit Ethernet 0
+5	pex0	PCIe Cntrl 0
+9	pex1	PCIe Cntrl 1
+15	sata0	SATA Host 0
+17	sdio	SDHCI Host
+25	tdm	Time Division Mplx
+28	ddr	DDR Cntrl
+30	sata1	SATA Host 0
+
+The following is a list of provided IDs for Armada XP:
+ID	Clock	Peripheral
+-----------------------------------
+0	audio	Audio Cntrl
+1	ge3	Gigabit Ethernet 3
+2	ge2	Gigabit Ethernet 2
+3	ge1	Gigabit Ethernet 1
+4	ge0	Gigabit Ethernet 0
+5	pex0	PCIe Cntrl 0
+6	pex1	PCIe Cntrl 1
+7	pex2	PCIe Cntrl 2
+8	pex3	PCIe Cntrl 3
+13	bp
+14	sata0lnk
+15	sata0	SATA Host 0
+16	lcd	LCD Cntrl
+17	sdio	SDHCI Host
+18	usb0	USB Host 0
+19	usb1	USB Host 1
+20	usb2	USB Host 2
+22	xor0	XOR DMA 0
+23	crypto	CESA engine
+25	tdm	Time Division Mplx
+28	xor1	XOR DMA 1
+29	sata1lnk
+30	sata1	SATA Host 0
+
 The following is a list of provided IDs for Dove:
 ID	Clock	Peripheral
 -----------------------------------
arch/arm/mach-mvebu/Kconfig +1 -0
index c7b8404..79299cd 100644
@@ -12,6 +12,7 @@ config ARCH_MVEBU
 	select CLKDEV_LOOKUP
 	select MVEBU_CLK_CORE
 	select MVEBU_CLK_CPU
+	select MVEBU_CLK_GATING
 
 if ARCH_MVEBU
 
drivers/clk/mvebu/clk-gating-ctrl.c +61 -0

73 lines not on this page · raw message

Signature · 1 line
1.7.10.4
author maintainer
#9 lore raw

PATCH v2 9/9 arm: mvebu: armada 370/XP adding clock gating support: dt binding

In reply to Andrew Lunn

From: Gregory CLEMENT <[email protected]>

---
 arch/arm/boot/dts/armada-370.dtsi |    8 ++++++++
 arch/arm/boot/dts/armada-xp.dtsi  |    7 +++++++
 2 files changed, 15 insertions(+)
arch/arm/boot/dts/armada-370.dtsi +8 -0
index dae966c..20ce596 100644
@@ -82,5 +82,13 @@
 			#clock-cells = <1>;
 		};
 
+		gateclk: clock-gating-control at d0018220 {
+			compatible = "marvell,armada-370-gating-clock";
+			reg = <0xd0018220 0x4>;
+			clocks = <&coreclk 0>;
+			#clock-cells = <1>;
+		};
+
+
 	};
 };
arch/arm/boot/dts/armada-xp.dtsi +7 -0
index f8382a8..9b0da25 100644
@@ -89,6 +89,13 @@
 			clocks = <&coreclk 1>;
 		};
 
+		gateclk: clock-gating-control at d001821c {
+			compatible = "marvell,armada-xp-gating-clock";
+			reg = <0xd001821c 0x4>;
+			clocks = <&coreclk 0>;
+			#clock-cells = <1>;
+		};
+
 		system-controller at d0018200 {
 				compatible = "marvell,armada-370-xp-system-controller";
 				reg = <0xd0018200 0x500>;
Signature · 1 line
1.7.10.4