Skip to contentSkip to conversation

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

PATCH In review Anson Huang 2 participants 7 messages Dec 27, 2019 – Jan 7, 2020

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

PATCH 1/3 dt-bindings: imx: Add clock binding doc for i.MX8MP

Add the clock binding doc for i.MX8MP.

---
 .../devicetree/bindings/clock/imx8mp-clock.yaml    | 112 ++++++++
 include/dt-bindings/clock/imx8mp-clock.h           | 300 +++++++++++++++++++++
 2 files changed, 412 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/imx8mp-clock.yaml
 create mode 100644 include/dt-bindings/clock/imx8mp-clock.h
Documentation/devicetree/bindings/clock/imx8mp-clock.yaml new file +112 -0
new file mode 100644
index 0000000..5e01995
@@ -0,0 +1,112 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bindings/clock/imx8mp-clock.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP i.MX8M Plus Clock Control Module Binding
+
+maintainers:
+  - Anson Huang <[email protected]>
+
+description: |
+  NXP i.MX8M Plus clock control module is an integrated clock controller, which
+  generates and supplies to all modules.
+
+properties:
+  compatible:
+    const: fsl,imx8mp-ccm
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: 32k osc
+      - description: 24m osc
+      - description: ext1 clock input
+      - description: ext2 clock input
+      - description: ext3 clock input
+      - description: ext4 clock input
+
+  clock-names:
+    items:
+      - const: osc_32k
+      - const: osc_24m
+      - const: clk_ext1
+      - const: clk_ext2
+      - const: clk_ext3
+      - const: clk_ext4
+
+  '#clock-cells':
+    const: 1
+    description: |
+      The clock consumer should specify the desired clock by having the clock
+      ID in its "clocks" phandle cell. See include/dt-bindings/clock/imx8mp-clock.h
+      for the full list of i.MX8M Plus clock IDs.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+
+examples:
+  # Clock Control Module node:
+  - |
+    clk: clock-controller@30380000 {
+        compatible = "fsl,imx8mp-ccm";
+        reg = <0x30380000 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";
+    };
+
+  # Required external clocks for Clock Control Module node:
+  - |
+    osc_32k: clock-osc-32k {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <32768>;
+        clock-output-names = "osc_32k";
+    };
+
+    osc_24m: clock-osc-24m {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <24000000>;
+        clock-output-names = "osc_24m";
+    };
+
+    clk_ext1: clock-ext1 {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <133000000>;
+        clock-output-names = "clk_ext1";
+    };
+
+    clk_ext2: clock-ext2 {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <133000000>;
+        clock-output-names = "clk_ext2";
+    };
+
+    clk_ext3: clock-ext3 {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <133000000>;
+        clock-output-names = "clk_ext3";
+    };
+
+    clk_ext4: clock-ext4 {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency= <133000000>;
+        clock-output-names = "clk_ext4";
+    };
+
+...
include/dt-bindings/clock/imx8mp-clock.h new file +300 -0

300 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/3 clk: imx: Add support for i.MX8MP clock driver

Add clock driver support for i.MX8MP which is a new SoC of i.MX8M family.

---
 drivers/clk/imx/Kconfig      |   6 +
 drivers/clk/imx/Makefile     |   1 +
 drivers/clk/imx/clk-imx8mp.c | 767 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 774 insertions(+)
 create mode 100644 drivers/clk/imx/clk-imx8mp.c
drivers/clk/imx/Kconfig +6 -0
index 1ac0c79..01eadee 100644
@@ -20,6 +20,12 @@ config CLK_IMX8MN
 	help
 	    Build the driver for i.MX8MN CCM Clock Driver
 
+config CLK_IMX8MP
+	bool "IMX8MP CCM Clock Driver"
+	depends on ARCH_MXC && ARM64
+	help
+	    Build the driver for i.MX8MP CCM Clock Driver
+
 config CLK_IMX8MQ
 	bool "IMX8MQ CCM Clock Driver"
 	depends on ARCH_MXC && ARM64
drivers/clk/imx/Makefile +1 -0
index 3724ba7..928f874 100644
@@ -27,6 +27,7 @@ obj-$(CONFIG_MXC_CLK_SCU) += \
 
 obj-$(CONFIG_CLK_IMX8MM) += clk-imx8mm.o
 obj-$(CONFIG_CLK_IMX8MN) += clk-imx8mn.o
