Skip to contentSkip to conversation

Add i.MX8MQ clock driver

PATCH Applied Abel Vesa 4 participants 15 messages Nov 13, 2018 – Dec 11, 2018

Subsystems (4)

v13 of 15 Applied Latest is v15 →

lore
Share & tools
lore

Abel Vesa

author
#0 lore raw

v13 cover Add i.MX8MQ clock driver

Here is a link to the 12th version:
https://lkml.org/lkml/2018/11/7/642

Changes since v12:
* replaced the division in clk_pll_recalc_rate in clk-frac with do_div as suggested by Stephen

Abel Vesa (2):
clk: imx: Add imx composite clock
clk: imx: Add clock driver for i.MX8MQ CCM

Lucas Stach (3):
dt-bindings: add binding for i.MX8MQ CCM
clk: imx: add fractional PLL output clock
clk: imx: Add SCCG PLL type

 .../devicetree/bindings/clock/imx8mq-clock.txt     |  20 +
 drivers/clk/imx/Makefile                           |   6 +-
 drivers/clk/imx/clk-composite-8m.c                 | 178 +++++++
 drivers/clk/imx/clk-frac-pll.c                     | 221 ++++++++
 drivers/clk/imx/clk-imx8mq.c                       | 589 +++++++++++++++++++++
 drivers/clk/imx/clk-sccg-pll.c                     | 256 +++++++++
 drivers/clk/imx/clk.h                              |  64 +++
 include/dt-bindings/clock/imx8mq-clock.h           | 395 ++++++++++++++
 8 files changed, 1728 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/clock/imx8mq-clock.txt
 create mode 100644 drivers/clk/imx/clk-composite-8m.c
 create mode 100644 drivers/clk/imx/clk-frac-pll.c
 create mode 100644 drivers/clk/imx/clk-imx8mq.c
 create mode 100644 drivers/clk/imx/clk-sccg-pll.c
 create mode 100644 include/dt-bindings/clock/imx8mq-clock.h
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH v13 1/5 dt-bindings: add binding for i.MX8MQ CCM

From: Lucas Stach <[email protected]>

This adds the binding for the i.MX8MQ Clock Controller Module.

---
 .../devicetree/bindings/clock/imx8mq-clock.txt     |  20 ++
 include/dt-bindings/clock/imx8mq-clock.h           | 395 +++++++++++++++++++++
 2 files changed, 415 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/imx8mq-clock.txt
 create mode 100644 include/dt-bindings/clock/imx8mq-clock.h
Documentation/devicetree/bindings/clock/imx8mq-clock.txt new file +20 -0
new file mode 100644
index 0000000..52de826
@@ -0,0 +1,20 @@
+* Clock bindings for NXP i.MX8M Quad
+
+Required properties:
+- compatible: Should be "fsl,imx8mq-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:
+    - "ckil"
+    - "osc_25m"
+    - "osc_27m"
+    - "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/imx8mq-clock.h
+for the full list of i.MX8M Quad clock IDs.
include/dt-bindings/clock/imx8mq-clock.h new file +395 -0

395 lines not on this page · raw message

Signature · 1 line
2.7.4
author
#3 lore raw

PATCH v13 2/5 clk: imx: add fractional PLL output clock

In reply to Abel Vesa

From: Lucas Stach <[email protected]>

This is a new fractional clock type introduced on i.MX8.

The description of this fractional clock can be found here:

https://www.nxp.com/docs/en/reference-manual/IMX8MDQLQRM.pdf#page=834

---
 drivers/clk/imx/Makefile       |   1 +
 drivers/clk/imx/clk-frac-pll.c | 221 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/imx/clk.h          |   3 +
 3 files changed, 225 insertions(+)
 create mode 100644 drivers/clk/imx/clk-frac-pll.c
drivers/clk/imx/Makefile +1 -0
index 8c3baa7..4893c1f 100644
@@ -6,6 +6,7 @@ obj-y += \
 	clk-cpu.o \
 	clk-fixup-div.o \
 	clk-fixup-mux.o \
