Skip to contentSkip to conversation

clk: Common clock support for IMG Pistachio

PATCH In review Andrew Bresticker 3 participants 15 messages Feb 25, 2015 – Mar 31, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover clk: Common clock support for IMG Pistachio

This series adds common clock support for the IMG Pistachio SoC. Pistachio has two clock controllers (core and peripheral) and two general control blocks (peripheral and top) which also contain several clock gates. Like the recently submitted pinctrl driver [1], this driver is written so that it's hopefully easy to add support for future IMG SoCs.

Tested on an IMG Pistachio BuB. Based on 4.0-rc1 + my series adding Pistachio platform support [2], which introduces the MACH_PISTACHIO Kconfig symbol. A branch with this series and the dependent patches is available at [3]. I'd like this to go through the MIPS tree with Mike's or Stephen's ACK if possible.

Cc Ezequiel Garcia <[email protected]>
Cc James Hartley <[email protected]>
Cc James Hogan <[email protected]>

[1] https://lkml.org/lkml/2015/2/23/705
[2] https://lkml.org/lkml/2015/2/23/694
[3] https://github.com/abrestic/linux/tree/pistachio-clk-v1

Andrew Bresticker (7):
clk: Add binding document for Pistachio clock controllers
clk: Add basic infrastructure for Pistachio clocks
clk: pistachio: Add PLL driver
clk: pistachio: Register core clocks
clk: pistachio: Register peripheral clocks
clk: pistachio: Register system interface gate clocks
clk: pistachio: Register external clock gates

 .../devicetree/bindings/clock/pistachio-clock.txt  | 123 +++++++
 drivers/clk/Makefile                               |   1 +
 drivers/clk/pistachio/Makefile                     |   3 +
 drivers/clk/pistachio/clk-pistachio.c              | 329 +++++++++++++++++
 drivers/clk/pistachio/clk-pll.c                    | 401 +++++++++++++++++++++
 drivers/clk/pistachio/clk.c                        | 140 +++++++
 drivers/clk/pistachio/clk.h                        | 174 +++++++++
 include/dt-bindings/clock/pistachio-clk.h          | 183 ++++++++++
 8 files changed, 1354 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/pistachio-clock.txt
 create mode 100644 drivers/clk/pistachio/Makefile
 create mode 100644 drivers/clk/pistachio/clk-pistachio.c
 create mode 100644 drivers/clk/pistachio/clk-pll.c
 create mode 100644 drivers/clk/pistachio/clk.c
 create mode 100644 drivers/clk/pistachio/clk.h
 create mode 100644 include/dt-bindings/clock/pistachio-clk.h
Signature · 6 lines
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw

PATCH 1/7 clk: Add binding document for Pistachio clock controllers

Add a device-tree binding document describing the four clock controllers present on the IMG Pistachio SoC.

Cc Rob Herring <[email protected]>
Cc Pawel Moll <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Ian Campbell <[email protected]>
Cc Kumar Gala <[email protected]>
---
 .../devicetree/bindings/clock/pistachio-clock.txt  | 123 ++++++++++++++
 include/dt-bindings/clock/pistachio-clk.h          | 183 +++++++++++++++++++++
 2 files changed, 306 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/pistachio-clock.txt
 create mode 100644 include/dt-bindings/clock/pistachio-clk.h
