Skip to contentSkip to conversation

ARM: i.MX1 clk: Add devicetree support

PATCH New Alexander Shiyan 3 participants 7 messages May 13, 2014 – May 14, 2014

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

PATCH v2 3/3 ARM: i.MX1 clk: Add devicetree support

This patch adds devicetree support CCM module for i.MX1 (MC9328MX1) CPUs.

---
 .../devicetree/bindings/clock/imx1-clock.txt       |  28 +++++
 arch/arm/mach-imx/clk-imx1.c                       | 138 +++++++++++++--------
 include/dt-bindings/clock/imx1-clock.h             |  40 ++++++
 3 files changed, 153 insertions(+), 53 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/imx1-clock.txt
 create mode 100644 include/dt-bindings/clock/imx1-clock.h
Documentation/devicetree/bindings/clock/imx1-clock.txt new file +28 -0
new file mode 100644
index 0000000..bae9216
@@ -0,0 +1,28 @@
+* Clock bindings for Freescale i.MX1 CPUs
+
+Required properties:
+- compatible: Should be "fsl,imx1-ccm".
+- reg: Address and length of the register set.
+- interrupts: Should contain CCM interrupt.
+- #clock-cells: Should be <1>.
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell. See include/dt-bindings/clock/imx1-clock.h
+for the full list of i.MX1 clock IDs.
+
+Examples:
+	clks: ccm at 0021b000 {
+		#clock-cells = <1>;
+		compatible = "fsl,imx1-ccm";
+		reg = <0x0021b000 0x1000>;
+		interrupts = <59>;
+	};
+
+	pwm: pwm at 00208000 {
+		#pwm-cells = <2>;
+		compatible = "fsl,imx1-pwm";
+		reg = <0x00208000 0x1000>;
+		interrupts = <34>;
+		clocks = <&clks IMX1_CLK_DUMMY>, <&clks IMX1_CLK_PER1>;
+		clock-names = "ipg", "per";
+	};
arch/arm/mach-imx/clk-imx1.c +85 -53

164 lines not on this page · raw message