+	clk-frac-pll.o \
 	clk-gate-exclusive.o \
 	clk-gate2.o \
 	clk-pllv1.o \
drivers/clk/imx/clk-frac-pll.c new file +221 -0

221 lines not on this page · raw message

drivers/clk/imx/clk.h +3 -0
index 5895e223..44a1f14 100644
@@ -27,6 +27,9 @@ struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name,
 struct clk *imx_clk_pllv2(const char *name, const char *parent,
 		void __iomem *base);
 
+struct clk *imx_clk_frac_pll(const char *name, const char *parent_name,
+			     void __iomem *base);
+
 enum imx_pllv3_type {
 	IMX_PLLV3_GENERIC,
 	IMX_PLLV3_SYS,
Signature · 1 line
2.7.4
author
#5 lore raw

PATCH v13 3/5 clk: imx: Add SCCG PLL type

In reply to Abel Vesa

From: Lucas Stach <[email protected]>

The SCCG is a new PLL type introduced on i.MX8.

The description of this SCCG clock can be found here:

https://www.nxp.com/docs/en/reference-manual/IMX8MDQLQRM.pdf#page=834

---
 drivers/clk/imx/Makefile       |   3 +-
 drivers/clk/imx/clk-sccg-pll.c | 256 +++++++++++++++++++++++++++++++++++++++++
 drivers/clk/imx/clk.h          |   9 ++
 3 files changed, 267 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/imx/clk-sccg-pll.c
drivers/clk/imx/Makefile +2 -1
index 4893c1f..b87513c 100644
@@ -12,7 +12,8 @@ obj-y += \
 	clk-pllv1.o \
 	clk-pllv2.o \
 	clk-pllv3.o \
-	clk-pfd.o
+	clk-pfd.o \
+	clk-sccg-pll.o
 
 obj-$(CONFIG_SOC_IMX1)   += clk-imx1.o
 obj-$(CONFIG_SOC_IMX21)  += clk-imx21.o
drivers/clk/imx/clk-sccg-pll.c new file +256 -0

256 lines not on this page · raw message

drivers/clk/imx/clk.h +9 -0
index 44a1f14..864cd8a 100644
@@ -21,6 +21,11 @@ enum imx_pllv1_type {
 	IMX_PLLV1_IMX35,
 };
 
+enum imx_sccg_pll_type {
+	SCCG_PLL1,
+	SCCG_PLL2,
+};
+
 struct clk *imx_clk_pllv1(enum imx_pllv1_type type, const char *name,
 		const char *parent, void __iomem *base);
 
@@ -30,6 +35,10 @@ struct clk *imx_clk_pllv2(const char *name, const char *parent,
 struct clk *imx_clk_frac_pll(const char *name, const char *parent_name,
 			     void __iomem *base);
 
+struct clk *imx_clk_sccg_pll(const char *name, const char *parent_name,
+			     void __iomem *base,
+			     enum imx_sccg_pll_type pll_type);
+
 enum imx_pllv3_type {
 	IMX_PLLV3_GENERIC,
 	IMX_PLLV3_SYS,
Signature · 1 line
2.7.4
author
#7 lore raw

PATCH v13 4/5 clk: imx: Add imx composite clock

In reply to Abel Vesa

Since a lot of clocks on imx8m are formed by a mux, gate, predivider and divider, the idea here is to combine all of those into one composite clock, but we need to deal with both predivider and divider at the same time and therefore we add the imx8m_clk_composite_divider_ops and register the composite clock with those.

---
 drivers/clk/imx/Makefile           |   1 +
 drivers/clk/imx/clk-composite-8m.c | 178 +++++++++++++++++++++++++++++++++++++
 drivers/clk/imx/clk.h              |  16 ++++
 3 files changed, 195 insertions(+)
 create mode 100644 drivers/clk/imx/clk-composite-8m.c
drivers/clk/imx/Makefile +1 -0
index b87513c..237444b 100644
@@ -3,6 +3,7 @@
 obj-y += \
 	clk.o \
 	clk-busy.o \
+	clk-composite-8m.o \
 	clk-cpu.o \
 	clk-fixup-div.o \
 	clk-fixup-mux.o \
drivers/clk/imx/clk-composite-8m.c new file +178 -0

178 lines not on this page · raw message

drivers/clk/imx/clk.h +16 -0
index 864cd8a..cb3e92c 100644
@@ -239,4 +239,20 @@ struct clk *imx_clk_cpu(const char *name, const char *parent_name,
 		struct clk *div, struct clk *mux, struct clk *pll,
 		struct clk *step);
 
+struct clk *imx8m_clk_composite_flags(const char *name,
+					const char **parent_names,
+					int num_parents, void __iomem *reg,
+					unsigned long flags);
+
+#define __imx8m_clk_composite(name, parent_names, reg, flags) \
+	imx8m_clk_composite_flags(name, parent_names, \
+		ARRAY_SIZE(parent_names), reg, \
+		flags | CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE)
+
+#define imx8m_clk_composite(name, parent_names, reg) \
+	__imx8m_clk_composite(name, parent_names, reg, 0)
+
+#define imx8m_clk_composite_critical(name, parent_names, reg) \
+	__imx8m_clk_composite(name, parent_names, reg, CLK_IS_CRITICAL)
+
 #endif
Signature · 1 line
2.7.4
author
#9 lore raw

PATCH v13 5/5 clk: imx: Add clock driver for i.MX8MQ CCM

In reply to Abel Vesa

Add driver for the Clock Control Module found on i.MX8MQ.

---
 drivers/clk/imx/Makefile     |   1 +
 drivers/clk/imx/clk-imx8mq.c | 589 +++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/imx/clk.h        |  36 +++
 3 files changed, 626 insertions(+)
 create mode 100644 drivers/clk/imx/clk-imx8mq.c
drivers/clk/imx/Makefile +1 -0
index 237444b..6952f05 100644
@@ -29,4 +29,5 @@ obj-$(CONFIG_SOC_IMX6SLL) += clk-imx6sll.o
 obj-$(CONFIG_SOC_IMX6SX) += clk-imx6sx.o
 obj-$(CONFIG_SOC_IMX6UL) += clk-imx6ul.o
 obj-$(CONFIG_SOC_IMX7D)  += clk-imx7d.o
+obj-$(CONFIG_SOC_IMX8MQ) += clk-imx8mq.o
 obj-$(CONFIG_SOC_VF610)  += clk-vf610.o
drivers/clk/imx/clk-imx8mq.c new file +589 -0

589 lines not on this page · raw message

drivers/clk/imx/clk.h +36 -0
index cb3e92c..34357ca 100644
@@ -128,6 +128,15 @@ static inline struct clk *imx_clk_divider2(const char *name, const char *parent,
 			reg, shift, width, 0, &imx_ccm_lock);
 }
 
+static inline struct clk *imx_clk_divider2_flags(const char *name,
+		const char *parent, void __iomem *reg, u8 shift, u8 width,
+		unsigned long flags)
+{
+	return clk_register_divider(NULL, name, parent,
+			flags | CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
+			reg, shift, width, 0, &imx_ccm_lock);
+}
+
 static inline struct clk *imx_clk_gate(const char *name, const char *parent,
 		void __iomem *reg, u8 shift)
 {
@@ -202,6 +211,15 @@ static inline struct clk *imx_clk_gate3(const char *name, const char *parent,
 			reg, shift, 0, &imx_ccm_lock);
 }
 
+static inline struct clk *imx_clk_gate3_flags(const char *name,
+		const char *parent, void __iomem *reg, u8 shift,
+		unsigned long flags)
+{
+	return clk_register_gate(NULL, name, parent,
+			flags | CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
+			reg, shift, 0, &imx_ccm_lock);
+}
+
 static inline struct clk *imx_clk_gate4(const char *name, const char *parent,
 		void __iomem *reg, u8 shift)
 {
@@ -210,6 +228,15 @@ static inline struct clk *imx_clk_gate4(const char *name, const char *parent,
 			reg, shift, 0x3, 0, &imx_ccm_lock, NULL);
 }
 
+static inline struct clk *imx_clk_gate4_flags(const char *name,
+		const char *parent, void __iomem *reg, u8 shift,
+		unsigned long flags)
+{
+	return clk_register_gate2(NULL, name, parent,
+			flags | CLK_SET_RATE_PARENT | CLK_OPS_PARENT_ENABLE,
+			reg, shift, 0x3, 0, &imx_ccm_lock, NULL);
+}
+
 static inline struct clk *imx_clk_mux(const char *name, void __iomem *reg,
 		u8 shift, u8 width, const char **parents, int num_parents)
 {
@@ -235,6 +262,15 @@ static inline struct clk *imx_clk_mux_flags(const char *name,
 			&imx_ccm_lock);
 }
 
+static inline struct clk *imx_clk_mux2_flags(const char *name,
+		void __iomem *reg, u8 shift, u8 width, const char **parents,
+		int num_parents, unsigned long flags)
+{
+	return clk_register_mux(NULL, name, parents, num_parents,
+			flags | CLK_SET_RATE_NO_REPARENT | CLK_OPS_PARENT_ENABLE,
+			reg, shift, width, 0, &imx_ccm_lock);
+}
+
 struct clk *imx_clk_cpu(const char *name, const char *parent_name,
 		struct clk *div, struct clk *mux, struct clk *pll,
 		struct clk *step);
Signature · 1 line
2.7.4
maintainer
#11 lore raw
In reply to Abel Vesa

Quoting Abel Vesa (2018-11-13 08:19:56)

Quoted 7 lines

Here is a link to the 12th version:
https://lkml.org/lkml/2018/11/7/642

Changes since v12:
* replaced the division in clk_pll_recalc_rate in clk-frac with do_div as suggested by Stephen

Quoted 9 lines

Abel Vesa (2):
clk: imx: Add imx composite clock
clk: imx: Add clock driver for i.MX8MQ CCM

Lucas Stach (3):
dt-bindings: add binding for i.MX8MQ CCM
clk: imx: add fractional PLL output clock
clk: imx: Add SCCG PLL type

I had to apply this set of fixes to silence sparse and smatch warnings about things that are not right. Please take a look over things and see if it's sane.

drivers/clk/imx/clk-composite-8m.c +2 -2
index bcd31d889584..6d9d3714b4df 100644
@@ -127,8 +127,8 @@ struct clk *imx8m_clk_composite_flags(const char *name,
 					int num_parents, void __iomem *reg,
 					unsigned long flags)
 {
-	struct clk_hw *hw = NULL, *mux_hw = NULL;
-	struct clk_hw *div_hw = NULL, *gate_hw = NULL;
+	struct clk_hw *hw = ERR_PTR(-ENOMEM), *mux_hw;
+	struct clk_hw *div_hw, *gate_hw;
 	struct clk_divider *div = NULL;
 	struct clk_gate *gate = NULL;
 	struct clk_mux *mux = NULL;
drivers/clk/imx/clk-frac-pll.c +3 -1
index a3732be5ad7f..98726206f3c4 100644
@@ -14,6 +14,8 @@
 #include <linux/slab.h>
 #include <linux/bitfield.h>
 
+#include "clk.h"
+
 #define PLL_CFG0		0x0
 #define PLL_CFG1		0x4
 
@@ -214,7 +216,7 @@ struct clk *imx_clk_frac_pll(const char *name, const char *parent_name,
 	ret = clk_hw_register(NULL, hw);
 	if (ret) {
 		kfree(pll);
-		return ERR_CAST(hw);
+		return ERR_PTR(ret);
 	}
 
 	return hw->clk;
drivers/clk/imx/clk-sccg-pll.c +1 -1
index 4666b96bdb3f..ee7752bace89 100644
@@ -249,7 +249,7 @@ struct clk *imx_clk_sccg_pll(const char *name,
 	ret = clk_hw_register(NULL, hw);
 	if (ret) {
 		kfree(pll);
-		return ERR_CAST(hw);
+		return ERR_PTR(ret);
 	}
 
 	return hw->clk;
#12 lore raw
Quoted 2 lines

-----Original Message-----
From: Stephen Boyd [mailto:sboyd at kernel.org]

[...]

Quoted 9 lines
Quoted 9 lines

Changes since v12:
* replaced the division in clk_pll_recalc_rate in clk-frac with do_div as suggested by Stephen

Abel Vesa (2):
clk: imx: Add imx composite clock
clk: imx: Add clock driver for i.MX8MQ CCM

Quoted 9 lines
Quoted 5 lines

Lucas Stach (3):
dt-bindings: add binding for i.MX8MQ CCM
clk: imx: add fractional PLL output clock
clk: imx: Add SCCG PLL type

I had to apply this set of fixes to silence sparse and smatch warnings about things that are not right. Please take a look over things and see if it's sane.

The change looks good to me and tested ok.
I did not see this patch series in your tree.
Do you want us to apply your changes and re-send for easy pick up?

Regards
Dong Aisheng

Quoted 53 lines
drivers/clk/imx/clk-composite-8m.c +2 -2
index bcd31d889584..6d9d3714b4df 100644
@@ -127,8 +127,8 @@ struct clk *imx8m_clk_composite_flags(const char
 *name,
 					int num_parents, void __iomem *reg,
 					unsigned long flags)
 {
-	struct clk_hw *hw = NULL, *mux_hw = NULL;
-	struct clk_hw *div_hw = NULL, *gate_hw = NULL;
+	struct clk_hw *hw = ERR_PTR(-ENOMEM), *mux_hw;
+	struct clk_hw *div_hw, *gate_hw;
 	struct clk_divider *div = NULL;
 	struct clk_gate *gate = NULL;
drivers/clk/imx/clk-composite-8m.c +0 -0
 	struct clk_mux *mux = NULL;
drivers/clk/imx/clk-frac-pll.c index renamed from drivers/clk/imx/clk-frac-pll.c +0 -0

a3732be5ad7f..98726206f3c4 100644

drivers/clk/imx/clk-frac-pll.c +3 -1
@@ -14,6 +14,8 @@
 #include <linux/slab.h>
 #include <linux/bitfield.h>
 
+#include "clk.h"
+
 #define PLL_CFG0		0x0
 #define PLL_CFG1		0x4
 
@@ -214,7 +216,7 @@ struct clk *imx_clk_frac_pll(const char *name, const
 char *parent_name,
 	ret = clk_hw_register(NULL, hw);
 	if (ret) {
 		kfree(pll);
-		return ERR_CAST(hw);
+		return ERR_PTR(ret);
 	}
 
drivers/clk/imx/clk-frac-pll.c +0 -0
 	return hw->clk;
drivers/clk/imx/clk-sccg-pll.c index renamed from drivers/clk/imx/clk-sccg-pll.c +0 -0

4666b96bdb3f..ee7752bace89 100644

drivers/clk/imx/clk-sccg-pll.c +1 -1
@@ -249,7 +249,7 @@ struct clk *imx_clk_sccg_pll(const char *name,
 	ret = clk_hw_register(NULL, hw);
 	if (ret) {
 		kfree(pll);
-		return ERR_CAST(hw);
+		return ERR_PTR(ret);
 	}
 
 	return hw->clk;
maintainer Applied
#4 lore raw

Re: [PATCH v13 2/5] clk: imx: add fractional PLL output clock

In reply to Abel Vesa

Quoting Abel Vesa (2018-11-13 08:19:58)

Quoted 4 lines

From: Lucas Stach <[email protected]>

This is a new fractional clock type introduced on i.MX8.

Quoted 8 lines

The description of this fractional clock can be found here:

https://www.nxp.com/docs/en/reference-manual/IMX8MDQLQRM.pdf#page=834

---

Applied to clk-next

maintainer Applied
#6 lore raw

Re: [PATCH v13 3/5] clk: imx: Add SCCG PLL type

In reply to Abel Vesa

Quoting Abel Vesa (2018-11-13 08:19:59)

Quoted 4 lines

From: Lucas Stach <[email protected]>

The SCCG is a new PLL type introduced on i.MX8.

Quoted 8 lines

The description of this SCCG clock can be found here:

https://www.nxp.com/docs/en/reference-manual/IMX8MDQLQRM.pdf#page=834

---

Applied to clk-next

maintainer Applied
#8 lore raw

Re: [PATCH v13 4/5] clk: imx: Add imx composite clock

In reply to Abel Vesa

Quoting Abel Vesa (2018-11-13 08:20:00)

Quoted 10 lines

Since a lot of clocks on imx8m are formed by a mux, gate, predivider and divider, the idea here is to combine all of those into one composite clock, but we need to deal with both predivider and divider at the same time and therefore we add the imx8m_clk_composite_divider_ops and register the composite clock with those.

---

Applied to clk-next

maintainer Applied
#10 lore raw

Re: [PATCH v13 5/5] clk: imx: Add clock driver for i.MX8MQ CCM

In reply to Abel Vesa

Quoting Abel Vesa (2018-11-13 08:20:01)

Quoted 8 lines

Add driver for the Clock Control Module found on i.MX8MQ.

---

Applied to clk-next

maintainer
#13 lore raw
In reply to Aisheng DONG

Quoting Aisheng DONG (2018-11-28 23:46:41)

Quoted 18 lines
Quoted 2 lines

-----Original Message-----
From: Stephen Boyd [mailto:[email protected]]

[...]

Quoted 15 lines
Quoted 14 lines

Changes since v12:
* replaced the division in clk_pll_recalc_rate in clk-frac with do_div as suggested by Stephen

Abel Vesa (2):
clk: imx: Add imx composite clock
clk: imx: Add clock driver for i.MX8MQ CCM

Lucas Stach (3):
dt-bindings: add binding for i.MX8MQ CCM
clk: imx: add fractional PLL output clock
clk: imx: Add SCCG PLL type

Quoted 8 lines
Quoted 3 lines

I had to apply this set of fixes to silence sparse and smatch warnings about things that are not right. Please take a look over things and see if it's sane.

The change looks good to me and tested ok.
I did not see this patch series in your tree.
Do you want us to apply your changes and re-send for easy pick up?

I applied this version and my fixes. I'll just mark v14 as superseded. Thanks for testing!

#14 lore raw
Quoted 23 lines · Stephen Boyd

Quoting Aisheng DONG (2018-11-28 23:46:41)

Quoted 22 lines
Quoted 2 lines

-----Original Message-----
From: Stephen Boyd [mailto:[email protected]]

[...]

Quoted 18 lines
Quoted 5 lines

Changes since v12:
* replaced the division in clk_pll_recalc_rate in clk-frac with do_div as suggested by Stephen

Quoted 9 lines

Abel Vesa (2):
clk: imx: Add imx composite clock
clk: imx: Add clock driver for i.MX8MQ CCM

Lucas Stach (3):
dt-bindings: add binding for i.MX8MQ CCM
clk: imx: add fractional PLL output clock
clk: imx: Add SCCG PLL type

I had to apply this set of fixes to silence sparse and smatch warnings about things that are not right. Please take a look over things and see if it's sane.

Quoted 7 lines
Quoted 4 lines

The change looks good to me and tested ok.
I did not see this patch series in your tree.
Do you want us to apply your changes and re-send for easy pick up?

I applied this version and my fixes. I'll just mark v14 as superseded. Thanks for testing!

Hi Stephen,

For the same reason as clk-imx7ulp, please keep branch clk-imx8mq stable. Thanks.

Shawn