Documentation/devicetree/bindings/clock/pistachio-clock.txt new file +123 -0
new file mode 100644
index 0000000..868db49
@@ -0,0 +1,123 @@
+Imagination Technologies Pistachio SoC clock controllers
+========================================================
+
+Pistachio has four clock controllers (core clock, peripheral clock, peripheral
+general control, and top general control) which are instantiated individually
+from the device-tree.
+
+External clocks:
+----------------
+
+There are three external inputs to the clock controllers which should be
+defined with the following clock-output-names:
+- "xtal": External 52Mhz oscillator (required)
+- "audio_clk_in": Alternate audio reference clock (optional)
+- "enet_clk_in": Alternate ethernet PHY clock (optional)
+
+Core clock controller:
+----------------------
+
+The core clock controller generates clocks for the CPU, RPU (WiFi + BT
+co-processor), audio, and several peripherals.
+
+Required properties:
+- compatible: Must be "img,pistachio-clk".
+- reg: Must contain the base address and length of the core clock controller.
+- #clock-cells: Must be 1.  The single cell is the clock identifier.
+  See dt-bindings/clock/pistachio-clk.h for the list of valid identifiers.
+- clocks: Must contain an entry for each clock in clock-names.
+- clock-names: Must include "xtal" (see "External clocks") and
+  "audio_clk_in_gate", "enet_clk_in_gate" which are generated by the
+  top-level general control.
+
+Example:
+	clk_core: clock-controller@18144000 {
+		compatible = "img,pistachio-clk";
+		reg = <0x18144000 0x800>;
+		clocks = <&xtal>, <&cr_top EXT_CLK_AUDIO_IN>,
+			 <&cr_top EXT_CLK_ENET_IN>;
+		clock-names = "xtal", "audio_clk_in_gate", "enet_clk_in_gate";
+
+		#clock-cells = <1>;
+	};
+
+Peripheral clock controller:
+----------------------------
+
+The peripheral clock controller generates clocks for the DDR, ROM, and other
+peripherals.  The peripheral system clock ("periph_sys") generated by the core
+clock controller is the input clock to the peripheral clock controller.
+
+Required properties:
+- compatible: Must be "img,pistachio-periph-clk".
+- reg: Must contain the base address and length of the peripheral clock
+  controller.
+- #clock-cells: Must be 1.  The single cell is the clock identifier.
+  See dt-bindings/clock/pistachio-clk.h for the list of valid identifiers.
+- clocks: Must contain an entry for each clock in clock-names.
+- clock-names: Must include "periph_sys", the peripheral system clock generated
+  by the core clock controller.
+
+Example:
+	clk_periph: clock-controller@18144800 {
+		compatible = "img,pistachio-clk-periph";
+		reg = <0x18144800 0x800>;
+		clocks = <&clk_core CLK_PERIPH_SYS>;
+		clock-names = "periph_sys";
+
+		#clock-cells = <1>;
+	};
+
+Peripheral general control:
+---------------------------
+
+The peripheral general control block generates system interface clocks and
+resets for various peripherals.  It also contains miscellaneous peripheral
+control registers.  The system clock ("sys") generated by the peripheral clock
+controller is the input clock to the system clock controller.
+
+Required properties:
+- compatible: Must include "img,pistachio-periph-cr" and "syscon".
+- reg: Must contain the base address and length of the peripheral general
+  control registers.
+- #clock-cells: Must be 1.  The single cell is the clock identifier.
+  See dt-bindings/clock/pistachio-clk.h for the list of valid identifiers.
+- clocks: Must contain an entry for each clock in clock-names.
+- clock-names: Must include "sys", the system clock generated by the peripheral
+  clock controller.
+
+Example:
+	cr_periph: syscon@18144800 {
+		compatible = "img,pistachio-cr-periph", "syscon";
+		reg = <0x18148000 0x1000>;
+		clocks = <&clock_periph PERIPH_CLK_PERIPH_SYS>;
+		clock-names = "sys";
+
+		#clock-cells = <1>;
+	};
+
+Top-level general control:
+--------------------------
+
+The top-level general control block contains miscellaneous control registers and
+gates for the external clocks "audio_clk_in" and "enet_clk_in".
+
+Required properties:
+- compatible: Must include "img,pistachio-cr-top" and "syscon".
+- reg: Must contain the base address and length of the top-level
+  control registers.
+- clocks: Must contain an entry for each clock in clock-names.
+- clock-names: Two optional clocks, "audio_clk_in" and "enet_clk_in" (see
+  "External clocks").
+- #clock-cells: Must be 1.  The single cell is the clock identifier.
+  See dt-bindings/clock/pistachio-clk.h for the list of valid identifiers.
+
+Example:
+	cr_top: syscon@18144800 {
+		compatible = "img,pistachio-cr-top", "syscon";
+		reg = <0x18149000 0x200>;
+		clocks = <&audio_refclk>, <&ext_enet_in>;
+		clock-names = "audio_clk_in", "enet_clk_in";
+
+		#clock-cells = <1>;
+	};
include/dt-bindings/clock/pistachio-clk.h new file +183 -0

183 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#2 lore raw

PATCH 2/7 clk: Add basic infrastructure for Pistachio clocks

In reply to Andrew Bresticker

Add helpers for registering clocks and clock providers on Pistachio.

---
 drivers/clk/Makefile           |   1 +
 drivers/clk/pistachio/Makefile |   1 +
 drivers/clk/pistachio/clk.c    | 140 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/pistachio/clk.h    | 124 ++++++++++++++++++++++++++++++++++++
 4 files changed, 266 insertions(+)
 create mode 100644 drivers/clk/pistachio/Makefile
 create mode 100644 drivers/clk/pistachio/clk.c
 create mode 100644 drivers/clk/pistachio/clk.h
drivers/clk/Makefile +1 -0
index d478ceb..e43ff53 100644
@@ -54,6 +54,7 @@ obj-$(CONFIG_ARCH_MMP)			+= mmp/
 endif
 obj-$(CONFIG_PLAT_ORION)		+= mvebu/
 obj-$(CONFIG_ARCH_MXS)			+= mxs/
