Skip to contentSkip to conversation

MediaTek MT8188 clock support

PATCH Superseded Garmin.Chang 5 participants 55 messages Jan 19, 2023 – Mar 9, 2023

Subsystems (5)

v5 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v5 cover MediaTek MT8188 clock support

Base on tag: next-20230119, linux-next/master

changes since v4:
- modify yaml file
- modify infrastructure clock

Garmin.Chang (19):
dt-bindings: clock: mediatek: Add new MT8188 clock
clk: mediatek: Add MT8188 apmixedsys clock support
clk: mediatek: Add MT8188 topckgen clock support
clk: mediatek: Add MT8188 peripheral clock support
clk: mediatek: Add MT8188 infrastructure clock support
clk: mediatek: Add MT8188 camsys clock support
clk: mediatek: Add MT8188 ccusys clock support
clk: mediatek: Add MT8188 imgsys clock support
clk: mediatek: Add MT8188 ipesys clock support
clk: mediatek: Add MT8188 mfgcfg clock support
clk: mediatek: Add MT8188 vdecsys clock support
clk: mediatek: Add MT8188 vdosys0 clock support
clk: mediatek: Add MT8188 vdosys1 clock support
clk: mediatek: Add MT8188 vencsys clock support
clk: mediatek: Add MT8188 vppsys0 clock support
clk: mediatek: Add MT8188 vppsys1 clock support
clk: mediatek: Add MT8188 wpesys clock support
clk: mediatek: Add MT8188 imp i2c wrapper clock support
clk: mediatek: Add MT8188 adsp clock support

 .../bindings/clock/mediatek,mt8188-clock.yaml |   71 +
 .../clock/mediatek,mt8188-sys-clock.yaml      |   55 +
 drivers/clk/mediatek/Kconfig                  |   11 +
 drivers/clk/mediatek/Makefile                 |    7 +
 .../clk/mediatek/clk-mt8188-adsp_audio26m.c   |   45 +
 drivers/clk/mediatek/clk-mt8188-apmixedsys.c  |  154 ++
 drivers/clk/mediatek/clk-mt8188-cam.c         |  118 ++
 drivers/clk/mediatek/clk-mt8188-ccu.c         |   48 +
 drivers/clk/mediatek/clk-mt8188-img.c         |  110 ++
 .../clk/mediatek/clk-mt8188-imp_iic_wrap.c    |   78 +
 drivers/clk/mediatek/clk-mt8188-infra_ao.c    |  196 +++
 drivers/clk/mediatek/clk-mt8188-ipe.c         |   50 +
 drivers/clk/mediatek/clk-mt8188-mfg.c         |   47 +
 drivers/clk/mediatek/clk-mt8188-peri_ao.c     |   56 +
 drivers/clk/mediatek/clk-mt8188-topckgen.c    | 1352 +++++++++++++++++
 drivers/clk/mediatek/clk-mt8188-vdec.c        |   90 ++
 drivers/clk/mediatek/clk-mt8188-vdo0.c        |  134 ++
 drivers/clk/mediatek/clk-mt8188-vdo1.c        |  181 +++
 drivers/clk/mediatek/clk-mt8188-venc.c        |   52 +
 drivers/clk/mediatek/clk-mt8188-vpp0.c        |  143 ++
 drivers/clk/mediatek/clk-mt8188-vpp1.c        |  138 ++
 drivers/clk/mediatek/clk-mt8188-wpe.c         |  101 ++
 .../dt-bindings/clock/mediatek,mt8188-clk.h   |  733 +++++++++
 23 files changed, 3970 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mt8188-clock.yaml
 create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mt8188-sys-clock.yaml
 create mode 100644 drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-apmixedsys.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-cam.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-ccu.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-img.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-imp_iic_wrap.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-infra_ao.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-ipe.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-mfg.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-peri_ao.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-topckgen.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdec.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo0.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo1.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-venc.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp0.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp1.c
 create mode 100644 drivers/clk/mediatek/clk-mt8188-wpe.c
 create mode 100644 include/dt-bindings/clock/mediatek,mt8188-clk.h
Signature · 1 line
2.18.0
#1 lore raw

PATCH v5 1/19 dt-bindings: clock: mediatek: Add new MT8188 clock

Add the new binding documentation for system clock and functional clock on MediaTek MT8188.

---
 .../bindings/clock/mediatek,mt8188-clock.yaml |  71 ++
 .../clock/mediatek,mt8188-sys-clock.yaml      |  55 ++
 .../dt-bindings/clock/mediatek,mt8188-clk.h   | 733 ++++++++++++++++++
 3 files changed, 859 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mt8188-clock.yaml
 create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mt8188-sys-clock.yaml
 create mode 100644 include/dt-bindings/clock/mediatek,mt8188-clk.h
Documentation/devicetree/bindings/clock/mediatek,mt8188-clock.yaml new file +71 -0
new file mode 100644
index 000000000000..d7214d97b2ba
@@ -0,0 +1,71 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/clock/mediatek,mt8188-clock.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek Functional Clock Controller for MT8188
+
+maintainers:
+  - Garmin Chang <[email protected]>
+
+description: |
+  The clock architecture in MediaTek like below
+  PLLs -->
+          dividers -->
+                      muxes
+                           -->
+                              clock gate
+
+  The devices provide clock gate control in different IP blocks.
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt8188-adsp-audio26m
+      - mediatek,mt8188-camsys
+      - mediatek,mt8188-camsys-rawa
+      - mediatek,mt8188-camsys-rawb
+      - mediatek,mt8188-camsys-yuva
+      - mediatek,mt8188-camsys-yuvb
+      - mediatek,mt8188-ccusys
+      - mediatek,mt8188-imgsys
+      - mediatek,mt8188-imgsys-wpe1
+      - mediatek,mt8188-imgsys-wpe2
+      - mediatek,mt8188-imgsys-wpe3
+      - mediatek,mt8188-imgsys1-dip-nr
+      - mediatek,mt8188-imgsys1-dip-top
+      - mediatek,mt8188-imp-iic-wrap-c
+      - mediatek,mt8188-imp-iic-wrap-en
+      - mediatek,mt8188-imp-iic-wrap-w
+      - mediatek,mt8188-ipesys
+      - mediatek,mt8188-mfgcfg
+      - mediatek,mt8188-vdecsys
+      - mediatek,mt8188-vdecsys-soc
+      - mediatek,mt8188-vencsys
+      - mediatek,mt8188-vppsys0
+      - mediatek,mt8188-vppsys1
+      - mediatek,mt8188-wpesys
+      - mediatek,mt8188-wpesys-vpp0
+
+  reg:
+    maxItems: 1
+
+  '#clock-cells':
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - '#clock-cells'
+
+additionalProperties: false
+
+examples:
+  - |
+    clock-controller@11283000 {
+        compatible = "mediatek,mt8188-imp-iic-wrap-c";
+        reg = <0x11283000 0x1000>;
+        #clock-cells = <1>;
+    };
+
Documentation/devicetree/bindings/clock/mediatek,mt8188-sys-clock.yaml new file +55 -0

55 lines not on this page · raw message

include/dt-bindings/clock/mediatek,mt8188-clk.h new file +733 -0

733 lines not on this page · raw message

Signature · 1 line
2.18.0
Reviewed-by on v5 1/19
#2 lore raw

Re: [PATCH v5 01/19] dt-bindings: clock: mediatek: Add new MT8188 clock

Quoted 9 lines · Garmin.Chang

Add the new binding documentation for system clock and functional clock on MediaTek MT8188.

---
 .../bindings/clock/mediatek,mt8188-clock.yaml |  71 ++
 .../clock/mediatek,mt8188-sys-clock.yaml      |  55 ++
 .../dt-bindings/clock/mediatek,mt8188-clk.h   | 733 ++++++++++++++++++
 3 files changed, 859 insertions(+)

Best regards,
Krzysztof

#3 lore raw

PATCH v5 2/19 clk: mediatek: Add MT8188 apmixedsys clock support

In reply to Garmin.Chang

Add MT8188 apmixedsys clock controller which provides Plls generated from SoC 26m and ssusb clock gate control.

---
 drivers/clk/mediatek/Kconfig                 |  11 ++
 drivers/clk/mediatek/Makefile                |   1 +
 drivers/clk/mediatek/clk-mt8188-apmixedsys.c | 154 +++++++++++++++++++
 3 files changed, 166 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-apmixedsys.c
drivers/clk/mediatek/Kconfig +11 -0
index 22e8e79475ee..f02b679f71d0 100644
@@ -565,6 +565,17 @@ config COMMON_CLK_MT8186
 	help
 	  This driver supports MediaTek MT8186 clocks.
 
+config COMMON_CLK_MT8188
+	bool "Clock driver for MediaTek MT8188"
+	depends on ARM64 || COMPILE_TEST
+	select COMMON_CLK_MEDIATEK
+	default ARCH_MEDIATEK
+	help
+	  This driver supports MediaTek MT8188 basic clocks and clocks
+	  required for various peripheral found on MediaTek. Choose
+	  M or Y here if you want to use clocks such as peri_ao,
+	  infra_ao, etc.
+
 config COMMON_CLK_MT8192
 	bool "Clock driver for MediaTek MT8192"
 	depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index e24080fd6e7f..13ab8deb362c 100644
@@ -83,6 +83,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 				   clk-mt8186-mfg.o clk-mt8186-mm.o clk-mt8186-wpe.o \
 				   clk-mt8186-img.o clk-mt8186-vdec.o clk-mt8186-venc.o \
 				   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
+obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +154 -0

154 lines not on this page · raw message

Signature · 1 line
2.18.0
#4 lore raw

Re: [PATCH v5 02/19] clk: mediatek: Add MT8188 apmixedsys clock support

Quoted 154 lines · Garmin.Chang

Add MT8188 apmixedsys clock controller which provides Plls generated from SoC 26m and ssusb clock gate control.

---
 drivers/clk/mediatek/Kconfig                 |  11 ++
 drivers/clk/mediatek/Makefile                |   1 +
 drivers/clk/mediatek/clk-mt8188-apmixedsys.c | 154 +++++++++++++++++++
 3 files changed, 166 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-apmixedsys.c
drivers/clk/mediatek/Kconfig +11 -0
index 22e8e79475ee..f02b679f71d0 100644
@@ -565,6 +565,17 @@ config COMMON_CLK_MT8186
        help
          This driver supports MediaTek MT8186 clocks.
 
+config COMMON_CLK_MT8188
+       bool "Clock driver for MediaTek MT8188"
+       depends on ARM64 || COMPILE_TEST
+       select COMMON_CLK_MEDIATEK
+       default ARCH_MEDIATEK
+       help
+         This driver supports MediaTek MT8188 basic clocks and clocks
+         required for various peripheral found on MediaTek. Choose
+         M or Y here if you want to use clocks such as peri_ao,
+         infra_ao, etc.
+
 config COMMON_CLK_MT8192
        bool "Clock driver for MediaTek MT8192"
        depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index e24080fd6e7f..13ab8deb362c 100644
@@ -83,6 +83,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
                                   clk-mt8186-mfg.o clk-mt8186-mm.o clk-mt8186-wpe.o \
                                   clk-mt8186-img.o clk-mt8186-vdec.o clk-mt8186-venc.o \
                                   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
+obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +102 -0
new file mode 100644
index 000000000000..8d73ae3a0da8
@@ -0,0 +1,154 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "clk-pll.h"
+
+static const struct mtk_gate_regs apmixed_cg_regs = {
+       .set_ofs = 0x8,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x8,
+};
+
+#define GATE_APMIXED(_id, _name, _parent, _shift)                      \
+       GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+static const struct mtk_gate apmixed_clks[] = {
+       GATE_APMIXED(CLK_APMIXED_PLL_SSUSB26M_EN, "pll_ssusb26m_en", "clk26m", 1),
+};
+
+#define MT8188_PLL_FMAX                (3800UL * MHZ)
+#define MT8188_PLL_FMIN                (1500UL * MHZ)
+#define MT8188_INTEGER_BITS    8
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask, _flags,              \
+           _rst_bar_mask, _pcwbits, _pd_reg, _pd_shift,                \
+           _tuner_reg, _tuner_en_reg, _tuner_en_bit,                   \
+           _pcw_reg, _pcw_shift, _pcw_chg_reg,                         \
+           _en_reg, _pll_en_bit) {                                     \
+               .id = _id,                                              \
+               .name = _name,                                          \
+               .reg = _reg,                                            \
+               .pwr_reg = _pwr_reg,                                    \
+               .en_mask = _en_mask,                                    \
+               .flags = _flags,                                        \
+               .rst_bar_mask = _rst_bar_mask,                          \
+               .fmax = MT8188_PLL_FMAX,                                \
+               .fmin = MT8188_PLL_FMIN,                                \
+               .pcwbits = _pcwbits,                                    \
+               .pcwibits = MT8188_INTEGER_BITS,                        \
+               .pd_reg = _pd_reg,                                      \
+               .pd_shift = _pd_shift,                                  \
+               .tuner_reg = _tuner_reg,                                \
+               .tuner_en_reg = _tuner_en_reg,                          \
+               .tuner_en_bit = _tuner_en_bit,                          \
+               .pcw_reg = _pcw_reg,                                    \
+               .pcw_shift = _pcw_shift,                                \
+               .pcw_chg_reg = _pcw_chg_reg,                            \
+               .en_reg = _en_reg,                                      \
+               .pll_en_bit = _pll_en_bit,                              \
+       }
+
+static const struct mtk_pll_data plls[] = {
+       PLL(CLK_APMIXED_ETHPLL, "ethpll", 0x044C, 0x0458, 0,
+           0, 0, 22, 0x0450, 24, 0, 0, 0, 0x0450, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0514, 0x0520, 0,
+           0, 0, 22, 0x0518, 24, 0, 0, 0, 0x0518, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_TVDPLL1, "tvdpll1", 0x0524, 0x0530, 0,
+           0, 0, 22, 0x0528, 24, 0, 0, 0, 0x0528, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_TVDPLL2, "tvdpll2", 0x0534, 0x0540, 0,
+           0, 0, 22, 0x0538, 24, 0, 0, 0, 0x0538, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0544, 0x0550, 0xff000000,
+           HAVE_RST_BAR, BIT(23), 22, 0x0548, 24, 0, 0, 0, 0x0548, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x045C, 0x0468, 0xff000000,
+           HAVE_RST_BAR, BIT(23), 22, 0x0460, 24, 0, 0, 0, 0x0460, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_IMGPLL, "imgpll", 0x0554, 0x0560, 0,
+           0, 0, 22, 0x0558, 24, 0, 0, 0, 0x0558, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0504, 0x0510, 0xff000000,
+           HAVE_RST_BAR, BIT(23), 22, 0x0508, 24, 0, 0, 0, 0x0508, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_ADSPPLL, "adsppll", 0x042C, 0x0438, 0,
+           0, 0, 22, 0x0430, 24, 0, 0, 0, 0x0430, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL1, "apll1", 0x0304, 0x0314, 0,
+           0, 0, 32, 0x0308, 24, 0x0034, 0x0000, 12, 0x030C, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL2, "apll2", 0x0318, 0x0328, 0,
+           0, 0, 32, 0x031C, 24, 0x0038, 0x0000, 13, 0x0320, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL3, "apll3", 0x032C, 0x033C, 0,
+           0, 0, 32, 0x0330, 24, 0x003C, 0x0000, 14, 0x0334, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL4, "apll4", 0x0404, 0x0414, 0,
+           0, 0, 32, 0x0408, 24, 0x0040, 0x0000, 15, 0x040C, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL5, "apll5", 0x0418, 0x0428, 0,
+           0, 0, 32, 0x041C, 24, 0x0044, 0x0000, 16, 0x0420, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0340, 0x034C, 0,
+           0, 0, 22, 0x0344, 24, 0, 0, 0, 0x0344, 0, 0, 0, 9),
+};
+
+static const struct of_device_id of_match_clk_mt8188_apmixed[] = {
+       { .compatible = "mediatek,mt8188-apmixedsys", },
+       {}
+};
+
+static int clk_mt8188_apmixed_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       int r;
+

drivers/clk/mediatek/clk-mt8188-apmixedsys.c line 112

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +10 -0
+       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls), clk_data);
+       if (r)
+               goto free_apmixed_data;
+
+       r = mtk_clk_register_gates_with_dev(node, apmixed_clks,
+               ARRAY_SIZE(apmixed_clks), clk_data, NULL);

This API is gone. Please replace it with mtk_clk_register_clks. And please pass in the |struct device| pointer.

ChenYu

#5 lore raw

Re: [PATCH v5 02/19] clk: mediatek: Add MT8188 apmixedsys clock support

Quoted 220 lines · Chen-Yu Tsai
Quoted 208 lines · Garmin.Chang

Add MT8188 apmixedsys clock controller which provides Plls generated from SoC 26m and ssusb clock gate control.

---
 drivers/clk/mediatek/Kconfig                 |  11 ++
 drivers/clk/mediatek/Makefile                |   1 +
 drivers/clk/mediatek/clk-mt8188-apmixedsys.c | 154
+++++++++++++++++++
 3 files changed, 166 insertions(+)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-apmixedsys.c
drivers/clk/mediatek/Kconfig +7 -0
index 22e8e79475ee..f02b679f71d0 100644
@@ -565,6 +565,17 @@ config COMMON_CLK_MT8186
        help
          This driver supports MediaTek MT8186 clocks.
 
+config COMMON_CLK_MT8188
+       bool "Clock driver for MediaTek MT8188"
+       depends on ARM64 || COMPILE_TEST
+       select COMMON_CLK_MEDIATEK
+       default ARCH_MEDIATEK
+       help
+         This driver supports MediaTek MT8188 basic clocks and

clocks

drivers/clk/mediatek/Kconfig +4 -0
+         required for various peripheral found on MediaTek. Choose
+         M or Y here if you want to use clocks such as peri_ao,
+         infra_ao, etc.
+
 config COMMON_CLK_MT8192
        bool "Clock driver for MediaTek MT8192"
        depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +0 -0
index e24080fd6e7f..13ab8deb362c 100644
@@ -83,6 +83,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-

mcu.o clk-mt8186-topckgen.o clk-mt

                                   clk-mt8186-mfg.o clk-mt8186-mm.o 
clk-mt8186-wpe.o \
                                   clk-mt8186-img.o clk-mt8186-
vdec.o clk-mt8186-venc.o \
                                   clk-mt8186-cam.o clk-mt8186-

mdp.o clk-mt8186-ipe.o

drivers/clk/mediatek/Makefile +1 -0
+obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +20 -0
new file mode 100644
index 000000000000..8d73ae3a0da8
@@ -0,0 +1,154 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "clk-pll.h"
+
+static const struct mtk_gate_regs apmixed_cg_regs = {
+       .set_ofs = 0x8,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x8,
+};
+
+#define GATE_APMIXED(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &apmixed_cg_regs, _shift,
&mtk_clk_gate_ops_no_setclr_inv)

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +3 -0
+
+static const struct mtk_gate apmixed_clks[] = {
+       GATE_APMIXED(CLK_APMIXED_PLL_SSUSB26M_EN,

"pll_ssusb26m_en", "clk26m", 1),

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +7 -0
+};
+
+#define MT8188_PLL_FMAX                (3800UL * MHZ)
+#define MT8188_PLL_FMIN                (1500UL * MHZ)
+#define MT8188_INTEGER_BITS    8
+
+#define PLL(_id, _name, _reg, _pwr_reg, _en_mask,

_flags, \
+ _rst_bar_mask, _pcwbits, _pd_reg,
_pd_shift, \
+ _tuner_reg, _tuner_en_reg,
_tuner_en_bit, \
+ _pcw_reg, _pcw_shift,
_pcw_chg_reg, \
+ _en_reg, _pll_en_bit)
{ \
+ .id =
_id, \
+ .name =
_name, \
+ .reg =
_reg, \
+ .pwr_reg =
_pwr_reg, \
+ .en_mask =
_en_mask, \
+ .flags =
_flags, \
+ .rst_bar_mask =
_rst_bar_mask, \
+ .fmax =
MT8188_PLL_FMAX, \
+ .fmin =
MT8188_PLL_FMIN, \
+ .pcwbits =
_pcwbits, \
+ .pcwibits =
MT8188_INTEGER_BITS, \
+ .pd_reg =
_pd_reg, \
+ .pd_shift =
_pd_shift, \
+ .tuner_reg =
_tuner_reg, \
+ .tuner_en_reg =
_tuner_en_reg, \
+ .tuner_en_bit =
_tuner_en_bit, \
+ .pcw_reg =
_pcw_reg, \
+ .pcw_shift =
_pcw_shift, \
+ .pcw_chg_reg =
_pcw_chg_reg, \
+ .en_reg =
_en_reg, \
+ .pll_en_bit =
_pll_en_bit, \

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +13 -0
+       }
+
+static const struct mtk_pll_data plls[] = {
+       PLL(CLK_APMIXED_ETHPLL, "ethpll", 0x044C, 0x0458, 0,
+           0, 0, 22, 0x0450, 24, 0, 0, 0, 0x0450, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MSDCPLL, "msdcpll", 0x0514, 0x0520, 0,
+           0, 0, 22, 0x0518, 24, 0, 0, 0, 0x0518, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_TVDPLL1, "tvdpll1", 0x0524, 0x0530, 0,
+           0, 0, 22, 0x0528, 24, 0, 0, 0, 0x0528, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_TVDPLL2, "tvdpll2", 0x0534, 0x0540, 0,
+           0, 0, 22, 0x0538, 24, 0, 0, 0, 0x0538, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_MMPLL, "mmpll", 0x0544, 0x0550, 0xff000000,
+           HAVE_RST_BAR, BIT(23), 22, 0x0548, 24, 0, 0, 0, 0x0548,

0, 0, 0, 9),
+ PLL(CLK_APMIXED_MAINPLL, "mainpll", 0x045C, 0x0468,
0xff000000,
+ HAVE_RST_BAR, BIT(23), 22, 0x0460, 24, 0, 0, 0, 0x0460,
0, 0, 0, 9),

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +3 -0
+       PLL(CLK_APMIXED_IMGPLL, "imgpll", 0x0554, 0x0560, 0,
+           0, 0, 22, 0x0558, 24, 0, 0, 0, 0x0558, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_UNIVPLL, "univpll", 0x0504, 0x0510,

0xff000000,
+ HAVE_RST_BAR, BIT(23), 22, 0x0508, 24, 0, 0, 0, 0x0508,
0, 0, 0, 9),

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +4 -0
+       PLL(CLK_APMIXED_ADSPPLL, "adsppll", 0x042C, 0x0438, 0,
+           0, 0, 22, 0x0430, 24, 0, 0, 0, 0x0430, 0, 0, 0, 9),
+       PLL(CLK_APMIXED_APLL1, "apll1", 0x0304, 0x0314, 0,
+           0, 0, 32, 0x0308, 24, 0x0034, 0x0000, 12, 0x030C, 0, 0,

0, 9),

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +2 -0
+       PLL(CLK_APMIXED_APLL2, "apll2", 0x0318, 0x0328, 0,
+           0, 0, 32, 0x031C, 24, 0x0038, 0x0000, 13, 0x0320, 0, 0,

0, 9),

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +2 -0
+       PLL(CLK_APMIXED_APLL3, "apll3", 0x032C, 0x033C, 0,
+           0, 0, 32, 0x0330, 24, 0x003C, 0x0000, 14, 0x0334, 0, 0,

0, 9),

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +2 -0
+       PLL(CLK_APMIXED_APLL4, "apll4", 0x0404, 0x0414, 0,
+           0, 0, 32, 0x0408, 24, 0x0040, 0x0000, 15, 0x040C, 0, 0,

0, 9),

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +2 -0
+       PLL(CLK_APMIXED_APLL5, "apll5", 0x0418, 0x0428, 0,
+           0, 0, 32, 0x041C, 24, 0x0044, 0x0000, 16, 0x0420, 0, 0,

0, 9),

drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +20 -0
+       PLL(CLK_APMIXED_MFGPLL, "mfgpll", 0x0340, 0x034C, 0,
+           0, 0, 22, 0x0344, 24, 0, 0, 0, 0x0344, 0, 0, 0, 9),
+};
+
+static const struct of_device_id of_match_clk_mt8188_apmixed[] = {
+       { .compatible = "mediatek,mt8188-apmixedsys", },
+       {}
+};
+
+static int clk_mt8188_apmixed_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_plls(node, plls, ARRAY_SIZE(plls),

clk_data);

drivers/clk/mediatek/clk-mt8188-apmixedsys.c line 112

Quoted 5 lines
drivers/clk/mediatek/clk-mt8188-apmixedsys.c new file +5 -0
+       if (r)
+               goto free_apmixed_data;
+
+       r = mtk_clk_register_gates_with_dev(node, apmixed_clks,
+               ARRAY_SIZE(apmixed_clks), clk_data, NULL);

This API is gone. Please replace it with mtk_clk_register_clks. And please
pass in the |struct device| pointer.

Quoted 1 line

ChenYu

Thank you for your suggestions.
OK, I will use mtk_clk_register_gates in v6.

#6 lore raw

PATCH v5 3/19 clk: mediatek: Add MT8188 topckgen clock support

In reply to Garmin.Chang

Add MT8188 topckgen clock controller which provides muxes, dividers to handle variety clock selection in other IP blocks.

---
 drivers/clk/mediatek/Makefile              |    2 +-
 drivers/clk/mediatek/clk-mt8188-topckgen.c | 1352 ++++++++++++++++++++
 2 files changed, 1353 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-topckgen.c
drivers/clk/mediatek/Makefile +1 -1
index 13ab8deb362c..89b1b331cad0 100644
@@ -83,7 +83,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 				   clk-mt8186-mfg.o clk-mt8186-mm.o clk-mt8186-wpe.o \
 				   clk-mt8186-img.o clk-mt8186-vdec.o clk-mt8186-venc.o \
 				   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
-obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o
+obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +1352 -0

1,352 lines not on this page · raw message

Signature · 1 line
2.18.0
#7 lore raw

Re: [PATCH v5 03/19] clk: mediatek: Add MT8188 topckgen clock support

Quoted 47 lines · Garmin.Chang

Add MT8188 topckgen clock controller which provides muxes, dividers to handle variety clock selection in other IP blocks.

---
 drivers/clk/mediatek/Makefile              |    2 +-
 drivers/clk/mediatek/clk-mt8188-topckgen.c | 1352 ++++++++++++++++++++
 2 files changed, 1353 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-topckgen.c
drivers/clk/mediatek/Makefile +1 -1
index 13ab8deb362c..89b1b331cad0 100644
@@ -83,7 +83,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
                                   clk-mt8186-mfg.o clk-mt8186-mm.o clk-mt8186-wpe.o \
                                   clk-mt8186-img.o clk-mt8186-vdec.o clk-mt8186-venc.o \
                                   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
-obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o
+obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +17 -0
new file mode 100644
index 000000000000..dd0014b461ff
@@ -0,0 +1,1352 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "clk-mux.h"
+
+static DEFINE_SPINLOCK(mt8188_clk_lock);
+
+static const struct mtk_fixed_clk top_fixed_clks[] = {
+       FIXED_CLK(CLK_TOP_ULPOSC1, "ulposc_ck1", NULL, 260000000),

drivers/clk/mediatek/clk-mt8188-topckgen.c line 27

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       FIXED_CLK(CLK_TOP_MPHONE_SLAVE_BCK, "mphone_slave_bck", NULL, 49152000),
+       FIXED_CLK(CLK_TOP_PAD_FPC, "pad_fpc_ck", NULL, 50000000),
+       FIXED_CLK(CLK_TOP_466M_FMEM, "hd_466m_fmem_ck", NULL, 533000000),
+       FIXED_CLK(CLK_TOP_PEXTP_PIPE, "pextp_pipe", NULL, 250000000),
+       FIXED_CLK(CLK_TOP_DSI_PHY, "dsi_phy", NULL, 500000000),
+};
+
+static const struct mtk_fixed_factor top_divs[] = {
+       FACTOR(CLK_TOP_MFGPLL, "mfgpll_ck", "mfgpll", 1, 1),
+       FACTOR(CLK_TOP_MAINPLL, "mainpll_ck", "mainpll", 1, 1),

Please don't add 1:1 placeholder clocks. They only bloat the clock tree and do nothing else.

Quoted 9 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +9 -0
+       FACTOR(CLK_TOP_MAINPLL_D3, "mainpll_d3", "mainpll_ck", 1, 3),
+       FACTOR(CLK_TOP_MAINPLL_D4, "mainpll_d4", "mainpll_ck", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D4_D2, "mainpll_d4_d2", "mainpll_d4", 1, 2),
+       FACTOR(CLK_TOP_MAINPLL_D4_D4, "mainpll_d4_d4", "mainpll_d4", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D4_D8, "mainpll_d4_d8", "mainpll_d4", 1, 8),
+       FACTOR(CLK_TOP_MAINPLL_D5, "mainpll_d5", "mainpll_ck", 1, 5),
+       FACTOR(CLK_TOP_MAINPLL_D5_D2, "mainpll_d5_d2", "mainpll_d5", 1, 2),
+       FACTOR(CLK_TOP_MAINPLL_D5_D4, "mainpll_d5_d4", "mainpll_d5", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D5_D8, "mainpll_d5_d8", "mainpll_d5", 1, 8),

drivers/clk/mediatek/clk-mt8188-topckgen.c line 46

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       FACTOR(CLK_TOP_MAINPLL_D6, "mainpll_d6", "mainpll_ck", 1, 6),
+       FACTOR(CLK_TOP_MAINPLL_D6_D2, "mainpll_d6_d2", "mainpll_d6", 1, 2),
+       FACTOR(CLK_TOP_MAINPLL_D6_D4, "mainpll_d6_d4", "mainpll_d6", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D6_D8, "mainpll_d6_d8", "mainpll_d6", 1, 8),
+       FACTOR(CLK_TOP_MAINPLL_D7, "mainpll_d7", "mainpll_ck", 1, 7),
+       FACTOR(CLK_TOP_MAINPLL_D7_D2, "mainpll_d7_d2", "mainpll_d7", 1, 2),
+       FACTOR(CLK_TOP_MAINPLL_D7_D4, "mainpll_d7_d4", "mainpll_d7", 1, 4),
+       FACTOR(CLK_TOP_MAINPLL_D7_D8, "mainpll_d7_d8", "mainpll_d7", 1, 8),
+       FACTOR(CLK_TOP_MAINPLL_D9, "mainpll_d9", "mainpll_ck", 1, 9),
+       FACTOR(CLK_TOP_UNIVPLL, "univpll_ck", "univpll", 1, 1),

Same here.

Quoted 12 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +12 -0
+       FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll_ck", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll_ck", 1, 3),
+       FACTOR(CLK_TOP_UNIVPLL_D4, "univpll_d4", "univpll_ck", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_D4_D2, "univpll_d4_d2", "univpll_d4", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL_D4_D4, "univpll_d4_d4", "univpll_d4", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_D4_D8, "univpll_d4_d8", "univpll_d4", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll_ck", 1, 5),
+       FACTOR(CLK_TOP_UNIVPLL_D5_D2, "univpll_d5_d2", "univpll_d5", 1, 2),
+       FACTOR(CLK_TOP_UNIVPLL_D5_D4, "univpll_d5_d4", "univpll_d5", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_D5_D8, "univpll_d5_d8", "univpll_d5", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_D6, "univpll_d6", "univpll_ck", 1, 6),
+       FACTOR(CLK_TOP_UNIVPLL_D6_D2, "univpll_d6_d2", "univpll_d6", 1, 2),

drivers/clk/mediatek/clk-mt8188-topckgen.c line 68

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       FACTOR(CLK_TOP_UNIVPLL_D6_D4, "univpll_d6_d4", "univpll_d6", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_D6_D8, "univpll_d6_d8", "univpll_d6", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll_ck", 1, 7),
+       FACTOR(CLK_TOP_UNIVPLL_192M, "univpll_192m", "univpll_ck", 1, 13),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D4, "univpll_192m_d4", "univpll_192m", 1, 4),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D8, "univpll_192m_d8", "univpll_192m", 1, 8),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D10, "univpll_192m_d10", "univpll_192m", 1, 10),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D16, "univpll_192m_d16", "univpll_192m", 1, 16),
+       FACTOR(CLK_TOP_UNIVPLL_192M_D32, "univpll_192m_d32", "univpll_192m", 1, 32),
+       FACTOR(CLK_TOP_IMGPLL, "imgpll_ck", "imgpll", 1, 1),

Again.

drivers/clk/mediatek/clk-mt8188-topckgen.c line 76

Quoted 8 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +8 -0
+       FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1", 1, 3),
+       FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1", 1, 4),
+       FACTOR(CLK_TOP_APLL2_D3, "apll2_d3", "apll2", 1, 3),
+       FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2", 1, 4),
+       FACTOR(CLK_TOP_APLL3_D4, "apll3_d4", "apll3", 1, 4),
+       FACTOR(CLK_TOP_APLL4_D4, "apll4_d4", "apll4", 1, 4),
+       FACTOR(CLK_TOP_APLL5_D4, "apll5_d4", "apll5", 1, 4),
+       FACTOR(CLK_TOP_MMPLL, "mmpll_ck", "mmpll", 1, 1),

Again.

Quoted 8 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +8 -0
+       FACTOR(CLK_TOP_MMPLL_D4, "mmpll_d4", "mmpll_ck", 1, 4),
+       FACTOR(CLK_TOP_MMPLL_D4_D2, "mmpll_d4_d2", "mmpll_d4", 1, 2),
+       FACTOR(CLK_TOP_MMPLL_D5, "mmpll_d5", "mmpll_ck", 1, 5),
+       FACTOR(CLK_TOP_MMPLL_D5_D2, "mmpll_d5_d2", "mmpll_d5", 1, 2),
+       FACTOR(CLK_TOP_MMPLL_D5_D4, "mmpll_d5_d4", "mmpll_d5", 1, 4),
+       FACTOR(CLK_TOP_MMPLL_D6, "mmpll_d6", "mmpll_ck", 1, 6),
+       FACTOR(CLK_TOP_MMPLL_D6_D2, "mmpll_d6_d2", "mmpll_d6", 1, 2),
+       FACTOR(CLK_TOP_MMPLL_D7, "mmpll_d7", "mmpll_ck", 1, 7),

drivers/clk/mediatek/clk-mt8188-topckgen.c line 94

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       FACTOR(CLK_TOP_MMPLL_D9, "mmpll_d9", "mmpll_ck", 1, 9),
+       FACTOR(CLK_TOP_TVDPLL1_D2, "tvdpll1_d2", "tvdpll1", 1, 2),
+       FACTOR(CLK_TOP_TVDPLL1_D4, "tvdpll1_d4", "tvdpll1", 1, 4),
+       FACTOR(CLK_TOP_TVDPLL1_D8, "tvdpll1_d8", "tvdpll1", 1, 8),
+       FACTOR(CLK_TOP_TVDPLL1_D16, "tvdpll1_d16", "tvdpll1", 1, 16),
+       FACTOR(CLK_TOP_TVDPLL2_D2, "tvdpll2_d2", "tvdpll2", 1, 2),
+       FACTOR(CLK_TOP_TVDPLL2_D4, "tvdpll2_d4", "tvdpll2", 1, 4),
+       FACTOR(CLK_TOP_TVDPLL2_D8, "tvdpll2_d8", "tvdpll2", 1, 8),
+       FACTOR(CLK_TOP_TVDPLL2_D16, "tvdpll2_d16", "tvdpll2", 1, 16),
+       FACTOR(CLK_TOP_MSDCPLL, "msdcpll_ck", "msdcpll", 1, 1),

