Skip to contentSkip to conversation

MT8189: Add support for system and base clock controllers

PATCH Applied Louis-Alexis Eyraud 4 participants 39 messages Sep 4 – Nov 17

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

v6 cover MT8189: Add support for system and base clock controllers

This series is a continuation by AngeloGioacchino Del Regno and I of a previous series ([1]), that adds the clock controller support for the Mediatek MT8189 SoC and its variants (MT8371, MT8391).

The first major changes is the split of the series in two:
- one for all basic clock controllers including system ones (this series)
- one for the multimedia and graphics related clock controllers (to be send in the future)

We chose to separate the multimedia clock drivers from the base system ones, as there is currently an unsolvable inter-dependency between the power domains and multimedia clocks; the power domains need a dual-stage bring-up, where only a part of the multimedia clocks are accessible in the first power domain powerup stage, and the rest when the second stage (SRAM enablement) is done.
The current workarounds for this issue, such as removing the is_enabled operation from the impacted clock controllers clk_ops table or let the multimedia power domain always on, were quickly discarded for upstream.

The second major change is the dt-bindings patch ([2]) that got heavily reworked, not only because of the split choice. We took the opportunity to regroup in the MT8186 clock and system clock dt-bindings the description of several other Mediatek SoC (MT8188, MT8192 and MT8195) and add in them the MT8189 new ones.
The rationale is to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.

Finally the pending remarks from peer reviews on the v6 revision of [1] were also taken into account and new fixes and cleanups were also added.

A more detailed changelog between [1] and this series:
- Removed multimedia and graphics related clock controllers code and definitions from series
- Added new dt-bindings patches to factorise existing MT8188, MT8192 and MT8195 in MT8186 clock dt-bindings
- Heavily modified the MT8189 dt-bindings to add new compatibles in MT8186 clock dt-bindings
- Created a new dt-bindings include for the MT8189 reset controller definitions (include/dt-bindings/reset/mediatek,mt8189-resets.h)
- Removed unnecessary syscon compatible fallback from MT8189 base clock controllers
- Added missing 'mediatek,mt8189-fhctl' compatible declaration in dt-bindings
- Modified Kconfig to COMMON_CLK_MT8189 be tristate (and not bool) to allow all MT8189 clock controller drivers to be built as modules (it was partial)
- Fix pll unregisters in clk_mt8189_apmixed_probe error case
- Reparent several clocks to correct 26M references in clk-mt8189-bus.c, clk-mt8189-topckgen.c and clk-mt8189-vlpckgen.c
- Removed CLK_SET_RATE_NO_REPARENT flag from mfg_sel_mfgpll
- Rename TOPCKGEN_fmipi_csi_up26m clock to fmipi_csi_up26m to remove caps usage
- Implemented reset controllers in clk-mt8189-ufs.c
- Updated all file headers to update copyrights and add all authors
- Added all co-developed-by trailers

The series is based on linux-next tree (tag: next-20260903) and has been tested on Mediatek Genio 520-EVK (MT8371) and 720-EVK (MT8391) boards, with hardware enablement patch series ([3]), and on Genio 510-EVK (MT8370, variant of MT8188) and Genio 1200-EVK (MT8395, variant of MT8195).

[1]: https://lore.kernel.org/linux-mediatek/[email protected]/
[2]: https://lore.kernel.org/linux-mediatek/[email protected]/
[3]: https://lore.kernel.org/linux-mediatek/20260701-add-mediatek-genio-520-720-evk-v2-0-19d5da4ef984@collabora.com/

---
Changes in v6:
- Rebased on next-20260903 tag
- Added contains keyword use in patch 5, as recommended by R. Herring
- Fixed typo and comment in patch 13 (B. Masney)
- Added patches 16 and 17 to do some code improvements suggested in
B. Masney review
- Removed unnecessary header inclusions and reorder remaining ones in
patch 18 to 27 (B. Masney)
- Added received Reviewed-By trailers
- Removed netdev mailing list from Cc
- Link to v5: https://lore.kernel.org/r/20260801-mt8189-clocks-system-base-v5-0-ac4410697cc2@collabora.com

Changes in v5:
- Rebased on next-20260730 tag
- Dropped "clk: mediatek: pll: split default prepare/unprepare callbacks"
patch and added "clk: mediatek: pll: Factorise pll power on/off sequence"
and "clk: mediatek: pll: Add PLL stabilization delay definition"
patches in replacement.
- patch 13:
- reworded commit message to show this new clocks ops use specific pll
enablement rather powering
- reworked mtk_pll_prepare_setclr and mtk_pll_unprepare_setclr
sequence to handle properly specific enable/disable sequence
using en_set/clr register (Sashiko)
- fixed timeout management in mtk_pll_prepare_setclr and
mtk_pll_unprepare_setclr (Sashiko)
- Link to v4: https://lore.kernel.org/r/20260729-mt8189-clocks-system-base-v4-0-e356b813a64c@collabora.com

Changes in v4:
- Rebased on next-20260728 tag
- Added patches 9 to 14 to add new clock ops data set for PLL and
PLL-FHCTL to handle a new PLL switch logic for PLL control and BAR
reset, supported by MT8189 SoC
- Patch 15:
- Removed useless includes (B. Masney)
- Fixed variable declaration order in clk_mt8189_apmixed_probe (B.
Masney)
- Added missing pwr_reg setting setting in PLL_SETCLR macro (B.
Masney, Sashiko)
- Added en_set_reg, en_clr_reg, rst_bar_reg, rst_bar_set_reg and
rst_bar_clr_reg fixed offsets and new mtk_pll_setclr_ops ops
setting in PLL_SETCLR macro
- Added pwr_reg offset values in apmixed_plls array
- Fixed rst_bar_mask for mainpll univpll, and mmpll in apmixed_plls
array to match rst_bar set/clr reg settings
- Fixed factor ratio for mainpll_d4_d8, tvdpll1_d16, tvdpll2_d16 and
osc_d16 clocks (Sashiko)
- Link to v3: https://lore.kernel.org/r/20260720-mt8189-clocks-system-base-v3-0-8e6d99ab3ad2@collabora.com

Changes in v3:
- Rebased on next-20260717 tag
- Added Fixes tags to patches 1, 2 and 3
- Reworded patch 8 subject and description messages
- Updated Reviewed-by and Acked-by trailers
- Link to v2: https://lore.kernel.org/r/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com

Changes in v2:
- Rebased on next-20260708 tag
- Added patch 1,2 and 3 to make the #clock-cells a required property in
MT8186, MT8192 and MT8195 clock controller dt-bindings
- Patch 5:
- Removed conditional blocks to check clock-cells property presence
for MT8188 clock controller compatible
- Reworded commit message to remove the note (no more applicable)
- Fixed incorrect property value in else block for #reset-cells
property check.
_ Removed from patch 9 conditional blocks to check clock-cells property
presence for MT8189 clock controller compatible
- Fixed missing MODULE_DEVICE_TABLE in patches 10, 11 and 12.
- Added devicetree series link in cover letter
- Link to v1: https://lore.kernel.org/r/20260701-mt8189-clocks-system-base-v1-0-2b048feea50a@collabora.com

---
Louis-Alexis Eyraud (27):
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195
dt-bindings: clock: mediatek: reorder MT8186 compatibles
dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186
dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186
dt-bindings: clock: mediatek: regroup MT8195 dt-bindings into MT8186
dt-bindings: clock: mediatek: Add MT8189 system/base clocks and resets
clk: mediatek: Harmonize mtk_pll_fenc related symbol names
clk: mediatek: pll: Add BAR reset register offsets
clk: mediatek: pll: Factorise pll power on/off sequences
clk: mediatek: pll: Add PLL stabilization delay definition
clk: mediatek: pll: Add ops for PLLs using set/clr regs
clk: mediatek: pllfh: Add configurable clock ops to mtk_pllfh_data
clk: mediatek: pllfh: Add ops for PLLs using set/clr regs
clk: mediatek: Move fhctl_parse_dt call into mtk_clk_register_pllfhs
clk: mediatek: pllfh: clear state data in mtk_clk_cleanup_pllfhs
clk: mediatek: Add MT8189 apmixedsys clock support
clk: mediatek: Add MT8189 topckgen clock support
clk: mediatek: Add MT8189 vlpckgen clock support
clk: mediatek: Add MT8189 vlpcfg clock support
clk: mediatek: Add MT8189 bus clock support
clk: mediatek: Add MT8189 dbgao clock support
clk: mediatek: Add MT8189 dvfsrc clock support
clk: mediatek: Add MT8189 i2c clock support
clk: mediatek: Add MT8189 scp clock support
clk: mediatek: Add MT8189 ufs clock support

 .../bindings/clock/mediatek,mt8186-clock.yaml      |  129 ++-
 .../bindings/clock/mediatek,mt8186-fhctl.yaml      |    1 +
 .../bindings/clock/mediatek,mt8186-sys-clock.yaml  |   24 +-
 .../bindings/clock/mediatek,mt8188-clock.yaml      |   93 --
 .../bindings/clock/mediatek,mt8188-sys-clock.yaml  |   58 --
 .../bindings/clock/mediatek,mt8192-clock.yaml      |  191 ----
 .../bindings/clock/mediatek,mt8192-sys-clock.yaml  |   68 --
 .../bindings/clock/mediatek,mt8195-clock.yaml      |  238 -----
 .../bindings/clock/mediatek,mt8195-sys-clock.yaml  |   76 --
 drivers/clk/mediatek/Kconfig                       |   79 ++
 drivers/clk/mediatek/Makefile                      |    8 +
 drivers/clk/mediatek/clk-mt6795-apmixedsys.c       |    3 +-
 drivers/clk/mediatek/clk-mt8173-apmixedsys.c       |    5 +-
 drivers/clk/mediatek/clk-mt8186-apmixedsys.c       |    4 +-
 drivers/clk/mediatek/clk-mt8189-apmixedsys.c       |  202 ++++
 drivers/clk/mediatek/clk-mt8189-bus.c              |  199 ++++
 drivers/clk/mediatek/clk-mt8189-dbgao.c            |   97 ++
 drivers/clk/mediatek/clk-mt8189-dvfsrc.c           |   57 ++
 drivers/clk/mediatek/clk-mt8189-iic.c              |  121 +++
 drivers/clk/mediatek/clk-mt8189-scp.c              |   76 ++
 drivers/clk/mediatek/clk-mt8189-topckgen.c         | 1019 ++++++++++++++++++++
 drivers/clk/mediatek/clk-mt8189-ufs.c              |  132 +++
 drivers/clk/mediatek/clk-mt8189-vlpcfg.c           |  115 +++
 drivers/clk/mediatek/clk-mt8189-vlpckgen.c         |  279 ++++++
 drivers/clk/mediatek/clk-mt8192-apmixedsys.c       |    4 +-
 drivers/clk/mediatek/clk-mt8195-apmixedsys.c       |    4 +-
 drivers/clk/mediatek/clk-mt8196-apmixedsys.c       |    2 +-
 drivers/clk/mediatek/clk-mt8196-vlpckgen.c         |    2 +-
 drivers/clk/mediatek/clk-pll.c                     |  131 ++-
 drivers/clk/mediatek/clk-pll.h                     |   13 +-
 drivers/clk/mediatek/clk-pllfh.c                   |   33 +-
 drivers/clk/mediatek/clk-pllfh.h                   |    8 +-
 include/dt-bindings/clock/mediatek,mt8189-clk.h    |  433 +++++++++
 include/dt-bindings/reset/mediatek,mt8189-resets.h |   17 +
 34 files changed, 3139 insertions(+), 782 deletions(-)

---
base-commit: 0abd4c5dd02744f837ade691fb214ca7cb970e4b
change-id: 20260630-mt8189-clocks-system-base-70714e4ff2aa

Best regards,

Signature · 1 line
Louis-Alexis Eyraud <[email protected]>
#1 lore raw

PATCH v6 1/27 dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186

Both MT8186 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.

Fixes f113a51aa2cf ("dt-bindings: ARM: MediaTek: Add new document bindings of MT8186 clock")
---
 Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml     | 1 +
 Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml | 1 +
 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +1 -0
index f4e58bfa504f..539149c945d0 100644
@@ -44,6 +44,7 @@ properties:
 required:
   - compatible
   - reg
+  - '#clock-cells'
 
 additionalProperties: false
 
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +1 -0
index 1c446fbc5108..f8acc02cafee 100644
@@ -45,6 +45,7 @@ properties:
 required:
   - compatible
   - reg
+  - '#clock-cells'
 
 additionalProperties: false
 
Signature · 1 line
2.55.0
#2 lore raw

PATCH v6 2/27 dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192

In reply to Louis-Alexis Eyraud

Both MT8192 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.

Fixes 4a803990aeb1 ("dt-bindings: ARM: Mediatek: Add new document bindings of MT8192 clock")
---
 Documentation/devicetree/bindings/clock/mediatek,mt8192-clock.yaml     | 1 +
 Documentation/devicetree/bindings/clock/mediatek,mt8192-sys-clock.yaml | 1 +
 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/clock/mediatek,mt8192-clock.yaml +1 -0
index b8d690e28bdc..65e4c2fddf5b 100644
@@ -46,6 +46,7 @@ properties:
 required:
   - compatible
   - reg
+  - '#clock-cells'
 
 additionalProperties: false
 
Documentation/devicetree/bindings/clock/mediatek,mt8192-sys-clock.yaml +1 -0
index bf8c9aacdf1e..0ebd0d60e2f6 100644
@@ -35,6 +35,7 @@ properties:
 required:
   - compatible
   - reg
+  - '#clock-cells'
 
 additionalProperties: false
 
Signature · 1 line
2.55.0
#3 lore raw

PATCH v6 3/27 dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195

In reply to Louis-Alexis Eyraud

Both MT8195 clock controllers dt-bindings (clock and sys-clock) document the '#clock-cells' property but do not enforce it as required property.
As clock provider nodes should define this property in devicetrees, add it to the required property list in both its dt-bindings files.

Fixes 34d3ed3b9a00 ("dt-bindings: ARM: Mediatek: Add new document bindings of MT8195 clock")
---
 Documentation/devicetree/bindings/clock/mediatek,mt8195-clock.yaml     | 1 +
 Documentation/devicetree/bindings/clock/mediatek,mt8195-sys-clock.yaml | 1 +
 2 files changed, 2 insertions(+)
Documentation/devicetree/bindings/clock/mediatek,mt8195-clock.yaml +1 -0
index fcc963aff087..94dd29c2396c 100644
@@ -58,6 +58,7 @@ properties:
 required:
   - compatible
   - reg
+  - '#clock-cells'
 
 additionalProperties: false
 
Documentation/devicetree/bindings/clock/mediatek,mt8195-sys-clock.yaml +1 -0
index 69f096eb168d..ba1b36fa0169 100644
@@ -43,6 +43,7 @@ properties:
 required:
   - compatible
   - reg