+obj-$(CONFIG_MACH_PISTACHIO)		+= pistachio/
 obj-$(CONFIG_COMMON_CLK_PXA)		+= pxa/
 obj-$(CONFIG_COMMON_CLK_QCOM)		+= qcom/
 obj-$(CONFIG_ARCH_ROCKCHIP)		+= rockchip/
drivers/clk/pistachio/Makefile new file +1 -0
new file mode 100644
index 0000000..fc216ad
@@ -0,0 +1 @@
+obj-y	+= clk.o
drivers/clk/pistachio/clk.c new file +140 -0

140 lines not on this page · raw message

drivers/clk/pistachio/clk.h new file +124 -0

124 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#3 lore raw

Re: [PATCH 2/7] clk: Add basic infrastructure for Pistachio clocks

Quoted 10 lines · Andrew Bresticker
drivers/clk/pistachio/clk.c new file +9 -0
+
+void pistachio_clk_force_enable(struct pistachio_clk_provider *p,
+				unsigned int *clk_ids, unsigned int num)
+{
+	unsigned int i;
+	int err;
+
+	for (i = 0; i < num; i++) {
+		struct clk *clk = p->clk_data.clks[clk_ids[i]];

drivers/clk/pistachio/clk.c line 140

Quoted 10 lines
drivers/clk/pistachio/clk.c new file +10 -0
+
+		if (IS_ERR(clk))
+			continue;
+
+		err = clk_prepare_enable(clk);
+		if (err)
+			pr_err("Failed to enable clock %s: %d\n",
+			       __clk_get_name(clk), err);
+	}
+}

Is this to workaround some problems in the framework where clocks are turned off? Or is it that these clocks are already on before we boot Linux and we need to make sure the framework knows that?

Signature · 7 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#4 lore raw

Re: [PATCH 2/7] clk: Add basic infrastructure for Pistachio clocks

Quoted 17 lines · Stephen Boyd
Quoted 16 lines · Andrew Bresticker
drivers/clk/pistachio/clk.c new file +16 -0
+
+void pistachio_clk_force_enable(struct pistachio_clk_provider *p,
+                             unsigned int *clk_ids, unsigned int num)
+{
+     unsigned int i;
+     int err;
+
+     for (i = 0; i < num; i++) {
+             struct clk *clk = p->clk_data.clks[clk_ids[i]];
+
+             if (IS_ERR(clk))
+                     continue;
+
+             err = clk_prepare_enable(clk);
+             if (err)
+                     pr_err("Failed to enable clock %s: %d\n",
Quoted 8 lines

drivers/clk/pistachio/clk.c line 140

Quoted 4 lines
drivers/clk/pistachio/clk.c new file +3 -0
+                            __clk_get_name(clk), err);
+     }
+}

Is this to workaround some problems in the framework where clocks are turned off? Or is it that these clocks are already on before we boot Linux and we need to make sure the framework knows that?

It's the former. These clocks are enabled at POR and may only be gated as the final step to entering suspend, so they must remain on at runtime. The issue we were running into was that consumers of these critical clocks or their descendants would enable/disable their clocks during boot or runtime PM and cause these clocks to get disabled. Bumping up the prepare/enable count of these critical clocks seemed like the best way to handle this - is there a more preferred way? FWIW, this is also how the Tegra and Rockchip drivers handled this problem.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: [PATCH 2/7] clk: Add basic infrastructure for Pistachio clocks

Quoted 25 lines · Andrew Bresticker
Quoted 16 lines · Stephen Boyd
Quoted 15 lines · Andrew Bresticker
drivers/clk/pistachio/clk.c new file +15 -0
+
+void pistachio_clk_force_enable(struct pistachio_clk_provider *p,
+                             unsigned int *clk_ids, unsigned int num)
+{
+     unsigned int i;
+     int err;
+
+     for (i = 0; i < num; i++) {
+             struct clk *clk = p->clk_data.clks[clk_ids[i]];
+
+             if (IS_ERR(clk))
+                     continue;
+
+             err = clk_prepare_enable(clk);
+             if (err)
Quoted 8 lines

drivers/clk/pistachio/clk.c line 140

Quoted 5 lines
drivers/clk/pistachio/clk.c new file +4 -0
+                     pr_err("Failed to enable clock %s: %d\n",
+                            __clk_get_name(clk), err);
+     }
+}

Is this to workaround some problems in the framework where clocks are turned off? Or is it that these clocks are already on before we boot Linux and we need to make sure the framework knows that?

Quoted 9 lines

It's the former. These clocks are enabled at POR and may only be gated as the final step to entering suspend, so they must remain on at runtime. The issue we were running into was that consumers of these critical clocks or their descendants would enable/disable their clocks during boot or runtime PM and cause these clocks to get disabled. Bumping up the prepare/enable count of these critical clocks seemed like the best way to handle this - is there a more preferred way? FWIW, this is also how the Tegra and Rockchip drivers handled this problem.

