Skip to contentSkip to conversation

dt-bindings: imx: Add clock binding doc for i.MX8MN

PATCH Superseded [email protected] 2 participants 13 messages Jun 4, 2019 – Jun 25, 2019

Subsystems (4)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/4 dt-bindings: imx: Add clock binding doc for i.MX8MN

From: Anson Huang <[email protected]>

Add the clock binding doc for i.MX8MN.

---
No changes.

---
 .../devicetree/bindings/clock/imx8mn-clock.txt     |  29 +++
 include/dt-bindings/clock/imx8mn-clock.h           | 215 +++++++++++++++++++++
 2 files changed, 244 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/imx8mn-clock.txt
 create mode 100644 include/dt-bindings/clock/imx8mn-clock.h
Documentation/devicetree/bindings/clock/imx8mn-clock.txt new file +29 -0
new file mode 100644
index 0000000..d83db5c
@@ -0,0 +1,29 @@
+* Clock bindings for NXP i.MX8M Nano
+
+Required properties:
+- compatible: Should be "fsl,imx8mn-ccm"
+- reg: Address and length of the register set
+- #clock-cells: Should be <1>
+- clocks: list of clock specifiers, must contain an entry for each required
+          entry in clock-names
+- clock-names: should include the following entries:
+    - "osc_32k"
+    - "osc_24m"
+    - "clk_ext1"
+    - "clk_ext2"
+    - "clk_ext3"
+    - "clk_ext4"
+
+clk: clock-controller@30380000 {
+	compatible = "fsl,imx8mn-ccm";
+	reg = <0x0 0x30380000 0x0 0x10000>;
+	#clock-cells = <1>;
+	clocks = <&osc_32k>, <&osc_24m>, <&clk_ext1>, <&clk_ext2>,
+		 <&clk_ext3>, <&clk_ext4>;
+	clock-names = "osc_32k", "osc_24m", "clk_ext1", "clk_ext2",
+		      "clk_ext3", "clk_ext4";
+};
+
+The clock consumer should specify the desired clock by having the clock
+ID in its "clocks" phandle cell. See include/dt-bindings/clock/imx8mn-clock.h
+for the full list of i.MX8M Nano clock IDs.
include/dt-bindings/clock/imx8mn-clock.h new file +215 -0

215 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 2/4 clk: imx8mm: Make 1416X/1443X PLL macro definitions common for usage

From: Anson Huang <[email protected]>

1416X/1443X PLL are used on i.MX8MM and i.MX8MN and maybe other i.MX8M series SoC later, the macro definitions of these PLLs' initialization should be common for usage.

---
New patch.

---
 drivers/clk/imx/clk-imx8mm.c | 17 -----------------
 drivers/clk/imx/clk.h        | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 17 deletions(-)
drivers/clk/imx/clk-imx8mm.c +0 -17
index eb9fcf0..fecb3b2 100644
@@ -26,23 +26,6 @@ static u32 share_count_dcss;
 static u32 share_count_pdm;
 static u32 share_count_nand;
 
