Skip to contentSkip to conversation

clk: Samsung: audss: Register audio subsytem clocks using common clk framework

PATCH Superseded Padmavathi Venna 5 participants 10 messages May 7, 2013 – May 11, 2013

Subsystems (4)

v2 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v2 cover clk: Samsung: audss: Register audio subsytem clocks using common clk framework

Samsung S5PV210 and Exynos SoC has a separate subsystem for audio. This subsystem has a internal clock controller which controls i2s0 and pcm0 clocks. This patch series adds the Samsung audio subsytem clock to the common clock framework and provides the I2S controllers clock information in the dtsi file.

This patch series is dependent on
https://patchwork.kernel.org/patch/2532091/
http://www.spinics.net/lists/linux-kbuild/msg07616.html

This patch series is made based on Kukjin Kim for-next branch

Changes since V1:
- Reworked on all review comments by Sylwester Nawrocki
- Added a header file for all clock indexes as requested by Sylwester
- Added different compatible names for s5pv210, exynos4 and exynos5
- Registered the pcm clocks with common clock framework

Padmavathi Venna (3):
clk: samsung: register audio subsystem clocks using common clock
framework
ARM: dts: add Exynos audio subsystem clock controller node
ARM: dts: add clock provider information for i2s controllers in

    Exynos5250
 .../bindings/clock/clk-samsung-audss.txt           |   64 +++++++++
 arch/arm/boot/dts/exynos5250.dtsi                  |   16 +++
 drivers/clk/samsung/Makefile                       |    1 +
 drivers/clk/samsung/clk-samsung-audss.c            |  137 ++++++++++++++++++++
 include/dt-bindings/clk/samsung-audss-clk.h        |   25 ++++
 5 files changed, 243 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/clk-samsung-audss.txt
 create mode 100644 drivers/clk/samsung/clk-samsung-audss.c
 create mode 100644 include/dt-bindings/clk/samsung-audss-clk.h
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH v2 1/3 clk: samsung: register audio subsystem clocks using common clock framework

Audio subsystem is introduced in s5pv210 and exynos platforms. This has seperate clock controller which can control i2s0 and pcm0 clocks. This patch registers the audio subsystem clocks with the common clock framework.

---
 .../bindings/clock/clk-samsung-audss.txt           |   64 +++++++++
 drivers/clk/samsung/Makefile                       |    1 +
 drivers/clk/samsung/clk-samsung-audss.c            |  137 ++++++++++++++++++++
 include/dt-bindings/clk/samsung-audss-clk.h        |   25 ++++
 4 files changed, 227 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/clk-samsung-audss.txt
 create mode 100644 drivers/clk/samsung/clk-samsung-audss.c
 create mode 100644 include/dt-bindings/clk/samsung-audss-clk.h
Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +64 -0
new file mode 100644
index 0000000..ec2cd0b
@@ -0,0 +1,64 @@
+* Samsung Audio Subsystem Clock Controller
+
+The Samsung Audio Subsystem clock controller generates and supplies clocks
+to Audio Subsystem block available in the S5PV210 and Exynos SoCs. The clock
+binding described here is applicable to all SoC's in the S5PV210 and Exynos
+family.
+
+Required Properties:
+
+- compatible: should be one of the following:
+  - "samsung,s5pv210-audss-clock" - controller compatible with all S5PV210 SoCs.
+  - "samsung,exynos4210-audss-clock" - controller compatible with all Exynos4 SoCs.
+  - "samsung,exynos5250-audss-clock" - controller compatible with all Exynos5 SoCs.
+
+- reg: physical base address and length of the controller's register set.
+
+- #clock-cells: should be 1.
+
+The following is the list of clocks generated by the controller. Each clock is
+assigned an identifier and client nodes use this identifier to specify the
+clock which they consume. Some of the clocks are available only on a particular
+Exynos4 SoC and this is specified where applicable.
+
+Provided clocks:
+
+Clock           ID      SoC (if specific)
+-----------------------------------------------
+
+mout_audss      0
+mout_i2s        1
+dout_srp        2
+dout_bus        3
+dout_i2s        4
+srp_clk         5
+i2s_bus         6
+sclk_i2s        7
+pcm_bus         8
+sclk_pcm        9
+
+Example 1: An example of a clock controller node is listed below.
+
+clock_audss: audss-clock-controller@03810000 {
+	compatible = "samsung,exynos5250-audss-clock";
+	reg = <0x03810000 0x0C>;
+	#clock-cells = <1>;
+};
+
+Example 2: I2S controller node that consumes the clock generated by the clock
+           controller. Refer to the standard clock bindings for information
+           about 'clocks' and 'clock-names' property.
+
+ i2s0: i2s@03830000 {
+		compatible = "samsung,i2s-v5";
+		reg = <0x03830000 0x100>;
+		dmas = <&pdma0 10
+			&pdma0 9
+			&pdma0 8>;
+		dma-names = "tx", "rx", "tx-sec";
+		clocks = <&clock_audss SAMSUNG_I2S_BUS>,
+			<&clock_audss SAMSUNG_I2S_BUS>,
+			<&clock_audss SAMSUNG_SCLK_I2S>;
+		clock-names = "iis", "i2s_opclk0", "i2s_opclk1";
+};
+
drivers/clk/samsung/Makefile +1 -0
index b7c232e..5425fa8 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_COMMON_CLK)	+= clk.o clk-pll.o
 obj-$(CONFIG_ARCH_EXYNOS4)	+= clk-exynos4.o
 obj-$(CONFIG_SOC_EXYNOS5250)	+= clk-exynos5250.o
 obj-$(CONFIG_SOC_EXYNOS5440)	+= clk-exynos5440.o