Ideally clock providers just provide clocks and don't actually call clock consumer APIs. I don't see where these clocks are disabled in this series. Is it just because suspend isn't done right now so there isn't a place to hook the disable part? I hope that it's a 1:1 relation between the clocks that are turned on here and the clocks that are turned off during suspend.

I have a slightly similar problem on my hardware. Consider the case where the bootloader has left on the display and audio clocks and they share a common parent PLL. When the kernel boots up, all it knows is that the display clock and audio clock share a common PLL and the rate they're running at. If the audio driver probes first, calls clk_enable() on the audio clock (almost a no-op except for the fact that we call the .enable op when it's already on) and then calls clk_disable() on the audio clock when it's done we'll also turn off the shared PLL. Unfortunately it's also being used by the display clock for the display driver that hasn't probed yet and so the display stops working and it may show an artifact or black screen.

Other cases are where certain clocks should never be turned off because they're used by some non-linux entity (dram controller for example) and we don't have a place to put the clk_prepare_enable() besides in the clock driver itself. In these cases, it may be better to tell the framework that a clock should always be on. I think this case is what Lee Jones is working on here[1].

Do you fall into one of these two cases? It isn't clear to me how suspend is special and needs to be dealt with differently. Why wouldn't these clocks be always on?

[1] https://lkml.org/lkml/2015/2/27/548

Signature · 7 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw

Re: [PATCH 2/7] clk: Add basic infrastructure for Pistachio clocks

Quoted 36 lines · Stephen Boyd
Quoted 25 lines · Andrew Bresticker
Quoted 16 lines · Stephen Boyd
Quoted 15 lines · Andrew Bresticker
drivers/clk/pistachio/clk.c new file +15 -0
+
+void pistachio_clk_force_enable(struct pistachio_clk_provider *p,
+                             unsigned int *clk_ids, unsigned int num)
+{
+     unsigned int i;
+     int err;
+
+     for (i = 0; i < num; i++) {
+             struct clk *clk = p->clk_data.clks[clk_ids[i]];
+
+             if (IS_ERR(clk))
+                     continue;
+
+             err = clk_prepare_enable(clk);
+             if (err)
Quoted 8 lines

drivers/clk/pistachio/clk.c line 140

Quoted 5 lines
drivers/clk/pistachio/clk.c new file +4 -0
+                     pr_err("Failed to enable clock %s: %d\n",
+                            __clk_get_name(clk), err);
+     }
+}

Is this to workaround some problems in the framework where clocks are turned off? Or is it that these clocks are already on before we boot Linux and we need to make sure the framework knows that?

Quoted 9 lines

It's the former. These clocks are enabled at POR and may only be gated as the final step to entering suspend, so they must remain on at runtime. The issue we were running into was that consumers of these critical clocks or their descendants would enable/disable their clocks during boot or runtime PM and cause these clocks to get disabled. Bumping up the prepare/enable count of these critical clocks seemed like the best way to handle this - is there a more preferred way? FWIW, this is also how the Tegra and Rockchip drivers handled this problem.

Quoted 6 lines

Ideally clock providers just provide clocks and don't actually call clock consumer APIs. I don't see where these clocks are disabled in this series. Is it just because suspend isn't done right now so there isn't a place to hook the disable part? I hope that it's a 1:1 relation between the clocks that are turned on here and the clocks that are turned off during suspend.

Suspend hasn't been hooked up yet and it's still a long ways off.

Quoted 19 lines

I have a slightly similar problem on my hardware. Consider the case where the bootloader has left on the display and audio clocks and they share a common parent PLL. When the kernel boots up, all it knows is that the display clock and audio clock share a common PLL and the rate they're running at. If the audio driver probes first, calls clk_enable() on the audio clock (almost a no-op except for the fact that we call the .enable op when it's already on) and then calls clk_disable() on the audio clock when it's done we'll also turn off the shared PLL. Unfortunately it's also being used by the display clock for the display driver that hasn't probed yet and so the display stops working and it may show an artifact or black screen.

Other cases are where certain clocks should never be turned off because they're used by some non-linux entity (dram controller for example) and we don't have a place to put the clk_prepare_enable() besides in the clock driver itself. In these cases, it may be better to tell the framework that a clock should always be on. I think this case is what Lee Jones is working on here[1].

Quoted 3 lines

Do you fall into one of these two cases? It isn't clear to me how suspend is special and needs to be dealt with differently. Why wouldn't these clocks be always on?

These clocks fall into the latter case in that there's really no good place to put the clk_prepare_enable() calls, so it looks like I want to use what Lee is proposing.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#7 lore raw

Re: [PATCH 2/7] clk: Add basic infrastructure for Pistachio clocks

