Skip to contentSkip to conversation

Add MediaTek SoC(vdosys1) support for mt8195

PATCH Superseded Nancy.Lin 6 participants 30 messages Nov 7, 2022 – Dec 27, 2022

Subsystems (3)

v28 of 30 Superseded Latest is v30 →

lore
Share & tools
lore

Nancy.Lin

author
#0 lore raw

v28 cover Add MediaTek SoC(vdosys1) support for mt8195

The hardware path of vdosys1 with DPTx output need to go through by several modules, such as, OVL_ADAPTOR and MERGE.

Add mmsys and mutex modules support by the patches below:

Changes in v28:
- rebase to next-20221107
- fix reviewer comment in v27
- remove change id
- fix mmsys config api typo

Changes in v27:
- rebase to next-20221102
- change mmsys compatible for mt8195 vdosys1
- base on jason's series[ref 1]
- fix reviewer comment
- only register mmsys reset controller if num_resets > 0

Changes in v26:
- fix reviewer comment
- set mmsys num_resets to 32 for 8192
- rebase to next-20220819

Changes in v25:
- fix reviewer comment
- refine mtk_mmsys_reset_update func
- rebase to next-20220708

Changes in v24:
- fix reviewer comment
- refine mtk_mmsys_reset_update func
- rebase to next-20220622

Changes in v23:
- separate[7] mmsys/mutex and drm patches into two series

Changes in v22:
- rebase to next-20220525
- rebase to vdosys0 series v22
- separate dts to a new patch

Changes in v21:
- fix reviewer comment
- fix rdma and ethdr binding doc and dts

Changes in v20:
- fix reviewer comment
- update mmsys update bit api name
- add mtk_mmsys_update_bits error message if lose gce property
- list all mt8195 vdosys1 reset bits

Changes in v19:
- fix reviewer comment
- separate mt8195 mmsys component to a new patch
- separate mt8195 vdo0 and vdo1 routing table
- separate mmsys_write_reg api to a new patch and simplify write reg code
- separate mmsys 64 bit reset to a new patch
- separate mtk-mutex dp_intf1 component to a new patch

Changes in v18:
- fix reviewer comment
- fix rdma binding doc
- fix ethdr binding doc
- refine mmsys config cmdq support
- refine merge reset control flow, get reset control in probe function
- add ethdr reset control error handling and remove dbg log
- rebase to vdosys0 series v20 (ref [5])

Changes in v17:
- fix reviewer comment in v16
- separate ovl adaptor comp in mtk-mmsys and mtk-mutex
- separate mmsys config API
- move mdp_rdma binding yaml
- fix ovl adaptor pm runtime get sync timing issue
- rebase to vdosys0 series v19 (ref [5])
- rebase to [7] for modify vblank register change

Changes in v16:
- fix reviewer comment in v 15
- fix mtk_drm_ddp_comp.c alignment
- fix vdosys0 mmsys num before adding vdosys1 patch

Changes in v15:
- fix ethdr uppercase hex number in dts

Changes in v14:
- remove MTK_MMSYS 64 bit dependency
- add ethdr.yaml back and fix dt_schema check fail

Resend v13
- add related maintainer in maillist

Changes in v13:
- fix reviewer comment in v12
- fix rdma dt-binding format
- fix dts node naming
- fix 32 bit build error
- modify 64bit dependency for mtk-mmsys
- rebase to vdosys0 series v16. (ref [5])

Changes in v12:
- fix reviewer comment in v11
- modify mbox index
- refine dma dev for ovl_adaptor sub driver

Changes in v11:
- remove ethdr vblank spin lock
- refine ovl_adaptor print message

Changes in v10:
- refine ethdr reset control using devm_reset_control_array_get_optional_exclusive
- fix ovl_adaptor mtk_ovl_adaptor_clk_enable error handle issue

Changes in v9:
- rebase on kernel-5.16-rc1
- rebase on vdosys0 series v13. (ref [5])
- fix ovl_adaptor sub driver is brought up unintentionally
- fix clang build test fail- duplicate ethdr/mdp_rdma init_module/cleanup_module symbol issue

Changes in v8:
- separate merge async reset to new patch.
- separate drm ovl_adaptor sub driver to new patch.
- fix reviewer comment in v7.

Changes in v7:
- rebase on vdosys0 series v12 (ref[5])
- add dma description in ethdr binding document.
- refine vdosys1 bit definition of mmsys routing table.
- separate merge modification into 3 pathces.
- separate mutex modification into 2 patches.
- add plane color coding for mdp_rdma csc.
- move mdp_rdma pm control to ovl_adaptor.
- fix reviewer comment in v6.

Changes in v6:
- rebase on kernel-5.15-rc1.
- change mbox label to gce0 for dts node of vdosys1.
- modify mmsys reset num for mt8195.
- rebase on vdosys0 series v10. (ref [5])
- use drm to bring up ovl_adaptor driver.
- move drm iommu/mutex check from kms init to drm bind.
- modify rdma binding doc location. (Documentation/devicetree/bindings/arm/)
- modify for reviewer's comment in v5.

Changes in v5:
- add mmsys reset controller reference.

Changes in v4:
- use merge common driver for merge1~4.
- refine ovl_adaptor rdma driver.
- use ovl_adaptor ddp_comp function instead of ethdr.
- modify for reviewer's comment in v3.

Changes in v3:
- modify for reviewer's comment in v2.
- add vdosys1 2 pixels align limit.
- add mixer odd offset support.

Changes in v2:
- Merge PSEUDO_OVL and ETHDR into one DRM component.
- Add mmsys config API for vdosys1 hardware setting.
- Add mmsys reset control using linux reset framework.

This series are based on the following patch:
[1] Change mmsys compatible for mt8195 mediatek-drm

    [email protected]

Nancy.Lin (11):
dt-bindings: arm: mediatek: mmsys: add vdosys1 compatible for MT8195
dt-bindings: reset: mt8195: add vdosys1 reset control bit
soc: mediatek: add mtk-mmsys ethdr and mdp_rdma components
soc: mediatek: add mtk-mmsys support for mt8195 vdosys1
soc: mediatek: refine code to use mtk_mmsys_update_bits API
soc: mediatek: add mtk-mmsys config API for mt8195 vdosys1
soc: mediatek: add cmdq support of mtk-mmsys config API for mt8195
vdosys1
soc: mediatek: mmsys: add mmsys for support 64 reset bits
soc: mediatek: mmsys: add reset control for MT8195 vdosys1
soc: mediatek: add mtk-mutex component - dp_intf1
soc: mediatek: add mtk-mutex support for mt8195 vdosys1

 .../bindings/arm/mediatek/mediatek,mmsys.yaml |   4 +-
 drivers/soc/mediatek/mt8195-mmsys.h           | 146 ++++++++++++++++++
 drivers/soc/mediatek/mtk-mmsys.c              | 145 ++++++++++++-----
 drivers/soc/mediatek/mtk-mmsys.h              |   1 +
 drivers/soc/mediatek/mtk-mutex.c              |  37 +++++
 include/dt-bindings/reset/mt8195-resets.h     |  45 ++++++
 include/linux/soc/mediatek/mtk-mmsys.h        |  25 +++
 7 files changed, 366 insertions(+), 37 deletions(-)
Signature · 1 line
2.18.0
author
#1 lore raw

PATCH v28 1/11 dt-bindings: arm: mediatek: mmsys: add vdosys1 compatible for MT8195

Add vdosys1 mmsys compatible for MT8195 platform.

For MT8195, VDOSYS0 and VDOSYS1 are 2 display HW pipelines binding to 2 different power domains, different clock drivers and different mediatek-drm drivers.

---
 .../devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml      | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +3 -1
index 0711f1834fbd..aaabe2196185 100644
@@ -48,7 +48,9 @@ properties:
           - const: syscon
 
       - items:
-          - const: mediatek,mt8195-vdosys0
+          - enum:
+              - mediatek,mt8195-vdosys0
+              - mediatek,mt8195-vdosys1
           - const: mediatek,mt8195-mmsys
           - const: syscon
 
Signature · 1 line
2.18.0
maintainer
#2 lore raw

Re: [PATCH v28 01/11] dt-bindings: arm: mediatek: mmsys: add vdosys1 compatible for MT8195

Quoted 17 lines · Nancy.Lin

Add vdosys1 mmsys compatible for MT8195 platform.

For MT8195, VDOSYS0 and VDOSYS1 are 2 display HW pipelines binding to 2 different power domains, different clock drivers and different mediatek-drm drivers.

---
  .../devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml      | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +0 -0
index 0711f1834fbd..aaabe2196185 100644

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml properties: · line 56

Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +3 -1
@@ -48,7 +48,9 @@ properties:
            - const: syscon
 
        - items:
-          - const: mediatek,mt8195-vdosys0
+          - enum:
+              - mediatek,mt8195-vdosys0
+              - mediatek,mt8195-vdosys1
            - const: mediatek,mt8195-mmsys
            - const: syscon
 

I think we had that several times already:
https://lore.kernel.org/all/[email protected]/

We will something like this, but please check that this does not give any errors/warnings:

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +10 -1
index eb451bec23d3d..8e9c4f4d7c389 100644
@@ -32,13 +32,22 @@ properties:
               - mediatek,mt8183-mmsys
               - mediatek,mt8186-mmsys
               - mediatek,mt8192-mmsys
-              - mediatek,mt8195-mmsys
               - mediatek,mt8365-mmsys
           - const: syscon
       - items:
           - const: mediatek,mt7623-mmsys
           - const: mediatek,mt2701-mmsys
           - const: syscon
+      - items:
+          - const: mediatek,mt8195-vdosys0
+          - const: syscon
+      - items:
+          - const: mediatek,mt8195-vdosys1
+          - const: syscon
+      - items:
+          - const: mediatek,mt8195-mmsys
+          - const: syscon
+      deprecated: true
 
   reg:
     maxItems: 1
#3 lore raw

Re: [PATCH v28 01/11] dt-bindings: arm: mediatek: mmsys: add vdosys1 compatible for MT8195

Quoted 31 lines · Matthias Brugger
Quoted 29 lines · Nancy.Lin

Add vdosys1 mmsys compatible for MT8195 platform.

For MT8195, VDOSYS0 and VDOSYS1 are 2 display HW pipelines binding to
2 different power domains, different clock drivers and different mediatek-drm drivers.

---
  .../devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml      | 4
+++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yam l b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yam l
index 0711f1834fbd..aaabe2196185 100644
---
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yam l
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yam l

(quoted diff) +0 -0
@@ -48,7 +48,9 @@ properties:
            - const: syscon
 
Quoted 11 lines

Review properties: · line 56

Quoted 8 lines
(quoted diff) +3 -1
        - items:
-          - const: mediatek,mt8195-vdosys0
+          - enum:
+              - mediatek,mt8195-vdosys0
+              - mediatek,mt8195-vdosys1
            - const: mediatek,mt8195-mmsys
            - const: syscon
 

I think we had that several times already:

https://lore.kernel.org/all/[email protected]/

Quoted 27 lines

We will something like this, but please check that this does not give any
errors/warnings:

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml index eb451bec23d3d..8e9c4f4d7c389 100644
---
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +3 -1
@@ -32,13 +32,22 @@ properties:
                - mediatek,mt8183-mmsys
                - mediatek,mt8186-mmsys
                - mediatek,mt8192-mmsys
-              - mediatek,mt8195-mmsys
                - mediatek,mt8365-mmsys
            - const: syscon
        - items:
            - const: mediatek,mt7623-mmsys
            - const: mediatek,mt2701-mmsys
            - const: syscon
+      - items:
+          - const: mediatek,mt8195-vdosys0
+          - const: syscon

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml properties: · line 53

Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +7 -0
+      - items:
+          - const: mediatek,mt8195-vdosys1
+          - const: syscon
+      - items:
+          - const: mediatek,mt8195-mmsys
+          - const: syscon
+      deprecated: true
 
    reg:
      maxItems: 1

Hi Matthias,

As the vdosys0 previous reviewed patch:

https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
Should I modify the vdosys0 items format like your example?

Or should vdosys1 add items format like vdosys0's previous patch?
- items:
- const: mediatek,mt8195-vdosys1
- const: mediatek,mt8195-mmsys
- const: syscon

Regards,
Jason-JH.Lin

maintainer
#4 lore raw

Re: [PATCH v28 01/11] dt-bindings: arm: mediatek: mmsys: add vdosys1 compatible for MT8195

Quoted 84 lines · Jason-JH Lin (林睿祥)
Quoted 31 lines · Matthias Brugger
Quoted 29 lines · Nancy.Lin

Add vdosys1 mmsys compatible for MT8195 platform.

For MT8195, VDOSYS0 and VDOSYS1 are 2 display HW pipelines binding to
2 different power domains, different clock drivers and different mediatek-drm drivers.

---
  .../devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml      | 4
+++-
  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yam l b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yam l
index 0711f1834fbd..aaabe2196185 100644
---
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yam l
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yam l

(quoted diff) +0 -0
@@ -48,7 +48,9 @@ properties:
            - const: syscon
 
Quoted 11 lines

Review properties: · line 56

Quoted 8 lines
(quoted diff) +3 -1
        - items:
-          - const: mediatek,mt8195-vdosys0
+          - enum:
+              - mediatek,mt8195-vdosys0
+              - mediatek,mt8195-vdosys1
            - const: mediatek,mt8195-mmsys
            - const: syscon
 

I think we had that several times already:

https://lore.kernel.org/all/[email protected]/

Quoted 25 lines

We will something like this, but please check that this does not give any errors/warnings:

diff --git
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml index eb451bec23d3d..8e9c4f4d7c389 100644
---
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +3 -1
@@ -32,13 +32,22 @@ properties:
                - mediatek,mt8183-mmsys
                - mediatek,mt8186-mmsys
                - mediatek,mt8192-mmsys
-              - mediatek,mt8195-mmsys
                - mediatek,mt8365-mmsys
            - const: syscon
        - items:
            - const: mediatek,mt7623-mmsys
            - const: mediatek,mt2701-mmsys
            - const: syscon
+      - items:
+          - const: mediatek,mt8195-vdosys0
+          - const: syscon

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml properties: · line 53

Quoted 10 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +7 -0
+      - items:
+          - const: mediatek,mt8195-vdosys1
+          - const: syscon
+      - items:
+          - const: mediatek,mt8195-mmsys
+          - const: syscon
+      deprecated: true
 
    reg:
      maxItems: 1

Hi Matthias,

As the vdosys0 previous reviewed patch:

Quoted 9 lines

https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/
Should I modify the vdosys0 items format like your example?

Or should vdosys1 add items format like vdosys0's previous patch?
- items:
- const: mediatek,mt8195-vdosys1
- const: mediatek,mt8195-mmsys
- const: syscon

No, vdosys1 must not have mediatek,mt8195-mmsys fallback.

Regards,
Matthias

Quoted 19 lines

Regards,
Jason-JH.Lin