+obj-$(CONFIG_PLAT_SAMSUNG)	+= clk-samsung-audss.o
drivers/clk/samsung/clk-samsung-audss.c new file +137 -0

137 lines not on this page · raw message

include/dt-bindings/clk/samsung-audss-clk.h new file +25 -0
new file mode 100644
index 0000000..d335555
@@ -0,0 +1,25 @@
+/*
+ * This header provides constants for Samsung audio subsystem
+ * clock controller.
+ *
+ * The constants defined in this header are being used in dts
+ * and samsung audss driver.
+ */
+
+#ifndef _DT_BINDINGS_CLK_SAMSUNG_AUDSS_H
+#define _DT_BINDINGS_CLK_SAMSUNG_AUDSS_H
+
+#define SAMSUNG_MOUT_AUDSS	0
+#define SAMSUNG_MOUT_I2S	1
+#define SAMSUNG_DOUT_SRP	2
+#define SAMSUNG_DOUT_BUS	3
+#define SAMSUNG_DOUT_I2S	4
+#define SAMSUNG_SRP_CLK		5
+#define SAMSUNG_I2S_BUS		6
+#define SAMSUNG_SCLK_I2S	7
+#define SAMSUNG_PCM_BUS		8
+#define SAMSUNG_SCLK_PCM	9
+
+#define SAMSUNG_AUDSS_MAX_CLKS	10
+
+#endif
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH v2 1/3 clk: samsung: register audio subsystem clocks using common clock framework

Hi Padmavathi,

I managed to review the patch a bit more thoroughly and I had few more comments. You can find them inline.

Quoted 171 lines · On Tuesday 07 of May 2013 12:13:34 Padmavathi Venna wrote:

Audio subsystem is introduced in s5pv210 and exynos platforms. This has seperate clock controller which can control i2s0 and pcm0 clocks. This patch registers the audio subsystem clocks with the common clock framework.

---
 .../bindings/clock/clk-samsung-audss.txt           |   64 +++++++++
 drivers/clk/samsung/Makefile                       |    1 +
 drivers/clk/samsung/clk-samsung-audss.c            |  137
++++++++++++++++++++ include/dt-bindings/clk/samsung-audss-clk.h       
|   25 ++++ 4 files changed, 227 insertions(+), 0 deletions(-)
 create mode 100644
Documentation/devicetree/bindings/clock/clk-samsung-audss.txt create
mode 100644 drivers/clk/samsung/clk-samsung-audss.c
 create mode 100644 include/dt-bindings/clk/samsung-audss-clk.h

diff --git a/Documentation/devicetree/bindings/clock/clk-samsung-audss.txt b/Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file mode 100644
index 0000000..ec2cd0b

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +3 -0
@@ -0,0 +1,64 @@
+* Samsung Audio Subsystem Clock Controller
+
+The Samsung Audio Subsystem clock controller generates and supplies

clocks +to Audio Subsystem block available in the S5PV210 and Exynos SoCs. The clock +binding described here is applicable to all SoC's in the S5PV210 and Exynos +family.

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +5 -0
+
+Required Properties:
+
+- compatible: should be one of the following:
+  - "samsung,s5pv210-audss-clock" - controller compatible with all

S5PV210 SoCs. + - "samsung,exynos4210-audss-clock" - controller compatible with all Exynos4 SoCs. + - "samsung,exynos5250-audss-clock"
- controller compatible with all Exynos5 SoCs. +
+- reg: physical base address and length of the controller's register set. +
+- #clock-cells: should be 1.

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +2 -0
+
+The following is the list of clocks generated by the controller. Each

clock is +assigned an identifier and client nodes use this identifier to specify the +clock which they consume. Some of the clocks are available only on a particular +Exynos4 SoC and this is specified where applicable.

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +26 -0
+
+Provided clocks:
+
+Clock           ID      SoC (if specific)
+-----------------------------------------------
+
+mout_audss      0
+mout_i2s        1
+dout_srp        2
+dout_bus        3
+dout_i2s        4
+srp_clk         5
+i2s_bus         6
+sclk_i2s        7
+pcm_bus         8
+sclk_pcm        9
+
+Example 1: An example of a clock controller node is listed below.
+
+clock_audss: audss-clock-controller at 03810000 {
+	compatible = "samsung,exynos5250-audss-clock";
+	reg = <0x03810000 0x0C>;
+	#clock-cells = <1>;
+};
+
+Example 2: I2S controller node that consumes the clock generated by the

clock + controller. Refer to the standard clock bindings for
information + about 'clocks' and 'clock-names' property.

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +14 -0
+
+ i2s0: i2s at 03830000 {
+		compatible = "samsung,i2s-v5";
+		reg = <0x03830000 0x100>;
+		dmas = <&pdma0 10
+			&pdma0 9
+			&pdma0 8>;
+		dma-names = "tx", "rx", "tx-sec";
+		clocks = <&clock_audss SAMSUNG_I2S_BUS>,
+			<&clock_audss SAMSUNG_I2S_BUS>,
+			<&clock_audss SAMSUNG_SCLK_I2S>;
+		clock-names = "iis", "i2s_opclk0", "i2s_opclk1";
+};
+
drivers/clk/samsung/Makefile +1 -0
index b7c232e..5425fa8 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_COMMON_CLK)	+= clk.o clk-pll.o
 obj-$(CONFIG_ARCH_EXYNOS4)	+= clk-exynos4.o
 obj-$(CONFIG_SOC_EXYNOS5250)	+= clk-exynos5250.o
 obj-$(CONFIG_SOC_EXYNOS5440)	+= clk-exynos5440.o