+  - '#clock-cells'
 
 additionalProperties: false
 
Signature · 1 line
2.55.0
#4 lore raw

PATCH v6 4/27 dt-bindings: clock: mediatek: reorder MT8186 compatibles

In reply to Louis-Alexis Eyraud

In order to prepare regrouping several Mediatek SoC clock controller dt-bindings files into the MT8186 ones, reorder the MT8186 clock controller compatibles so they are sorted alphanumerically.

---
 .../bindings/clock/mediatek,mt8186-clock.yaml           | 17 +++++++++--------
 .../bindings/clock/mediatek,mt8186-sys-clock.yaml       |  4 ++--
 2 files changed, 11 insertions(+), 10 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +9 -8
index 539149c945d0..756b937bb7c4 100644
@@ -23,18 +23,19 @@ properties:
   compatible:
     items:
       - enum:
-          - mediatek,mt8186-imp_iic_wrap
-          - mediatek,mt8186-mfgsys
-          - mediatek,mt8186-wpesys
-          - mediatek,mt8186-imgsys1
-          - mediatek,mt8186-imgsys2
-          - mediatek,mt8186-vdecsys
-          - mediatek,mt8186-vencsys
           - mediatek,mt8186-camsys
           - mediatek,mt8186-camsys_rawa
           - mediatek,mt8186-camsys_rawb
-          - mediatek,mt8186-mdpsys
+          - mediatek,mt8186-imgsys1
+          - mediatek,mt8186-imgsys2
+          - mediatek,mt8186-imp_iic_wrap
           - mediatek,mt8186-ipesys
+          - mediatek,mt8186-mdpsys
+          - mediatek,mt8186-mfgsys
+          - mediatek,mt8186-vdecsys
+          - mediatek,mt8186-vencsys
+          - mediatek,mt8186-wpesys
+
   reg:
     maxItems: 1
 
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +2 -2
index f8acc02cafee..6733dafbde16 100644
@@ -27,10 +27,10 @@ properties:
   compatible:
     items:
       - enum:
+          - mediatek,mt8186-apmixedsys
+          - mediatek,mt8186-infracfg_ao
           - mediatek,mt8186-mcusys
           - mediatek,mt8186-topckgen
-          - mediatek,mt8186-infracfg_ao
-          - mediatek,mt8186-apmixedsys
       - const: syscon
 
   reg:
Signature · 1 line
2.55.0
#5 lore raw

PATCH v6 5/27 dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186

In reply to Louis-Alexis Eyraud

Regroup the MT8188 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.

---
 .../bindings/clock/mediatek,mt8186-clock.yaml      | 51 +++++++++++-
 .../bindings/clock/mediatek,mt8186-sys-clock.yaml  |  6 +-
 .../bindings/clock/mediatek,mt8188-clock.yaml      | 93 ----------------------
 .../bindings/clock/mediatek,mt8188-sys-clock.yaml  | 58 --------------
 4 files changed, 55 insertions(+), 153 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +50 -1
index 756b937bb7c4..6a6ce343fab0 100644
@@ -4,7 +4,7 @@
 $id: http://devicetree.org/schemas/clock/mediatek,mt8186-clock.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: MediaTek Functional Clock Controller for MT8186
+title: MediaTek Functional Clock Controller for Mediatek SoCs
 
 maintainers:
   - Chun-Jie Chen <[email protected]>
@@ -35,6 +35,29 @@ properties:
           - mediatek,mt8186-vdecsys
           - mediatek,mt8186-vencsys
           - mediatek,mt8186-wpesys
+          - 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-wpesys
+          - mediatek,mt8188-wpesys-vpp0
 
   reg:
     maxItems: 1
@@ -42,11 +65,37 @@ properties:
   '#clock-cells':
     const: 1
 
+  '#reset-cells':
+    const: 1
+
 required:
   - compatible
   - reg
   - '#clock-cells'
 
+allOf:
+  - if:
+      properties:
+        compatible:
+          contains:
+            enum:
+              - mediatek,mt8188-camsys-rawa
+              - mediatek,mt8188-camsys-rawb
+              - mediatek,mt8188-camsys-yuva
+              - mediatek,mt8188-camsys-yuvb
+              - mediatek,mt8188-imgsys-wpe1
+              - mediatek,mt8188-imgsys-wpe2
+              - mediatek,mt8188-imgsys-wpe3
+              - mediatek,mt8188-imgsys1-dip-nr
+              - mediatek,mt8188-imgsys1-dip-top
+              - mediatek,mt8188-ipesys
+    then:
+      required:
+        - '#reset-cells'
+    else:
+      properties:
+        '#reset-cells': false
+
 additionalProperties: false
 
 examples:
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +5 -1
index 6733dafbde16..199eac2034f2 100644
@@ -4,7 +4,7 @@
 $id: http://devicetree.org/schemas/clock/mediatek,mt8186-sys-clock.yaml#
 $schema: http://devicetree.org/meta-schemas/core.yaml#
 
-title: MediaTek System Clock Controller for MT8186
+title: MediaTek System Clock Controller for  Mediatek SoCs
 
 maintainers:
   - Chun-Jie Chen <[email protected]>
@@ -31,6 +31,10 @@ properties:
           - mediatek,mt8186-infracfg_ao
           - mediatek,mt8186-mcusys
           - mediatek,mt8186-topckgen
+          - mediatek,mt8188-apmixedsys
+          - mediatek,mt8188-infracfg-ao
+          - mediatek,mt8188-pericfg-ao
+          - mediatek,mt8188-topckgen
       - const: syscon
 
   reg:
Documentation/devicetree/bindings/clock/mediatek,mt8188-clock.yaml deleted +0 -93

93 lines not on this page · raw message

Documentation/devicetree/bindings/clock/mediatek,mt8188-sys-clock.yaml deleted +0 -58

58 lines not on this page · raw message

Signature · 1 line
2.55.0
#6 lore raw

PATCH v6 6/27 dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186

In reply to Louis-Alexis Eyraud

Regroup the MT8192 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.

---
 .../bindings/clock/mediatek,mt8186-clock.yaml      |  20 +++
 .../bindings/clock/mediatek,mt8186-sys-clock.yaml  |   4 +
 .../bindings/clock/mediatek,mt8192-clock.yaml      | 192 ---------------------
 .../bindings/clock/mediatek,mt8192-sys-clock.yaml  |  69 --------
 4 files changed, 24 insertions(+), 261 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +20 -0
index 6a6ce343fab0..3db9e2953a0e 100644
@@ -58,6 +58,26 @@ properties:
           - mediatek,mt8188-vencsys
           - mediatek,mt8188-wpesys
           - mediatek,mt8188-wpesys-vpp0
+          - mediatek,mt8192-camsys
+          - mediatek,mt8192-camsys_rawa
+          - mediatek,mt8192-camsys_rawb
+          - mediatek,mt8192-camsys_rawc
+          - mediatek,mt8192-imgsys
+          - mediatek,mt8192-imgsys2
+          - mediatek,mt8192-imp_iic_wrap_c
+          - mediatek,mt8192-imp_iic_wrap_e
+          - mediatek,mt8192-imp_iic_wrap_s
+          - mediatek,mt8192-imp_iic_wrap_ws
+          - mediatek,mt8192-imp_iic_wrap_w
+          - mediatek,mt8192-imp_iic_wrap_n
+          - mediatek,mt8192-ipesys
+          - mediatek,mt8192-mdpsys
+          - mediatek,mt8192-mfgcfg
+          - mediatek,mt8192-msdc_top
+          - mediatek,mt8192-scp_adsp
+          - mediatek,mt8192-vdecsys_soc
+          - mediatek,mt8192-vdecsys
+          - mediatek,mt8192-vencsys
 
   reg:
     maxItems: 1
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +4 -0
index 199eac2034f2..41b8c61132e2 100644
@@ -35,6 +35,10 @@ properties:
           - mediatek,mt8188-infracfg-ao
           - mediatek,mt8188-pericfg-ao
           - mediatek,mt8188-topckgen
+          - mediatek,mt8192-apmixedsys
+          - mediatek,mt8192-infracfg
+          - mediatek,mt8192-pericfg
+          - mediatek,mt8192-topckgen
       - const: syscon
 
   reg:
Documentation/devicetree/bindings/clock/mediatek,mt8192-clock.yaml deleted +0 -192

192 lines not on this page · raw message

Documentation/devicetree/bindings/clock/mediatek,mt8192-sys-clock.yaml deleted +0 -69

69 lines not on this page · raw message

Signature · 1 line
2.55.0
#7 lore raw

Re: [PATCH v6 06/27] dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Medium] Missing required constraint for #reset-cells on reset providers. --

commit 0550a18e08e9f8b8ca4e5f412e6e70a0779197aa
Author: Louis-Alexis Eyraud <[email protected]>

dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186

This commit regroups the MT8192 functional and system clock dt-bindings into the MT8186 bindings to improve maintainability. It removes the MT8192-specific binding files and adds their compatible strings to the shared MT8186 yaml schemas.

Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml properties: · line 41

Quoted 12 lines
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +4 -0
index 199eac2034f22..41b8c61132e22 100644
@@ -35,6 +35,10 @@ properties:
           - mediatek,mt8188-infracfg-ao
           - mediatek,mt8188-pericfg-ao
           - mediatek,mt8188-topckgen
+          - mediatek,mt8192-apmixedsys
+          - mediatek,mt8192-infracfg
+          - mediatek,mt8192-pericfg
+          - mediatek,mt8192-topckgen

[Severity: Medium]
This is a pre-existing issue, but should the reset-cells property be explicitly required for compatible strings that act as reset providers, such as mediatek,mt8192-infracfg?

Currently, the properties section in mt8186-sys-clock.yaml specifies reset-cells as an optional property globally. Since mediatek,mt8192-infracfg functions as a reset provider, is an allOf conditional block needed to make reset-cells explicitly required for it?

Without this constraint, an incomplete device tree node omitting reset-cells for a reset provider will incorrectly pass schema validation silently.

Quoted 3 lines
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +0 -0
       - const: syscon
 
   reg:
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-mt8189-clocks-system-base-v6-0-5df247f56938@collabora.com?part=6
#8 lore raw

PATCH v6 7/27 dt-bindings: clock: mediatek: regroup MT8195 dt-bindings into MT8186

In reply to Louis-Alexis Eyraud

Regroup the MT8195 clock and system clock dt-bindings into MT8186 ones to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.

---
 .../bindings/clock/mediatek,mt8186-clock.yaml      |  25 +++
 .../bindings/clock/mediatek,mt8186-sys-clock.yaml  |   4 +
 .../bindings/clock/mediatek,mt8195-clock.yaml      | 239 ---------------------
 .../bindings/clock/mediatek,mt8195-sys-clock.yaml  |  77 -------
 4 files changed, 29 insertions(+), 316 deletions(-)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +25 -0
index 3db9e2953a0e..5af9e2ed4eeb 100644
@@ -78,6 +78,31 @@ properties:
           - mediatek,mt8192-vdecsys_soc
           - mediatek,mt8192-vdecsys
           - mediatek,mt8192-vencsys
+          - mediatek,mt8195-apusys_pll
+          - mediatek,mt8195-camsys
+          - mediatek,mt8195-camsys_rawa
+          - mediatek,mt8195-camsys_yuva
+          - mediatek,mt8195-camsys_rawb
+          - mediatek,mt8195-camsys_yuvb
+          - mediatek,mt8195-camsys_mraw
+          - mediatek,mt8195-ccusys
+          - mediatek,mt8195-imgsys
+          - mediatek,mt8195-imgsys1_dip_top
+          - mediatek,mt8195-imgsys1_dip_nr
+          - mediatek,mt8195-imgsys1_wpe
+          - mediatek,mt8195-imp_iic_wrap_s
+          - mediatek,mt8195-imp_iic_wrap_w
+          - mediatek,mt8195-ipesys
+          - mediatek,mt8195-mfgcfg
+          - mediatek,mt8195-scp_adsp
+          - mediatek,mt8195-vdecsys_soc
+          - mediatek,mt8195-vdecsys
+          - mediatek,mt8195-vdecsys_core1
+          - mediatek,mt8195-vencsys
+          - mediatek,mt8195-vencsys_core1
+          - mediatek,mt8195-wpesys
+          - mediatek,mt8195-wpesys_vpp0
+          - mediatek,mt8195-wpesys_vpp1
 
   reg:
     maxItems: 1
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +4 -0
index 41b8c61132e2..4a9d3eea4316 100644
@@ -39,6 +39,10 @@ properties:
           - mediatek,mt8192-infracfg
           - mediatek,mt8192-pericfg
           - mediatek,mt8192-topckgen
+          - mediatek,mt8195-apmixedsys
+          - mediatek,mt8195-infracfg_ao
+          - mediatek,mt8195-pericfg_ao
+          - mediatek,mt8195-topckgen
       - const: syscon
 
   reg:
Documentation/devicetree/bindings/clock/mediatek,mt8195-clock.yaml deleted +0 -239

239 lines not on this page · raw message

Documentation/devicetree/bindings/clock/mediatek,mt8195-sys-clock.yaml deleted +0 -77

77 lines not on this page · raw message

Signature · 1 line
2.55.0
#9 lore raw

PATCH v6 8/27 dt-bindings: clock: mediatek: Add MT8189 system/base clocks and resets

In reply to Louis-Alexis Eyraud

Add compatible and binding headers files for system and base clock controllers and reset controllers support of MediaTek MT8189 SoC. The MT8189 clock IP provide clock control for main system (apmixedsys, topcksys and vlpcksys) and subsys (eg. peri, scp, ufs...).

Also, add compatible for frequency hopping and spread spectrum clock functionality.

---
 .../bindings/clock/mediatek,mt8186-clock.yaml      |  15 +
 .../bindings/clock/mediatek,mt8186-fhctl.yaml      |   1 +
 .../bindings/clock/mediatek,mt8186-sys-clock.yaml  |   5 +
 include/dt-bindings/clock/mediatek,mt8189-clk.h    | 433 +++++++++++++++++++++
 include/dt-bindings/reset/mediatek,mt8189-resets.h |  17 +
 5 files changed, 471 insertions(+)
Documentation/devicetree/bindings/clock/mediatek,mt8186-clock.yaml +15 -0
index 5af9e2ed4eeb..f5d97aa9ec16 100644
@@ -58,6 +58,19 @@ properties:
           - mediatek,mt8188-vencsys
           - mediatek,mt8188-wpesys
           - mediatek,mt8188-wpesys-vpp0