-#define PLL_1416X_RATE(_rate, _m, _p, _s)		\
-	{						\
-		.rate	=	(_rate),		\
-		.mdiv	=	(_m),			\
-		.pdiv	=	(_p),			\
-		.sdiv	=	(_s),			\
-	}
-
-#define PLL_1443X_RATE(_rate, _m, _p, _s, _k)		\
-	{						\
-		.rate	=	(_rate),		\
-		.mdiv	=	(_m),			\
-		.pdiv	=	(_p),			\
-		.sdiv	=	(_s),			\
-		.kdiv	=	(_k),			\
-	}
-
 static const struct imx_pll14xx_rate_table imx8mm_pll1416x_tbl[] = {
 	PLL_1416X_RATE(1800000000U, 225, 3, 0),
 	PLL_1416X_RATE(1600000000U, 200, 3, 0),
drivers/clk/imx/clk.h +17 -0
index 6dcdc91..ac8c4ae 100644
@@ -81,6 +81,23 @@ enum imx_pllv3_type {
 	IMX_PLLV3_AV_IMX7,
 };
 
+#define PLL_1416X_RATE(_rate, _m, _p, _s)		\
+	{						\
+		.rate	=	(_rate),		\
+		.mdiv	=	(_m),			\
+		.pdiv	=	(_p),			\
+		.sdiv	=	(_s),			\
+	}
+
+#define PLL_1443X_RATE(_rate, _m, _p, _s, _k)		\
+	{						\
+		.rate	=	(_rate),		\
+		.mdiv	=	(_m),			\
+		.pdiv	=	(_p),			\
+		.sdiv	=	(_s),			\
+		.kdiv	=	(_k),			\
+	}
+
 struct clk *imx_clk_pllv3(enum imx_pllv3_type type, const char *name,
 		const char *parent_name, void __iomem *base, u32 div_mask);
 
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 3/4 clk: imx: Add support for i.MX8MN clock driver

In reply to [email protected]

From: Anson Huang <[email protected]>

This patch adds i.MX8MN clock driver support.

---
Changes since V2:
- use platform driver model for this clock driver;
- add "const" to clock mux arrays.

---
 drivers/clk/imx/Kconfig      |   6 +
 drivers/clk/imx/Makefile     |   1 +
 drivers/clk/imx/clk-imx8mn.c | 630 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 637 insertions(+)
 create mode 100644 drivers/clk/imx/clk-imx8mn.c
drivers/clk/imx/Kconfig +6 -0
index 0eaf418..1ac0c79 100644
@@ -14,6 +14,12 @@ config CLK_IMX8MM
 	help
 	    Build the driver for i.MX8MM CCM Clock Driver
 
+config CLK_IMX8MN
+	bool "IMX8MN CCM Clock Driver"
+	depends on ARCH_MXC && ARM64
+	help
+	    Build the driver for i.MX8MN CCM Clock Driver
+
 config CLK_IMX8MQ
 	bool "IMX8MQ CCM Clock Driver"
 	depends on ARCH_MXC && ARM64
drivers/clk/imx/Makefile +1 -0
index 05641c6..77a3d71 100644
@@ -26,6 +26,7 @@ obj-$(CONFIG_MXC_CLK_SCU) += \
 	clk-lpcg-scu.o
 
 obj-$(CONFIG_CLK_IMX8MM) += clk-imx8mm.o
+obj-$(CONFIG_CLK_IMX8MN) += clk-imx8mn.o
 obj-$(CONFIG_CLK_IMX8MQ) += clk-imx8mq.o
 obj-$(CONFIG_CLK_IMX8QXP) += clk-imx8qxp.o clk-imx8qxp-lpcg.o
 
drivers/clk/imx/clk-imx8mn.c new file +630 -0

630 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#3 lore raw

Re: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Quoting [email protected] (2019-06-03 18:59:27)

Quoted 8 lines

From: Anson Huang <[email protected]>

This patch adds i.MX8MN clock driver support.

---
Changes since V2:
- use platform driver model for this clock driver;

Can you also use platform device APIs like platform_*(), devm_ioremap_resource() and devmified clk registration?

#4 lore raw

RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Hi, Stephen

Quoted 23 lines

-----Original Message-----
From: Stephen Boyd <[email protected]>
Sent: Friday, June 7, 2019 12:26 AM
To: Anson Huang <[email protected]>; Abel Vesa <[email protected]>; Aisheng Dong <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Leonard Crestez <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Jacky Bai <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: dl-linux-imx <[email protected]>
Subject: Re: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Quoting [email protected] (2019-06-03 18:59:27)

Quoted 4 lines

From: Anson Huang <[email protected]>

This patch adds i.MX8MN clock driver support.

Quoted 7 lines
Quoted 4 lines

---
Changes since V2:
- use platform driver model for this clock driver;

Can you also use platform device APIs like platform_*(), devm_ioremap_resource() and devmified clk registration?

I will use devm_platform_ioremap_resource() instead of ioremap(), and can you be more specific about devmified clk registration?

Thanks,
Anson

maintainer
#5 lore raw

RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Quoting Anson Huang (2019-06-06 17:50:28)

Quoted 4 lines

I will use devm_platform_ioremap_resource() instead of ioremap(), and can you be more specific about devmified clk registration?

I mean using things like devm_clk_hw_register().

#6 lore raw

RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Hi, Stephen

Quoted 19 lines

-----Original Message-----
From: Stephen Boyd <[email protected]>
Sent: Saturday, June 8, 2019 2:01 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; s.hauer@pengutronix .de <[email protected]>; [email protected]; [email protected]; Abel Vesa <[email protected]>; Aisheng Dong <[email protected]>; Anson Huang <[email protected]>; Jacky Bai <[email protected]>; Leonard Crestez <[email protected]>
Cc: dl-linux-imx <[email protected]>
Subject: RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Quoted 7 lines

Quoting Anson Huang (2019-06-06 17:50:28)

Quoted 4 lines

I will use devm_platform_ioremap_resource() instead of ioremap(), and can you be more specific about devmified clk registration?

I mean using things like devm_clk_hw_register().

Sorry, I am still a little confused, all the clock register(clk_register()) are via each different clock types like imx_clk_gate4/imx_clk_pll14xx, if using clk_hw_register, means we need to re-write the clock driver using different clk register method, that will make the driver completely different from i.mx8mq/i.mx8mm, they are actually same series of SoC as i.mx8mn, it will introduce many confusion, is my understanding correct? And is it OK to just keep what it is and make them all aligned?

Thanks,
Anson.

maintainer
#7 lore raw

RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Quoting Anson Huang (2019-06-08 02:58:18)

Quoted 27 lines

Hi, Stephen

Quoted 25 lines

-----Original Message-----
From: Stephen Boyd <[email protected]>
Sent: Saturday, June 8, 2019 2:01 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; s.hauer@pengutronix .de <[email protected]>; [email protected]; [email protected]; Abel Vesa <[email protected]>; Aisheng Dong <[email protected]>; Anson Huang <[email protected]>; Jacky Bai <[email protected]>; Leonard Crestez <[email protected]>
Cc: dl-linux-imx <[email protected]>
Subject: RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Quoting Anson Huang (2019-06-06 17:50:28)

Quoted 4 lines

I will use devm_platform_ioremap_resource() instead of ioremap(), and can you be more specific about devmified clk registration?

Quoted 9 lines
Quoted 1 line

I mean using things like devm_clk_hw_register().

Sorry, I am still a little confused, all the clock register(clk_register()) are via each different clock types like imx_clk_gate4/imx_clk_pll14xx, if using clk_hw_register, means we need to re-write the clock driver using different clk register method, that will make the driver completely different from i.mx8mq/i.mx8mm, they are actually same series of SoC as i.mx8mn, it will introduce many confusion, is my understanding correct? And is it OK to just keep what it is and make them all aligned?

Ok, the problem I'm trying to point out is that clk registrations need to be undone, i.e. clk_unregister() needs to be called, when the driver fails to probe. devm_*() is one way to do this, but if you have other ways of removing all the registered clks then that works too. Makes sense?

#8 lore raw

RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Hi, Stephen

Quoted 58 lines

-----Original Message-----
From: Stephen Boyd <[email protected]>
Sent: Monday, June 10, 2019 11:14 PM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; s.hauer@pengutronix .de <[email protected]>; [email protected]; [email protected]; Abel Vesa <[email protected]>; Aisheng Dong <[email protected]>; Anson Huang <[email protected]>; Jacky Bai <[email protected]>; Leonard Crestez <[email protected]>
Cc: dl-linux-imx <[email protected]>
Subject: RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Quoting Anson Huang (2019-06-08 02:58:18)

Quoted 18 lines

Hi, Stephen

Quoted 16 lines

-----Original Message-----
From: Stephen Boyd <[email protected]>
Sent: Saturday, June 8, 2019 2:01 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; s.hauer@pengutronix .de robh+<[email protected]>;
[email protected]; [email protected]; Abel Vesa <[email protected]>; Aisheng Dong <[email protected]>; Anson Huang <[email protected]>; Jacky Bai <[email protected]>;

Leonard

Quoted 11 lines
Quoted 11 lines

Crestez <[email protected]>
Cc: dl-linux-imx <[email protected]>
Subject: RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Quoting Anson Huang (2019-06-06 17:50:28)

Quoted 4 lines

I will use devm_platform_ioremap_resource() instead of ioremap(), and can you be more specific about devmified clk registration?

Quoted 8 lines
Quoted 1 line

I mean using things like devm_clk_hw_register().

Sorry, I am still a little confused, all the clock register(clk_register()) are via each different clock types like imx_clk_gate4/imx_clk_pll14xx, if using clk_hw_register, means we need to re-write the clock driver using different clk register method, that will make the driver completely different from i.mx8mq/i.mx8mm, they are actually same series of SoC as i.mx8mn, it will introduce many

Quoted 8 lines

confusion, is my understanding correct? And is it OK to just keep what it is and make them all aligned?

Quoted 1 line

Ok, the problem I'm trying to point out is that clk registrations need to be undone, i.e. clk_unregister() needs to be called, when the driver fails to probe. devm_*() is one way to do this, but if you have other ways of removing all the registered clks then that works too. Makes sense?

Yes, it makes sense. Do you think it is OK to add an imx_unregister_clocks() API, then call it in every place of returning failure in .probe function? If yes, I will add it and also fix it in i.MX8MQ driver which uses platform driver model but does NOT handle this case.

        base = devm_platform_ioremap_resource(pdev, 0);

- if (WARN_ON(IS_ERR(base)))
- return PTR_ERR(base);
+ if (WARN_ON(IS_ERR(base))) {
+ ret = PTR_ERR(base);
+ goto unregister_clks;
+ }

                pr_err("failed to register clks for i.MX8MN\n");
-               return -EINVAL;
+               goto unregister_clks;
        }

        return 0;