+obj-$(CONFIG_PLAT_SAMSUNG)	+= clk-samsung-audss.o
(quoted diff) +0 -0

b/drivers/clk/samsung/clk-samsung-audss.c new file mode 100644 index 0000000..97526b7

drivers/clk/samsung/clk-samsung-audss.c new file +6 -0
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * Author: Padmavathi Venna <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as +

* published by the Free Software Foundation.
+ *
+ * Common Clock Framework support for Audio Subsystem Clock Controller.

drivers/clk/samsung/clk-samsung-audss.c new file +28 -0
+*/
+
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>
+#include <linux/syscore_ops.h>
+
+#include <dt-bindings/clk/samsung-audss-clk.h>
+
+static DEFINE_SPINLOCK(lock);
+static struct clk **clk_table;
+static void __iomem *reg_base;
+static struct clk_onecell_data clk_data;
+
+#define ASS_CLK_SRC 0x0
+#define ASS_CLK_DIV 0x4
+#define ASS_CLK_GATE 0x8
+
+static unsigned long reg_save[][2] = {
+	{ASS_CLK_SRC,  0},
+	{ASS_CLK_DIV,  0},
+	{ASS_CLK_GATE, 0},
+};
+
+/* list of all parent clock list */
+static const char *mout_audss_p[] = { "fin_pll", "fout_epll" };
+static const char *mout_i2s_p[] = { "mout_audss", "cdclk0",

"sclk_audio0" }; +

drivers/clk/samsung/clk-samsung-audss.c new file +28 -0
+#ifdef CONFIG_PM_SLEEP
+static int samsung_audss_clk_suspend(void)
+{
+	int i;
+
+	for (i = 0; i < 3; i++)
+		reg_save[i][1] = readl(reg_base + reg_save[i][0]);
+
+	return 0;
+}
+
+static void samsung_audss_clk_resume(void)
+{
+	int i;
+
+	for (i = 0; i < 3; i++)
+		writel(reg_save[i][1], reg_base + reg_save[i][0]);
+}
+
+static struct syscore_ops samsung_audss_clk_syscore_ops = {
+	.suspend	= samsung_audss_clk_suspend,
+	.resume		= samsung_audss_clk_resume,
+};
+#endif /* CONFIG_PM_SLEEP */
+
+/* register samsung_audss clocks */
+void __init samsung_audss_clk_init(struct device_node *np)
+{

drivers/clk/samsung/clk-samsung-audss.c

Quoted 10 lines
drivers/clk/samsung/clk-samsung-audss.c new file +10 -0
+	reg_base = of_iomap(np, 0);
+	if (!reg_base) {
+		pr_err("%s: failed to map audss registers\n", __func__);
+		return;
+	}
+
+	clk_table = kzalloc(sizeof(struct clk *) * SAMSUNG_AUDSS_MAX_CLKS,
+				GFP_KERNEL);
+	if (!clk_table) {
+		pr_err("%s: could not allocate clock lookup table\n", 

__func__);

drivers/clk/samsung/clk-samsung-audss.c

Quoted 8 lines
drivers/clk/samsung/clk-samsung-audss.c new file +8 -0
+		return;
+	}
+
+	clk_data.clks = clk_table;
+	clk_data.clk_num = SAMSUNG_AUDSS_MAX_CLKS;
+	of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
+
+	clk_table[SAMSUNG_MOUT_AUDSS] = clk_register_mux(NULL, 

"mout_audss",

Quoted 4 lines
drivers/clk/samsung/clk-samsung-audss.c new file +3 -0
+				mout_audss_p, ARRAY_SIZE(mout_audss_p), 0,
+				reg_base + ASS_CLK_SRC, 0, 1, 0, &lock);
+	clk_register_clkdev(clk_table[SAMSUNG_MOUT_AUDSS], "mout_audss",

NULL); +

Is there are a reason for this clkdev lookup to be registered?

This driver seems to be used only in DT-case, so DT-based lookup should be enough.

drivers/clk/samsung/clk-samsung-audss.c

Quoted 4 lines
drivers/clk/samsung/clk-samsung-audss.c new file +4 -0
+	clk_table[SAMSUNG_MOUT_I2S] = clk_register_mux(NULL, "mout_i2s",
+				mout_i2s_p, ARRAY_SIZE(mout_i2s_p), 0,
+				reg_base + ASS_CLK_SRC, 2, 2, 0, &lock);
+	clk_register_clkdev(clk_table[SAMSUNG_MOUT_I2S], "mout_i2s", 

NULL);

Same here.

drivers/clk/samsung/clk-samsung-audss.c

Quoted 2 lines
drivers/clk/samsung/clk-samsung-audss.c new file +2 -0
+
+	clk_table[SAMSUNG_DOUT_SRP] = clk_register_divider(NULL, 

"dout_srp",

drivers/clk/samsung/clk-samsung-audss.c

Quoted 1 line
drivers/clk/samsung/clk-samsung-audss.c new file +1 -0
+				"mout_audss", 0, reg_base + ASS_CLK_DIV, 

0, 4,

drivers/clk/samsung/clk-samsung-audss.c

Quoted 3 lines
drivers/clk/samsung/clk-samsung-audss.c new file +3 -0
+				0, &lock);
+
+	clk_table[SAMSUNG_DOUT_BUS] = clk_register_divider(NULL, 

"dout_bus",

drivers/clk/samsung/clk-samsung-audss.c

Quoted 1 line
drivers/clk/samsung/clk-samsung-audss.c new file +1 -0
+				"dout_srp", 0, reg_base + ASS_CLK_DIV, 4, 

4, 0,

drivers/clk/samsung/clk-samsung-audss.c

Quoted 3 lines
drivers/clk/samsung/clk-samsung-audss.c new file +3 -0
+				&lock);
+
+	clk_table[SAMSUNG_DOUT_I2S] = clk_register_divider(NULL, 

"dout_i2s",

drivers/clk/samsung/clk-samsung-audss.c

Quoted 1 line
drivers/clk/samsung/clk-samsung-audss.c new file +1 -0
+				"mout_i2s", 0, reg_base + ASS_CLK_DIV, 8, 

4, 0,

Quoted 20 lines
drivers/clk/samsung/clk-samsung-audss.c new file +20 -0
+				&lock);
+
+	clk_table[SAMSUNG_SRP_CLK] = clk_register_gate(NULL, "srp_clk",
+				"dout_srp", CLK_SET_RATE_PARENT,
+				reg_base + ASS_CLK_GATE, 0, 0, &lock);
+
+	clk_table[SAMSUNG_I2S_BUS] = clk_register_gate(NULL, "i2s_bus",
+				"dout_bus", CLK_SET_RATE_PARENT,
+				reg_base + ASS_CLK_GATE, 2, 0, &lock);
+
+	clk_table[SAMSUNG_SCLK_I2S] = clk_register_gate(NULL, "sclk_i2s",
+				"dout_i2s", CLK_SET_RATE_PARENT,
+				reg_base + ASS_CLK_GATE, 3, 0, &lock);
+
+	clk_table[SAMSUNG_PCM_BUS] = clk_register_gate(NULL, "pcm_bus",
+				 "sclk_pcm", CLK_SET_RATE_PARENT,
+				reg_base + ASS_CLK_GATE, 4, 0, &lock);
+
+	clk_table[SAMSUNG_SCLK_PCM] = clk_register_gate(NULL, "sclk_pcm",
+				"div_pcm0", CLK_SET_RATE_PARENT,

drivers/clk/samsung/clk-samsung-audss.c line 133

Quoted 10 lines
drivers/clk/samsung/clk-samsung-audss.c new file +10 -0
+				reg_base + ASS_CLK_GATE, 5, 0, &lock);
+
+#ifdef CONFIG_PM_SLEEP
+	register_syscore_ops(&samsung_audss_clk_syscore_ops);
+#endif
+
+	pr_info("Exynos: Audss: clock setup completed\n");
+}
+CLK_OF_DECLARE(s5pv210_audss_clk, "samsung,s5pv210-audss-clock",
+		samsung_audss_clk_init);