+obj-$(CONFIG_CLK_IMX8MP) += clk-imx8mp.o
 obj-$(CONFIG_CLK_IMX8MQ) += clk-imx8mq.o
 obj-$(CONFIG_CLK_IMX8QXP) += clk-imx8qxp.o clk-imx8qxp-lpcg.o
 
drivers/clk/imx/clk-imx8mp.c new file +767 -0

767 lines not on this page · raw message

Signature · 1 line
2.7.4
maintainer
#2 lore raw

Re: [PATCH 2/3] clk: imx: Add support for i.MX8MP clock driver

Quoting Anson Huang (2019-12-26 18:12:27)

drivers/clk/imx/clk-imx8mp.c line 7

Quoted 13 lines
drivers/clk/imx/clk-imx8mp.c new file +7 -0
new file mode 100644
index 0000000..7f0d482
@@ -0,0 +1,767 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2019 NXP.
+ */
+
+#include <dt-bindings/clock/imx8mp-clock.h>
+#include <linux/clk.h>

Please include clk-provider.h as this is a clk provider. If possible, don't include clk.h as this shouldn't be a consumer.

drivers/clk/imx/clk-imx8mp.c line 11

Quoted 4 lines
drivers/clk/imx/clk-imx8mp.c new file +4 -0
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>

Is this include used?

drivers/clk/imx/clk-imx8mp.c line 12

Quoted 1 line
drivers/clk/imx/clk-imx8mp.c new file +1 -0
+#include <linux/of_address.h>

Is this include used?

drivers/clk/imx/clk-imx8mp.c line 21

Quoted 9 lines
drivers/clk/imx/clk-imx8mp.c new file +9 -0
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
+#include "clk.h"
+
+static u32 share_count_nand;
+static u32 share_count_media;
+
+static const char *pll_ref_sels[] = { "osc_24m", "dummy", "dummy", "dummy", };

Is it possible to make these const char * const foo[] arrays?

Quoted 3 lines
drivers/clk/imx/clk-imx8mp.c new file +3 -0
+static const char *audio_pll1_bypass_sels[] = {"audio_pll1", "audio_pll1_ref_sel", };
+static const char *audio_pll2_bypass_sels[] = {"audio_pll2", "audio_pll2_ref_sel", };
+static const char *video_pll1_bypass_sels[] = {"video_pll1", "video_pll1_ref_sel", };

[...]

drivers/clk/imx/clk-imx8mp.c line 486

Quoted 10 lines
drivers/clk/imx/clk-imx8mp.c new file +10 -0
+       clk_set_parent(clks[IMX8MP_AUDIO_PLL1_BYPASS], clks[IMX8MP_AUDIO_PLL1]);
+       clk_set_parent(clks[IMX8MP_AUDIO_PLL2_BYPASS], clks[IMX8MP_AUDIO_PLL2]);
+       clk_set_parent(clks[IMX8MP_VIDEO_PLL1_BYPASS], clks[IMX8MP_VIDEO_PLL1]);
+       clk_set_parent(clks[IMX8MP_DRAM_PLL_BYPASS], clks[IMX8MP_DRAM_PLL]);
+       clk_set_parent(clks[IMX8MP_GPU_PLL_BYPASS], clks[IMX8MP_GPU_PLL]);
+       clk_set_parent(clks[IMX8MP_VPU_PLL_BYPASS], clks[IMX8MP_VPU_PLL]);
+       clk_set_parent(clks[IMX8MP_ARM_PLL_BYPASS], clks[IMX8MP_ARM_PLL]);
+       clk_set_parent(clks[IMX8MP_SYS_PLL1_BYPASS], clks[IMX8MP_SYS_PLL1]);
+       clk_set_parent(clks[IMX8MP_SYS_PLL2_BYPASS], clks[IMX8MP_SYS_PLL2]);
+       clk_set_parent(clks[IMX8MP_SYS_PLL3_BYPASS], clks[IMX8MP_SYS_PLL3]);

These can't be done with assigned-clock-parents properties in DT?

drivers/clk/imx/clk-imx8mp.c line 497