+          - mediatek,mt8189-dbg-ao
+          - mediatek,mt8189-dem
+          - mediatek,mt8189-dvfsrc-top
+          - mediatek,mt8189-iic-wrap-e
+          - mediatek,mt8189-iic-wrap-en
+          - mediatek,mt8189-iic-wrap-s
+          - mediatek,mt8189-iic-wrap-ws
+          - mediatek,mt8189-scp-clk
+          - mediatek,mt8189-scp-i2c-clk
+          - mediatek,mt8189-ufscfg-ao
+          - mediatek,mt8189-ufscfg-pdn
+          - mediatek,mt8189-vlpcfg
+          - mediatek,mt8189-vlpcfg-ao
           - mediatek,mt8192-camsys
           - mediatek,mt8192-camsys_rawa
           - mediatek,mt8192-camsys_rawb
@@ -134,6 +147,8 @@ allOf:
               - mediatek,mt8188-imgsys1-dip-nr
               - mediatek,mt8188-imgsys1-dip-top
               - mediatek,mt8188-ipesys
+              - mediatek,mt8189-ufscfg-ao
+              - mediatek,mt8189-ufscfg-pdn
     then:
       required:
         - '#reset-cells'
Documentation/devicetree/bindings/clock/mediatek,mt8186-fhctl.yaml +1 -0
index d00327d12e1e..824e3b2bd6c0 100644
@@ -20,6 +20,7 @@ properties:
       - mediatek,mt6795-fhctl
       - mediatek,mt8173-fhctl
       - mediatek,mt8186-fhctl
+      - mediatek,mt8189-fhctl
       - mediatek,mt8192-fhctl
       - mediatek,mt8195-fhctl
 
Documentation/devicetree/bindings/clock/mediatek,mt8186-sys-clock.yaml +5 -0
index 4a9d3eea4316..2575f84ef917 100644
@@ -35,6 +35,11 @@ properties:
           - mediatek,mt8188-infracfg-ao
           - mediatek,mt8188-pericfg-ao
           - mediatek,mt8188-topckgen
+          - mediatek,mt8189-apmixedsys
+          - mediatek,mt8189-infra-ao
+          - mediatek,mt8189-peri-ao
+          - mediatek,mt8189-topckgen
+          - mediatek,mt8189-vlpckgen
           - mediatek,mt8192-apmixedsys
           - mediatek,mt8192-infracfg
           - mediatek,mt8192-pericfg
include/dt-bindings/clock/mediatek,mt8189-clk.h new file +433 -0

433 lines not on this page · raw message

include/dt-bindings/reset/mediatek,mt8189-resets.h new file +17 -0
new file mode 100644
index 000000000000..0f31984374be
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) */
+/*
+ * Copyright (c) 2026 Collabora Ltd.
+ * Author: Louis-Alexis Eyraud <[email protected]>
+ */
+
+#ifndef _DT_BINDINGS_RESET_CONTROLLER_MT8189
+#define _DT_BINDINGS_RESET_CONTROLLER_MT8189
+
+/* UFS resets */
+#define MT8189_UFSAO_RST_UFS_MPHY		0
+
+#define MT8189_UFSPDN_RST_UFS_UNIPRO		0
+#define MT8189_UFSPDN_RST_UFS_CRYPTO		1
+#define MT8189_UFSPDN_RST_UFS_HCI		2
+
+#endif  /* _DT_BINDINGS_RESET_CONTROLLER_MT8189 */
Signature · 1 line
2.55.0
#10 lore raw

PATCH v6 9/27 clk: mediatek: Harmonize mtk_pll_fenc related symbol names

In reply to Louis-Alexis Eyraud

To prepare for the new clock ops set addition, with support for set/clr enable logic only, rename mtk_pll_fenc_setclr_ops and its callback names to harmonize the naming with the same suffix.

---
 drivers/clk/mediatek/clk-mt8196-apmixedsys.c |  2 +-
 drivers/clk/mediatek/clk-mt8196-vlpckgen.c   |  2 +-
 drivers/clk/mediatek/clk-pll.c               | 16 ++++++++--------
 drivers/clk/mediatek/clk-pll.h               |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)
drivers/clk/mediatek/clk-mt8196-apmixedsys.c +1 -1
index c4ebb0170b82..41c5117b18f8 100644
@@ -83,7 +83,7 @@
 		.en_set_reg = PLLEN_ALL_SET,			\
 		.en_clr_reg = PLLEN_ALL_CLR,			\
 		.pll_en_bit = _pll_en_bit,			\
-		.ops = &mtk_pll_fenc_clr_set_ops,		\
+		.ops = &mtk_pll_fenc_setclr_ops,		\
 }
 
 struct mtk_pll_desc {
drivers/clk/mediatek/clk-mt8196-vlpckgen.c +1 -1
index ee88dc4a231a..814709db2924 100644
@@ -162,7 +162,7 @@
 		.en_set_reg = VLP_PLLEN_ALL_SET,		\
 		.en_clr_reg = VLP_PLLEN_ALL_CLR,		\
 		.pll_en_bit = _pll_en_bit,			\
-		.ops = &mtk_pll_fenc_clr_set_ops,		\
+		.ops = &mtk_pll_fenc_setclr_ops,		\
 }
 
 static DEFINE_SPINLOCK(mt8196_clk_vlp_lock);
drivers/clk/mediatek/clk-pll.c +8 -8
index e97064868908..ee478bc64085 100644
@@ -38,7 +38,7 @@ int mtk_pll_is_prepared(struct clk_hw *hw)
 	return (readl(pll->en_addr) & BIT(pll->data->pll_en_bit)) != 0;
 }
 
-static int mtk_pll_fenc_is_prepared(struct clk_hw *hw)
+static int mtk_pll_is_prepared_fenc_setclr(struct clk_hw *hw)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 
@@ -285,7 +285,7 @@ void mtk_pll_unprepare(struct clk_hw *hw)
 	writel(r, pll->pwr_addr);
 }
 
-static int mtk_pll_prepare_setclr(struct clk_hw *hw)
+static int mtk_pll_prepare_fenc_setclr(struct clk_hw *hw)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 
@@ -297,7 +297,7 @@ static int mtk_pll_prepare_setclr(struct clk_hw *hw)
 	return 0;
 }
 
-static void mtk_pll_unprepare_setclr(struct clk_hw *hw)
+static void mtk_pll_unprepare_fenc_setclr(struct clk_hw *hw)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 
@@ -313,15 +313,15 @@ const struct clk_ops mtk_pll_ops = {
 	.set_rate	= mtk_pll_set_rate,
 };
 
-const struct clk_ops mtk_pll_fenc_clr_set_ops = {
-	.is_prepared	= mtk_pll_fenc_is_prepared,
-	.prepare	= mtk_pll_prepare_setclr,
-	.unprepare	= mtk_pll_unprepare_setclr,
+const struct clk_ops mtk_pll_fenc_setclr_ops = {
+	.is_prepared	= mtk_pll_is_prepared_fenc_setclr,
+	.prepare	= mtk_pll_prepare_fenc_setclr,
+	.unprepare	= mtk_pll_unprepare_fenc_setclr,
 	.recalc_rate	= mtk_pll_recalc_rate,
 	.determine_rate	= mtk_pll_determine_rate,
 	.set_rate	= mtk_pll_set_rate,
 };
-EXPORT_SYMBOL_GPL(mtk_pll_fenc_clr_set_ops);
+EXPORT_SYMBOL_GPL(mtk_pll_fenc_setclr_ops);
 
 struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
 					const struct mtk_pll_data *data,
drivers/clk/mediatek/clk-pll.h +1 -1
index f49dc2732ffe..d6d34840c09d 100644
@@ -85,7 +85,7 @@ void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls,
 			     struct clk_hw_onecell_data *clk_data);
 
 extern const struct clk_ops mtk_pll_ops;
-extern const struct clk_ops mtk_pll_fenc_clr_set_ops;
+extern const struct clk_ops mtk_pll_fenc_setclr_ops;
 
 static inline struct mtk_clk_pll *to_mtk_clk_pll(struct clk_hw *hw)
 {
Signature · 1 line
2.55.0
#11 lore raw

PATCH v6 10/27 clk: mediatek: pll: Add BAR reset register offsets

In reply to Louis-Alexis Eyraud

Currently, the register offset to handle BAR reset, for PLLs that support it, is hardcoded to CON0.
On MT8189 SoC, there are separate status, set and clr registers to handle this, so differents offsets are needed.

Add the new fields for offsets and addresses to the MTK PLL data structure and modify mtk_clk_register_pll_ops function to compute the new register addresses so they are available for clock operation usage.

Also, replace reset BAR address computing by its computed address from MTK PLL data structure in prepare/unprepare callbacks.

---
 drivers/clk/mediatek/clk-pll.c | 18 ++++++++++++++----
 drivers/clk/mediatek/clk-pll.h |  6 ++++++
 2 files changed, 20 insertions(+), 4 deletions(-)
drivers/clk/mediatek/clk-pll.c +14 -4
index ee478bc64085..4b0f7e2bfc5a 100644
@@ -249,9 +249,9 @@ int mtk_pll_prepare(struct clk_hw *hw)
 	udelay(20);
 
 	if (pll->data->flags & HAVE_RST_BAR) {
-		r = readl(pll->base_addr + REG_CON0);
+		r = readl(pll->rst_bar_addr);
 		r |= pll->data->rst_bar_mask;
-		writel(r, pll->base_addr + REG_CON0);
+		writel(r, pll->rst_bar_addr);
 	}
 
 	return 0;
@@ -263,9 +263,9 @@ void mtk_pll_unprepare(struct clk_hw *hw)
 	u32 r;
 
 	if (pll->data->flags & HAVE_RST_BAR) {
-		r = readl(pll->base_addr + REG_CON0);
+		r = readl(pll->rst_bar_addr);
 		r &= ~pll->data->rst_bar_mask;
-		writel(r, pll->base_addr + REG_CON0);
+		writel(r, pll->rst_bar_addr);
 	}
 
 	__mtk_pll_tuner_disable(pll);
@@ -352,6 +352,16 @@ struct clk_hw *mtk_clk_register_pll_ops(struct mtk_clk_pll *pll,
 		pll->en_set_addr = base + data->en_set_reg;
 	if (data->en_clr_reg)
 		pll->en_clr_addr = base + data->en_clr_reg;
+
+	if (data->rst_bar_reg)
+		pll->rst_bar_addr = base + data->rst_bar_reg;
+	else
+		pll->rst_bar_addr = pll->base_addr + REG_CON0;
+	if (data->rst_bar_set_reg)
+		pll->rst_bar_set_addr = base + data->rst_bar_set_reg;
+	if (data->rst_bar_clr_reg)
+		pll->rst_bar_clr_addr = base + data->rst_bar_clr_reg;
+
 	pll->hw.init = &init;
 	pll->data = data;
 
drivers/clk/mediatek/clk-pll.h +6 -0
index d6d34840c09d..3aaf3a7654b5 100644
@@ -49,6 +49,9 @@ struct mtk_pll_data {
 	u32 en_reg;
 	u32 en_set_reg;
 	u32 en_clr_reg;
+	u32 rst_bar_reg;
+	u32 rst_bar_set_reg;
+	u32 rst_bar_clr_reg;
 	u8 pll_en_bit; /* Assume 0, indicates BIT(0) by default */
 	u8 pcw_chg_bit;
 	u8 fenc_sta_bit;
@@ -75,6 +78,9 @@ struct mtk_clk_pll {
 	void __iomem	*en_set_addr;
 	void __iomem	*en_clr_addr;
 	void __iomem	*fenc_addr;
+	void __iomem	*rst_bar_addr;
+	void __iomem	*rst_bar_set_addr;
+	void __iomem	*rst_bar_clr_addr;
 	const struct mtk_pll_data *data;
 };
 
Signature · 1 line
2.55.0
#12 lore raw

PATCH v6 11/27 clk: mediatek: pll: Factorise pll power on/off sequences

In reply to Louis-Alexis Eyraud

In order to prepare the MT8189 SoC support, that requires different registers to control PLL status and perform reset BAR, and so a different sets of clock operations, split the pll power on and off sequences from mtk_pll_prepare/unprepare functions into private subfunctions.

---
 drivers/clk/mediatek/clk-pll.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/clk/mediatek/clk-pll.c +21 -7
index 4b0f7e2bfc5a..2aaf2871ecf6 100644
@@ -223,9 +223,8 @@ int mtk_pll_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
 	return 0;
 }
 
-int mtk_pll_prepare(struct clk_hw *hw)
+static void mtk_pll_power_on(struct mtk_clk_pll *pll)
 {
-	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
 	u32 r;
 
 	r = readl(pll->pwr_addr) | CON0_PWR_ON;
@@ -235,6 +234,25 @@ int mtk_pll_prepare(struct clk_hw *hw)
 	r = readl(pll->pwr_addr) & ~CON0_ISO_EN;
 	writel(r, pll->pwr_addr);
 	udelay(1);
+}
+
+static void mtk_pll_power_off(struct mtk_clk_pll *pll)
+{
+	u32 r;
+
+	r = readl(pll->pwr_addr) | CON0_ISO_EN;
+	writel(r, pll->pwr_addr);
+
+	r = readl(pll->pwr_addr) & ~CON0_PWR_ON;
+	writel(r, pll->pwr_addr);
+}
+
+int mtk_pll_prepare(struct clk_hw *hw)
+{
+	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
+	u32 r;
+
+	mtk_pll_power_on(pll);
 
 	r = readl(pll->en_addr) | BIT(pll->data->pll_en_bit);
 	writel(r, pll->en_addr);
@@ -278,11 +296,7 @@ void mtk_pll_unprepare(struct clk_hw *hw)
 	r = readl(pll->en_addr) & ~BIT(pll->data->pll_en_bit);
 	writel(r, pll->en_addr);
 
-	r = readl(pll->pwr_addr) | CON0_ISO_EN;
-	writel(r, pll->pwr_addr);
-
-	r = readl(pll->pwr_addr) & ~CON0_PWR_ON;
-	writel(r, pll->pwr_addr);
+	mtk_pll_power_off(pll);
 }
 
 static int mtk_pll_prepare_fenc_setclr(struct clk_hw *hw)
Signature · 1 line
2.55.0
#13 lore raw

PATCH v6 12/27 clk: mediatek: pll: Add PLL stabilization delay definition

In reply to Louis-Alexis Eyraud

Several functions uses a hardcoded value (20), to represent the needed delay to stabilize a PLL.
Add a common define for this value.

---
 drivers/clk/mediatek/clk-pll.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/clk/mediatek/clk-pll.c +5 -3
index 2aaf2871ecf6..9a197a657dce 100644
@@ -31,6 +31,8 @@
 /* default 7 bits integer, can be overridden with pcwibits. */
 #define INTEGER_BITS		7
 
+#define PLL_STABILIZATION_DELAY	20 /* in us */
+
 int mtk_pll_is_prepared(struct clk_hw *hw)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
@@ -131,7 +133,7 @@ static void mtk_pll_set_rate_regs(struct mtk_clk_pll *pll, u32 pcw,
 	/* restore tuner_en */
 	__mtk_pll_tuner_enable(pll);
 
-	udelay(20);
+	udelay(PLL_STABILIZATION_DELAY);
 }
 
 /*
@@ -264,7 +266,7 @@ int mtk_pll_prepare(struct clk_hw *hw)
 
 	__mtk_pll_tuner_enable(pll);
 
-	udelay(20);
+	udelay(PLL_STABILIZATION_DELAY);
 
 	if (pll->data->flags & HAVE_RST_BAR) {
 		r = readl(pll->rst_bar_addr);
@@ -306,7 +308,7 @@ static int mtk_pll_prepare_fenc_setclr(struct clk_hw *hw)
 	writel(BIT(pll->data->pll_en_bit), pll->en_set_addr);
 
 	/* Wait 20us after enable for the PLL to stabilize */
-	udelay(20);
+	udelay(PLL_STABILIZATION_DELAY);
 
 	return 0;
 }
Signature · 1 line
2.55.0
#14 lore raw

Re: [PATCH v6 12/27] clk: mediatek: pll: Add PLL stabilization delay definition

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Comment retains a hardcoded delay value, defeating the purpose of the macro refactoring. --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] Comment retains a hardcoded delay value, defeating the purpose of the macro refactoring. --