In reply to Andrew Bresticker

Quoting Andrew Bresticker (2015-03-30 17:15:43)

Quoted 27 lines · Stephen Boyd
Quoted 17 lines · Andrew Bresticker
Quoted 16 lines
drivers/clk/pistachio/clk.c new file +16 -0
+
+void pistachio_clk_force_enable(struct pistachio_clk_provider *p,
+                             unsigned int *clk_ids, unsigned int num)
+{
+     unsigned int i;
+     int err;
+
+     for (i = 0; i < num; i++) {
+             struct clk *clk = p->clk_data.clks[clk_ids[i]];
+
+             if (IS_ERR(clk))
+                     continue;
+
+             err = clk_prepare_enable(clk);
+             if (err)
+                     pr_err("Failed to enable clock %s: %d\n",
Quoted 8 lines

drivers/clk/pistachio/clk.c line 140

Quoted 4 lines
drivers/clk/pistachio/clk.c new file +3 -0
+                            __clk_get_name(clk), err);
+     }
+}

Is this to workaround some problems in the framework where clocks are turned off? Or is it that these clocks are already on before we boot Linux and we need to make sure the framework knows that?

Quoted 9 lines

It's the former. These clocks are enabled at POR and may only be gated as the final step to entering suspend, so they must remain on at runtime. The issue we were running into was that consumers of these critical clocks or their descendants would enable/disable their clocks during boot or runtime PM and cause these clocks to get disabled. Bumping up the prepare/enable count of these critical clocks seemed like the best way to handle this - is there a more preferred way? FWIW, this is also how the Tegra and Rockchip drivers handled this problem.

Hi Andrew,

Why are your drivers allowed to disable clocks which must not be disabled? (you mentioned boot and runtime pm)

Is this the case that a critical clock is not directly disabled, but a parent of that critical clock is and it is gated as a result?

Regards,
Mike

#8 lore raw

Re: [PATCH 2/7] clk: Add basic infrastructure for Pistachio clocks

Hi Mike,

Quoted 38 lines · Michael Turquette

Quoting Andrew Bresticker (2015-03-30 17:15:43)

Quoted 27 lines · Stephen Boyd
Quoted 17 lines · Andrew Bresticker
Quoted 16 lines
drivers/clk/pistachio/clk.c new file +16 -0
+
+void pistachio_clk_force_enable(struct pistachio_clk_provider *p,
+                             unsigned int *clk_ids, unsigned int num)
+{
+     unsigned int i;
+     int err;
+
+     for (i = 0; i < num; i++) {
+             struct clk *clk = p->clk_data.clks[clk_ids[i]];
+
+             if (IS_ERR(clk))
+                     continue;
+
+             err = clk_prepare_enable(clk);
+             if (err)
+                     pr_err("Failed to enable clock %s: %d\n",
Quoted 8 lines

drivers/clk/pistachio/clk.c line 140

Quoted 4 lines
drivers/clk/pistachio/clk.c new file +3 -0
+                            __clk_get_name(clk), err);
+     }
+}

Is this to workaround some problems in the framework where clocks are turned off? Or is it that these clocks are already on before we boot Linux and we need to make sure the framework knows that?

Quoted 9 lines

It's the former. These clocks are enabled at POR and may only be gated as the final step to entering suspend, so they must remain on at runtime. The issue we were running into was that consumers of these critical clocks or their descendants would enable/disable their clocks during boot or runtime PM and cause these clocks to get disabled. Bumping up the prepare/enable count of these critical clocks seemed like the best way to handle this - is there a more preferred way? FWIW, this is also how the Tegra and Rockchip drivers handled this problem.

Quoted 4 lines

Hi Andrew,

Why are your drivers allowed to disable clocks which must not be disabled? (you mentioned boot and runtime pm)

The issue is that they do not directly consume a critical clock, but rather a descendant of the critical clock and thus could cause the critical clock to be disabled. For example, the periph_sys clock is one of these critical clocks and it is the parent of various peripheral clocks, like the watchdog, I2C, PWM, etc. If the I2C driver enables and disables it's clock during probe(), and nothing else has caused the periph_sys clock to be enabled, the disable() call will cause periph_sys to become disabled since its enable count drops to 0.

Now this could be solved if there was a driver to directly consume these clocks and keep them enabled, but, like Stephen mentioned, there really isn't a proper driver for that. So it looks like I want something like the always-on feature Lee is trying to introduce.

Thanks,
Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#9 lore raw

PATCH 3/7 clk: pistachio: Add PLL driver

In reply to Andrew Bresticker

Add a driver for the integer (GF40LP_LAINT) and fractional (GF40LP_FRAC) PLLs present on Pistachio.