+
+unregister_clks:
+ imx_unregister_clocks(clks, ARRAY_SIZE(clks));
+
+ return ret;

+void imx_unregister_clocks(struct clk *clks[], unsigned int count) +{
+ unsigned i;
+
+ for (i = 0; i < count; i++)
+ clk_unregister(clks[i]);
+}
+

Thanks,
Anson.

maintainer
#9 lore raw

RE: [PATCH V3 3/4] clk: imx: Add support for i.MX8MN clock driver

Quoting Anson Huang (2019-06-10 19:06:22)

Quoted 39 lines
Quoted 7 lines
Quoted 7 lines

Sorry, I am still a little confused, all the clock register(clk_register()) are via each different clock types like imx_clk_gate4/imx_clk_pll14xx, if using clk_hw_register, means we need to re-write the clock driver using different clk register method, that will make the driver completely different from i.mx8mq/i.mx8mm, they are actually same series of SoC as i.mx8mn, it will introduce many

Quoted 8 lines

confusion, is my understanding correct? And is it OK to just keep what it is and make them all aligned?

Quoted 1 line

Ok, the problem I'm trying to point out is that clk registrations need to be undone, i.e. clk_unregister() needs to be called, when the driver fails to probe. devm_*() is one way to do this, but if you have other ways of removing all the registered clks then that works too. Makes sense?