Here too.

drivers/clk/mediatek/clk-mt8188-topckgen.c line 97

Quoted 3 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll_ck", 1, 2),
+       FACTOR(CLK_TOP_MSDCPLL_D16, "msdcpll_d16", "msdcpll_ck", 1, 16),
+       FACTOR(CLK_TOP_ETHPLL, "ethpll_ck", "ethpll", 1, 1),

And this one.

drivers/clk/mediatek/clk-mt8188-topckgen.c line 102

Quoted 5 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +5 -0
+       FACTOR(CLK_TOP_ETHPLL_D2, "ethpll_d2", "ethpll_ck", 1, 2),
+       FACTOR(CLK_TOP_ETHPLL_D4, "ethpll_d4", "ethpll_ck", 1, 4),
+       FACTOR(CLK_TOP_ETHPLL_D8, "ethpll_d8", "ethpll_ck", 1, 8),
+       FACTOR(CLK_TOP_ETHPLL_D10, "ethpll_d10", "ethpll_ck", 1, 10),
+       FACTOR(CLK_TOP_ADSPPLL, "adsppll_ck", "adsppll", 1, 1),

And this one.

Quoted 127 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +127 -0
+       FACTOR(CLK_TOP_ADSPPLL_D2, "adsppll_d2", "adsppll_ck", 1, 2),
+       FACTOR(CLK_TOP_ADSPPLL_D4, "adsppll_d4", "adsppll_ck", 1, 4),
+       FACTOR(CLK_TOP_ADSPPLL_D8, "adsppll_d8", "adsppll_ck", 1, 8),
+       FACTOR(CLK_TOP_ULPOSC1_D2, "ulposc1_d2", "ulposc_ck1", 1, 2),
+       FACTOR(CLK_TOP_ULPOSC1_D4, "ulposc1_d4", "ulposc_ck1", 1, 4),
+       FACTOR(CLK_TOP_ULPOSC1_D8, "ulposc1_d8", "ulposc_ck1", 1, 8),
+       FACTOR(CLK_TOP_ULPOSC1_D7, "ulposc1_d7", "ulposc_ck1", 1, 7),
+       FACTOR(CLK_TOP_ULPOSC1_D10, "ulposc1_d10", "ulposc_ck1", 1, 10),
+       FACTOR(CLK_TOP_ULPOSC1_D16, "ulposc1_d16", "ulposc_ck1", 1, 16),
+};
+
+static const char * const axi_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d7_d2",
+       "mainpll_d4_d2",
+       "mainpll_d5_d2",
+       "mainpll_d6_d2",
+       "ulposc1_d4"
+};
+
+static const char * const spm_parents[] = {
+       "clk26m",
+       "ulposc1_d10",
+       "mainpll_d7_d4",
+       "clk32k"
+};
+
+static const char * const scp_parents[] = {
+       "clk26m",
+       "univpll_d4",
+       "mainpll_d6",
+       "univpll_d6",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "univpll_d3",
+       "mainpll_d3"
+};
+
+static const char * const bus_aximem_parents[] = {
+       "clk26m",
+       "mainpll_d7_d2",
+       "mainpll_d4_d2",
+       "mainpll_d5_d2",
+       "mainpll_d6"
+};
+
+static const char * const vpp_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d4",
+       "mmpll_d5",
+       "tvdpll1",
+       "tvdpll2",
+       "univpll_d4",
+       "mmpll_d4"
+};
+
+static const char * const ethdr_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d4",
+       "mmpll_d5_d4",
+       "tvdpll1",
+       "tvdpll2",
+       "univpll_d4",
+       "mmpll_d4"
+};
+
+static const char * const ipe_parents[] = {
+       "clk26m",
+       "imgpll_ck",
+       "mainpll_d4",
+       "mmpll_d6",
+       "univpll_d6",
+       "mainpll_d6",
+       "mmpll_d4_d2",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "mainpll_d7"
+};
+
+static const char * const cam_parents[] = {
+       "clk26m",
+       "tvdpll1",
+       "mainpll_d4",
+       "mmpll_d4",
+       "univpll_d4",
+       "univpll_d5",
+       "univpll_d6",
+       "mmpll_d7",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "imgpll_ck"
+};
+
+static const char * const ccu_parents[] = {
+       "clk26m",
+       "univpll_d6",
+       "mainpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d5",
+       "mainpll_d6",
+       "mmpll_d6",
+       "mmpll_d7",
+       "univpll_d4_d2",
+       "univpll_d7"
+};
+
+static const char * const ccu_ahb_parents[] = {
+       "clk26m",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 239

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "univpll_d6",
+       "mainpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d5",
+       "mainpll_d6",
+       "mmpll_d6",
+       "mmpll_d7",
+       "univpll_d4_d2",
+       "univpll_d7"
+};

This looks like it is the same as ccu_parents. Please reuse it. Add a comment saying "ccu_parents is also used for ccu_ahb clock" if it helps.

Quoted 101 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +101 -0
+
+static const char * const img_parents[] = {
+       "clk26m",
+       "imgpll_ck",
+       "univpll_d4",
+       "mainpll_d4",
+       "univpll_d5",
+       "mmpll_d6",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d6",
+       "mmpll_d4_d2",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "univpll_d5_d2"
+};
+
+static const char * const camtm_parents[] = {
+       "clk26m",
+       "univpll_d4_d4",
+       "univpll_d6_d2",
+       "univpll_d6_d4"
+};
+
+static const char * const dsp_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "univpll_d5",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp1_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d5",
+       "mmpll_d5",
+       "univpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp2_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d5",
+       "mmpll_d5",
+       "univpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp3_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d5",
+       "mmpll_d5",
+       "univpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp4_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp5_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp6_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+

drivers/clk/mediatek/clk-mt8188-topckgen.c line 350

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+static const char * const dsp7_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "univpll_d5",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};

These dsp*_parents all look very similar. From what I can tell there are two variants. Please merge them. You could name them dspX_Y_Z_parents or something. Maybe add a comment just above them stating that the dsp* clocks have two variants.

Quoted 30 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +30 -0
+
+static const char * const mfg_core_tmp_parents[] = {
+       "clk26m",
+       "mainpll_d5_d2",
+       "univpll_d6",
+       "univpll_d7"
+};
+
+static const char * const camtg_parents[] = {
+       "clk26m",
+       "univpll_192m_d8",
+       "univpll_d6_d8",
+       "univpll_192m_d4",
+       "univpll_192m_d10",
+       "clk13m",
+       "univpll_192m_d16",
+       "univpll_192m_d32"
+};
+
+static const char * const camtg2_parents[] = {
+       "clk26m",
+       "univpll_192m_d8",
+       "univpll_d6_d8",
+       "univpll_192m_d4",
+       "univpll_192m_d10",
+       "clk13m",
+       "univpll_192m_d16",
+       "univpll_192m_d32"
+};
+

drivers/clk/mediatek/clk-mt8188-topckgen.c line 390

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+static const char * const camtg3_parents[] = {
+       "clk26m",
+       "univpll_192m_d8",
+       "univpll_d6_d8",
+       "univpll_192m_d4",
+       "univpll_192m_d10",
+       "clk13m",
+       "univpll_192m_d16",
+       "univpll_192m_d32"
+};

Please merge the three into one.

Quoted 36 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +36 -0
+static const char * const uart_parents[] = {
+       "clk26m",
+       "univpll_d6_d8"
+};
+
+static const char * const spi_parents[] = {
+       "clk26m",
+       "mainpll_d5_d4",
+       "mainpll_d6_d4",
+       "univpll_d6_d4",
+       "univpll_d6_d2",
+       "mainpll_d6_d2",
+       "mainpll_d4_d4",
+       "univpll_d5_d4"
+};
+
+static const char * const msdc5hclk_parents[] = {
+       "clk26m",
+       "mainpll_d4_d2",
+       "mainpll_d6_d2"
+};
+
+static const char * const msdc50_0_parents[] = {
+       "clk26m",
+       "msdcpll_ck",
+       "msdcpll_d2",
+       "univpll_d4_d4",
+       "mainpll_d6_d2",
+       "univpll_d4_d2"
+};
+
+static const char * const msdc30_1_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d6_d2",
+       "mainpll_d7_d2",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 437

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "msdcpll_d2"
+};
+
+static const char * const msdc30_2_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d6_d2",
+       "mainpll_d7_d2",
+       "msdcpll_d2"
+};

Merge the two.

Quoted 71 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +71 -0
+static const char * const intdir_parents[] = {
+       "clk26m",
+       "univpll_d6",
+       "mainpll_d4",
+       "univpll_d4"
+};
+
+static const char * const aud_intbus_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d7_d4"
+};
+
+static const char * const audio_h_parents[] = {
+       "clk26m",
+       "univpll_d7",
+       "apll1",
+       "apll2"
+};
+
+static const char * const pwrap_ulposc_parents[] = {
+       "clk26m",
+       "ulposc1_d10",
+       "ulposc1_d7",
+       "ulposc1_d8",
+       "ulposc1_d16",
+       "mainpll_d4_d8",
+       "univpll_d5_d8",
+       "tvdpll1_d16"
+};
+
+static const char * const atb_parents[] = {
+       "clk26m",
+       "mainpll_d4_d2",
+       "mainpll_d5_d2"
+};
+
+static const char * const sspm_parents[] = {
+       "clk26m",
+       "mainpll_d7_d2",
+       "mainpll_d6_d2",
+       "mainpll_d5_d2",
+       "mainpll_d9",
+       "mainpll_d4_d2"
+};
+
+static const char * const dp_parents[] = {
+       "clk26m",
+       "tvdpll1_d2",
+       "tvdpll2_d2",
+       "tvdpll1_d4",
+       "tvdpll2_d4",
+       "tvdpll1_d8",
+       "tvdpll2_d8",
+       "tvdpll1_d16",
+       "tvdpll2_d16"
+};
+
+static const char * const edp_parents[] = {
+       "clk26m",
+       "tvdpll1_d2",
+       "tvdpll2_d2",
+       "tvdpll1_d4",
+       "tvdpll2_d4",
+       "tvdpll1_d8",
+       "tvdpll2_d8",
+       "tvdpll1_d16",
+       "tvdpll2_d16"
+};
+
+static const char * const dpi_parents[] = {

drivers/clk/mediatek/clk-mt8188-topckgen.c line 519

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "clk26m",
+       "tvdpll1_d2",
+       "tvdpll2_d2",
+       "tvdpll1_d4",
+       "tvdpll2_d4",
+       "tvdpll1_d8",
+       "tvdpll2_d8",
+       "tvdpll1_d16",
+       "tvdpll2_d16"
+};

Merge the three.

Quoted 6 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +6 -0
+static const char * const disp_pwm0_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "ulposc1_d2",
+       "ulposc1_d4",
+       "ulposc1_d16",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 536

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "ethpll_d4"
+};
+
+static const char * const disp_pwm1_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "ulposc1_d2",
+       "ulposc1_d4",
+       "ulposc1_d16"
+};

You could merge the two, and add a comment saying that pwm1 doesn't have the last clock. Later below in the clock definition, for pwm1 just have ARRAY_SIZE() - 1 for num_parents.

This one is up to you though. It's trading amount of code for complexity.

Quoted 31 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +31 -0
+static const char * const usb_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const ssusb_xhci_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const usb_2p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const ssusb_xhci_2p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const usb_3p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 578

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const ssusb_xhci_3p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};

These are all the same. Please merge them. Maybe call them usb_parents?

Quoted 17 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +17 -0
+static const char * const i2c_parents[] = {
+       "clk26m",
+       "mainpll_d4_d8",
+       "univpll_d5_d4"
+};
+
+static const char * const seninf_parents[] = {
+       "clk26m",
+       "univpll_d4_d4",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d7",
+       "univpll_d6",
+       "mmpll_d6",
+       "univpll_d5"
+};
+

drivers/clk/mediatek/clk-mt8188-topckgen.c line 606

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+static const char * const seninf1_parents[] = {
+       "clk26m",
+       "univpll_d4_d4",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d7",
+       "univpll_d6",
+       "mmpll_d6",
+       "univpll_d5"
+};

These two are the same. Please merge.

Quoted 74 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +74 -0
+static const char * const gcpu_parents[] = {
+       "clk26m",
+       "mainpll_d6",
+       "univpll_d4_d2",
+       "mmpll_d5_d2",
+       "univpll_d5_d2"
+};
+
+static const char * const venc_parents[] = {
+       "clk26m",
+       "mmpll_d4_d2",
+       "mainpll_d6",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "univpll_d6",
+       "mmpll_d6",
+       "mainpll_d5_d2",
+       "mainpll_d6_d2",
+       "mmpll_d9",
+       "univpll_d4_d4",
+       "mainpll_d4",
+       "univpll_d4",
+       "univpll_d5",
+       "univpll_d5_d2",
+       "mainpll_d5"
+};
+
+static const char * const vdec_parents[] = {
+       "clk26m",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "univpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mmpll_d6",
+       "mainpll_d4",
+       "tvdpll2",
+       "univpll_d4",
+       "imgpll_ck",
+       "univpll_d6_d2",
+       "mmpll_d9"
+};
+
+static const char * const pwm_parents[] = {
+       "clk32k",
+       "clk26m",
+       "univpll_d4_d8",
+       "univpll_d6_d4"
+};
+
+static const char * const mcupm_parents[] = {
+       "clk26m",
+       "mainpll_d6_d2",
+       "mainpll_d7_d4"
+};
+
+static const char * const spmi_p_mst_parents[] = {
+       "clk26m",
+       "clk13m",
+       "ulposc1_d8",
+       "ulposc1_d10",
+       "ulposc1_d16",
+       "ulposc1_d7",
+       "clk32k",
+       "mainpll_d7_d8",
+       "mainpll_d6_d8",
+       "mainpll_d5_d8"
+};
+
+static const char * const spmi_m_mst_parents[] = {
+       "clk26m",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 691

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "clk13m",
+       "ulposc1_d8",
+       "ulposc1_d10",
+       "ulposc1_d16",
+       "ulposc1_d7",
+       "clk32k",
+       "mainpll_d7_d8",
+       "mainpll_d6_d8",
+       "mainpll_d5_d8"
+};

Merge these two.

Quoted 196 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +196 -0
+static const char * const dvfsrc_parents[] = {
+       "clk26m",
+       "ulposc1_d10",
+       "univpll_d6_d8",
+       "msdcpll_d16"
+};
+
+static const char * const tl_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "mainpll_d4_d4"
+};
+
+static const char * const aes_msdcfde_parents[] = {
+       "clk26m",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "mainpll_d4_d4",
+       "univpll_d4_d2",
+       "univpll_d6"
+};
+
+static const char * const dsi_occ_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2"
+};
+
+static const char * const wpe_vpp_parents[] = {
+       "clk26m",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "mainpll_d4_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "mainpll_d6",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mainpll_d4",
+       "tvdpll1",
+       "univpll_d4"
+};
+
+static const char * const hdcp_parents[] = {
+       "clk26m",
+       "univpll_d4_d8",
+       "mainpll_d5_d8",
+       "univpll_d6_d4"
+};
+
+static const char * const hdcp_24m_parents[] = {
+       "clk26m",
+       "univpll_192m_d4",
+       "univpll_192m_d8",
+       "univpll_d6_d8"
+};
+
+static const char * const hdmi_apb_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "msdcpll_d2"
+};
+
+static const char * const snps_eth_250m_parents[] = {
+       "clk26m",
+       "ethpll_d2"
+};
+
+static const char * const snps_eth_62p4m_ptp_parents[] = {
+       "apll2_d3",
+       "apll1_d3",
+       "clk26m",
+       "ethpll_d8"
+};
+
+static const char * const snps_eth_50m_rmii_parents[] = {
+       "clk26m",
+       "ethpll_d10"
+};
+
+static const char * const adsp_parents[] = {
+       "clk26m",
+       "clk13m",
+       "mainpll_d6",
+       "mainpll_d5_d2",
+       "univpll_d4_d4",
+       "univpll_d4",
+       "ulposc1_d2",
+       "ulposc1_ck1",
+       "adsppll_ck",
+       "adsppll_d2",
+       "adsppll_d4",
+       "adsppll_d8"
+};
+
+static const char * const audio_local_bus_parents[] = {
+       "clk26m",
+       "clk13m",
+       "mainpll_d4_d4",
+       "mainpll_d7_d2",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d7",
+       "mainpll_d4",
+       "univpll_d6",
+       "ulposc1_ck1",
+       "ulposc1_d4",
+       "ulposc1_d2"
+};
+
+static const char * const asm_h_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "univpll_d6_d2",
+       "mainpll_d5_d2"
+};
+
+static const char * const asm_l_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "univpll_d6_d2",
+       "mainpll_d5_d2"
+};
+
+static const char * const apll1_parents[] = {
+       "clk26m",
+       "apll1_d4"
+};
+
+static const char * const apll2_parents[] = {
+       "clk26m",
+       "apll2_d4"
+};
+
+static const char * const apll3_parents[] = {
+       "clk26m",
+       "apll3_d4"
+};
+
+static const char * const apll4_parents[] = {
+       "clk26m",
+       "apll4_d4"
+};
+
+static const char * const apll5_parents[] = {
+       "clk26m",
+       "apll5_d4"
+};
+
+static const char * const i2so1_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const i2so2_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const i2si1_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const i2si2_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const dptx_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"

drivers/clk/mediatek/clk-mt8188-topckgen.c line 898

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+};
+
+static const char * const aud_iec_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};

Please merge all these. Maybe call them something like aud_if?

Quoted 13 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +13 -0
+static const char * const a1sys_hp_parents[] = {
+       "clk26m",
+       "apll1_d4"
+};
+
+static const char * const a2sys_parents[] = {
+       "clk26m",
+       "apll2_d4"
+};
+
+static const char * const a3sys_parents[] = {
+       "clk26m",
+       "apll3_d4",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 922

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "apll4_d4",
+       "apll5_d4"
+};
+
+static const char * const a4sys_parents[] = {
+       "clk26m",
+       "apll3_d4",
+       "apll4_d4",
+       "apll5_d4"
+};

Please merge the two.

Quoted 413 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +413 -0
+static const char * const ecc_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "univpll_d6"
+};
+
+static const char * const spinor_parents[] = {
+       "clk26m",
+       "clk13m",
+       "mainpll_d7_d8",
+       "univpll_d6_d8"
+};
+
+static const char * const ulposc_parents[] = {
+       "ulposc_ck1",
+       "ethpll_d2",
+       "mainpll_d4_d2",
+       "ethpll_d10"
+};
+
+static const char * const srck_parents[] = {
+       "ulposc1_d10",
+       "clk26m"
+};
+
+static const char * const mfg_fast_ref_parents[] = {
+       "top_mfg_core_tmp",
+       "mfgpll_ck"
+};
+
+static const struct mtk_mux top_mtk_muxes[] = {
+       /*
+        * CLK_CFG_0
+        * axi_sel and bus_aximem_sel are bus clocks, should not be closed by Linux.
+        * spm_sel and scp_sel are main clocks in always-on co-processor.
+        */
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_AXI, "top_axi", axi_parents,
+                                  0x020, 0x024, 0x028, 0, 4, 7, 0x04, 0, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SPM, "top_spm", spm_parents,
+                                  0x020, 0x024, 0x028, 8, 4, 15, 0x04, 1, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SCP, "top_scp", scp_parents,
+                                  0x020, 0x024, 0x028, 16, 4, 23, 0x04, 2, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_BUS_AXIMEM, "top_bus_aximem", bus_aximem_parents,
+                                  0x020, 0x024, 0x028, 24, 4, 31, 0x04, 3, CLK_IS_CRITICAL),
+       /* CLK_CFG_1 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_VPP, "top_vpp",
+                            vpp_parents, 0x02C, 0x030, 0x034, 0, 4, 7, 0x04, 4),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ETHDR, "top_ethdr",
+                            ethdr_parents, 0x02C, 0x030, 0x034, 8, 4, 15, 0x04, 5),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_IPE, "top_ipe",
+                            ipe_parents, 0x02C, 0x030, 0x034, 16, 4, 23, 0x04, 6),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAM, "top_cam",
+                            cam_parents, 0x02C, 0x030, 0x034, 24, 4, 31, 0x04, 7),
+       /* CLK_CFG_2 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CCU, "top_ccu",
+                            ccu_parents, 0x038, 0x03C, 0x040, 0, 4, 7, 0x04, 8),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CCU_AHB, "top_ccu_ahb",
+                            ccu_ahb_parents, 0x038, 0x03C, 0x040, 8, 4, 15, 0x04, 9),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_IMG, "top_img",
+                            img_parents, 0x038, 0x03C, 0x040, 16, 4, 23, 0x04, 10),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTM, "top_camtm",
+                            camtm_parents, 0x038, 0x03C, 0x040, 24, 4, 31, 0x04, 11),
+       /* CLK_CFG_3 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP, "top_dsp",
+                            dsp_parents, 0x044, 0x048, 0x04C, 0, 4, 7, 0x04, 12),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP1, "top_dsp1",
+                            dsp1_parents, 0x044, 0x048, 0x04C, 8, 4, 15, 0x04, 13),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP2, "top_dsp2",
+                            dsp2_parents, 0x044, 0x048, 0x04C, 16, 4, 23, 0x04, 14),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP3, "top_dsp3",
+                            dsp3_parents, 0x044, 0x048, 0x04C, 24, 4, 31, 0x04, 15),
+       /* CLK_CFG_4 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP4, "top_dsp4",
+                            dsp4_parents, 0x050, 0x054, 0x058, 0, 4, 7, 0x04, 16),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP5, "top_dsp5",
+                            dsp5_parents, 0x050, 0x054, 0x058, 8, 4, 15, 0x04, 17),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP6, "top_dsp6",
+                            dsp6_parents, 0x050, 0x054, 0x058, 16, 4, 23, 0x04, 18),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP7, "top_dsp7",
+                            dsp7_parents, 0x050, 0x054, 0x058, 24, 4, 31, 0x04, 19),
+       /* CLK_CFG_5 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MFG_CORE_TMP, "top_mfg_core_tmp",
+                            mfg_core_tmp_parents, 0x05C, 0x060, 0x064, 0, 4, 7, 0x04, 20),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG, "top_camtg",
+                            camtg_parents, 0x05C, 0x060, 0x064, 8, 4, 15, 0x04, 21),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG2, "top_camtg2",
+                            camtg2_parents, 0x05C, 0x060, 0x064, 16, 4, 23, 0x04, 22),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG3, "top_camtg3",
+                            camtg3_parents, 0x05C, 0x060, 0x064, 24, 4, 31, 0x04, 23),
+       /* CLK_CFG_6 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_UART, "top_uart",
+                            uart_parents, 0x068, 0x06C, 0x070, 0, 4, 7, 0x04, 24),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPI, "top_spi",
+                            spi_parents, 0x068, 0x06C, 0x070, 8, 4, 15, 0x04, 25),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0_HCLK, "top_msdc5hclk",
+                            msdc5hclk_parents, 0x068, 0x06C, 0x070, 16, 4, 23, 0x04, 26),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0, "top_msdc50_0",
+                            msdc50_0_parents, 0x068, 0x06C, 0x070, 24, 4, 31, 0x04, 27),
+       /* CLK_CFG_7 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_1, "top_msdc30_1",
+                            msdc30_1_parents, 0x074, 0x078, 0x07C, 0, 4, 7, 0x04, 28),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_2, "top_msdc30_2",
+                            msdc30_2_parents, 0x074, 0x078, 0x07C, 8, 4, 15, 0x04, 29),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_INTDIR, "top_intdir",
+                            intdir_parents, 0x074, 0x078, 0x07C, 16, 4, 23, 0x04, 30),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_INTBUS, "top_aud_intbus",
+                            aud_intbus_parents, 0x074, 0x078, 0x07C, 24, 4, 31, 0x04, 31),
+       /* CLK_CFG_8 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_H, "top_audio_h",
+                            audio_h_parents, 0x080, 0x084, 0x088, 0, 4, 7, 0x08, 0),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_PWRAP_ULPOSC, "top_pwrap_ulposc",
+                            pwrap_ulposc_parents, 0x080, 0x084, 0x088, 8, 4, 15, 0x08, 1),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ATB, "top_atb",
+                            atb_parents, 0x080, 0x084, 0x088, 16, 4, 23, 0x08, 2),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSPM, "top_sspm",
+                            sspm_parents, 0x080, 0x084, 0x088, 24, 4, 31, 0x08, 3),
+       /* CLK_CFG_9 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DP, "top_dp",
+                            dp_parents, 0x08C, 0x090, 0x094, 0, 4, 7, 0x08, 4),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_EDP, "top_edp",
+                            edp_parents, 0x08C, 0x090, 0x094, 8, 4, 15, 0x08, 5),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DPI, "top_dpi",
+                            dpi_parents, 0x08C, 0x090, 0x094, 16, 4, 23, 0x08, 6),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP_PWM0, "top_disp_pwm0",
+                            disp_pwm0_parents, 0x08C, 0x090, 0x094, 24, 4, 31, 0x08, 7),
+       /* CLK_CFG_10 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP_PWM1, "top_disp_pwm1",
+                            disp_pwm1_parents, 0x098, 0x09C, 0x0A0, 0, 4, 7, 0x08, 8),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP, "top_usb_top",
+                            usb_parents, 0x098, 0x09C, 0x0A0, 8, 4, 15, 0x08, 9),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI, "top_ssusb_xhci",
+                            ssusb_xhci_parents, 0x098, 0x09C, 0x0A0, 16, 4, 23, 0x08, 10),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP_2P, "top_usb_top_2p",
+                            usb_2p_parents, 0x098, 0x09C, 0x0A0, 24, 4, 31, 0x08, 11),
+       /* CLK_CFG_11 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI_2P, "top_ssusb_xhci_2p",
+                            ssusb_xhci_2p_parents, 0x0A4, 0x0A8, 0x0AC, 0, 4, 7, 0x08, 12),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP_3P, "top_usb_top_3p",
+                            usb_3p_parents, 0x0A4, 0x0A8, 0x0AC, 8, 4, 15, 0x08, 13),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI_3P, "top_ssusb_xhci_3p",
+                            ssusb_xhci_3p_parents, 0x0A4, 0x0A8, 0x0AC, 16, 4, 23, 0x08, 14),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2C, "top_i2c",
+                            i2c_parents, 0x0A4, 0x0A8, 0x0AC, 24, 4, 31, 0x08, 15),
+       /* CLK_CFG_12 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF, "top_seninf",
+                            seninf_parents, 0x0B0, 0x0B4, 0x0B8, 0, 4, 7, 0x08, 16),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF1, "top_seninf1",
+                            seninf1_parents, 0x0B0, 0x0B4, 0x0B8, 8, 4, 15, 0x08, 17),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_GCPU, "top_gcpu",
+                            gcpu_parents, 0x0B0, 0x0B4, 0x0B8, 16, 4, 23, 0x08, 18),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_VENC, "top_venc",
+                            venc_parents, 0x0B0, 0x0B4, 0x0B8, 24, 4, 31, 0x08, 19),
+       /*
+        * CLK_CFG_13
+        * top_mcupm is main clock in co-processor, should not be handled by Linux.
+        */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_VDEC, "top_vdec",
+                            vdec_parents, 0x0BC, 0x0C0, 0x0C4, 0, 4, 7, 0x08, 20),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_PWM, "top_pwm",
+                            pwm_parents, 0x0BC, 0x0C0, 0x0C4, 8, 4, 15, 0x08, 21),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MCUPM, "top_mcupm", mcupm_parents,
+                                  0x0BC, 0x0C0, 0x0C4, 16, 4, 23, 0x08, 22, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPMI_P_MST, "top_spmi_p_mst",
+                            spmi_p_mst_parents, 0x0BC, 0x0C0, 0x0C4, 24, 4, 31, 0x08, 23),
+       /*
+        * CLK_CFG_14
+        * dvfsrc_sel is for internal DVFS usage, should not be handled by Linux.
+        */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPMI_M_MST, "top_spmi_m_mst",
+                            spmi_m_mst_parents, 0x0C8, 0x0CC, 0x0D0, 0, 4, 7, 0x08, 24),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_DVFSRC, "top_dvfsrc", dvfsrc_parents,
+                                  0x0C8, 0x0CC, 0x0D0, 8, 4, 15, 0x08, 25, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_TL, "top_tl",
+                            tl_parents, 0x0C8, 0x0CC, 0x0D0, 16, 4, 23, 0x08, 26),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AES_MSDCFDE, "top_aes_msdcfde",
+                            aes_msdcfde_parents, 0x0C8, 0x0CC, 0x0D0, 24, 4, 31, 0x08, 27),
+       /* CLK_CFG_15 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSI_OCC, "top_dsi_occ",
+                            dsi_occ_parents, 0x0D4, 0x0D8, 0x0DC, 0, 4, 7, 0x08, 28),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_WPE_VPP, "top_wpe_vpp",
+                            wpe_vpp_parents, 0x0D4, 0x0D8, 0x0DC, 8, 4, 15, 0x08, 29),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_HDCP, "top_hdcp",
+                            hdcp_parents, 0x0D4, 0x0D8, 0x0DC, 16, 4, 23, 0x08, 30),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_HDCP_24M, "top_hdcp_24m",
+                            hdcp_24m_parents, 0x0D4, 0x0D8, 0x0DC, 24, 4, 31, 0x08, 31),
+       /* CLK_CFG_16 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_HDMI_APB, "top_hdmi_apb",
+                            hdmi_apb_parents, 0x0E0, 0x0E4, 0x0E8, 0, 4, 7, 0x0C, 0),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_250M, "top_snps_eth_250m",
+                            snps_eth_250m_parents, 0x0E0, 0x0E4, 0x0E8, 8, 4, 15, 0x0C, 1),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_62P4M_PTP, "top_snps_eth_62p4m_ptp",
+                            snps_eth_62p4m_ptp_parents, 0x0E0, 0x0E4, 0x0E8, 16, 4, 23, 0x0C, 2),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_50M_RMII, "snps_eth_50m_rmii",
+                            snps_eth_50m_rmii_parents, 0x0E0, 0x0E4, 0x0E8, 24, 4, 31, 0x0C, 3),
+       /* CLK_CFG_17 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ADSP, "top_adsp",
+                            adsp_parents, 0x0EC, 0x0F0, 0x0F4, 0, 4, 7, 0x0C, 4),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_LOCAL_BUS, "top_audio_local_bus",
+                            audio_local_bus_parents, 0x0EC, 0x0F0, 0x0F4, 8, 4, 15, 0x0C, 5),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ASM_H, "top_asm_h",
+                            asm_h_parents, 0x0EC, 0x0F0, 0x0F4, 16, 4, 23, 0x0C, 6),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ASM_L, "top_asm_l",
+                            asm_l_parents, 0x0EC, 0x0F0, 0x0F4, 24, 4, 31, 0x0C, 7),
+       /* CLK_CFG_18 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL1, "top_apll1",
+                            apll1_parents, 0x0F8, 0x0FC, 0x100, 0, 4, 7, 0x0C, 8),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL2, "top_apll2",
+                            apll2_parents, 0x0F8, 0x0FC, 0x100, 8, 4, 15, 0x0C, 9),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL3, "top_apll3",
+                            apll3_parents, 0x0F8, 0x0FC, 0x100, 16, 4, 23, 0x0C, 10),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL4, "top_apll4",
+                            apll4_parents, 0x0F8, 0x0FC, 0x100, 24, 4, 31, 0x0C, 11),
+       /* CLK_CFG_19 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL5, "top_apll5",
+                            apll5_parents, 0x0104, 0x0108, 0x010C, 0, 4, 7, 0x0C, 12),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SO1, "top_i2so1",
+                            i2so1_parents, 0x0104, 0x0108, 0x010C, 8, 4, 15, 0x0C, 13),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SO2, "top_i2so2",
+                            i2so2_parents, 0x0104, 0x0108, 0x010C, 16, 4, 23, 0x0C, 14),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SI1, "top_i2si1",
+                            i2si1_parents, 0x0104, 0x0108, 0x010C, 24, 4, 31, 0x0C, 15),
+       /* CLK_CFG_20 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SI2, "top_i2si2",
+                            i2si2_parents, 0x0110, 0x0114, 0x0118, 0, 4, 7, 0x0C, 16),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DPTX, "top_dptx",
+                            dptx_parents, 0x0110, 0x0114, 0x0118, 8, 4, 15, 0x0C, 17),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_IEC, "top_aud_iec",
+                            aud_iec_parents, 0x0110, 0x0114, 0x0118, 16, 4, 23, 0x0C, 18),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A1SYS_HP, "top_a1sys_hp",
+                            a1sys_hp_parents, 0x0110, 0x0114, 0x0118, 24, 4, 31, 0x0C, 19),
+       /* CLK_CFG_21 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A2SYS, "top_a2sys",
+                            a2sys_parents, 0x011C, 0x0120, 0x0124, 0, 4, 7, 0x0C, 20),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A3SYS, "top_a3sys",
+                            a3sys_parents, 0x011C, 0x0120, 0x0124, 8, 4, 15, 0x0C, 21),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A4SYS, "top_a4sys",
+                            a4sys_parents, 0x011C, 0x0120, 0x0124, 16, 4, 23, 0x0C, 22),
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ECC, "top_ecc",
+                            ecc_parents, 0x011C, 0x0120, 0x0124, 24, 4, 31, 0x0C, 23),
+       /*
+        * CLK_CFG_22
+        * top_ulposc/top_srck are clock source of always on co-processor,
+        * should not be closed by Linux.
+        */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPINOR, "top_spinor",
+                            spinor_parents, 0x0128, 0x012C, 0x0130, 0, 4, 7, 0x0C, 24),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_ULPOSC, "top_ulposc", ulposc_parents,
+                                  0x0128, 0x012C, 0x0130, 8, 4, 15, 0x0C, 25, CLK_IS_CRITICAL),
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SRCK, "top_srck", srck_parents,
+                                  0x0128, 0x012C, 0x0130, 16, 4, 23, 0x0C, 26, CLK_IS_CRITICAL),
+};
+
+static const struct mtk_composite top_adj_divs[] = {
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV0, "apll12_div0", "top_i2si1", 0x0320, 0, 0x0328, 8, 0),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV1, "apll12_div1", "top_i2si2", 0x0320, 1, 0x0328, 8, 8),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV2, "apll12_div2", "top_i2so1", 0x0320, 2, 0x0328, 8, 16),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV3, "apll12_div3", "top_i2so2", 0x0320, 3, 0x0328, 8, 24),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV4, "apll12_div4", "top_aud_iec", 0x0320, 4, 0x0334, 8, 0),
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV9, "apll12_div9", "top_dptx", 0x0320, 9, 0x0338, 8, 8),
+};
+static const struct mtk_gate_regs top0_cg_regs = {
+       .set_ofs = 0x238,
+       .clr_ofs = 0x238,
+       .sta_ofs = 0x238,
+};
+
+static const struct mtk_gate_regs top1_cg_regs = {
+       .set_ofs = 0x250,
+       .clr_ofs = 0x250,
+       .sta_ofs = 0x250,
+};
+
+#define GATE_TOP0(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+#define GATE_TOP1(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv)
+
+static const struct mtk_gate top_clks[] = {
+       /* TOP0 */
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VPP0, "cfgreg_clock_vpp0", "top_vpp", 0),
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VPP1, "cfgreg_clock_vpp1", "top_vpp", 1),
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VDO0, "cfgreg_clock_vdo0", "top_vpp", 2),
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VDO1, "cfgreg_clock_vdo1", "top_vpp", 3),
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_ISP_AXI_GALS, "cfgreg_clock_isp_axi_gals", "top_vpp", 4),
+       GATE_TOP0(CLK_TOP_CFGREG_F26M_VPP0, "cfgreg_f26m_vpp0", "clk26m", 5),
+       GATE_TOP0(CLK_TOP_CFGREG_F26M_VPP1, "cfgreg_f26m_vpp1", "clk26m", 6),
+       GATE_TOP0(CLK_TOP_CFGREG_F26M_VDO0, "cfgreg_f26m_vdo0", "clk26m", 7),
+       GATE_TOP0(CLK_TOP_CFGREG_F26M_VDO1, "cfgreg_f26m_vdo1", "clk26m", 8),
+       GATE_TOP0(CLK_TOP_CFGREG_AUD_F26M_AUD, "cfgreg_aud_f26m_aud", "clk26m", 9),
+       GATE_TOP0(CLK_TOP_CFGREG_UNIPLL_SES, "cfgreg_unipll_ses", "univpll_d2", 15),
+       GATE_TOP0(CLK_TOP_CFGREG_F_PCIE_PHY_REF, "cfgreg_f_pcie_phy_ref", "clk26m", 18),
+       /* TOP1 */
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_REF, "ssusb_ref", "clk26m", 0),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_REF, "ssusb_phy_ref", "clk26m", 1),
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_P1_REF, "ssusb_p1_ref", "clk26m", 2),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_P1_REF, "ssusb_phy_p1_ref", "clk26m", 3),
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_P2_REF, "ssusb_p2_ref", "clk26m", 4),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_P2_REF, "ssusb_phy_p2_ref", "clk26m", 5),
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_P3_REF, "ssusb_p3_ref", "clk26m", 6),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_P3_REF, "ssusb_phy_p3_ref", "clk26m", 7),
+};
+
+static const struct of_device_id of_match_clk_mt8188_topck[] = {
+       { .compatible = "mediatek,mt8188-topckgen", },
+       {}
+};
+
+/* Register mux notifier for MFG mux */
+static int clk_mt8188_reg_mfg_mux_notifier(struct device *dev, struct clk *clk)
+{
+       struct mtk_mux_nb *mfg_mux_nb;
+
+       mfg_mux_nb = devm_kzalloc(dev, sizeof(*mfg_mux_nb), GFP_KERNEL);
+       if (!mfg_mux_nb)
+               return -ENOMEM;
+
+       mfg_mux_nb->ops = &clk_mux_ops;
+       mfg_mux_nb->bypass_index = 0; /* Bypass to TOP_MFG_CORE_TMP */
+
+       return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb);
+}
+
+static int clk_mt8188_topck_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *top_clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       struct clk_hw *hw;
+       int r;
+       void __iomem *base;
+
+       top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+       if (!top_clk_data)
+               return -ENOMEM;
+
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base)) {
+               r = PTR_ERR(base);
+               goto free_top_data;
+       }
+
+       r = mtk_clk_register_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks),
+                                       top_clk_data);
+       if (r)
+               goto free_top_data;
+
+       r = mtk_clk_register_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
+       if (r)
+               goto unregister_fixed_clks;
+
+       r = mtk_clk_register_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), node,
+                                  &mt8188_clk_lock, top_clk_data);
+       if (r)
+               goto unregister_factors;
+
+       hw = devm_clk_hw_register_mux(&pdev->dev, "mfg_ck_fast_ref", mfg_fast_ref_parents,
+                                     ARRAY_SIZE(mfg_fast_ref_parents), CLK_SET_RATE_PARENT,
+                                     (base + 0x250), 8, 1, 0, &mt8188_clk_lock);
+       if (IS_ERR(hw)) {
+               r = PTR_ERR(hw);
+               goto unregister_muxes;
+       }
+       top_clk_data->hws[CLK_TOP_MFG_CK_FAST_REF] = hw;
+
+       r = clk_mt8188_reg_mfg_mux_notifier(&pdev->dev,
+                                           top_clk_data->hws[CLK_TOP_MFG_CK_FAST_REF]->clk);
+       if (r)
+               goto unregister_muxes;
+
+       r = mtk_clk_register_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), base,
+                                       &mt8188_clk_lock, top_clk_data);
+       if (r)
+               goto unregister_muxes;
+
+       r = mtk_clk_register_gates(node, top_clks, ARRAY_SIZE(top_clks), top_clk_data);
+       if (r)
+               goto unregister_composite_divs;
+
+       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, top_clk_data);
+       if (r)
+               goto unregister_gates;
+
+       platform_set_drvdata(pdev, top_clk_data);
+
+       return r;
+
+unregister_gates:
+       mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data);
+unregister_composite_divs:
+       mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data);
+unregister_muxes:
+       mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data);
+unregister_factors:
+       mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
+unregister_fixed_clks:
+       mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data);
+free_top_data:
+       mtk_free_clk_data(top_clk_data);
+       return r;
+}
+
+static int clk_mt8188_topck_remove(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *top_clk_data = platform_get_drvdata(pdev);
+       struct device_node *node = pdev->dev.of_node;
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks), top_clk_data);
+       mtk_clk_unregister_composites(top_adj_divs, ARRAY_SIZE(top_adj_divs), top_clk_data);
+       mtk_clk_unregister_muxes(top_mtk_muxes, ARRAY_SIZE(top_mtk_muxes), top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c line 1346

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs), top_clk_data);
+       mtk_clk_unregister_fixed_clks(top_fixed_clks, ARRAY_SIZE(top_fixed_clks), top_clk_data);
+       mtk_free_clk_data(top_clk_data);
+
+       return 0;
+}
+
+static struct platform_driver clk_mt8188_topck_drv = {
+       .probe = clk_mt8188_topck_probe,
+       .remove = clk_mt8188_topck_remove,

With the recently merged cleanup and refactor, you can use the expanded simple probe library for this. Please see clk-mt8192.c in latest -next.

Thanks
ChenYu

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +6 -1
+       .driver = {
+               .name = "clk-mt8188-topck",
+               .of_match_table = of_match_clk_mt8188_topck,
+       },
+};
+builtin_platform_driver(clk_mt8188_topck_drv);
--