---
 drivers/clk/pistachio/Makefile  |   1 +
 drivers/clk/pistachio/clk-pll.c | 401 ++++++++++++++++++++++++++++++++++++++++
 drivers/clk/pistachio/clk.h     |  50 +++++
 3 files changed, 452 insertions(+)
 create mode 100644 drivers/clk/pistachio/clk-pll.c
drivers/clk/pistachio/Makefile +1 -0
index fc216ad..a93490d 100644
@@ -1 +1,2 @@
 obj-y	+= clk.o
+obj-y	+= clk-pll.o
drivers/clk/pistachio/clk-pll.c new file +401 -0

401 lines not on this page · raw message

drivers/clk/pistachio/clk.h +50 -0

62 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#10 lore raw

PATCH 4/7 clk: pistachio: Register core clocks

In reply to Andrew Bresticker

Register the clocks generated by the core clock controller. This includes the 7 PLLs and clocks for the CPU, RPU co-processor, audio, WiFi, bluetooth, and several other peripherals.

The MIPS and PERIPH_SYS clocks must remain enabled at all times.

---
 drivers/clk/pistachio/Makefile        |   1 +
 drivers/clk/pistachio/clk-pistachio.c | 199 ++++++++++++++++++++++++++++++++++
 2 files changed, 200 insertions(+)
 create mode 100644 drivers/clk/pistachio/clk-pistachio.c
drivers/clk/pistachio/Makefile +1 -0
index a93490d..f1e151f 100644
@@ -1,2 +1,3 @@
 obj-y	+= clk.o
 obj-y	+= clk-pll.o
+obj-y	+= clk-pistachio.o
drivers/clk/pistachio/clk-pistachio.c new file +199 -0

199 lines not on this page · raw message

Signature · 1 line
2.2.0.rc0.207.ga3a616c
#11 lore raw

PATCH 5/7 clk: pistachio: Register peripheral clocks

In reply to Andrew Bresticker

Register the clocks generated by the peripheral clock controller. This includes the clocks for several peripherals, including I2C, PWM, watchdog, and timer.

---
 drivers/clk/pistachio/clk-pistachio.c | 67 +++++++++++++++++++++++++++++++++++
 1 file changed, 67 insertions(+)
drivers/clk/pistachio/clk-pistachio.c +67 -0
index 12a45e2..0eabb54 100644
@@ -197,3 +197,70 @@ static void __init pistachio_clk_init(struct device_node *np)
 				   ARRAY_SIZE(pistachio_critical_clks));
 }
 CLK_OF_DECLARE(pistachio_clk, "img,pistachio-clk", pistachio_clk_init);