Quoted 11 lines
drivers/clk/imx/clk-imx8mp.c new file +11 -0
+
+       clks[IMX8MP_AUDIO_PLL1_OUT] = imx_clk_gate("audio_pll1_out", "audio_pll1_bypass", base, 13);
+       clks[IMX8MP_AUDIO_PLL2_OUT] = imx_clk_gate("audio_pll2_out", "audio_pll2_bypass", base + 0x14, 13);
+       clks[IMX8MP_VIDEO_PLL1_OUT] = imx_clk_gate("video_pll1_out", "video_pll1_bypass", base + 0x28, 13);
+       clks[IMX8MP_DRAM_PLL_OUT] = imx_clk_gate("dram_pll_out", "dram_pll_bypass", base + 0x50, 13);
+       clks[IMX8MP_GPU_PLL_OUT] = imx_clk_gate("gpu_pll_out", "gpu_pll_bypass", base + 0x64, 11);
+       clks[IMX8MP_VPU_PLL_OUT] = imx_clk_gate("vpu_pll_out", "vpu_pll_bypass", base + 0x74, 11);
+       clks[IMX8MP_ARM_PLL_OUT] = imx_clk_gate("arm_pll_out", "arm_pll_bypass", base + 0x84, 11);
+       clks[IMX8MP_SYS_PLL1_OUT] = imx_clk_gate("sys_pll1_out", "sys_pll1_bypass", base + 0x94, 11);
+       clks[IMX8MP_SYS_PLL2_OUT] = imx_clk_gate("sys_pll2_out", "sys_pll2_bypass", base + 0x104, 11);
+       clks[IMX8MP_SYS_PLL3_OUT] = imx_clk_gate("sys_pll3_out", "sys_pll3_bypass", base + 0x114, 11);

Any reason why we can't get back clk_hw pointers instead and register a hw based provider?

Quoted 16 lines
drivers/clk/imx/clk-imx8mp.c new file +16 -0
+
+       clks[IMX8MP_SYS_PLL1_40M] = imx_clk_fixed_factor("sys_pll1_40m", "sys_pll1_out", 1, 20);
+       clks[IMX8MP_SYS_PLL1_80M] = imx_clk_fixed_factor("sys_pll1_80m", "sys_pll1_out", 1, 10);
+       clks[IMX8MP_SYS_PLL1_100M] = imx_clk_fixed_factor("sys_pll1_100m", "sys_pll1_out", 1, 8);
+       clks[IMX8MP_SYS_PLL1_133M] = imx_clk_fixed_factor("sys_pll1_133m", "sys_pll1_out", 1, 6);
+       clks[IMX8MP_SYS_PLL1_160M] = imx_clk_fixed_factor("sys_pll1_160m", "sys_pll1_out", 1, 5);
+       clks[IMX8MP_SYS_PLL1_200M] = imx_clk_fixed_factor("sys_pll1_200m", "sys_pll1_out", 1, 4);
+       clks[IMX8MP_SYS_PLL1_266M] = imx_clk_fixed_factor("sys_pll1_266m", "sys_pll1_out", 1, 3);
+       clks[IMX8MP_SYS_PLL1_400M] = imx_clk_fixed_factor("sys_pll1_400m", "sys_pll1_out", 1, 2);
+       clks[IMX8MP_SYS_PLL1_800M] = imx_clk_fixed_factor("sys_pll1_800m", "sys_pll1_out", 1, 1);
+
+       clks[IMX8MP_SYS_PLL2_50M] = imx_clk_fixed_factor("sys_pll2_50m", "sys_pll2_out", 1, 20);
+       clks[IMX8MP_SYS_PLL2_100M] = imx_clk_fixed_factor("sys_pll2_100m", "sys_pll2_out", 1, 10);
+       clks[IMX8MP_SYS_PLL2_125M] = imx_clk_fixed_factor("sys_pll2_125m", "sys_pll2_out", 1, 8);
+       clks[IMX8MP_SYS_PLL2_166M] = imx_clk_fixed_factor("sys_pll2_166m", "sys_pll2_out", 1, 6);
+       clks[IMX8MP_SYS_PLL2_200M] = imx_clk_fixed_factor("sys_pll2_200m", "sys_pll2_out", 1, 5);

drivers/clk/imx/clk-imx8mp.c line 523