************* MEDIATEK Confidentiality Notice
********************
The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe

that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!

#5 lore raw

Re: [PATCH v28 01/11] dt-bindings: arm: mediatek: mmsys: add vdosys1 compatible for MT8195

Dear Matthias,

Thanks for the review.

Quoted 42 lines · Matthias Brugger
Quoted 40 lines · Jason-JH Lin (林睿祥)
Quoted 39 lines · Matthias Brugger
Quoted 37 lines · Nancy.Lin

Add vdosys1 mmsys compatible for MT8195 platform.

For MT8195, VDOSYS0 and VDOSYS1 are 2 display HW pipelines binding
to
2 different power domains, different clock drivers and different
mediatek-drm drivers.

---

.../devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml |
4
+++-

  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys .yam
l b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys .yam
l
index 0711f1834fbd..aaabe2196185 100644
---
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys .yam
l
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys .yam
l

(quoted diff) +0 -0
@@ -48,7 +48,9 @@ properties:
            - const: syscon
 
Quoted 13 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
(quoted diff) +3 -1
        - items:
-          - const: mediatek,mt8195-vdosys0
+          - enum:
+              - mediatek,mt8195-vdosys0
+              - mediatek,mt8195-vdosys1
            - const: mediatek,mt8195-mmsys
            - const: syscon
 
Quoted 4 lines
Quoted 2 lines

I think we had that several times already:

https://lore.kernel.org/all/[email protected]/

Quoted 40 lines
Quoted 40 lines
Quoted 40 lines

We will something like this, but please check that this does not give
any
errors/warnings:

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.y aml b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.y aml
index eb451bec23d3d..8e9c4f4d7c389 100644
---
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.y aml
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.y aml

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +10 -1
@@ -32,13 +32,22 @@ properties:
                - mediatek,mt8183-mmsys
                - mediatek,mt8186-mmsys
                - mediatek,mt8192-mmsys
-              - mediatek,mt8195-mmsys
                - mediatek,mt8365-mmsys
            - const: syscon
        - items:
            - const: mediatek,mt7623-mmsys
            - const: mediatek,mt2701-mmsys
            - const: syscon
+      - items:
+          - const: mediatek,mt8195-vdosys0
+          - const: syscon
+      - items:
+          - const: mediatek,mt8195-vdosys1
+          - const: syscon
+      - items:
+          - const: mediatek,mt8195-mmsys
+          - const: syscon
+      deprecated: true
 
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml properties: · line 53

Quoted 2 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +0 -0
    reg:
      maxItems: 1

Hi Matthias,

As the vdosys0 previous reviewed patch:

https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/__;!!CTRNKA9wMg0ARbw!zRdbIyyAsfqob2kapMAcKYATAguhEV0x0qE5cTOAcWUNhzeAbMHzZoos_2QzUCxS$

Quoted 10 lines
Quoted 9 lines

Should I modify the vdosys0 items format like your example?

Or should vdosys1 add items format like vdosys0's previous patch?
- items:
- const: mediatek,mt8195-vdosys1
- const: mediatek,mt8195-mmsys
- const: syscon

Quoted 5 lines

No, vdosys1 must not have mediatek,mt8195-mmsys fallback.

Regards,
Matthias

I will fix it and add the following vdosys1 binding base on [1].

- description: vdosys0 and vdosys1 are 2 display HW pipelines, so mt8195 binding should be deprecated.
deprecated: true
items:
- const: mediatek,mt8195-mmsys
- const: syscon
- items:
- const: mediatek,mt7623-mmsys
- const: mediatek,mt2701-mmsys
- const: syscon
- items:
- const: mediatek,mt8195-vdosys0
- const: mediatek,mt8195-mmsys
- const: syscon
+ - items:
+ - const: mediatek,mt8195-vdosys1
+ - const: syscon

[1]
https://kernel.googlesource.com/pub/scm/linux/kernel/git/matthias.bgg/linux/+/b237efd47df7d25b78c306e90b97c5aa0ff4c4fc/Documentation/devicetree/bindings/arm/mediatek/mediatek%2Cmmsys.yaml

Regards,
Nancy

Quoted 29 lines
Quoted 27 lines

Regards,
Jason-JH.Lin

************* MEDIATEK Confidentiality Notice
********************
The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination,
distribution, printing, retaining or copying of this e-mail (including its
attachments) by unintended recipient(s) is strictly prohibited and may
be unlawful. If you are not an intended recipient of this e-mail, or believe

that you have received this e-mail in error, please notify the sender
immediately (by replying to this e-mail), delete any and all copies of
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!

maintainer
#6 lore raw

Re: [PATCH v28 01/11] dt-bindings: arm: mediatek: mmsys: add vdosys1 compatible for MT8195

Quoted 135 lines · Nancy Lin (林欣螢)

Dear Matthias,

Thanks for the review.

Quoted 42 lines · Matthias Brugger
Quoted 40 lines · Jason-JH Lin (林睿祥)
Quoted 39 lines · Matthias Brugger
Quoted 37 lines · Nancy.Lin

Add vdosys1 mmsys compatible for MT8195 platform.

For MT8195, VDOSYS0 and VDOSYS1 are 2 display HW pipelines binding
to
2 different power domains, different clock drivers and different
mediatek-drm drivers.

---

.../devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml |
4
+++-

  1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys .yam
l b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys .yam
l
index 0711f1834fbd..aaabe2196185 100644
---
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys .yam
l
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys .yam
l

(quoted diff) +0 -0
@@ -48,7 +48,9 @@ properties:
            - const: syscon
 
Quoted 13 lines
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
(quoted diff) +3 -1
        - items:
-          - const: mediatek,mt8195-vdosys0
+          - enum:
+              - mediatek,mt8195-vdosys0
+              - mediatek,mt8195-vdosys1
            - const: mediatek,mt8195-mmsys
            - const: syscon
 
Quoted 4 lines
Quoted 2 lines

I think we had that several times already:

https://lore.kernel.org/all/[email protected]/

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines

We will something like this, but please check that this does not give
any errors/warnings:

diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.y aml b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.y aml
index eb451bec23d3d..8e9c4f4d7c389 100644
---
a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.y aml
+++
b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.y aml

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +10 -1
@@ -32,13 +32,22 @@ properties:
                - mediatek,mt8183-mmsys
                - mediatek,mt8186-mmsys
                - mediatek,mt8192-mmsys
-              - mediatek,mt8195-mmsys
                - mediatek,mt8365-mmsys
            - const: syscon
        - items:
            - const: mediatek,mt7623-mmsys
            - const: mediatek,mt2701-mmsys
            - const: syscon
+      - items:
+          - const: mediatek,mt8195-vdosys0
+          - const: syscon
+      - items:
+          - const: mediatek,mt8195-vdosys1
+          - const: syscon
+      - items:
+          - const: mediatek,mt8195-mmsys
+          - const: syscon
+      deprecated: true
 
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml properties: · line 53

Quoted 2 lines
Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.yaml +0 -0
    reg:
      maxItems: 1

Hi Matthias,

As the vdosys0 previous reviewed patch:

https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek/patch/[email protected]/__;!!CTRNKA9wMg0ARbw!zRdbIyyAsfqob2kapMAcKYATAguhEV0x0qE5cTOAcWUNhzeAbMHzZoos_2QzUCxS$

Quoted 10 lines
Quoted 9 lines

Should I modify the vdosys0 items format like your example?

Or should vdosys1 add items format like vdosys0's previous patch?
- items:
- const: mediatek,mt8195-vdosys1
- const: mediatek,mt8195-mmsys
- const: syscon

Quoted 5 lines

No, vdosys1 must not have mediatek,mt8195-mmsys fallback.

Regards,
Matthias

I will fix it and add the following vdosys1 binding base on [1].

- description: vdosys0 and vdosys1 are 2 display HW pipelines, so mt8195 binding should be deprecated.
deprecated: true
items:
- const: mediatek,mt8195-mmsys
- const: syscon
- items:
- const: mediatek,mt7623-mmsys
- const: mediatek,mt2701-mmsys

Quoted 9 lines

- const: syscon
- items:
- const: mediatek,mt8195-vdosys0
- const: mediatek,mt8195-mmsys
- const: syscon
+ - items:
+ - const: mediatek,mt8195-vdosys1
+ - const: syscon

Looks good, thanks
Matthias

Quoted 49 lines

[1]
https://kernel.googlesource.com/pub/scm/linux/kernel/git/matthias.bgg/linux/+/b237efd47df7d25b78c306e90b97c5aa0ff4c4fc/Documentation/devicetree/bindings/arm/mediatek/mediatek%2Cmmsys.yaml

Regards,
Nancy

Quoted 20 lines
Quoted 20 lines

Regards,
Jason-JH.Lin

************* MEDIATEK Confidentiality Notice
********************
The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise
exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination,
distribution, printing, retaining or copying of this e-mail (including its
attachments) by unintended recipient(s) is strictly prohibited and may
be unlawful. If you are not an intended recipient of this e-mail, or believe

Quoted 9 lines
Quoted 7 lines

that you have received this e-mail in error, please notify the sender
immediately (by replying to this e-mail), delete any and all copies of
this e-mail (including any attachments) from your system, and do not
disclose the content of this e-mail to any other person. Thank you!

************* MEDIATEK Confidentiality Notice ******************** The information contained in this e-mail message (including any attachments) may be confidential, proprietary, privileged, or otherwise exempt from disclosure under applicable laws. It is intended to be conveyed only to the designated recipient(s). Any use, dissemination, distribution, printing, retaining or copying of this e-mail (including its attachments) by unintended recipient(s) is strictly prohibited and may be unlawful. If you are not an intended recipient of this e-mail, or believe that you have received this e-mail in error, please notify the sender immediately (by replying to this e-mail), delete any and all copies of this e-mail (including any attachments) from your system, and do not disclose the content of this e-mail to any other person. Thank you!

#7 lore raw

Re: [PATCH v28 01/11] dt-bindings: arm: mediatek: mmsys: add vdosys1 compatible for MT8195

In reply to Nancy.Lin
Quoted 8 lines · Nancy.Lin

Add vdosys1 mmsys compatible for MT8195 platform.

For MT8195, VDOSYS0 and VDOSYS1 are 2 display HW pipelines binding to 2 different power domains, different clock drivers and different mediatek-drm drivers.

Any reason for not CC-ing maintainers pointed out by get_maintainers.pl?

Best regards,
Krzysztof

#8 lore raw

Re: [PATCH v28 01/11] dt-bindings: arm: mediatek: mmsys: add vdosys1 compatible for MT8195

Dear Krzysztof,

Thanks for the review.

Quoted 14 lines · Krzysztof Kozlowski
Quoted 9 lines · Nancy.Lin

Add vdosys1 mmsys compatible for MT8195 platform.

For MT8195, VDOSYS0 and VDOSYS1 are 2 display HW pipelines binding to
2 different power domains, different clock drivers and different mediatek-drm drivers.

Any reason for not CC-ing maintainers pointed out by get_maintainers.pl?

Quoted 7 lines

Best regards,
Krzysztof

I used the recorded maintainer list, instead of executing the maintainer.pl every time. I will update maintainer in the next revision soon. Sorry for the inconvinence.

Regards,
Nancy

author
#9 lore raw

PATCH v28 2/11 dt-bindings: reset: mt8195: add vdosys1 reset control bit

In reply to Nancy.Lin

Add vdosys1 reset control bit for MT8195 platform.

---
 include/dt-bindings/reset/mt8195-resets.h | 45 +++++++++++++++++++++++
 1 file changed, 45 insertions(+)
include/dt-bindings/reset/mt8195-resets.h +45 -0
index 24ab3631dcea..e61660438d61 100644
@@ -35,4 +35,49 @@
 #define MT8195_INFRA_RST2_PCIE_P1_SWRST        4
 #define MT8195_INFRA_RST2_USBSIF_P1_SWRST      5
 
+/* VDOSYS1 */
+#define MT8195_VDOSYS1_SW0_RST_B_SMI_LARB2                     0
+#define MT8195_VDOSYS1_SW0_RST_B_SMI_LARB3                     1
+#define MT8195_VDOSYS1_SW0_RST_B_GALS                          2
+#define MT8195_VDOSYS1_SW0_RST_B_FAKE_ENG0                     3
+#define MT8195_VDOSYS1_SW0_RST_B_FAKE_ENG1                     4
+#define MT8195_VDOSYS1_SW0_RST_B_MDP_RDMA0                     5
+#define MT8195_VDOSYS1_SW0_RST_B_MDP_RDMA1                     6
+#define MT8195_VDOSYS1_SW0_RST_B_MDP_RDMA2                     7
+#define MT8195_VDOSYS1_SW0_RST_B_MDP_RDMA3                     8
+#define MT8195_VDOSYS1_SW0_RST_B_VPP_MERGE0                    9
+#define MT8195_VDOSYS1_SW0_RST_B_VPP_MERGE1                    10
+#define MT8195_VDOSYS1_SW0_RST_B_VPP_MERGE2                    11
+#define MT8195_VDOSYS1_SW0_RST_B_VPP_MERGE3                    12
+#define MT8195_VDOSYS1_SW0_RST_B_VPP_MERGE4                    13
+#define MT8195_VDOSYS1_SW0_RST_B_VPP2_TO_VDO1_DL_ASYNC         14
+#define MT8195_VDOSYS1_SW0_RST_B_VPP3_TO_VDO1_DL_ASYNC         15
+#define MT8195_VDOSYS1_SW0_RST_B_DISP_MUTEX                    16
+#define MT8195_VDOSYS1_SW0_RST_B_MDP_RDMA4                     17
+#define MT8195_VDOSYS1_SW0_RST_B_MDP_RDMA5                     18
+#define MT8195_VDOSYS1_SW0_RST_B_MDP_RDMA6                     19
+#define MT8195_VDOSYS1_SW0_RST_B_MDP_RDMA7                     20
+#define MT8195_VDOSYS1_SW0_RST_B_DP_INTF0                      21
+#define MT8195_VDOSYS1_SW0_RST_B_DPI0                          22
+#define MT8195_VDOSYS1_SW0_RST_B_DPI1                          23
+#define MT8195_VDOSYS1_SW0_RST_B_DISP_MONITOR                  24
+#define MT8195_VDOSYS1_SW0_RST_B_MERGE0_DL_ASYNC               25
+#define MT8195_VDOSYS1_SW0_RST_B_MERGE1_DL_ASYNC               26
+#define MT8195_VDOSYS1_SW0_RST_B_MERGE2_DL_ASYNC               27
+#define MT8195_VDOSYS1_SW0_RST_B_MERGE3_DL_ASYNC               28
+#define MT8195_VDOSYS1_SW0_RST_B_MERGE4_DL_ASYNC               29
+#define MT8195_VDOSYS1_SW0_RST_B_VDO0_DSC_TO_VDO1_DL_ASYNC     30
+#define MT8195_VDOSYS1_SW0_RST_B_VDO0_MERGE_TO_VDO1_DL_ASYNC   31
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_VDO_FE0                   32
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_GFX_FE0                   33
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_VDO_BE                    34
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_VDO_FE1                   48
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_GFX_FE1                   49
+#define MT8195_VDOSYS1_SW1_RST_B_DISP_MIXER                    50
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_VDO_FE0_DL_ASYNC          51
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_VDO_FE1_DL_ASYNC          52
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_GFX_FE0_DL_ASYNC          53
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_GFX_FE1_DL_ASYNC          54
+#define MT8195_VDOSYS1_SW1_RST_B_HDR_VDO_BE_DL_ASYNC           55
+
 #endif  /* _DT_BINDINGS_RESET_CONTROLLER_MT8195 */