I'm wondering if this driver in its current state is really compatible with S5PV210. Quick look at documentation shows that CLK_GATE and CLK_DIV registers on this SoC have different layout than on Exynos SoCs.

I guess that for now the best choice would be to remove any mentions about S5PV210 from the patch and add them back after the driver gets proper support for this SoC.

drivers/clk/samsung/clk-samsung-audss.c line 137

Quoted 4 lines
drivers/clk/samsung/clk-samsung-audss.c new file +4 -0
+CLK_OF_DECLARE(exynos4210_audss_clk, "samsung,exynos4210-audss-clock",
+		samsung_audss_clk_init);
+CLK_OF_DECLARE(exynos5250_audss_clk, "samsung,exynos5250-audss-clock",
+		samsung_audss_clk_init);

Also if both Exynos4210 and Exynos5250 have exactly the same audss clock layout, there is no reason to have two compatibles for them - the convention is that just the first model that had this hardware is enough - in this case Exynos4210.

Having two different compatibles suggests that those two SoCs differ in a way that needs special handling, which is misleading, based on the fact that there is no such special handling in the driver.

Best regards,
Tomasz

#3 lore raw

PATCH v2 1/3 clk: samsung: register audio subsystem clocks using common clock framework

Hi Tomasz,

Quoted 4 lines · Tomasz Figa

Hi Padmavathi,

I managed to review the patch a bit more thoroughly and I had few more comments. You can find them inline.

Thanks for the review.

Quoted 198 lines · On Tuesday 07 of May 2013 12:13:34 Padmavathi Venna wrote:
Quoted 171 lines

Audio subsystem is introduced in s5pv210 and exynos platforms. This has seperate clock controller which can control i2s0 and pcm0 clocks. This patch registers the audio subsystem clocks with the common clock framework.

---
 .../bindings/clock/clk-samsung-audss.txt           |   64 +++++++++
 drivers/clk/samsung/Makefile                       |    1 +
 drivers/clk/samsung/clk-samsung-audss.c            |  137
++++++++++++++++++++ include/dt-bindings/clk/samsung-audss-clk.h
|   25 ++++ 4 files changed, 227 insertions(+), 0 deletions(-)
 create mode 100644
Documentation/devicetree/bindings/clock/clk-samsung-audss.txt create
mode 100644 drivers/clk/samsung/clk-samsung-audss.c
 create mode 100644 include/dt-bindings/clk/samsung-audss-clk.h

diff --git a/Documentation/devicetree/bindings/clock/clk-samsung-audss.txt b/Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file mode 100644
index 0000000..ec2cd0b

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +3 -0
@@ -0,0 +1,64 @@
+* Samsung Audio Subsystem Clock Controller
+
+The Samsung Audio Subsystem clock controller generates and supplies