Quoted 10 lines
drivers/clk/imx/clk-imx8mp.c new file +10 -0
+       clks[IMX8MP_SYS_PLL2_250M] = imx_clk_fixed_factor("sys_pll2_250m", "sys_pll2_out", 1, 4);
+       clks[IMX8MP_SYS_PLL2_333M] = imx_clk_fixed_factor("sys_pll2_333m", "sys_pll2_out", 1, 3);
+       clks[IMX8MP_SYS_PLL2_500M] = imx_clk_fixed_factor("sys_pll2_500m", "sys_pll2_out", 1, 2);
+       clks[IMX8MP_SYS_PLL2_1000M] = imx_clk_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1);
+
+       np = dev->of_node;
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (WARN_ON(IS_ERR(base))) {
+               ret = PTR_ERR(base);
+               goto unregister_clks;

Why not ioremap first so we don't have to unwind clk registration on failure?

Quoted 9 lines
drivers/clk/imx/clk-imx8mp.c new file +9 -0
+       }
+
+       clks[IMX8MP_CLK_A53_SRC] = imx_clk_mux2("arm_a53_src", base + 0x8000, 24, 3, imx8mp_a53_sels, ARRAY_SIZE(imx8mp_a53_sels));
+       clks[IMX8MP_CLK_M7_SRC] = imx_clk_mux2("arm_m7_src", base + 0x8080, 24, 3, imx8mp_m7_sels, ARRAY_SIZE(imx8mp_m7_sels));
+       clks[IMX8MP_CLK_ML_SRC] = imx_clk_mux2("ml_src", base + 0x8100, 24, 3, imx8mp_ml_sels, ARRAY_SIZE(imx8mp_ml_sels));
+       clks[IMX8MP_CLK_GPU3D_CORE_SRC] = imx_clk_mux2("gpu3d_core_src", base + 0x8180, 24, 3,  imx8mp_gpu3d_core_sels, ARRAY_SIZE(imx8mp_gpu3d_core_sels));
+       clks[IMX8MP_CLK_GPU3D_SHADER_SRC] = imx_clk_mux2("gpu3d_shader_src", base + 0x8200, 24, 3, imx8mp_gpu3d_shader_sels, ARRAY_SIZE(imx8mp_gpu3d_shader_sels));
+       clks[IMX8MP_CLK_GPU2D_SRC] = imx_clk_mux2("gpu2d_src", base + 0x8280, 24, 3, imx8mp_gpu2d_sels, ARRAY_SIZE(imx8mp_gpu2d_sels));
+       clks[IMX8MP_CLK_AUDIO_AXI_SRC] = imx_clk_mux2("audio_axi_src", base + 0x8300, 24, 3, imx8mp_audio_axi_sels, ARRAY_SIZE(imx8mp_audio_axi_sels));

[...]

Quoted 4 lines
drivers/clk/imx/clk-imx8mp.c new file +4 -0
+
+       imx_register_uart_clocks(uart_clks);
+
+       return 0;

drivers/clk/imx/clk-imx8mp.c line 751