Signature · 1 line
2.18.0
author
#10 lore raw

PATCH v28 3/11 soc: mediatek: add mtk-mmsys ethdr and mdp_rdma components

In reply to Nancy.Lin

Add new mmsys component: ethdr_mixer and mdp_rdma. These components will use in mt8195 vdosys1.

---
 include/linux/soc/mediatek/mtk-mmsys.h | 9 +++++++++
 1 file changed, 9 insertions(+)
include/linux/soc/mediatek/mtk-mmsys.h +9 -0
index 16ac0e5847f0..127f1b888ace 100644
@@ -28,7 +28,16 @@ enum mtk_ddp_comp_id {
 	DDP_COMPONENT_DSI1,
 	DDP_COMPONENT_DSI2,
 	DDP_COMPONENT_DSI3,
+	DDP_COMPONENT_ETHDR_MIXER,
 	DDP_COMPONENT_GAMMA,
+	DDP_COMPONENT_MDP_RDMA0,
+	DDP_COMPONENT_MDP_RDMA1,
+	DDP_COMPONENT_MDP_RDMA2,
+	DDP_COMPONENT_MDP_RDMA3,
+	DDP_COMPONENT_MDP_RDMA4,
+	DDP_COMPONENT_MDP_RDMA5,
+	DDP_COMPONENT_MDP_RDMA6,
+	DDP_COMPONENT_MDP_RDMA7,
 	DDP_COMPONENT_MERGE0,
 	DDP_COMPONENT_MERGE1,
 	DDP_COMPONENT_MERGE2,
Signature · 1 line
2.18.0
author
#11 lore raw

PATCH v28 4/11 soc: mediatek: add mtk-mmsys support for mt8195 vdosys1

In reply to Nancy.Lin

Add mt8195 vdosys1 routing table to the driver data of mtk-mmsys.

---
 drivers/soc/mediatek/mt8195-mmsys.h | 139 ++++++++++++++++++++++++++++
 drivers/soc/mediatek/mtk-mmsys.c    |  10 ++
 2 files changed, 149 insertions(+)
drivers/soc/mediatek/mt8195-mmsys.h +139 -0
index abfe94a30248..fd7b455bd675 100644
@@ -75,6 +75,70 @@
 #define MT8195_SOUT_DSC_WRAP1_OUT_TO_SINA_VIRTUAL0		(2 << 16)
 #define MT8195_SOUT_DSC_WRAP1_OUT_TO_VPP_MERGE			(3 << 16)
 
+#define MT8195_VDO1_VPP_MERGE0_P0_SEL_IN			0xf04
+#define MT8195_VPP_MERGE0_P0_SEL_IN_FROM_MDP_RDMA0			1
+
+#define MT8195_VDO1_VPP_MERGE0_P1_SEL_IN			0xf08
+#define MT8195_VPP_MERGE0_P1_SEL_IN_FROM_MDP_RDMA1			1
+
+#define MT8195_VDO1_DISP_DPI1_SEL_IN				0xf10
+#define MT8195_DISP_DPI1_SEL_IN_FROM_VPP_MERGE4_MOUT			0
+
+#define MT8195_VDO1_DISP_DP_INTF0_SEL_IN			0xf14
+#define MT8195_DISP_DP_INTF0_SEL_IN_FROM_VPP_MERGE4_MOUT		0
+
+#define MT8195_VDO1_MERGE4_SOUT_SEL				0xf18
+#define MT8195_MERGE4_SOUT_TO_DPI1_SEL					2
+#define MT8195_MERGE4_SOUT_TO_DP_INTF0_SEL				3
+
+#define MT8195_VDO1_MIXER_IN1_SEL_IN				0xf24
+#define MT8195_MIXER_IN1_SEL_IN_FROM_MERGE0_ASYNC_SOUT			1
+
+#define MT8195_VDO1_MIXER_IN2_SEL_IN				0xf28
+#define MT8195_MIXER_IN2_SEL_IN_FROM_MERGE1_ASYNC_SOUT			1
+
+#define MT8195_VDO1_MIXER_IN3_SEL_IN				0xf2c
+#define MT8195_MIXER_IN3_SEL_IN_FROM_MERGE2_ASYNC_SOUT			1
+
+#define MT8195_VDO1_MIXER_IN4_SEL_IN				0xf30
+#define MT8195_MIXER_IN4_SEL_IN_FROM_MERGE3_ASYNC_SOUT			1
+
+#define MT8195_VDO1_MIXER_OUT_SOUT_SEL				0xf34
+#define MT8195_MIXER_SOUT_TO_MERGE4_ASYNC_SEL				1
+
+#define MT8195_VDO1_VPP_MERGE1_P0_SEL_IN			0xf3c
+#define MT8195_VPP_MERGE1_P0_SEL_IN_FROM_MDP_RDMA2			1
+
+#define MT8195_VDO1_MERGE0_ASYNC_SOUT_SEL			0xf40
+#define MT8195_SOUT_TO_MIXER_IN1_SEL					1
+
+#define MT8195_VDO1_MERGE1_ASYNC_SOUT_SEL			0xf44
+#define MT8195_SOUT_TO_MIXER_IN2_SEL					1
+
+#define MT8195_VDO1_MERGE2_ASYNC_SOUT_SEL			0xf48
+#define MT8195_SOUT_TO_MIXER_IN3_SEL					1
+
+#define MT8195_VDO1_MERGE3_ASYNC_SOUT_SEL			0xf4c
+#define MT8195_SOUT_TO_MIXER_IN4_SEL					1
+
+#define MT8195_VDO1_MERGE4_ASYNC_SEL_IN				0xf50
+#define MT8195_MERGE4_ASYNC_SEL_IN_FROM_MIXER_OUT_SOUT			1
+
+#define MT8195_VDO1_MIXER_IN1_SOUT_SEL				0xf58
+#define MT8195_MIXER_IN1_SOUT_TO_DISP_MIXER				0
+
+#define MT8195_VDO1_MIXER_IN2_SOUT_SEL				0xf5c
+#define MT8195_MIXER_IN2_SOUT_TO_DISP_MIXER				0
+
+#define MT8195_VDO1_MIXER_IN3_SOUT_SEL				0xf60
+#define MT8195_MIXER_IN3_SOUT_TO_DISP_MIXER				0
+
+#define MT8195_VDO1_MIXER_IN4_SOUT_SEL				0xf64
+#define MT8195_MIXER_IN4_SOUT_TO_DISP_MIXER				0
+
+#define MT8195_VDO1_MIXER_SOUT_SEL_IN				0xf68
+#define MT8195_MIXER_SOUT_SEL_IN_FROM_DISP_MIXER			0
+
 static const struct mtk_mmsys_routes mmsys_mt8195_routing_table[] = {
 	{
 		DDP_COMPONENT_OVL0, DDP_COMPONENT_RDMA0,
@@ -367,4 +431,79 @@ static const struct mtk_mmsys_routes mmsys_mt8195_routing_table[] = {
 	}
 };
 
+static const struct mtk_mmsys_routes mmsys_mt8195_vdo1_routing_table[] = {
+	{
+		DDP_COMPONENT_MDP_RDMA0, DDP_COMPONENT_MERGE1,
+		MT8195_VDO1_VPP_MERGE0_P0_SEL_IN, GENMASK(0, 0),
+		MT8195_VPP_MERGE0_P0_SEL_IN_FROM_MDP_RDMA0
+	}, {
+		DDP_COMPONENT_MDP_RDMA1, DDP_COMPONENT_MERGE1,
+		MT8195_VDO1_VPP_MERGE0_P1_SEL_IN, GENMASK(0, 0),
+		MT8195_VPP_MERGE0_P1_SEL_IN_FROM_MDP_RDMA1
+	}, {
+		DDP_COMPONENT_MDP_RDMA2, DDP_COMPONENT_MERGE2,
+		MT8195_VDO1_VPP_MERGE1_P0_SEL_IN, GENMASK(0, 0),
+		MT8195_VPP_MERGE1_P0_SEL_IN_FROM_MDP_RDMA2
+	}, {
+		DDP_COMPONENT_MERGE1, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MERGE0_ASYNC_SOUT_SEL, GENMASK(1, 0),
+		MT8195_SOUT_TO_MIXER_IN1_SEL
+	}, {
+		DDP_COMPONENT_MERGE2, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MERGE1_ASYNC_SOUT_SEL, GENMASK(1, 0),
+		MT8195_SOUT_TO_MIXER_IN2_SEL
+	}, {
+		DDP_COMPONENT_MERGE3, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MERGE2_ASYNC_SOUT_SEL, GENMASK(1, 0),
+		MT8195_SOUT_TO_MIXER_IN3_SEL
+	}, {
+		DDP_COMPONENT_MERGE4, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MERGE3_ASYNC_SOUT_SEL, GENMASK(1, 0),
+		MT8195_SOUT_TO_MIXER_IN4_SEL
+	}, {
+		DDP_COMPONENT_ETHDR_MIXER, DDP_COMPONENT_MERGE5,
+		MT8195_VDO1_MIXER_OUT_SOUT_SEL, GENMASK(0, 0),
+		MT8195_MIXER_SOUT_TO_MERGE4_ASYNC_SEL
+	}, {
+		DDP_COMPONENT_MERGE1, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MIXER_IN1_SEL_IN, GENMASK(0, 0),
+		MT8195_MIXER_IN1_SEL_IN_FROM_MERGE0_ASYNC_SOUT
+	}, {
+		DDP_COMPONENT_MERGE2, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MIXER_IN2_SEL_IN, GENMASK(0, 0),
+		MT8195_MIXER_IN2_SEL_IN_FROM_MERGE1_ASYNC_SOUT
+	}, {
+		DDP_COMPONENT_MERGE3, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MIXER_IN3_SEL_IN, GENMASK(0, 0),
+		MT8195_MIXER_IN3_SEL_IN_FROM_MERGE2_ASYNC_SOUT
+	}, {
+		DDP_COMPONENT_MERGE4, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MIXER_IN4_SEL_IN, GENMASK(0, 0),
+		MT8195_MIXER_IN4_SEL_IN_FROM_MERGE3_ASYNC_SOUT
+	}, {
+		DDP_COMPONENT_ETHDR_MIXER, DDP_COMPONENT_MERGE5,
+		MT8195_VDO1_MIXER_SOUT_SEL_IN, GENMASK(2, 0),
+		MT8195_MIXER_SOUT_SEL_IN_FROM_DISP_MIXER
+	}, {
+		DDP_COMPONENT_ETHDR_MIXER, DDP_COMPONENT_MERGE5,
+		MT8195_VDO1_MERGE4_ASYNC_SEL_IN, GENMASK(2, 0),
+		MT8195_MERGE4_ASYNC_SEL_IN_FROM_MIXER_OUT_SOUT
+	}, {
+		DDP_COMPONENT_MERGE5, DDP_COMPONENT_DPI1,
+		MT8195_VDO1_DISP_DPI1_SEL_IN, GENMASK(1, 0),
+		MT8195_DISP_DPI1_SEL_IN_FROM_VPP_MERGE4_MOUT
+	}, {
+		DDP_COMPONENT_MERGE5, DDP_COMPONENT_DPI1,
+		MT8195_VDO1_MERGE4_SOUT_SEL, GENMASK(1, 0),
+		MT8195_MERGE4_SOUT_TO_DPI1_SEL
+	}, {
+		DDP_COMPONENT_MERGE5, DDP_COMPONENT_DP_INTF1,
+		MT8195_VDO1_DISP_DP_INTF0_SEL_IN, GENMASK(1, 0),
+		MT8195_DISP_DP_INTF0_SEL_IN_FROM_VPP_MERGE4_MOUT
+	}, {
+		DDP_COMPONENT_MERGE5, DDP_COMPONENT_DP_INTF1,
+		MT8195_VDO1_MERGE4_SOUT_SEL, GENMASK(1, 0),
+		MT8195_MERGE4_SOUT_TO_DP_INTF0_SEL
+	}
+};
 #endif /* __SOC_MEDIATEK_MT8195_MMSYS_H */
drivers/soc/mediatek/mtk-mmsys.c +10 -0
index 146a78ba06c1..9a327eb5d9d7 100644
@@ -80,6 +80,12 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = {
 	.num_routes = ARRAY_SIZE(mmsys_mt8195_routing_table),
 };
 
+static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {
+	.clk_driver = "clk-mt8195-vdo1",
+	.routes = mmsys_mt8195_vdo1_routing_table,
+	.num_routes = ARRAY_SIZE(mmsys_mt8195_vdo1_routing_table),
+};
+
 static const struct mtk_mmsys_driver_data mt8365_mmsys_driver_data = {
 	.clk_driver = "clk-mt8365-mm",
 	.routes = mt8365_mmsys_routing_table,
@@ -292,6 +298,10 @@ static const struct of_device_id of_match_mtk_mmsys[] = {
 		.compatible = "mediatek,mt8195-vdosys0",
 		.data = &mt8195_vdosys0_driver_data,
 	},
+	{
+		.compatible = "mediatek,mt8195-vdosys1",
+		.data = &mt8195_vdosys1_driver_data,
+	},
 	{
 		.compatible = "mediatek,mt8365-mmsys",
 		.data = &mt8365_mmsys_driver_data,
Signature · 1 line
2.18.0
maintainer
#12 lore raw

Re: [PATCH v28 04/11] soc: mediatek: add mtk-mmsys support for mt8195 vdosys1

Quoted 186 lines · Nancy.Lin

Add mt8195 vdosys1 routing table to the driver data of mtk-mmsys.

---
  drivers/soc/mediatek/mt8195-mmsys.h | 139 ++++++++++++++++++++++++++++
  drivers/soc/mediatek/mtk-mmsys.c    |  10 ++
  2 files changed, 149 insertions(+)
drivers/soc/mediatek/mt8195-mmsys.h +139 -0
index abfe94a30248..fd7b455bd675 100644
@@ -75,6 +75,70 @@
  #define MT8195_SOUT_DSC_WRAP1_OUT_TO_SINA_VIRTUAL0		(2 << 16)
  #define MT8195_SOUT_DSC_WRAP1_OUT_TO_VPP_MERGE			(3 << 16)
 
+#define MT8195_VDO1_VPP_MERGE0_P0_SEL_IN			0xf04
+#define MT8195_VPP_MERGE0_P0_SEL_IN_FROM_MDP_RDMA0			1
+
+#define MT8195_VDO1_VPP_MERGE0_P1_SEL_IN			0xf08
+#define MT8195_VPP_MERGE0_P1_SEL_IN_FROM_MDP_RDMA1			1
+
+#define MT8195_VDO1_DISP_DPI1_SEL_IN				0xf10
+#define MT8195_DISP_DPI1_SEL_IN_FROM_VPP_MERGE4_MOUT			0
+
+#define MT8195_VDO1_DISP_DP_INTF0_SEL_IN			0xf14
+#define MT8195_DISP_DP_INTF0_SEL_IN_FROM_VPP_MERGE4_MOUT		0
+
+#define MT8195_VDO1_MERGE4_SOUT_SEL				0xf18
+#define MT8195_MERGE4_SOUT_TO_DPI1_SEL					2
+#define MT8195_MERGE4_SOUT_TO_DP_INTF0_SEL				3
+
+#define MT8195_VDO1_MIXER_IN1_SEL_IN				0xf24
+#define MT8195_MIXER_IN1_SEL_IN_FROM_MERGE0_ASYNC_SOUT			1
+
+#define MT8195_VDO1_MIXER_IN2_SEL_IN				0xf28
+#define MT8195_MIXER_IN2_SEL_IN_FROM_MERGE1_ASYNC_SOUT			1
+
+#define MT8195_VDO1_MIXER_IN3_SEL_IN				0xf2c
+#define MT8195_MIXER_IN3_SEL_IN_FROM_MERGE2_ASYNC_SOUT			1
+
+#define MT8195_VDO1_MIXER_IN4_SEL_IN				0xf30
+#define MT8195_MIXER_IN4_SEL_IN_FROM_MERGE3_ASYNC_SOUT			1
+
+#define MT8195_VDO1_MIXER_OUT_SOUT_SEL				0xf34
+#define MT8195_MIXER_SOUT_TO_MERGE4_ASYNC_SEL				1
+
+#define MT8195_VDO1_VPP_MERGE1_P0_SEL_IN			0xf3c
+#define MT8195_VPP_MERGE1_P0_SEL_IN_FROM_MDP_RDMA2			1
+
+#define MT8195_VDO1_MERGE0_ASYNC_SOUT_SEL			0xf40
+#define MT8195_SOUT_TO_MIXER_IN1_SEL					1
+
+#define MT8195_VDO1_MERGE1_ASYNC_SOUT_SEL			0xf44
+#define MT8195_SOUT_TO_MIXER_IN2_SEL					1
+
+#define MT8195_VDO1_MERGE2_ASYNC_SOUT_SEL			0xf48
+#define MT8195_SOUT_TO_MIXER_IN3_SEL					1
+
+#define MT8195_VDO1_MERGE3_ASYNC_SOUT_SEL			0xf4c
+#define MT8195_SOUT_TO_MIXER_IN4_SEL					1
+
+#define MT8195_VDO1_MERGE4_ASYNC_SEL_IN				0xf50
+#define MT8195_MERGE4_ASYNC_SEL_IN_FROM_MIXER_OUT_SOUT			1
+
+#define MT8195_VDO1_MIXER_IN1_SOUT_SEL				0xf58
+#define MT8195_MIXER_IN1_SOUT_TO_DISP_MIXER				0
+
+#define MT8195_VDO1_MIXER_IN2_SOUT_SEL				0xf5c
+#define MT8195_MIXER_IN2_SOUT_TO_DISP_MIXER				0
+
+#define MT8195_VDO1_MIXER_IN3_SOUT_SEL				0xf60
+#define MT8195_MIXER_IN3_SOUT_TO_DISP_MIXER				0
+
+#define MT8195_VDO1_MIXER_IN4_SOUT_SEL				0xf64
+#define MT8195_MIXER_IN4_SOUT_TO_DISP_MIXER				0
+
+#define MT8195_VDO1_MIXER_SOUT_SEL_IN				0xf68
+#define MT8195_MIXER_SOUT_SEL_IN_FROM_DISP_MIXER			0
+
  static const struct mtk_mmsys_routes mmsys_mt8195_routing_table[] = {
  	{
  		DDP_COMPONENT_OVL0, DDP_COMPONENT_RDMA0,
@@ -367,4 +431,79 @@ static const struct mtk_mmsys_routes mmsys_mt8195_routing_table[] = {
  	}
  };
 
+static const struct mtk_mmsys_routes mmsys_mt8195_vdo1_routing_table[] = {
+	{
+		DDP_COMPONENT_MDP_RDMA0, DDP_COMPONENT_MERGE1,
+		MT8195_VDO1_VPP_MERGE0_P0_SEL_IN, GENMASK(0, 0),
+		MT8195_VPP_MERGE0_P0_SEL_IN_FROM_MDP_RDMA0
+	}, {
+		DDP_COMPONENT_MDP_RDMA1, DDP_COMPONENT_MERGE1,
+		MT8195_VDO1_VPP_MERGE0_P1_SEL_IN, GENMASK(0, 0),
+		MT8195_VPP_MERGE0_P1_SEL_IN_FROM_MDP_RDMA1
+	}, {
+		DDP_COMPONENT_MDP_RDMA2, DDP_COMPONENT_MERGE2,
+		MT8195_VDO1_VPP_MERGE1_P0_SEL_IN, GENMASK(0, 0),
+		MT8195_VPP_MERGE1_P0_SEL_IN_FROM_MDP_RDMA2
+	}, {
+		DDP_COMPONENT_MERGE1, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MERGE0_ASYNC_SOUT_SEL, GENMASK(1, 0),
+		MT8195_SOUT_TO_MIXER_IN1_SEL
+	}, {
+		DDP_COMPONENT_MERGE2, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MERGE1_ASYNC_SOUT_SEL, GENMASK(1, 0),
+		MT8195_SOUT_TO_MIXER_IN2_SEL
+	}, {
+		DDP_COMPONENT_MERGE3, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MERGE2_ASYNC_SOUT_SEL, GENMASK(1, 0),
+		MT8195_SOUT_TO_MIXER_IN3_SEL
+	}, {
+		DDP_COMPONENT_MERGE4, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MERGE3_ASYNC_SOUT_SEL, GENMASK(1, 0),
+		MT8195_SOUT_TO_MIXER_IN4_SEL
+	}, {
+		DDP_COMPONENT_ETHDR_MIXER, DDP_COMPONENT_MERGE5,
+		MT8195_VDO1_MIXER_OUT_SOUT_SEL, GENMASK(0, 0),
+		MT8195_MIXER_SOUT_TO_MERGE4_ASYNC_SEL
+	}, {
+		DDP_COMPONENT_MERGE1, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MIXER_IN1_SEL_IN, GENMASK(0, 0),
+		MT8195_MIXER_IN1_SEL_IN_FROM_MERGE0_ASYNC_SOUT
+	}, {
+		DDP_COMPONENT_MERGE2, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MIXER_IN2_SEL_IN, GENMASK(0, 0),
+		MT8195_MIXER_IN2_SEL_IN_FROM_MERGE1_ASYNC_SOUT
+	}, {
+		DDP_COMPONENT_MERGE3, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MIXER_IN3_SEL_IN, GENMASK(0, 0),
+		MT8195_MIXER_IN3_SEL_IN_FROM_MERGE2_ASYNC_SOUT
+	}, {
+		DDP_COMPONENT_MERGE4, DDP_COMPONENT_ETHDR_MIXER,
+		MT8195_VDO1_MIXER_IN4_SEL_IN, GENMASK(0, 0),
+		MT8195_MIXER_IN4_SEL_IN_FROM_MERGE3_ASYNC_SOUT
+	}, {
+		DDP_COMPONENT_ETHDR_MIXER, DDP_COMPONENT_MERGE5,
+		MT8195_VDO1_MIXER_SOUT_SEL_IN, GENMASK(2, 0),
+		MT8195_MIXER_SOUT_SEL_IN_FROM_DISP_MIXER
+	}, {
+		DDP_COMPONENT_ETHDR_MIXER, DDP_COMPONENT_MERGE5,
+		MT8195_VDO1_MERGE4_ASYNC_SEL_IN, GENMASK(2, 0),
+		MT8195_MERGE4_ASYNC_SEL_IN_FROM_MIXER_OUT_SOUT
+	}, {
+		DDP_COMPONENT_MERGE5, DDP_COMPONENT_DPI1,
+		MT8195_VDO1_DISP_DPI1_SEL_IN, GENMASK(1, 0),
+		MT8195_DISP_DPI1_SEL_IN_FROM_VPP_MERGE4_MOUT
+	}, {
+		DDP_COMPONENT_MERGE5, DDP_COMPONENT_DPI1,
+		MT8195_VDO1_MERGE4_SOUT_SEL, GENMASK(1, 0),
+		MT8195_MERGE4_SOUT_TO_DPI1_SEL
+	}, {
+		DDP_COMPONENT_MERGE5, DDP_COMPONENT_DP_INTF1,
+		MT8195_VDO1_DISP_DP_INTF0_SEL_IN, GENMASK(1, 0),
+		MT8195_DISP_DP_INTF0_SEL_IN_FROM_VPP_MERGE4_MOUT
+	}, {
+		DDP_COMPONENT_MERGE5, DDP_COMPONENT_DP_INTF1,
+		MT8195_VDO1_MERGE4_SOUT_SEL, GENMASK(1, 0),
+		MT8195_MERGE4_SOUT_TO_DP_INTF0_SEL
+	}
+};
  #endif /* __SOC_MEDIATEK_MT8195_MMSYS_H */
drivers/soc/mediatek/mtk-mmsys.c +6 -0
index 146a78ba06c1..9a327eb5d9d7 100644
@@ -80,6 +80,12 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = {
  	.num_routes = ARRAY_SIZE(mmsys_mt8195_routing_table),
  };
 
+static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {
+	.clk_driver = "clk-mt8195-vdo1",
+	.routes = mmsys_mt8195_vdo1_routing_table,
+	.num_routes = ARRAY_SIZE(mmsys_mt8195_vdo1_routing_table),
+};
+
  static const struct mtk_mmsys_driver_data mt8365_mmsys_driver_data = {
  	.clk_driver = "clk-mt8365-mm",
  	.routes = mt8365_mmsys_routing_table,

drivers/soc/mediatek/mtk-mmsys.c static const struct of_device_id of_match_mtk_mmsys[] = { · line 299

Quoted 2 lines
drivers/soc/mediatek/mtk-mmsys.c +0 -0
@@ -292,6 +298,10 @@ static const struct of_device_id of_match_mtk_mmsys[] = {
  		.compatible = "mediatek,mt8195-vdosys0",
  		.data = &mt8195_vdosys0_driver_data,

It seems we are missing a patch in the series. vdosys0 also correct was never introduced in the driver...

Quoted 8 lines
drivers/soc/mediatek/mtk-mmsys.c +4 -0
  	},
+	{
+		.compatible = "mediatek,mt8195-vdosys1",
+		.data = &mt8195_vdosys1_driver_data,
+	},
  	{
  		.compatible = "mediatek,mt8365-mmsys",
  		.data = &mt8365_mmsys_driver_data,
#13 lore raw

Re: [PATCH v28 04/11] soc: mediatek: add mtk-mmsys support for mt8195 vdosys1

Quoted 1 line · Matthias Brugger

On 07/11/2022 08:22, Nancy.Lin wrote:

[..]

Quoted 12 lines
Quoted 12 lines
drivers/soc/mediatek/mtk-mmsys.c +6 -0
@@ -80,6 +80,12 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = {
  	.num_routes = ARRAY_SIZE(mmsys_mt8195_routing_table),
  };
+static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {
+	.clk_driver = "clk-mt8195-vdo1",
+	.routes = mmsys_mt8195_vdo1_routing_table,
+	.num_routes = ARRAY_SIZE(mmsys_mt8195_vdo1_routing_table),
+};
+
  static const struct mtk_mmsys_driver_data mt8365_mmsys_driver_data = {
Quoted 8 lines

drivers/soc/mediatek/mtk-mmsys.c static const struct of_device_id of_match_mtk_mmsys[] = { · line 299

Quoted 5 lines
drivers/soc/mediatek/mtk-mmsys.c +0 -0
  	.clk_driver = "clk-mt8365-mm",
  	.routes = mt8365_mmsys_routing_table,
@@ -292,6 +298,10 @@ static const struct of_device_id of_match_mtk_mmsys[] = {
  		.compatible = "mediatek,mt8195-vdosys0",
  		.data = &mt8195_vdosys0_driver_data,

It seems we are missing a patch in the series. vdosys0 also correct was never introduced in the driver...

Hi Matthias,

as mentioned in the cover letter, this series is based on the series "Change mmsys compatible for mt8195 mediatek-drm" [1], which introduces vdosys0. This compatible entry specifically is added on patch 3 of that series [2].

[1] https://lore.kernel.org/all/[email protected]/
[2] https://lore.kernel.org/all/[email protected]/

Thanks,
Nícolas

Quoted 9 lines
Quoted 9 lines
drivers/soc/mediatek/mtk-mmsys.c +4 -0
  	},
+	{
+		.compatible = "mediatek,mt8195-vdosys1",
+		.data = &mt8195_vdosys1_driver_data,
+	},
  	{
  		.compatible = "mediatek,mt8365-mmsys",
  		.data = &mt8365_mmsys_driver_data,
maintainer
#14 lore raw

Re: [PATCH v28 04/11] soc: mediatek: add mtk-mmsys support for mt8195 vdosys1

Quoted 24 lines · Nícolas F. R. A. Prado
Quoted 1 line · Matthias Brugger

On 07/11/2022 08:22, Nancy.Lin wrote:

[..]

Quoted 12 lines
Quoted 12 lines
drivers/soc/mediatek/mtk-mmsys.c +6 -0
@@ -80,6 +80,12 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = {
   	.num_routes = ARRAY_SIZE(mmsys_mt8195_routing_table),
   };
+static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {
+	.clk_driver = "clk-mt8195-vdo1",
+	.routes = mmsys_mt8195_vdo1_routing_table,
+	.num_routes = ARRAY_SIZE(mmsys_mt8195_vdo1_routing_table),
+};
+
   static const struct mtk_mmsys_driver_data mt8365_mmsys_driver_data = {
Quoted 8 lines

drivers/soc/mediatek/mtk-mmsys.c static const struct of_device_id of_match_mtk_mmsys[] = { · line 299

Quoted 5 lines
drivers/soc/mediatek/mtk-mmsys.c +0 -0
   	.clk_driver = "clk-mt8365-mm",
   	.routes = mt8365_mmsys_routing_table,
@@ -292,6 +298,10 @@ static const struct of_device_id of_match_mtk_mmsys[] = {
   		.compatible = "mediatek,mt8195-vdosys0",
   		.data = &mt8195_vdosys0_driver_data,

It seems we are missing a patch in the series. vdosys0 also correct was never introduced in the driver...

Quoted 7 lines

Hi Matthias,

as mentioned in the cover letter, this series is based on the series "Change mmsys compatible for mt8195 mediatek-drm" [1], which introduces vdosys0. This compatible entry specifically is added on patch 3 of that series [2].

[1] https://lore.kernel.org/all/[email protected]/

My bad. Thanks for the link. I realized that yesterday but had to leave urgently. I'll have a look on this series now.

Regards,
Matthias

Quoted 14 lines

[2] https://lore.kernel.org/all/[email protected]/

Thanks,
Nícolas

Quoted 9 lines
Quoted 9 lines
drivers/soc/mediatek/mtk-mmsys.c +4 -0
   	},
+	{
+		.compatible = "mediatek,mt8195-vdosys1",
+		.data = &mt8195_vdosys1_driver_data,
+	},
   	{
   		.compatible = "mediatek,mt8365-mmsys",
   		.data = &mt8365_mmsys_driver_data,
author
#15 lore raw

PATCH v28 5/11 soc: mediatek: refine code to use mtk_mmsys_update_bits API

In reply to Nancy.Lin

Simplify code for update mmsys reg.

---
 drivers/soc/mediatek/mtk-mmsys.c | 45 ++++++++++++--------------------
 1 file changed, 16 insertions(+), 29 deletions(-)
drivers/soc/mediatek/mtk-mmsys.c +16 -29
index 9a327eb5d9d7..73c8bd27e6ae 100644
@@ -99,22 +99,27 @@ struct mtk_mmsys {
 	struct reset_controller_dev rcdev;
 };
 
+static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
+{
+	u32 tmp;
+
+	tmp = readl_relaxed(mmsys->regs + offset);
+	tmp = (tmp & ~mask) | (val & mask);
+	writel_relaxed(tmp, mmsys->regs + offset);
+}
+
 void mtk_mmsys_ddp_connect(struct device *dev,
 			   enum mtk_ddp_comp_id cur,
 			   enum mtk_ddp_comp_id next)
 {
 	struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
 	const struct mtk_mmsys_routes *routes = mmsys->data->routes;
-	u32 reg;
 	int i;
 
 	for (i = 0; i < mmsys->data->num_routes; i++)
-		if (cur == routes[i].from_comp && next == routes[i].to_comp) {
-			reg = readl_relaxed(mmsys->regs + routes[i].addr);
-			reg &= ~routes[i].mask;
-			reg |= routes[i].val;
-			writel_relaxed(reg, mmsys->regs + routes[i].addr);
-		}
+		if (cur == routes[i].from_comp && next == routes[i].to_comp)
+			mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask,
+					      routes[i].val);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_connect);
 
@@ -124,27 +129,14 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
 {
 	struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
 	const struct mtk_mmsys_routes *routes = mmsys->data->routes;
-	u32 reg;
 	int i;
 
 	for (i = 0; i < mmsys->data->num_routes; i++)
-		if (cur == routes[i].from_comp && next == routes[i].to_comp) {
-			reg = readl_relaxed(mmsys->regs + routes[i].addr);
-			reg &= ~routes[i].mask;
-			writel_relaxed(reg, mmsys->regs + routes[i].addr);
-		}
+		if (cur == routes[i].from_comp && next == routes[i].to_comp)
+			mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask, 0);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
 
-static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
-{
-	u32 tmp;
-
-	tmp = readl_relaxed(mmsys->regs + offset);
-	tmp = (tmp & ~mask) | val;
-	writel_relaxed(tmp, mmsys->regs + offset);
-}
-
 void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val)
 {
 	if (val)
@@ -161,18 +153,13 @@ static int mtk_mmsys_reset_update(struct reset_controller_dev *rcdev, unsigned l
 {
 	struct mtk_mmsys *mmsys = container_of(rcdev, struct mtk_mmsys, rcdev);
 	unsigned long flags;
-	u32 reg;
 
 	spin_lock_irqsave(&mmsys->lock, flags);
 
-	reg = readl_relaxed(mmsys->regs + mmsys->data->sw0_rst_offset);
-
 	if (assert)
-		reg &= ~BIT(id);
+		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), 0);
 	else
-		reg |= BIT(id);
-
-	writel_relaxed(reg, mmsys->regs + mmsys->data->sw0_rst_offset);
+		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), BIT(id));
 
 	spin_unlock_irqrestore(&mmsys->lock, flags);
 
Signature · 1 line
2.18.0
maintainer
#16 lore raw

Re: [PATCH v28 05/11] soc: mediatek: refine code to use mtk_mmsys_update_bits API

Quoted 17 lines · Nancy.Lin

Simplify code for update mmsys reg.

---
  drivers/soc/mediatek/mtk-mmsys.c | 45 ++++++++++++--------------------
  1 file changed, 16 insertions(+), 29 deletions(-)
drivers/soc/mediatek/mtk-mmsys.c +0 -0
index 9a327eb5d9d7..73c8bd27e6ae 100644

drivers/soc/mediatek/mtk-mmsys.c struct mtk_mmsys { · line 107

Quoted 9 lines
drivers/soc/mediatek/mtk-mmsys.c +6 -0
@@ -99,22 +99,27 @@ struct mtk_mmsys {
  	struct reset_controller_dev rcdev;
  };
 
+static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
+{
+	u32 tmp;
+
+	tmp = readl_relaxed(mmsys->regs + offset);
+	tmp = (tmp & ~mask) | (val & mask);

I'm not sure about the change in the implementation of mtk_mmsys_update_bits(). Nicolas tried to explain it to me on IRC but I wasn't totally convincing. As we have to go for at least another round of this patches, I'd like to get a clear understanding while it is needed that val bits are set to 1 in the mask.

Regards,
Matthias

Quoted 76 lines
drivers/soc/mediatek/mtk-mmsys.c +10 -29
+	writel_relaxed(tmp, mmsys->regs + offset);
+}
+
  void mtk_mmsys_ddp_connect(struct device *dev,
  			   enum mtk_ddp_comp_id cur,
  			   enum mtk_ddp_comp_id next)
  {
  	struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
  	const struct mtk_mmsys_routes *routes = mmsys->data->routes;
-	u32 reg;
  	int i;
 
  	for (i = 0; i < mmsys->data->num_routes; i++)
-		if (cur == routes[i].from_comp && next == routes[i].to_comp) {
-			reg = readl_relaxed(mmsys->regs + routes[i].addr);
-			reg &= ~routes[i].mask;
-			reg |= routes[i].val;
-			writel_relaxed(reg, mmsys->regs + routes[i].addr);
-		}
+		if (cur == routes[i].from_comp && next == routes[i].to_comp)
+			mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask,
+					      routes[i].val);
  }
  EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_connect);
 
@@ -124,27 +129,14 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
  {
  	struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
  	const struct mtk_mmsys_routes *routes = mmsys->data->routes;
-	u32 reg;
  	int i;
 
  	for (i = 0; i < mmsys->data->num_routes; i++)
-		if (cur == routes[i].from_comp && next == routes[i].to_comp) {
-			reg = readl_relaxed(mmsys->regs + routes[i].addr);
-			reg &= ~routes[i].mask;
-			writel_relaxed(reg, mmsys->regs + routes[i].addr);
-		}
+		if (cur == routes[i].from_comp && next == routes[i].to_comp)
+			mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask, 0);
  }
  EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
 
-static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
-{
-	u32 tmp;
-
-	tmp = readl_relaxed(mmsys->regs + offset);
-	tmp = (tmp & ~mask) | val;
-	writel_relaxed(tmp, mmsys->regs + offset);
-}
-
  void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val)
  {
  	if (val)
@@ -161,18 +153,13 @@ static int mtk_mmsys_reset_update(struct reset_controller_dev *rcdev, unsigned l
  {
  	struct mtk_mmsys *mmsys = container_of(rcdev, struct mtk_mmsys, rcdev);
  	unsigned long flags;
-	u32 reg;
 
  	spin_lock_irqsave(&mmsys->lock, flags);
 
-	reg = readl_relaxed(mmsys->regs + mmsys->data->sw0_rst_offset);
-
  	if (assert)
-		reg &= ~BIT(id);
+		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), 0);
  	else
-		reg |= BIT(id);
-
-	writel_relaxed(reg, mmsys->regs + mmsys->data->sw0_rst_offset);
+		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), BIT(id));
 
  	spin_unlock_irqrestore(&mmsys->lock, flags);
 
#17 lore raw

Re: [PATCH v28 05/11] soc: mediatek: refine code to use mtk_mmsys_update_bits API

Quoted 26 lines · Matthias Brugger
Quoted 23 lines · Nancy.Lin

Simplify code for update mmsys reg.

---
  drivers/soc/mediatek/mtk-mmsys.c | 45 ++++++++++++--------------------
  1 file changed, 16 insertions(+), 29 deletions(-)
drivers/soc/mediatek/mtk-mmsys.c +4 -0
index 9a327eb5d9d7..73c8bd27e6ae 100644
@@ -99,22 +99,27 @@ struct mtk_mmsys {
  	struct reset_controller_dev rcdev;
  };
+static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
+{
+	u32 tmp;
+
Quoted 8 lines

drivers/soc/mediatek/mtk-mmsys.c struct mtk_mmsys { · line 107

Quoted 2 lines
drivers/soc/mediatek/mtk-mmsys.c +2 -0
+	tmp = readl_relaxed(mmsys->regs + offset);
+	tmp = (tmp & ~mask) | (val & mask);

I'm not sure about the change in the implementation of mtk_mmsys_update_bits(). Nicolas tried to explain it to me on IRC but I wasn't totally convincing. As we have to go for at least another round of this patches, I'd like to get a clear understanding while it is needed that val bits are set to 1 in the mask.

The point here was to make sure that mtk_mmsys_update_bits() didn't allow setting bits outside of the mask, since that's never what you want: the entire point of having a mask is to specify the bits that should be updated (and the ones that should be kept unchanged). So for example if you had

mask = 0x0ff0
val = 0x00ff

the previous implementation would happily overwrite the 4 least significant bits on the destination register, despite them not being present in the mask, which is wrong.

This wrong behavior could easily lead to hard to trace bugs as soon as a badly formatted/wrong val is passed and an unrelated bit updated due to the mask being ignored.

For reference, _regmap_update_bits() does the same masking of the value [1].

That said, given that this function already existed and was just being moved, it would've been cleaner to make this change in a separate commit.

[1] https://elixir.bootlin.com/linux/latest/source/drivers/base/regmap/regmap.c#L3122

Thanks,
Nícolas

Quoted 6 lines

Regards,
Matthias

Quoted 2 lines
drivers/soc/mediatek/mtk-mmsys.c +2 -0
+	writel_relaxed(tmp, mmsys->regs + offset);
+}

[..]

Quoted 9 lines
Quoted 9 lines
drivers/soc/mediatek/mtk-mmsys.c +0 -9
-static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
-{
-	u32 tmp;
-
-	tmp = readl_relaxed(mmsys->regs + offset);
-	tmp = (tmp & ~mask) | val;
-	writel_relaxed(tmp, mmsys->regs + offset);
-}
-

[..]

maintainer
#18 lore raw

Re: [PATCH v28 05/11] soc: mediatek: refine code to use mtk_mmsys_update_bits API

Quoted 48 lines · Nícolas F. R. A. Prado
Quoted 26 lines · Matthias Brugger
Quoted 23 lines · Nancy.Lin

Simplify code for update mmsys reg.

---
   drivers/soc/mediatek/mtk-mmsys.c | 45 ++++++++++++--------------------
   1 file changed, 16 insertions(+), 29 deletions(-)
drivers/soc/mediatek/mtk-mmsys.c +4 -0
index 9a327eb5d9d7..73c8bd27e6ae 100644
@@ -99,22 +99,27 @@ struct mtk_mmsys {
   	struct reset_controller_dev rcdev;
   };
+static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
+{
+	u32 tmp;
+
Quoted 8 lines

drivers/soc/mediatek/mtk-mmsys.c struct mtk_mmsys { · line 107

Quoted 2 lines
drivers/soc/mediatek/mtk-mmsys.c +2 -0
+	tmp = readl_relaxed(mmsys->regs + offset);
+	tmp = (tmp & ~mask) | (val & mask);

I'm not sure about the change in the implementation of mtk_mmsys_update_bits(). Nicolas tried to explain it to me on IRC but I wasn't totally convincing. As we have to go for at least another round of this patches, I'd like to get a clear understanding while it is needed that val bits are set to 1 in the mask.

The point here was to make sure that mtk_mmsys_update_bits() didn't allow setting bits outside of the mask, since that's never what you want: the entire point of having a mask is to specify the bits that should be updated (and the ones that should be kept unchanged). So for example if you had

mask = 0x0ff0
val = 0x00ff

the previous implementation would happily overwrite the 4 least significant bits on the destination register, despite them not being present in the mask, which is wrong.

Quoted 9 lines

This wrong behavior could easily lead to hard to trace bugs as soon as a badly formatted/wrong val is passed and an unrelated bit updated due to the mask being ignored.

For reference, _regmap_update_bits() does the same masking of the value [1].

That said, given that this function already existed and was just being moved, it would've been cleaner to make this change in a separate commit.

Would have been better, but we can leave it as it.

Regards,
Matthias

Quoted 22 lines

[1] https://elixir.bootlin.com/linux/latest/source/drivers/base/regmap/regmap.c#L3122

Thanks,
Nícolas

Quoted 6 lines

Regards,
Matthias

Quoted 2 lines
drivers/soc/mediatek/mtk-mmsys.c +2 -0
+	writel_relaxed(tmp, mmsys->regs + offset);
+}

[..]

Quoted 9 lines
Quoted 9 lines
drivers/soc/mediatek/mtk-mmsys.c +0 -9
-static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
-{
-	u32 tmp;
-
-	tmp = readl_relaxed(mmsys->regs + offset);
-	tmp = (tmp & ~mask) | val;
-	writel_relaxed(tmp, mmsys->regs + offset);
-}
-

[..]

#19 lore raw

Re: [PATCH v28 05/11] soc: mediatek: refine code to use mtk_mmsys_update_bits API

Dear Matthias,

Thanks for the review.

Quoted 77 lines · Matthias Brugger
Quoted 67 lines · Nícolas F. R. A. Prado
Quoted 34 lines · Matthias Brugger
Quoted 21 lines · Nancy.Lin

Simplify code for update mmsys reg.

Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

Tested-by AngeloGioacchino Del Regno <

[email protected]>

---
   drivers/soc/mediatek/mtk-mmsys.c | 45 ++++++++++++--------
------------
   1 file changed, 16 insertions(+), 29 deletions(-)
drivers/soc/mediatek/mtk-mmsys.c +0 -0
index 9a327eb5d9d7..73c8bd27e6ae 100644

drivers/soc/mediatek/mtk-mmsys.c struct mtk_mmsys { · line 107

Quoted 9 lines
drivers/soc/mediatek/mtk-mmsys.c +6 -0
@@ -99,22 +99,27 @@ struct mtk_mmsys {
   	struct reset_controller_dev rcdev;
   };
+static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32
 offset, u32 mask, u32 val)
+{
+	u32 tmp;
+
+	tmp = readl_relaxed(mmsys->regs + offset);
+	tmp = (tmp & ~mask) | (val & mask);
Quoted 8 lines

I'm not sure about the change in the implementation of mtk_mmsys_update_bits(). Nicolas tried to explain it to me on IRC but I
wasn't totally convincing. As we have to go for at least another round of
this patches, I'd like to get a clear understanding while it is needed that
val bits are set to 1 in the mask.

The point here was to make sure that mtk_mmsys_update_bits() didn't allow
setting bits outside of the mask, since that's never what you want:
the entire
point of having a mask is to specify the bits that should be updated (and the
ones that should be kept unchanged). So for example if you had

mask = 0x0ff0
val = 0x00ff

the previous implementation would happily overwrite the 4 least significant bits
on the destination register, despite them not being present in the mask, which
is wrong.

This wrong behavior could easily lead to hard to trace bugs as soon as a badly
formatted/wrong val is passed and an unrelated bit updated due to the mask being
ignored.

Quoted 7 lines

For reference, _regmap_update_bits() does the same masking of the value [1].

That said, given that this function already existed and was just being moved,
it would've been cleaner to make this change in a separate commit.

Quoted 5 lines

Would have been better, but we can leave it as it.

Regards,
Matthias

Do you mean to keep original one (1), or keep this (2) ?

1. tmp = (tmp & ~mask) | val;
2. tmp = (tmp & ~mask) | (val & mask);

Regards,
Nancy

Quoted 29 lines
Quoted 27 lines

[1]
https://urldefense.com/v3/__https://elixir.bootlin.com/linux/latest/source/drivers/base/regmap/regmap.c*L3122__;Iw!!CTRNKA9wMg0ARbw!xSv5xbY6cv-Mg-1xDGOf3oVZ93uyrcv4tt87DKlx5emjmwufjf2DjION7GiNAaJB$

Thanks,
Nícolas

Quoted 6 lines

Regards,
Matthias

Quoted 2 lines
drivers/soc/mediatek/mtk-mmsys.c +2 -0
+	writel_relaxed(tmp, mmsys->regs + offset);
+}

[..]

Quoted 10 lines
Quoted 10 lines

-static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)

drivers/soc/mediatek/mtk-mmsys.c +0 -8
-{
-	u32 tmp;
-
-	tmp = readl_relaxed(mmsys->regs + offset);
-	tmp = (tmp & ~mask) | val;
-	writel_relaxed(tmp, mmsys->regs + offset);
-}
-

[..]

#20 lore raw

Re: [PATCH v28 05/11] soc: mediatek: refine code to use mtk_mmsys_update_bits API

In reply to Nancy.Lin
Quoted 17 lines · Nancy.Lin

Simplify code for update mmsys reg.

---
 drivers/soc/mediatek/mtk-mmsys.c | 45 ++++++++++++--------------------
 1 file changed, 16 insertions(+), 29 deletions(-)
drivers/soc/mediatek/mtk-mmsys.c +0 -0
index 9a327eb5d9d7..73c8bd27e6ae 100644

[...]

Quoted 20 lines
drivers/soc/mediatek/mtk-mmsys.c +2 -8
@@ -124,27 +129,14 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
 {
        struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
        const struct mtk_mmsys_routes *routes = mmsys->data->routes;
-       u32 reg;
        int i;
 
        for (i = 0; i < mmsys->data->num_routes; i++)
-               if (cur == routes[i].from_comp && next == routes[i].to_comp) {
-                       reg = readl_relaxed(mmsys->regs + routes[i].addr);
-                       reg &= ~routes[i].mask;
-                       writel_relaxed(reg, mmsys->regs + routes[i].addr);
-               }
+               if (cur == routes[i].from_comp && next == routes[i].to_comp)
+                       mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask, 0);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
 
-static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
-{

drivers/soc/mediatek/mtk-mmsys.c void mtk_mmsys_ddp_disconnect(struct device *dev, · line 142

Quoted 10 lines
drivers/soc/mediatek/mtk-mmsys.c +0 -7
-       u32 tmp;
-
-       tmp = readl_relaxed(mmsys->regs + offset);
-       tmp = (tmp & ~mask) | val;
-       writel_relaxed(tmp, mmsys->regs + offset);
-}
-
 void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val)
 {
        if (val)

This hunk now doesn't apply due to

soc: mediatek: Add all settings to mtk_mmsys_ddp_dpi_fmt_config func

touching mtk_mmsys_ddp_dpi_fmt_config() as well. It's trivial to resolve though.

ChenYu

#21 lore raw

Re: [PATCH v28 05/11] soc: mediatek: refine code to use mtk_mmsys_update_bits API

Dear Chen-Yu,

Sorry for late response and thanks for the review.

Quoted 67 lines · Chen-Yu Tsai
Quoted 21 lines · Nancy.Lin

Simplify code for update mmsys reg.

Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

Tested-by AngeloGioacchino Del Regno <

[email protected]>

---
 drivers/soc/mediatek/mtk-mmsys.c | 45 ++++++++++++--------------
------
 1 file changed, 16 insertions(+), 29 deletions(-)
drivers/soc/mediatek/mtk-mmsys.c +0 -0
index 9a327eb5d9d7..73c8bd27e6ae 100644

[...]

Quoted 28 lines
drivers/soc/mediatek/mtk-mmsys.c +2 -6
@@ -124,27 +129,14 @@ void mtk_mmsys_ddp_disconnect(struct device
 *dev,
 {
        struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
        const struct mtk_mmsys_routes *routes = mmsys->data-
 >routes;
-       u32 reg;
        int i;
 
        for (i = 0; i < mmsys->data->num_routes; i++)
-               if (cur == routes[i].from_comp && next ==
 routes[i].to_comp) {
-                       reg = readl_relaxed(mmsys->regs +
 routes[i].addr);
-                       reg &= ~routes[i].mask;
-                       writel_relaxed(reg, mmsys->regs +
 routes[i].addr);
-               }
+               if (cur == routes[i].from_comp && next ==
 routes[i].to_comp)
+                       mtk_mmsys_update_bits(mmsys,

routes[i].addr, routes[i].mask, 0);
}
EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);

-static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)

drivers/soc/mediatek/mtk-mmsys.c +0 -1
-{

drivers/soc/mediatek/mtk-mmsys.c void mtk_mmsys_ddp_disconnect(struct device *dev, · line 142

Quoted 10 lines
drivers/soc/mediatek/mtk-mmsys.c +0 -7
-       u32 tmp;
-
-       tmp = readl_relaxed(mmsys->regs + offset);
-       tmp = (tmp & ~mask) | val;
-       writel_relaxed(tmp, mmsys->regs + offset);
-}
-
 void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val)
 {
        if (val)

This hunk now doesn't apply due to

Quoted 8 lines

soc: mediatek: Add all settings to mtk_mmsys_ddp_dpi_fmt_config
func

touching mtk_mmsys_ddp_dpi_fmt_config() as well. It's trivial to resolve
though.

ChenYu

I will update next revision base on next-20221226 which include the patch you mentioned.

Regards,
Nancy

author
#22 lore raw

PATCH v28 6/11 soc: mediatek: add mtk-mmsys config API for mt8195 vdosys1

In reply to Nancy.Lin

Add four mmsys config APIs. The config APIs are used for config mmsys reg. Some mmsys regs need to be set according to the HW engine binding to the mmsys simultaneously.

1. mtk_mmsys_merge_async_config: config merge async width/height. async is used for cross-clock domain synchronization.
2. mtk_mmsys_hdr_confing: config hdr backend async width/height.
3. mtk_mmsys_mixer_in_config and mtk_mmsys_mixer_in_config:
config mixer related settings.

---
 drivers/soc/mediatek/mt8195-mmsys.h    |  6 +++++
 drivers/soc/mediatek/mtk-mmsys.c       | 35 ++++++++++++++++++++++++++
 include/linux/soc/mediatek/mtk-mmsys.h |  9 +++++++
 3 files changed, 50 insertions(+)
drivers/soc/mediatek/mt8195-mmsys.h +6 -0
index fd7b455bd675..454944a9409c 100644
@@ -75,6 +75,12 @@
 #define MT8195_SOUT_DSC_WRAP1_OUT_TO_SINA_VIRTUAL0		(2 << 16)
 #define MT8195_SOUT_DSC_WRAP1_OUT_TO_VPP_MERGE			(3 << 16)
 
+#define MT8195_VDO1_MERGE0_ASYNC_CFG_WD				0xe30
+#define MT8195_VDO1_HDRBE_ASYNC_CFG_WD				0xe70
+#define MT8195_VDO1_HDR_TOP_CFG					0xd00
+#define MT8195_VDO1_MIXER_IN1_ALPHA				0xd30
+#define MT8195_VDO1_MIXER_IN1_PAD				0xd40
+
 #define MT8195_VDO1_VPP_MERGE0_P0_SEL_IN			0xf04
 #define MT8195_VPP_MERGE0_P0_SEL_IN_FROM_MDP_RDMA0			1
 
drivers/soc/mediatek/mtk-mmsys.c +35 -0
index 73c8bd27e6ae..6040a3cff6f8 100644
@@ -137,6 +137,41 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
 
+void mtk_mmsys_merge_async_config(struct device *dev, int idx, int width, int height)
+{
+	mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_MERGE0_ASYNC_CFG_WD + 0x10 * idx,
+			      ~0, height << 16 | width);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_merge_async_config);
+
+void mtk_mmsys_hdr_config(struct device *dev, int be_width, int be_height)
+{
+	mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_HDRBE_ASYNC_CFG_WD, ~0,
+			      be_height << 16 | be_width);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_hdr_config);
+
+void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16 alpha,
+			       u8 mode, u32 biwidth)
+{
+	struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
+
+	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_ALPHA + (idx - 1) * 4, ~0,
+			      alpha << 16 | alpha);
+	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_HDR_TOP_CFG, BIT(19 + idx),
+			      alpha_sel << (19 + idx));
+	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_PAD + (idx - 1) * 4,
+			      GENMASK(31, 16) | GENMASK(1, 0), biwidth << 16 | mode);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_mixer_in_config);
+
+void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx, bool channel_swap)
+{
+	mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_MIXER_IN1_PAD + (idx - 1) * 4,
+			      BIT(4), channel_swap << 4);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_mixer_in_channel_swap);
+
 void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val)
 {
 	if (val)
include/linux/soc/mediatek/mtk-mmsys.h +9 -0
index 127f1b888ace..a4708859c188 100644
@@ -75,4 +75,13 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
 
 void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val);
 