clocks +to Audio Subsystem block available in the S5PV210 and Exynos SoCs. The clock +binding described here is applicable to all SoC's in the S5PV210 and Exynos +family.

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +5 -0
+
+Required Properties:
+
+- compatible: should be one of the following:
+  - "samsung,s5pv210-audss-clock" - controller compatible with all

S5PV210 SoCs. + - "samsung,exynos4210-audss-clock" - controller compatible with all Exynos4 SoCs. + - "samsung,exynos5250-audss-clock"
- controller compatible with all Exynos5 SoCs. +
+- reg: physical base address and length of the controller's register set. +
+- #clock-cells: should be 1.

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +2 -0
+
+The following is the list of clocks generated by the controller. Each

clock is +assigned an identifier and client nodes use this identifier to specify the +clock which they consume. Some of the clocks are available only on a particular +Exynos4 SoC and this is specified where applicable.

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +26 -0
+
+Provided clocks:
+
+Clock           ID      SoC (if specific)
+-----------------------------------------------
+
+mout_audss      0
+mout_i2s        1
+dout_srp        2
+dout_bus        3
+dout_i2s        4
+srp_clk         5
+i2s_bus         6
+sclk_i2s        7
+pcm_bus         8
+sclk_pcm        9
+
+Example 1: An example of a clock controller node is listed below.
+
+clock_audss: audss-clock-controller at 03810000 {
+     compatible = "samsung,exynos5250-audss-clock";
+     reg = <0x03810000 0x0C>;
+     #clock-cells = <1>;
+};
+
+Example 2: I2S controller node that consumes the clock generated by the

clock + controller. Refer to the standard clock bindings for
information + about 'clocks' and 'clock-names' property.

Documentation/devicetree/bindings/clock/clk-samsung-audss.txt new file +14 -0
+
+ i2s0: i2s at 03830000 {
+             compatible = "samsung,i2s-v5";
+             reg = <0x03830000 0x100>;
+             dmas = <&pdma0 10
+                     &pdma0 9
+                     &pdma0 8>;
+             dma-names = "tx", "rx", "tx-sec";
+             clocks = <&clock_audss SAMSUNG_I2S_BUS>,
+                     <&clock_audss SAMSUNG_I2S_BUS>,
+                     <&clock_audss SAMSUNG_SCLK_I2S>;
+             clock-names = "iis", "i2s_opclk0", "i2s_opclk1";
+};
+
drivers/clk/samsung/Makefile +1 -0
index b7c232e..5425fa8 100644
@@ -6,3 +6,4 @@ obj-$(CONFIG_COMMON_CLK)      += clk.o clk-pll.o
 obj-$(CONFIG_ARCH_EXYNOS4)   += clk-exynos4.o
 obj-$(CONFIG_SOC_EXYNOS5250) += clk-exynos5250.o
 obj-$(CONFIG_SOC_EXYNOS5440) += clk-exynos5440.o
+obj-$(CONFIG_PLAT_SAMSUNG)   += clk-samsung-audss.o
(quoted diff) +0 -0

b/drivers/clk/samsung/clk-samsung-audss.c new file mode 100644 index 0000000..97526b7

drivers/clk/samsung/clk-samsung-audss.c new file +6 -0
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ * Author: Padmavathi Venna <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as +

* published by the Free Software Foundation.
+ *
+ * Common Clock Framework support for Audio Subsystem Clock Controller.

drivers/clk/samsung/clk-samsung-audss.c new file +28 -0
+*/
+
+#include <linux/clkdev.h>
+#include <linux/io.h>
+#include <linux/clk-provider.h>
+#include <linux/of_address.h>
+#include <linux/syscore_ops.h>
+
+#include <dt-bindings/clk/samsung-audss-clk.h>
+
+static DEFINE_SPINLOCK(lock);
+static struct clk **clk_table;
+static void __iomem *reg_base;
+static struct clk_onecell_data clk_data;
+
+#define ASS_CLK_SRC 0x0
+#define ASS_CLK_DIV 0x4
+#define ASS_CLK_GATE 0x8
+
+static unsigned long reg_save[][2] = {
+     {ASS_CLK_SRC,  0},
+     {ASS_CLK_DIV,  0},
+     {ASS_CLK_GATE, 0},
+};
+
+/* list of all parent clock list */
+static const char *mout_audss_p[] = { "fin_pll", "fout_epll" };
+static const char *mout_i2s_p[] = { "mout_audss", "cdclk0",

"sclk_audio0" }; +