2.18.0

#8 lore raw

Re: [PATCH v5 03/19] clk: mediatek: Add MT8188 topckgen clock support

Quoted 66 lines · Chen-Yu Tsai
Quoted 64 lines · Garmin.Chang

Add MT8188 topckgen clock controller which provides muxes, dividers to handle variety clock selection in other IP blocks.

---
 drivers/clk/mediatek/Makefile              |    2 +-
 drivers/clk/mediatek/clk-mt8188-topckgen.c | 1352
++++++++++++++++++++
 2 files changed, 1353 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-topckgen.c
drivers/clk/mediatek/Makefile +0 -0
index 13ab8deb362c..89b1b331cad0 100644
@@ -83,7 +83,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-

mcu.o clk-mt8186-topckgen.o clk-mt

                                   clk-mt8186-mfg.o clk-mt8186-mm.o 
clk-mt8186-wpe.o \
                                   clk-mt8186-img.o clk-mt8186-
vdec.o clk-mt8186-venc.o \
                                   clk-mt8186-cam.o clk-mt8186-

mdp.o clk-mt8186-ipe.o

drivers/clk/mediatek/Makefile +1 -1
-obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o
+obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-

mt8188-topckgen.o
obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +18 -0
new file mode 100644
index 000000000000..dd0014b461ff
@@ -0,0 +1,1352 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+#include "clk-mux.h"
+
+static DEFINE_SPINLOCK(mt8188_clk_lock);
+
+static const struct mtk_fixed_clk top_fixed_clks[] = {
+       FIXED_CLK(CLK_TOP_ULPOSC1, "ulposc_ck1", NULL, 260000000),
+       FIXED_CLK(CLK_TOP_MPHONE_SLAVE_BCK, "mphone_slave_bck",

NULL, 49152000),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       FIXED_CLK(CLK_TOP_PAD_FPC, "pad_fpc_ck", NULL, 50000000),
+       FIXED_CLK(CLK_TOP_466M_FMEM, "hd_466m_fmem_ck", NULL,

533000000),
+ FIXED_CLK(CLK_TOP_PEXTP_PIPE, "pextp_pipe", NULL,
250000000),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       FIXED_CLK(CLK_TOP_DSI_PHY, "dsi_phy", NULL, 500000000),
+};
Quoted 8 lines

drivers/clk/mediatek/clk-mt8188-topckgen.c line 27

Quoted 4 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+
+static const struct mtk_fixed_factor top_divs[] = {
+       FACTOR(CLK_TOP_MFGPLL, "mfgpll_ck", "mfgpll", 1, 1),
+       FACTOR(CLK_TOP_MAINPLL, "mainpll_ck", "mainpll", 1, 1),

Please don't add 1:1 placeholder clocks. They only bloat the clock tree
and do nothing else.

Thank you for your suggestions.
OK, I will remove all 1:1 placeholder clocks in v6.

Quoted 39 lines
Quoted 30 lines

+ FACTOR(CLK_TOP_MAINPLL_D3, "mainpll_d3", "mainpll_ck", 1,
3),
+ FACTOR(CLK_TOP_MAINPLL_D4, "mainpll_d4", "mainpll_ck", 1,
4),
+ FACTOR(CLK_TOP_MAINPLL_D4_D2, "mainpll_d4_d2",
"mainpll_d4", 1, 2),
+ FACTOR(CLK_TOP_MAINPLL_D4_D4, "mainpll_d4_d4",
"mainpll_d4", 1, 4),
+ FACTOR(CLK_TOP_MAINPLL_D4_D8, "mainpll_d4_d8",
"mainpll_d4", 1, 8),
+ FACTOR(CLK_TOP_MAINPLL_D5, "mainpll_d5", "mainpll_ck", 1,
5),
+ FACTOR(CLK_TOP_MAINPLL_D5_D2, "mainpll_d5_d2",
"mainpll_d5", 1, 2),
+ FACTOR(CLK_TOP_MAINPLL_D5_D4, "mainpll_d5_d4",
"mainpll_d5", 1, 4),
+ FACTOR(CLK_TOP_MAINPLL_D5_D8, "mainpll_d5_d8",
"mainpll_d5", 1, 8),
+ FACTOR(CLK_TOP_MAINPLL_D6, "mainpll_d6", "mainpll_ck", 1,
6),
+ FACTOR(CLK_TOP_MAINPLL_D6_D2, "mainpll_d6_d2",
"mainpll_d6", 1, 2),
+ FACTOR(CLK_TOP_MAINPLL_D6_D4, "mainpll_d6_d4",
"mainpll_d6", 1, 4),
+ FACTOR(CLK_TOP_MAINPLL_D6_D8, "mainpll_d6_d8",
"mainpll_d6", 1, 8),
+ FACTOR(CLK_TOP_MAINPLL_D7, "mainpll_d7", "mainpll_ck", 1,
7),
+ FACTOR(CLK_TOP_MAINPLL_D7_D2, "mainpll_d7_d2",

Quoted 8 lines

"mainpll_d7", 1, 2),
+ FACTOR(CLK_TOP_MAINPLL_D7_D4, "mainpll_d7_d4",
"mainpll_d7", 1, 4),
+ FACTOR(CLK_TOP_MAINPLL_D7_D8, "mainpll_d7_d8",
"mainpll_d7", 1, 8),
+ FACTOR(CLK_TOP_MAINPLL_D9, "mainpll_d9", "mainpll_ck", 1,
9),
+ FACTOR(CLK_TOP_UNIVPLL, "univpll_ck", "univpll", 1, 1),

Quoted 1 line

Same here.

OK, I will remove it in v6.

Quoted 45 lines
Quoted 36 lines

+ FACTOR(CLK_TOP_UNIVPLL_D2, "univpll_d2", "univpll_ck", 1,
2),
+ FACTOR(CLK_TOP_UNIVPLL_D3, "univpll_d3", "univpll_ck", 1,
3),
+ FACTOR(CLK_TOP_UNIVPLL_D4, "univpll_d4", "univpll_ck", 1,
4),
+ FACTOR(CLK_TOP_UNIVPLL_D4_D2, "univpll_d4_d2",
"univpll_d4", 1, 2),
+ FACTOR(CLK_TOP_UNIVPLL_D4_D4, "univpll_d4_d4",
"univpll_d4", 1, 4),
+ FACTOR(CLK_TOP_UNIVPLL_D4_D8, "univpll_d4_d8",
"univpll_d4", 1, 8),
+ FACTOR(CLK_TOP_UNIVPLL_D5, "univpll_d5", "univpll_ck", 1,
5),
+ FACTOR(CLK_TOP_UNIVPLL_D5_D2, "univpll_d5_d2",
"univpll_d5", 1, 2),
+ FACTOR(CLK_TOP_UNIVPLL_D5_D4, "univpll_d5_d4",
"univpll_d5", 1, 4),
+ FACTOR(CLK_TOP_UNIVPLL_D5_D8, "univpll_d5_d8",
"univpll_d5", 1, 8),
+ FACTOR(CLK_TOP_UNIVPLL_D6, "univpll_d6", "univpll_ck", 1,
6),
+ FACTOR(CLK_TOP_UNIVPLL_D6_D2, "univpll_d6_d2",
"univpll_d6", 1, 2),
+ FACTOR(CLK_TOP_UNIVPLL_D6_D4, "univpll_d6_d4",
"univpll_d6", 1, 4),
+ FACTOR(CLK_TOP_UNIVPLL_D6_D8, "univpll_d6_d8",
"univpll_d6", 1, 8),
+ FACTOR(CLK_TOP_UNIVPLL_D7, "univpll_d7", "univpll_ck", 1,
7),
+ FACTOR(CLK_TOP_UNIVPLL_192M, "univpll_192m", "univpll_ck",
1, 13),
+ FACTOR(CLK_TOP_UNIVPLL_192M_D4, "univpll_192m_d4",
"univpll_192m", 1, 4),
+ FACTOR(CLK_TOP_UNIVPLL_192M_D8, "univpll_192m_d8",

Quoted 8 lines

"univpll_192m", 1, 8),
+ FACTOR(CLK_TOP_UNIVPLL_192M_D10, "univpll_192m_d10",
"univpll_192m", 1, 10),
+ FACTOR(CLK_TOP_UNIVPLL_192M_D16, "univpll_192m_d16",
"univpll_192m", 1, 16),
+ FACTOR(CLK_TOP_UNIVPLL_192M_D32, "univpll_192m_d32",
"univpll_192m", 1, 32),
+ FACTOR(CLK_TOP_IMGPLL, "imgpll_ck", "imgpll", 1, 1),

Quoted 1 line

Again.

OK, I will remove it in v6.

Quoted 11 lines

drivers/clk/mediatek/clk-mt8188-topckgen.c line 76

Quoted 9 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +8 -0
+       FACTOR(CLK_TOP_APLL1_D3, "apll1_d3", "apll1", 1, 3),
+       FACTOR(CLK_TOP_APLL1_D4, "apll1_d4", "apll1", 1, 4),
+       FACTOR(CLK_TOP_APLL2_D3, "apll2_d3", "apll2", 1, 3),
+       FACTOR(CLK_TOP_APLL2_D4, "apll2_d4", "apll2", 1, 4),
+       FACTOR(CLK_TOP_APLL3_D4, "apll3_d4", "apll3", 1, 4),
+       FACTOR(CLK_TOP_APLL4_D4, "apll4_d4", "apll4", 1, 4),
+       FACTOR(CLK_TOP_APLL5_D4, "apll5_d4", "apll5", 1, 4),
+       FACTOR(CLK_TOP_MMPLL, "mmpll_ck", "mmpll", 1, 1),

Again.

OK, I will remove it in v6.

Quoted 26 lines
Quoted 23 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       FACTOR(CLK_TOP_MMPLL_D4, "mmpll_d4", "mmpll_ck", 1, 4),
+       FACTOR(CLK_TOP_MMPLL_D4_D2, "mmpll_d4_d2", "mmpll_d4", 1,

2),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       FACTOR(CLK_TOP_MMPLL_D5, "mmpll_d5", "mmpll_ck", 1, 5),
+       FACTOR(CLK_TOP_MMPLL_D5_D2, "mmpll_d5_d2", "mmpll_d5", 1,

2),
+ FACTOR(CLK_TOP_MMPLL_D5_D4, "mmpll_d5_d4", "mmpll_d5", 1,
4),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       FACTOR(CLK_TOP_MMPLL_D6, "mmpll_d6", "mmpll_ck", 1, 6),
+       FACTOR(CLK_TOP_MMPLL_D6_D2, "mmpll_d6_d2", "mmpll_d6", 1,

2),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +6 -0
+       FACTOR(CLK_TOP_MMPLL_D7, "mmpll_d7", "mmpll_ck", 1, 7),
+       FACTOR(CLK_TOP_MMPLL_D9, "mmpll_d9", "mmpll_ck", 1, 9),
+       FACTOR(CLK_TOP_TVDPLL1_D2, "tvdpll1_d2", "tvdpll1", 1, 2),
+       FACTOR(CLK_TOP_TVDPLL1_D4, "tvdpll1_d4", "tvdpll1", 1, 4),
+       FACTOR(CLK_TOP_TVDPLL1_D8, "tvdpll1_d8", "tvdpll1", 1, 8),
+       FACTOR(CLK_TOP_TVDPLL1_D16, "tvdpll1_d16", "tvdpll1", 1,

16),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+       FACTOR(CLK_TOP_TVDPLL2_D2, "tvdpll2_d2", "tvdpll2", 1, 2),
+       FACTOR(CLK_TOP_TVDPLL2_D4, "tvdpll2_d4", "tvdpll2", 1, 4),
+       FACTOR(CLK_TOP_TVDPLL2_D8, "tvdpll2_d8", "tvdpll2", 1, 8),
+       FACTOR(CLK_TOP_TVDPLL2_D16, "tvdpll2_d16", "tvdpll2", 1,
Quoted 2 lines

16),
+ FACTOR(CLK_TOP_MSDCPLL, "msdcpll_ck", "msdcpll", 1, 1),

Quoted 1 line

Here too.

OK, I will remove it in v6.

Quoted 8 lines
Quoted 6 lines

+ FACTOR(CLK_TOP_MSDCPLL_D2, "msdcpll_d2", "msdcpll_ck", 1,
2),
+ FACTOR(CLK_TOP_MSDCPLL_D16, "msdcpll_d16", "msdcpll_ck", 1,
16),
+ FACTOR(CLK_TOP_ETHPLL, "ethpll_ck", "ethpll", 1, 1),

And this one.

OK, I will remove it in v6.

Quoted 9 lines
Quoted 7 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+       FACTOR(CLK_TOP_ETHPLL_D2, "ethpll_d2", "ethpll_ck", 1, 2),
+       FACTOR(CLK_TOP_ETHPLL_D4, "ethpll_d4", "ethpll_ck", 1, 4),
+       FACTOR(CLK_TOP_ETHPLL_D8, "ethpll_d8", "ethpll_ck", 1, 8),
+       FACTOR(CLK_TOP_ETHPLL_D10, "ethpll_d10", "ethpll_ck", 1,

10),
+ FACTOR(CLK_TOP_ADSPPLL, "adsppll_ck", "adsppll", 1, 1),

And this one.

OK, I will remove it in v6.

Quoted 1,479 lines
Quoted 137 lines

+ FACTOR(CLK_TOP_ADSPPLL_D2, "adsppll_d2", "adsppll_ck", 1,
2),
+ FACTOR(CLK_TOP_ADSPPLL_D4, "adsppll_d4", "adsppll_ck", 1,
4),
+ FACTOR(CLK_TOP_ADSPPLL_D8, "adsppll_d8", "adsppll_ck", 1,
8),
+ FACTOR(CLK_TOP_ULPOSC1_D2, "ulposc1_d2", "ulposc_ck1", 1,
2),
+ FACTOR(CLK_TOP_ULPOSC1_D4, "ulposc1_d4", "ulposc_ck1", 1,
4),
+ FACTOR(CLK_TOP_ULPOSC1_D8, "ulposc1_d8", "ulposc_ck1", 1,
8),
+ FACTOR(CLK_TOP_ULPOSC1_D7, "ulposc1_d7", "ulposc_ck1", 1,
7),
+ FACTOR(CLK_TOP_ULPOSC1_D10, "ulposc1_d10", "ulposc_ck1", 1,
10),
+ FACTOR(CLK_TOP_ULPOSC1_D16, "ulposc1_d16", "ulposc_ck1", 1,
16),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +118 -0
+};
+
+static const char * const axi_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d7_d2",
+       "mainpll_d4_d2",
+       "mainpll_d5_d2",
+       "mainpll_d6_d2",
+       "ulposc1_d4"
+};
+
+static const char * const spm_parents[] = {
+       "clk26m",
+       "ulposc1_d10",
+       "mainpll_d7_d4",
+       "clk32k"
+};
+
+static const char * const scp_parents[] = {
+       "clk26m",
+       "univpll_d4",
+       "mainpll_d6",
+       "univpll_d6",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "univpll_d3",
+       "mainpll_d3"
+};
+
+static const char * const bus_aximem_parents[] = {
+       "clk26m",
+       "mainpll_d7_d2",
+       "mainpll_d4_d2",
+       "mainpll_d5_d2",
+       "mainpll_d6"
+};
+
+static const char * const vpp_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d4",
+       "mmpll_d5",
+       "tvdpll1",
+       "tvdpll2",
+       "univpll_d4",
+       "mmpll_d4"
+};
+
+static const char * const ethdr_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d4",
+       "mmpll_d5_d4",
+       "tvdpll1",
+       "tvdpll2",
+       "univpll_d4",
+       "mmpll_d4"
+};
+
+static const char * const ipe_parents[] = {
+       "clk26m",
+       "imgpll_ck",
+       "mainpll_d4",
+       "mmpll_d6",
+       "univpll_d6",
+       "mainpll_d6",
+       "mmpll_d4_d2",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "mainpll_d7"
+};
+
+static const char * const cam_parents[] = {
+       "clk26m",
+       "tvdpll1",
+       "mainpll_d4",
+       "mmpll_d4",
+       "univpll_d4",
+       "univpll_d5",
+       "univpll_d6",
+       "mmpll_d7",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "imgpll_ck"
+};
+
+static const char * const ccu_parents[] = {
+       "clk26m",
+       "univpll_d6",
+       "mainpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d5",
+       "mainpll_d6",
+       "mmpll_d6",
+       "mmpll_d7",
+       "univpll_d4_d2",
+       "univpll_d7"
+};
+
+static const char * const ccu_ahb_parents[] = {
+       "clk26m",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 239

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "univpll_d6",
+       "mainpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d5",
+       "mainpll_d6",
+       "mmpll_d6",
+       "mmpll_d7",
+       "univpll_d4_d2",
+       "univpll_d7"
+};

This looks like it is the same as ccu_parents. Please reuse it. Add a comment saying "ccu_parents is also used for ccu_ahb clock" if it helps.

Quoted 101 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +101 -0
+
+static const char * const img_parents[] = {
+       "clk26m",
+       "imgpll_ck",
+       "univpll_d4",
+       "mainpll_d4",
+       "univpll_d5",
+       "mmpll_d6",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d6",
+       "mmpll_d4_d2",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "univpll_d5_d2"
+};
+
+static const char * const camtm_parents[] = {
+       "clk26m",
+       "univpll_d4_d4",
+       "univpll_d6_d2",
+       "univpll_d6_d4"
+};
+
+static const char * const dsp_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "univpll_d5",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp1_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d5",
+       "mmpll_d5",
+       "univpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp2_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d5",
+       "mmpll_d5",
+       "univpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp3_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d5",
+       "mmpll_d5",
+       "univpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp4_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp5_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+
+static const char * const dsp6_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "mainpll_d4",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};
+

drivers/clk/mediatek/clk-mt8188-topckgen.c line 350

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+static const char * const dsp7_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d4_d2",
+       "univpll_d5",
+       "univpll_d4",
+       "mmpll_d4",
+       "mainpll_d3",
+       "univpll_d3"
+};

These dsp*_parents all look very similar. From what I can tell there are two variants. Please merge them. You could name them dspX_Y_Z_parents
or something. Maybe add a comment just above them stating that the dsp* clocks have two variants.

Quoted 30 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +30 -0
+
+static const char * const mfg_core_tmp_parents[] = {
+       "clk26m",
+       "mainpll_d5_d2",
+       "univpll_d6",
+       "univpll_d7"
+};
+
+static const char * const camtg_parents[] = {
+       "clk26m",
+       "univpll_192m_d8",
+       "univpll_d6_d8",
+       "univpll_192m_d4",
+       "univpll_192m_d10",
+       "clk13m",
+       "univpll_192m_d16",
+       "univpll_192m_d32"
+};
+
+static const char * const camtg2_parents[] = {
+       "clk26m",
+       "univpll_192m_d8",
+       "univpll_d6_d8",
+       "univpll_192m_d4",
+       "univpll_192m_d10",
+       "clk13m",
+       "univpll_192m_d16",
+       "univpll_192m_d32"
+};
+

drivers/clk/mediatek/clk-mt8188-topckgen.c line 390

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+static const char * const camtg3_parents[] = {
+       "clk26m",
+       "univpll_192m_d8",
+       "univpll_d6_d8",
+       "univpll_192m_d4",
+       "univpll_192m_d10",
+       "clk13m",
+       "univpll_192m_d16",
+       "univpll_192m_d32"
+};

Please merge the three into one.

Quoted 36 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +36 -0
+static const char * const uart_parents[] = {
+       "clk26m",
+       "univpll_d6_d8"
+};
+
+static const char * const spi_parents[] = {
+       "clk26m",
+       "mainpll_d5_d4",
+       "mainpll_d6_d4",
+       "univpll_d6_d4",
+       "univpll_d6_d2",
+       "mainpll_d6_d2",
+       "mainpll_d4_d4",
+       "univpll_d5_d4"
+};
+
+static const char * const msdc5hclk_parents[] = {
+       "clk26m",
+       "mainpll_d4_d2",
+       "mainpll_d6_d2"
+};
+
+static const char * const msdc50_0_parents[] = {
+       "clk26m",
+       "msdcpll_ck",
+       "msdcpll_d2",
+       "univpll_d4_d4",
+       "mainpll_d6_d2",
+       "univpll_d4_d2"
+};
+
+static const char * const msdc30_1_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d6_d2",
+       "mainpll_d7_d2",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 437

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "msdcpll_d2"
+};
+
+static const char * const msdc30_2_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "mainpll_d6_d2",
+       "mainpll_d7_d2",
+       "msdcpll_d2"
+};

Merge the two.

Quoted 71 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +71 -0
+static const char * const intdir_parents[] = {
+       "clk26m",
+       "univpll_d6",
+       "mainpll_d4",
+       "univpll_d4"
+};
+
+static const char * const aud_intbus_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d7_d4"
+};
+
+static const char * const audio_h_parents[] = {
+       "clk26m",
+       "univpll_d7",
+       "apll1",
+       "apll2"
+};
+
+static const char * const pwrap_ulposc_parents[] = {
+       "clk26m",
+       "ulposc1_d10",
+       "ulposc1_d7",
+       "ulposc1_d8",
+       "ulposc1_d16",
+       "mainpll_d4_d8",
+       "univpll_d5_d8",
+       "tvdpll1_d16"
+};
+
+static const char * const atb_parents[] = {
+       "clk26m",
+       "mainpll_d4_d2",
+       "mainpll_d5_d2"
+};
+
+static const char * const sspm_parents[] = {
+       "clk26m",
+       "mainpll_d7_d2",
+       "mainpll_d6_d2",
+       "mainpll_d5_d2",
+       "mainpll_d9",
+       "mainpll_d4_d2"
+};
+
+static const char * const dp_parents[] = {
+       "clk26m",
+       "tvdpll1_d2",
+       "tvdpll2_d2",
+       "tvdpll1_d4",
+       "tvdpll2_d4",
+       "tvdpll1_d8",
+       "tvdpll2_d8",
+       "tvdpll1_d16",
+       "tvdpll2_d16"
+};
+
+static const char * const edp_parents[] = {
+       "clk26m",
+       "tvdpll1_d2",
+       "tvdpll2_d2",
+       "tvdpll1_d4",
+       "tvdpll2_d4",
+       "tvdpll1_d8",
+       "tvdpll2_d8",
+       "tvdpll1_d16",
+       "tvdpll2_d16"
+};
+
+static const char * const dpi_parents[] = {

drivers/clk/mediatek/clk-mt8188-topckgen.c line 519

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "clk26m",
+       "tvdpll1_d2",
+       "tvdpll2_d2",
+       "tvdpll1_d4",
+       "tvdpll2_d4",
+       "tvdpll1_d8",
+       "tvdpll2_d8",
+       "tvdpll1_d16",
+       "tvdpll2_d16"
+};

Merge the three.

Quoted 6 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +6 -0
+static const char * const disp_pwm0_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "ulposc1_d2",
+       "ulposc1_d4",
+       "ulposc1_d16",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 536

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "ethpll_d4"
+};
+
+static const char * const disp_pwm1_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "ulposc1_d2",
+       "ulposc1_d4",
+       "ulposc1_d16"
+};

You could merge the two, and add a comment saying that pwm1 doesn't have
the last clock. Later below in the clock definition, for pwm1 just have
ARRAY_SIZE() - 1 for num_parents.

This one is up to you though. It's trading amount of code for complexity.

Quoted 31 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +31 -0
+static const char * const usb_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const ssusb_xhci_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const usb_2p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const ssusb_xhci_2p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const usb_3p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 578

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};
+
+static const char * const ssusb_xhci_3p_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "univpll_d6_d4",
+       "univpll_d5_d2"
+};

These are all the same. Please merge them. Maybe call them usb_parents?

Quoted 17 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +17 -0
+static const char * const i2c_parents[] = {
+       "clk26m",
+       "mainpll_d4_d8",
+       "univpll_d5_d4"
+};
+
+static const char * const seninf_parents[] = {
+       "clk26m",
+       "univpll_d4_d4",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d7",
+       "univpll_d6",
+       "mmpll_d6",
+       "univpll_d5"
+};
+

drivers/clk/mediatek/clk-mt8188-topckgen.c line 606

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+static const char * const seninf1_parents[] = {
+       "clk26m",
+       "univpll_d4_d4",
+       "univpll_d6_d2",
+       "mainpll_d4_d2",
+       "univpll_d7",
+       "univpll_d6",
+       "mmpll_d6",
+       "univpll_d5"
+};

These two are the same. Please merge.

Quoted 74 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +74 -0
+static const char * const gcpu_parents[] = {
+       "clk26m",
+       "mainpll_d6",
+       "univpll_d4_d2",
+       "mmpll_d5_d2",
+       "univpll_d5_d2"
+};
+
+static const char * const venc_parents[] = {
+       "clk26m",
+       "mmpll_d4_d2",
+       "mainpll_d6",
+       "univpll_d4_d2",
+       "mainpll_d4_d2",
+       "univpll_d6",
+       "mmpll_d6",
+       "mainpll_d5_d2",
+       "mainpll_d6_d2",
+       "mmpll_d9",
+       "univpll_d4_d4",
+       "mainpll_d4",
+       "univpll_d4",
+       "univpll_d5",
+       "univpll_d5_d2",
+       "mainpll_d5"
+};
+
+static const char * const vdec_parents[] = {
+       "clk26m",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "univpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mmpll_d6",
+       "mainpll_d4",
+       "tvdpll2",
+       "univpll_d4",
+       "imgpll_ck",
+       "univpll_d6_d2",
+       "mmpll_d9"
+};
+
+static const char * const pwm_parents[] = {
+       "clk32k",
+       "clk26m",
+       "univpll_d4_d8",
+       "univpll_d6_d4"
+};
+
+static const char * const mcupm_parents[] = {
+       "clk26m",
+       "mainpll_d6_d2",
+       "mainpll_d7_d4"
+};
+
+static const char * const spmi_p_mst_parents[] = {
+       "clk26m",
+       "clk13m",
+       "ulposc1_d8",
+       "ulposc1_d10",
+       "ulposc1_d16",
+       "ulposc1_d7",
+       "clk32k",
+       "mainpll_d7_d8",
+       "mainpll_d6_d8",
+       "mainpll_d5_d8"
+};
+
+static const char * const spmi_m_mst_parents[] = {
+       "clk26m",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 691

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "clk13m",
+       "ulposc1_d8",
+       "ulposc1_d10",
+       "ulposc1_d16",
+       "ulposc1_d7",
+       "clk32k",
+       "mainpll_d7_d8",
+       "mainpll_d6_d8",
+       "mainpll_d5_d8"
+};

Merge these two.