+void mtk_mmsys_merge_async_config(struct device *dev, int idx, int width, int height);
+
+void mtk_mmsys_hdr_config(struct device *dev, int be_width, int be_height);
+
+void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16 alpha,
+			       u8 mode, u32 biwidth);
+
+void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx, bool channel_swap);
+
 #endif /* __MTK_MMSYS_H */
Signature · 1 line
2.18.0
maintainer
#23 lore raw

Re: [PATCH v28 06/11] soc: mediatek: add mtk-mmsys config API for mt8195 vdosys1

Quoted 10 lines · Nancy.Lin

Add four mmsys config APIs. The config APIs are used for config mmsys reg. Some mmsys regs need to be set according to the HW engine binding to the mmsys simultaneously.

1. mtk_mmsys_merge_async_config: config merge async width/height. async is used for cross-clock domain synchronization.
2. mtk_mmsys_hdr_confing: config hdr backend async width/height.
3. mtk_mmsys_mixer_in_config and mtk_mmsys_mixer_in_config:
config mixer related settings.

Quoted 5 lines

Not something we need to fix in this series, but it would make sense instead of adding all the EXPORTS to pass the functions as callbacks in the platform_device_register_data. But I realize you don't pass the VDOSYS number to the DRM driver to distinguish between the different MMSYS devices that created the platform device. I hadn't had a deep look on the DRM implementation but I suppose it will be challenge...