drivers/clk/samsung/clk-samsung-audss.c new file +28 -0
+#ifdef CONFIG_PM_SLEEP
+static int samsung_audss_clk_suspend(void)
+{
+     int i;
+
+     for (i = 0; i < 3; i++)
+             reg_save[i][1] = readl(reg_base + reg_save[i][0]);
+
+     return 0;
+}
+
+static void samsung_audss_clk_resume(void)
+{
+     int i;
+
+     for (i = 0; i < 3; i++)
+             writel(reg_save[i][1], reg_base + reg_save[i][0]);
+}
+
+static struct syscore_ops samsung_audss_clk_syscore_ops = {
+     .suspend        = samsung_audss_clk_suspend,
+     .resume         = samsung_audss_clk_resume,
+};
+#endif /* CONFIG_PM_SLEEP */
+
+/* register samsung_audss clocks */
+void __init samsung_audss_clk_init(struct device_node *np)
+{

drivers/clk/samsung/clk-samsung-audss.c

Quoted 10 lines
drivers/clk/samsung/clk-samsung-audss.c new file +10 -0
+     reg_base = of_iomap(np, 0);
+     if (!reg_base) {
+             pr_err("%s: failed to map audss registers\n", __func__);
+             return;
+     }
+
+     clk_table = kzalloc(sizeof(struct clk *) * SAMSUNG_AUDSS_MAX_CLKS,
+                             GFP_KERNEL);
+     if (!clk_table) {
+             pr_err("%s: could not allocate clock lookup table\n",

__func__);

drivers/clk/samsung/clk-samsung-audss.c

Quoted 8 lines
drivers/clk/samsung/clk-samsung-audss.c new file +8 -0
+             return;
+     }
+
+     clk_data.clks = clk_table;
+     clk_data.clk_num = SAMSUNG_AUDSS_MAX_CLKS;
+     of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
+
+     clk_table[SAMSUNG_MOUT_AUDSS] = clk_register_mux(NULL,

"mout_audss",

Quoted 4 lines
drivers/clk/samsung/clk-samsung-audss.c new file +3 -0
+                             mout_audss_p, ARRAY_SIZE(mout_audss_p), 0,
+                             reg_base + ASS_CLK_SRC, 0, 1, 0, &lock);
+     clk_register_clkdev(clk_table[SAMSUNG_MOUT_AUDSS], "mout_audss",

NULL); +

Quoted 4 lines

Is there are a reason for this clkdev lookup to be registered?

This driver seems to be used only in DT-case, so DT-based lookup should be enough.

Ok. I will not register these clocks with clkdev. I will add as clock entries into i2s0 node.

Quoted 52 lines

drivers/clk/samsung/clk-samsung-audss.c

Quoted 5 lines
drivers/clk/samsung/clk-samsung-audss.c new file +4 -0
+     clk_table[SAMSUNG_MOUT_I2S] = clk_register_mux(NULL, "mout_i2s",
+                             mout_i2s_p, ARRAY_SIZE(mout_i2s_p), 0,
+                             reg_base + ASS_CLK_SRC, 2, 2, 0, &lock);
+     clk_register_clkdev(clk_table[SAMSUNG_MOUT_I2S], "mout_i2s",

NULL);

Same here.

drivers/clk/samsung/clk-samsung-audss.c

Quoted 2 lines
drivers/clk/samsung/clk-samsung-audss.c new file +2 -0
+
+     clk_table[SAMSUNG_DOUT_SRP] = clk_register_divider(NULL,

"dout_srp",

Quoted 1 line

+ "mout_audss", 0, reg_base + ASS_CLK_DIV,

0, 4,

drivers/clk/samsung/clk-samsung-audss.c

Quoted 3 lines
drivers/clk/samsung/clk-samsung-audss.c new file +3 -0
+                             0, &lock);
+
+     clk_table[SAMSUNG_DOUT_BUS] = clk_register_divider(NULL,

"dout_bus",

Quoted 1 line

+ "dout_srp", 0, reg_base + ASS_CLK_DIV, 4,

4, 0,

drivers/clk/samsung/clk-samsung-audss.c

Quoted 3 lines
drivers/clk/samsung/clk-samsung-audss.c new file +3 -0
+                             &lock);
+
+     clk_table[SAMSUNG_DOUT_I2S] = clk_register_divider(NULL,

"dout_i2s",

Quoted 1 line

+ "mout_i2s", 0, reg_base + ASS_CLK_DIV, 8,

4, 0,

Quoted 26 lines
drivers/clk/samsung/clk-samsung-audss.c new file +26 -0
+                             &lock);
+
+     clk_table[SAMSUNG_SRP_CLK] = clk_register_gate(NULL, "srp_clk",
+                             "dout_srp", CLK_SET_RATE_PARENT,
+                             reg_base + ASS_CLK_GATE, 0, 0, &lock);
+
+     clk_table[SAMSUNG_I2S_BUS] = clk_register_gate(NULL, "i2s_bus",
+                             "dout_bus", CLK_SET_RATE_PARENT,
+                             reg_base + ASS_CLK_GATE, 2, 0, &lock);
+
+     clk_table[SAMSUNG_SCLK_I2S] = clk_register_gate(NULL, "sclk_i2s",
+                             "dout_i2s", CLK_SET_RATE_PARENT,
+                             reg_base + ASS_CLK_GATE, 3, 0, &lock);
+
+     clk_table[SAMSUNG_PCM_BUS] = clk_register_gate(NULL, "pcm_bus",
+                              "sclk_pcm", CLK_SET_RATE_PARENT,
+                             reg_base + ASS_CLK_GATE, 4, 0, &lock);
+
+     clk_table[SAMSUNG_SCLK_PCM] = clk_register_gate(NULL, "sclk_pcm",
+                             "div_pcm0", CLK_SET_RATE_PARENT,
+                             reg_base + ASS_CLK_GATE, 5, 0, &lock);
+
+#ifdef CONFIG_PM_SLEEP
+     register_syscore_ops(&samsung_audss_clk_syscore_ops);
+#endif
+
Quoted 8 lines

drivers/clk/samsung/clk-samsung-audss.c line 133

Quoted 4 lines
drivers/clk/samsung/clk-samsung-audss.c new file +4 -0
+     pr_info("Exynos: Audss: clock setup completed\n");
+}
+CLK_OF_DECLARE(s5pv210_audss_clk, "samsung,s5pv210-audss-clock",
+             samsung_audss_clk_init);

I'm wondering if this driver in its current state is really compatible with S5PV210. Quick look at documentation shows that CLK_GATE and CLK_DIV registers on this SoC have different layout than on Exynos SoCs.