include/dt-bindings/clock/imx1-clock.h new file +40 -0
new file mode 100644
index 0000000..607bf01
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2014 Alexander Shiyan <[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.
+ *
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_IMX1_H
+#define __DT_BINDINGS_CLOCK_IMX1_H
+
+#define IMX1_CLK_DUMMY		0
+#define IMX1_CLK_CLK32		1
+#define IMX1_CLK_CLK16M_EXT	2
+#define IMX1_CLK_CLK16M		3
+#define IMX1_CLK_CLK32_PREMULT	4
+#define IMX1_CLK_PREM		5
+#define IMX1_CLK_MPLL		6
+#define IMX1_CLK_MPLL_GATE	7
+#define IMX1_CLK_SPLL		8
+#define IMX1_CLK_SPLL_GATE	9
+#define IMX1_CLK_MCU		10
+#define IMX1_CLK_FCLK		11
+#define IMX1_CLK_HCLK		12
+#define IMX1_CLK_CLK48M		13
+#define IMX1_CLK_PER1		14
+#define IMX1_CLK_PER2		15
+#define IMX1_CLK_PER3		16
+#define IMX1_CLK_CLKO		17
+#define IMX1_CLK_UART3_GATE	18
+#define IMX1_CLK_SSI2_GATE	19
+#define IMX1_CLK_BROM_GATE	20
+#define IMX1_CLK_DMA_GATE	21
+#define IMX1_CLK_CSI_GATE	22
+#define IMX1_CLK_MMA_GATE	23
+#define IMX1_CLK_USBD_GATE	24
+#define IMX1_CLK_MAX		25
+
+#endif
Signature · 1 line
1.8.3.2
reviewer
#1 lore raw

PATCH v2 3/3 ARM: i.MX1 clk: Add devicetree support

arch/arm/mach-imx/clk-imx1.c static const char *prem_sel_clks[] = { "clk32_premult", "clk16m", }; · line 63

Quoted 8 lines · Alexander Shiyan
arch/arm/mach-imx/clk-imx1.c +8 -0
+       clk[IMX1_CLK_DUMMY] =
+               imx_clk_fixed("dummy", 0);
+       clk[IMX1_CLK_CLK32] =
+               imx_obtain_fixed_clock("clk32", fref);
+       clk[IMX1_CLK_CLK16M_EXT] =
+               imx_clk_fixed("clk16m_ext", 16000000);
+       clk[IMX1_CLK_CLK16M] =
+               imx_clk_gate("clk16m", "clk16m_ext", CCM_CSCR, 17);

Why don't you put each entry into a single line instead?

Even if it gets larger than 80 columns, it would be easier to read.

#2 lore raw

Tue, 13 May 2014 13:18:40 -0300 ?? Fabio Estevam <[email protected]>:

Quoted 11 lines · Alexander Shiyan

arch/arm/mach-imx/clk-imx1.c static const char *prem_sel_clks[] = { "clk32_premult", "clk16m", }; · line 63

Quoted 9 lines
arch/arm/mach-imx/clk-imx1.c +8 -0
+       clk[IMX1_CLK_DUMMY] =
+               imx_clk_fixed("dummy", 0);
+       clk[IMX1_CLK_CLK32] =
+               imx_obtain_fixed_clock("clk32", fref);
+       clk[IMX1_CLK_CLK16M_EXT] =
+               imx_clk_fixed("clk16m_ext", 16000000);
+       clk[IMX1_CLK_CLK16M] =
+               imx_clk_gate("clk16m", "clk16m_ext", CCM_CSCR, 17);
Quoted 3 lines

Why don't you put each entry into a single line instead?

Even if it gets larger than 80 columns, it would be easier to read.

I thought about it, but came to the conclusion that it is better to observe the kernel rules.

---

reviewer
#3 lore raw

PATCH v2 3/3 ARM: i.MX1 clk: Add devicetree support

Quoted 12 lines · Alexander Shiyan

Tue, 13 May 2014 13:18:40 -0300 ?? Fabio Estevam <[email protected]>:

Quoted 11 lines · Alexander Shiyan
Quoted 9 lines
arch/arm/mach-imx/clk-imx1.c +8 -0
+       clk[IMX1_CLK_DUMMY] =
+               imx_clk_fixed("dummy", 0);
+       clk[IMX1_CLK_CLK32] =
+               imx_obtain_fixed_clock("clk32", fref);
+       clk[IMX1_CLK_CLK16M_EXT] =
+               imx_clk_fixed("clk16m_ext", 16000000);
+       clk[IMX1_CLK_CLK16M] =
+               imx_clk_gate("clk16m", "clk16m_ext", CCM_CSCR, 17);
Quoted 6 lines
Quoted 3 lines

Why don't you put each entry into a single line instead?

Even if it gets larger than 80 columns, it would be easier to read.

I thought about it, but came to the conclusion that it is better to observe the kernel rules.

Do you mean checkpatch complaint?

Then try to make checkpatch happy with other clock file such as arch/arm/mach-imx/clk-imx6q.

The result will be unreadable :-)

#4 lore raw

Tue, 13 May 2014 13:28:28 -0300 ?? Fabio Estevam <[email protected]>:

Quoted 20 lines · Alexander Shiyan
Quoted 12 lines

Tue, 13 May 2014 13:18:40 -0300 ?? Fabio Estevam <[email protected]>:

Quoted 11 lines · Alexander Shiyan
Quoted 9 lines
arch/arm/mach-imx/clk-imx1.c +8 -0
+       clk[IMX1_CLK_DUMMY] =
+               imx_clk_fixed("dummy", 0);
+       clk[IMX1_CLK_CLK32] =
+               imx_obtain_fixed_clock("clk32", fref);
+       clk[IMX1_CLK_CLK16M_EXT] =
+               imx_clk_fixed("clk16m_ext", 16000000);
+       clk[IMX1_CLK_CLK16M] =
+               imx_clk_gate("clk16m", "clk16m_ext", CCM_CSCR, 17);
Quoted 6 lines
Quoted 3 lines

Why don't you put each entry into a single line instead?

Even if it gets larger than 80 columns, it would be easier to read.

I thought about it, but came to the conclusion that it is better to observe the kernel rules.

Quoted 6 lines

Do you mean checkpatch complaint?

Then try to make checkpatch happy with other clock file such as arch/arm/mach-imx/clk-imx6q.

The result will be unreadable :-)

As another solution we can use macros, something like this:

#define IMXCLK_MUX(id, name, reg, off, sz, arr) \
clk[id] = imx_clk_mux(name, reg, off, sz, arr, ARRAY_SIZE(arr))

...

	IMXCLK_MUX(IMX1_CLK_PREM, "prem", CCM_CSCR, 16, 1, prem_sel_clks);

---

maintainer
#5 lore raw

PATCH v2 3/3 ARM: i.MX1 clk: Add devicetree support

Quoted 26 lines · Alexander Shiyan

Tue, 13 May 2014 13:28:28 -0300 ?? Fabio Estevam <[email protected]>:

Quoted 25 lines · Alexander Shiyan
Quoted 12 lines

Tue, 13 May 2014 13:18:40 -0300 ?? Fabio Estevam <[email protected]>:

Quoted 11 lines · Alexander Shiyan
Quoted 9 lines
arch/arm/mach-imx/clk-imx1.c +8 -0
+       clk[IMX1_CLK_DUMMY] =
+               imx_clk_fixed("dummy", 0);
+       clk[IMX1_CLK_CLK32] =
+               imx_obtain_fixed_clock("clk32", fref);
+       clk[IMX1_CLK_CLK16M_EXT] =
+               imx_clk_fixed("clk16m_ext", 16000000);
+       clk[IMX1_CLK_CLK16M] =
+               imx_clk_gate("clk16m", "clk16m_ext", CCM_CSCR, 17);
Quoted 6 lines
Quoted 3 lines

Why don't you put each entry into a single line instead?

Even if it gets larger than 80 columns, it would be easier to read.

I thought about it, but came to the conclusion that it is better to observe the kernel rules.

Do you mean checkpatch complaint?

Then try to make checkpatch happy with other clock file such as arch/arm/mach-imx/clk-imx6q.

Quoted 6 lines
Quoted 1 line

The result will be unreadable :-)

As another solution we can use macros, something like this:

#define IMXCLK_MUX(id, name, reg, off, sz, arr) \
clk[id] = imx_clk_mux(name, reg, off, sz, arr, ARRAY_SIZE(arr))

Please don't do that. We have i.MX specific wrapper functions. Wrapping these again with macros doesn't improve the situation. I'm with Fabio here, I would prefer the functions in a single line.

Sascha

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#6 lore raw

Tue, 13 May 2014 19:31:43 +0200 ?? Sascha Hauer <[email protected]>:

Quoted 29 lines · Alexander Shiyan
Quoted 28 lines

Tue, 13 May 2014 13:28:28 -0300 ?? Fabio Estevam <[email protected]>:

Quoted 26 lines · Alexander Shiyan
Quoted 12 lines

Tue, 13 May 2014 13:18:40 -0300 ?? Fabio Estevam <[email protected]>:

Quoted 11 lines · Alexander Shiyan
Quoted 9 lines
arch/arm/mach-imx/clk-imx1.c +8 -0
+       clk[IMX1_CLK_DUMMY] =
+               imx_clk_fixed("dummy", 0);
+       clk[IMX1_CLK_CLK32] =
+               imx_obtain_fixed_clock("clk32", fref);
+       clk[IMX1_CLK_CLK16M_EXT] =
+               imx_clk_fixed("clk16m_ext", 16000000);
+       clk[IMX1_CLK_CLK16M] =
+               imx_clk_gate("clk16m", "clk16m_ext", CCM_CSCR, 17);
Quoted 6 lines
Quoted 3 lines

Why don't you put each entry into a single line instead?

Even if it gets larger than 80 columns, it would be easier to read.

I thought about it, but came to the conclusion that it is better to observe the kernel rules.

Do you mean checkpatch complaint?

Then try to make checkpatch happy with other clock file such as arch/arm/mach-imx/clk-imx6q.

The result will be unreadable :-)

Quoted 8 lines
Quoted 4 lines

As another solution we can use macros, something like this:

#define IMXCLK_MUX(id, name, reg, off, sz, arr) \
clk[id] = imx_clk_mux(name, reg, off, sz, arr, ARRAY_SIZE(arr))

Please don't do that. We have i.MX specific wrapper functions. Wrapping these again with macros doesn't improve the situation. I'm with Fabio here, I would prefer the functions in a single line.

OK. Shawn, if no objections to parts 1 and 2, I would like them to be applied.

---