Regards,
Matthias

Quoted 87 lines
---
  drivers/soc/mediatek/mt8195-mmsys.h    |  6 +++++
  drivers/soc/mediatek/mtk-mmsys.c       | 35 ++++++++++++++++++++++++++
  include/linux/soc/mediatek/mtk-mmsys.h |  9 +++++++
  3 files changed, 50 insertions(+)
drivers/soc/mediatek/mt8195-mmsys.h +6 -0
index fd7b455bd675..454944a9409c 100644
@@ -75,6 +75,12 @@
  #define MT8195_SOUT_DSC_WRAP1_OUT_TO_SINA_VIRTUAL0		(2 << 16)
  #define MT8195_SOUT_DSC_WRAP1_OUT_TO_VPP_MERGE			(3 << 16)
 
+#define MT8195_VDO1_MERGE0_ASYNC_CFG_WD				0xe30
+#define MT8195_VDO1_HDRBE_ASYNC_CFG_WD				0xe70
+#define MT8195_VDO1_HDR_TOP_CFG					0xd00
+#define MT8195_VDO1_MIXER_IN1_ALPHA				0xd30
+#define MT8195_VDO1_MIXER_IN1_PAD				0xd40
+
  #define MT8195_VDO1_VPP_MERGE0_P0_SEL_IN			0xf04
  #define MT8195_VPP_MERGE0_P0_SEL_IN_FROM_MDP_RDMA0			1
 