Yes, it makes sense. Do you think it is OK to add an imx_unregister_clocks() API, then call it in every place of returning failure in .probe function? If yes, I will add it and also fix it in i.MX8MQ driver which uses platform driver model but does NOT handle this case.

        base = devm_platform_ioremap_resource(pdev, 0);
(quoted diff) +9 -3
-       if (WARN_ON(IS_ERR(base)))
-               return PTR_ERR(base);
+       if (WARN_ON(IS_ERR(base))) {
+               ret = PTR_ERR(base);
+               goto unregister_clks;
+       }
 
                pr_err("failed to register clks for i.MX8MN\n");
-               return -EINVAL;
+               goto unregister_clks;
        }
 
        return 0;
+
+unregister_clks:
+       imx_unregister_clocks(clks, ARRAY_SIZE(clks));
+

Review

Quoted 10 lines
(quoted diff) +9 -0
+       return ret;
 
+void imx_unregister_clocks(struct clk *clks[], unsigned int count)
+{
+       unsigned i;
+
+       for (i = 0; i < count; i++)
+               clk_unregister(clks[i]);
+}
+

Yes, looks better.

#10 lore raw

PATCH v3 4/4 arm64: defconfig: Select CONFIG_CLK_IMX8MN by default

In reply to [email protected]