Quoted 10 lines
drivers/clk/imx/clk-imx8mp.c new file +10 -0
+
+unregister_clks:
+       imx_unregister_clocks(clks, ARRAY_SIZE(clks));
+
+       return ret;
+}
+
+static const struct of_device_id imx8mp_clk_of_match[] = {
+       { .compatible = "fsl,imx8mp-ccm" },
+       { /* Sentinel */ },

Please drop the comma after sentinel so that nothing can go after it.

Quoted 5 lines
drivers/clk/imx/clk-imx8mp.c new file +5 -0
+};
+MODULE_DEVICE_TABLE(of, imx8mp_clk_of_match);
+
+static struct platform_driver imx8mp_clk_driver = {
+       .probe = imx8mp_clocks_probe,
#3 lore raw

RE: [PATCH 2/3] clk: imx: Add support for i.MX8MP clock driver

Hi, Stephen

Quoted 19 lines

Subject: Re: [PATCH 2/3] clk: imx: Add support for i.MX8MP clock driver

Quoting Anson Huang (2019-12-26 18:12:27)

drivers/clk/imx/clk-imx8mp.c line 7

Quoted 13 lines
(quoted diff) +0 -0

b/drivers/clk/imx/clk-imx8mp.c new file mode 100644 index 0000000..7f0d482

drivers/clk/imx/clk-imx8mp.c new file +7 -0
@@ -0,0 +1,767 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2019 NXP.
+ */
+
+#include <dt-bindings/clock/imx8mp-clock.h>
+#include <linux/clk.h>

Please include clk-provider.h as this is a clk provider. If possible, don't include clk.h as this shouldn't be a consumer.

The reason of including clk.h is to call of_clk_get_by_name() to get some clocks from DT, currently on i.MX8M series SoC, we still NOT switch to hw based clock, so some hw based clock APIs is NOT able to be used.

Quoted 7 lines

drivers/clk/imx/clk-imx8mp.c line 11

Quoted 5 lines
drivers/clk/imx/clk-imx8mp.c new file +4 -0
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>

Is this include used?

Will remove it in V2.

Quoted 4 lines

drivers/clk/imx/clk-imx8mp.c line 12

Quoted 2 lines
drivers/clk/imx/clk-imx8mp.c new file +1 -0
+#include <linux/of_address.h>

Is this include used?

It is used by of_iomap for anatop_base below;

Quoted 13 lines

drivers/clk/imx/clk-imx8mp.c

Quoted 11 lines
drivers/clk/imx/clk-imx8mp.c new file +10 -0
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
+#include "clk.h"
+
+static u32 share_count_nand;
+static u32 share_count_media;
+
+static const char *pll_ref_sels[] = { "osc_24m", "dummy", "dummy",
+"dummy", };

Is it possible to make these const char * const foo[] arrays?

Will improve it in V2.

Quoted 20 lines
Quoted 5 lines
drivers/clk/imx/clk-imx8mp.c new file +4 -0
+static const char *audio_pll1_bypass_sels[] = {"audio_pll1",
+"audio_pll1_ref_sel", }; static const char *audio_pll2_bypass_sels[]
+= {"audio_pll2", "audio_pll2_ref_sel", }; static const char
+*video_pll1_bypass_sels[] = {"video_pll1", "video_pll1_ref_sel", };

[...]

Quoted 1 line

+ clk_set_parent(clks[IMX8MP_AUDIO_PLL1_BYPASS],

clks[IMX8MP_AUDIO_PLL1]);

Quoted 1 line

+ clk_set_parent(clks[IMX8MP_AUDIO_PLL2_BYPASS],

clks[IMX8MP_AUDIO_PLL2]);

Quoted 1 line

+ clk_set_parent(clks[IMX8MP_VIDEO_PLL1_BYPASS],

clks[IMX8MP_VIDEO_PLL1]);

Quoted 1 line

+ clk_set_parent(clks[IMX8MP_DRAM_PLL_BYPASS],

clks[IMX8MP_DRAM_PLL]);

Quoted 1 line

+ clk_set_parent(clks[IMX8MP_GPU_PLL_BYPASS],

clks[IMX8MP_GPU_PLL]);

Quoted 1 line

+ clk_set_parent(clks[IMX8MP_VPU_PLL_BYPASS],

clks[IMX8MP_VPU_PLL]);

Quoted 1 line

+ clk_set_parent(clks[IMX8MP_ARM_PLL_BYPASS],

clks[IMX8MP_ARM_PLL]);

Quoted 8 lines
Quoted 1 line

+ clk_set_parent(clks[IMX8MP_SYS_PLL1_BYPASS],

clks[IMX8MP_SYS_PLL1]);

Quoted 1 line

+ clk_set_parent(clks[IMX8MP_SYS_PLL2_BYPASS],

clks[IMX8MP_SYS_PLL2]);

Quoted 2 lines

+ clk_set_parent(clks[IMX8MP_SYS_PLL3_BYPASS],
+ clks[IMX8MP_SYS_PLL3]);

These can't be done with assigned-clock-parents properties in DT?

Ah, yes, will remove them and put them in DT is necessary.

Quoted 17 lines

drivers/clk/imx/clk-imx8mp.c

Quoted 3 lines
drivers/clk/imx/clk-imx8mp.c new file +2 -0
+
+       clks[IMX8MP_AUDIO_PLL1_OUT] = imx_clk_gate("audio_pll1_out",

"audio_pll1_bypass", base, 13);

Quoted 1 line

+ clks[IMX8MP_AUDIO_PLL2_OUT] = imx_clk_gate("audio_pll2_out",

"audio_pll2_bypass", base + 0x14, 13);

Quoted 1 line

+ clks[IMX8MP_VIDEO_PLL1_OUT] = imx_clk_gate("video_pll1_out",

"video_pll1_bypass", base + 0x28, 13);

Quoted 1 line

+ clks[IMX8MP_DRAM_PLL_OUT] = imx_clk_gate("dram_pll_out",

"dram_pll_bypass", base + 0x50, 13);

Quoted 1 line

+ clks[IMX8MP_GPU_PLL_OUT] = imx_clk_gate("gpu_pll_out",

"gpu_pll_bypass", base + 0x64, 11);

Quoted 1 line

+ clks[IMX8MP_VPU_PLL_OUT] = imx_clk_gate("vpu_pll_out",

"vpu_pll_bypass", base + 0x74, 11);

Quoted 1 line

+ clks[IMX8MP_ARM_PLL_OUT] = imx_clk_gate("arm_pll_out",

"arm_pll_bypass", base + 0x84, 11);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL1_OUT] = imx_clk_gate("sys_pll1_out",

Quoted 8 lines

"sys_pll1_bypass", base + 0x94, 11);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL2_OUT] = imx_clk_gate("sys_pll2_out",

"sys_pll2_bypass", base + 0x104, 11);