+
+static struct pistachio_gate pistachio_periph_gates[] __initdata = {
+	GATE(PERIPH_CLK_SYS, "sys", "periph_sys", 0x100, 0),
+	GATE(PERIPH_CLK_SYS_BUS, "bus_sys", "periph_sys", 0x100, 1),
+	GATE(PERIPH_CLK_DDR, "ddr", "periph_sys", 0x100, 2),
+	GATE(PERIPH_CLK_ROM, "rom", "rom_div", 0x100, 3),
+	GATE(PERIPH_CLK_COUNTER_FAST, "counter_fast", "counter_fast_div",
+	     0x100, 4),
+	GATE(PERIPH_CLK_COUNTER_SLOW, "counter_slow", "counter_slow_div",
+	     0x100, 5),
+	GATE(PERIPH_CLK_IR, "ir", "ir_div", 0x100, 6),
+	GATE(PERIPH_CLK_WD, "wd", "wd_div", 0x100, 7),
+	GATE(PERIPH_CLK_PDM, "pdm", "pdm_div", 0x100, 8),
+	GATE(PERIPH_CLK_PWM, "pwm", "pwm_div", 0x100, 9),
+	GATE(PERIPH_CLK_I2C0, "i2c0", "i2c0_div", 0x100, 10),
+	GATE(PERIPH_CLK_I2C1, "i2c1", "i2c1_div", 0x100, 11),
+	GATE(PERIPH_CLK_I2C2, "i2c2", "i2c2_div", 0x100, 12),
+	GATE(PERIPH_CLK_I2C3, "i2c3", "i2c3_div", 0x100, 13),
+};
+
+static struct pistachio_div pistachio_periph_divs[] __initdata = {
+	DIV(PERIPH_CLK_ROM_DIV, "rom_div", "periph_sys", 0x10c, 7),
+	DIV(PERIPH_CLK_COUNTER_FAST_DIV, "counter_fast_div", "periph_sys",
+	    0x110, 7),
+	DIV(PERIPH_CLK_COUNTER_SLOW_PRE_DIV, "counter_slow_pre_div",
+	    "periph_sys", 0x114, 7),
+	DIV(PERIPH_CLK_COUNTER_SLOW_DIV, "counter_slow_div",
+	    "counter_slow_pre_div", 0x118, 7),
+	DIV_F(PERIPH_CLK_IR_PRE_DIV, "ir_pre_div", "periph_sys", 0x11c, 7,
+	      CLK_DIVIDER_ROUND_CLOSEST),
+	DIV_F(PERIPH_CLK_IR_DIV, "ir_div", "ir_pre_div", 0x120, 7,
+	      CLK_DIVIDER_ROUND_CLOSEST),
+	DIV_F(PERIPH_CLK_WD_PRE_DIV, "wd_pre_div", "periph_sys", 0x124, 7,
+	      CLK_DIVIDER_ROUND_CLOSEST),
+	DIV_F(PERIPH_CLK_WD_DIV, "wd_div", "wd_pre_div", 0x128, 7,
+	      CLK_DIVIDER_ROUND_CLOSEST),
+	DIV(PERIPH_CLK_PDM_PRE_DIV, "pdm_pre_div", "periph_sys", 0x12c, 7),
+	DIV(PERIPH_CLK_PDM_DIV, "pdm_div", "pdm_pre_div", 0x130, 7),
+	DIV(PERIPH_CLK_PWM_PRE_DIV, "pwm_pre_div", "periph_sys", 0x134, 7),
+	DIV(PERIPH_CLK_PWM_DIV, "pwm_div", "pwm_pre_div", 0x138, 7),
+	DIV(PERIPH_CLK_I2C0_PRE_DIV, "i2c0_pre_div", "periph_sys", 0x13c, 7),
+	DIV(PERIPH_CLK_I2C0_DIV, "i2c0_div", "i2c0_pre_div", 0x140, 7),
+	DIV(PERIPH_CLK_I2C1_PRE_DIV, "i2c1_pre_div", "periph_sys", 0x144, 7),
+	DIV(PERIPH_CLK_I2C1_DIV, "i2c1_div", "i2c1_pre_div", 0x148, 7),
+	DIV(PERIPH_CLK_I2C2_PRE_DIV, "i2c2_pre_div", "periph_sys", 0x14c, 7),
+	DIV(PERIPH_CLK_I2C2_DIV, "i2c2_div", "i2c2_pre_div", 0x150, 7),
+	DIV(PERIPH_CLK_I2C3_PRE_DIV, "i2c3_pre_div", "periph_sys", 0x154, 7),
+	DIV(PERIPH_CLK_I2C3_DIV, "i2c3_div", "i2c3_pre_div", 0x158, 7),
+};
+
+static void __init pistachio_clk_periph_init(struct device_node *np)
+{
+	struct pistachio_clk_provider *p;
+
+	p = pistachio_clk_alloc_provider(np, PERIPH_CLK_NR_CLKS);
+	if (!p)
+		return;
+
+	pistachio_clk_register_div(p, pistachio_periph_divs,
+				   ARRAY_SIZE(pistachio_periph_divs));
+	pistachio_clk_register_gate(p, pistachio_periph_gates,
+				    ARRAY_SIZE(pistachio_periph_gates));
+
+	pistachio_clk_register_provider(p);
+}
+CLK_OF_DECLARE(pistachio_clk_periph, "img,pistachio-clk-periph",
+	       pistachio_clk_periph_init);
Signature · 6 lines
2.2.0.rc0.207.ga3a616c

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#12 lore raw

PATCH 6/7 clk: pistachio: Register system interface gate clocks

In reply to Andrew Bresticker

Register the system interface gate clocks provided by the peripheral general control block. These clocks gate register access for various peripherals.

---
 drivers/clk/pistachio/clk-pistachio.c | 42 +++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
drivers/clk/pistachio/clk-pistachio.c +42 -0
index 0eabb54..3351808 100644
@@ -264,3 +264,45 @@ static void __init pistachio_clk_periph_init(struct device_node *np)
 }
 CLK_OF_DECLARE(pistachio_clk_periph, "img,pistachio-clk-periph",
 	       pistachio_clk_periph_init);