Quoted 196 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +196 -0
+static const char * const dvfsrc_parents[] = {
+       "clk26m",
+       "ulposc1_d10",
+       "univpll_d6_d8",
+       "msdcpll_d16"
+};
+
+static const char * const tl_parents[] = {
+       "clk26m",
+       "univpll_d5_d4",
+       "mainpll_d4_d4"
+};
+
+static const char * const aes_msdcfde_parents[] = {
+       "clk26m",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "mainpll_d4_d4",
+       "univpll_d4_d2",
+       "univpll_d6"
+};
+
+static const char * const dsi_occ_parents[] = {
+       "clk26m",
+       "univpll_d6_d2",
+       "univpll_d5_d2",
+       "univpll_d4_d2"
+};
+
+static const char * const wpe_vpp_parents[] = {
+       "clk26m",
+       "mainpll_d5_d2",
+       "mmpll_d6_d2",
+       "univpll_d5_d2",
+       "mainpll_d4_d2",
+       "univpll_d4_d2",
+       "mmpll_d4_d2",
+       "mainpll_d6",
+       "mmpll_d7",
+       "univpll_d6",
+       "mainpll_d5",
+       "univpll_d5",
+       "mainpll_d4",
+       "tvdpll1",
+       "univpll_d4"
+};
+
+static const char * const hdcp_parents[] = {
+       "clk26m",
+       "univpll_d4_d8",
+       "mainpll_d5_d8",
+       "univpll_d6_d4"
+};
+
+static const char * const hdcp_24m_parents[] = {
+       "clk26m",
+       "univpll_192m_d4",
+       "univpll_192m_d8",
+       "univpll_d6_d8"
+};
+
+static const char * const hdmi_apb_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "msdcpll_d2"
+};
+
+static const char * const snps_eth_250m_parents[] = {
+       "clk26m",
+       "ethpll_d2"
+};
+
+static const char * const snps_eth_62p4m_ptp_parents[] = {
+       "apll2_d3",
+       "apll1_d3",
+       "clk26m",
+       "ethpll_d8"
+};
+
+static const char * const snps_eth_50m_rmii_parents[] = {
+       "clk26m",
+       "ethpll_d10"
+};
+
+static const char * const adsp_parents[] = {
+       "clk26m",
+       "clk13m",
+       "mainpll_d6",
+       "mainpll_d5_d2",
+       "univpll_d4_d4",
+       "univpll_d4",
+       "ulposc1_d2",
+       "ulposc1_ck1",
+       "adsppll_ck",
+       "adsppll_d2",
+       "adsppll_d4",
+       "adsppll_d8"
+};
+
+static const char * const audio_local_bus_parents[] = {
+       "clk26m",
+       "clk13m",
+       "mainpll_d4_d4",
+       "mainpll_d7_d2",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d7",
+       "mainpll_d4",
+       "univpll_d6",
+       "ulposc1_ck1",
+       "ulposc1_d4",
+       "ulposc1_d2"
+};
+
+static const char * const asm_h_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "univpll_d6_d2",
+       "mainpll_d5_d2"
+};
+
+static const char * const asm_l_parents[] = {
+       "clk26m",
+       "univpll_d6_d4",
+       "univpll_d6_d2",
+       "mainpll_d5_d2"
+};
+
+static const char * const apll1_parents[] = {
+       "clk26m",
+       "apll1_d4"
+};
+
+static const char * const apll2_parents[] = {
+       "clk26m",
+       "apll2_d4"
+};
+
+static const char * const apll3_parents[] = {
+       "clk26m",
+       "apll3_d4"
+};
+
+static const char * const apll4_parents[] = {
+       "clk26m",
+       "apll4_d4"
+};
+
+static const char * const apll5_parents[] = {
+       "clk26m",
+       "apll5_d4"
+};
+
+static const char * const i2so1_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const i2so2_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const i2si1_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const i2si2_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};
+
+static const char * const dptx_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"

drivers/clk/mediatek/clk-mt8188-topckgen.c line 898

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+};
+
+static const char * const aud_iec_parents[] = {
+       "clk26m",
+       "apll1",
+       "apll2",
+       "apll3",
+       "apll4",
+       "apll5"
+};

Please merge all these. Maybe call them something like aud_if?

Quoted 13 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +13 -0
+static const char * const a1sys_hp_parents[] = {
+       "clk26m",
+       "apll1_d4"
+};
+
+static const char * const a2sys_parents[] = {
+       "clk26m",
+       "apll2_d4"
+};
+
+static const char * const a3sys_parents[] = {
+       "clk26m",
+       "apll3_d4",

drivers/clk/mediatek/clk-mt8188-topckgen.c line 922

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +10 -0
+       "apll4_d4",
+       "apll5_d4"
+};
+
+static const char * const a4sys_parents[] = {
+       "clk26m",
+       "apll3_d4",
+       "apll4_d4",
+       "apll5_d4"
+};

Please merge the two.

Quoted 582 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +37 -0
+static const char * const ecc_parents[] = {
+       "clk26m",
+       "mainpll_d4_d4",
+       "mainpll_d5_d2",
+       "mainpll_d4_d2",
+       "mainpll_d6",
+       "univpll_d6"
+};
+
+static const char * const spinor_parents[] = {
+       "clk26m",
+       "clk13m",
+       "mainpll_d7_d8",
+       "univpll_d6_d8"
+};
+
+static const char * const ulposc_parents[] = {
+       "ulposc_ck1",
+       "ethpll_d2",
+       "mainpll_d4_d2",
+       "ethpll_d10"
+};
+
+static const char * const srck_parents[] = {
+       "ulposc1_d10",
+       "clk26m"
+};
+
+static const char * const mfg_fast_ref_parents[] = {
+       "top_mfg_core_tmp",
+       "mfgpll_ck"
+};
+
+static const struct mtk_mux top_mtk_muxes[] = {
+       /*
+        * CLK_CFG_0
+        * axi_sel and bus_aximem_sel are bus clocks, should not be

closed by Linux.
+ * spm_sel and scp_sel are main clocks in always-on co-
processor.

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+        */
+       MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_AXI, "top_axi",

axi_parents,
+ 0x020, 0x024, 0x028, 0, 4, 7,
0x04, 0, CLK_IS_CRITICAL),
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SPM, "top_spm",
spm_parents,
+ 0x020, 0x024, 0x028, 8, 4, 15,
0x04, 1, CLK_IS_CRITICAL),
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SCP, "top_scp",
scp_parents,
+ 0x020, 0x024, 0x028, 16, 4, 23,
0x04, 2, CLK_IS_CRITICAL),
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_BUS_AXIMEM,
"top_bus_aximem", bus_aximem_parents,
+ 0x020, 0x024, 0x028, 24, 4, 31,
0x04, 3, CLK_IS_CRITICAL),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_1 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_VPP, "top_vpp",
+                            vpp_parents, 0x02C, 0x030, 0x034, 0,

4, 7, 0x04, 4),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ETHDR, "top_ethdr",
+                            ethdr_parents, 0x02C, 0x030, 0x034, 8,

4, 15, 0x04, 5),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_IPE, "top_ipe",
+                            ipe_parents, 0x02C, 0x030, 0x034, 16,

4, 23, 0x04, 6),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAM, "top_cam",
+                            cam_parents, 0x02C, 0x030, 0x034, 24,

4, 31, 0x04, 7),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_2 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CCU, "top_ccu",
+                            ccu_parents, 0x038, 0x03C, 0x040, 0,

4, 7, 0x04, 8),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CCU_AHB, "top_ccu_ahb",
+                            ccu_ahb_parents, 0x038, 0x03C, 0x040,

8, 4, 15, 0x04, 9),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_IMG, "top_img",
+                            img_parents, 0x038, 0x03C, 0x040, 16,

4, 23, 0x04, 10),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTM, "top_camtm",
+                            camtm_parents, 0x038, 0x03C, 0x040,

24, 4, 31, 0x04, 11),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_3 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP, "top_dsp",
+                            dsp_parents, 0x044, 0x048, 0x04C, 0,

4, 7, 0x04, 12),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP1, "top_dsp1",
+                            dsp1_parents, 0x044, 0x048, 0x04C, 8,

4, 15, 0x04, 13),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP2, "top_dsp2",
+                            dsp2_parents, 0x044, 0x048, 0x04C, 16,

4, 23, 0x04, 14),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP3, "top_dsp3",
+                            dsp3_parents, 0x044, 0x048, 0x04C, 24,

4, 31, 0x04, 15),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_4 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP4, "top_dsp4",
+                            dsp4_parents, 0x050, 0x054, 0x058, 0,

4, 7, 0x04, 16),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP5, "top_dsp5",
+                            dsp5_parents, 0x050, 0x054, 0x058, 8,

4, 15, 0x04, 17),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP6, "top_dsp6",
+                            dsp6_parents, 0x050, 0x054, 0x058, 16,

4, 23, 0x04, 18),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSP7, "top_dsp7",
+                            dsp7_parents, 0x050, 0x054, 0x058, 24,

4, 31, 0x04, 19),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       /* CLK_CFG_5 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MFG_CORE_TMP,

"top_mfg_core_tmp",
+ mfg_core_tmp_parents, 0x05C, 0x060,
0x064, 0, 4, 7, 0x04, 20),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG, "top_camtg",
+                            camtg_parents, 0x05C, 0x060, 0x064, 8,

4, 15, 0x04, 21),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG2, "top_camtg2",
+                            camtg2_parents, 0x05C, 0x060, 0x064,

16, 4, 23, 0x04, 22),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_CAMTG3, "top_camtg3",
+                            camtg3_parents, 0x05C, 0x060, 0x064,

24, 4, 31, 0x04, 23),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_6 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_UART, "top_uart",
+                            uart_parents, 0x068, 0x06C, 0x070, 0,

4, 7, 0x04, 24),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPI, "top_spi",
+                            spi_parents, 0x068, 0x06C, 0x070, 8,

4, 15, 0x04, 25),
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0_HCLK,
"top_msdc5hclk",
+ msdc5hclk_parents, 0x068, 0x06C,
0x070, 16, 4, 23, 0x04, 26),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC50_0, "top_msdc50_0",
+                            msdc50_0_parents, 0x068, 0x06C, 0x070,

24, 4, 31, 0x04, 27),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_7 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_1, "top_msdc30_1",
+                            msdc30_1_parents, 0x074, 0x078, 0x07C,

0, 4, 7, 0x04, 28),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_MSDC30_2, "top_msdc30_2",
+                            msdc30_2_parents, 0x074, 0x078, 0x07C,

8, 4, 15, 0x04, 29),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_INTDIR, "top_intdir",
+                            intdir_parents, 0x074, 0x078, 0x07C,

16, 4, 23, 0x04, 30),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_INTBUS, "top_aud_intbus",
+                            aud_intbus_parents, 0x074, 0x078,

0x07C, 24, 4, 31, 0x04, 31),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_8 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_H, "top_audio_h",
+                            audio_h_parents, 0x080, 0x084, 0x088,

0, 4, 7, 0x08, 0),
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_PWRAP_ULPOSC,
"top_pwrap_ulposc",
+ pwrap_ulposc_parents, 0x080, 0x084,
0x088, 8, 4, 15, 0x08, 1),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ATB, "top_atb",
+                            atb_parents, 0x080, 0x084, 0x088, 16,

4, 23, 0x08, 2),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSPM, "top_sspm",
+                            sspm_parents, 0x080, 0x084, 0x088, 24,

4, 31, 0x08, 3),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_9 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DP, "top_dp",
+                            dp_parents, 0x08C, 0x090, 0x094, 0, 4,

7, 0x08, 4),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_EDP, "top_edp",
+                            edp_parents, 0x08C, 0x090, 0x094, 8,

4, 15, 0x08, 5),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DPI, "top_dpi",
+                            dpi_parents, 0x08C, 0x090, 0x094, 16,

4, 23, 0x08, 6),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP_PWM0, "top_disp_pwm0",
+                            disp_pwm0_parents, 0x08C, 0x090,

0x094, 24, 4, 31, 0x08, 7),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_10 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DISP_PWM1, "top_disp_pwm1",
+                            disp_pwm1_parents, 0x098, 0x09C,

0x0A0, 0, 4, 7, 0x08, 8),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP, "top_usb_top",
+                            usb_parents, 0x098, 0x09C, 0x0A0, 8,

4, 15, 0x08, 9),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI, "top_ssusb_xhci",
+                            ssusb_xhci_parents, 0x098, 0x09C,

0x0A0, 16, 4, 23, 0x08, 10),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP_2P, "top_usb_top_2p",
+                            usb_2p_parents, 0x098, 0x09C, 0x0A0,

24, 4, 31, 0x08, 11),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       /* CLK_CFG_11 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI_2P,

"top_ssusb_xhci_2p",
+ ssusb_xhci_2p_parents, 0x0A4, 0x0A8,
0x0AC, 0, 4, 7, 0x08, 12),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_USB_TOP_3P, "top_usb_top_3p",
+                            usb_3p_parents, 0x0A4, 0x0A8, 0x0AC,

8, 4, 15, 0x08, 13),
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_SSUSB_XHCI_3P,
"top_ssusb_xhci_3p",
+ ssusb_xhci_3p_parents, 0x0A4, 0x0A8,
0x0AC, 16, 4, 23, 0x08, 14),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2C, "top_i2c",
+                            i2c_parents, 0x0A4, 0x0A8, 0x0AC, 24,

4, 31, 0x08, 15),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_12 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF, "top_seninf",
+                            seninf_parents, 0x0B0, 0x0B4, 0x0B8,

0, 4, 7, 0x08, 16),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SENINF1, "top_seninf1",
+                            seninf1_parents, 0x0B0, 0x0B4, 0x0B8,

8, 4, 15, 0x08, 17),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_GCPU, "top_gcpu",
+                            gcpu_parents, 0x0B0, 0x0B4, 0x0B8, 16,

4, 23, 0x08, 18),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_VENC, "top_venc",
+                            venc_parents, 0x0B0, 0x0B4, 0x0B8, 24,

4, 31, 0x08, 19),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /*
+        * CLK_CFG_13
+        * top_mcupm is main clock in co-processor, should not be

handled by Linux.

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+        */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_VDEC, "top_vdec",
+                            vdec_parents, 0x0BC, 0x0C0, 0x0C4, 0,

4, 7, 0x08, 20),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_PWM, "top_pwm",
+                            pwm_parents, 0x0BC, 0x0C0, 0x0C4, 8,

4, 15, 0x08, 21),
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MCUPM, "top_mcupm",
mcupm_parents,
+ 0x0BC, 0x0C0, 0x0C4, 16, 4, 23,
0x08, 22, CLK_IS_CRITICAL),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPMI_P_MST, "top_spmi_p_mst",
+                            spmi_p_mst_parents, 0x0BC, 0x0C0,

0x0C4, 24, 4, 31, 0x08, 23),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /*
+        * CLK_CFG_14
+        * dvfsrc_sel is for internal DVFS usage, should not be

handled by Linux.

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+        */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPMI_M_MST, "top_spmi_m_mst",
+                            spmi_m_mst_parents, 0x0C8, 0x0CC,

0x0D0, 0, 4, 7, 0x08, 24),
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_DVFSRC, "top_dvfsrc",
dvfsrc_parents,
+ 0x0C8, 0x0CC, 0x0D0, 8, 4, 15,
0x08, 25, CLK_IS_CRITICAL),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_TL, "top_tl",
+                            tl_parents, 0x0C8, 0x0CC, 0x0D0, 16,

4, 23, 0x08, 26),
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_AES_MSDCFDE,
"top_aes_msdcfde",
+ aes_msdcfde_parents, 0x0C8, 0x0CC,
0x0D0, 24, 4, 31, 0x08, 27),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_15 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DSI_OCC, "top_dsi_occ",
+                            dsi_occ_parents, 0x0D4, 0x0D8, 0x0DC,

0, 4, 7, 0x08, 28),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_WPE_VPP, "top_wpe_vpp",
+                            wpe_vpp_parents, 0x0D4, 0x0D8, 0x0DC,

8, 4, 15, 0x08, 29),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_HDCP, "top_hdcp",
+                            hdcp_parents, 0x0D4, 0x0D8, 0x0DC, 16,

4, 23, 0x08, 30),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_HDCP_24M, "top_hdcp_24m",
+                            hdcp_24m_parents, 0x0D4, 0x0D8, 0x0DC,

24, 4, 31, 0x08, 31),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_16 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_HDMI_APB, "top_hdmi_apb",
+                            hdmi_apb_parents, 0x0E0, 0x0E4, 0x0E8,

0, 4, 7, 0x0C, 0),
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_250M,
"top_snps_eth_250m",
+ snps_eth_250m_parents, 0x0E0, 0x0E4,
0x0E8, 8, 4, 15, 0x0C, 1),
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_62P4M_PTP,
"top_snps_eth_62p4m_ptp",
+ snps_eth_62p4m_ptp_parents, 0x0E0,
0x0E4, 0x0E8, 16, 4, 23, 0x0C, 2),
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_SNPS_ETH_50M_RMII,
"snps_eth_50m_rmii",
+ snps_eth_50m_rmii_parents, 0x0E0,
0x0E4, 0x0E8, 24, 4, 31, 0x0C, 3),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_17 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ADSP, "top_adsp",
+                            adsp_parents, 0x0EC, 0x0F0, 0x0F4, 0,

4, 7, 0x0C, 4),
+ MUX_GATE_CLR_SET_UPD(CLK_TOP_AUDIO_LOCAL_BUS,
"top_audio_local_bus",
+ audio_local_bus_parents, 0x0EC, 0x0F0,
0x0F4, 8, 4, 15, 0x0C, 5),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ASM_H, "top_asm_h",
+                            asm_h_parents, 0x0EC, 0x0F0, 0x0F4,

16, 4, 23, 0x0C, 6),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ASM_L, "top_asm_l",
+                            asm_l_parents, 0x0EC, 0x0F0, 0x0F4,

24, 4, 31, 0x0C, 7),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_18 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL1, "top_apll1",
+                            apll1_parents, 0x0F8, 0x0FC, 0x100, 0,

4, 7, 0x0C, 8),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL2, "top_apll2",
+                            apll2_parents, 0x0F8, 0x0FC, 0x100, 8,

4, 15, 0x0C, 9),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL3, "top_apll3",
+                            apll3_parents, 0x0F8, 0x0FC, 0x100,

16, 4, 23, 0x0C, 10),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL4, "top_apll4",
+                            apll4_parents, 0x0F8, 0x0FC, 0x100,

24, 4, 31, 0x0C, 11),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_19 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_APLL5, "top_apll5",
+                            apll5_parents, 0x0104, 0x0108, 0x010C,

0, 4, 7, 0x0C, 12),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SO1, "top_i2so1",
+                            i2so1_parents, 0x0104, 0x0108, 0x010C,

8, 4, 15, 0x0C, 13),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SO2, "top_i2so2",
+                            i2so2_parents, 0x0104, 0x0108, 0x010C,

16, 4, 23, 0x0C, 14),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SI1, "top_i2si1",
+                            i2si1_parents, 0x0104, 0x0108, 0x010C,

24, 4, 31, 0x0C, 15),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_20 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_I2SI2, "top_i2si2",
+                            i2si2_parents, 0x0110, 0x0114, 0x0118,

0, 4, 7, 0x0C, 16),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_DPTX, "top_dptx",
+                            dptx_parents, 0x0110, 0x0114, 0x0118,

8, 4, 15, 0x0C, 17),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_AUD_IEC, "top_aud_iec",
+                            aud_iec_parents, 0x0110, 0x0114,

0x0118, 16, 4, 23, 0x0C, 18),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A1SYS_HP, "top_a1sys_hp",
+                            a1sys_hp_parents, 0x0110, 0x0114,

0x0118, 24, 4, 31, 0x0C, 19),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* CLK_CFG_21 */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A2SYS, "top_a2sys",
+                            a2sys_parents, 0x011C, 0x0120, 0x0124,

0, 4, 7, 0x0C, 20),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A3SYS, "top_a3sys",
+                            a3sys_parents, 0x011C, 0x0120, 0x0124,

8, 4, 15, 0x0C, 21),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_A4SYS, "top_a4sys",
+                            a4sys_parents, 0x011C, 0x0120, 0x0124,

16, 4, 23, 0x0C, 22),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_ECC, "top_ecc",
+                            ecc_parents, 0x011C, 0x0120, 0x0124,

24, 4, 31, 0x0C, 23),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /*
+        * CLK_CFG_22
+        * top_ulposc/top_srck are clock source of always on co-

processor,

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+        * should not be closed by Linux.
+        */
+       MUX_GATE_CLR_SET_UPD(CLK_TOP_SPINOR, "top_spinor",
+                            spinor_parents, 0x0128, 0x012C,

0x0130, 0, 4, 7, 0x0C, 24),
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_ULPOSC, "top_ulposc",
ulposc_parents,
+ 0x0128, 0x012C, 0x0130, 8, 4,
15, 0x0C, 25, CLK_IS_CRITICAL),
+ MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_SRCK, "top_srck",
srck_parents,
+ 0x0128, 0x012C, 0x0130, 16, 4,
23, 0x0C, 26, CLK_IS_CRITICAL),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+};
+
+static const struct mtk_composite top_adj_divs[] = {
+       DIV_GATE(CLK_TOP_APLL12_CK_DIV0, "apll12_div0",

"top_i2si1", 0x0320, 0, 0x0328, 8, 0),
+ DIV_GATE(CLK_TOP_APLL12_CK_DIV1, "apll12_div1",
"top_i2si2", 0x0320, 1, 0x0328, 8, 8),
+ DIV_GATE(CLK_TOP_APLL12_CK_DIV2, "apll12_div2",
"top_i2so1", 0x0320, 2, 0x0328, 8, 16),
+ DIV_GATE(CLK_TOP_APLL12_CK_DIV3, "apll12_div3",
"top_i2so2", 0x0320, 3, 0x0328, 8, 24),
+ DIV_GATE(CLK_TOP_APLL12_CK_DIV4, "apll12_div4",
"top_aud_iec", 0x0320, 4, 0x0334, 8, 0),
+ DIV_GATE(CLK_TOP_APLL12_CK_DIV9, "apll12_div9", "top_dptx",
0x0320, 9, 0x0338, 8, 8),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +15 -0
+};
+static const struct mtk_gate_regs top0_cg_regs = {
+       .set_ofs = 0x238,
+       .clr_ofs = 0x238,
+       .sta_ofs = 0x238,
+};
+
+static const struct mtk_gate_regs top1_cg_regs = {
+       .set_ofs = 0x250,
+       .clr_ofs = 0x250,
+       .sta_ofs = 0x250,
+};
+
+#define GATE_TOP0(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &top0_cg_regs, _shift,

&mtk_clk_gate_ops_no_setclr_inv)

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+
+#define GATE_TOP1(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &top1_cg_regs, _shift,