commit ed78802d4853a74588db6e1da90538ffeb9ae7a6
Author: Louis-Alexis Eyraud <[email protected]>

clk: mediatek: pll: Add PLL stabilization delay definition

This commit introduces a new macro PLL_STABILIZATION_DELAY to replace hardcoded 20us delays used for PLL stabilization.

Quoted 4 lines
drivers/clk/mediatek/clk-pll.c +0 -0
index 2aaf2871ecf6a..9a197a657dce0 100644

[ ... ]

drivers/clk/mediatek/clk-pll.c static int mtk_pll_prepare_fenc_setclr(struct clk_hw *hw) · line 310

Quoted 4 lines
drivers/clk/mediatek/clk-pll.c +0 -0
@@ -306,7 +308,7 @@ static int mtk_pll_prepare_fenc_setclr(struct clk_hw *hw)
 	writel(BIT(pll->data->pll_en_bit), pll->en_set_addr);
 
 	/* Wait 20us after enable for the PLL to stabilize */

[Severity: Low]
This isn't a bug, but the comment still hardcodes the 20us value that the patch abstracts.

Should this comment be updated to remove the hardcoded value so it won't become stale if the PLL_STABILIZATION_DELAY macro is updated in the future?

Quoted 5 lines
drivers/clk/mediatek/clk-pll.c +1 -1
-	udelay(20);
+	udelay(PLL_STABILIZATION_DELAY);
 
 	return 0;
 }
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-mt8189-clocks-system-base-v6-0-5df247f56938@collabora.com?part=12
#15 lore raw

PATCH v6 13/27 clk: mediatek: pll: Add ops for PLLs using set/clr regs

In reply to Louis-Alexis Eyraud

MT8189 SoC uses a new combination of status and set/clr registers to control its PLL enable state and perform BAR reset, that are different than the current default clock prepare/unprepare operations are using.

Add new set of PLL clock operations to support this logic that relies on the following registers for prepare/unprepare operations:
- en/en_set/en_clr, rather than en register, for PLL enable control
- rst_bar/rst_bar_set/rst_bar_clr, rather than default rst_bar register for BAR reset control

Also, handle rst_bar register setting/clearing with a timeout, to verify the operation was correctly performed.

---
 drivers/clk/mediatek/clk-pll.c | 67 ++++++++++++++++++++++++++++++++++++++++++
 drivers/clk/mediatek/clk-pll.h |  5 ++++
 2 files changed, 72 insertions(+)
drivers/clk/mediatek/clk-pll.c +67 -0
index 9a197a657dce..f32b9145f256 100644
@@ -9,6 +9,7 @@
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/platform_device.h>
@@ -32,6 +33,7 @@
 #define INTEGER_BITS		7
 
 #define PLL_STABILIZATION_DELAY	20 /* in us */
+#define RST_BAR_TIMEOUT		20 /* in us */
 
 int mtk_pll_is_prepared(struct clk_hw *hw)
 {
@@ -301,6 +303,61 @@ void mtk_pll_unprepare(struct clk_hw *hw)
 	mtk_pll_power_off(pll);
 }
 