Yes. There are some differences. As of now I will remove v210.

Quoted 15 lines

I guess that for now the best choice would be to remove any mentions about S5PV210 from the patch and add them back after the driver gets proper support for this SoC.

drivers/clk/samsung/clk-samsung-audss.c line 137

Quoted 4 lines
drivers/clk/samsung/clk-samsung-audss.c new file +4 -0
+CLK_OF_DECLARE(exynos4210_audss_clk, "samsung,exynos4210-audss-clock",
+             samsung_audss_clk_init);
+CLK_OF_DECLARE(exynos5250_audss_clk, "samsung,exynos5250-audss-clock",
+             samsung_audss_clk_init);

Also if both Exynos4210 and Exynos5250 have exactly the same audss clock layout, there is no reason to have two compatibles for them - the convention is that just the first model that had this hardware is enough - in this case Exynos4210.

Quoted 3 lines

Having two different compatibles suggests that those two SoCs differ in a way that needs special handling, which is misleading, based on the fact that there is no such special handling in the driver.

There is only one difference between Exynos4 and Exynos5 is bit 1 of CLK_GATE register where in Exynos5 it is reserved and Exynos4 it is gate to IntMEM. I am not sure if we use this bit some where? So is it okey to have same compatible with this diff?

I will post next version of patches after the dependencies are merged into mainline(dtc+cpp patches by Stephen).

Quoted 4 lines

Best regards,
Tomasz

Thanks
Padma

#4 lore raw

PATCH v2 1/3 clk: samsung: register audio subsystem clocks using common clock framework

Hi,

Quoted 10 lines · Padma Venkat
Quoted 10 lines
Quoted 10 lines

+CLK_OF_DECLARE(exynos4210_audss_clk, "samsung,exynos4210-audss-clock",

Quoted 3 lines
Quoted 3 lines

+ samsung_audss_clk_init);
+CLK_OF_DECLARE(exynos5250_audss_clk, "samsung,exynos5250-audss-clock",
+ samsung_audss_clk_init);

Also if both Exynos4210 and Exynos5250 have exactly the same audss clock layout, there is no reason to have two compatibles for them - the convention is that just the first model that had this hardware is enough - in this case Exynos4210.

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Having two different compatibles suggests that those two SoCs differ in a way that needs special handling, which is misleading, based on the fact that there is no such special handling in the driver.

There is only one difference between Exynos4 and Exynos5 is bit 1 of CLK_GATE register where in Exynos5 it is reserved and Exynos4 it is gate to IntMEM. I am not sure if we use this bit some where? So is it okey to have same compatible with this diff?

I think such difference warrants separate compatible properties, as Exynos5250
seems to be not compatible with Exynos4210 in that case. Reserved bits should
be left untouched.

I wouldn't be surprised to see more differences we might be overlooking now.
IMHO it's better to be save than sorry, keeping both 'compatible' strings as
they are now.

Regards,
Sylwester

#5 lore raw

PATCH v2 2/3 ARM: dts: add Exynos audio subsystem clock controller node

In reply to Padmavathi Venna

Audio subsystem introduced in s5pv210 and exynos platforms which has a internal clock controller. This patch adds a node for the same on exynos5250.

---
 arch/arm/boot/dts/exynos5250.dtsi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
arch/arm/boot/dts/exynos5250.dtsi +6 -0
index 36c9d8d..7026de0 100644
@@ -72,6 +72,12 @@
 		#clock-cells = <1>;
 	};
 
+	clock_audss: audss-clock-controller@0x03810000 {
+		compatible = "samsung,exynos5250-audss-clock";
+		reg = <0x03810000 0x0C>;
+		#clock-cells = <1>;
+	};
+
 	gic:interrupt-controller@10481000 {
 		compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic";
 		#interrupt-cells = <3>;
Signature · 1 line
1.7.4.4
#6 lore raw

PATCH v2 2/3 ARM: dts: add Exynos audio subsystem clock controller node

Hi Padmavathi,

Quoted 14 lines · On Tuesday 07 of May 2013 12:13:35 Padmavathi Venna wrote:

Audio subsystem introduced in s5pv210 and exynos platforms which has a internal clock controller. This patch adds a node for the same on exynos5250.

---
 arch/arm/boot/dts/exynos5250.dtsi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/arm/boot/dts/exynos5250.dtsi index 36c9d8d..7026de0 100644

arch/arm/boot/dts/exynos5250.dtsi line 75

Quoted 4 lines
arch/arm/boot/dts/exynos5250.dtsi +1 -0
@@ -72,6 +72,12 @@
 		#clock-cells = <1>;
 	};
 
+	clock_audss: audss-clock-controller at 0x03810000 {

Just a nitpick: this should be @3810000, without the 0x and leading zeroes.

Best regards,

Signature · 3 lines
Tomasz Figa
Samsung Poland R&D Center
SW Solution Development, Kernel and System Framework
Quoted 8 lines
arch/arm/boot/dts/exynos5250.dtsi +5 -0
+		compatible = "samsung,exynos5250-audss-clock";
+		reg = <0x03810000 0x0C>;
+		#clock-cells = <1>;
+	};
+
 	gic:interrupt-controller at 10481000 {
 		compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic";
 		#interrupt-cells = <3>;
#7 lore raw

PATCH v2 2/3 ARM: dts: add Exynos audio subsystem clock controller node

Hi Tomasz,

Quoted 20 lines · Tomasz Figa

Hi Padmavathi,

Quoted 17 lines · On Tuesday 07 of May 2013 12:13:35 Padmavathi Venna wrote:

Audio subsystem introduced in s5pv210 and exynos platforms which has a internal clock controller. This patch adds a node for the same on exynos5250.

---
 arch/arm/boot/dts/exynos5250.dtsi |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
(quoted diff) +0 -0

b/arch/arm/boot/dts/exynos5250.dtsi index 36c9d8d..7026de0 100644

arch/arm/boot/dts/exynos5250.dtsi +0 -0
@@ -72,6 +72,12 @@
              #clock-cells = <1>;
      };
 