&mtk_clk_gate_ops_no_setclr_inv)

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+
+static const struct mtk_gate top_clks[] = {
+       /* TOP0 */
+       GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VPP0,

"cfgreg_clock_vpp0", "top_vpp", 0),
+ GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VPP1,
"cfgreg_clock_vpp1", "top_vpp", 1),
+ GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VDO0,
"cfgreg_clock_vdo0", "top_vpp", 2),
+ GATE_TOP0(CLK_TOP_CFGREG_CLOCK_EN_VDO1,
"cfgreg_clock_vdo1", "top_vpp", 3),
+ GATE_TOP0(CLK_TOP_CFGREG_CLOCK_ISP_AXI_GALS,
"cfgreg_clock_isp_axi_gals", "top_vpp", 4),
+ GATE_TOP0(CLK_TOP_CFGREG_F26M_VPP0, "cfgreg_f26m_vpp0",
"clk26m", 5),
+ GATE_TOP0(CLK_TOP_CFGREG_F26M_VPP1, "cfgreg_f26m_vpp1",
"clk26m", 6),
+ GATE_TOP0(CLK_TOP_CFGREG_F26M_VDO0, "cfgreg_f26m_vdo0",
"clk26m", 7),
+ GATE_TOP0(CLK_TOP_CFGREG_F26M_VDO1, "cfgreg_f26m_vdo1",
"clk26m", 8),
+ GATE_TOP0(CLK_TOP_CFGREG_AUD_F26M_AUD,
"cfgreg_aud_f26m_aud", "clk26m", 9),
+ GATE_TOP0(CLK_TOP_CFGREG_UNIPLL_SES, "cfgreg_unipll_ses",
"univpll_d2", 15),
+ GATE_TOP0(CLK_TOP_CFGREG_F_PCIE_PHY_REF,
"cfgreg_f_pcie_phy_ref", "clk26m", 18),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +3 -0
+       /* TOP1 */
+       GATE_TOP1(CLK_TOP_SSUSB_TOP_REF, "ssusb_ref", "clk26m", 0),
+       GATE_TOP1(CLK_TOP_SSUSB_PHY_REF, "ssusb_phy_ref", "clk26m",

1),
+ GATE_TOP1(CLK_TOP_SSUSB_TOP_P1_REF, "ssusb_p1_ref",
"clk26m", 2),
+ GATE_TOP1(CLK_TOP_SSUSB_PHY_P1_REF, "ssusb_phy_p1_ref",
"clk26m", 3),
+ GATE_TOP1(CLK_TOP_SSUSB_TOP_P2_REF, "ssusb_p2_ref",
"clk26m", 4),
+ GATE_TOP1(CLK_TOP_SSUSB_PHY_P2_REF, "ssusb_phy_p2_ref",
"clk26m", 5),
+ GATE_TOP1(CLK_TOP_SSUSB_TOP_P3_REF, "ssusb_p3_ref",
"clk26m", 6),
+ GATE_TOP1(CLK_TOP_SSUSB_PHY_P3_REF, "ssusb_phy_p3_ref",
"clk26m", 7),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +9 -0
+};
+
+static const struct of_device_id of_match_clk_mt8188_topck[] = {
+       { .compatible = "mediatek,mt8188-topckgen", },
+       {}
+};
+
+/* Register mux notifier for MFG mux */
+static int clk_mt8188_reg_mfg_mux_notifier(struct device *dev,

struct clk *clk)

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+{
+       struct mtk_mux_nb *mfg_mux_nb;
+
+       mfg_mux_nb = devm_kzalloc(dev, sizeof(*mfg_mux_nb),

GFP_KERNEL);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +5 -0
+       if (!mfg_mux_nb)
+               return -ENOMEM;
+
+       mfg_mux_nb->ops = &clk_mux_ops;
+       mfg_mux_nb->bypass_index = 0; /* Bypass to TOP_MFG_CORE_TMP

*/

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+
+       return devm_mtk_clk_mux_notifier_register(dev, clk,

mfg_mux_nb);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +21 -0
+}
+
+static int clk_mt8188_topck_probe(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *top_clk_data;
+       struct device_node *node = pdev->dev.of_node;
+       struct clk_hw *hw;
+       int r;
+       void __iomem *base;
+
+       top_clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+       if (!top_clk_data)
+               return -ENOMEM;
+
+       base = devm_platform_ioremap_resource(pdev, 0);
+       if (IS_ERR(base)) {
+               r = PTR_ERR(base);
+               goto free_top_data;
+       }
+
+       r = mtk_clk_register_fixed_clks(top_fixed_clks,

ARRAY_SIZE(top_fixed_clks),

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +5 -0
+                                       top_clk_data);
+       if (r)
+               goto free_top_data;
+
+       r = mtk_clk_register_factors(top_divs,

ARRAY_SIZE(top_divs), top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+       if (r)
+               goto unregister_fixed_clks;
+
+       r = mtk_clk_register_muxes(top_mtk_muxes,

ARRAY_SIZE(top_mtk_muxes), node,

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +5 -0
+                                  &mt8188_clk_lock, top_clk_data);
+       if (r)
+               goto unregister_factors;
+
+       hw = devm_clk_hw_register_mux(&pdev->dev,

"mfg_ck_fast_ref", mfg_fast_ref_parents,
+ ARRAY_SIZE(mfg_fast_ref_paren
ts), CLK_SET_RATE_PARENT,
+ (base + 0x250), 8, 1, 0,
&mt8188_clk_lock);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +8 -0
+       if (IS_ERR(hw)) {
+               r = PTR_ERR(hw);
+               goto unregister_muxes;
+       }
+       top_clk_data->hws[CLK_TOP_MFG_CK_FAST_REF] = hw;
+
+       r = clk_mt8188_reg_mfg_mux_notifier(&pdev->dev,
+                                           top_clk_data-
Quoted 1 line

hws[CLK_TOP_MFG_CK_FAST_REF]->clk);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+       if (r)
+               goto unregister_muxes;
+
+       r = mtk_clk_register_composites(top_adj_divs,

ARRAY_SIZE(top_adj_divs), base,
+ &mt8188_clk_lock,
top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+       if (r)
+               goto unregister_muxes;
+
+       r = mtk_clk_register_gates(node, top_clks,

ARRAY_SIZE(top_clks), top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+       if (r)
+               goto unregister_composite_divs;
+
+       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,

top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +9 -0
+       if (r)
+               goto unregister_gates;
+
+       platform_set_drvdata(pdev, top_clk_data);
+
+       return r;
+
+unregister_gates:
+       mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks),

top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+unregister_composite_divs:
+       mtk_clk_unregister_composites(top_adj_divs,

ARRAY_SIZE(top_adj_divs), top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+unregister_muxes:
+       mtk_clk_unregister_muxes(top_mtk_muxes,

ARRAY_SIZE(top_mtk_muxes), top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+unregister_factors:
+       mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs),

top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +2 -0
+unregister_fixed_clks:
+       mtk_clk_unregister_fixed_clks(top_fixed_clks,

ARRAY_SIZE(top_fixed_clks), top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +8 -0
+free_top_data:
+       mtk_free_clk_data(top_clk_data);
+       return r;
+}
+
+static int clk_mt8188_topck_remove(struct platform_device *pdev)
+{
+       struct clk_hw_onecell_data *top_clk_data =

platform_get_drvdata(pdev);

drivers/clk/mediatek/clk-mt8188-topckgen.c new file +4 -0
+       struct device_node *node = pdev->dev.of_node;
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_gates(top_clks, ARRAY_SIZE(top_clks),

top_clk_data);
+ mtk_clk_unregister_composites(top_adj_divs,
ARRAY_SIZE(top_adj_divs), top_clk_data);
+ mtk_clk_unregister_muxes(top_mtk_muxes,
ARRAY_SIZE(top_mtk_muxes), top_clk_data);
+ mtk_clk_unregister_factors(top_divs, ARRAY_SIZE(top_divs),
top_clk_data);
+ mtk_clk_unregister_fixed_clks(top_fixed_clks,
ARRAY_SIZE(top_fixed_clks), top_clk_data);

drivers/clk/mediatek/clk-mt8188-topckgen.c line 1346

Quoted 8 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +8 -0
+       mtk_free_clk_data(top_clk_data);
+
+       return 0;
+}
+
+static struct platform_driver clk_mt8188_topck_drv = {
+       .probe = clk_mt8188_topck_probe,
+       .remove = clk_mt8188_topck_remove,

With the recently merged cleanup and refactor, you can use the expanded
simple probe library for this. Please see clk-mt8192.c in latest -next.

Thanks
ChenYu

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-topckgen.c new file +6 -1
+       .driver = {
+               .name = "clk-mt8188-topck",
+               .of_match_table = of_match_clk_mt8188_topck,
+       },
+};
+builtin_platform_driver(clk_mt8188_topck_drv);
--

2.18.0

#9 lore raw

PATCH v5 4/19 clk: mediatek: Add MT8188 peripheral clock support

In reply to Garmin.Chang

Add MT8188 peripheral clock controller which provides clock gate control for ethernet/flashif/pcie/ssusb.

---
 drivers/clk/mediatek/Makefile             |  3 +-
 drivers/clk/mediatek/clk-mt8188-peri_ao.c | 56 +++++++++++++++++++++++
 2 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-peri_ao.c
drivers/clk/mediatek/Makefile +2 -1
index 89b1b331cad0..b8a3042f4809 100644
@@ -83,7 +83,8 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 				   clk-mt8186-mfg.o clk-mt8186-mm.o clk-mt8186-wpe.o \
 				   clk-mt8186-img.o clk-mt8186-vdec.o clk-mt8186-venc.o \
 				   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
-obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
+obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
+				   clk-mt8188-peri_ao.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-peri_ao.c new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
2.18.0
#11 lore raw

PATCH v5 5/19 clk: mediatek: Add MT8188 infrastructure clock support

In reply to Garmin.Chang

Add MT8188 infrastructure clock controller which provides clock gate control for basic IP like pwm, uart, spi and so on.

---
 drivers/clk/mediatek/Makefile              |   2 +-
 drivers/clk/mediatek/clk-mt8188-infra_ao.c | 196 +++++++++++++++++++++
 2 files changed, 197 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-infra_ao.c
drivers/clk/mediatek/Makefile +1 -1
index b8a3042f4809..a3393782f7e1 100644
@@ -84,7 +84,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 				   clk-mt8186-img.o clk-mt8186-vdec.o clk-mt8186-venc.o \
 				   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
-				   clk-mt8188-peri_ao.o
+				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-infra_ao.c new file +196 -0

196 lines not on this page · raw message

Signature · 1 line
2.18.0
#13 lore raw

PATCH v5 6/19 clk: mediatek: Add MT8188 camsys clock support

In reply to Garmin.Chang

Add MT8188 camsys clock controllers which provide clock gate control for camera IP blocks.

---
 drivers/clk/mediatek/Makefile         |   3 +-
 drivers/clk/mediatek/clk-mt8188-cam.c | 118 ++++++++++++++++++++++++++
 2 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-cam.c
drivers/clk/mediatek/Makefile +2 -1
index a3393782f7e1..dc247bf67e8b 100644
@@ -84,7 +84,8 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 				   clk-mt8186-img.o clk-mt8186-vdec.o clk-mt8186-venc.o \
 				   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
-				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o
+				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
+				   clk-mt8188-cam.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-cam.c new file +118 -0

118 lines not on this page · raw message

Signature · 1 line
2.18.0
#15 lore raw

PATCH v5 7/19 clk: mediatek: Add MT8188 ccusys clock support

In reply to Garmin.Chang

Add MT8188 ccusys clock controller which provides clock gate control in Camera Computing Unit.

---
 drivers/clk/mediatek/Makefile         |  2 +-
 drivers/clk/mediatek/clk-mt8188-ccu.c | 48 +++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-ccu.c
drivers/clk/mediatek/Makefile +1 -1
index dc247bf67e8b..dbd140b81763 100644
@@ -85,7 +85,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 				   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
 				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
-				   clk-mt8188-cam.o
+				   clk-mt8188-cam.o clk-mt8188-ccu.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-ccu.c new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
2.18.0
Reviewed-by on v5 7/19
#16 lore raw

Re: [PATCH v5 07/19] clk: mediatek: Add MT8188 ccusys clock support

Quoted 3 lines · Garmin.Chang

Add MT8188 ccusys clock controller which provides clock gate control in Camera Computing Unit.

If this is also for camera related functions, could you fold this into the previous CAM clock driver? That would save a bit of space.

The code looks OK.

Quoted 78 lines
---
 drivers/clk/mediatek/Makefile         |  2 +-
 drivers/clk/mediatek/clk-mt8188-ccu.c | 48 +++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-ccu.c
drivers/clk/mediatek/Makefile +1 -1
index dc247bf67e8b..dbd140b81763 100644
@@ -85,7 +85,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
                                   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
                                   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
-                                  clk-mt8188-cam.o
+                                  clk-mt8188-cam.o clk-mt8188-ccu.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-ccu.c new file +48 -1
new file mode 100644
index 000000000000..b7380060f906
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs ccu_cg_regs = {
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_CCU(_id, _name, _parent, _shift)                  \
+       GATE_MTK(_id, _name, _parent, &ccu_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate ccu_clks[] = {
+       GATE_CCU(CLK_CCU_LARB27, "ccu_larb27", "top_ccu", 0),
+       GATE_CCU(CLK_CCU_AHB, "ccu_ahb", "top_ccu", 1),
+       GATE_CCU(CLK_CCU_CCU0, "ccu_ccu0", "top_ccu", 2),
+};
+
+static const struct mtk_clk_desc ccu_desc = {
+       .clks = ccu_clks,
+       .num_clks = ARRAY_SIZE(ccu_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_ccu[] = {
+       { .compatible = "mediatek,mt8188-ccusys", .data = &ccu_desc},
+       { /* sentinel */ }
+};
+
+static struct platform_driver clk_mt8188_ccu_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-ccu",
+               .of_match_table = of_match_clk_mt8188_ccu,
+       },
+};
+
+builtin_platform_driver(clk_mt8188_ccu_drv);
+MODULE_LICENSE("GPL");
--

2.18.0

#17 lore raw

PATCH v5 8/19 clk: mediatek: Add MT8188 imgsys clock support

In reply to Garmin.Chang

Add MT8188 imgsys clock controllers which provide clock gate control for image IP blocks.

---
 drivers/clk/mediatek/Makefile         |   2 +-
 drivers/clk/mediatek/clk-mt8188-img.c | 110 ++++++++++++++++++++++++++
 2 files changed, 111 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-img.c
drivers/clk/mediatek/Makefile +1 -1
index dbd140b81763..be835d5e179d 100644
@@ -85,7 +85,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 				   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
 				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
-				   clk-mt8188-cam.o clk-mt8188-ccu.o
+				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-img.c new file +110 -0

110 lines not on this page · raw message

Signature · 1 line
2.18.0
#19 lore raw

PATCH v5 9/19 clk: mediatek: Add MT8188 ipesys clock support

In reply to Garmin.Chang

Add MT8188 ipesys clock controller which provides clock gate control for Image Process Engine.

---
 drivers/clk/mediatek/Makefile         |  3 +-
 drivers/clk/mediatek/clk-mt8188-ipe.c | 50 +++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-ipe.c
drivers/clk/mediatek/Makefile +2 -1
index be835d5e179d..4a599122f761 100644
@@ -85,7 +85,8 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 				   clk-mt8186-cam.o clk-mt8186-mdp.o clk-mt8186-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
 				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
-				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o
+				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
+				   clk-mt8188-ipe.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-ipe.c new file +50 -0

50 lines not on this page · raw message

Signature · 1 line
2.18.0
#21 lore raw

PATCH v5 10/19 clk: mediatek: Add MT8188 mfgcfg clock support

In reply to Garmin.Chang

Add MT8188 mfg clock controller which provides clock gate control for GPU.

---
 drivers/clk/mediatek/Makefile         |  2 +-
 drivers/clk/mediatek/clk-mt8188-mfg.c | 47 +++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-mfg.c
drivers/clk/mediatek/Makefile +1 -1
index 4a599122f761..a0fd87a882b5 100644
@@ -86,7 +86,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
 				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
 				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
-				   clk-mt8188-ipe.o
+				   clk-mt8188-ipe.o clk-mt8188-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-mfg.c new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
2.18.0
#22 lore raw

Re: [PATCH v5 10/19] clk: mediatek: Add MT8188 mfgcfg clock support

Quoted 44 lines · Garmin.Chang

Add MT8188 mfg clock controller which provides clock gate control for GPU.

---
 drivers/clk/mediatek/Makefile         |  2 +-
 drivers/clk/mediatek/clk-mt8188-mfg.c | 47 +++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-mfg.c
drivers/clk/mediatek/Makefile +1 -1
index 4a599122f761..a0fd87a882b5 100644
@@ -86,7 +86,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
                                   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
-                                  clk-mt8188-ipe.o
+                                  clk-mt8188-ipe.o clk-mt8188-mfg.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-mfg.c new file +14 -0
new file mode 100644
index 000000000000..57b0afb5f4df
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs mfgcfg_cg_regs = {
+       .set_ofs = 0x4,

drivers/clk/mediatek/clk-mt8188-mfg.c line 24

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-mfg.c new file +10 -0
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_MFG(_id, _name, _parent, _shift)                          \
+       GATE_MTK_FLAGS(_id, _name, _parent, &mfgcfg_cg_regs, _shift,    \
+                      &mtk_clk_gate_ops_setclr, CLK_SET_RATE_PARENT)
+
+static const struct mtk_gate mfgcfg_clks[] = {
+       GATE_MFG(CLK_MFGCFG_BG3D, "mfgcfg_bg3d", "top_mfg_core_tmp", 0),

Are you sure the parent isn't "mfg_ck_fast_ref"?

ChenYu

#23 lore raw

Re: [PATCH v5 10/19] clk: mediatek: Add MT8188 mfgcfg clock support

Quoted 62 lines · Chen-Yu Tsai
Quoted 60 lines · Garmin.Chang

Add MT8188 mfg clock controller which provides clock gate control for GPU.

---
 drivers/clk/mediatek/Makefile         |  2 +-
 drivers/clk/mediatek/clk-mt8188-mfg.c | 47
+++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-mfg.c
drivers/clk/mediatek/Makefile +0 -0
index 4a599122f761..a0fd87a882b5 100644
@@ -86,7 +86,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-

mcu.o clk-mt8186-topckgen.o clk-mt
obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-

mt8188-topckgen.o \
                                   clk-mt8188-peri_ao.o clk-mt8188-
infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-

ccu.o clk-mt8188-img.o \

drivers/clk/mediatek/Makefile +1 -1
-                                  clk-mt8188-ipe.o
+                                  clk-mt8188-ipe.o clk-mt8188-

mfg.o
obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o

drivers/clk/mediatek/clk-mt8188-mfg.c new file +19 -0
new file mode 100644
index 000000000000..57b0afb5f4df
@@ -0,0 +1,47 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs mfgcfg_cg_regs = {
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_MFG(_id, _name, _parent,

_shift) \
+ GATE_MTK_FLAGS(_id, _name, _parent, &mfgcfg_cg_regs,
_shift, \

Quoted 8 lines
Quoted 6 lines

+ &mtk_clk_gate_ops_setclr,
CLK_SET_RATE_PARENT)

drivers/clk/mediatek/clk-mt8188-mfg.c new file +3 -0
+
+static const struct mtk_gate mfgcfg_clks[] = {
+       GATE_MFG(CLK_MFGCFG_BG3D, "mfgcfg_bg3d",

"top_mfg_core_tmp", 0),

Are you sure the parent isn't "mfg_ck_fast_ref"?

Thank you for your suggestions.
OK, I will chnage to mfg_ck_fast_ref in v6.

Quoted 2 lines

ChenYu

#24 lore raw

PATCH v5 11/19 clk: mediatek: Add MT8188 vdecsys clock support

In reply to Garmin.Chang

Add MT8188 vdec clock controllers which provide clock gate control for video decoder.

---
 drivers/clk/mediatek/Makefile          |  2 +-
 drivers/clk/mediatek/clk-mt8188-vdec.c | 90 ++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdec.c
drivers/clk/mediatek/Makefile +1 -1
index a0fd87a882b5..7d09e9fc6538 100644
@@ -86,7 +86,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
 				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
 				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
-				   clk-mt8188-ipe.o clk-mt8188-mfg.o
+				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdec.c new file +90 -0

90 lines not on this page · raw message

Signature · 1 line
2.18.0
#25 lore raw

Re: [PATCH v5 11/19] clk: mediatek: Add MT8188 vdecsys clock support

Quoted 33 lines · Garmin.Chang

Add MT8188 vdec clock controllers which provide clock gate control for video decoder.

---
 drivers/clk/mediatek/Makefile          |  2 +-
 drivers/clk/mediatek/clk-mt8188-vdec.c | 90 ++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdec.c
drivers/clk/mediatek/Makefile +1 -1
index a0fd87a882b5..7d09e9fc6538 100644
@@ -86,7 +86,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
                                   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
-                                  clk-mt8188-ipe.o clk-mt8188-mfg.o
+                                  clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdec.c new file +3 -0
new file mode 100644
index 000000000000..e05a27957136
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.

drivers/clk/mediatek/clk-mt8188-vdec.c line 13

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-vdec.c new file +10 -0
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vde0_cg_regs = {

Could you replace all instances of "vde" (both upper and lower case) with "vdec" to be consistent with usages elsewhere?

Quoted 26 lines
drivers/clk/mediatek/clk-mt8188-vdec.c new file +26 -0
+       .set_ofs = 0x0,
+       .clr_ofs = 0x4,
+       .sta_ofs = 0x0,
+};
+
+static const struct mtk_gate_regs vde1_cg_regs = {
+       .set_ofs = 0x200,
+       .clr_ofs = 0x204,
+       .sta_ofs = 0x200,
+};
+
+static const struct mtk_gate_regs vde2_cg_regs = {
+       .set_ofs = 0x8,
+       .clr_ofs = 0xc,
+       .sta_ofs = 0x8,
+};
+
+#define GATE_VDE0(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &vde0_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+#define GATE_VDE1(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &vde1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+#define GATE_VDE2(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &vde2_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+

drivers/clk/mediatek/clk-mt8188-vdec.c line 49

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-vdec.c new file +10 -0
+static const struct mtk_gate vde1_clks[] = {
+       /* VDE1_0 */
+       GATE_VDE0(CLK_VDE1_SOC_VDEC, "vde1_soc_vdec", "top_vdec", 0),
+       GATE_VDE0(CLK_VDE1_SOC_VDEC_ACTIVE, "vde1_soc_vdec_active", "top_vdec", 4),
+       GATE_VDE0(CLK_VDE1_SOC_VDEC_ENG, "vde1_soc_vdec_eng", "top_vdec", 8),
+       /* VDE1_1 */
+       GATE_VDE1(CLK_VDE1_SOC_LAT, "vde1_soc_lat", "top_vdec", 0),
+       GATE_VDE1(CLK_VDE1_SOC_LAT_ACTIVE, "vde1_soc_lat_active", "top_vdec", 4),
+       GATE_VDE1(CLK_VDE1_SOC_LAT_ENG, "vde1_soc_lat_eng", "top_vdec", 8),
+       /* VDE12 */

Add an underscore like the above?

ChenYu

Quoted 45 lines
drivers/clk/mediatek/clk-mt8188-vdec.c new file +41 -1
+       GATE_VDE2(CLK_VDE1_SOC_LARB1, "vde1_soc_larb1", "top_vdec", 0),
+};
+
+static const struct mtk_gate vde2_clks[] = {
+       /* VDE2_0 */
+       GATE_VDE0(CLK_VDE2_VDEC, "vde2_vdec", "top_vdec", 0),
+       GATE_VDE0(CLK_VDE2_VDEC_ACTIVE, "vde2_vdec_active", "top_vdec", 4),
+       GATE_VDE0(CLK_VDE2_VDEC_ENG, "vde2_vdec_eng", "top_vdec", 8),
+       /* VDE2_1 */
+       GATE_VDE1(CLK_VDE2_LAT, "vde2_lat", "top_vdec", 0),
+       /* VDE2_2 */
+       GATE_VDE2(CLK_VDE2_LARB1, "vde2_larb1", "top_vdec", 0),
+};
+
+static const struct mtk_clk_desc vde1_desc = {
+       .clks = vde1_clks,
+       .num_clks = ARRAY_SIZE(vde1_clks),
+};
+
+static const struct mtk_clk_desc vde2_desc = {
+       .clks = vde2_clks,
+       .num_clks = ARRAY_SIZE(vde2_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_vde[] = {
+       { .compatible = "mediatek,mt8188-vdecsys-soc", .data = &vde1_desc },
+       { .compatible = "mediatek,mt8188-vdecsys", .data = &vde2_desc },
+       { /* sentinel */ }
+};
+
+static struct platform_driver clk_mt8188_vde_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-vde",
+               .of_match_table = of_match_clk_mt8188_vde,
+       },
+};
+
+builtin_platform_driver(clk_mt8188_vde_drv);
+MODULE_LICENSE("GPL");
--

2.18.0

#26 lore raw

Re: [PATCH v5 11/19] clk: mediatek: Add MT8188 vdecsys clock support

Quoted 49 lines · Chen-Yu Tsai
Quoted 47 lines · Garmin.Chang

Add MT8188 vdec clock controllers which provide clock gate control for video decoder.

---
 drivers/clk/mediatek/Makefile          |  2 +-
 drivers/clk/mediatek/clk-mt8188-vdec.c | 90
++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdec.c
drivers/clk/mediatek/Makefile +0 -0
index a0fd87a882b5..7d09e9fc6538 100644
@@ -86,7 +86,7 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-

mcu.o clk-mt8186-topckgen.o clk-mt
obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-

mt8188-topckgen.o \
                                   clk-mt8188-peri_ao.o clk-mt8188-
infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-

ccu.o clk-mt8188-img.o \
- clk-mt8188-ipe.o clk-mt8188-
mfg.o
+ clk-mt8188-ipe.o clk-mt8188-
mfg.o clk-mt8188-vdec.o
obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o

drivers/clk/mediatek/clk-mt8188-vdec.c new file +8 -0
new file mode 100644
index 000000000000..e05a27957136
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
Quoted 8 lines

drivers/clk/mediatek/clk-mt8188-vdec.c line 13

Quoted 5 lines
drivers/clk/mediatek/clk-mt8188-vdec.c new file +5 -0
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vde0_cg_regs = {

Could you replace all instances of "vde" (both upper and lower case) with "vdec" to be consistent with usages elsewhere?

Thank you for your suggestions.
OK, I will modify this series in v6.

Quoted 48 lines
Quoted 41 lines
drivers/clk/mediatek/clk-mt8188-vdec.c new file +19 -0
+       .set_ofs = 0x0,
+       .clr_ofs = 0x4,
+       .sta_ofs = 0x0,
+};
+
+static const struct mtk_gate_regs vde1_cg_regs = {
+       .set_ofs = 0x200,
+       .clr_ofs = 0x204,
+       .sta_ofs = 0x200,
+};
+
+static const struct mtk_gate_regs vde2_cg_regs = {
+       .set_ofs = 0x8,
+       .clr_ofs = 0xc,
+       .sta_ofs = 0x8,
+};
+
+#define GATE_VDE0(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &vde0_cg_regs, _shift,

&mtk_clk_gate_ops_setclr_inv)

drivers/clk/mediatek/clk-mt8188-vdec.c new file +3 -0
+
+#define GATE_VDE1(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &vde1_cg_regs, _shift,

&mtk_clk_gate_ops_setclr_inv)

drivers/clk/mediatek/clk-mt8188-vdec.c new file +3 -0
+
+#define GATE_VDE2(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &vde2_cg_regs, _shift,

&mtk_clk_gate_ops_setclr_inv)

drivers/clk/mediatek/clk-mt8188-vdec.c new file +4 -0
+
+static const struct mtk_gate vde1_clks[] = {
+       /* VDE1_0 */
+       GATE_VDE0(CLK_VDE1_SOC_VDEC, "vde1_soc_vdec", "top_vdec",

0),
+ GATE_VDE0(CLK_VDE1_SOC_VDEC_ACTIVE, "vde1_soc_vdec_active",
"top_vdec", 4),
+ GATE_VDE0(CLK_VDE1_SOC_VDEC_ENG, "vde1_soc_vdec_eng",
"top_vdec", 8),

drivers/clk/mediatek/clk-mt8188-vdec.c new file +3 -0
+       /* VDE1_1 */
+       GATE_VDE1(CLK_VDE1_SOC_LAT, "vde1_soc_lat", "top_vdec", 0),
+       GATE_VDE1(CLK_VDE1_SOC_LAT_ACTIVE, "vde1_soc_lat_active",
Quoted 4 lines

"top_vdec", 4),
+ GATE_VDE1(CLK_VDE1_SOC_LAT_ENG, "vde1_soc_lat_eng",
"top_vdec", 8),
+ /* VDE12 */

Add an underscore like the above?

Quoted 1 line

ChenYu

OK, I will add underscore in v6.

Quoted 51 lines
Quoted 51 lines

+ GATE_VDE2(CLK_VDE1_SOC_LARB1, "vde1_soc_larb1", "top_vdec",
0),

drivers/clk/mediatek/clk-mt8188-vdec.c new file +6 -0
+};
+
+static const struct mtk_gate vde2_clks[] = {
+       /* VDE2_0 */
+       GATE_VDE0(CLK_VDE2_VDEC, "vde2_vdec", "top_vdec", 0),
+       GATE_VDE0(CLK_VDE2_VDEC_ACTIVE, "vde2_vdec_active",

"top_vdec", 4),
+ GATE_VDE0(CLK_VDE2_VDEC_ENG, "vde2_vdec_eng", "top_vdec",
8),

drivers/clk/mediatek/clk-mt8188-vdec.c new file +18 -0
+       /* VDE2_1 */
+       GATE_VDE1(CLK_VDE2_LAT, "vde2_lat", "top_vdec", 0),
+       /* VDE2_2 */
+       GATE_VDE2(CLK_VDE2_LARB1, "vde2_larb1", "top_vdec", 0),
+};
+
+static const struct mtk_clk_desc vde1_desc = {
+       .clks = vde1_clks,
+       .num_clks = ARRAY_SIZE(vde1_clks),
+};
+
+static const struct mtk_clk_desc vde2_desc = {
+       .clks = vde2_clks,
+       .num_clks = ARRAY_SIZE(vde2_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_vde[] = {
+       { .compatible = "mediatek,mt8188-vdecsys-soc", .data =

&vde1_desc },
+ { .compatible = "mediatek,mt8188-vdecsys", .data =
&vde2_desc },

drivers/clk/mediatek/clk-mt8188-vdec.c new file +14 -1
+       { /* sentinel */ }
+};
+
+static struct platform_driver clk_mt8188_vde_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-vde",
+               .of_match_table = of_match_clk_mt8188_vde,
+       },
+};
+
+builtin_platform_driver(clk_mt8188_vde_drv);
+MODULE_LICENSE("GPL");
--

2.18.0

#27 lore raw

PATCH v5 12/19 clk: mediatek: Add MT8188 vdosys0 clock support

In reply to Garmin.Chang

Add MT8188 vdosys0 clock controller which provides clock gate control in video system. This is integrated with mtk-mmsys driver which will populate device by platform_device_register_data to start vdosys clock driver.

---
 drivers/clk/mediatek/Makefile          |   3 +-
 drivers/clk/mediatek/clk-mt8188-vdo0.c | 134 +++++++++++++++++++++++++
 2 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo0.c
drivers/clk/mediatek/Makefile +2 -1
index 7d09e9fc6538..df78c0777fef 100644
@@ -86,7 +86,8 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
 				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
 				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
-				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o
+				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
+				   clk-mt8188-vdo0.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdo0.c new file +134 -0

134 lines not on this page · raw message

Signature · 1 line
2.18.0
#28 lore raw

Re: [PATCH v5 12/19] clk: mediatek: Add MT8188 vdosys0 clock support

Quoted 118 lines · Garmin.Chang

Add MT8188 vdosys0 clock controller which provides clock gate control in video system. This is integrated with mtk-mmsys driver which will populate device by platform_device_register_data to start vdosys clock driver.

---
 drivers/clk/mediatek/Makefile          |   3 +-
 drivers/clk/mediatek/clk-mt8188-vdo0.c | 134 +++++++++++++++++++++++++
 2 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo0.c
drivers/clk/mediatek/Makefile +2 -1
index 7d09e9fc6538..df78c0777fef 100644
@@ -86,7 +86,8 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
 obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
                                   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
-                                  clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o
+                                  clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
+                                  clk-mt8188-vdo0.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdo0.c new file +85 -0
new file mode 100644
index 000000000000..30dd64374ace
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vdo0_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vdo0_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs vdo0_2_cg_regs = {
+       .set_ofs = 0x124,
+       .clr_ofs = 0x128,
+       .sta_ofs = 0x120,
+};
+
+#define GATE_VDO0_0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo0_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO0_1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo0_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO0_2(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo0_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO0_2_FLAGS(_id, _name, _parent, _shift, _flags)         \
+       GATE_MTK_FLAGS(_id, _name, _parent, &vdo0_2_cg_regs, _shift,    \
+       &mtk_clk_gate_ops_setclr, _flags)
+
+static const struct mtk_gate vdo0_clks[] = {
+       /* VDO0_0 */
+       GATE_VDO0_0(CLK_VDO0_DISP_OVL0, "vdo0_disp_ovl0", "top_vpp", 0),
+       GATE_VDO0_0(CLK_VDO0_FAKE_ENG0, "vdo0_fake_eng0", "top_vpp", 2),
+       GATE_VDO0_0(CLK_VDO0_DISP_CCORR0, "vdo0_disp_ccorr0", "top_vpp", 4),
+       GATE_VDO0_0(CLK_VDO0_DISP_MUTEX0, "vdo0_disp_mutex0", "top_vpp", 6),
+       GATE_VDO0_0(CLK_VDO0_DISP_GAMMA0, "vdo0_disp_gamma0", "top_vpp", 8),
+       GATE_VDO0_0(CLK_VDO0_DISP_DITHER0, "vdo0_disp_dither0", "top_vpp", 10),
+       GATE_VDO0_0(CLK_VDO0_DISP_WDMA0, "vdo0_disp_wdma0", "top_vpp", 17),
+       GATE_VDO0_0(CLK_VDO0_DISP_RDMA0, "vdo0_disp_rdma0", "top_vpp", 19),
+       GATE_VDO0_0(CLK_VDO0_DSI0, "vdo0_dsi0", "top_vpp", 21),
+       GATE_VDO0_0(CLK_VDO0_DSI1, "vdo0_dsi1", "top_vpp", 22),
+       GATE_VDO0_0(CLK_VDO0_DSC_WRAP0, "vdo0_dsc_wrap0", "top_vpp", 23),
+       GATE_VDO0_0(CLK_VDO0_VPP_MERGE0, "vdo0_vpp_merge0", "top_vpp", 24),
+       GATE_VDO0_0(CLK_VDO0_DP_INTF0, "vdo0_dp_intf0", "top_vpp", 25),
+       GATE_VDO0_0(CLK_VDO0_DISP_AAL0, "vdo0_disp_aal0", "top_vpp", 26),
+       GATE_VDO0_0(CLK_VDO0_INLINEROT0, "vdo0_inlinerot0", "top_vpp", 27),
+       GATE_VDO0_0(CLK_VDO0_APB_BUS, "vdo0_apb_bus", "top_vpp", 28),
+       GATE_VDO0_0(CLK_VDO0_DISP_COLOR0, "vdo0_disp_color0", "top_vpp", 29),
+       GATE_VDO0_0(CLK_VDO0_MDP_WROT0, "vdo0_mdp_wrot0", "top_vpp", 30),
+       GATE_VDO0_0(CLK_VDO0_DISP_RSZ0, "vdo0_disp_rsz0", "top_vpp", 31),
+       /* VDO0_1 */
+       GATE_VDO0_1(CLK_VDO0_DISP_POSTMASK0, "vdo0_disp_postmask0", "top_vpp", 0),
+       GATE_VDO0_1(CLK_VDO0_FAKE_ENG1, "vdo0_fake_eng1", "top_vpp", 1),
+       GATE_VDO0_1(CLK_VDO0_DL_ASYNC2, "vdo0_dl_async2", "top_vpp", 5),
+       GATE_VDO0_1(CLK_VDO0_DL_RELAY3, "vdo0_dl_relay3", "top_vpp", 6),
+       GATE_VDO0_1(CLK_VDO0_DL_RELAY4, "vdo0_dl_relay4", "top_vpp", 7),
+       GATE_VDO0_1(CLK_VDO0_SMI_GALS, "vdo0_smi_gals", "top_vpp", 10),
+       GATE_VDO0_1(CLK_VDO0_SMI_COMMON, "vdo0_smi_common", "top_vpp", 11),
+       GATE_VDO0_1(CLK_VDO0_SMI_EMI, "vdo0_smi_emi", "top_vpp", 12),
+       GATE_VDO0_1(CLK_VDO0_SMI_IOMMU, "vdo0_smi_iommu", "top_vpp", 13),
+       GATE_VDO0_1(CLK_VDO0_SMI_LARB, "vdo0_smi_larb", "top_vpp", 14),
+       GATE_VDO0_1(CLK_VDO0_SMI_RSI, "vdo0_smi_rsi", "top_vpp", 15),
+       /* VDO0_2 */
+       GATE_VDO0_2(CLK_VDO0_DSI0_DSI, "vdo0_dsi0_dsi", "top_dsi_occ", 0),
+       GATE_VDO0_2(CLK_VDO0_DSI1_DSI, "vdo0_dsi1_dsi", "top_dsi_occ", 8),
+       GATE_VDO0_2_FLAGS(CLK_VDO0_DP_INTF0_DP_INTF, "vdo0_dp_intf0_dp_intf",
+               "top_edp", 16, CLK_SET_RATE_PARENT),
+};
+
+static int clk_mt8188_vdo0_probe(struct platform_device *pdev)
+{

drivers/clk/mediatek/clk-mt8188-vdo0.c line 95

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-vdo0.c new file +10 -0
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_VDO0_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data);

This API was changed. Please rebase onto the latest -next and update.

Angelo (CC-ed) also mentioned a new simple probe variant for non-DT clock drivers is being developed. He didn't mention a timeline though.

#29 lore raw

Re: [PATCH v5 12/19] clk: mediatek: Add MT8188 vdosys0 clock support

Il 03/02/23 08:19, Chen-Yu Tsai ha scritto:

Quoted 132 lines · Garmin.Chang
Quoted 118 lines

Add MT8188 vdosys0 clock controller which provides clock gate control in video system. This is integrated with mtk-mmsys driver which will populate device by platform_device_register_data to start vdosys clock driver.

---
  drivers/clk/mediatek/Makefile          |   3 +-
  drivers/clk/mediatek/clk-mt8188-vdo0.c | 134 +++++++++++++++++++++++++
  2 files changed, 136 insertions(+), 1 deletion(-)

create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo0.c

drivers/clk/mediatek/Makefile +2 -1
index 7d09e9fc6538..df78c0777fef 100644
@@ -86,7 +86,8 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-mcu.o clk-mt8186-topckgen.o clk-mt
  obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o \
                                    clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
                                    clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
-                                  clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o
+                                  clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
+                                  clk-mt8188-vdo0.o
  obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
  obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
  obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdo0.c new file +85 -0
new file mode 100644
index 000000000000..30dd64374ace
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vdo0_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vdo0_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs vdo0_2_cg_regs = {
+       .set_ofs = 0x124,
+       .clr_ofs = 0x128,
+       .sta_ofs = 0x120,
+};
+
+#define GATE_VDO0_0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo0_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO0_1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo0_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO0_2(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo0_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO0_2_FLAGS(_id, _name, _parent, _shift, _flags)         \
+       GATE_MTK_FLAGS(_id, _name, _parent, &vdo0_2_cg_regs, _shift,    \
+       &mtk_clk_gate_ops_setclr, _flags)
+
+static const struct mtk_gate vdo0_clks[] = {
+       /* VDO0_0 */
+       GATE_VDO0_0(CLK_VDO0_DISP_OVL0, "vdo0_disp_ovl0", "top_vpp", 0),
+       GATE_VDO0_0(CLK_VDO0_FAKE_ENG0, "vdo0_fake_eng0", "top_vpp", 2),
+       GATE_VDO0_0(CLK_VDO0_DISP_CCORR0, "vdo0_disp_ccorr0", "top_vpp", 4),
+       GATE_VDO0_0(CLK_VDO0_DISP_MUTEX0, "vdo0_disp_mutex0", "top_vpp", 6),
+       GATE_VDO0_0(CLK_VDO0_DISP_GAMMA0, "vdo0_disp_gamma0", "top_vpp", 8),
+       GATE_VDO0_0(CLK_VDO0_DISP_DITHER0, "vdo0_disp_dither0", "top_vpp", 10),
+       GATE_VDO0_0(CLK_VDO0_DISP_WDMA0, "vdo0_disp_wdma0", "top_vpp", 17),
+       GATE_VDO0_0(CLK_VDO0_DISP_RDMA0, "vdo0_disp_rdma0", "top_vpp", 19),
+       GATE_VDO0_0(CLK_VDO0_DSI0, "vdo0_dsi0", "top_vpp", 21),
+       GATE_VDO0_0(CLK_VDO0_DSI1, "vdo0_dsi1", "top_vpp", 22),
+       GATE_VDO0_0(CLK_VDO0_DSC_WRAP0, "vdo0_dsc_wrap0", "top_vpp", 23),
+       GATE_VDO0_0(CLK_VDO0_VPP_MERGE0, "vdo0_vpp_merge0", "top_vpp", 24),
+       GATE_VDO0_0(CLK_VDO0_DP_INTF0, "vdo0_dp_intf0", "top_vpp", 25),
+       GATE_VDO0_0(CLK_VDO0_DISP_AAL0, "vdo0_disp_aal0", "top_vpp", 26),
+       GATE_VDO0_0(CLK_VDO0_INLINEROT0, "vdo0_inlinerot0", "top_vpp", 27),
+       GATE_VDO0_0(CLK_VDO0_APB_BUS, "vdo0_apb_bus", "top_vpp", 28),
+       GATE_VDO0_0(CLK_VDO0_DISP_COLOR0, "vdo0_disp_color0", "top_vpp", 29),
+       GATE_VDO0_0(CLK_VDO0_MDP_WROT0, "vdo0_mdp_wrot0", "top_vpp", 30),
+       GATE_VDO0_0(CLK_VDO0_DISP_RSZ0, "vdo0_disp_rsz0", "top_vpp", 31),
+       /* VDO0_1 */
+       GATE_VDO0_1(CLK_VDO0_DISP_POSTMASK0, "vdo0_disp_postmask0", "top_vpp", 0),
+       GATE_VDO0_1(CLK_VDO0_FAKE_ENG1, "vdo0_fake_eng1", "top_vpp", 1),
+       GATE_VDO0_1(CLK_VDO0_DL_ASYNC2, "vdo0_dl_async2", "top_vpp", 5),
+       GATE_VDO0_1(CLK_VDO0_DL_RELAY3, "vdo0_dl_relay3", "top_vpp", 6),
+       GATE_VDO0_1(CLK_VDO0_DL_RELAY4, "vdo0_dl_relay4", "top_vpp", 7),
+       GATE_VDO0_1(CLK_VDO0_SMI_GALS, "vdo0_smi_gals", "top_vpp", 10),
+       GATE_VDO0_1(CLK_VDO0_SMI_COMMON, "vdo0_smi_common", "top_vpp", 11),
+       GATE_VDO0_1(CLK_VDO0_SMI_EMI, "vdo0_smi_emi", "top_vpp", 12),
+       GATE_VDO0_1(CLK_VDO0_SMI_IOMMU, "vdo0_smi_iommu", "top_vpp", 13),
+       GATE_VDO0_1(CLK_VDO0_SMI_LARB, "vdo0_smi_larb", "top_vpp", 14),
+       GATE_VDO0_1(CLK_VDO0_SMI_RSI, "vdo0_smi_rsi", "top_vpp", 15),
+       /* VDO0_2 */
+       GATE_VDO0_2(CLK_VDO0_DSI0_DSI, "vdo0_dsi0_dsi", "top_dsi_occ", 0),
+       GATE_VDO0_2(CLK_VDO0_DSI1_DSI, "vdo0_dsi1_dsi", "top_dsi_occ", 8),
+       GATE_VDO0_2_FLAGS(CLK_VDO0_DP_INTF0_DP_INTF, "vdo0_dp_intf0_dp_intf",
+               "top_edp", 16, CLK_SET_RATE_PARENT),
+};
+
+static int clk_mt8188_vdo0_probe(struct platform_device *pdev)
+{

drivers/clk/mediatek/clk-mt8188-vdo0.c line 95

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-vdo0.c new file +10 -0
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_VDO0_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vdo0_clks, ARRAY_SIZE(vdo0_clks), clk_data);

This API was changed. Please rebase onto the latest -next and update.

Quoted 2 lines

Angelo (CC-ed) also mentioned a new simple probe variant for non-DT clock drivers is being developed. He didn't mention a timeline though.

I've already tested the new simple probe variant for non-DT clock drivers and it works fine on MT8173, MT8192 and MT8195.

Timeline - I should be able to push the part 2 series next week, which will include more conversion to simple probe and almost all clock drivers changed to allow building as modules.

Cheers,
Angelo

#30 lore raw

Re: [PATCH v5 12/19] clk: mediatek: Add MT8188 vdosys0 clock support

Quoted 193 lines · AngeloGioacchino Del Regno

Il 03/02/23 08:19, Chen-Yu Tsai ha scritto:

Quoted 184 lines
Quoted 177 lines · Garmin.Chang

Add MT8188 vdosys0 clock controller which provides clock gate control in video system. This is integrated with mtk-mmsys driver which will populate device by platform_device_register_data
to start vdosys clock driver.

---
  drivers/clk/mediatek/Makefile          |   3 +-
  drivers/clk/mediatek/clk-mt8188-vdo0.c | 134
+++++++++++++++++++++++++
  2 files changed, 136 insertions(+), 1 deletion(-)

create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo0.c

drivers/clk/mediatek/Makefile +0 -0
index 7d09e9fc6538..df78c0777fef 100644
@@ -86,7 +86,8 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-

mcu.o clk-mt8186-topckgen.o clk-mt
obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-

mt8188-topckgen.o \
                                    clk-mt8188-peri_ao.o clk-
mt8188-infra_ao.o \
                                    clk-mt8188-cam.o clk-mt8188-

ccu.o clk-mt8188-img.o \
- clk-mt8188-ipe.o clk-mt8188-
mfg.o clk-mt8188-vdec.o
+ clk-mt8188-ipe.o clk-mt8188-
mfg.o clk-mt8188-vdec.o \

drivers/clk/mediatek/Makefile +1 -0
+                                  clk-mt8188-vdo0.o
  obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
  obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
  obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdo0.c new file +31 -0
new file mode 100644
index 000000000000..30dd64374ace
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vdo0_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vdo0_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs vdo0_2_cg_regs = {
+       .set_ofs = 0x124,
+       .clr_ofs = 0x128,
+       .sta_ofs = 0x120,
+};
+
+#define GATE_VDO0_0(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vdo0_0_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+
+#define GATE_VDO0_1(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vdo0_1_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+
+#define GATE_VDO0_2(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vdo0_2_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+
+#define GATE_VDO0_2_FLAGS(_id, _name, _parent, _shift,

_flags) \
+ GATE_MTK_FLAGS(_id, _name, _parent, &vdo0_2_cg_regs,
_shift, \

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +5 -0
+       &mtk_clk_gate_ops_setclr, _flags)
+
+static const struct mtk_gate vdo0_clks[] = {
+       /* VDO0_0 */
+       GATE_VDO0_0(CLK_VDO0_DISP_OVL0, "vdo0_disp_ovl0",

"top_vpp", 0),
+ GATE_VDO0_0(CLK_VDO0_FAKE_ENG0, "vdo0_fake_eng0",
"top_vpp", 2),
+ GATE_VDO0_0(CLK_VDO0_DISP_CCORR0, "vdo0_disp_ccorr0",
"top_vpp", 4),
+ GATE_VDO0_0(CLK_VDO0_DISP_MUTEX0, "vdo0_disp_mutex0",
"top_vpp", 6),
+ GATE_VDO0_0(CLK_VDO0_DISP_GAMMA0, "vdo0_disp_gamma0",
"top_vpp", 8),
+ GATE_VDO0_0(CLK_VDO0_DISP_DITHER0, "vdo0_disp_dither0",
"top_vpp", 10),
+ GATE_VDO0_0(CLK_VDO0_DISP_WDMA0, "vdo0_disp_wdma0",
"top_vpp", 17),
+ GATE_VDO0_0(CLK_VDO0_DISP_RDMA0, "vdo0_disp_rdma0",
"top_vpp", 19),

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +3 -0
+       GATE_VDO0_0(CLK_VDO0_DSI0, "vdo0_dsi0", "top_vpp", 21),
+       GATE_VDO0_0(CLK_VDO0_DSI1, "vdo0_dsi1", "top_vpp", 22),
+       GATE_VDO0_0(CLK_VDO0_DSC_WRAP0, "vdo0_dsc_wrap0",

"top_vpp", 23),
+ GATE_VDO0_0(CLK_VDO0_VPP_MERGE0, "vdo0_vpp_merge0",
"top_vpp", 24),
+ GATE_VDO0_0(CLK_VDO0_DP_INTF0, "vdo0_dp_intf0",
"top_vpp", 25),
+ GATE_VDO0_0(CLK_VDO0_DISP_AAL0, "vdo0_disp_aal0",
"top_vpp", 26),
+ GATE_VDO0_0(CLK_VDO0_INLINEROT0, "vdo0_inlinerot0",
"top_vpp", 27),
+ GATE_VDO0_0(CLK_VDO0_APB_BUS, "vdo0_apb_bus", "top_vpp",
28),
+ GATE_VDO0_0(CLK_VDO0_DISP_COLOR0, "vdo0_disp_color0",
"top_vpp", 29),
+ GATE_VDO0_0(CLK_VDO0_MDP_WROT0, "vdo0_mdp_wrot0",
"top_vpp", 30),
+ GATE_VDO0_0(CLK_VDO0_DISP_RSZ0, "vdo0_disp_rsz0",
"top_vpp", 31),

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+       /* VDO0_1 */
+       GATE_VDO0_1(CLK_VDO0_DISP_POSTMASK0,

"vdo0_disp_postmask0", "top_vpp", 0),
+ GATE_VDO0_1(CLK_VDO0_FAKE_ENG1, "vdo0_fake_eng1",
"top_vpp", 1),
+ GATE_VDO0_1(CLK_VDO0_DL_ASYNC2, "vdo0_dl_async2",
"top_vpp", 5),
+ GATE_VDO0_1(CLK_VDO0_DL_RELAY3, "vdo0_dl_relay3",
"top_vpp", 6),
+ GATE_VDO0_1(CLK_VDO0_DL_RELAY4, "vdo0_dl_relay4",
"top_vpp", 7),
+ GATE_VDO0_1(CLK_VDO0_SMI_GALS, "vdo0_smi_gals",
"top_vpp", 10),
+ GATE_VDO0_1(CLK_VDO0_SMI_COMMON, "vdo0_smi_common",
"top_vpp", 11),
+ GATE_VDO0_1(CLK_VDO0_SMI_EMI, "vdo0_smi_emi", "top_vpp",
12),
+ GATE_VDO0_1(CLK_VDO0_SMI_IOMMU, "vdo0_smi_iommu",
"top_vpp", 13),
+ GATE_VDO0_1(CLK_VDO0_SMI_LARB, "vdo0_smi_larb",
"top_vpp", 14),
+ GATE_VDO0_1(CLK_VDO0_SMI_RSI, "vdo0_smi_rsi", "top_vpp",
15),

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+       /* VDO0_2 */
+       GATE_VDO0_2(CLK_VDO0_DSI0_DSI, "vdo0_dsi0_dsi",

"top_dsi_occ", 0),
+ GATE_VDO0_2(CLK_VDO0_DSI1_DSI, "vdo0_dsi1_dsi",
"top_dsi_occ", 8),
+ GATE_VDO0_2_FLAGS(CLK_VDO0_DP_INTF0_DP_INTF,
"vdo0_dp_intf0_dp_intf",

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +15 -0
+               "top_edp", 16, CLK_SET_RATE_PARENT),
+};
+
+static int clk_mt8188_vdo0_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_VDO0_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vdo0_clks,
Quoted 1 line

ARRAY_SIZE(vdo0_clks), clk_data);

This API was changed. Please rebase onto the latest -next and update.

Quoted 3 lines

Angelo (CC-ed) also mentioned a new simple probe variant for non-DT clock drivers is being developed. He didn't mention a timeline though.

I've already tested the new simple probe variant for non-DT clock drivers and
it works fine on MT8173, MT8192 and MT8195.

Quoted 9 lines

Timeline - I should be able to push the part 2 series next week, which will include
more conversion to simple probe and almost all clock drivers changed to allow
building as modules.

Cheers,
Angelo

Thank you for your suggestions.
When the new simple probe variant and building as modules are ready, I will rebase latest-next and update it.

#31 lore raw

Re: [PATCH v5 12/19] clk: mediatek: Add MT8188 vdosys0 clock support

Il 09/03/23 06:49, Garmin Chang (張家銘) ha scritto:

Quoted 200 lines · AngeloGioacchino Del Regno
Quoted 199 lines

Il 03/02/23 08:19, Chen-Yu Tsai ha scritto:

Quoted 184 lines
Quoted 177 lines · Garmin.Chang

Add MT8188 vdosys0 clock controller which provides clock gate control in video system. This is integrated with mtk-mmsys driver which will populate device by platform_device_register_data
to start vdosys clock driver.

---
   drivers/clk/mediatek/Makefile          |   3 +-
   drivers/clk/mediatek/clk-mt8188-vdo0.c | 134
+++++++++++++++++++++++++
   2 files changed, 136 insertions(+), 1 deletion(-)

create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo0.c

drivers/clk/mediatek/Makefile +0 -0
index 7d09e9fc6538..df78c0777fef 100644
@@ -86,7 +86,8 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-

mcu.o clk-mt8186-topckgen.o clk-mt
obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-

mt8188-topckgen.o \
                                     clk-mt8188-peri_ao.o clk-
mt8188-infra_ao.o \
                                     clk-mt8188-cam.o clk-mt8188-

ccu.o clk-mt8188-img.o \
- clk-mt8188-ipe.o clk-mt8188-
mfg.o clk-mt8188-vdec.o
+ clk-mt8188-ipe.o clk-mt8188-
mfg.o clk-mt8188-vdec.o \

drivers/clk/mediatek/Makefile +1 -0
+                                  clk-mt8188-vdo0.o
   obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
   obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
   obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdo0.c new file +31 -0
new file mode 100644
index 000000000000..30dd64374ace
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vdo0_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vdo0_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs vdo0_2_cg_regs = {
+       .set_ofs = 0x124,
+       .clr_ofs = 0x128,
+       .sta_ofs = 0x120,
+};
+
+#define GATE_VDO0_0(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vdo0_0_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+
+#define GATE_VDO0_1(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vdo0_1_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+
+#define GATE_VDO0_2(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vdo0_2_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+
+#define GATE_VDO0_2_FLAGS(_id, _name, _parent, _shift,

_flags) \
+ GATE_MTK_FLAGS(_id, _name, _parent, &vdo0_2_cg_regs,
_shift, \

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +5 -0
+       &mtk_clk_gate_ops_setclr, _flags)
+
+static const struct mtk_gate vdo0_clks[] = {
+       /* VDO0_0 */
+       GATE_VDO0_0(CLK_VDO0_DISP_OVL0, "vdo0_disp_ovl0",

"top_vpp", 0),
+ GATE_VDO0_0(CLK_VDO0_FAKE_ENG0, "vdo0_fake_eng0",
"top_vpp", 2),
+ GATE_VDO0_0(CLK_VDO0_DISP_CCORR0, "vdo0_disp_ccorr0",
"top_vpp", 4),
+ GATE_VDO0_0(CLK_VDO0_DISP_MUTEX0, "vdo0_disp_mutex0",
"top_vpp", 6),
+ GATE_VDO0_0(CLK_VDO0_DISP_GAMMA0, "vdo0_disp_gamma0",
"top_vpp", 8),
+ GATE_VDO0_0(CLK_VDO0_DISP_DITHER0, "vdo0_disp_dither0",
"top_vpp", 10),
+ GATE_VDO0_0(CLK_VDO0_DISP_WDMA0, "vdo0_disp_wdma0",
"top_vpp", 17),
+ GATE_VDO0_0(CLK_VDO0_DISP_RDMA0, "vdo0_disp_rdma0",
"top_vpp", 19),

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +3 -0
+       GATE_VDO0_0(CLK_VDO0_DSI0, "vdo0_dsi0", "top_vpp", 21),
+       GATE_VDO0_0(CLK_VDO0_DSI1, "vdo0_dsi1", "top_vpp", 22),
+       GATE_VDO0_0(CLK_VDO0_DSC_WRAP0, "vdo0_dsc_wrap0",

"top_vpp", 23),
+ GATE_VDO0_0(CLK_VDO0_VPP_MERGE0, "vdo0_vpp_merge0",
"top_vpp", 24),
+ GATE_VDO0_0(CLK_VDO0_DP_INTF0, "vdo0_dp_intf0",
"top_vpp", 25),
+ GATE_VDO0_0(CLK_VDO0_DISP_AAL0, "vdo0_disp_aal0",
"top_vpp", 26),
+ GATE_VDO0_0(CLK_VDO0_INLINEROT0, "vdo0_inlinerot0",
"top_vpp", 27),
+ GATE_VDO0_0(CLK_VDO0_APB_BUS, "vdo0_apb_bus", "top_vpp",
28),
+ GATE_VDO0_0(CLK_VDO0_DISP_COLOR0, "vdo0_disp_color0",
"top_vpp", 29),
+ GATE_VDO0_0(CLK_VDO0_MDP_WROT0, "vdo0_mdp_wrot0",
"top_vpp", 30),
+ GATE_VDO0_0(CLK_VDO0_DISP_RSZ0, "vdo0_disp_rsz0",
"top_vpp", 31),

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+       /* VDO0_1 */
+       GATE_VDO0_1(CLK_VDO0_DISP_POSTMASK0,

"vdo0_disp_postmask0", "top_vpp", 0),
+ GATE_VDO0_1(CLK_VDO0_FAKE_ENG1, "vdo0_fake_eng1",
"top_vpp", 1),
+ GATE_VDO0_1(CLK_VDO0_DL_ASYNC2, "vdo0_dl_async2",
"top_vpp", 5),
+ GATE_VDO0_1(CLK_VDO0_DL_RELAY3, "vdo0_dl_relay3",
"top_vpp", 6),
+ GATE_VDO0_1(CLK_VDO0_DL_RELAY4, "vdo0_dl_relay4",
"top_vpp", 7),
+ GATE_VDO0_1(CLK_VDO0_SMI_GALS, "vdo0_smi_gals",
"top_vpp", 10),
+ GATE_VDO0_1(CLK_VDO0_SMI_COMMON, "vdo0_smi_common",
"top_vpp", 11),
+ GATE_VDO0_1(CLK_VDO0_SMI_EMI, "vdo0_smi_emi", "top_vpp",
12),
+ GATE_VDO0_1(CLK_VDO0_SMI_IOMMU, "vdo0_smi_iommu",
"top_vpp", 13),
+ GATE_VDO0_1(CLK_VDO0_SMI_LARB, "vdo0_smi_larb",
"top_vpp", 14),
+ GATE_VDO0_1(CLK_VDO0_SMI_RSI, "vdo0_smi_rsi", "top_vpp",
15),

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+       /* VDO0_2 */
+       GATE_VDO0_2(CLK_VDO0_DSI0_DSI, "vdo0_dsi0_dsi",

"top_dsi_occ", 0),
+ GATE_VDO0_2(CLK_VDO0_DSI1_DSI, "vdo0_dsi1_dsi",
"top_dsi_occ", 8),
+ GATE_VDO0_2_FLAGS(CLK_VDO0_DP_INTF0_DP_INTF,
"vdo0_dp_intf0_dp_intf",

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +15 -0
+               "top_edp", 16, CLK_SET_RATE_PARENT),
+};
+
+static int clk_mt8188_vdo0_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_VDO0_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vdo0_clks,
Quoted 1 line

ARRAY_SIZE(vdo0_clks), clk_data);

This API was changed. Please rebase onto the latest -next and update.

Quoted 3 lines

Angelo (CC-ed) also mentioned a new simple probe variant for non-DT clock drivers is being developed. He didn't mention a timeline though.

I've already tested the new simple probe variant for non-DT clock drivers and
it works fine on MT8173, MT8192 and MT8195.

Timeline - I should be able to push the part 2 series next week, which will include
more conversion to simple probe and almost all clock drivers changed to allow
building as modules.

Quoted 6 lines
Quoted 3 lines

Cheers,
Angelo

Thank you for your suggestions.
When the new simple probe variant and building as modules are ready, I will rebase latest-next and update it.

It's *finally* ready as it's fully tested and reviewed.

You can go on with a rebase on top of it:

https://patchwork.kernel.org/project/linux-mediatek/list/?series=726914

Regards,
Angelo

#32 lore raw

Re: [PATCH v5 12/19] clk: mediatek: Add MT8188 vdosys0 clock support

In reply to Chen-Yu Tsai
Quoted 173 lines · Chen-Yu Tsai
Quoted 171 lines · Garmin.Chang

Add MT8188 vdosys0 clock controller which provides clock gate control in video system. This is integrated with mtk-mmsys driver which will populate device by platform_device_register_data to start vdosys clock driver.

---
 drivers/clk/mediatek/Makefile          |   3 +-
 drivers/clk/mediatek/clk-mt8188-vdo0.c | 134
+++++++++++++++++++++++++
 2 files changed, 136 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo0.c
drivers/clk/mediatek/Makefile +0 -0
index 7d09e9fc6538..df78c0777fef 100644
@@ -86,7 +86,8 @@ obj-$(CONFIG_COMMON_CLK_MT8186) += clk-mt8186-

mcu.o clk-mt8186-topckgen.o clk-mt
obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-

mt8188-topckgen.o \
                                   clk-mt8188-peri_ao.o clk-mt8188-
infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-

ccu.o clk-mt8188-img.o \
- clk-mt8188-ipe.o clk-mt8188-
mfg.o clk-mt8188-vdec.o
+ clk-mt8188-ipe.o clk-mt8188-
mfg.o clk-mt8188-vdec.o \

drivers/clk/mediatek/Makefile +1 -0
+                                  clk-mt8188-vdo0.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdo0.c new file +31 -0
new file mode 100644
index 000000000000..30dd64374ace
@@ -0,0 +1,134 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vdo0_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vdo0_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs vdo0_2_cg_regs = {
+       .set_ofs = 0x124,
+       .clr_ofs = 0x128,
+       .sta_ofs = 0x120,
+};
+
+#define GATE_VDO0_0(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vdo0_0_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+
+#define GATE_VDO0_1(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vdo0_1_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+
+#define GATE_VDO0_2(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vdo0_2_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+
+#define GATE_VDO0_2_FLAGS(_id, _name, _parent, _shift,

_flags) \
+ GATE_MTK_FLAGS(_id, _name, _parent, &vdo0_2_cg_regs,
_shift, \

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +5 -0
+       &mtk_clk_gate_ops_setclr, _flags)
+
+static const struct mtk_gate vdo0_clks[] = {
+       /* VDO0_0 */
+       GATE_VDO0_0(CLK_VDO0_DISP_OVL0, "vdo0_disp_ovl0",

"top_vpp", 0),
+ GATE_VDO0_0(CLK_VDO0_FAKE_ENG0, "vdo0_fake_eng0",
"top_vpp", 2),
+ GATE_VDO0_0(CLK_VDO0_DISP_CCORR0, "vdo0_disp_ccorr0",
"top_vpp", 4),
+ GATE_VDO0_0(CLK_VDO0_DISP_MUTEX0, "vdo0_disp_mutex0",
"top_vpp", 6),
+ GATE_VDO0_0(CLK_VDO0_DISP_GAMMA0, "vdo0_disp_gamma0",
"top_vpp", 8),
+ GATE_VDO0_0(CLK_VDO0_DISP_DITHER0, "vdo0_disp_dither0",
"top_vpp", 10),
+ GATE_VDO0_0(CLK_VDO0_DISP_WDMA0, "vdo0_disp_wdma0",
"top_vpp", 17),
+ GATE_VDO0_0(CLK_VDO0_DISP_RDMA0, "vdo0_disp_rdma0",
"top_vpp", 19),

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +3 -0
+       GATE_VDO0_0(CLK_VDO0_DSI0, "vdo0_dsi0", "top_vpp", 21),
+       GATE_VDO0_0(CLK_VDO0_DSI1, "vdo0_dsi1", "top_vpp", 22),
+       GATE_VDO0_0(CLK_VDO0_DSC_WRAP0, "vdo0_dsc_wrap0",

"top_vpp", 23),
+ GATE_VDO0_0(CLK_VDO0_VPP_MERGE0, "vdo0_vpp_merge0",
"top_vpp", 24),
+ GATE_VDO0_0(CLK_VDO0_DP_INTF0, "vdo0_dp_intf0", "top_vpp",
25),
+ GATE_VDO0_0(CLK_VDO0_DISP_AAL0, "vdo0_disp_aal0",
"top_vpp", 26),
+ GATE_VDO0_0(CLK_VDO0_INLINEROT0, "vdo0_inlinerot0",
"top_vpp", 27),
+ GATE_VDO0_0(CLK_VDO0_APB_BUS, "vdo0_apb_bus", "top_vpp",
28),
+ GATE_VDO0_0(CLK_VDO0_DISP_COLOR0, "vdo0_disp_color0",
"top_vpp", 29),
+ GATE_VDO0_0(CLK_VDO0_MDP_WROT0, "vdo0_mdp_wrot0",
"top_vpp", 30),
+ GATE_VDO0_0(CLK_VDO0_DISP_RSZ0, "vdo0_disp_rsz0",
"top_vpp", 31),

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+       /* VDO0_1 */
+       GATE_VDO0_1(CLK_VDO0_DISP_POSTMASK0, "vdo0_disp_postmask0",

"top_vpp", 0),
+ GATE_VDO0_1(CLK_VDO0_FAKE_ENG1, "vdo0_fake_eng1",
"top_vpp", 1),
+ GATE_VDO0_1(CLK_VDO0_DL_ASYNC2, "vdo0_dl_async2",
"top_vpp", 5),
+ GATE_VDO0_1(CLK_VDO0_DL_RELAY3, "vdo0_dl_relay3",
"top_vpp", 6),
+ GATE_VDO0_1(CLK_VDO0_DL_RELAY4, "vdo0_dl_relay4",
"top_vpp", 7),
+ GATE_VDO0_1(CLK_VDO0_SMI_GALS, "vdo0_smi_gals", "top_vpp",
10),
+ GATE_VDO0_1(CLK_VDO0_SMI_COMMON, "vdo0_smi_common",
"top_vpp", 11),
+ GATE_VDO0_1(CLK_VDO0_SMI_EMI, "vdo0_smi_emi", "top_vpp",
12),
+ GATE_VDO0_1(CLK_VDO0_SMI_IOMMU, "vdo0_smi_iommu",
"top_vpp", 13),
+ GATE_VDO0_1(CLK_VDO0_SMI_LARB, "vdo0_smi_larb", "top_vpp",
14),
+ GATE_VDO0_1(CLK_VDO0_SMI_RSI, "vdo0_smi_rsi", "top_vpp",
15),

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +2 -0
+       /* VDO0_2 */
+       GATE_VDO0_2(CLK_VDO0_DSI0_DSI, "vdo0_dsi0_dsi",

"top_dsi_occ", 0),
+ GATE_VDO0_2(CLK_VDO0_DSI1_DSI, "vdo0_dsi1_dsi",
"top_dsi_occ", 8),
+ GATE_VDO0_2_FLAGS(CLK_VDO0_DP_INTF0_DP_INTF,
"vdo0_dp_intf0_dp_intf",

drivers/clk/mediatek/clk-mt8188-vdo0.c new file +10 -0
+               "top_edp", 16, CLK_SET_RATE_PARENT),
+};
+
+static int clk_mt8188_vdo0_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
Quoted 8 lines
Quoted 6 lines
drivers/clk/mediatek/clk-mt8188-vdo0.c new file +5 -0
+       clk_data = mtk_alloc_clk_data(CLK_VDO0_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vdo0_clks,

ARRAY_SIZE(vdo0_clks), clk_data);

This API was changed. Please rebase onto the latest -next and update.

Thank you for your suggestions.
OK I will modify it in v6.

Quoted 4 lines

Angelo (CC-ed) also mentioned a new simple probe variant for non-DT clock drivers is being developed. He didn't mention a timeline though.

When the new simple probe variant is ready, I will rebase latest-next and update it.

#33 lore raw

PATCH v5 13/19 clk: mediatek: Add MT8188 vdosys1 clock support

In reply to Garmin.Chang

Add MT8188 vdosys1 clock controller which provides clock gate control in video system. This is integrated with mtk-mmsys driver which will populate device by platform_device_register_data to start vdosys clock driver.

---
 drivers/clk/mediatek/Makefile          |   2 +-
 drivers/clk/mediatek/clk-mt8188-vdo1.c | 181 +++++++++++++++++++++++++
 2 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo1.c
drivers/clk/mediatek/Makefile +1 -1
index df78c0777fef..c654f4288e09 100644
@@ -87,7 +87,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
 				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
 				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
 				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
-				   clk-mt8188-vdo0.o
+				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdo1.c new file +181 -0

181 lines not on this page · raw message

Signature · 1 line
2.18.0
#34 lore raw

Re: [PATCH v5 13/19] clk: mediatek: Add MT8188 vdosys1 clock support

Quoted 79 lines · Garmin.Chang

Add MT8188 vdosys1 clock controller which provides clock gate control in video system. This is integrated with mtk-mmsys driver which will populate device by platform_device_register_data to start vdosys clock driver.

---
 drivers/clk/mediatek/Makefile          |   2 +-
 drivers/clk/mediatek/clk-mt8188-vdo1.c | 181 +++++++++++++++++++++++++
 2 files changed, 182 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vdo1.c
drivers/clk/mediatek/Makefile +1 -1
index df78c0777fef..c654f4288e09 100644
@@ -87,7 +87,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
                                   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
                                   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
-                                  clk-mt8188-vdo0.o
+                                  clk-mt8188-vdo0.o clk-mt8188-vdo1.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vdo1.c new file +47 -0
new file mode 100644
index 000000000000..be658c6a95bf
@@ -0,0 +1,181 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vdo1_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vdo1_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+static const struct mtk_gate_regs vdo1_2_cg_regs = {
+       .set_ofs = 0x124,
+       .clr_ofs = 0x128,
+       .sta_ofs = 0x120,
+};
+
+static const struct mtk_gate_regs vdo1_3_cg_regs = {
+       .set_ofs = 0x134,
+       .clr_ofs = 0x138,
+       .sta_ofs = 0x130,
+};
+
+static const struct mtk_gate_regs vdo1_4_cg_regs = {
+       .set_ofs = 0x144,
+       .clr_ofs = 0x148,
+       .sta_ofs = 0x140,
+};
+
+#define GATE_VDO1_0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO1_1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vdo1.c line 57

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-vdo1.c new file +10 -0
+
+#define GATE_VDO1_2(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO1_3(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_3_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VDO1_3_FLAGS(_id, _name, _parent, _shift, _flags)         \
+       GATE_MTK_FLAGS(_id, _name, _parent, &vdo1_3_cg_regs, _shift,    \
+                      &mtk_clk_gate_ops_setclr, _flags)

You could reverse GATE_VDO1_3 and GATE_VDO1_3_FLAGS, and then define GATE_VDO1_3 with GATE_VDO1_3_FLAGS. You could do the same for vdosys0 driver as well.

Quoted 74 lines
drivers/clk/mediatek/clk-mt8188-vdo1.c new file +74 -0
+#define GATE_VDO1_4(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vdo1_4_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate vdo1_clks[] = {
+       /* VDO1_0 */
+       GATE_VDO1_0(CLK_VDO1_SMI_LARB2, "vdo1_smi_larb2", "top_vpp", 0),
+       GATE_VDO1_0(CLK_VDO1_SMI_LARB3, "vdo1_smi_larb3", "top_vpp", 1),
+       GATE_VDO1_0(CLK_VDO1_GALS, "vdo1_gals", "top_vpp", 2),
+       GATE_VDO1_0(CLK_VDO1_FAKE_ENG0, "vdo1_fake_eng0", "top_vpp", 3),
+       GATE_VDO1_0(CLK_VDO1_FAKE_ENG1, "vdo1_fake_eng1", "top_vpp", 4),
+       GATE_VDO1_0(CLK_VDO1_MDP_RDMA0, "vdo1_mdp_rdma0", "top_vpp", 5),
+       GATE_VDO1_0(CLK_VDO1_MDP_RDMA1, "vdo1_mdp_rdma1", "top_vpp", 6),
+       GATE_VDO1_0(CLK_VDO1_MDP_RDMA2, "vdo1_mdp_rdma2", "top_vpp", 7),
+       GATE_VDO1_0(CLK_VDO1_MDP_RDMA3, "vdo1_mdp_rdma3", "top_vpp", 8),
+       GATE_VDO1_0(CLK_VDO1_VPP_MERGE0, "vdo1_vpp_merge0", "top_vpp", 9),
+       GATE_VDO1_0(CLK_VDO1_VPP_MERGE1, "vdo1_vpp_merge1", "top_vpp", 10),
+       GATE_VDO1_0(CLK_VDO1_VPP_MERGE2, "vdo1_vpp_merge2", "top_vpp", 11),
+       /* VDO1_1 */
+       GATE_VDO1_1(CLK_VDO1_VPP_MERGE3, "vdo1_vpp_merge3", "top_vpp", 0),
+       GATE_VDO1_1(CLK_VDO1_VPP_MERGE4, "vdo1_vpp_merge4", "top_vpp", 1),
+       GATE_VDO1_1(CLK_VDO1_VPP2_TO_VDO1_DL_ASYNC, "vdo1_vpp2_to_vdo1_dl_async", "top_vpp", 2),
+       GATE_VDO1_1(CLK_VDO1_VPP3_TO_VDO1_DL_ASYNC, "vdo1_vpp3_to_vdo1_dl_async", "top_vpp", 3),
+       GATE_VDO1_1(CLK_VDO1_DISP_MUTEX, "vdo1_disp_mutex", "top_vpp", 4),
+       GATE_VDO1_1(CLK_VDO1_MDP_RDMA4, "vdo1_mdp_rdma4", "top_vpp", 5),
+       GATE_VDO1_1(CLK_VDO1_MDP_RDMA5, "vdo1_mdp_rdma5", "top_vpp", 6),
+       GATE_VDO1_1(CLK_VDO1_MDP_RDMA6, "vdo1_mdp_rdma6", "top_vpp", 7),
+       GATE_VDO1_1(CLK_VDO1_MDP_RDMA7, "vdo1_mdp_rdma7", "top_vpp", 8),
+       GATE_VDO1_1(CLK_VDO1_DP_INTF0_MMCK, "vdo1_dp_intf0_mmck", "top_vpp", 9),
+       GATE_VDO1_1(CLK_VDO1_DPI0_MM, "vdo1_dpi0_mm_ck", "top_vpp", 10),
+       GATE_VDO1_1(CLK_VDO1_DPI1_MM, "vdo1_dpi1_mm_ck", "top_vpp", 11),
+       GATE_VDO1_1(CLK_VDO1_MERGE0_DL_ASYNC, "vdo1_merge0_dl_async", "top_vpp", 13),
+       GATE_VDO1_1(CLK_VDO1_MERGE1_DL_ASYNC, "vdo1_merge1_dl_async", "top_vpp", 14),
+       GATE_VDO1_1(CLK_VDO1_MERGE2_DL_ASYNC, "vdo1_merge2_dl_async", "top_vpp", 15),
+       GATE_VDO1_1(CLK_VDO1_MERGE3_DL_ASYNC, "vdo1_merge3_dl_async", "top_vpp", 16),
+       GATE_VDO1_1(CLK_VDO1_MERGE4_DL_ASYNC, "vdo1_merge4_dl_async", "top_vpp", 17),
+       GATE_VDO1_1(CLK_VDO1_DSC_VDO1_DL_ASYNC, "vdo1_dsc_vdo1_dl_async", "top_vpp", 18),
+       GATE_VDO1_1(CLK_VDO1_MERGE_VDO1_DL_ASYNC, "vdo1_merge_vdo1_dl_async", "top_vpp", 19),
+       GATE_VDO1_1(CLK_VDO1_PADDING0, "vdo1_padding0", "top_vpp", 20),
+       GATE_VDO1_1(CLK_VDO1_PADDING1, "vdo1_padding1", "top_vpp", 21),
+       GATE_VDO1_1(CLK_VDO1_PADDING2, "vdo1_padding2", "top_vpp", 22),
+       GATE_VDO1_1(CLK_VDO1_PADDING3, "vdo1_padding3", "top_vpp", 23),
+       GATE_VDO1_1(CLK_VDO1_PADDING4, "vdo1_padding4", "top_vpp", 24),
+       GATE_VDO1_1(CLK_VDO1_PADDING5, "vdo1_padding5", "top_vpp", 25),
+       GATE_VDO1_1(CLK_VDO1_PADDING6, "vdo1_padding6", "top_vpp", 26),
+       GATE_VDO1_1(CLK_VDO1_PADDING7, "vdo1_padding7", "top_vpp", 27),
+       GATE_VDO1_1(CLK_VDO1_DISP_RSZ0, "vdo1_disp_rsz0", "top_vpp", 28),
+       GATE_VDO1_1(CLK_VDO1_DISP_RSZ1, "vdo1_disp_rsz1", "top_vpp", 29),
+       GATE_VDO1_1(CLK_VDO1_DISP_RSZ2, "vdo1_disp_rsz2", "top_vpp", 30),
+       GATE_VDO1_1(CLK_VDO1_DISP_RSZ3, "vdo1_disp_rsz3", "top_vpp", 31),
+       /* VDO1_2 */
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE0, "vdo1_hdr_vdo_fe0", "top_vpp", 0),
+       GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE0, "vdo1_hdr_gfx_fe0", "top_vpp", 1),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_BE, "vdo1_hdr_vdo_be", "top_vpp", 2),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE1, "vdo1_hdr_vdo_fe1", "top_vpp", 16),
+       GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE1, "vdo1_hdr_gfx_fe1", "top_vpp", 17),
+       GATE_VDO1_2(CLK_VDO1_DISP_MIXER, "vdo1_disp_mixer", "top_vpp", 18),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE0_DL_ASYNC, "vdo1_hdr_vdo_fe0_dl_async", "top_vpp", 19),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_FE1_DL_ASYNC, "vdo1_hdr_vdo_fe1_dl_async", "top_vpp", 20),
+       GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE0_DL_ASYNC, "vdo1_hdr_gfx_fe0_dl_async", "top_vpp", 21),
+       GATE_VDO1_2(CLK_VDO1_HDR_GFX_FE1_DL_ASYNC, "vdo1_hdr_gfx_fe1_dl_async", "top_vpp", 22),
+       GATE_VDO1_2(CLK_VDO1_HDR_VDO_BE_DL_ASYNC, "vdo1_hdr_vdo_be_dl_async", "top_vpp", 23),
+       /* VDO1_3 */
+       GATE_VDO1_3(CLK_VDO1_DPI0, "vdo1_dpi0_ck", "top_vpp", 0),
+       GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPI0, "vdo1_disp_monitor_dpi0_ck", "top_vpp", 1),
+       GATE_VDO1_3(CLK_VDO1_DPI1, "vdo1_dpi1_ck", "top_vpp", 8),
+       GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPI1, "vdo1_disp_monitor_dpi1_ck", "top_vpp", 9),
+       GATE_VDO1_3_FLAGS(CLK_VDO1_DPINTF, "vdo1_dpintf", "top_dp", 16, CLK_SET_RATE_PARENT),
+       GATE_VDO1_3(CLK_VDO1_DISP_MONITOR_DPINTF, "vdo1_disp_monitor_dpintf_ck", "top_vpp", 17),
+       /* VDO1_4 */
+       GATE_VDO1_4(CLK_VDO1_26M_SLOW, "vdo1_26m_slow_ck", "clk26m", 8),
+};
+
+static int clk_mt8188_vdo1_probe(struct platform_device *pdev)
+{

drivers/clk/mediatek/clk-mt8188-vdo1.c line 142

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-vdo1.c new file +10 -0
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_VDO1_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data);