+int mtk_pll_prepare_setclr(struct clk_hw *hw)
+{
+	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
+	u32 val = 0;
+	int ret;
+
+	mtk_pll_power_on(pll);
+
+	writel(BIT(pll->data->pll_en_bit), pll->en_set_addr);
+
+	__mtk_pll_tuner_enable(pll);
+
+	udelay(PLL_STABILIZATION_DELAY);
+
+	if (pll->data->flags & HAVE_RST_BAR) {
+		writel(pll->data->rst_bar_mask, pll->rst_bar_set_addr);
+
+		ret = readl_poll_timeout(pll->rst_bar_addr, val,
+					(val & pll->data->rst_bar_mask), 1,
+					RST_BAR_TIMEOUT);
+		if (ret) {
+			mtk_pll_unprepare_setclr(hw);
+			return ret;
+		}
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(mtk_pll_prepare_setclr);
+
+void mtk_pll_unprepare_setclr(struct clk_hw *hw)
+{
+	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
+	u32 val = 0;
+
+	if (pll->data->flags & HAVE_RST_BAR) {
+		writel(pll->data->rst_bar_mask, pll->rst_bar_clr_addr);
+
+		/*
+		 * Ignore return code to continue unpreparing the PLL if
+		 * an error occurs on register read poll.
+		 */
+		readl_poll_timeout(pll->rst_bar_addr, val,
+				   !(val & pll->data->rst_bar_mask), 1,
+				   RST_BAR_TIMEOUT);
+	}
+
+	__mtk_pll_tuner_disable(pll);
+
+	writel(BIT(pll->data->pll_en_bit), pll->en_clr_addr);
+
+	mtk_pll_power_off(pll);
+}
+EXPORT_SYMBOL_GPL(mtk_pll_unprepare_setclr);
+
 static int mtk_pll_prepare_fenc_setclr(struct clk_hw *hw)
 {
 	struct mtk_clk_pll *pll = to_mtk_clk_pll(hw);
@@ -329,6 +386,16 @@ const struct clk_ops mtk_pll_ops = {
 	.set_rate	= mtk_pll_set_rate,
 };
 
+const struct clk_ops mtk_pll_setclr_ops = {
+	.is_prepared	= mtk_pll_is_prepared,
+	.prepare	= mtk_pll_prepare_setclr,
+	.unprepare	= mtk_pll_unprepare_setclr,
+	.recalc_rate	= mtk_pll_recalc_rate,
+	.determine_rate = mtk_pll_determine_rate,
+	.set_rate	= mtk_pll_set_rate,
+};
+EXPORT_SYMBOL_GPL(mtk_pll_setclr_ops);
+
 const struct clk_ops mtk_pll_fenc_setclr_ops = {
 	.is_prepared	= mtk_pll_is_prepared_fenc_setclr,
 	.prepare	= mtk_pll_prepare_fenc_setclr,
drivers/clk/mediatek/clk-pll.h +5 -0
index 3aaf3a7654b5..296bed073290 100644
@@ -92,6 +92,7 @@ void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls,
 
 extern const struct clk_ops mtk_pll_ops;
 extern const struct clk_ops mtk_pll_fenc_setclr_ops;
+extern const struct clk_ops mtk_pll_setclr_ops;
 
 static inline struct mtk_clk_pll *to_mtk_clk_pll(struct clk_hw *hw)
 {
@@ -104,6 +105,10 @@ int mtk_pll_prepare(struct clk_hw *hw);
 
 void mtk_pll_unprepare(struct clk_hw *hw);
 
+int mtk_pll_prepare_setclr(struct clk_hw *hw);
+
+void mtk_pll_unprepare_setclr(struct clk_hw *hw);
+
 unsigned long mtk_pll_recalc_rate(struct clk_hw *hw, unsigned long parent_rate);
 
 void mtk_pll_calc_values(struct mtk_clk_pll *pll, u32 *pcw, u32 *postdiv,
Signature · 1 line
2.55.0
#16 lore raw

PATCH v6 14/27 clk: mediatek: pllfh: Add configurable clock ops to mtk_pllfh_data

In reply to Louis-Alexis Eyraud

Currently, the mtk_clk_register_pllfh functions always registers the default PLL clock operation set (mtk_pllfh_ops). This does not allow use a custom one, for SoC such as MT8189, that needs different set with support for set/clr enable.

Add a new field for the ops to register in mtk_pllfh_data structure and use this new field to either register it when not null or the default ops otherwise.

---
 drivers/clk/mediatek/clk-pllfh.c | 5 +++--
 drivers/clk/mediatek/clk-pllfh.h | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/clk/mediatek/clk-pllfh.c +3 -2
index 6249fb87b1f5..cc73eb4f87e6 100644
@@ -153,6 +153,8 @@ static struct clk_hw *
 mtk_clk_register_pllfh(struct device *dev, const struct mtk_pll_data *pll_data,
 		       struct mtk_pllfh_data *pllfh_data, void __iomem *base)
 {
+	const struct clk_ops *pllfh_ops = pllfh_data->data.ops ?
+					  pllfh_data->data.ops : &mtk_pllfh_ops;
 	struct clk_hw *hw;
 	struct mtk_fh *fh;
 	int ret;
@@ -169,8 +171,7 @@ mtk_clk_register_pllfh(struct device *dev, const struct mtk_pll_data *pll_data,
 
 	fh->clk_pll.dev = dev;
 
-	hw = mtk_clk_register_pll_ops(&fh->clk_pll, pll_data, base,
-				      &mtk_pllfh_ops);
+	hw = mtk_clk_register_pll_ops(&fh->clk_pll, pll_data, base, pllfh_ops);
 
 	if (IS_ERR(hw))
 		goto out;
drivers/clk/mediatek/clk-pllfh.h +1 -0
index a4f337acad71..d32bfe194ec4 100644
@@ -34,6 +34,7 @@ struct fh_pll_data {
 	u32 updnlmt_shft;
 	u32 msk_frddsx_dys;
 	u32 msk_frddsx_dts;
+	const struct clk_ops *ops;
 };
 
 struct mtk_pllfh_data {
Signature · 1 line
2.55.0
#17 lore raw

PATCH v6 15/27 clk: mediatek: pllfh: Add ops for PLLs using set/clr regs

In reply to Louis-Alexis Eyraud

Add new set of PLL FHCTL clock operations, that uses the new prepare and unprepare methods, added in PLL for MT8189 SoC to support this logic.

---
 drivers/clk/mediatek/clk-pllfh.c | 10 ++++++++++
 drivers/clk/mediatek/clk-pllfh.h |  2 ++
 2 files changed, 12 insertions(+)
drivers/clk/mediatek/clk-pllfh.c +10 -0
index cc73eb4f87e6..f36dbc7fa06d 100644
@@ -47,6 +47,16 @@ static const struct clk_ops mtk_pllfh_ops = {
 	.set_rate	= mtk_fhctl_set_rate,
 };
 
+const struct clk_ops mtk_pllfh_setclr_ops = {
+	.is_prepared	= mtk_pll_is_prepared,
+	.prepare	= mtk_pll_prepare_setclr,
+	.unprepare	= mtk_pll_unprepare_setclr,
+	.recalc_rate	= mtk_pll_recalc_rate,
+	.determine_rate = mtk_pll_determine_rate,
+	.set_rate	= mtk_fhctl_set_rate,
+};
+EXPORT_SYMBOL_GPL(mtk_pllfh_setclr_ops);
+
 static struct mtk_pllfh_data *get_pllfh_by_id(struct mtk_pllfh_data *pllfhs,
 					      int num_fhs, int pll_id)
 {
drivers/clk/mediatek/clk-pllfh.h +2 -0
index d32bfe194ec4..a9eb7558de1c 100644
@@ -69,6 +69,8 @@ struct fh_operation {
 	int (*ssc_enable)(struct mtk_fh *fh, u32 rate);
 };
 
+extern const struct clk_ops mtk_pllfh_setclr_ops;
+
 int mtk_clk_register_pllfhs(struct device *dev,
 			    const struct mtk_pll_data *plls, int num_plls,
 			    struct mtk_pllfh_data *pllfhs, int num_pllfhs,
Signature · 1 line
2.55.0
#18 lore raw

PATCH v6 16/27 clk: mediatek: Move fhctl_parse_dt call into mtk_clk_register_pllfhs

In reply to Louis-Alexis Eyraud

Currently, in the probe functions of apmixedsys drivers with PLL frequency hopping support (FHCTL), the call to mtk_clk_register_pllfh is always preceded by a call to fhctl_parse_dt.

This function purpose is to prepare FHCTL-related internal data, that are then used by mtk_clk_register_pllfhs. It is not used in another case and both functions are implemented in the same source file (clk-pllfh.c). There is little interest to keep as it this call sequence in the several probe functions.

So, add an additional parameter (compatible name string) in mtk_clk_register_pllfhs and move the fhctl_parse_dt call into it. Finally, make this function private by removing it from clk-pllfh.h include, remove its EXPORT_SYMBOL_GPL macro use and add the static keyword.

---
 drivers/clk/mediatek/clk-mt6795-apmixedsys.c |  3 +--
 drivers/clk/mediatek/clk-mt8173-apmixedsys.c |  5 ++---
 drivers/clk/mediatek/clk-mt8186-apmixedsys.c |  4 +---
 drivers/clk/mediatek/clk-mt8192-apmixedsys.c |  4 +---
 drivers/clk/mediatek/clk-mt8195-apmixedsys.c |  4 +---
 drivers/clk/mediatek/clk-pllfh.c             | 10 ++++++----
 drivers/clk/mediatek/clk-pllfh.h             |  5 +----
 7 files changed, 13 insertions(+), 22 deletions(-)
drivers/clk/mediatek/clk-mt6795-apmixedsys.c +1 -2
index 123d5d7fea85..a860708ef908 100644
@@ -151,8 +151,7 @@ static int clk_mt6795_apmixed_probe(struct platform_device *pdev)
 	if (!clk_data)
 		return -ENOMEM;
 
-	fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
-	ret = mtk_clk_register_pllfhs(dev, plls, ARRAY_SIZE(plls),
+	ret = mtk_clk_register_pllfhs(dev, fhctl_node, plls, ARRAY_SIZE(plls),
 				      pllfhs, ARRAY_SIZE(pllfhs), clk_data);
 	if (ret)
 		goto free_clk_data;
drivers/clk/mediatek/clk-mt8173-apmixedsys.c +2 -3
index d7d416172ab3..8920eb1c3fa6 100644
@@ -156,9 +156,8 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 		goto unmap_io;
 	}
 
-	fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
-	r = mtk_clk_register_pllfhs(dev, plls, ARRAY_SIZE(plls), pllfhs,
-				    ARRAY_SIZE(pllfhs), clk_data);
+	r = mtk_clk_register_pllfhs(dev, fhctl_node, plls, ARRAY_SIZE(plls),
+				    pllfhs, ARRAY_SIZE(pllfhs), clk_data);
 	if (r)
 		goto free_clk_data;
 
drivers/clk/mediatek/clk-mt8186-apmixedsys.c +1 -3
index d35dd2632e43..e8fc6bd90fcb 100644
@@ -149,9 +149,7 @@ static int clk_mt8186_apmixed_probe(struct platform_device *pdev)
 	if (!clk_data)
 		return -ENOMEM;
 
-	fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
-
-	r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
+	r = mtk_clk_register_pllfhs(&pdev->dev, fhctl_node, plls, ARRAY_SIZE(plls),
 				    pllfhs, ARRAY_SIZE(pllfhs), clk_data);
 	if (r)
 		goto free_apmixed_data;
drivers/clk/mediatek/clk-mt8192-apmixedsys.c +1 -3
index b0563a285bd6..2e4f5aff9eee 100644
@@ -160,9 +160,7 @@ static int clk_mt8192_apmixed_probe(struct platform_device *pdev)
 	if (!clk_data)
 		return -ENOMEM;
 
-	fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
-
-	r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
+	r = mtk_clk_register_pllfhs(&pdev->dev, fhctl_node, plls, ARRAY_SIZE(plls),
 				    pllfhs, ARRAY_SIZE(pllfhs), clk_data);
 	if (r)
 		goto free_clk_data;
drivers/clk/mediatek/clk-mt8195-apmixedsys.c +1 -3
index a120c3305547..12e51b39b764 100644
@@ -178,9 +178,7 @@ static int clk_mt8195_apmixed_probe(struct platform_device *pdev)
 	if (!clk_data)
 		return -ENOMEM;
 
-	fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
-
-	r = mtk_clk_register_pllfhs(&pdev->dev, plls, ARRAY_SIZE(plls),
+	r = mtk_clk_register_pllfhs(&pdev->dev, fhctl_node, plls, ARRAY_SIZE(plls),
 				    pllfhs, ARRAY_SIZE(pllfhs), clk_data);
 	if (r)
 		goto free_apmixed_data;
drivers/clk/mediatek/clk-pllfh.c +6 -4
index f36dbc7fa06d..398edad2a69e 100644
@@ -69,8 +69,9 @@ static struct mtk_pllfh_data *get_pllfh_by_id(struct mtk_pllfh_data *pllfhs,
 	return NULL;
 }
 
-void fhctl_parse_dt(const u8 *compatible_node, struct mtk_pllfh_data *pllfhs,
-		    int num_fhs)
+static void fhctl_parse_dt(const u8 *compatible_node,
+			   struct mtk_pllfh_data *pllfhs,
+			   int num_fhs)
 {
 	void __iomem *base;
 	struct device_node *node;
@@ -121,7 +122,6 @@ void fhctl_parse_dt(const u8 *compatible_node, struct mtk_pllfh_data *pllfhs,
 	iounmap(base);
 	goto out_node_put;
 }
-EXPORT_SYMBOL_GPL(fhctl_parse_dt);
 
 static int pllfh_init(struct mtk_fh *fh, struct mtk_pllfh_data *pllfh_data)
 {
@@ -252,7 +252,7 @@ static void mtk_clk_cleanup_pllfhs(void __iomem *iomem_base,
 }
 
 
-int mtk_clk_register_pllfhs(struct device *dev,
+int mtk_clk_register_pllfhs(struct device *dev, const u8 *fhctl_node,
 			    const struct mtk_pll_data *plls, int num_plls,
 			    struct mtk_pllfh_data *pllfhs, int num_fhs,
 			    struct clk_hw_onecell_data *clk_data)
@@ -261,6 +261,8 @@ int mtk_clk_register_pllfhs(struct device *dev,
 	int i;
 	struct clk_hw *hw;
 
+	fhctl_parse_dt(fhctl_node, pllfhs, num_fhs);
+
 	base = of_iomap(dev->of_node, 0);
 	if (!base) {
 		pr_err("%s(): ioremap failed\n", __func__);
drivers/clk/mediatek/clk-pllfh.h +1 -4
index a9eb7558de1c..07269e467e34 100644
@@ -71,7 +71,7 @@ struct fh_operation {
 
 extern const struct clk_ops mtk_pllfh_setclr_ops;
 
-int mtk_clk_register_pllfhs(struct device *dev,
+int mtk_clk_register_pllfhs(struct device *dev, const u8 *fhctl_node,
 			    const struct mtk_pll_data *plls, int num_plls,
 			    struct mtk_pllfh_data *pllfhs, int num_pllfhs,
 			    struct clk_hw_onecell_data *clk_data);
@@ -80,7 +80,4 @@ void mtk_clk_unregister_pllfhs(const struct mtk_pll_data *plls, int num_plls,
 			       struct mtk_pllfh_data *pllfhs, int num_fhs,
 			       struct clk_hw_onecell_data *clk_data);
 
-void fhctl_parse_dt(const u8 *compatible_node, struct mtk_pllfh_data *pllfhs,
-		    int num_pllfhs);
-
 #endif /* __CLK_PLLFH_H */
Signature · 1 line
2.55.0
#19 lore raw

PATCH v6 17/27 clk: mediatek: pllfh: clear state data in mtk_clk_cleanup_pllfhs

In reply to Louis-Alexis Eyraud

Currently, fhctl_parse_dt function sets some state variables that are never cleared in the unregister nominal path or register error one. As they are stored in a static array variable, given as parameter from the caller function, they retain their values until they are initialized again by another fhctl_parse_dt call.

So, add a loop to clear these state variables in mtk_clk_cleanup_pllfhs function.

---
 drivers/clk/mediatek/clk-pllfh.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/clk/mediatek/clk-pllfh.c +8 -0
index 398edad2a69e..ae56d4ad66dc 100644
@@ -244,6 +244,14 @@ static void mtk_clk_cleanup_pllfhs(void __iomem *iomem_base,
 		clk_data->hws[pll->id] = ERR_PTR(-ENOENT);
 	}
 
+	for (i = 0; i < num_fhs; i++) {
+		struct mtk_pllfh_data *pllfh = &pllfhs[i];
+
+		pllfh->state.fh_enable = 0;
+		pllfh->state.ssc_rate = 0;
+		pllfh->state.base = NULL;
+	}
+
 	if (fhctl_base)
 		iounmap(fhctl_base);
 
Signature · 1 line
2.55.0
#20 lore raw

Re: [PATCH v6 17/27] clk: mediatek: pllfh: clear state data in mtk_clk_cleanup_pllfhs

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Variables pll_id and ssc_rate are used uninitialized if device tree property reads fail. --

commit d96970ce40bb3dd0da1358d2ea7d97e33c5495ae
Author: Louis-Alexis Eyraud <[email protected]>

clk: mediatek: pllfh: clear state data in mtk_clk_cleanup_pllfhs

Currently, fhctl_parse_dt function sets some state variables that are never cleared in the unregister nominal path or register error one. As they are stored in a static array variable, given as parameter from the caller function, they retain their values until they are initialized again by another fhctl_parse_dt call.

drivers/clk/mediatek/clk-pllfh.c static void mtk_clk_cleanup_pllfhs(void __iomem *iomem_base, · line 251

Quoted 13 lines
drivers/clk/mediatek/clk-pllfh.c +5 -0
index 398edad2a69e6..ae56d4ad66dc8 100644
@@ -244,6 +244,14 @@ static void mtk_clk_cleanup_pllfhs(void __iomem *iomem_base,
 		clk_data->hws[pll->id] = ERR_PTR(-ENOENT);
 	}
 
+	for (i = 0; i < num_fhs; i++) {
+		struct mtk_pllfh_data *pllfh = &pllfhs[i];
+
+		pllfh->state.fh_enable = 0;
+		pllfh->state.ssc_rate = 0;

[Severity: High]
This isn't a bug introduced by this patch, but while we are clearing this state data here, there appears to be an initialization issue in fhctl_parse_dt() where pll_id and ssc_rate are populated:

drivers/clk/mediatek/clk-pllfh.c:fhctl_parse_dt() {
    ...
		of_property_read_u32_index(node, "clocks", offset + 1, &pll_id);
		of_property_read_u32_index(node,
					   "mediatek,hopping-ssc-percent",
					   i, &ssc_rate);

		pllfh = get_pllfh_by_id(pllfhs, num_fhs, pll_id);
    ...
}

Are these variables used uninitialized if the device tree property reads fail?

If the clocks or mediatek,hopping-ssc-percent properties are missing or malformed in the device tree, of_property_read_u32_index() will fail silently and leave pll_id and ssc_rate unmodified.

On the first iteration, this could result in stack garbage being used to look up a PLL ID and set its spread-spectrum clocking rate. On subsequent iterations, the variables might incorrectly reuse values from the previous clock, applying wrong configurations to the hardware.

Should we be checking the return values of of_property_read_u32_index() to prevent unexpected PLL state configurations?

Quoted 6 lines
drivers/clk/mediatek/clk-pllfh.c +3 -0
+		pllfh->state.base = NULL;
+	}
+
 	if (fhctl_base)
 		iounmap(fhctl_base);
 
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-mt8189-clocks-system-base-v6-0-5df247f56938@collabora.com?part=17
#21 lore raw

PATCH v6 18/27 clk: mediatek: Add MT8189 apmixedsys clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 apmixedsys clock controller, which provides PLLs generated from SoC 26m.

---
 drivers/clk/mediatek/Kconfig                 |  13 ++
 drivers/clk/mediatek/Makefile                |   1 +
 drivers/clk/mediatek/clk-mt8189-apmixedsys.c | 202 +++++++++++++++++++++++++++
 3 files changed, 216 insertions(+)
drivers/clk/mediatek/Kconfig +13 -0
index b059d44577f1..d1200be0166c 100644
@@ -825,6 +825,19 @@ config COMMON_CLK_MT8188_WPESYS
 	help
 	  This driver supports MediaTek MT8188 Warp Engine clocks.
 
+config COMMON_CLK_MT8189
+	tristate "Clock driver for MediaTek MT8189"
+	depends on ARM64 || COMPILE_TEST
+	select COMMON_CLK_MEDIATEK
+	select COMMON_CLK_MEDIATEK_FHCTL
+	default ARCH_MEDIATEK
+	help
+	  Enable this option to support the clock management for MediaTek MT8189 SoC. This
+	  includes handling of all primary clock functions and features specific to the MT8189
+	  platform. Enabling this driver ensures that the system's clock functionality aligns
+	  with the MediaTek MT8189 hardware capabilities, providing efficient management of
+	  clock speeds and power consumption.
+
 config COMMON_CLK_MT8192
 	tristate "Clock driver for MediaTek MT8192"
 	depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index 892a54eeb281..79b8ee47a867 100644
@@ -124,6 +124,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VDOSYS) += clk-mt8188-vdo0.o clk-mt8188-vdo1.o
 obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o
 obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o
+obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-apmixedsys.c new file +202 -0

202 lines not on this page · raw message

Signature · 1 line
2.55.0
#22 lore raw

Re: [PATCH v6 18/27] clk: mediatek: Add MT8189 apmixedsys clock support

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Uninitialized variables cause potential hardware corruption due to ignored return values.
- [High] Memory leak of the fhctl I/O mapping on early probe failure.
--

commit 899c77c67da66015b28a154ffd13a738ef18913e
Author: Louis-Alexis Eyraud <[email protected]>

clk: mediatek: Add MT8189 apmixedsys clock support

Add support for the MT8189 apmixedsys clock controller, which provides PLLs generated from SoC 26m.

Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +0 -0
new file mode 100644
index 0000000000000..7399a444ec4d4

[ ... ]

Quoted 4 lines
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +4 -0
+static int clk_mt8189_apmixed_probe(struct platform_device *pdev)
+{
+	const u8 *fhctl_node = "mediatek,mt8189-fhctl";
+	struct device_node *node = pdev->dev.of_node;

drivers/clk/mediatek/clk-mt8189-apmixedsys.c line 160

Quoted 10 lines
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +10 -0
+	struct clk_hw_onecell_data *clk_data;
+	int r;
+
+	clk_data = mtk_alloc_clk_data(ARRAY_SIZE(apmixed_plls));
+	if (!clk_data)
+		return -ENOMEM;
+
+	r = mtk_clk_register_pllfhs(&pdev->dev, fhctl_node, apmixed_plls,
+				    ARRAY_SIZE(apmixed_plls), pllfhs,
+				    ARRAY_SIZE(pllfhs), clk_data);

[Severity: High]
This is a pre-existing issue, but does this call expose a potential memory leak of the fhctl I/O mapping on early probe failure?

If of_iomap() fails in mtk_clk_register_pllfhs(), it returns -EINVAL and leaks the fhctl_base mapped earlier in fhctl_parse_dt():

drivers/clk/mediatek/clk-pllfh.c:mtk_clk_register_pllfhs() {
    fhctl_parse_dt(fhctl_node, pllfhs, num_fhs);

    base = of_iomap(dev->of_node, 0);
    if (!base) {
        pr_err("%s(): ioremap failed\n", __func__);
        return -EINVAL;
    }
    ...
}

Similarly, if the loop fails on the very first iteration, it branches to the error path and calls mtk_clk_cleanup_pllfhs() with a loop counter of 0. Because the cleanup loop relies on the loop counter to discover fhctl_base from the state array, the loop is skipped, fhctl_base remains NULL, and the reference is overwritten without calling iounmap().

Is there a way to ensure this mapping is correctly cleaned up if probe fails during testing or device bind/unbind?

[Severity: High]
This is another pre-existing issue exposed by this call, but does fhctl_parse_dt() ignore the return values of of_property_read_u32_index(), leading to uninitialized stack variables being passed to get_pllfh_by_id()?

drivers/clk/mediatek/clk-pllfh.c:fhctl_parse_dt() {
        of_property_read_u32_index(node, "clocks", offset + 1, &pll_id);
        of_property_read_u32_index(node,
                                   "mediatek,hopping-ssc-percent",
                                   i, &ssc_rate);

        pllfh = get_pllfh_by_id(pllfhs, num_fhs, pll_id);
    ...
}

If the device tree is missing the 'clocks' or 'mediatek,hopping-ssc-percent' properties, of_property_read_u32_index() returns an error without initializing pll_id and ssc_rate. These uninitialized stack variables are then used to look up a PLL and configure its SSC rate, which could lead to hardware state corruption.

Could we add error checking for these device tree reads?

Quoted 18 lines
drivers/clk/mediatek/clk-mt8189-apmixedsys.c new file +18 -0
+	if (r)
+		goto free_apmixed_data;
+
+	r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
+	if (r)
+		goto unregister_plls;
+
+	platform_set_drvdata(pdev, clk_data);
+
+	return 0;
+
+unregister_plls:
+	mtk_clk_unregister_pllfhs(apmixed_plls, ARRAY_SIZE(apmixed_plls), pllfhs,
+				  ARRAY_SIZE(pllfhs), clk_data);
+free_apmixed_data:
+	mtk_free_clk_data(clk_data);
+	return r;
+}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-mt8189-clocks-system-base-v6-0-5df247f56938@collabora.com?part=18
#23 lore raw

PATCH v6 19/27 clk: mediatek: Add MT8189 topckgen clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 topckgen clock controller, which provides muxes and dividers for clock selection in other IP blocks.

---
 drivers/clk/mediatek/Makefile              |    2 +-
 drivers/clk/mediatek/clk-mt8189-topckgen.c | 1019 ++++++++++++++++++++++++++++
 2 files changed, 1020 insertions(+), 1 deletion(-)
drivers/clk/mediatek/Makefile +1 -1
index 79b8ee47a867..eb9a1f3efebe 100644
@@ -124,7 +124,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VDOSYS) += clk-mt8188-vdo0.o clk-mt8188-vdo1.o
 obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o
 obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o
-obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o
+obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-topckgen.c new file +1019 -0

1,019 lines not on this page · raw message

Signature · 1 line
2.55.0
#24 lore raw

Re: [PATCH v6 19/27] clk: mediatek: Add MT8189 topckgen clock support

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Use-after-free of struct clk and struct clk_core due to mismatched devres unregistration order during device remove or probe error. --

commit c9fccf00f7b65c99304902dc0b7804332954da0c
Author: Louis-Alexis Eyraud <[email protected]>

clk: mediatek: Add MT8189 topckgen clock support

Add support for the MT8189 topckgen clock controller, which provides muxes and dividers for clock selection in other IP blocks.

Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-topckgen.c new file +0 -0
new file mode 100644
index 0000000000000..6ed7661119b82

[ ... ]

Quoted 4 lines
drivers/clk/mediatek/clk-mt8189-topckgen.c new file +4 -0
+/* Register mux notifier for MFG mux */
+static int clk_mt8189_reg_mfg_mux_notifier(struct device *dev,
+					   struct clk *clk)
+{

drivers/clk/mediatek/clk-mt8189-topckgen.c line 985

Quoted 10 lines
drivers/clk/mediatek/clk-mt8189-topckgen.c new file +10 -0
+	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 = &mtk_mux_clr_set_upd_ops;
+	mfg_mux_nb->bypass_index = 0; /* Bypass to CLK_TOP_MFG_REF_SEL */
+
+	return devm_mtk_clk_mux_notifier_register(dev, clk, mfg_mux_nb);

[Severity: High]
This isn't a bug introduced by this patch, but does this devres registration cause a use-after-free during device removal?

The clock notifier is registered using devres via devm_mtk_clk_mux_notifier_register(). During device unbind (e.g., via sysfs or rmmod) or when probe fails after the notifier is registered, the driver manually unregisters the clock via mtk_clk_unregister_muxes(), which internally calls clk_hw_unregister(). This unconditionally frees the struct clk instance.

Afterward, the devres framework automatically runs cleanup callbacks and invokes devm_clk_notifier_release(). This devres callback passes the already-freed clk pointer to clk_notifier_unregister(), which dereferences the freed memory to access clk->core->notifier_count.

Quoted 1 line

+}

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-mt8189-clocks-system-base-v6-0-5df247f56938@collabora.com?part=19
#25 lore raw

PATCH 1/1 clk: mediatek: mt8189: Don't let the GPU reference mux retune MAINPLL

In reply to Louis-Alexis Eyraud

mfg_sel_mfgpll selects the GPU clock from mfg_ref_sel or mfgpll and has CLK_SET_RATE_PARENT, so a GPU rate request (Panfrost devfreq) goes through __clk_mux_determine_rate(), which evaluates both parents. mfg_ref_sel is a MUX_GATE_CLR_SET_UPD() and so also has CLK_SET_RATE_PARENT, as does its mainpll_d6 parent: through it, any GPU OPP can be met exactly by retuning MAINPLL to six times the requested rate. mfg_ref_sel is parent 0, so it wins over mfgpll whenever both match.

On an MT8189 Chromebook, MAINPLL therefore followed the GPU: 2340 MHz for the 390 MHz OPP instead of the 2184 MHz the firmware sets, and 3360 or 3570 MHz while the GPU ran at 560 or 595 MHz. Everything else derived from MAINPLL moved with it: the peripheral and memory buses, and the display PWM, whose backlight frequency jumped from 2 to about 3 kHz for tens of milliseconds under GPU load. That showed as a visible brightness flicker.

mfg_ref_sel is only the reference/bypass parent that the mux notifier switches to while MFGPLL relocks. Don't let it propagate rate changes, as MT8195 does for its top_mfg_core_tmp. The GPU then gets its rates from MFGPLL, and MAINPLL stays at its firmware rate.

Assisted-by LLM

---
Found on top of v6 ("[PATCH v6 19/27] clk: mediatek: Add MT8189 topckgen clock support"); it applies to that patch and can be squashed into it.

Testing: Lenovo IdeaPad Slim 3 Chromebook (MT8189, "quigon"), next-20261008 plus this series and local board support, Panfrost on the Mali-G57 with devfreq. Before: MAINPLL 2340 MHz at idle and 3360/3570 MHz under GPU load, read from clk_summary; the display PWM's actual period (debugfs/pwm) went from 500 us to 348/328 us with it. After: every GPU OPP from 390 to 1100 MHz forced through devfreq min/max_freq, and scrolling a busy page: the GPU always on mfgpll, MAINPLL fixed at 2184 MHz, the PWM steady, no flicker. No device tree change needed (the mux selects mfgpll by itself). Built with W=1.

 drivers/clk/mediatek/clk-mt8189-topckgen.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/clk/mediatek/clk-mt8189-topckgen.c +7 -3
index 6ed7661119b8..ff9fd5115c5b 100644
@@ -818,9 +818,13 @@ static const struct mtk_mux top_muxes[] = {
 			     dxcc_parents, 0x100, 0x104, 0x108,
 			     24, 2, 31, 0x0c, 1),
 	/* CLK_CFG_16 */
-	MUX_GATE_CLR_SET_UPD(CLK_TOP_MFG_REF_SEL, "mfg_ref_sel",
-			     mfg_ref_parents, 0x110, 0x114, 0x118,
-			     0, 2, 7, 0x0c, 2),
+	/*
+	 * Reference/bypass parent of mfg_sel_mfgpll: don't propagate rate
+	 * requests, or GPU DVFS retunes MAINPLL through mainpll_d6.
+	 */
+	MUX_GATE_CLR_SET_UPD_FLAGS(CLK_TOP_MFG_REF_SEL, "mfg_ref_sel",
+				   mfg_ref_parents, 0x110, 0x114, 0x118,
+				   0, 2, 7, 0x0c, 2, 0),
 	MUX_GATE_CLR_SET_UPD(CLK_TOP_MDP0_SEL, "mdp0_sel",
 			     mmsys_parents, 0x110, 0x114, 0x118,
 			     8, 4, 15, 0x0c, 3),
Signature · 1 line
2.43.0
maintainer Applied
#26 lore raw

Re: [PATCH] clk: mediatek: mt8189: Don't let the GPU reference mux retune MAINPLL

Quoted 9 lines · On Sun, 11 Oct 2026 15:56:12 -0400, zoan37 wrote:

mfg_sel_mfgpll selects the GPU clock from mfg_ref_sel or mfgpll and has CLK_SET_RATE_PARENT, so a GPU rate request (Panfrost devfreq) goes through __clk_mux_determine_rate(), which evaluates both parents. mfg_ref_sel is a MUX_GATE_CLR_SET_UPD() and so also has CLK_SET_RATE_PARENT, as does its mainpll_d6 parent: through it, any GPU OPP can be met exactly by retuning MAINPLL to six times the requested rate. mfg_ref_sel is parent 0, so it wins over mfgpll whenever both match.

[...]

Applied to v7.4-next/clk, thanks!

[1/1] clk: mediatek: mt8189: Don't let the GPU reference mux retune MAINPLL

      commit: 838ddf25b4f1350a115d8921b47e9bbaa773a26c

Cheers,
Angelo

#27 lore raw

PATCH v6 20/27 clk: mediatek: Add MT8189 vlpckgen clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 vlpckgen clock controller, which provides muxes and dividers for clock selection in vlp domain for other IP blocks.

---
 drivers/clk/mediatek/Makefile              |   3 +-
 drivers/clk/mediatek/clk-mt8189-vlpckgen.c | 279 +++++++++++++++++++++++++++++
 2 files changed, 281 insertions(+), 1 deletion(-)
drivers/clk/mediatek/Makefile +2 -1
index eb9a1f3efebe..8fc63b830467 100644
@@ -124,7 +124,8 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VDOSYS) += clk-mt8188-vdo0.o clk-mt8188-vdo1.o
 obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o
 obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o
-obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o
+obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o \
+				   clk-mt8189-vlpckgen.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-vlpckgen.c new file +279 -0

279 lines not on this page · raw message

Signature · 1 line
2.55.0
#28 lore raw

PATCH v6 21/27 clk: mediatek: Add MT8189 vlpcfg clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 vlpcfg clock controller, which provides clock gate control for vlp domain IPs.

---
 drivers/clk/mediatek/Makefile            |   2 +-
 drivers/clk/mediatek/clk-mt8189-vlpcfg.c | 115 +++++++++++++++++++++++++++++++
 2 files changed, 116 insertions(+), 1 deletion(-)
drivers/clk/mediatek/Makefile +1 -1
index 8fc63b830467..b0fb36108179 100644
@@ -125,7 +125,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VENCSYS) += clk-mt8188-venc.o
 obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o
 obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o
 obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o \
-				   clk-mt8189-vlpckgen.o
+				   clk-mt8189-vlpckgen.o clk-mt8189-vlpcfg.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-vlpcfg.c new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
2.55.0
#29 lore raw

PATCH v6 22/27 clk: mediatek: Add MT8189 bus clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 bus clock controller, which provides clock gate control for infra/peri IPs (such as spi, uart, msdc, flashif ...).

---
 drivers/clk/mediatek/Kconfig          |  11 ++
 drivers/clk/mediatek/Makefile         |   1 +
 drivers/clk/mediatek/clk-mt8189-bus.c | 199 ++++++++++++++++++++++++++++++++++
 3 files changed, 211 insertions(+)
drivers/clk/mediatek/Kconfig +11 -0
index d1200be0166c..7b0810fb8491 100644
@@ -838,6 +838,17 @@ config COMMON_CLK_MT8189
 	  with the MediaTek MT8189 hardware capabilities, providing efficient management of
 	  clock speeds and power consumption.
 
+config COMMON_CLK_MT8189_BUS
+	tristate "Clock driver for MediaTek MT8189 bus"
+	depends on COMMON_CLK_MT8189
+	default COMMON_CLK_MT8189
+	help
+	  Enable this configuration option to support the clock framework for
+	  MediaTek MT8189 SoC bus clocks. It includes the necessary clock
+	  management for bus-related peripherals and interconnects within the
+	  MT8189 chipset, ensuring that all bus-related components receive the
+	  correct clock signals for optimal performance.
+
 config COMMON_CLK_MT8192
 	tristate "Clock driver for MediaTek MT8192"
 	depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index b0fb36108179..1a0de9364968 100644
@@ -126,6 +126,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_VPPSYS) += clk-mt8188-vpp0.o clk-mt8188-vpp1.o
 obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o
 obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o \
 				   clk-mt8189-vlpckgen.o clk-mt8189-vlpcfg.o
+obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-bus.c new file +199 -0

199 lines not on this page · raw message

Signature · 1 line
2.55.0
#30 lore raw

PATCH v6 23/27 clk: mediatek: Add MT8189 dbgao clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 dbgao clock controller, which provides clock gate control for debug-system.

---
 drivers/clk/mediatek/Kconfig            | 10 ++++
 drivers/clk/mediatek/Makefile           |  1 +
 drivers/clk/mediatek/clk-mt8189-dbgao.c | 97 +++++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+)
drivers/clk/mediatek/Kconfig +10 -0
index 7b0810fb8491..e92599016f3a 100644
@@ -849,6 +849,16 @@ config COMMON_CLK_MT8189_BUS
 	  MT8189 chipset, ensuring that all bus-related components receive the
 	  correct clock signals for optimal performance.
 
+config COMMON_CLK_MT8189_DBGAO
+	tristate "Clock driver for MediaTek MT8189 debug ao"
+	depends on COMMON_CLK_MT8189
+	default COMMON_CLK_MT8189
+	help
+	  Enable this to support the clock management for the debug function
+	  on MediaTek MT8189 SoCs. This includes enabling and disabling
+	  vcore debug system clocks. If you want to control its clocks, say Y or M
+	  to include this driver in your kernel build.
+
 config COMMON_CLK_MT8192
 	tristate "Clock driver for MediaTek MT8192"
 	depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index 1a0de9364968..3600dd72ab9e 100644
@@ -127,6 +127,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188_WPESYS) += clk-mt8188-wpe.o
 obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o \
 				   clk-mt8189-vlpckgen.o clk-mt8189-vlpcfg.o
 obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o
+obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-dbgao.c new file +97 -0

97 lines not on this page · raw message

Signature · 1 line
2.55.0
#31 lore raw

PATCH v6 24/27 clk: mediatek: Add MT8189 dvfsrc clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 dvfsrc clock controller, which provides clock gate control for dram dvfs.

---
 drivers/clk/mediatek/Kconfig             | 10 ++++++
 drivers/clk/mediatek/Makefile            |  1 +
 drivers/clk/mediatek/clk-mt8189-dvfsrc.c | 57 ++++++++++++++++++++++++++++++++
 3 files changed, 68 insertions(+)
drivers/clk/mediatek/Kconfig +10 -0
index e92599016f3a..9ed3f7b155ff 100644
@@ -859,6 +859,16 @@ config COMMON_CLK_MT8189_DBGAO
 	  vcore debug system clocks. If you want to control its clocks, say Y or M
 	  to include this driver in your kernel build.
 
+config COMMON_CLK_MT8189_DVFSRC
+	tristate "Clock driver for MediaTek MT8189 dvfsrc"
+	depends on COMMON_CLK_MT8189
+	default COMMON_CLK_MT8189
+	help
+	  Enable this to support the clock management for the dvfsrc
+	  on MediaTek MT8189 SoCs. This includes enabling and disabling
+	  vcore dvfs clocks. If you want to control its clocks, say Y or M
+	  to include this driver in your kernel build.
+
 config COMMON_CLK_MT8192
 	tristate "Clock driver for MediaTek MT8192"
 	depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index 3600dd72ab9e..822abeae205b 100644
@@ -128,6 +128,7 @@ obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o
 				   clk-mt8189-vlpckgen.o clk-mt8189-vlpcfg.o
 obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o
 obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o
+obj-$(CONFIG_COMMON_CLK_MT8189_DVFSRC) += clk-mt8189-dvfsrc.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-dvfsrc.c new file +57 -0

57 lines not on this page · raw message

Signature · 1 line
2.55.0
#32 lore raw

PATCH v6 25/27 clk: mediatek: Add MT8189 i2c clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 i2c clock controller,
which provides clock gate control for i2c.

---
 drivers/clk/mediatek/Kconfig          |  13 ++++
 drivers/clk/mediatek/Makefile         |   1 +
 drivers/clk/mediatek/clk-mt8189-iic.c | 121 ++++++++++++++++++++++++++++++++++
 3 files changed, 135 insertions(+)
drivers/clk/mediatek/Kconfig +13 -0
index 9ed3f7b155ff..7b3bc27edbe3 100644
@@ -869,6 +869,19 @@ config COMMON_CLK_MT8189_DVFSRC
 	  vcore dvfs clocks. If you want to control its clocks, say Y or M
 	  to include this driver in your kernel build.
 
+config COMMON_CLK_MT8189_IIC
+	tristate "Clock driver for MediaTek MT8189 iic"
+	depends on COMMON_CLK_MT8189
+	default COMMON_CLK_MT8189
+	help
+	  Enable this option to support the clock framework for MediaTek MT8189
+	  integrated circuits (iic). This driver is responsible for managing
+	  clock sources, dividers, and gates specifically designed for MT8189
+	  SoCs. Enabling this driver ensures that the system can correctly
+	  manage clock frequencies and power for various components within
+	  the MT8189 chipset, improving the overall performance and power
+	  efficiency of the device.
+
 config COMMON_CLK_MT8192
 	tristate "Clock driver for MediaTek MT8192"
 	depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index 822abeae205b..5e35185d23b0 100644
@@ -129,6 +129,7 @@ obj-$(CONFIG_COMMON_CLK_MT8189) += clk-mt8189-apmixedsys.o clk-mt8189-topckgen.o
 obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o
 obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o
 obj-$(CONFIG_COMMON_CLK_MT8189_DVFSRC) += clk-mt8189-dvfsrc.o
+obj-$(CONFIG_COMMON_CLK_MT8189_IIC) += clk-mt8189-iic.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-iic.c new file +121 -0

121 lines not on this page · raw message

Signature · 1 line
2.55.0
#33 lore raw

PATCH v6 26/27 clk: mediatek: Add MT8189 scp clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 scp clock controller, which provides clock gate control for System Control Processor.

---
 drivers/clk/mediatek/Kconfig          | 10 +++++
 drivers/clk/mediatek/Makefile         |  1 +
 drivers/clk/mediatek/clk-mt8189-scp.c | 76 +++++++++++++++++++++++++++++++++++
 3 files changed, 87 insertions(+)
drivers/clk/mediatek/Kconfig +10 -0
index 7b3bc27edbe3..17e0bfa695fe 100644
@@ -882,6 +882,16 @@ config COMMON_CLK_MT8189_IIC
 	  the MT8189 chipset, improving the overall performance and power
 	  efficiency of the device.
 
+config COMMON_CLK_MT8189_SCP
+	tristate "Clock driver for MediaTek MT8189 scp"
+	depends on COMMON_CLK_MT8189
+	default COMMON_CLK_MT8189
+	help
+	  Enable this to support the clock framework for the System Control
+	  Processor (SCP) in the MediaTek MT8189 SoC. This includes clock
+	  management for SCP-related features, ensuring proper clock
+	  distribution and gating for power efficiency and functionality.
+
 config COMMON_CLK_MT8192
 	tristate "Clock driver for MediaTek MT8192"
 	depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index 5e35185d23b0..e712815f7572 100644
@@ -130,6 +130,7 @@ obj-$(CONFIG_COMMON_CLK_MT8189_BUS) += clk-mt8189-bus.o
 obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o
 obj-$(CONFIG_COMMON_CLK_MT8189_DVFSRC) += clk-mt8189-dvfsrc.o
 obj-$(CONFIG_COMMON_CLK_MT8189_IIC) += clk-mt8189-iic.o
+obj-$(CONFIG_COMMON_CLK_MT8189_SCP) += clk-mt8189-scp.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-scp.c new file +76 -0

76 lines not on this page · raw message

Signature · 1 line
2.55.0
#34 lore raw

Re: [PATCH v6 26/27] clk: mediatek: Add MT8189 scp clock support

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] Incorrect register offsets defined in `scp_cg_regs` for SCP SPI clocks break clock operations and…

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incorrect register offsets defined in scp_cg_regs for SCP SPI clocks break clock operations and status reporting. --

commit 761866944873dbacd9da82a6105c5dd33a62520c
Author: Louis-Alexis Eyraud <[email protected]>

clk: mediatek: Add MT8189 scp clock support

Add support for the MT8189 scp clock controller, which provides clock gate control for System Control Processor.

Quoted 6 lines
drivers/clk/mediatek/clk-mt8189-scp.c new file +0 -0
new file mode 100644
index 0000000000000..75f087d819c08
@@ -0,0 +1,76 @@

[ ... ]

drivers/clk/mediatek/clk-mt8189-scp.c line 32

Quoted 13 lines
drivers/clk/mediatek/clk-mt8189-scp.c new file +13 -0
+static const struct mtk_gate_regs scp_cg_regs = {
+	.set_ofs = 0x4,
+	.clr_ofs = 0x8,
+	.sta_ofs = 0x4,
+};
+
+#define GATE_SCP(_id, _name, _parent, _shift)		\
+	GATE_MTK(_id, _name, _parent, &scp_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)
+
+static const struct mtk_gate scp_clks[] = {
+	GATE_SCP(CLK_SCP_SET_SPI0, "scp_set_spi0", "clk26m", 0),
+	GATE_SCP(CLK_SCP_SET_SPI1, "scp_set_spi1", "clk26m", 1),
+};

[Severity: High]
Does the scp_cg_regs struct assign the correct register offsets for the SCP SPI clocks?

It appears that sta_ofs is set identically to set_ofs at 0x4, which is typically a write-only W1S register in MediaTek SET/CLR clock gates. If the status offset points to a write-only register, will the common clock framework read invalid data when checking the status of scp_set_spi0 and scp_set_spi1 during late init?

This could break state tracking, preventing clk_disable_unused() from correctly powering off these clocks.

Additionally, the set_ofs and clr_ofs are defined as 0x4 and 0x8 here, but are inverted compared to scp_iic_cg_regs below.

drivers/clk/mediatek/clk-mt8189-scp.c line 46

Quoted 8 lines
drivers/clk/mediatek/clk-mt8189-scp.c new file +8 -0
+static const struct mtk_gate_regs scp_iic_cg_regs = {
+	.set_ofs = 0x8,
+	.clr_ofs = 0x4,
+	.sta_ofs = 0x0,
+};
+
+#define GATE_SCP_IIC(_id, _name, _parent, _shift)	\
+	GATE_MTK(_id, _name, _parent, &scp_iic_cg_regs, _shift, &mtk_clk_gate_ops_setclr_inv)

[Severity: High]
Since GATE_SCP and GATE_SCP_IIC both use mtk_clk_gate_ops_setclr_inv, doesn't this mean that enabling an SPI clock writes to 0x4, while enabling an IIC clock writes to 0x8?

Could this swap in offsets cause the SPI clocks to remain disabled when requested by consumer drivers, breaking clock operations deterministically when clk_prepare_enable() or clk_disable_unprepare() are called on scp_set_spi0 or scp_set_spi1?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-mt8189-clocks-system-base-v6-0-5df247f56938@collabora.com?part=26
#35 lore raw

PATCH v6 27/27 clk: mediatek: Add MT8189 ufs clock support

In reply to Louis-Alexis Eyraud

Add support for the MT8189 ufs clock controller, which provides clock gate control for Universal Flash Storage.

---
 drivers/clk/mediatek/Kconfig          |  12 ++++
 drivers/clk/mediatek/Makefile         |   1 +
 drivers/clk/mediatek/clk-mt8189-ufs.c | 132 ++++++++++++++++++++++++++++++++++
 3 files changed, 145 insertions(+)
drivers/clk/mediatek/Kconfig +12 -0
index 17e0bfa695fe..d26c07afd085 100644
@@ -892,6 +892,18 @@ config COMMON_CLK_MT8189_SCP
 	  management for SCP-related features, ensuring proper clock
 	  distribution and gating for power efficiency and functionality.
 
+config COMMON_CLK_MT8189_UFS
+	tristate "Clock driver for MediaTek MT8189 ufs"
+	depends on COMMON_CLK_MT8189
+	default COMMON_CLK_MT8189
+	help
+	  Enable this to support the clock management for the Universal Flash
+	  Storage (UFS) interface on MediaTek MT8189 SoCs. This includes
+	  clock sources, dividers, and gates that are specific to the UFS
+	  feature of the MT8189 platform. It is recommended to enable this
+	  option if the system includes a UFS device that relies on the MT8189
+	  SoC for clock management.
+
 config COMMON_CLK_MT8192
 	tristate "Clock driver for MediaTek MT8192"
 	depends on ARM64 || COMPILE_TEST
drivers/clk/mediatek/Makefile +1 -0
index e712815f7572..a0bba466bb93 100644
@@ -131,6 +131,7 @@ obj-$(CONFIG_COMMON_CLK_MT8189_DBGAO) += clk-mt8189-dbgao.o
 obj-$(CONFIG_COMMON_CLK_MT8189_DVFSRC) += clk-mt8189-dvfsrc.o
 obj-$(CONFIG_COMMON_CLK_MT8189_IIC) += clk-mt8189-iic.o
 obj-$(CONFIG_COMMON_CLK_MT8189_SCP) += clk-mt8189-scp.o
+obj-$(CONFIG_COMMON_CLK_MT8189_UFS) += clk-mt8189-ufs.o
 obj-$(CONFIG_COMMON_CLK_MT8192) += clk-mt8192-apmixedsys.o 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-mt8189-ufs.c new file +132 -0

132 lines not on this page · raw message

Signature · 1 line
2.55.0
#36 lore raw

Re: [PATCH v6 27/27] clk: mediatek: Add MT8189 ufs clock support

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Preexisting Use-After-Free risk when reset controller registration fails in __mtk_clk_simple_probe. --

commit b8b3345488c1f0eb6db7c64bd2d428ce6c86087f
Author: Louis-Alexis Eyraud <[email protected]>

clk: mediatek: Add MT8189 ufs clock support

Add support for the MT8189 ufs clock controller, which provides clock gate control for Universal Flash Storage.

Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-ufs.c new file +0 -0
new file mode 100644
index 0000000000000..ec98fe01a5989

[ ... ]

Quoted 5 lines
drivers/clk/mediatek/clk-mt8189-ufs.c new file +5 -0
+static const struct mtk_clk_desc ufscfg_ao_reg_mcd = {
+	.clks = ufscfg_ao_reg_clks,
+	.num_clks = ARRAY_SIZE(ufscfg_ao_reg_clks),
+	.rst_desc = &ufscfg_ao_rst_desc,
+};

[ ... ]

drivers/clk/mediatek/clk-mt8189-ufs.c line 122

Quoted 2 lines
drivers/clk/mediatek/clk-mt8189-ufs.c new file +2 -0
+static struct platform_driver clk_mt8189_ufs_drv = {
+	.probe = mtk_clk_simple_probe,

[Severity: High]
This isn't a bug introduced by this patch, but does the inclusion of rst_desc expose a use-after-free risk in the Mediatek clock framework?

Looking at __mtk_clk_simple_probe() in drivers/clk/mediatek/clk-mtk.c, the framework registers the OF clock provider before the reset controller:

	r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
	if (r)
		goto unregister_clks;

	if (mcd->rst_desc) {
		r = mtk_register_reset_controller_with_dev(&pdev->dev,
							   mcd->rst_desc);
		if (r)
			goto unregister_clks;
	}

If mtk_register_reset_controller_with_dev() fails, the error path jumps to unregister_clks and frees clk_data via mtk_free_clk_data().

Since it doesn't call of_clk_del_provider(node) during this teardown, does this leave a dangling pointer in the OF clock framework? Any subsequent OF clock lookup for this device would likely dereference the freed clk_data.

Quoted 6 lines
drivers/clk/mediatek/clk-mt8189-ufs.c new file +6 -0
+	.remove = mtk_clk_simple_remove,
+	.driver = {
+		.name = "clk-mt8189-ufs",
+		.of_match_table = of_match_clk_mt8189_ufs,
+	},
+};
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-mt8189-clocks-system-base-v6-0-5df247f56938@collabora.com?part=27
maintainer Reviewed-by on the v6 series
#37 lore raw
In reply to Louis-Alexis Eyraud
Quoted 4 lines · Louis-Alexis Eyraud

This series is a continuation by AngeloGioacchino Del Regno and I of a previous series ([1]), that adds the clock controller support for the Mediatek MT8189 SoC and its variants (MT8371, MT8391).

Everything is

Quoted 208 lines

The first major changes is the split of the series in two:
- one for all basic clock controllers including system ones (this series)
- one for the multimedia and graphics related clock controllers (to be send in the future)

We chose to separate the multimedia clock drivers from the base system ones, as there is currently an unsolvable inter-dependency between the power domains and multimedia clocks; the power domains need a dual-stage bring-up, where only a part of the multimedia clocks are accessible in the first power domain powerup stage, and the rest when the second stage (SRAM enablement) is done.
The current workarounds for this issue, such as removing the is_enabled operation from the impacted clock controllers clk_ops table or let the multimedia power domain always on, were quickly discarded for upstream.

The second major change is the dt-bindings patch ([2]) that got heavily reworked, not only because of the split choice. We took the opportunity to regroup in the MT8186 clock and system clock dt-bindings the description of several other Mediatek SoC (MT8188, MT8192 and MT8195) and add in them the MT8189 new ones.
The rationale is to ease maintainability and have common files for several currently supported SoC or new future ones, that have the same kind of clock controller design.

Finally the pending remarks from peer reviews on the v6 revision of [1] were also taken into account and new fixes and cleanups were also added.

A more detailed changelog between [1] and this series:
- Removed multimedia and graphics related clock controllers code and definitions from series
- Added new dt-bindings patches to factorise existing MT8188, MT8192 and MT8195 in MT8186 clock dt-bindings
- Heavily modified the MT8189 dt-bindings to add new compatibles in MT8186 clock dt-bindings
- Created a new dt-bindings include for the MT8189 reset controller definitions (include/dt-bindings/reset/mediatek,mt8189-resets.h)
- Removed unnecessary syscon compatible fallback from MT8189 base clock controllers
- Added missing 'mediatek,mt8189-fhctl' compatible declaration in dt-bindings
- Modified Kconfig to COMMON_CLK_MT8189 be tristate (and not bool) to allow all MT8189 clock controller drivers to be built as modules (it was partial)
- Fix pll unregisters in clk_mt8189_apmixed_probe error case
- Reparent several clocks to correct 26M references in clk-mt8189-bus.c, clk-mt8189-topckgen.c and clk-mt8189-vlpckgen.c
- Removed CLK_SET_RATE_NO_REPARENT flag from mfg_sel_mfgpll
- Rename TOPCKGEN_fmipi_csi_up26m clock to fmipi_csi_up26m to remove caps usage
- Implemented reset controllers in clk-mt8189-ufs.c
- Updated all file headers to update copyrights and add all authors
- Added all co-developed-by trailers

The series is based on linux-next tree (tag: next-20260903) and has been tested on Mediatek Genio 520-EVK (MT8371) and 720-EVK (MT8391) boards, with hardware enablement patch series ([3]), and on Genio 510-EVK (MT8370, variant of MT8188) and Genio 1200-EVK (MT8395, variant of MT8195).

[1]: https://lore.kernel.org/linux-mediatek/[email protected]/
[2]: https://lore.kernel.org/linux-mediatek/[email protected]/
[3]: https://lore.kernel.org/linux-mediatek/20260701-add-mediatek-genio-520-720-evk-v2-0-19d5da4ef984@collabora.com/

---
Changes in v6:
- Rebased on next-20260903 tag
- Added contains keyword use in patch 5, as recommended by R. Herring
- Fixed typo and comment in patch 13 (B. Masney)
- Added patches 16 and 17 to do some code improvements suggested in
B. Masney review
- Removed unnecessary header inclusions and reorder remaining ones in
patch 18 to 27 (B. Masney)
- Added received Reviewed-By trailers
- Removed netdev mailing list from Cc
- Link to v5: https://lore.kernel.org/r/20260801-mt8189-clocks-system-base-v5-0-ac4410697cc2@collabora.com

Changes in v5:
- Rebased on next-20260730 tag
- Dropped "clk: mediatek: pll: split default prepare/unprepare callbacks"
patch and added "clk: mediatek: pll: Factorise pll power on/off sequence"
and "clk: mediatek: pll: Add PLL stabilization delay definition"
patches in replacement.
- patch 13:
- reworded commit message to show this new clocks ops use specific pll
enablement rather powering
- reworked mtk_pll_prepare_setclr and mtk_pll_unprepare_setclr
sequence to handle properly specific enable/disable sequence
using en_set/clr register (Sashiko)
- fixed timeout management in mtk_pll_prepare_setclr and
mtk_pll_unprepare_setclr (Sashiko)
- Link to v4: https://lore.kernel.org/r/20260729-mt8189-clocks-system-base-v4-0-e356b813a64c@collabora.com

Changes in v4:
- Rebased on next-20260728 tag
- Added patches 9 to 14 to add new clock ops data set for PLL and
PLL-FHCTL to handle a new PLL switch logic for PLL control and BAR
reset, supported by MT8189 SoC
- Patch 15:
- Removed useless includes (B. Masney)
- Fixed variable declaration order in clk_mt8189_apmixed_probe (B.
Masney)
- Added missing pwr_reg setting setting in PLL_SETCLR macro (B.
Masney, Sashiko)
- Added en_set_reg, en_clr_reg, rst_bar_reg, rst_bar_set_reg and
rst_bar_clr_reg fixed offsets and new mtk_pll_setclr_ops ops
setting in PLL_SETCLR macro
- Added pwr_reg offset values in apmixed_plls array
- Fixed rst_bar_mask for mainpll univpll, and mmpll in apmixed_plls
array to match rst_bar set/clr reg settings
- Fixed factor ratio for mainpll_d4_d8, tvdpll1_d16, tvdpll2_d16 and
osc_d16 clocks (Sashiko)
- Link to v3: https://lore.kernel.org/r/20260720-mt8189-clocks-system-base-v3-0-8e6d99ab3ad2@collabora.com

Changes in v3:
- Rebased on next-20260717 tag
- Added Fixes tags to patches 1, 2 and 3
- Reworded patch 8 subject and description messages
- Updated Reviewed-by and Acked-by trailers
- Link to v2: https://lore.kernel.org/r/20260709-mt8189-clocks-system-base-v2-0-2926da3db6cf@collabora.com

Changes in v2:
- Rebased on next-20260708 tag
- Added patch 1,2 and 3 to make the #clock-cells a required property in
MT8186, MT8192 and MT8195 clock controller dt-bindings
- Patch 5:
- Removed conditional blocks to check clock-cells property presence
for MT8188 clock controller compatible
- Reworded commit message to remove the note (no more applicable)
- Fixed incorrect property value in else block for #reset-cells
property check.
_ Removed from patch 9 conditional blocks to check clock-cells property
presence for MT8189 clock controller compatible
- Fixed missing MODULE_DEVICE_TABLE in patches 10, 11 and 12.
- Added devicetree series link in cover letter
- Link to v1: https://lore.kernel.org/r/20260701-mt8189-clocks-system-base-v1-0-2b048feea50a@collabora.com

---
Louis-Alexis Eyraud (27):
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192
dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195
dt-bindings: clock: mediatek: reorder MT8186 compatibles
dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186
dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186
dt-bindings: clock: mediatek: regroup MT8195 dt-bindings into MT8186
dt-bindings: clock: mediatek: Add MT8189 system/base clocks and resets
clk: mediatek: Harmonize mtk_pll_fenc related symbol names
clk: mediatek: pll: Add BAR reset register offsets
clk: mediatek: pll: Factorise pll power on/off sequences
clk: mediatek: pll: Add PLL stabilization delay definition
clk: mediatek: pll: Add ops for PLLs using set/clr regs
clk: mediatek: pllfh: Add configurable clock ops to mtk_pllfh_data
clk: mediatek: pllfh: Add ops for PLLs using set/clr regs
clk: mediatek: Move fhctl_parse_dt call into mtk_clk_register_pllfhs
clk: mediatek: pllfh: clear state data in mtk_clk_cleanup_pllfhs
clk: mediatek: Add MT8189 apmixedsys clock support
clk: mediatek: Add MT8189 topckgen clock support
clk: mediatek: Add MT8189 vlpckgen clock support
clk: mediatek: Add MT8189 vlpcfg clock support
clk: mediatek: Add MT8189 bus clock support
clk: mediatek: Add MT8189 dbgao clock support
clk: mediatek: Add MT8189 dvfsrc clock support
clk: mediatek: Add MT8189 i2c clock support
clk: mediatek: Add MT8189 scp clock support
clk: mediatek: Add MT8189 ufs clock support

  .../bindings/clock/mediatek,mt8186-clock.yaml      |  129 ++-
  .../bindings/clock/mediatek,mt8186-fhctl.yaml      |    1 +
  .../bindings/clock/mediatek,mt8186-sys-clock.yaml  |   24 +-
  .../bindings/clock/mediatek,mt8188-clock.yaml      |   93 --
  .../bindings/clock/mediatek,mt8188-sys-clock.yaml  |   58 --
  .../bindings/clock/mediatek,mt8192-clock.yaml      |  191 ----
  .../bindings/clock/mediatek,mt8192-sys-clock.yaml  |   68 --
  .../bindings/clock/mediatek,mt8195-clock.yaml      |  238 -----
  .../bindings/clock/mediatek,mt8195-sys-clock.yaml  |   76 --
  drivers/clk/mediatek/Kconfig                       |   79 ++
  drivers/clk/mediatek/Makefile                      |    8 +
  drivers/clk/mediatek/clk-mt6795-apmixedsys.c       |    3 +-
  drivers/clk/mediatek/clk-mt8173-apmixedsys.c       |    5 +-
  drivers/clk/mediatek/clk-mt8186-apmixedsys.c       |    4 +-
  drivers/clk/mediatek/clk-mt8189-apmixedsys.c       |  202 ++++
  drivers/clk/mediatek/clk-mt8189-bus.c              |  199 ++++
  drivers/clk/mediatek/clk-mt8189-dbgao.c            |   97 ++
  drivers/clk/mediatek/clk-mt8189-dvfsrc.c           |   57 ++
  drivers/clk/mediatek/clk-mt8189-iic.c              |  121 +++
  drivers/clk/mediatek/clk-mt8189-scp.c              |   76 ++
  drivers/clk/mediatek/clk-mt8189-topckgen.c         | 1019 ++++++++++++++++++++
  drivers/clk/mediatek/clk-mt8189-ufs.c              |  132 +++
  drivers/clk/mediatek/clk-mt8189-vlpcfg.c           |  115 +++
  drivers/clk/mediatek/clk-mt8189-vlpckgen.c         |  279 ++++++
  drivers/clk/mediatek/clk-mt8192-apmixedsys.c       |    4 +-
  drivers/clk/mediatek/clk-mt8195-apmixedsys.c       |    4 +-
  drivers/clk/mediatek/clk-mt8196-apmixedsys.c       |    2 +-
  drivers/clk/mediatek/clk-mt8196-vlpckgen.c         |    2 +-
  drivers/clk/mediatek/clk-pll.c                     |  131 ++-
  drivers/clk/mediatek/clk-pll.h                     |   13 +-
  drivers/clk/mediatek/clk-pllfh.c                   |   33 +-
  drivers/clk/mediatek/clk-pllfh.h                   |    8 +-
  include/dt-bindings/clock/mediatek,mt8189-clk.h    |  433 +++++++++
  include/dt-bindings/reset/mediatek,mt8189-resets.h |   17 +
  34 files changed, 3139 insertions(+), 782 deletions(-)

---
base-commit: 0abd4c5dd02744f837ade691fb214ca7cb970e4b
change-id: 20260630-mt8189-clocks-system-base-70714e4ff2aa

Best regards,

maintainer Applied
#38 lore raw
In reply to Louis-Alexis Eyraud
Quoted 11 lines · Louis-Alexis Eyraud

This series is a continuation by AngeloGioacchino Del Regno and I of a previous series ([1]), that adds the clock controller support for the Mediatek MT8189 SoC and its variants (MT8371, MT8391).

The first major changes is the split of the series in two:
- one for all basic clock controllers including system ones (this series)
- one for the multimedia and graphics related clock controllers (to be send in the future)

[...]

Applied to v7.4-next/clk, thanks!

[01/27] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8186

        commit: 51928be3081a25842d66501b085dd6ee00d2fe0d
[02/27] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8192
        commit: 1a2b86804febe4870956297188e8ccfa079f4d22
[03/27] dt-bindings: clock: mediatek: Make '#clock-cells' required for MT8195
        commit: cb47a7976bb5e5e4a7df1df71d221b932af7b2b8
[04/27] dt-bindings: clock: mediatek: reorder MT8186 compatibles
        commit: 3b372542144aa2e6cb6925e6d8039abfbd9682a7
[05/27] dt-bindings: clock: mediatek: regroup MT8188 dt-bindings into MT8186
        commit: 09b156611b0a8fc480dc894f04a475c0c4313a98
[06/27] dt-bindings: clock: mediatek: regroup MT8192 dt-bindings into MT8186
        commit: 833dc5fe7832ff0d8e8935cafd09d530055d8126
[07/27] dt-bindings: clock: mediatek: regroup MT8195 dt-bindings into MT8186
        commit: dc3a6ae2eeab954820701713dc7d4b1556df7dc4
[08/27] dt-bindings: clock: mediatek: Add MT8189 system/base clocks and resets
        commit: 294637d60bc0dff970b51f32cf0a5d46bede0652
[09/27] clk: mediatek: Harmonize mtk_pll_fenc related symbol names
        commit: e998b6e82a481b204c097a6f24bf4d0523041ab1
[10/27] clk: mediatek: pll: Add BAR reset register offsets
        commit: 696eb5f8af066bd43dc2cea7c1557c39a9346f44
[11/27] clk: mediatek: pll: Factorise pll power on/off sequences
        commit: efa27fb6334209382fba265d1a0874fd35a5f7d6
[12/27] clk: mediatek: pll: Add PLL stabilization delay definition
        commit: b7285135ac89017d442941145f020eaa4664afef
[13/27] clk: mediatek: pll: Add ops for PLLs using set/clr regs
        commit: 7cbf375f78def36afc6a737c987e900c0b59a0ed
[14/27] clk: mediatek: pllfh: Add configurable clock ops to mtk_pllfh_data
        commit: 4587b6170ea5f091a456ac7613a26df798722b09
[15/27] clk: mediatek: pllfh: Add ops for PLLs using set/clr regs
        commit: 2def5260f4be10f60510a6a133368d52f2eb9ba8
[16/27] clk: mediatek: Move fhctl_parse_dt call into mtk_clk_register_pllfhs
        commit: a3ef44f33667dcef6a4487ed74fbafe2dd65cf37
[17/27] clk: mediatek: pllfh: clear state data in mtk_clk_cleanup_pllfhs
        commit: 6fe7aa32b1063c2c7c61261cdd5f378facae2e89
[18/27] clk: mediatek: Add MT8189 apmixedsys clock support
        commit: 874ab1eba81e795b8ae8bf26a5410cf80f3eab83
[19/27] clk: mediatek: Add MT8189 topckgen clock support
        commit: ad50e6912ab54da07142cb805283803f94f03be0
[20/27] clk: mediatek: Add MT8189 vlpckgen clock support
        commit: 9f5133b5d9f4fd18ec7d623b45614549f3dbae41
[21/27] clk: mediatek: Add MT8189 vlpcfg clock support
        commit: 67ef8994e541421b38d848cf3da88b75f241a7d6
[22/27] clk: mediatek: Add MT8189 bus clock support
        commit: ef1c46bbb81c4bcee613f9ca4ee8e4fcf4483e04
[23/27] clk: mediatek: Add MT8189 dbgao clock support
        commit: 4d2ff5667bf25203d8e898ff7931e7aaa1653ee5
[24/27] clk: mediatek: Add MT8189 dvfsrc clock support
        commit: 8051bf8c06a1b8224345637fe8656dc2abf97e94
[25/27] clk: mediatek: Add MT8189 i2c clock support
        commit: ab4fef2b58b3db345b9aadf6c806ae32ba15d2cf
[26/27] clk: mediatek: Add MT8189 scp clock support
        commit: e87051328cf23217e04236ceb6ee2ae72f6ddc45
[27/27] clk: mediatek: Add MT8189 ufs clock support
        commit: 633757ec0147497a11309e0bd877396cac5e64e1

Cheers,
Angelo