Quoted 2 lines

+ clks[IMX8MP_SYS_PLL3_OUT] = imx_clk_gate("sys_pll3_out",
+ "sys_pll3_bypass", base + 0x114, 11);

Any reason why we can't get back clk_hw pointers instead and register a hw based provider?

Because i.MX8M series SoCs are still NOT using hw based clock implementation, some of the APIs are shared, like imx_clk_pll14xx() and imx8m_clk_composite() etc., so I think it is better to keep them(i.MX8MQ/i.MX8MM/i.MX8MN/i.MX8MP) aligned, and I will find a chance soon to do a patch series to switch all of them to hw based clock, does it make sense to you?

Quoted 46 lines

drivers/clk/imx/clk-imx8mp.c

Quoted 3 lines
drivers/clk/imx/clk-imx8mp.c new file +2 -0
+
+       clks[IMX8MP_SYS_PLL1_40M] = imx_clk_fixed_factor("sys_pll1_40m",

"sys_pll1_out", 1, 20);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL1_80M] = imx_clk_fixed_factor("sys_pll1_80m",

"sys_pll1_out", 1, 10);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL1_100M] =

imx_clk_fixed_factor("sys_pll1_100m", "sys_pll1_out", 1, 8);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL1_133M] =

imx_clk_fixed_factor("sys_pll1_133m", "sys_pll1_out", 1, 6);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL1_160M] =

imx_clk_fixed_factor("sys_pll1_160m", "sys_pll1_out", 1, 5);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL1_200M] =

imx_clk_fixed_factor("sys_pll1_200m", "sys_pll1_out", 1, 4);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL1_266M] =

imx_clk_fixed_factor("sys_pll1_266m", "sys_pll1_out", 1, 3);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL1_400M] =

imx_clk_fixed_factor("sys_pll1_400m", "sys_pll1_out", 1, 2);

drivers/clk/imx/clk-imx8mp.c

Quoted 4 lines
drivers/clk/imx/clk-imx8mp.c new file +4 -0
+       clks[IMX8MP_SYS_PLL1_800M] =
+ imx_clk_fixed_factor("sys_pll1_800m", "sys_pll1_out", 1, 1);
+
+       clks[IMX8MP_SYS_PLL2_50M] = imx_clk_fixed_factor("sys_pll2_50m",

"sys_pll2_out", 1, 20);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL2_100M] =

imx_clk_fixed_factor("sys_pll2_100m", "sys_pll2_out", 1, 10);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL2_125M] =

imx_clk_fixed_factor("sys_pll2_125m", "sys_pll2_out", 1, 8);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL2_166M] =

imx_clk_fixed_factor("sys_pll2_166m", "sys_pll2_out", 1, 6);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL2_200M] =

imx_clk_fixed_factor("sys_pll2_200m", "sys_pll2_out", 1, 5);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL2_250M] =

imx_clk_fixed_factor("sys_pll2_250m", "sys_pll2_out", 1, 4);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL2_333M] =

imx_clk_fixed_factor("sys_pll2_333m", "sys_pll2_out", 1, 3);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL2_500M] =

imx_clk_fixed_factor("sys_pll2_500m", "sys_pll2_out", 1, 2);

drivers/clk/imx/clk-imx8mp.c line 523

Quoted 8 lines
drivers/clk/imx/clk-imx8mp.c new file +8 -0
+       clks[IMX8MP_SYS_PLL2_1000M] =
+ imx_clk_fixed_factor("sys_pll2_1000m", "sys_pll2_out", 1, 1);
+
+       np = dev->of_node;
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (WARN_ON(IS_ERR(base))) {
+               ret = PTR_ERR(base);
+               goto unregister_clks;
Quoted 1 line

Why not ioremap first so we don't have to unwind clk registration on failure?

Yes, I will do it in V2.

Quoted 21 lines

drivers/clk/imx/clk-imx8mp.c

Quoted 4 lines
drivers/clk/imx/clk-imx8mp.c new file +3 -0
+       }
+
+       clks[IMX8MP_CLK_A53_SRC] = imx_clk_mux2("arm_a53_src", base +

0x8000, 24, 3, imx8mp_a53_sels, ARRAY_SIZE(imx8mp_a53_sels));