Same as vdosys0 patch, this API was changed and the usage here needs to be updated.

ChenYu

Quoted 43 lines
drivers/clk/mediatek/clk-mt8188-vdo1.c new file +39 -1
+       if (r)
+               goto free_vdo1_data;
+
+       r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+       if (r)
+               goto unregister_gates;
+
+       platform_set_drvdata(pdev, clk_data);
+
+       return r;
+
+unregister_gates:
+       mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data);
+free_vdo1_data:
+       mtk_free_clk_data(clk_data);
+       return r;
+}
+
+static int clk_mt8188_vdo1_remove(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+       of_clk_del_provider(node);
+       mtk_clk_unregister_gates(vdo1_clks, ARRAY_SIZE(vdo1_clks), clk_data);
+       mtk_free_clk_data(clk_data);
+
+       return 0;
+}
+
+static struct platform_driver clk_mt8188_vdo1_drv = {
+       .probe = clk_mt8188_vdo1_probe,
+       .remove = clk_mt8188_vdo1_remove,
+       .driver = {
+               .name = "clk-mt8188-vdo1",
+       },
+};
+builtin_platform_driver(clk_mt8188_vdo1_drv);
--

2.18.0

#35 lore raw

PATCH v5 14/19 clk: mediatek: Add MT8188 vencsys clock support

In reply to Garmin.Chang

Add MT8188 vencsys clock controllers which provide clock gate control for video encoder.

---
 drivers/clk/mediatek/Makefile          |  2 +-
 drivers/clk/mediatek/clk-mt8188-venc.c | 52 ++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-venc.c
drivers/clk/mediatek/Makefile +1 -1
index c654f4288e09..22a3840160fc 100644
@@ -87,7 +87,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
 				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
 				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
 				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
-				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o
+				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-venc.c new file +52 -0

52 lines not on this page · raw message

Signature · 1 line
2.18.0
#36 lore raw

Re: [PATCH v5 14/19] clk: mediatek: Add MT8188 vencsys clock support

Quoted 33 lines · Garmin.Chang

Add MT8188 vencsys clock controllers which provide clock gate control for video encoder.

---
 drivers/clk/mediatek/Makefile          |  2 +-
 drivers/clk/mediatek/clk-mt8188-venc.c | 52 ++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-venc.c
drivers/clk/mediatek/Makefile +1 -1
index c654f4288e09..22a3840160fc 100644
@@ -87,7 +87,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
                                   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
                                   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
-                                  clk-mt8188-vdo0.o clk-mt8188-vdo1.o
+                                  clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-venc.c new file +3 -0
new file mode 100644
index 000000000000..375ef99e2349
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.