drivers/soc/mediatek/mtk-mmsys.c +35 -0
index 73c8bd27e6ae..6040a3cff6f8 100644
@@ -137,6 +137,41 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
  }
  EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
 
+void mtk_mmsys_merge_async_config(struct device *dev, int idx, int width, int height)
+{
+	mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_MERGE0_ASYNC_CFG_WD + 0x10 * idx,
+			      ~0, height << 16 | width);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_merge_async_config);
+
+void mtk_mmsys_hdr_config(struct device *dev, int be_width, int be_height)
+{
+	mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_HDRBE_ASYNC_CFG_WD, ~0,
+			      be_height << 16 | be_width);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_hdr_config);
+
+void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16 alpha,
+			       u8 mode, u32 biwidth)
+{
+	struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
+
+	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_ALPHA + (idx - 1) * 4, ~0,
+			      alpha << 16 | alpha);
+	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_HDR_TOP_CFG, BIT(19 + idx),
+			      alpha_sel << (19 + idx));
+	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_PAD + (idx - 1) * 4,
+			      GENMASK(31, 16) | GENMASK(1, 0), biwidth << 16 | mode);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_mixer_in_config);
+
+void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx, bool channel_swap)
+{
+	mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_MIXER_IN1_PAD + (idx - 1) * 4,
+			      BIT(4), channel_swap << 4);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_mixer_in_channel_swap);
+
  void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val)
  {
  	if (val)
include/linux/soc/mediatek/mtk-mmsys.h +9 -0
index 127f1b888ace..a4708859c188 100644
@@ -75,4 +75,13 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
 
  void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val);
 