Quoted 1 line

+ clks[IMX8MP_CLK_M7_SRC] = imx_clk_mux2("arm_m7_src", base +

0x8080, 24, 3, imx8mp_m7_sels, ARRAY_SIZE(imx8mp_m7_sels));

Quoted 1 line

+ clks[IMX8MP_CLK_ML_SRC] = imx_clk_mux2("ml_src", base + 0x8100,

24, 3, imx8mp_ml_sels, ARRAY_SIZE(imx8mp_ml_sels));

Quoted 1 line

+ clks[IMX8MP_CLK_GPU3D_CORE_SRC] =

imx_clk_mux2("gpu3d_core_src", base + 0x8180, 24, 3, imx8mp_gpu3d_core_sels, ARRAY_SIZE(imx8mp_gpu3d_core_sels));

Quoted 1 line

+ clks[IMX8MP_CLK_GPU3D_SHADER_SRC] =

imx_clk_mux2("gpu3d_shader_src", base + 0x8200, 24, 3, imx8mp_gpu3d_shader_sels, ARRAY_SIZE(imx8mp_gpu3d_shader_sels));

Quoted 1 line

+ clks[IMX8MP_CLK_GPU2D_SRC] = imx_clk_mux2("gpu2d_src", base +

0x8280, 24, 3, imx8mp_gpu2d_sels, ARRAY_SIZE(imx8mp_gpu2d_sels));

Quoted 3 lines

+ clks[IMX8MP_CLK_AUDIO_AXI_SRC] = imx_clk_mux2("audio_axi_src",
+ base + 0x8300, 24, 3, imx8mp_audio_axi_sels,
+ ARRAY_SIZE(imx8mp_audio_axi_sels));

[...]

Quoted 16 lines
Quoted 4 lines
drivers/clk/imx/clk-imx8mp.c new file +4 -0
+
+       imx_register_uart_clocks(uart_clks);
+
+       return 0;

drivers/clk/imx/clk-imx8mp.c line 751

Quoted 10 lines
drivers/clk/imx/clk-imx8mp.c new file +10 -0
+
+unregister_clks:
+       imx_unregister_clocks(clks, ARRAY_SIZE(clks));
+
+       return ret;
+}
+
+static const struct of_device_id imx8mp_clk_of_match[] = {
+       { .compatible = "fsl,imx8mp-ccm" },
+       { /* Sentinel */ },

Please drop the comma after sentinel so that nothing can go after it.

Will do it in V2.

Thanks,
Anson

#4 lore raw

RE: [PATCH 2/3] clk: imx: Add support for i.MX8MP clock driver

Hi, Stephen

Quoted 24 lines
Quoted 15 lines
Quoted 1 line

+ clks[IMX8MP_AUDIO_PLL1_OUT] = imx_clk_gate("audio_pll1_out",

"audio_pll1_bypass", base, 13);

Quoted 1 line

+ clks[IMX8MP_AUDIO_PLL2_OUT] = imx_clk_gate("audio_pll2_out",

"audio_pll2_bypass", base + 0x14, 13);

Quoted 1 line

+ clks[IMX8MP_VIDEO_PLL1_OUT] = imx_clk_gate("video_pll1_out",

"video_pll1_bypass", base + 0x28, 13);

Quoted 1 line

+ clks[IMX8MP_DRAM_PLL_OUT] = imx_clk_gate("dram_pll_out",

"dram_pll_bypass", base + 0x50, 13);

Quoted 1 line

+ clks[IMX8MP_GPU_PLL_OUT] = imx_clk_gate("gpu_pll_out",

"gpu_pll_bypass", base + 0x64, 11);

Quoted 1 line

+ clks[IMX8MP_VPU_PLL_OUT] = imx_clk_gate("vpu_pll_out",

"vpu_pll_bypass", base + 0x74, 11);

Quoted 1 line

+ clks[IMX8MP_ARM_PLL_OUT] = imx_clk_gate("arm_pll_out",

"arm_pll_bypass", base + 0x84, 11);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL1_OUT] = imx_clk_gate("sys_pll1_out",

Quoted 8 lines

"sys_pll1_bypass", base + 0x94, 11);

Quoted 1 line

+ clks[IMX8MP_SYS_PLL2_OUT] = imx_clk_gate("sys_pll2_out",

"sys_pll2_bypass", base + 0x104, 11);

Quoted 2 lines

+ clks[IMX8MP_SYS_PLL3_OUT] = imx_clk_gate("sys_pll3_out",
+ "sys_pll3_bypass", base + 0x114, 11);