drivers/clk/mediatek/clk-mt8188-venc.c line 13

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-venc.c new file +10 -0
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs ven1_cg_regs = {

Like the vdecsys patch, please change "ven" to "venc" to be consistent with usages elsewhere.

Quoted 6 lines
drivers/clk/mediatek/clk-mt8188-venc.c new file +6 -0
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_VEN1(_id, _name, _parent, _shift)                 \

drivers/clk/mediatek/clk-mt8188-venc.c line 29

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-venc.c new file +10 -0
+       GATE_MTK(_id, _name, _parent, &ven1_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+static const struct mtk_gate ven1_clks[] = {
+       GATE_VEN1(CLK_VEN1_CKE0_LARB, "ven1_cke0_larb", "top_venc", 0),
+       GATE_VEN1(CLK_VEN1_CKE1_VENC, "ven1_cke1_venc", "top_venc", 4),
+       GATE_VEN1(CLK_VEN1_CKE2_JPGENC, "ven1_cke2_jpgenc", "top_venc", 8),
+       GATE_VEN1(CLK_VEN1_CKE3_JPGDEC, "ven1_cke3_jpgdec", "top_venc", 12),
+       GATE_VEN1(CLK_VEN1_CKE4_JPGDEC_C1, "ven1_cke4_jpgdec_c1", "top_venc", 16),
+       GATE_VEN1(CLK_VEN1_CKE5_GALS, "ven1_cke5_gals", "top_venc", 28),
+       GATE_VEN1(CLK_VEN1_CKE6_GALS_SRAM, "ven1_cke6_gals_sram", "top_venc", 31),

Is ckeN in both the macro name and clock name necessary? We don't really care about the index.

ChenYu

Quoted 27 lines
drivers/clk/mediatek/clk-mt8188-venc.c new file +23 -1
+};
+
+static const struct mtk_clk_desc ven1_desc = {
+       .clks = ven1_clks,
+       .num_clks = ARRAY_SIZE(ven1_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_ven1[] = {
+       { .compatible = "mediatek,mt8188-vencsys", .data = &ven1_desc },
+       { /* sentinel */ }
+};
+
+static struct platform_driver clk_mt8188_ven1_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-ven1",
+               .of_match_table = of_match_clk_mt8188_ven1,
+       },
+};
+
+builtin_platform_driver(clk_mt8188_ven1_drv);
+MODULE_LICENSE("GPL");
--

2.18.0

#37 lore raw

Re: [PATCH v5 14/19] clk: mediatek: Add MT8188 vencsys clock support

Quoted 50 lines · Chen-Yu Tsai
Quoted 48 lines · Garmin.Chang

Add MT8188 vencsys clock controllers which provide clock gate control for video encoder.

---
 drivers/clk/mediatek/Makefile          |  2 +-
 drivers/clk/mediatek/clk-mt8188-venc.c | 52
++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-venc.c
drivers/clk/mediatek/Makefile +0 -0
index c654f4288e09..22a3840160fc 100644
@@ -87,7 +87,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-

apmixedsys.o clk-mt8188-topckgen.o

                                   clk-mt8188-peri_ao.o clk-mt8188-
infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-
ccu.o clk-mt8188-img.o \
                                   clk-mt8188-ipe.o clk-mt8188-

mfg.o clk-mt8188-vdec.o \
- clk-mt8188-vdo0.o clk-mt8188-
vdo1.o
+ clk-mt8188-vdo0.o clk-mt8188-
vdo1.o clk-mt8188-venc.o
obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o

drivers/clk/mediatek/clk-mt8188-venc.c new file +9 -0
new file mode 100644
index 000000000000..375ef99e2349
@@ -0,0 +1,52 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
Quoted 8 lines

drivers/clk/mediatek/clk-mt8188-venc.c line 13

Quoted 4 lines
drivers/clk/mediatek/clk-mt8188-venc.c new file +4 -0
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs ven1_cg_regs = {

Like the vdecsys patch, please change "ven" to "venc" to be consistent
with usages elsewhere.

Thank you for your suggestions.
OK, I will modify this series in v6.

Quoted 30 lines
Quoted 17 lines
drivers/clk/mediatek/clk-mt8188-venc.c new file +7 -0
+       .set_ofs = 0x4,
+       .clr_ofs = 0x8,
+       .sta_ofs = 0x0,
+};
+
+#define GATE_VEN1(_id, _name, _parent, _shift)                 \
+       GATE_MTK(_id, _name, _parent, &ven1_cg_regs, _shift,

&mtk_clk_gate_ops_setclr_inv)

drivers/clk/mediatek/clk-mt8188-venc.c new file +3 -0
+
+static const struct mtk_gate ven1_clks[] = {
+       GATE_VEN1(CLK_VEN1_CKE0_LARB, "ven1_cke0_larb", "top_venc",

0),
+ GATE_VEN1(CLK_VEN1_CKE1_VENC, "ven1_cke1_venc", "top_venc",
4),
+ GATE_VEN1(CLK_VEN1_CKE2_JPGENC, "ven1_cke2_jpgenc",
"top_venc", 8),

Quoted 8 lines

+ GATE_VEN1(CLK_VEN1_CKE3_JPGDEC, "ven1_cke3_jpgdec",
"top_venc", 12),
+ GATE_VEN1(CLK_VEN1_CKE4_JPGDEC_C1, "ven1_cke4_jpgdec_c1",
"top_venc", 16),
+ GATE_VEN1(CLK_VEN1_CKE5_GALS, "ven1_cke5_gals", "top_venc",
28),
+ GATE_VEN1(CLK_VEN1_CKE6_GALS_SRAM, "ven1_cke6_gals_sram",
"top_venc", 31),

Is ckeN in both the macro name and clock name necessary? We don't really
care about the index.

Quoted 1 line

ChenYu

OK, I will modify it in v6.

Quoted 29 lines
Quoted 29 lines
drivers/clk/mediatek/clk-mt8188-venc.c new file +9 -0
+};
+
+static const struct mtk_clk_desc ven1_desc = {
+       .clks = ven1_clks,
+       .num_clks = ARRAY_SIZE(ven1_clks),
+};
+
+static const struct of_device_id of_match_clk_mt8188_ven1[] = {
+       { .compatible = "mediatek,mt8188-vencsys", .data =

&ven1_desc },

drivers/clk/mediatek/clk-mt8188-venc.c new file +14 -1
+       { /* sentinel */ }
+};
+
+static struct platform_driver clk_mt8188_ven1_drv = {
+       .probe = mtk_clk_simple_probe,
+       .remove = mtk_clk_simple_remove,
+       .driver = {
+               .name = "clk-mt8188-ven1",
+               .of_match_table = of_match_clk_mt8188_ven1,
+       },
+};
+
+builtin_platform_driver(clk_mt8188_ven1_drv);
+MODULE_LICENSE("GPL");
--

2.18.0

#38 lore raw

PATCH v5 15/19 clk: mediatek: Add MT8188 vppsys0 clock support

In reply to Garmin.Chang

Add MT8188 vppsys0 clock controller which provides clock gate controller for Video Processor Pipe.

---
 drivers/clk/mediatek/Makefile          |   3 +-
 drivers/clk/mediatek/clk-mt8188-vpp0.c | 143 +++++++++++++++++++++++++
 2 files changed, 145 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp0.c
drivers/clk/mediatek/Makefile +2 -1
index 22a3840160fc..48deecc6b520 100644
@@ -87,7 +87,8 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
 				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
 				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
 				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
-				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o
+				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
+				   clk-mt8188-vpp0.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vpp0.c new file +143 -0

143 lines not on this page · raw message

Signature · 1 line
2.18.0
maintainer Reviewed-by on v5 15/19
#39 lore raw

Re: [PATCH v5 15/19] clk: mediatek: Add MT8188 vppsys0 clock support

Quoted 4 lines · Garmin.Chang

Add MT8188 vppsys0 clock controller which provides clock gate controller for Video Processor Pipe.

Quoted 169 lines
---
  drivers/clk/mediatek/Makefile          |   3 +-
  drivers/clk/mediatek/clk-mt8188-vpp0.c | 143 +++++++++++++++++++++++++
  2 files changed, 145 insertions(+), 1 deletion(-)

create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp0.c

drivers/clk/mediatek/Makefile +2 -1
index 22a3840160fc..48deecc6b520 100644
@@ -87,7 +87,8 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
  				   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
  				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
  				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
-				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o
+				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
+				   clk-mt8188-vpp0.o
  obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
  obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
  obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vpp0.c new file +143 -0
new file mode 100644
index 000000000000..e7b46142d653
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vpp0_0_cg_regs = {
+	.set_ofs = 0x24,
+	.clr_ofs = 0x28,
+	.sta_ofs = 0x20,
+};
+
+static const struct mtk_gate_regs vpp0_1_cg_regs = {
+	.set_ofs = 0x30,
+	.clr_ofs = 0x34,
+	.sta_ofs = 0x2c,
+};
+
+static const struct mtk_gate_regs vpp0_2_cg_regs = {
+	.set_ofs = 0x3c,
+	.clr_ofs = 0x40,
+	.sta_ofs = 0x38,
+};
+
+#define GATE_VPP0_0(_id, _name, _parent, _shift)			\
+	GATE_MTK(_id, _name, _parent, &vpp0_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VPP0_1(_id, _name, _parent, _shift)			\
+	GATE_MTK(_id, _name, _parent, &vpp0_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VPP0_2(_id, _name, _parent, _shift)			\
+	GATE_MTK(_id, _name, _parent, &vpp0_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate vpp0_clks[] = {
+	/* VPP0_0 */
+	GATE_VPP0_0(CLK_VPP0_MDP_FG, "vpp0_mdp_fg", "top_vpp", 1),
+	GATE_VPP0_0(CLK_VPP0_STITCH, "vpp0_stitch", "top_vpp", 2),
+	GATE_VPP0_0(CLK_VPP0_PADDING, "vpp0_padding", "top_vpp", 7),
+	GATE_VPP0_0(CLK_VPP0_MDP_TCC, "vpp0_mdp_tcc", "top_vpp", 8),
+	GATE_VPP0_0(CLK_VPP0_WARP0_ASYNC_TX, "vpp0_warp0_async_tx", "top_vpp", 10),
+	GATE_VPP0_0(CLK_VPP0_WARP1_ASYNC_TX, "vpp0_warp1_async_tx", "top_vpp", 11),
+	GATE_VPP0_0(CLK_VPP0_MUTEX, "vpp0_mutex", "top_vpp", 13),
+	GATE_VPP0_0(CLK_VPP02VPP1_RELAY, "vpp02vpp1_relay", "top_vpp", 14),
+	GATE_VPP0_0(CLK_VPP0_VPP12VPP0_ASYNC, "vpp0_vpp12vpp0_async", "top_vpp", 15),
+	GATE_VPP0_0(CLK_VPP0_MMSYSRAM_TOP, "vpp0_mmsysram_top", "top_vpp", 16),
+	GATE_VPP0_0(CLK_VPP0_MDP_AAL, "vpp0_mdp_aal", "top_vpp", 17),
+	GATE_VPP0_0(CLK_VPP0_MDP_RSZ, "vpp0_mdp_rsz", "top_vpp", 18),
+	/* VPP0_1 */
+	GATE_VPP0_1(CLK_VPP0_SMI_COMMON_MMSRAM, "vpp0_smi_common_mmsram", "top_vpp", 0),
+	GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB0_MMSRAM, "vpp0_gals_vdo0_larb0_mmsram", "top_vpp", 1),
+	GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB1_MMSRAM, "vpp0_gals_vdo0_larb1_mmsram", "top_vpp", 2),
+	GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_MMSRAM, "vpp0_gals_vencsys_mmsram", "top_vpp", 3),
+	GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_CORE1_MMSRAM,
+		    "vpp0_gals_vencsys_core1_mmsram", "top_vpp", 4),
+	GATE_VPP0_1(CLK_VPP0_GALS_INFRA_MMSRAM, "vpp0_gals_infra_mmsram", "top_vpp", 5),
+	GATE_VPP0_1(CLK_VPP0_GALS_CAMSYS_MMSRAM, "vpp0_gals_camsys_mmsram", "top_vpp", 6),
+	GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB5_MMSRAM, "vpp0_gals_vpp1_larb5_mmsram", "top_vpp", 7),
+	GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB6_MMSRAM, "vpp0_gals_vpp1_larb6_mmsram", "top_vpp", 8),
+	GATE_VPP0_1(CLK_VPP0_SMI_REORDER_MMSRAM, "vpp0_smi_reorder_mmsram", "top_vpp", 9),
+	GATE_VPP0_1(CLK_VPP0_SMI_IOMMU, "vpp0_smi_iommu", "top_vpp", 10),
+	GATE_VPP0_1(CLK_VPP0_GALS_IMGSYS_CAMSYS, "vpp0_gals_imgsys_camsys", "top_vpp", 11),
+	GATE_VPP0_1(CLK_VPP0_MDP_RDMA, "vpp0_mdp_rdma", "top_vpp", 12),
+	GATE_VPP0_1(CLK_VPP0_MDP_WROT, "vpp0_mdp_wrot", "top_vpp", 13),
+	GATE_VPP0_1(CLK_VPP0_GALS_EMI0_EMI1, "vpp0_gals_emi0_emi1", "top_vpp", 16),
+	GATE_VPP0_1(CLK_VPP0_SMI_SUB_COMMON_REORDER, "vpp0_smi_sub_common_reorder", "top_vpp", 17),
+	GATE_VPP0_1(CLK_VPP0_SMI_RSI, "vpp0_smi_rsi", "top_vpp", 18),
+	GATE_VPP0_1(CLK_VPP0_SMI_COMMON_LARB4, "vpp0_smi_common_larb4", "top_vpp", 19),
+	GATE_VPP0_1(CLK_VPP0_GALS_VDEC_VDEC_CORE1, "vpp0_gals_vdec_vdec_core1", "top_vpp", 20),
+	GATE_VPP0_1(CLK_VPP0_GALS_VPP1_WPESYS, "vpp0_gals_vpp1_wpesys", "top_vpp", 21),
+	GATE_VPP0_1(CLK_VPP0_GALS_VDO0_VDO1_VENCSYS_CORE1,
+		    "vpp0_gals_vdo0_vdo1_vencsys_core1", "top_vpp", 22),
+	GATE_VPP0_1(CLK_VPP0_FAKE_ENG, "vpp0_fake_eng", "top_vpp", 23),
+	GATE_VPP0_1(CLK_VPP0_MDP_HDR, "vpp0_mdp_hdr", "top_vpp", 24),
+	GATE_VPP0_1(CLK_VPP0_MDP_TDSHP, "vpp0_mdp_tdshp", "top_vpp", 25),
+	GATE_VPP0_1(CLK_VPP0_MDP_COLOR, "vpp0_mdp_color", "top_vpp", 26),
+	GATE_VPP0_1(CLK_VPP0_MDP_OVL, "vpp0_mdp_ovl", "top_vpp", 27),
+	GATE_VPP0_1(CLK_VPP0_DSIP_RDMA, "vpp0_dsip_rdma", "top_vpp", 28),
+	GATE_VPP0_1(CLK_VPP0_DISP_WDMA, "vpp0_disp_wdma", "top_vpp", 29),
+	GATE_VPP0_1(CLK_VPP0_MDP_HMS, "vpp0_mdp_hms", "top_vpp", 30),
+	/* VPP0_2 */
+	GATE_VPP0_2(CLK_VPP0_WARP0_RELAY, "vpp0_warp0_relay", "top_wpe_vpp", 0),
+	GATE_VPP0_2(CLK_VPP0_WARP0_ASYNC, "vpp0_warp0_async", "top_wpe_vpp", 1),
+	GATE_VPP0_2(CLK_VPP0_WARP1_RELAY, "vpp0_warp1_relay", "top_wpe_vpp", 2),
+	GATE_VPP0_2(CLK_VPP0_WARP1_ASYNC, "vpp0_warp1_async", "top_wpe_vpp", 3),
+};
+
+static int clk_mt8188_vpp0_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->parent->of_node;
+	struct clk_hw_onecell_data *clk_data;
+	int r;
+
+	clk_data = mtk_alloc_clk_data(CLK_VPP0_NR_CLK);
+	if (!clk_data)
+		return -ENOMEM;
+
+	r = mtk_clk_register_gates(node, vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
+	if (r)
+		goto free_vpp0_data;
+
+	r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+	if (r)
+		goto unregister_gates;
+
+	platform_set_drvdata(pdev, clk_data);
+
+	return r;
+
+unregister_gates:
+	mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
+free_vpp0_data:
+	mtk_free_clk_data(clk_data);
+	return r;
+}
+
+static int clk_mt8188_vpp0_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->parent->of_node;
+	struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+	of_clk_del_provider(node);
+	mtk_clk_unregister_gates(vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);
+	mtk_free_clk_data(clk_data);
+
+	return 0;
+}
+
+static struct platform_driver clk_mt8188_vpp0_drv = {
+	.probe = clk_mt8188_vpp0_probe,
+	.remove = clk_mt8188_vpp0_remove,
+	.driver = {
+		.name = "clk-mt8188-vpp0",
+	},
+};
+builtin_platform_driver(clk_mt8188_vpp0_drv);
Reviewed-by on v5 15/19
#40 lore raw

Re: [PATCH v5 15/19] clk: mediatek: Add MT8188 vppsys0 clock support

In reply to Garmin.Chang
Quoted 125 lines · Garmin.Chang

Add MT8188 vppsys0 clock controller which provides clock gate controller for Video Processor Pipe.

---
 drivers/clk/mediatek/Makefile          |   3 +-
 drivers/clk/mediatek/clk-mt8188-vpp0.c | 143 +++++++++++++++++++++++++
 2 files changed, 145 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp0.c
drivers/clk/mediatek/Makefile +2 -1
index 22a3840160fc..48deecc6b520 100644
@@ -87,7 +87,8 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
                                   clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
                                   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
-                                  clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o
+                                  clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
+                                  clk-mt8188-vpp0.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vpp0.c new file +94 -0
new file mode 100644
index 000000000000..e7b46142d653
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vpp0_0_cg_regs = {
+       .set_ofs = 0x24,
+       .clr_ofs = 0x28,
+       .sta_ofs = 0x20,
+};
+
+static const struct mtk_gate_regs vpp0_1_cg_regs = {
+       .set_ofs = 0x30,
+       .clr_ofs = 0x34,
+       .sta_ofs = 0x2c,
+};
+
+static const struct mtk_gate_regs vpp0_2_cg_regs = {
+       .set_ofs = 0x3c,
+       .clr_ofs = 0x40,
+       .sta_ofs = 0x38,
+};
+
+#define GATE_VPP0_0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp0_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VPP0_1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp0_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VPP0_2(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp0_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate vpp0_clks[] = {
+       /* VPP0_0 */
+       GATE_VPP0_0(CLK_VPP0_MDP_FG, "vpp0_mdp_fg", "top_vpp", 1),
+       GATE_VPP0_0(CLK_VPP0_STITCH, "vpp0_stitch", "top_vpp", 2),
+       GATE_VPP0_0(CLK_VPP0_PADDING, "vpp0_padding", "top_vpp", 7),
+       GATE_VPP0_0(CLK_VPP0_MDP_TCC, "vpp0_mdp_tcc", "top_vpp", 8),
+       GATE_VPP0_0(CLK_VPP0_WARP0_ASYNC_TX, "vpp0_warp0_async_tx", "top_vpp", 10),
+       GATE_VPP0_0(CLK_VPP0_WARP1_ASYNC_TX, "vpp0_warp1_async_tx", "top_vpp", 11),
+       GATE_VPP0_0(CLK_VPP0_MUTEX, "vpp0_mutex", "top_vpp", 13),
+       GATE_VPP0_0(CLK_VPP02VPP1_RELAY, "vpp02vpp1_relay", "top_vpp", 14),
+       GATE_VPP0_0(CLK_VPP0_VPP12VPP0_ASYNC, "vpp0_vpp12vpp0_async", "top_vpp", 15),
+       GATE_VPP0_0(CLK_VPP0_MMSYSRAM_TOP, "vpp0_mmsysram_top", "top_vpp", 16),
+       GATE_VPP0_0(CLK_VPP0_MDP_AAL, "vpp0_mdp_aal", "top_vpp", 17),
+       GATE_VPP0_0(CLK_VPP0_MDP_RSZ, "vpp0_mdp_rsz", "top_vpp", 18),
+       /* VPP0_1 */
+       GATE_VPP0_1(CLK_VPP0_SMI_COMMON_MMSRAM, "vpp0_smi_common_mmsram", "top_vpp", 0),
+       GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB0_MMSRAM, "vpp0_gals_vdo0_larb0_mmsram", "top_vpp", 1),
+       GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB1_MMSRAM, "vpp0_gals_vdo0_larb1_mmsram", "top_vpp", 2),
+       GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_MMSRAM, "vpp0_gals_vencsys_mmsram", "top_vpp", 3),
+       GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_CORE1_MMSRAM,
+                   "vpp0_gals_vencsys_core1_mmsram", "top_vpp", 4),
+       GATE_VPP0_1(CLK_VPP0_GALS_INFRA_MMSRAM, "vpp0_gals_infra_mmsram", "top_vpp", 5),
+       GATE_VPP0_1(CLK_VPP0_GALS_CAMSYS_MMSRAM, "vpp0_gals_camsys_mmsram", "top_vpp", 6),
+       GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB5_MMSRAM, "vpp0_gals_vpp1_larb5_mmsram", "top_vpp", 7),
+       GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB6_MMSRAM, "vpp0_gals_vpp1_larb6_mmsram", "top_vpp", 8),
+       GATE_VPP0_1(CLK_VPP0_SMI_REORDER_MMSRAM, "vpp0_smi_reorder_mmsram", "top_vpp", 9),
+       GATE_VPP0_1(CLK_VPP0_SMI_IOMMU, "vpp0_smi_iommu", "top_vpp", 10),
+       GATE_VPP0_1(CLK_VPP0_GALS_IMGSYS_CAMSYS, "vpp0_gals_imgsys_camsys", "top_vpp", 11),
+       GATE_VPP0_1(CLK_VPP0_MDP_RDMA, "vpp0_mdp_rdma", "top_vpp", 12),
+       GATE_VPP0_1(CLK_VPP0_MDP_WROT, "vpp0_mdp_wrot", "top_vpp", 13),
+       GATE_VPP0_1(CLK_VPP0_GALS_EMI0_EMI1, "vpp0_gals_emi0_emi1", "top_vpp", 16),
+       GATE_VPP0_1(CLK_VPP0_SMI_SUB_COMMON_REORDER, "vpp0_smi_sub_common_reorder", "top_vpp", 17),
+       GATE_VPP0_1(CLK_VPP0_SMI_RSI, "vpp0_smi_rsi", "top_vpp", 18),
+       GATE_VPP0_1(CLK_VPP0_SMI_COMMON_LARB4, "vpp0_smi_common_larb4", "top_vpp", 19),
+       GATE_VPP0_1(CLK_VPP0_GALS_VDEC_VDEC_CORE1, "vpp0_gals_vdec_vdec_core1", "top_vpp", 20),
+       GATE_VPP0_1(CLK_VPP0_GALS_VPP1_WPESYS, "vpp0_gals_vpp1_wpesys", "top_vpp", 21),
+       GATE_VPP0_1(CLK_VPP0_GALS_VDO0_VDO1_VENCSYS_CORE1,
+                   "vpp0_gals_vdo0_vdo1_vencsys_core1", "top_vpp", 22),
+       GATE_VPP0_1(CLK_VPP0_FAKE_ENG, "vpp0_fake_eng", "top_vpp", 23),
+       GATE_VPP0_1(CLK_VPP0_MDP_HDR, "vpp0_mdp_hdr", "top_vpp", 24),
+       GATE_VPP0_1(CLK_VPP0_MDP_TDSHP, "vpp0_mdp_tdshp", "top_vpp", 25),
+       GATE_VPP0_1(CLK_VPP0_MDP_COLOR, "vpp0_mdp_color", "top_vpp", 26),
+       GATE_VPP0_1(CLK_VPP0_MDP_OVL, "vpp0_mdp_ovl", "top_vpp", 27),
+       GATE_VPP0_1(CLK_VPP0_DSIP_RDMA, "vpp0_dsip_rdma", "top_vpp", 28),
+       GATE_VPP0_1(CLK_VPP0_DISP_WDMA, "vpp0_disp_wdma", "top_vpp", 29),
+       GATE_VPP0_1(CLK_VPP0_MDP_HMS, "vpp0_mdp_hms", "top_vpp", 30),
+       /* VPP0_2 */
+       GATE_VPP0_2(CLK_VPP0_WARP0_RELAY, "vpp0_warp0_relay", "top_wpe_vpp", 0),
+       GATE_VPP0_2(CLK_VPP0_WARP0_ASYNC, "vpp0_warp0_async", "top_wpe_vpp", 1),
+       GATE_VPP0_2(CLK_VPP0_WARP1_RELAY, "vpp0_warp1_relay", "top_wpe_vpp", 2),
+       GATE_VPP0_2(CLK_VPP0_WARP1_ASYNC, "vpp0_warp1_async", "top_wpe_vpp", 3),
+};
+
+static int clk_mt8188_vpp0_probe(struct platform_device *pdev)
+{

drivers/clk/mediatek/clk-mt8188-vpp0.c line 104

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-vpp0.c new file +10 -0
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_VPP0_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vpp0_clks, ARRAY_SIZE(vpp0_clks), clk_data);

This API has changed. Please rebase and update.

Otherwise,

#41 lore raw

Re: [PATCH v5 15/19] clk: mediatek: Add MT8188 vppsys0 clock support

Quoted 189 lines · Chen-Yu Tsai
Quoted 187 lines · Garmin.Chang

Add MT8188 vppsys0 clock controller which provides clock gate controller for Video Processor Pipe.

---
 drivers/clk/mediatek/Makefile          |   3 +-
 drivers/clk/mediatek/clk-mt8188-vpp0.c | 143
+++++++++++++++++++++++++
 2 files changed, 145 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp0.c
drivers/clk/mediatek/Makefile +0 -0
index 22a3840160fc..48deecc6b520 100644
@@ -87,7 +87,8 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-

apmixedsys.o clk-mt8188-topckgen.o

                                   clk-mt8188-peri_ao.o clk-mt8188-
infra_ao.o \
                                   clk-mt8188-cam.o clk-mt8188-
ccu.o clk-mt8188-img.o \
                                   clk-mt8188-ipe.o clk-mt8188-

mfg.o clk-mt8188-vdec.o \
- clk-mt8188-vdo0.o clk-mt8188-
vdo1.o clk-mt8188-venc.o
+ clk-mt8188-vdo0.o clk-mt8188-
vdo1.o clk-mt8188-venc.o \

drivers/clk/mediatek/Makefile +1 -0
+                                  clk-mt8188-vpp0.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vpp0.c new file +31 -0
new file mode 100644
index 000000000000..e7b46142d653
@@ -0,0 +1,143 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vpp0_0_cg_regs = {
+       .set_ofs = 0x24,
+       .clr_ofs = 0x28,
+       .sta_ofs = 0x20,
+};
+
+static const struct mtk_gate_regs vpp0_1_cg_regs = {
+       .set_ofs = 0x30,
+       .clr_ofs = 0x34,
+       .sta_ofs = 0x2c,
+};
+
+static const struct mtk_gate_regs vpp0_2_cg_regs = {
+       .set_ofs = 0x3c,
+       .clr_ofs = 0x40,
+       .sta_ofs = 0x38,
+};
+
+#define GATE_VPP0_0(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vpp0_0_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vpp0.c new file +2 -0
+
+#define GATE_VPP0_1(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vpp0_1_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vpp0.c new file +2 -0
+
+#define GATE_VPP0_2(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vpp0_2_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vpp0.c new file +6 -0
+
+static const struct mtk_gate vpp0_clks[] = {
+       /* VPP0_0 */
+       GATE_VPP0_0(CLK_VPP0_MDP_FG, "vpp0_mdp_fg", "top_vpp", 1),
+       GATE_VPP0_0(CLK_VPP0_STITCH, "vpp0_stitch", "top_vpp", 2),
+       GATE_VPP0_0(CLK_VPP0_PADDING, "vpp0_padding", "top_vpp",

7),
+ GATE_VPP0_0(CLK_VPP0_MDP_TCC, "vpp0_mdp_tcc", "top_vpp",
8),
+ GATE_VPP0_0(CLK_VPP0_WARP0_ASYNC_TX, "vpp0_warp0_async_tx",
"top_vpp", 10),
+ GATE_VPP0_0(CLK_VPP0_WARP1_ASYNC_TX, "vpp0_warp1_async_tx",
"top_vpp", 11),

drivers/clk/mediatek/clk-mt8188-vpp0.c new file +2 -0
+       GATE_VPP0_0(CLK_VPP0_MUTEX, "vpp0_mutex", "top_vpp", 13),
+       GATE_VPP0_0(CLK_VPP02VPP1_RELAY, "vpp02vpp1_relay",

"top_vpp", 14),
+ GATE_VPP0_0(CLK_VPP0_VPP12VPP0_ASYNC,
"vpp0_vpp12vpp0_async", "top_vpp", 15),
+ GATE_VPP0_0(CLK_VPP0_MMSYSRAM_TOP, "vpp0_mmsysram_top",
"top_vpp", 16),
+ GATE_VPP0_0(CLK_VPP0_MDP_AAL, "vpp0_mdp_aal", "top_vpp",
17),
+ GATE_VPP0_0(CLK_VPP0_MDP_RSZ, "vpp0_mdp_rsz", "top_vpp",
18),

drivers/clk/mediatek/clk-mt8188-vpp0.c new file +2 -0
+       /* VPP0_1 */
+       GATE_VPP0_1(CLK_VPP0_SMI_COMMON_MMSRAM,

"vpp0_smi_common_mmsram", "top_vpp", 0),
+ GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB0_MMSRAM,
"vpp0_gals_vdo0_larb0_mmsram", "top_vpp", 1),
+ GATE_VPP0_1(CLK_VPP0_GALS_VDO0_LARB1_MMSRAM,
"vpp0_gals_vdo0_larb1_mmsram", "top_vpp", 2),
+ GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_MMSRAM,
"vpp0_gals_vencsys_mmsram", "top_vpp", 3),

drivers/clk/mediatek/clk-mt8188-vpp0.c new file +2 -0
+       GATE_VPP0_1(CLK_VPP0_GALS_VENCSYS_CORE1_MMSRAM,
+                   "vpp0_gals_vencsys_core1_mmsram", "top_vpp",

4),
+ GATE_VPP0_1(CLK_VPP0_GALS_INFRA_MMSRAM,
"vpp0_gals_infra_mmsram", "top_vpp", 5),
+ GATE_VPP0_1(CLK_VPP0_GALS_CAMSYS_MMSRAM,
"vpp0_gals_camsys_mmsram", "top_vpp", 6),
+ GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB5_MMSRAM,
"vpp0_gals_vpp1_larb5_mmsram", "top_vpp", 7),
+ GATE_VPP0_1(CLK_VPP0_GALS_VPP1_LARB6_MMSRAM,
"vpp0_gals_vpp1_larb6_mmsram", "top_vpp", 8),
+ GATE_VPP0_1(CLK_VPP0_SMI_REORDER_MMSRAM,
"vpp0_smi_reorder_mmsram", "top_vpp", 9),
+ GATE_VPP0_1(CLK_VPP0_SMI_IOMMU, "vpp0_smi_iommu",
"top_vpp", 10),
+ GATE_VPP0_1(CLK_VPP0_GALS_IMGSYS_CAMSYS,
"vpp0_gals_imgsys_camsys", "top_vpp", 11),
+ GATE_VPP0_1(CLK_VPP0_MDP_RDMA, "vpp0_mdp_rdma", "top_vpp",
12),
+ GATE_VPP0_1(CLK_VPP0_MDP_WROT, "vpp0_mdp_wrot", "top_vpp",
13),
+ GATE_VPP0_1(CLK_VPP0_GALS_EMI0_EMI1, "vpp0_gals_emi0_emi1",
"top_vpp", 16),
+ GATE_VPP0_1(CLK_VPP0_SMI_SUB_COMMON_REORDER,
"vpp0_smi_sub_common_reorder", "top_vpp", 17),
+ GATE_VPP0_1(CLK_VPP0_SMI_RSI, "vpp0_smi_rsi", "top_vpp",
18),
+ GATE_VPP0_1(CLK_VPP0_SMI_COMMON_LARB4,
"vpp0_smi_common_larb4", "top_vpp", 19),
+ GATE_VPP0_1(CLK_VPP0_GALS_VDEC_VDEC_CORE1,
"vpp0_gals_vdec_vdec_core1", "top_vpp", 20),
+ GATE_VPP0_1(CLK_VPP0_GALS_VPP1_WPESYS,
"vpp0_gals_vpp1_wpesys", "top_vpp", 21),

drivers/clk/mediatek/clk-mt8188-vpp0.c new file +2 -0
+       GATE_VPP0_1(CLK_VPP0_GALS_VDO0_VDO1_VENCSYS_CORE1,
+                   "vpp0_gals_vdo0_vdo1_vencsys_core1", "top_vpp",

22),
+ GATE_VPP0_1(CLK_VPP0_FAKE_ENG, "vpp0_fake_eng", "top_vpp",
23),
+ GATE_VPP0_1(CLK_VPP0_MDP_HDR, "vpp0_mdp_hdr", "top_vpp",
24),
+ GATE_VPP0_1(CLK_VPP0_MDP_TDSHP, "vpp0_mdp_tdshp",
"top_vpp", 25),
+ GATE_VPP0_1(CLK_VPP0_MDP_COLOR, "vpp0_mdp_color",
"top_vpp", 26),
+ GATE_VPP0_1(CLK_VPP0_MDP_OVL, "vpp0_mdp_ovl", "top_vpp",
27),
+ GATE_VPP0_1(CLK_VPP0_DSIP_RDMA, "vpp0_dsip_rdma",
"top_vpp", 28),
+ GATE_VPP0_1(CLK_VPP0_DISP_WDMA, "vpp0_disp_wdma",
"top_vpp", 29),
+ GATE_VPP0_1(CLK_VPP0_MDP_HMS, "vpp0_mdp_hms", "top_vpp",
30),

drivers/clk/mediatek/clk-mt8188-vpp0.c new file +2 -0
+       /* VPP0_2 */
+       GATE_VPP0_2(CLK_VPP0_WARP0_RELAY, "vpp0_warp0_relay",

"top_wpe_vpp", 0),
+ GATE_VPP0_2(CLK_VPP0_WARP0_ASYNC, "vpp0_warp0_async",
"top_wpe_vpp", 1),
+ GATE_VPP0_2(CLK_VPP0_WARP1_RELAY, "vpp0_warp1_relay",
"top_wpe_vpp", 2),
+ GATE_VPP0_2(CLK_VPP0_WARP1_ASYNC, "vpp0_warp1_async",
"top_wpe_vpp", 3),