+void mtk_mmsys_merge_async_config(struct device *dev, int idx, int width, int height);
+
+void mtk_mmsys_hdr_config(struct device *dev, int be_width, int be_height);
+
+void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16 alpha,
+			       u8 mode, u32 biwidth);
+
+void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx, bool channel_swap);
+
  #endif /* __MTK_MMSYS_H */
#24 lore raw

Re: [PATCH v28 06/11] soc: mediatek: add mtk-mmsys config API for mt8195 vdosys1

Dear Matthias,

Thanks for the review.

Quoted 31 lines · Matthias Brugger
Quoted 10 lines · Nancy.Lin

Add four mmsys config APIs. The config APIs are used for config mmsys reg. Some mmsys regs need to be set according to the HW engine binding to the mmsys simultaneously.

1. mtk_mmsys_merge_async_config: config merge async width/height. async is used for cross-clock domain synchronization.
2. mtk_mmsys_hdr_confing: config hdr backend async width/height.
3. mtk_mmsys_mixer_in_config and mtk_mmsys_mixer_in_config:
config mixer related settings.

Quoted 7 lines
Reviewed-by AngeloGioacchino Del Regno <

[email protected]>

Tested-by AngeloGioacchino Del Regno <

[email protected]>

Not something we need to fix in this series, but it would make sense instead of
adding all the EXPORTS to pass the functions as callbacks in the platform_device_register_data. But I realize you don't pass the VDOSYS number to
the DRM driver to distinguish between the different MMSYS devices that created
the platform device. I hadn't had a deep look on the DRM implementation but I
suppose it will be challenge...

Quoted 3 lines

Regards,
Matthias

Do you mean to move all the mmsys config APIs as callback in mmsys driver data?
If so, not only the four mmsys config APIs in this patch but also the following original three APIs.
It would take some refactoring effort. I think it would be better to change this after this series for vdosys1 if needed.

1. mtk_mmsys_ddp_connect
2. mtk_mmsys_ddp_disconnect
3. mtk_mmsys_ddp_dpi_fmt_config

Regards,
Nancy

Quoted 115 lines
Quoted 115 lines
---
  drivers/soc/mediatek/mt8195-mmsys.h    |  6 +++++
  drivers/soc/mediatek/mtk-mmsys.c       | 35
++++++++++++++++++++++++++
  include/linux/soc/mediatek/mtk-mmsys.h |  9 +++++++
  3 files changed, 50 insertions(+)
drivers/soc/mediatek/mt8195-mmsys.h +1 -0
index fd7b455bd675..454944a9409c 100644
@@ -75,6 +75,12 @@
  #define MT8195_SOUT_DSC_WRAP1_OUT_TO_SINA_VIRTUAL0		
 (2 << 16)
  #define MT8195_SOUT_DSC_WRAP1_OUT_TO_VPP_MERGE			
 (3 << 16)
 
+#define MT8195_VDO1_MERGE0_ASYNC_CFG_WD				

0xe30
+#define MT8195_VDO1_HDRBE_ASYNC_CFG_WD
0xe70
+#define MT8195_VDO1_HDR_TOP_CFG
0xd00
+#define MT8195_VDO1_MIXER_IN1_ALPHA
0xd30

drivers/soc/mediatek/mt8195-mmsys.h +2 -0
+#define MT8195_VDO1_MIXER_IN1_PAD				0xd40
+
  #define MT8195_VDO1_VPP_MERGE0_P0_SEL_IN			0xf04
  #define MT8195_VPP_MERGE0_P0_SEL_IN_FROM_MDP_RDMA0		
	1
drivers/soc/mediatek/mtk-mmsys.c +8 -0
index 73c8bd27e6ae..6040a3cff6f8 100644
@@ -137,6 +137,41 @@ void mtk_mmsys_ddp_disconnect(struct device
 *dev,
  }
  EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
 
+void mtk_mmsys_merge_async_config(struct device *dev, int idx, int
 width, int height)
+{
+	mtk_mmsys_update_bits(dev_get_drvdata(dev),
 MT8195_VDO1_MERGE0_ASYNC_CFG_WD + 0x10 * idx,
+			      ~0, height << 16 | width);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_merge_async_config);
+
+void mtk_mmsys_hdr_config(struct device *dev, int be_width, int

be_height)

drivers/soc/mediatek/mtk-mmsys.c +2 -0
+{
+	mtk_mmsys_update_bits(dev_get_drvdata(dev),

MT8195_VDO1_HDRBE_ASYNC_CFG_WD, ~0,

drivers/soc/mediatek/mtk-mmsys.c +5 -0
+			      be_height << 16 | be_width);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_hdr_config);
+
+void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool

alpha_sel, u16 alpha,

drivers/soc/mediatek/mtk-mmsys.c +7 -1
+			       u8 mode, u32 biwidth)
+{
+	struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
+
+	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_ALPHA + (idx
- 1) * 4, ~0,
+			      alpha << 16 | alpha);
+	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_HDR_TOP_CFG, BIT(19 +

idx),

drivers/soc/mediatek/mtk-mmsys.c +2 -0
+			      alpha_sel << (19 + idx));
+	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_PAD + (idx -

1) * 4,

drivers/soc/mediatek/mtk-mmsys.c +1 -0
+			      GENMASK(31, 16) | GENMASK(1, 0), biwidth

<< 16 | mode);

drivers/soc/mediatek/mtk-mmsys.c +4 -0
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_mixer_in_config);
+
+void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx,

bool channel_swap)

drivers/soc/mediatek/mtk-mmsys.c +2 -0
+{
+	mtk_mmsys_update_bits(dev_get_drvdata(dev),

MT8195_VDO1_MIXER_IN1_PAD + (idx - 1) * 4,

drivers/soc/mediatek/mtk-mmsys.c +4 -0
+			      BIT(4), channel_swap << 4);
+}
+EXPORT_SYMBOL_GPL(mtk_mmsys_mixer_in_channel_swap);
+
  void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val)
  {
  	if (val)
include/linux/soc/mediatek/mtk-mmsys.h +1 -0
index 127f1b888ace..a4708859c188 100644
@@ -75,4 +75,13 @@ void mtk_mmsys_ddp_disconnect(struct device
 *dev,
 
  void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val);
 
+void mtk_mmsys_merge_async_config(struct device *dev, int idx, int

width, int height);

include/linux/soc/mediatek/mtk-mmsys.h +2 -0
+
+void mtk_mmsys_hdr_config(struct device *dev, int be_width, int

be_height);

include/linux/soc/mediatek/mtk-mmsys.h +2 -0
+
+void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool

alpha_sel, u16 alpha,

include/linux/soc/mediatek/mtk-mmsys.h +3 -0
+			       u8 mode, u32 biwidth);
+
+void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx,

bool channel_swap);
+
#endif /* __MTK_MMSYS_H */

author
#25 lore raw

PATCH v28 7/11 soc: mediatek: add cmdq support of mtk-mmsys config API for mt8195 vdosys1

In reply to Nancy.Lin

Add cmdq support for mtk-mmsys config API.
The mmsys config register settings need to take effect with the other HW settings(like OVL_ADAPTOR...) at the same vblanking time.

If we use CPU to write the mmsys reg, we can't guarantee all the settings can be written in the same vblanking time.
Cmdq is used for this purpose. We prepare all the related HW settings in one cmdq packet. The first command in the packet is "wait stream done", and then following with all the HW settings. After the cmdq packet is flush to GCE HW. The GCE waits for the "stream done event" to coming and then starts flushing all the HW settings. This can guarantee all the settings flush in the same vblanking.

---
 drivers/soc/mediatek/mtk-mmsys.c       | 59 ++++++++++++++++++--------
 include/linux/soc/mediatek/mtk-mmsys.h | 15 +++++--
 2 files changed, 53 insertions(+), 21 deletions(-)
drivers/soc/mediatek/mtk-mmsys.c +42 -17
index 6040a3cff6f8..1bd2f8e45d85 100644
@@ -97,12 +97,27 @@ struct mtk_mmsys {
 	const struct mtk_mmsys_driver_data *data;
 	spinlock_t lock; /* protects mmsys_sw_rst_b reg */
 	struct reset_controller_dev rcdev;
+	struct cmdq_client_reg cmdq_base;
 };
 
-static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val)
+static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val,
+				  struct cmdq_pkt *cmdq_pkt)
 {
 	u32 tmp;
 
+#if IS_REACHABLE(CONFIG_MTK_CMDQ)
+	if (cmdq_pkt) {
+		if (mmsys->cmdq_base.size == 0) {
+			pr_err("mmsys lose gce property, failed to update mmsys bits with cmdq");
+			return;
+		}
+		cmdq_pkt_write_mask(cmdq_pkt, mmsys->cmdq_base.subsys,
+				    mmsys->cmdq_base.offset + offset, val,
+				    mask);
+		return;
+	}
+#endif
+
 	tmp = readl_relaxed(mmsys->regs + offset);
 	tmp = (tmp & ~mask) | (val & mask);
 	writel_relaxed(tmp, mmsys->regs + offset);
@@ -119,7 +134,7 @@ void mtk_mmsys_ddp_connect(struct device *dev,
 	for (i = 0; i < mmsys->data->num_routes; i++)
 		if (cur == routes[i].from_comp && next == routes[i].to_comp)
 			mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask,
-					      routes[i].val);
+					      routes[i].val, NULL);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_connect);
 
@@ -133,42 +148,45 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
 
 	for (i = 0; i < mmsys->data->num_routes; i++)
 		if (cur == routes[i].from_comp && next == routes[i].to_comp)
-			mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask, 0);
+			mtk_mmsys_update_bits(mmsys, routes[i].addr, routes[i].mask, 0, NULL);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_disconnect);
 
-void mtk_mmsys_merge_async_config(struct device *dev, int idx, int width, int height)
+void mtk_mmsys_merge_async_config(struct device *dev, int idx, int width, int height,
+				  struct cmdq_pkt *cmdq_pkt)
 {
 	mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_MERGE0_ASYNC_CFG_WD + 0x10 * idx,
-			      ~0, height << 16 | width);
+			      ~0, height << 16 | width, cmdq_pkt);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_merge_async_config);
 
-void mtk_mmsys_hdr_config(struct device *dev, int be_width, int be_height)
+void mtk_mmsys_hdr_config(struct device *dev, int be_width, int be_height,
+			  struct cmdq_pkt *cmdq_pkt)
 {
 	mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_HDRBE_ASYNC_CFG_WD, ~0,
-			      be_height << 16 | be_width);
+			      be_height << 16 | be_width, cmdq_pkt);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_hdr_config);
 
 void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16 alpha,
-			       u8 mode, u32 biwidth)
+			       u8 mode, u32 biwidth, struct cmdq_pkt *cmdq_pkt)
 {
 	struct mtk_mmsys *mmsys = dev_get_drvdata(dev);
 
 	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_ALPHA + (idx - 1) * 4, ~0,
-			      alpha << 16 | alpha);
+			      alpha << 16 | alpha, cmdq_pkt);
 	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_HDR_TOP_CFG, BIT(19 + idx),
-			      alpha_sel << (19 + idx));
+			      alpha_sel << (19 + idx), cmdq_pkt);
 	mtk_mmsys_update_bits(mmsys, MT8195_VDO1_MIXER_IN1_PAD + (idx - 1) * 4,
-			      GENMASK(31, 16) | GENMASK(1, 0), biwidth << 16 | mode);
+			      GENMASK(31, 16) | GENMASK(1, 0), biwidth << 16 | mode, cmdq_pkt);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_mixer_in_config);
 
-void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx, bool channel_swap)
+void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx, bool channel_swap,
+				     struct cmdq_pkt *cmdq_pkt)
 {
 	mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8195_VDO1_MIXER_IN1_PAD + (idx - 1) * 4,
-			      BIT(4), channel_swap << 4);
+			      BIT(4), channel_swap << 4, cmdq_pkt);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_mixer_in_channel_swap);
 
@@ -176,10 +194,10 @@ void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val)
 {
 	if (val)
 		mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8186_MMSYS_DPI_OUTPUT_FORMAT,
-				      DPI_RGB888_DDR_CON, DPI_FORMAT_MASK);
+				      DPI_RGB888_DDR_CON, DPI_FORMAT_MASK, NULL);
 	else
 		mtk_mmsys_update_bits(dev_get_drvdata(dev), MT8186_MMSYS_DPI_OUTPUT_FORMAT,
-				      DPI_RGB565_SDR_CON, DPI_FORMAT_MASK);
+				      DPI_RGB565_SDR_CON, DPI_FORMAT_MASK, NULL);
 }
 EXPORT_SYMBOL_GPL(mtk_mmsys_ddp_dpi_fmt_config);
 
@@ -192,9 +210,9 @@ static int mtk_mmsys_reset_update(struct reset_controller_dev *rcdev, unsigned l
 	spin_lock_irqsave(&mmsys->lock, flags);
 
 	if (assert)
-		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), 0);
+		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), 0, NULL);
 	else
-		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), BIT(id));
+		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), BIT(id), NULL);
 
 	spin_unlock_irqrestore(&mmsys->lock, flags);
 
@@ -262,6 +280,13 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
 	}
 
 	mmsys->data = of_device_get_match_data(&pdev->dev);
+
+#if IS_REACHABLE(CONFIG_MTK_CMDQ)
+	ret = cmdq_dev_get_client_reg(dev, &mmsys->cmdq_base, 0);
+	if (ret)
+		dev_dbg(dev, "No mediatek,gce-client-reg!\n");
+#endif
+
 	platform_set_drvdata(pdev, mmsys);
 
 	clks = platform_device_register_data(&pdev->dev, mmsys->data->clk_driver,
include/linux/soc/mediatek/mtk-mmsys.h +11 -4
index a4708859c188..37296146ac5a 100644
@@ -6,6 +6,10 @@
 #ifndef __MTK_MMSYS_H
 #define __MTK_MMSYS_H
 
+#include <linux/mailbox_controller.h>
+#include <linux/mailbox/mtk-cmdq-mailbox.h>
+#include <linux/soc/mediatek/mtk-cmdq.h>
+
 enum mtk_ddp_comp_id;
 struct device;
 
@@ -75,13 +79,16 @@ void mtk_mmsys_ddp_disconnect(struct device *dev,
 
 void mtk_mmsys_ddp_dpi_fmt_config(struct device *dev, u32 val);
 
-void mtk_mmsys_merge_async_config(struct device *dev, int idx, int width, int height);
+void mtk_mmsys_merge_async_config(struct device *dev, int idx, int width,
+				  int height, struct cmdq_pkt *cmdq_pkt);
 
-void mtk_mmsys_hdr_config(struct device *dev, int be_width, int be_height);
+void mtk_mmsys_hdr_config(struct device *dev, int be_width, int be_height,
+			  struct cmdq_pkt *cmdq_pkt);
 
 void mtk_mmsys_mixer_in_config(struct device *dev, int idx, bool alpha_sel, u16 alpha,
-			       u8 mode, u32 biwidth);
+			       u8 mode, u32 biwidth, struct cmdq_pkt *cmdq_pkt);
 
-void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx, bool channel_swap);
+void mtk_mmsys_mixer_in_channel_swap(struct device *dev, int idx, bool channel_swap,
+				     struct cmdq_pkt *cmdq_pkt);
 
 #endif /* __MTK_MMSYS_H */