Any reason why we can't get back clk_hw pointers instead and register a hw based provider?

Quoted 6 lines

Because i.MX8M series SoCs are still NOT using hw based clock implementation, some of the APIs are shared, like imx_clk_pll14xx() and imx8m_clk_composite() etc., so I think it is better to keep them(i.MX8MQ/i.MX8MM/i.MX8MN/i.MX8MP) aligned, and I will find a chance soon to do a patch series to switch all of them to hw based clock, does it make sense to you?

Please ignore this, I will do necessary patches together in this series to support hw clk based provider for i.MX8M SoCs, i.MX8MP will use hw based provider, and old i.MX8M SoCs will be handled later with separate patch.

Thanks,
Anson
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#5 lore raw

PATCH 3/3 arm64: defconfig: Enable CONFIG_CLK_IMX8MP by default

In reply to Anson Huang

Select CONFIG_CLK_IMX8MP by default to support i.MX8MP clock driver.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index c7a94c4ff..8d9b9ce 100644
@@ -701,6 +701,7 @@ CONFIG_COMMON_CLK_PWM=y
 CONFIG_CLK_RASPBERRYPI=m
 CONFIG_CLK_IMX8MM=y
 CONFIG_CLK_IMX8MN=y
+CONFIG_CLK_IMX8MP=y
 CONFIG_CLK_IMX8MQ=y
 CONFIG_CLK_IMX8QXP=y
 CONFIG_TI_SCI_CLK=y
Signature · 1 line
2.7.4
maintainer
#6 lore raw
In reply to Anson Huang

Quoting Anson Huang (2019-12-26 18:12:26)

Quoted 39 lines
Documentation/devicetree/bindings/clock/imx8mp-clock.yaml new file +33 -0
new file mode 100644
index 0000000..5e01995
@@ -0,0 +1,112 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bindings/clock/imx8mp-clock.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NXP i.MX8M Plus Clock Control Module Binding
+
+maintainers:
+  - Anson Huang <[email protected]>
+
+description: |
+  NXP i.MX8M Plus clock control module is an integrated clock controller, which
+  generates and supplies to all modules.
+
+properties:
+  compatible:
+    const: fsl,imx8mp-ccm
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    items:
+      - description: 32k osc
+      - description: 24m osc
+      - description: ext1 clock input
+      - description: ext2 clock input
+      - description: ext3 clock input
+      - description: ext4 clock input
+
+  clock-names:
+    items:

Documentation/devicetree/bindings/clock/imx8mp-clock.yaml line 43

Quoted 10 lines
Documentation/devicetree/bindings/clock/imx8mp-clock.yaml new file +10 -0
+      - const: osc_32k
+      - const: osc_24m
+      - const: clk_ext1
+      - const: clk_ext2
+      - const: clk_ext3
+      - const: clk_ext4
+
+  '#clock-cells':
+    const: 1
+    description: |

I think we can drop the bar here. Newlines shouldn't matter.

Quoted 22 lines
Documentation/devicetree/bindings/clock/imx8mp-clock.yaml new file +22 -0
+      The clock consumer should specify the desired clock by having the clock
+      ID in its "clocks" phandle cell. See include/dt-bindings/clock/imx8mp-clock.h
+      for the full list of i.MX8M Plus clock IDs.
+
+required:
+  - compatible
+  - reg
+  - clocks
+  - clock-names
+  - '#clock-cells'
+
+examples:
+  # Clock Control Module node:
+  - |
+    clk: clock-controller@30380000 {
+        compatible = "fsl,imx8mp-ccm";
+        reg = <0x30380000 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";

Documentation/devicetree/bindings/clock/imx8mp-clock.yaml line 75

Quoted 10 lines
Documentation/devicetree/bindings/clock/imx8mp-clock.yaml new file +10 -0
+    };
+
+  # Required external clocks for Clock Control Module node:
+  - |
+    osc_32k: clock-osc-32k {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <32768>;
+        clock-output-names = "osc_32k";
+    };

Do we need these in the example? They don't seem too useful.

Quoted 12 lines
Documentation/devicetree/bindings/clock/imx8mp-clock.yaml new file +12 -0
+
+    osc_24m: clock-osc-24m {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <24000000>;
+        clock-output-names = "osc_24m";
+    };
+
+    clk_ext1: clock-ext1 {
+        compatible = "fixed-clock";
+        #clock-cells = <0>;
+        clock-frequency = <133000000>;