+
+static struct pistachio_gate pistachio_sys_gates[] __initdata = {
+	GATE(SYS_CLK_I2C0, "i2c0_sys", "sys", 0x8, 0),
+	GATE(SYS_CLK_I2C1, "i2c1_sys", "sys", 0x8, 1),
+	GATE(SYS_CLK_I2C2, "i2c2_sys", "sys", 0x8, 2),
+	GATE(SYS_CLK_I2C3, "i2c3_sys", "sys", 0x8, 3),
+	GATE(SYS_CLK_I2S_IN, "i2s_in_sys", "sys", 0x8, 4),
+	GATE(SYS_CLK_PAUD_OUT, "paud_out_sys", "sys", 0x8, 5),
+	GATE(SYS_CLK_SPDIF_OUT, "spdif_out_sys", "sys", 0x8, 6),
+	GATE(SYS_CLK_SPI0_MASTER, "spi0_master_sys", "sys", 0x8, 7),
+	GATE(SYS_CLK_SPI0_SLAVE, "spi0_slave_sys", "sys", 0x8, 8),
+	GATE(SYS_CLK_PWM, "pwm_sys", "sys", 0x8, 9),
+	GATE(SYS_CLK_UART0, "uart0_sys", "sys", 0x8, 10),
+	GATE(SYS_CLK_UART1, "uart1_sys", "sys", 0x8, 11),
+	GATE(SYS_CLK_SPI1, "spi1_sys", "sys", 0x8, 12),
+	GATE(SYS_CLK_MDC, "mdc_sys", "sys", 0x8, 13),
+	GATE(SYS_CLK_SD_HOST, "sd_host_sys", "sys", 0x8, 14),
+	GATE(SYS_CLK_ENET, "enet_sys", "sys", 0x8, 15),
+	GATE(SYS_CLK_IR, "ir_sys", "sys", 0x8, 16),
+	GATE(SYS_CLK_WD, "wd_sys", "sys", 0x8, 17),
+	GATE(SYS_CLK_TIMER, "timer_sys", "sys", 0x8, 18),
+	GATE(SYS_CLK_I2S_OUT, "i2s_out_sys", "sys", 0x8, 24),
+	GATE(SYS_CLK_SPDIF_IN, "spdif_in_sys", "sys", 0x8, 25),
+	GATE(SYS_CLK_EVENT_TIMER, "event_timer_sys", "sys", 0x8, 26),
+	GATE(SYS_CLK_HASH, "hash_sys", "sys", 0x8, 27),
+};
+
+static void __init pistachio_cr_periph_init(struct device_node *np)
+{
+	struct pistachio_clk_provider *p;
+
+	p = pistachio_clk_alloc_provider(np, SYS_CLK_NR_CLKS);
+	if (!p)
+		return;
+
+	pistachio_clk_register_gate(p, pistachio_sys_gates,
+				    ARRAY_SIZE(pistachio_sys_gates));
+
+	pistachio_clk_register_provider(p);
+}
+CLK_OF_DECLARE(pistachio_cr_periph, "img,pistachio-cr-periph",
+	       pistachio_cr_periph_init);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
#13 lore raw

PATCH 7/7 clk: pistachio: Register external clock gates

In reply to Andrew Bresticker

Register the clock gates for the external audio and ethernet reference clocks provided by the top-level general control block.

---
 drivers/clk/pistachio/clk-pistachio.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/clk/pistachio/clk-pistachio.c +21 -0
index 3351808..8c0fe88 100644
@@ -306,3 +306,24 @@ static void __init pistachio_cr_periph_init(struct device_node *np)
 }
 CLK_OF_DECLARE(pistachio_cr_periph, "img,pistachio-cr-periph",
 	       pistachio_cr_periph_init);
+
+static struct pistachio_gate pistachio_ext_gates[] __initdata = {
+	GATE(EXT_CLK_ENET_IN, "enet_clk_in_gate", "enet_clk_in", 0x58, 5),
+	GATE(EXT_CLK_AUDIO_IN, "audio_clk_in_gate", "audio_clk_in", 0x58, 8)
+};
+
+static void __init pistachio_cr_top_init(struct device_node *np)
+{
+	struct pistachio_clk_provider *p;
+
+	p = pistachio_clk_alloc_provider(np, EXT_CLK_NR_CLKS);
+	if (!p)
+		return;
+
+	pistachio_clk_register_gate(p, pistachio_ext_gates,
+				    ARRAY_SIZE(pistachio_ext_gates));
+
+	pistachio_clk_register_provider(p);
+}
+CLK_OF_DECLARE(pistachio_cr_top, "img,pistachio-cr-top",
+	       pistachio_cr_top_init);
Signature · 1 line
2.2.0.rc0.207.ga3a616c
Acked-by on the v1 series
#14 lore raw
In reply to Andrew Bresticker
Quoted 7 lines · Andrew Bresticker

This series adds common clock support for the IMG Pistachio SoC. Pistachio has two clock controllers (core and peripheral) and two general control blocks (peripheral and top) which also contain several clock gates. Like the recently submitted pinctrl driver [1], this driver is written so that it's hopefully easy to add support for future IMG SoCs.

Quoted 7 lines

Tested on an IMG Pistachio BuB. Based on 4.0-rc1 + my series adding Pistachio platform support [2], which introduces the MACH_PISTACHIO Kconfig symbol. A branch with this series and the dependent patches is available at [3]. I'd like this to go through the MIPS tree with Mike's or Stephen's ACK if possible.

Minor comment on patch 2, but otherwise

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project