Quoted 3 lines

arch/arm/boot/dts/exynos5250.dtsi line 75

Quoted 1 line
arch/arm/boot/dts/exynos5250.dtsi +1 -0
+     clock_audss: audss-clock-controller at 0x03810000 {

Just a nitpick: this should be @3810000, without the 0x and leading zeroes.

Okey. I will change this.

Quoted 16 lines

Best regards,
--
Tomasz Figa
Samsung Poland R&D Center
SW Solution Development, Kernel and System Framework

Quoted 8 lines
arch/arm/boot/dts/exynos5250.dtsi +5 -0
+             compatible = "samsung,exynos5250-audss-clock";
+             reg = <0x03810000 0x0C>;
+             #clock-cells = <1>;
+     };
+
      gic:interrupt-controller at 10481000 {
              compatible = "arm,cortex-a15-gic", "arm,cortex-a9-gic";
              #interrupt-cells = <3>;

Thanks
Padma

#8 lore raw

PATCH v2 3/3 ARM: dts: add clock provider information for i2s controllers in Exynos5250

In reply to Padmavathi Venna

Add clock lookup information for i2s controllers on exynos5250 SoC.

---
 arch/arm/boot/dts/exynos5250.dtsi |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
arch/arm/boot/dts/exynos5250.dtsi +10 -0
index 7026de0..13305b9 100644
@@ -20,6 +20,8 @@
 #include "skeleton.dtsi"
 #include "exynos5250-pinctrl.dtsi"
 
+#include <dt-bindings/clk/samsung-audss-clk.h>
+
 / {
 	compatible = "samsung,exynos5250";
 	interrupt-parent = <&gic>;
@@ -457,6 +459,10 @@
 			&pdma0 9
 			&pdma0 8>;
 		dma-names = "tx", "rx", "tx-sec";
+		clocks = <&clock_audss SAMSUNG_I2S_BUS>,
+			<&clock_audss SAMSUNG_I2S_BUS>,
+			<&clock_audss SAMSUNG_SCLK_I2S>;
+		clock-names = "iis", "i2s_opclk0", "i2s_opclk1";
 		samsung,supports-6ch;
 		samsung,supports-rstclr;
 		samsung,supports-secdai;
@@ -471,6 +477,8 @@
 		dmas = <&pdma1 12
 			&pdma1 11>;
 		dma-names = "tx", "rx";
+		clocks = <&clock 307>;
+		clock-names = "iis";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2s1_bus>;
 	};
@@ -481,6 +489,8 @@
 		dmas = <&pdma0 12
 			&pdma0 11>;
 		dma-names = "tx", "rx";
+		clocks = <&clock 308>;
+		clock-names = "iis";
 		pinctrl-names = "default";
 		pinctrl-0 = <&i2s2_bus>;
 	};
Signature · 1 line
1.7.4.4
#9 lore raw

v2 cover clk: Samsung: audss: Register audio subsytem clocks using common clk framework

In reply to Padmavathi Venna

Hi Padmavathi,

Quoted 10 lines · On Tuesday 07 of May 2013 12:13:33 Padmavathi Venna wrote:

Samsung S5PV210 and Exynos SoC has a separate subsystem for audio. This subsystem has a internal clock controller which controls i2s0 and pcm0 clocks. This patch series adds the Samsung audio subsytem clock to the common clock framework and provides the I2S controllers clock information in the dtsi file.

This patch series is dependent on
https://patchwork.kernel.org/patch/2532091/
http://www.spinics.net/lists/linux-kbuild/msg07616.html

Quoted 5 lines

This patch series is made based on Kukjin Kim for-next branch

Changes since V1:
- Reworked on all review comments by Sylwester Nawrocki
- Added a header file for all clock indexes as requested by

Sylwester

Quoted 1 line

- Added different compatible names for s5pv210, exynos4 and

exynos5

Quoted 9 lines

- Registered the pcm clocks with common clock framework

Padmavathi Venna (3):
clk: samsung: register audio subsystem clocks using common clock
framework
ARM: dts: add Exynos audio subsystem clock controller node
ARM: dts: add clock provider information for i2s controllers in

    Exynos5250
Quoted 10 lines
 .../bindings/clock/clk-samsung-audss.txt           |   64 +++++++++
 arch/arm/boot/dts/exynos5250.dtsi                  |   16 +++
 drivers/clk/samsung/Makefile                       |    1 +
 drivers/clk/samsung/clk-samsung-audss.c            |  137
++++++++++++++++++++ include/dt-bindings/clk/samsung-audss-clk.h       
|   25 ++++ 5 files changed, 243 insertions(+), 0 deletions(-)
 create mode 100644
Documentation/devicetree/bindings/clock/clk-samsung-audss.txt create
mode 100644 drivers/clk/samsung/clk-samsung-audss.c
 create mode 100644 include/dt-bindings/clk/samsung-audss-clk.h

Also, I think that this series lacks

Cc Mike Turquette <[email protected]>

as he's the maintainer of the clk subsystem.

Best regards,
Tomasz