drivers/clk/mediatek/clk-mt8188-vpp0.c new file +9 -0
+};
+
+static int clk_mt8188_vpp0_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
Quoted 8 lines
Quoted 6 lines
drivers/clk/mediatek/clk-mt8188-vpp0.c new file +5 -0
+       clk_data = mtk_alloc_clk_data(CLK_VPP0_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vpp0_clks,

ARRAY_SIZE(vpp0_clks), clk_data);

This API has changed. Please rebase and update.

Thank you for your suggestions.
OK I will modify it in v6.

Quoted 4 lines

Otherwise,

#42 lore raw

PATCH v5 16/19 clk: mediatek: Add MT8188 vppsys1 clock support

In reply to Garmin.Chang

Add MT8188 vppsys1 clock controller which provides clock gate controller for Video Processor Pipe.

---
 drivers/clk/mediatek/Makefile          |   2 +-
 drivers/clk/mediatek/clk-mt8188-vpp1.c | 138 +++++++++++++++++++++++++
 2 files changed, 139 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp1.c
drivers/clk/mediatek/Makefile +1 -1
index 48deecc6b520..37663de293bf 100644
@@ -88,7 +88,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
 				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
 				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
 				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
-				   clk-mt8188-vpp0.o
+				   clk-mt8188-vpp0.o clk-mt8188-vpp1.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vpp1.c new file +138 -0

138 lines not on this page · raw message

Signature · 1 line
2.18.0
maintainer Reviewed-by on v5 16/19
#43 lore raw

Re: [PATCH v5 16/19] clk: mediatek: Add MT8188 vppsys1 clock support

Quoted 4 lines · Garmin.Chang

Add MT8188 vppsys1 clock controller which provides clock gate controller for Video Processor Pipe.

Quoted 163 lines
---
  drivers/clk/mediatek/Makefile          |   2 +-
  drivers/clk/mediatek/clk-mt8188-vpp1.c | 138 +++++++++++++++++++++++++
  2 files changed, 139 insertions(+), 1 deletion(-)

create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp1.c

drivers/clk/mediatek/Makefile +1 -1
index 48deecc6b520..37663de293bf 100644
@@ -88,7 +88,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
  				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
  				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
  				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
-				   clk-mt8188-vpp0.o
+				   clk-mt8188-vpp0.o clk-mt8188-vpp1.o
  obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
  obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
  obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vpp1.c new file +138 -0
new file mode 100644
index 000000000000..2bff3a52c93f
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vpp1_0_cg_regs = {
+	.set_ofs = 0x104,
+	.clr_ofs = 0x108,
+	.sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vpp1_1_cg_regs = {
+	.set_ofs = 0x114,
+	.clr_ofs = 0x118,
+	.sta_ofs = 0x110,
+};
+
+#define GATE_VPP1_0(_id, _name, _parent, _shift)			\
+	GATE_MTK(_id, _name, _parent, &vpp1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VPP1_1(_id, _name, _parent, _shift)			\
+	GATE_MTK(_id, _name, _parent, &vpp1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate vpp1_clks[] = {
+	/* VPP1_0 */
+	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_OVL, "vpp1_svpp1_mdp_ovl", "top_vpp", 0),
+	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TCC, "vpp1_svpp1_mdp_tcc", "top_vpp", 1),
+	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_WROT, "vpp1_svpp1_mdp_wrot", "top_vpp", 2),
+	GATE_VPP1_0(CLK_VPP1_SVPP1_VPP_PAD, "vpp1_svpp1_vpp_pad", "top_vpp", 3),
+	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_WROT, "vpp1_svpp2_mdp_wrot", "top_vpp", 4),
+	GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_PAD, "vpp1_svpp2_vpp_pad", "top_vpp", 5),
+	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_WROT, "vpp1_svpp3_mdp_wrot", "top_vpp", 6),
+	GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_PAD, "vpp1_svpp3_vpp_pad", "top_vpp", 7),
+	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RDMA, "vpp1_svpp1_mdp_rdma", "top_vpp", 8),
+	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_FG, "vpp1_svpp1_mdp_fg", "top_vpp", 9),
+	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RDMA, "vpp1_svpp2_mdp_rdma", "top_vpp", 10),
+	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_FG, "vpp1_svpp2_mdp_fg", "top_vpp", 11),
+	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RDMA, "vpp1_svpp3_mdp_rdma", "top_vpp", 12),
+	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_FG, "vpp1_svpp3_mdp_fg", "top_vpp", 13),
+	GATE_VPP1_0(CLK_VPP1_VPP_SPLIT, "vpp1_vpp_split", "top_vpp", 14),
+	GATE_VPP1_0(CLK_VPP1_SVPP2_VDO0_DL_RELAY, "vpp1_svpp2_vdo0_dl_relay", "top_vpp", 15),
+	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RSZ, "vpp1_svpp1_mdp_rsz", "top_vpp", 16),
+	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TDSHP, "vpp1_svpp1_mdp_tdshp", "top_vpp", 17),
+	GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_COLOR, "vpp1_svpp1_mdp_color", "top_vpp", 18),
+	GATE_VPP1_0(CLK_VPP1_SVPP3_VDO1_DL_RELAY, "vpp1_svpp3_vdo1_dl_relay", "top_vpp", 19),
+	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RSZ, "vpp1_svpp2_mdp_rsz", "top_vpp", 20),
+	GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_MERGE, "vpp1_svpp2_vpp_merge", "top_vpp", 21),
+	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_TDSHP, "vpp1_svpp2_mdp_tdshp", "top_vpp", 22),
+	GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_COLOR, "vpp1_svpp2_mdp_color", "top_vpp", 23),
+	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RSZ, "vpp1_svpp3_mdp_rsz", "top_vpp", 24),
+	GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_MERGE, "vpp1_svpp3_vpp_merge", "top_vpp", 25),
+	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_TDSHP, "vpp1_svpp3_mdp_tdshp", "top_vpp", 26),
+	GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_COLOR, "vpp1_svpp3_mdp_color", "top_vpp", 27),
+	GATE_VPP1_0(CLK_VPP1_GALS5, "vpp1_gals5", "top_vpp", 28),
+	GATE_VPP1_0(CLK_VPP1_GALS6, "vpp1_gals6", "top_vpp", 29),
+	GATE_VPP1_0(CLK_VPP1_LARB5, "vpp1_larb5", "top_vpp", 30),
+	GATE_VPP1_0(CLK_VPP1_LARB6, "vpp1_larb6", "top_vpp", 31),
+	/* VPP1_1 */
+	GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_HDR, "vpp1_svpp1_mdp_hdr", "top_vpp", 0),
+	GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_AAL, "vpp1_svpp1_mdp_aal", "top_vpp", 1),
+	GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_HDR, "vpp1_svpp2_mdp_hdr", "top_vpp", 2),
+	GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_AAL, "vpp1_svpp2_mdp_aal", "top_vpp", 3),
+	GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_HDR, "vpp1_svpp3_mdp_hdr", "top_vpp", 4),
+	GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_AAL, "vpp1_svpp3_mdp_aal", "top_vpp", 5),
+	GATE_VPP1_1(CLK_VPP1_DISP_MUTEX, "vpp1_disp_mutex", "top_vpp", 7),
+	GATE_VPP1_1(CLK_VPP1_SVPP2_VDO1_DL_RELAY, "vpp1_svpp2_vdo1_dl_relay", "top_vpp", 8),
+	GATE_VPP1_1(CLK_VPP1_SVPP3_VDO0_DL_RELAY, "vpp1_svpp3_vdo0_dl_relay", "top_vpp", 9),
+	GATE_VPP1_1(CLK_VPP1_VPP0_DL_ASYNC, "vpp1_vpp0_dl_async", "top_vpp", 10),
+	GATE_VPP1_1(CLK_VPP1_VPP0_DL1_RELAY, "vpp1_vpp0_dl1_relay", "top_vpp", 11),
+	GATE_VPP1_1(CLK_VPP1_LARB5_FAKE_ENG, "vpp1_larb5_fake_eng", "top_vpp", 12),
+	GATE_VPP1_1(CLK_VPP1_LARB6_FAKE_ENG, "vpp1_larb6_fake_eng", "top_vpp", 13),
+	GATE_VPP1_1(CLK_VPP1_HDMI_META, "vpp1_hdmi_meta", "top_vpp", 16),
+	GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_HDMI, "vpp1_vpp_split_hdmi", "top_vpp", 17),
+	GATE_VPP1_1(CLK_VPP1_DGI_IN, "vpp1_dgi_in", "top_vpp", 18),
+	GATE_VPP1_1(CLK_VPP1_DGI_OUT, "vpp1_dgi_out", "top_vpp", 19),
+	GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_DGI, "vpp1_vpp_split_dgi", "top_vpp", 20),
+	GATE_VPP1_1(CLK_VPP1_DL_CON_OCC, "vpp1_dl_con_occ", "top_vpp", 21),
+	GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "top_vpp", 26),
+};
+
+static int clk_mt8188_vpp1_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->parent->of_node;
+	struct clk_hw_onecell_data *clk_data;
+	int r;
+
+	clk_data = mtk_alloc_clk_data(CLK_VPP1_NR_CLK);
+	if (!clk_data)
+		return -ENOMEM;
+
+	r = mtk_clk_register_gates(node, vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
+	if (r)
+		goto free_vpp1_data;
+
+	r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+	if (r)
+		goto unregister_gates;
+
+	platform_set_drvdata(pdev, clk_data);
+
+	return r;
+
+unregister_gates:
+	mtk_clk_unregister_gates(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
+free_vpp1_data:
+	mtk_free_clk_data(clk_data);
+	return r;
+}
+
+static int clk_mt8188_vpp1_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *node = dev->parent->of_node;
+	struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+	of_clk_del_provider(node);
+	mtk_clk_unregister_gates(vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);
+	mtk_free_clk_data(clk_data);
+
+	return 0;
+}
+
+static struct platform_driver clk_mt8188_vpp1_drv = {
+	.probe = clk_mt8188_vpp1_probe,
+	.remove = clk_mt8188_vpp1_remove,
+	.driver = {
+		.name = "clk-mt8188-vpp1",
+	},
+};
+builtin_platform_driver(clk_mt8188_vpp1_drv);
Reviewed-by on v5 16/19
#44 lore raw

Re: [PATCH v5 16/19] clk: mediatek: Add MT8188 vppsys1 clock support

In reply to Garmin.Chang
Quoted 119 lines · Garmin.Chang

Add MT8188 vppsys1 clock controller which provides clock gate controller for Video Processor Pipe.

---
 drivers/clk/mediatek/Makefile          |   2 +-
 drivers/clk/mediatek/clk-mt8188-vpp1.c | 138 +++++++++++++++++++++++++
 2 files changed, 139 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp1.c
drivers/clk/mediatek/Makefile +1 -1
index 48deecc6b520..37663de293bf 100644
@@ -88,7 +88,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
                                   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
                                   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
                                   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
-                                  clk-mt8188-vpp0.o
+                                  clk-mt8188-vpp0.o clk-mt8188-vpp1.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-vpp1.c new file +89 -0
new file mode 100644
index 000000000000..2bff3a52c93f
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vpp1_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vpp1_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+#define GATE_VPP1_0(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp1_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+#define GATE_VPP1_1(_id, _name, _parent, _shift)                       \
+       GATE_MTK(_id, _name, _parent, &vpp1_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
+
+static const struct mtk_gate vpp1_clks[] = {
+       /* VPP1_0 */
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_OVL, "vpp1_svpp1_mdp_ovl", "top_vpp", 0),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TCC, "vpp1_svpp1_mdp_tcc", "top_vpp", 1),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_WROT, "vpp1_svpp1_mdp_wrot", "top_vpp", 2),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_VPP_PAD, "vpp1_svpp1_vpp_pad", "top_vpp", 3),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_WROT, "vpp1_svpp2_mdp_wrot", "top_vpp", 4),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_PAD, "vpp1_svpp2_vpp_pad", "top_vpp", 5),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_WROT, "vpp1_svpp3_mdp_wrot", "top_vpp", 6),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_PAD, "vpp1_svpp3_vpp_pad", "top_vpp", 7),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RDMA, "vpp1_svpp1_mdp_rdma", "top_vpp", 8),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_FG, "vpp1_svpp1_mdp_fg", "top_vpp", 9),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RDMA, "vpp1_svpp2_mdp_rdma", "top_vpp", 10),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_FG, "vpp1_svpp2_mdp_fg", "top_vpp", 11),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RDMA, "vpp1_svpp3_mdp_rdma", "top_vpp", 12),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_FG, "vpp1_svpp3_mdp_fg", "top_vpp", 13),
+       GATE_VPP1_0(CLK_VPP1_VPP_SPLIT, "vpp1_vpp_split", "top_vpp", 14),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_VDO0_DL_RELAY, "vpp1_svpp2_vdo0_dl_relay", "top_vpp", 15),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RSZ, "vpp1_svpp1_mdp_rsz", "top_vpp", 16),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TDSHP, "vpp1_svpp1_mdp_tdshp", "top_vpp", 17),
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_COLOR, "vpp1_svpp1_mdp_color", "top_vpp", 18),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_VDO1_DL_RELAY, "vpp1_svpp3_vdo1_dl_relay", "top_vpp", 19),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RSZ, "vpp1_svpp2_mdp_rsz", "top_vpp", 20),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_MERGE, "vpp1_svpp2_vpp_merge", "top_vpp", 21),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_TDSHP, "vpp1_svpp2_mdp_tdshp", "top_vpp", 22),
+       GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_COLOR, "vpp1_svpp2_mdp_color", "top_vpp", 23),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RSZ, "vpp1_svpp3_mdp_rsz", "top_vpp", 24),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_MERGE, "vpp1_svpp3_vpp_merge", "top_vpp", 25),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_TDSHP, "vpp1_svpp3_mdp_tdshp", "top_vpp", 26),
+       GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_COLOR, "vpp1_svpp3_mdp_color", "top_vpp", 27),
+       GATE_VPP1_0(CLK_VPP1_GALS5, "vpp1_gals5", "top_vpp", 28),
+       GATE_VPP1_0(CLK_VPP1_GALS6, "vpp1_gals6", "top_vpp", 29),
+       GATE_VPP1_0(CLK_VPP1_LARB5, "vpp1_larb5", "top_vpp", 30),
+       GATE_VPP1_0(CLK_VPP1_LARB6, "vpp1_larb6", "top_vpp", 31),
+       /* VPP1_1 */
+       GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_HDR, "vpp1_svpp1_mdp_hdr", "top_vpp", 0),
+       GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_AAL, "vpp1_svpp1_mdp_aal", "top_vpp", 1),
+       GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_HDR, "vpp1_svpp2_mdp_hdr", "top_vpp", 2),
+       GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_AAL, "vpp1_svpp2_mdp_aal", "top_vpp", 3),
+       GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_HDR, "vpp1_svpp3_mdp_hdr", "top_vpp", 4),
+       GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_AAL, "vpp1_svpp3_mdp_aal", "top_vpp", 5),
+       GATE_VPP1_1(CLK_VPP1_DISP_MUTEX, "vpp1_disp_mutex", "top_vpp", 7),
+       GATE_VPP1_1(CLK_VPP1_SVPP2_VDO1_DL_RELAY, "vpp1_svpp2_vdo1_dl_relay", "top_vpp", 8),
+       GATE_VPP1_1(CLK_VPP1_SVPP3_VDO0_DL_RELAY, "vpp1_svpp3_vdo0_dl_relay", "top_vpp", 9),
+       GATE_VPP1_1(CLK_VPP1_VPP0_DL_ASYNC, "vpp1_vpp0_dl_async", "top_vpp", 10),
+       GATE_VPP1_1(CLK_VPP1_VPP0_DL1_RELAY, "vpp1_vpp0_dl1_relay", "top_vpp", 11),
+       GATE_VPP1_1(CLK_VPP1_LARB5_FAKE_ENG, "vpp1_larb5_fake_eng", "top_vpp", 12),
+       GATE_VPP1_1(CLK_VPP1_LARB6_FAKE_ENG, "vpp1_larb6_fake_eng", "top_vpp", 13),
+       GATE_VPP1_1(CLK_VPP1_HDMI_META, "vpp1_hdmi_meta", "top_vpp", 16),
+       GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_HDMI, "vpp1_vpp_split_hdmi", "top_vpp", 17),
+       GATE_VPP1_1(CLK_VPP1_DGI_IN, "vpp1_dgi_in", "top_vpp", 18),
+       GATE_VPP1_1(CLK_VPP1_DGI_OUT, "vpp1_dgi_out", "top_vpp", 19),
+       GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_DGI, "vpp1_vpp_split_dgi", "top_vpp", 20),
+       GATE_VPP1_1(CLK_VPP1_DL_CON_OCC, "vpp1_dl_con_occ", "top_vpp", 21),
+       GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m", "top_vpp", 26),
+};
+
+static int clk_mt8188_vpp1_probe(struct platform_device *pdev)
+{

drivers/clk/mediatek/clk-mt8188-vpp1.c line 99

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-vpp1.c new file +10 -0
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
+       clk_data = mtk_alloc_clk_data(CLK_VPP1_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vpp1_clks, ARRAY_SIZE(vpp1_clks), clk_data);

Same here. Please update.

Once fixed,

#45 lore raw

Re: [PATCH v5 16/19] clk: mediatek: Add MT8188 vppsys1 clock support

Quoted 185 lines · Chen-Yu Tsai
Quoted 183 lines · Garmin.Chang

Add MT8188 vppsys1 clock controller which provides clock gate controller for Video Processor Pipe.

---
 drivers/clk/mediatek/Makefile          |   2 +-
 drivers/clk/mediatek/clk-mt8188-vpp1.c | 138
+++++++++++++++++++++++++
 2 files changed, 139 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-vpp1.c
drivers/clk/mediatek/Makefile +0 -0
index 48deecc6b520..37663de293bf 100644
@@ -88,7 +88,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-

apmixedsys.o clk-mt8188-topckgen.o

                                   clk-mt8188-cam.o clk-mt8188-
ccu.o clk-mt8188-img.o \
                                   clk-mt8188-ipe.o clk-mt8188-
mfg.o clk-mt8188-vdec.o \
                                   clk-mt8188-vdo0.o clk-mt8188-

vdo1.o clk-mt8188-venc.o \

drivers/clk/mediatek/Makefile +1 -1
-                                  clk-mt8188-vpp0.o
+                                  clk-mt8188-vpp0.o clk-mt8188-

vpp1.o
obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o

drivers/clk/mediatek/clk-mt8188-vpp1.c new file +25 -0
new file mode 100644
index 000000000000..2bff3a52c93f
@@ -0,0 +1,138 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs vpp1_0_cg_regs = {
+       .set_ofs = 0x104,
+       .clr_ofs = 0x108,
+       .sta_ofs = 0x100,
+};
+
+static const struct mtk_gate_regs vpp1_1_cg_regs = {
+       .set_ofs = 0x114,
+       .clr_ofs = 0x118,
+       .sta_ofs = 0x110,
+};
+
+#define GATE_VPP1_0(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vpp1_0_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vpp1.c new file +2 -0
+
+#define GATE_VPP1_1(_id, _name, _parent,

_shift) \
+ GATE_MTK(_id, _name, _parent, &vpp1_1_cg_regs, _shift,
&mtk_clk_gate_ops_setclr)

drivers/clk/mediatek/clk-mt8188-vpp1.c new file +4 -0
+
+static const struct mtk_gate vpp1_clks[] = {
+       /* VPP1_0 */
+       GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_OVL, "vpp1_svpp1_mdp_ovl",

"top_vpp", 0),
+ GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TCC, "vpp1_svpp1_mdp_tcc",
"top_vpp", 1),
+ GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_WROT, "vpp1_svpp1_mdp_wrot",
"top_vpp", 2),
+ GATE_VPP1_0(CLK_VPP1_SVPP1_VPP_PAD, "vpp1_svpp1_vpp_pad",
"top_vpp", 3),
+ GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_WROT, "vpp1_svpp2_mdp_wrot",
"top_vpp", 4),
+ GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_PAD, "vpp1_svpp2_vpp_pad",
"top_vpp", 5),
+ GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_WROT, "vpp1_svpp3_mdp_wrot",
"top_vpp", 6),
+ GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_PAD, "vpp1_svpp3_vpp_pad",
"top_vpp", 7),
+ GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RDMA, "vpp1_svpp1_mdp_rdma",
"top_vpp", 8),
+ GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_FG, "vpp1_svpp1_mdp_fg",
"top_vpp", 9),
+ GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RDMA, "vpp1_svpp2_mdp_rdma",
"top_vpp", 10),
+ GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_FG, "vpp1_svpp2_mdp_fg",
"top_vpp", 11),
+ GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RDMA, "vpp1_svpp3_mdp_rdma",
"top_vpp", 12),
+ GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_FG, "vpp1_svpp3_mdp_fg",
"top_vpp", 13),
+ GATE_VPP1_0(CLK_VPP1_VPP_SPLIT, "vpp1_vpp_split",
"top_vpp", 14),
+ GATE_VPP1_0(CLK_VPP1_SVPP2_VDO0_DL_RELAY,
"vpp1_svpp2_vdo0_dl_relay", "top_vpp", 15),
+ GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_RSZ, "vpp1_svpp1_mdp_rsz",
"top_vpp", 16),
+ GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_TDSHP,
"vpp1_svpp1_mdp_tdshp", "top_vpp", 17),
+ GATE_VPP1_0(CLK_VPP1_SVPP1_MDP_COLOR,
"vpp1_svpp1_mdp_color", "top_vpp", 18),
+ GATE_VPP1_0(CLK_VPP1_SVPP3_VDO1_DL_RELAY,
"vpp1_svpp3_vdo1_dl_relay", "top_vpp", 19),
+ GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_RSZ, "vpp1_svpp2_mdp_rsz",
"top_vpp", 20),
+ GATE_VPP1_0(CLK_VPP1_SVPP2_VPP_MERGE,
"vpp1_svpp2_vpp_merge", "top_vpp", 21),
+ GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_TDSHP,
"vpp1_svpp2_mdp_tdshp", "top_vpp", 22),
+ GATE_VPP1_0(CLK_VPP1_SVPP2_MDP_COLOR,
"vpp1_svpp2_mdp_color", "top_vpp", 23),
+ GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_RSZ, "vpp1_svpp3_mdp_rsz",
"top_vpp", 24),
+ GATE_VPP1_0(CLK_VPP1_SVPP3_VPP_MERGE,
"vpp1_svpp3_vpp_merge", "top_vpp", 25),
+ GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_TDSHP,
"vpp1_svpp3_mdp_tdshp", "top_vpp", 26),
+ GATE_VPP1_0(CLK_VPP1_SVPP3_MDP_COLOR,
"vpp1_svpp3_mdp_color", "top_vpp", 27),

drivers/clk/mediatek/clk-mt8188-vpp1.c new file +6 -0
+       GATE_VPP1_0(CLK_VPP1_GALS5, "vpp1_gals5", "top_vpp", 28),
+       GATE_VPP1_0(CLK_VPP1_GALS6, "vpp1_gals6", "top_vpp", 29),
+       GATE_VPP1_0(CLK_VPP1_LARB5, "vpp1_larb5", "top_vpp", 30),
+       GATE_VPP1_0(CLK_VPP1_LARB6, "vpp1_larb6", "top_vpp", 31),
+       /* VPP1_1 */
+       GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_HDR, "vpp1_svpp1_mdp_hdr",

"top_vpp", 0),
+ GATE_VPP1_1(CLK_VPP1_SVPP1_MDP_AAL, "vpp1_svpp1_mdp_aal",
"top_vpp", 1),
+ GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_HDR, "vpp1_svpp2_mdp_hdr",
"top_vpp", 2),
+ GATE_VPP1_1(CLK_VPP1_SVPP2_MDP_AAL, "vpp1_svpp2_mdp_aal",
"top_vpp", 3),
+ GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_HDR, "vpp1_svpp3_mdp_hdr",
"top_vpp", 4),
+ GATE_VPP1_1(CLK_VPP1_SVPP3_MDP_AAL, "vpp1_svpp3_mdp_aal",
"top_vpp", 5),
+ GATE_VPP1_1(CLK_VPP1_DISP_MUTEX, "vpp1_disp_mutex",
"top_vpp", 7),
+ GATE_VPP1_1(CLK_VPP1_SVPP2_VDO1_DL_RELAY,
"vpp1_svpp2_vdo1_dl_relay", "top_vpp", 8),
+ GATE_VPP1_1(CLK_VPP1_SVPP3_VDO0_DL_RELAY,
"vpp1_svpp3_vdo0_dl_relay", "top_vpp", 9),
+ GATE_VPP1_1(CLK_VPP1_VPP0_DL_ASYNC, "vpp1_vpp0_dl_async",
"top_vpp", 10),
+ GATE_VPP1_1(CLK_VPP1_VPP0_DL1_RELAY, "vpp1_vpp0_dl1_relay",
"top_vpp", 11),
+ GATE_VPP1_1(CLK_VPP1_LARB5_FAKE_ENG, "vpp1_larb5_fake_eng",
"top_vpp", 12),
+ GATE_VPP1_1(CLK_VPP1_LARB6_FAKE_ENG, "vpp1_larb6_fake_eng",
"top_vpp", 13),
+ GATE_VPP1_1(CLK_VPP1_HDMI_META, "vpp1_hdmi_meta",
"top_vpp", 16),
+ GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_HDMI, "vpp1_vpp_split_hdmi",
"top_vpp", 17),

drivers/clk/mediatek/clk-mt8188-vpp1.c new file +2 -0
+       GATE_VPP1_1(CLK_VPP1_DGI_IN, "vpp1_dgi_in", "top_vpp", 18),
+       GATE_VPP1_1(CLK_VPP1_DGI_OUT, "vpp1_dgi_out", "top_vpp",

19),
+ GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_DGI, "vpp1_vpp_split_dgi",
"top_vpp", 20),
+ GATE_VPP1_1(CLK_VPP1_DL_CON_OCC, "vpp1_dl_con_occ",
"top_vpp", 21),
+ GATE_VPP1_1(CLK_VPP1_VPP_SPLIT_26M, "vpp1_vpp_split_26m",
"top_vpp", 26),

drivers/clk/mediatek/clk-mt8188-vpp1.c new file +9 -0
+};
+
+static int clk_mt8188_vpp1_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct device_node *node = dev->parent->of_node;
+       struct clk_hw_onecell_data *clk_data;
+       int r;
+
Quoted 8 lines
Quoted 6 lines
drivers/clk/mediatek/clk-mt8188-vpp1.c new file +5 -0
+       clk_data = mtk_alloc_clk_data(CLK_VPP1_NR_CLK);
+       if (!clk_data)
+               return -ENOMEM;
+
+       r = mtk_clk_register_gates(node, vpp1_clks,

ARRAY_SIZE(vpp1_clks), clk_data);

Same here. Please update.

Thank you for your suggestions.
OK. I'll moidfy it in v6.

Quoted 4 lines

Once fixed,

#46 lore raw

PATCH v5 17/19 clk: mediatek: Add MT8188 wpesys clock support

In reply to Garmin.Chang

Add MT8188 wpesys clock controllers which provide clock gate control in Wrapping Engine.

---
 drivers/clk/mediatek/Makefile         |   2 +-
 drivers/clk/mediatek/clk-mt8188-wpe.c | 101 ++++++++++++++++++++++++++
 2 files changed, 102 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-wpe.c
drivers/clk/mediatek/Makefile +1 -1
index 37663de293bf..ed35546819a9 100644
@@ -88,7 +88,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
 				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
 				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
 				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
-				   clk-mt8188-vpp0.o clk-mt8188-vpp1.o
+				   clk-mt8188-vpp0.o clk-mt8188-vpp1.o clk-mt8188-wpe.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-wpe.c new file +101 -0

101 lines not on this page · raw message

Signature · 1 line
2.18.0
#48 lore raw

PATCH v5 18/19 clk: mediatek: Add MT8188 imp i2c wrapper clock support

In reply to Garmin.Chang

Add MT8188 imp i2c wrapper clock controllers which provide clock gate control in I2C IP blocks.

---
 drivers/clk/mediatek/Makefile                 |  3 +-
 .../clk/mediatek/clk-mt8188-imp_iic_wrap.c    | 78 +++++++++++++++++++
 2 files changed, 80 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-imp_iic_wrap.c
drivers/clk/mediatek/Makefile +2 -1
index ed35546819a9..8befaedfdd3d 100644
@@ -88,7 +88,8 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
 				   clk-mt8188-cam.o clk-mt8188-ccu.o clk-mt8188-img.o \
 				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
 				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
-				   clk-mt8188-vpp0.o clk-mt8188-vpp1.o clk-mt8188-wpe.o
+				   clk-mt8188-vpp0.o clk-mt8188-vpp1.o clk-mt8188-wpe.o \
+				   clk-mt8188-imp_iic_wrap.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-imp_iic_wrap.c new file +78 -0

78 lines not on this page · raw message

Signature · 1 line
2.18.0
#50 lore raw

PATCH v5 19/19 clk: mediatek: Add MT8188 adsp clock support

In reply to Garmin.Chang

Add MT8188 adsp clock controller which provides clock gate control for Audio DSP.

---
 drivers/clk/mediatek/Makefile                 |  2 +-
 .../clk/mediatek/clk-mt8188-adsp_audio26m.c   | 45 +++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c
drivers/clk/mediatek/Makefile +1 -1
index 8befaedfdd3d..b56ae9bee1d8 100644
@@ -89,7 +89,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
 				   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
 				   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
 				   clk-mt8188-vpp0.o clk-mt8188-vpp1.o clk-mt8188-wpe.o \
-				   clk-mt8188-imp_iic_wrap.o
+				   clk-mt8188-imp_iic_wrap.o clk-mt8188-adsp_audio26m.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c new file +45 -0

45 lines not on this page · raw message

Signature · 1 line
2.18.0
#51 lore raw

Re: [PATCH v5 19/19] clk: mediatek: Add MT8188 adsp clock support

Quoted 41 lines · Garmin.Chang

Add MT8188 adsp clock controller which provides clock gate control for Audio DSP.

---
 drivers/clk/mediatek/Makefile                 |  2 +-
 .../clk/mediatek/clk-mt8188-adsp_audio26m.c   | 45 +++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c
drivers/clk/mediatek/Makefile +1 -1
index 8befaedfdd3d..b56ae9bee1d8 100644
@@ -89,7 +89,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
                                   clk-mt8188-ipe.o clk-mt8188-mfg.o clk-mt8188-vdec.o \
                                   clk-mt8188-vdo0.o clk-mt8188-vdo1.o clk-mt8188-venc.o \
                                   clk-mt8188-vpp0.o clk-mt8188-vpp1.o clk-mt8188-wpe.o \
-                                  clk-mt8188-imp_iic_wrap.o
+                                  clk-mt8188-imp_iic_wrap.o clk-mt8188-adsp_audio26m.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o
 obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o
 obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o
drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c new file +11 -0
new file mode 100644
index 000000000000..f91381a1316c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"

drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c line 21

Quoted 10 lines
drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c new file +10 -0
+
+static const struct mtk_gate_regs adsp_audio26m_cg_regs = {
+       .set_ofs = 0x80,
+       .clr_ofs = 0x80,
+       .sta_ofs = 0x80,
+};
+
+#define GATE_ADSP_FLAGS(_id, _name, _parent, _shift)           \
+       GATE_MTK_FLAGS(_id, _name, _parent, &adsp_audio26m_cg_regs, _shift,             \
+               &mtk_clk_gate_ops_no_setclr, CLK_IGNORE_UNUSED)

Why CLK_IGNORE_UNUSED?

#52 lore raw

Re: [PATCH v5 19/19] clk: mediatek: Add MT8188 adsp clock support

Quoted 56 lines · Chen-Yu Tsai
Quoted 54 lines · Garmin.Chang

Add MT8188 adsp clock controller which provides clock gate control for Audio DSP.

---
 drivers/clk/mediatek/Makefile                 |  2 +-
 .../clk/mediatek/clk-mt8188-adsp_audio26m.c   | 45
+++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c
drivers/clk/mediatek/Makefile +0 -0
index 8befaedfdd3d..b56ae9bee1d8 100644
@@ -89,7 +89,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-

apmixedsys.o clk-mt8188-topckgen.o

                                   clk-mt8188-ipe.o clk-mt8188-
mfg.o clk-mt8188-vdec.o \
                                   clk-mt8188-vdo0.o clk-mt8188-
vdo1.o clk-mt8188-venc.o \
                                   clk-mt8188-vpp0.o clk-mt8188-

vpp1.o clk-mt8188-wpe.o \

drivers/clk/mediatek/Makefile +1 -1
-                                  clk-mt8188-imp_iic_wrap.o
+                                  clk-mt8188-imp_iic_wrap.o clk-

mt8188-adsp_audio26m.o
obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192.o obj-$(CONFIG_COMMON_CLK_MT8192_AUDSYS) += clk-mt8192-aud.o obj-$(CONFIG_COMMON_CLK_MT8192_CAMSYS) += clk-mt8192-cam.o

drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c new file +16 -0
new file mode 100644
index 000000000000..f91381a1316c
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// Copyright (c) 2022 MediaTek Inc.
+// Author: Garmin Chang <[email protected]>
+
+#include <linux/clk-provider.h>
+#include <linux/platform_device.h>
+#include <dt-bindings/clock/mediatek,mt8188-clk.h>
+
+#include "clk-gate.h"
+#include "clk-mtk.h"
+
+static const struct mtk_gate_regs adsp_audio26m_cg_regs = {
+       .set_ofs = 0x80,
+       .clr_ofs = 0x80,
+       .sta_ofs = 0x80,
Quoted 8 lines
Quoted 6 lines
drivers/clk/mediatek/clk-mt8188-adsp_audio26m.c new file +4 -0
+};
+
+#define GATE_ADSP_FLAGS(_id, _name, _parent, _shift)           \
+       GATE_MTK_FLAGS(_id, _name, _parent, &adsp_audio26m_cg_regs,

_shift, \
+ &mtk_clk_gate_ops_no_setclr, CLK_IGNORE_UNUSED)

Why CLK_IGNORE_UNUSED?

Thank you for your review.

Because ADSP_INFRA is always on, it is unnecessary to add CLK_IGNORE_UNUSED now. I wiil remove it in v6. Please see commit

https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/

Add ignore_unused before to avoid "ADSP_INFRA is turned off". If ADSP_INFRA is turned off, accessing registers will cause the system to hang.

#53 lore raw
In reply to Garmin.Chang
Quoted 2 lines · Garmin.Chang

Base on tag: next-20230119, linux-next/master

There are some recent changes to the MediaTek clk driver library that makes this series incompatible. Could you rebase onto next-202302xx and send a new version?

Thanks

#54 lore raw
Quoted 11 lines · Chen-Yu Tsai
Quoted 2 lines · Garmin.Chang

Base on tag: next-20230119, linux-next/master

There are some recent changes to the MediaTek clk driver library that makes this series incompatible. Could you rebase onto next- 202302xx
and send a new version?

Thanks

OK. I'll rebase onto next 202303xx, thanks.