From: Anson Huang <[email protected]>

Enable CONFIG_CLK_IMX8MN to support i.MX8MN clock driver.

---
Changes since V2:
- follow alphabet sequence.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index 8d4f25c..ae17f45 100644
@@ -655,6 +655,7 @@ CONFIG_COMMON_CLK_S2MPS11=y
 CONFIG_CLK_QORIQ=y
 CONFIG_COMMON_CLK_PWM=y
 CONFIG_CLK_IMX8MM=y
+CONFIG_CLK_IMX8MN=y
 CONFIG_CLK_IMX8MQ=y
 CONFIG_CLK_IMX8QXP=y
 CONFIG_TI_SCI_CLK=y
Signature · 1 line
2.7.4
maintainer
#11 lore raw
In reply to [email protected]

Quoting [email protected] (2019-06-03 18:59:25)

Quoted 9 lines

From: Anson Huang <[email protected]>

Add the clock binding doc for i.MX8MN.

---
No changes.

---
 .../devicetree/bindings/clock/imx8mn-clock.txt     |  29 +++

Can this be yaml?

Quoted 5 lines
 include/dt-bindings/clock/imx8mn-clock.h           | 215 +++++++++++++++++++++
 2 files changed, 244 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/imx8mn-clock.txt
 create mode 100644 include/dt-bindings/clock/imx8mn-clock.h
#12 lore raw

Hi, Stephen

Quoted 24 lines

-----Original Message-----
From: Stephen Boyd <[email protected]>
Sent: Thursday, June 6, 2019 7:33 AM
To: Anson Huang <[email protected]>; Abel Vesa <[email protected]>; Aisheng Dong <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Leonard Crestez <[email protected]>; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Jacky Bai <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Cc: dl-linux-imx <[email protected]>
Subject: Re: [PATCH V3 1/4] dt-bindings: imx: Add clock binding doc for i.MX8MN

Quoting [email protected] (2019-06-03 18:59:25)

Quoted 4 lines

From: Anson Huang <[email protected]>

Add the clock binding doc for i.MX8MN.

Quoted 7 lines
Quoted 5 lines

---
No changes.

---
 .../devicetree/bindings/clock/imx8mn-clock.txt     |  29 +++

Can this be yaml?

OK, I will try to use yaml in V4.

Thanks,
Anson.

Quoted 8 lines
Quoted 2 lines
 include/dt-bindings/clock/imx8mn-clock.h           | 215

+++++++++++++++++++++

Quoted 2 lines
 2 files changed, 244 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/imx8mn-

clock.txt

Quoted 2 lines
 create mode 100644 include/dt-bindings/clock/imx8mn-clock.h