Signature · 1 line
2.18.0
author
#26 lore raw

PATCH v28 8/11 soc: mediatek: mmsys: add mmsys for support 64 reset bits

In reply to Nancy.Lin

Add mmsys for support 64 reset bits. It is a preparation for MT8195 vdosys1 HW reset. MT8195 vdosys1 has more than 32 reset bits.

1. Add the number of reset bits in mmsys private data
2. move the whole "reset register code section" behind the "get mmsys->data" code section for getting the num_resets in mmsys->data.

---
 drivers/soc/mediatek/mtk-mmsys.c | 40 +++++++++++++++++++++-----------
 drivers/soc/mediatek/mtk-mmsys.h |  1 +
 2 files changed, 28 insertions(+), 13 deletions(-)
drivers/soc/mediatek/mtk-mmsys.c +27 -13
index 1bd2f8e45d85..78601372512f 100644
@@ -20,6 +20,8 @@
 #include "mt8195-mmsys.h"
 #include "mt8365-mmsys.h"
 
+#define MMSYS_SW_RESET_PER_REG 32
+
 static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = {
 	.clk_driver = "clk-mt2701-mm",
 	.routes = mmsys_default_routing_table,
@@ -51,6 +53,7 @@ static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
 	.routes = mmsys_default_routing_table,
 	.num_routes = ARRAY_SIZE(mmsys_default_routing_table),
 	.sw0_rst_offset = MT8183_MMSYS_SW0_RST_B,
+	.num_resets = 32,
 };
 
 static const struct mtk_mmsys_driver_data mt8183_mmsys_driver_data = {
@@ -58,6 +61,7 @@ static const struct mtk_mmsys_driver_data mt8183_mmsys_driver_data = {
 	.routes = mmsys_mt8183_routing_table,
 	.num_routes = ARRAY_SIZE(mmsys_mt8183_routing_table),
 	.sw0_rst_offset = MT8183_MMSYS_SW0_RST_B,
+	.num_resets = 32,
 };
 
 static const struct mtk_mmsys_driver_data mt8186_mmsys_driver_data = {
@@ -65,6 +69,7 @@ static const struct mtk_mmsys_driver_data mt8186_mmsys_driver_data = {
 	.routes = mmsys_mt8186_routing_table,
 	.num_routes = ARRAY_SIZE(mmsys_mt8186_routing_table),
 	.sw0_rst_offset = MT8186_MMSYS_SW0_RST_B,
+	.num_resets = 32,
 };
 
 static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = {
@@ -72,6 +77,7 @@ static const struct mtk_mmsys_driver_data mt8192_mmsys_driver_data = {
 	.routes = mmsys_mt8192_routing_table,
 	.num_routes = ARRAY_SIZE(mmsys_mt8192_routing_table),
 	.sw0_rst_offset = MT8186_MMSYS_SW0_RST_B,
+	.num_resets = 32,
 };
 
 static const struct mtk_mmsys_driver_data mt8195_vdosys0_driver_data = {
@@ -206,13 +212,19 @@ static int mtk_mmsys_reset_update(struct reset_controller_dev *rcdev, unsigned l
 {
 	struct mtk_mmsys *mmsys = container_of(rcdev, struct mtk_mmsys, rcdev);
 	unsigned long flags;
+	u32 offset;
+	u32 reg;
+
+	offset = (id / MMSYS_SW_RESET_PER_REG) * sizeof(u32);
+	id = id % MMSYS_SW_RESET_PER_REG;
+	reg = mmsys->data->sw0_rst_offset + offset;
 
 	spin_lock_irqsave(&mmsys->lock, flags);
 
 	if (assert)
-		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), 0, NULL);
+		mtk_mmsys_update_bits(mmsys, reg, BIT(id), 0, NULL);
 	else
-		mtk_mmsys_update_bits(mmsys, mmsys->data->sw0_rst_offset, BIT(id), BIT(id), NULL);
+		mtk_mmsys_update_bits(mmsys, reg, BIT(id), BIT(id), NULL);
 
 	spin_unlock_irqrestore(&mmsys->lock, flags);
 
@@ -267,20 +279,22 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	spin_lock_init(&mmsys->lock);
+	mmsys->data = of_device_get_match_data(&pdev->dev);
 
-	mmsys->rcdev.owner = THIS_MODULE;
-	mmsys->rcdev.nr_resets = 32;
-	mmsys->rcdev.ops = &mtk_mmsys_reset_ops;
-	mmsys->rcdev.of_node = pdev->dev.of_node;
-	ret = devm_reset_controller_register(&pdev->dev, &mmsys->rcdev);
-	if (ret) {
-		dev_err(&pdev->dev, "Couldn't register mmsys reset controller: %d\n", ret);
-		return ret;
+	if (mmsys->data->num_resets > 0) {
+		spin_lock_init(&mmsys->lock);
+
+		mmsys->rcdev.owner = THIS_MODULE;
+		mmsys->rcdev.nr_resets = mmsys->data->num_resets;
+		mmsys->rcdev.ops = &mtk_mmsys_reset_ops;
+		mmsys->rcdev.of_node = pdev->dev.of_node;
+		ret = devm_reset_controller_register(&pdev->dev, &mmsys->rcdev);
+		if (ret) {
+			dev_err(&pdev->dev, "Couldn't register mmsys reset controller: %d\n", ret);
+			return ret;
+		}
 	}
 
-	mmsys->data = of_device_get_match_data(&pdev->dev);
-
 #if IS_REACHABLE(CONFIG_MTK_CMDQ)
 	ret = cmdq_dev_get_client_reg(dev, &mmsys->cmdq_base, 0);
 	if (ret)
drivers/soc/mediatek/mtk-mmsys.h +1 -0
index 77f37f8c715b..e19994749adb 100644
@@ -91,6 +91,7 @@ struct mtk_mmsys_driver_data {
 	const struct mtk_mmsys_routes *routes;
 	const unsigned int num_routes;
 	const u16 sw0_rst_offset;
+	const u32 num_resets;
 };
 
 /*
Signature · 1 line
2.18.0
author
#27 lore raw

PATCH v28 9/11 soc: mediatek: mmsys: add reset control for MT8195 vdosys1

In reply to Nancy.Lin

MT8195 vdosys1 has more than 32 reset bits and a different reset base than other chips. Add the number of reset bits and reset base in mmsys private data.

---
 drivers/soc/mediatek/mt8195-mmsys.h | 1 +
 drivers/soc/mediatek/mtk-mmsys.c    | 2 ++
 2 files changed, 3 insertions(+)
drivers/soc/mediatek/mt8195-mmsys.h +1 -0
index 454944a9409c..a6652ae63431 100644
@@ -75,6 +75,7 @@
 #define MT8195_SOUT_DSC_WRAP1_OUT_TO_SINA_VIRTUAL0		(2 << 16)
 #define MT8195_SOUT_DSC_WRAP1_OUT_TO_VPP_MERGE			(3 << 16)
 
+#define MT8195_VDO1_SW0_RST_B					0x1d0
 #define MT8195_VDO1_MERGE0_ASYNC_CFG_WD				0xe30
 #define MT8195_VDO1_HDRBE_ASYNC_CFG_WD				0xe70
 #define MT8195_VDO1_HDR_TOP_CFG					0xd00
drivers/soc/mediatek/mtk-mmsys.c +2 -0
index 78601372512f..5278edd032c6 100644
@@ -90,6 +90,8 @@ static const struct mtk_mmsys_driver_data mt8195_vdosys1_driver_data = {
 	.clk_driver = "clk-mt8195-vdo1",
 	.routes = mmsys_mt8195_vdo1_routing_table,
 	.num_routes = ARRAY_SIZE(mmsys_mt8195_vdo1_routing_table),
+	.sw0_rst_offset = MT8195_VDO1_SW0_RST_B,
+	.num_resets = 64,
 };
 
 static const struct mtk_mmsys_driver_data mt8365_mmsys_driver_data = {
Signature · 1 line
2.18.0
author
#28 lore raw

PATCH v28 10/11 soc: mediatek: add mtk-mutex component - dp_intf1

In reply to Nancy.Lin

Add mtk-mutex DDP_COMPONENT_DP_INTF1 component. The MT8195 vdosys1 path component contains ovl_adaptor, merge5, and dp_intf1. It is a preparation for adding support for MT8195 vdosys1 path component.

---
 drivers/soc/mediatek/mtk-mutex.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/soc/mediatek/mtk-mutex.c +4 -0
index c1a33d52038e..41cba6aa0e83 100644
@@ -602,6 +602,9 @@ void mtk_mutex_add_comp(struct mtk_mutex *mutex,
 	case DDP_COMPONENT_DP_INTF0:
 		sof_id = MUTEX_SOF_DP_INTF0;
 		break;
+	case DDP_COMPONENT_DP_INTF1:
+		sof_id = MUTEX_SOF_DP_INTF1;
+		break;
 	default:
 		if (mtx->data->mutex_mod[id] < 32) {
 			offset = DISP_REG_MUTEX_MOD(mtx->data->mutex_mod_reg,
@@ -642,6 +645,7 @@ void mtk_mutex_remove_comp(struct mtk_mutex *mutex,
 	case DDP_COMPONENT_DPI0:
 	case DDP_COMPONENT_DPI1:
 	case DDP_COMPONENT_DP_INTF0:
+	case DDP_COMPONENT_DP_INTF1:
 		writel_relaxed(MUTEX_SOF_SINGLE_MODE,
 			       mtx->regs +
 			       DISP_REG_MUTEX_SOF(mtx->data->mutex_sof_reg,
Signature · 1 line
2.18.0
author
#29 lore raw

PATCH v28 11/11 soc: mediatek: add mtk-mutex support for mt8195 vdosys1

In reply to Nancy.Lin

Add mtk-mutex support for mt8195 vdosys1.
The vdosys1 path component contains ovl_adaptor, merge5, and dp_intf1. Ovl_adaptor is composed of several sub-elements which include MDP_RDMA0~7, MERGE0~3, and ETHDR.

---
 drivers/soc/mediatek/mtk-mutex.c | 33 ++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
drivers/soc/mediatek/mtk-mutex.c +33 -0
index 41cba6aa0e83..8d0eb70690e5 100644
@@ -130,6 +130,24 @@
 #define MT8195_MUTEX_MOD_DISP_DP_INTF0		21
 #define MT8195_MUTEX_MOD_DISP_PWM0		27
 
+#define MT8195_MUTEX_MOD_DISP1_MDP_RDMA0	0
+#define MT8195_MUTEX_MOD_DISP1_MDP_RDMA1	1
+#define MT8195_MUTEX_MOD_DISP1_MDP_RDMA2	2
+#define MT8195_MUTEX_MOD_DISP1_MDP_RDMA3	3
+#define MT8195_MUTEX_MOD_DISP1_MDP_RDMA4	4
+#define MT8195_MUTEX_MOD_DISP1_MDP_RDMA5	5
+#define MT8195_MUTEX_MOD_DISP1_MDP_RDMA6	6
+#define MT8195_MUTEX_MOD_DISP1_MDP_RDMA7	7
+#define MT8195_MUTEX_MOD_DISP1_VPP_MERGE0	8
+#define MT8195_MUTEX_MOD_DISP1_VPP_MERGE1	9
+#define MT8195_MUTEX_MOD_DISP1_VPP_MERGE2	10
+#define MT8195_MUTEX_MOD_DISP1_VPP_MERGE3	11
+#define MT8195_MUTEX_MOD_DISP1_VPP_MERGE4	12
+#define MT8195_MUTEX_MOD_DISP1_DISP_MIXER	18
+#define MT8195_MUTEX_MOD_DISP1_DPI0		25
+#define MT8195_MUTEX_MOD_DISP1_DPI1		26
+#define MT8195_MUTEX_MOD_DISP1_DP_INTF0		27
+
 #define MT8365_MUTEX_MOD_DISP_OVL0		7
 #define MT8365_MUTEX_MOD_DISP_OVL0_2L		8
 #define MT8365_MUTEX_MOD_DISP_RDMA0		9
@@ -372,6 +390,21 @@ static const unsigned int mt8195_mutex_mod[DDP_COMPONENT_ID_MAX] = {
 	[DDP_COMPONENT_DSI0] = MT8195_MUTEX_MOD_DISP_DSI0,
 	[DDP_COMPONENT_PWM0] = MT8195_MUTEX_MOD_DISP_PWM0,
 	[DDP_COMPONENT_DP_INTF0] = MT8195_MUTEX_MOD_DISP_DP_INTF0,
+	[DDP_COMPONENT_MDP_RDMA0] = MT8195_MUTEX_MOD_DISP1_MDP_RDMA0,
+	[DDP_COMPONENT_MDP_RDMA1] = MT8195_MUTEX_MOD_DISP1_MDP_RDMA1,
+	[DDP_COMPONENT_MDP_RDMA2] = MT8195_MUTEX_MOD_DISP1_MDP_RDMA2,
+	[DDP_COMPONENT_MDP_RDMA3] = MT8195_MUTEX_MOD_DISP1_MDP_RDMA3,
+	[DDP_COMPONENT_MDP_RDMA4] = MT8195_MUTEX_MOD_DISP1_MDP_RDMA4,
+	[DDP_COMPONENT_MDP_RDMA5] = MT8195_MUTEX_MOD_DISP1_MDP_RDMA5,
+	[DDP_COMPONENT_MDP_RDMA6] = MT8195_MUTEX_MOD_DISP1_MDP_RDMA6,
+	[DDP_COMPONENT_MDP_RDMA7] = MT8195_MUTEX_MOD_DISP1_MDP_RDMA7,
+	[DDP_COMPONENT_MERGE1] = MT8195_MUTEX_MOD_DISP1_VPP_MERGE0,
+	[DDP_COMPONENT_MERGE2] = MT8195_MUTEX_MOD_DISP1_VPP_MERGE1,
+	[DDP_COMPONENT_MERGE3] = MT8195_MUTEX_MOD_DISP1_VPP_MERGE2,
+	[DDP_COMPONENT_MERGE4] = MT8195_MUTEX_MOD_DISP1_VPP_MERGE3,
+	[DDP_COMPONENT_ETHDR_MIXER] = MT8195_MUTEX_MOD_DISP1_DISP_MIXER,
+	[DDP_COMPONENT_MERGE5] = MT8195_MUTEX_MOD_DISP1_VPP_MERGE4,
+	[DDP_COMPONENT_DP_INTF1] = MT8195_MUTEX_MOD_DISP1_DP_INTF0,
 };
 
 static const unsigned int mt8365_mutex_mod[DDP_COMPONENT_ID_MAX] = {
Signature · 1 line
2.18.0