Skip to contentSkip to conversation

arm/arm64: mediatek: Fix mmsys device probing

PATCH RESEND Superseded [email protected] 5 participants 34 messages Dec 7, 2019 – Feb 13, 2020

Subsystems (7)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v6 cover arm/arm64: mediatek: Fix mmsys device probing

From: Matthias Brugger <[email protected]>

[reseding due to wrong mail of Stephen]

This is version five of the series. It's a long time this wasn't worked on, so as a reminder, version four can be found here:
https://patchwork.kernel.org/cover/10686247/

The biggest changes this new version does, is to implement the clock probing through a platform driver. The corresponding platform device get's created in the DRM driver. I converted all the clock drivers to platform drivers and tested the approach on the Acer Chromebook R13 (mt8173 based).
Apart from that I reordered the patches so that the DT bindings update are the first patches.

Changes since v5:
- re-arrange the patch order
- generate platform_device for mmsys clock driver inside the DRM driver
- fix DTS binding accordingly
- switch all mmsys clock driver to platform probing
- fix mt8173 platform driver remove function
- fix probe defer path in HDMI driver
- fix probe defer path in mtk_mdp_comp
- fix identation of error messages

Changes since v4:
- fix missing regmap accessors in drm diver (patch 1)
- omit probe deffered warning on all drivers (patch 5)
- update drm and clk bindings (patch 6 and 7)
- put mmsys clock part in dts child node of mmsys. Only done for HW where no dts backport compatible breakage is expected (either DRM driver not yet implemented or no HW available to the public) (patch 9 to 12)

Changes since v3:
- use platform device to probe clock driver
- add Acked-by CK Hu for the probe deferred patch

Changes since v2:
- fix kconfig typo (shame on me)
- delete __initconst from mm_clocks as converted to a platform driver

Changes since v1:
- add binding documentation
- ddp: use regmap_update_bits
- ddp: ignore EPROBE_DEFER on clock probing
- mfd: delete mmsys_private
- add Reviewed-by and Acked-by tags

MMSYS in Mediatek SoCs has some registers to control clock gates (which is used in the clk driver) and some registers to set the routing and enable the differnet blocks of the display subsystem.

Up to now both drivers, clock and drm are probed with the same device tree compatible. But only the first driver get probed, which in effect breaks graphics on mt8173 and mt2701.

This patch uses a platform device registration in the DRM driver, which will trigger the probe of the corresponding clock driver. It was tested on the bananapi-r2 and the Acer R13 Chromebook.

Matthias Brugger (12):
dt-bindings: display: mediatek: Add mmsys binding description
dt-bindings: mediatek: Add compatible for mt7623 drm/mediatek: Use regmap for register access
drm: mediatek: Omit warning on probe defers
media: mtk-mdp: Check return value of of_clk_get
clk: mediatek: mt2701: switch mmsys to platform device probing
clk: mediatek: mt2712e: switch to platform device probing
clk: mediatek: mt6779: switch mmsys to platform device probing
clk: mediatek: mt6797: switch to platform device probing
clk: mediatek: mt8183: switch mmsys to platform device probing
clk: mediatek: mt8173: switch mmsys to platform device probing drm/mediatek: Add support for mmsys through a pdev

 .../display/mediatek/mediatek,disp.txt        | 30 ++++++-----
 drivers/clk/mediatek/clk-mt2701-mm.c          | 41 +++++++++-----
 drivers/clk/mediatek/clk-mt2712-mm.c          | 39 +++++++++-----
 drivers/clk/mediatek/clk-mt6779-mm.c          | 41 +++++++++-----
 drivers/clk/mediatek/clk-mt6797-mm.c          | 43 ++++++++++-----
 drivers/clk/mediatek/clk-mt8173.c             | 51 +++++++++++++++---
 drivers/clk/mediatek/clk-mt8183-mm.c          | 39 +++++++++-----
 drivers/gpu/drm/mediatek/mtk_disp_color.c     |  5 +-
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c       |  5 +-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c      |  5 +-
 drivers/gpu/drm/mediatek/mtk_dpi.c            | 12 +++--
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c       |  4 +-
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c        | 54 +++++++++----------
 drivers/gpu/drm/mediatek/mtk_drm_ddp.h        |  4 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c        | 35 +++++++++---
 drivers/gpu/drm/mediatek/mtk_drm_drv.h        |  4 +-
 drivers/gpu/drm/mediatek/mtk_dsi.c            |  8 ++-
 drivers/gpu/drm/mediatek/mtk_hdmi.c           |  4 +-
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  6 +++
 19 files changed, 295 insertions(+), 135 deletions(-)
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

PATCH RESEND v6 1/12 dt-bindings: display: mediatek: Add mmsys binding description

From: Matthias Brugger <[email protected]>

The MediaTek DRM has a block called mmsys, which sets the routing and enalbes the different blocks.
This patch adds one line for the mmsys bindings description.

---
 .../display/mediatek/mediatek,disp.txt        | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +15 -13
index 8469de510001..c71c8a4b73ff 100644
@@ -27,20 +27,22 @@ Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt.
 
 Required properties (all function blocks):
 - compatible: "mediatek,<chip>-disp-<function>", one of
-	"mediatek,<chip>-disp-ovl"   - overlay (4 layers, blending, csc)
-	"mediatek,<chip>-disp-rdma"  - read DMA / line buffer
-	"mediatek,<chip>-disp-wdma"  - write DMA
-	"mediatek,<chip>-disp-color" - color processor
-	"mediatek,<chip>-disp-aal"   - adaptive ambient light controller
-	"mediatek,<chip>-disp-gamma" - gamma correction
-	"mediatek,<chip>-disp-merge" - merge streams from two RDMA sources
-	"mediatek,<chip>-disp-split" - split stream to two encoders
-	"mediatek,<chip>-disp-ufoe"  - data compression engine
-	"mediatek,<chip>-dsi"        - DSI controller, see mediatek,dsi.txt
-	"mediatek,<chip>-dpi"        - DPI controller, see mediatek,dpi.txt
-	"mediatek,<chip>-disp-mutex" - display mutex
-	"mediatek,<chip>-disp-od"    - overdrive
+	"mediatek,<chip>-disp-ovl"		- overlay (4 layers, blending, csc)
+	"mediatek,<chip>-disp-rdma"		- read DMA / line buffer
+	"mediatek,<chip>-disp-wdma"		- write DMA
+	"mediatek,<chip>-disp-color"		- color processor
+	"mediatek,<chip>-disp-aal"		- adaptive ambient light controller
+	"mediatek,<chip>-disp-gamma"		- gamma correction
+	"mediatek,<chip>-disp-merge"		- merge streams from two RDMA sources
+	"mediatek,<chip>-disp-split"		- split stream to two encoders
+	"mediatek,<chip>-disp-ufoe"		- data compression engine
+	"mediatek,<chip>-dsi"			- DSI controller, see mediatek,dsi.txt
+	"mediatek,<chip>-dpi"			- DPI controller, see mediatek,dpi.txt
+	"mediatek,<chip>-disp-mutex"		- display mutex
+	"mediatek,<chip>-disp-od"		- overdrive
+	"mediatek,<chip>-mmsys", "syscon"	- provide clocks and components management
   the supported chips are mt2701, mt2712 and mt8173.
+
 - reg: Physical base address and length of the function block register space
 - interrupts: The interrupt signal from the function block (required, except for
   merge and split function blocks).
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw

Re: [resend PATCH v6 01/12] dt-bindings: display: mediatek: Add mmsys binding description

Hi, Matthias:

Quoted 23 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The MediaTek DRM has a block called mmsys, which sets the routing and enalbes the different blocks.
This patch adds one line for the mmsys bindings description.

---
 .../display/mediatek/mediatek,disp.txt        | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +0 -4
index 8469de510001..c71c8a4b73ff 100644
@@ -27,20 +27,22 @@ Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt.
 
 Required properties (all function blocks):
 - compatible: "mediatek,<chip>-disp-<function>", one of
-	"mediatek,<chip>-disp-ovl"   - overlay (4 layers, blending, csc)
-	"mediatek,<chip>-disp-rdma"  - read DMA / line buffer
-	"mediatek,<chip>-disp-wdma"  - write DMA
-	"mediatek,<chip>-disp-color" - color processor

Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt. · line 30

Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1 -9
-	"mediatek,<chip>-disp-aal"   - adaptive ambient light controller
-	"mediatek,<chip>-disp-gamma" - gamma correction
-	"mediatek,<chip>-disp-merge" - merge streams from two RDMA sources
-	"mediatek,<chip>-disp-split" - split stream to two encoders
-	"mediatek,<chip>-disp-ufoe"  - data compression engine
-	"mediatek,<chip>-dsi"        - DSI controller, see mediatek,dsi.txt
-	"mediatek,<chip>-dpi"        - DPI controller, see mediatek,dpi.txt
-	"mediatek,<chip>-disp-mutex" - display mutex
-	"mediatek,<chip>-disp-od"    - overdrive
+	"mediatek,<chip>-disp-ovl"		- overlay (4 layers, blending, csc)

This patch conflicts with 5.5-rc, please resend this patch base on 5.5-rc1.

Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +4 -0
+	"mediatek,<chip>-disp-rdma"		- read DMA / line buffer
+	"mediatek,<chip>-disp-wdma"		- write DMA
+	"mediatek,<chip>-disp-color"		- color processor
+	"mediatek,<chip>-disp-aal"		- adaptive ambient light controller

Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt. · line 44

Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +9 -0
+	"mediatek,<chip>-disp-gamma"		- gamma correction
+	"mediatek,<chip>-disp-merge"		- merge streams from two RDMA sources
+	"mediatek,<chip>-disp-split"		- split stream to two encoders
+	"mediatek,<chip>-disp-ufoe"		- data compression engine
+	"mediatek,<chip>-dsi"			- DSI controller, see mediatek,dsi.txt
+	"mediatek,<chip>-dpi"			- DPI controller, see mediatek,dpi.txt
+	"mediatek,<chip>-disp-mutex"		- display mutex
+	"mediatek,<chip>-disp-od"		- overdrive
+	"mediatek,<chip>-mmsys", "syscon"	- provide clocks and components management
   the supported chips are mt2701, mt2712 and mt8173.

The original binding document for mmsys is in [1], I think we should not define it in duplicate. Maybe you could remove the original document.

[1]
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/mediatek/mediatek%2Cmmsys.txt

Regards,
CK

Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt. · line 48

Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1 -0
+
 - reg: Physical base address and length of the function block register space
 - interrupts: The interrupt signal from the function block (required, except for
   merge and split function blocks).

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

#3 lore raw

Re: [resend PATCH v6 01/12] dt-bindings: display: mediatek: Add mmsys binding description

Hi Matthias,

Quoted 7 lines · CK Hu

Hi, Matthias:

Quoted 4 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The MediaTek DRM has a block called mmsys, which sets the routing and enalbes the different blocks.

Typo s/enalbes/enables/

Quoted 62 lines
Quoted 19 lines

This patch adds one line for the mmsys bindings description.

---
 .../display/mediatek/mediatek,disp.txt        | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +0 -4
index 8469de510001..c71c8a4b73ff 100644
@@ -27,20 +27,22 @@ Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt.
 
 Required properties (all function blocks):
 - compatible: "mediatek,<chip>-disp-<function>", one of
-	"mediatek,<chip>-disp-ovl"   - overlay (4 layers, blending, csc)
-	"mediatek,<chip>-disp-rdma"  - read DMA / line buffer
-	"mediatek,<chip>-disp-wdma"  - write DMA
-	"mediatek,<chip>-disp-color" - color processor

Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt. · line 30

Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1 -9
-	"mediatek,<chip>-disp-aal"   - adaptive ambient light controller
-	"mediatek,<chip>-disp-gamma" - gamma correction
-	"mediatek,<chip>-disp-merge" - merge streams from two RDMA sources
-	"mediatek,<chip>-disp-split" - split stream to two encoders
-	"mediatek,<chip>-disp-ufoe"  - data compression engine
-	"mediatek,<chip>-dsi"        - DSI controller, see mediatek,dsi.txt
-	"mediatek,<chip>-dpi"        - DPI controller, see mediatek,dpi.txt
-	"mediatek,<chip>-disp-mutex" - display mutex
-	"mediatek,<chip>-disp-od"    - overdrive
+	"mediatek,<chip>-disp-ovl"		- overlay (4 layers, blending, csc)

This patch conflicts with 5.5-rc, please resend this patch base on 5.5-rc1.

Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +4 -0
+	"mediatek,<chip>-disp-rdma"		- read DMA / line buffer
+	"mediatek,<chip>-disp-wdma"		- write DMA
+	"mediatek,<chip>-disp-color"		- color processor
+	"mediatek,<chip>-disp-aal"		- adaptive ambient light controller

Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt. · line 44

Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +9 -0
+	"mediatek,<chip>-disp-gamma"		- gamma correction
+	"mediatek,<chip>-disp-merge"		- merge streams from two RDMA sources
+	"mediatek,<chip>-disp-split"		- split stream to two encoders
+	"mediatek,<chip>-disp-ufoe"		- data compression engine
+	"mediatek,<chip>-dsi"			- DSI controller, see mediatek,dsi.txt
+	"mediatek,<chip>-dpi"			- DPI controller, see mediatek,dpi.txt
+	"mediatek,<chip>-disp-mutex"		- display mutex
+	"mediatek,<chip>-disp-od"		- overdrive
+	"mediatek,<chip>-mmsys", "syscon"	- provide clocks and components management
   the supported chips are mt2701, mt2712 and mt8173.

The original binding document for mmsys is in [1], I think we should not define it in duplicate. Maybe you could remove the original document.

[1]
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/mediatek/mediatek%2Cmmsys.txt

Regards,
CK

Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1 -0
+
 - reg: Physical base address and length of the function block register space
 - interrupts: The interrupt signal from the function block (required, except for
   merge and split function blocks).
maintainer
#4 lore raw

Re: [resend PATCH v6 01/12] dt-bindings: display: mediatek: Add mmsys binding description

In reply to CK Hu
Quoted 58 lines · CK Hu

Hi, Matthias:

Quoted 23 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The MediaTek DRM has a block called mmsys, which sets the routing and enalbes the different blocks.
This patch adds one line for the mmsys bindings description.

---
 .../display/mediatek/mediatek,disp.txt        | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +0 -4
index 8469de510001..c71c8a4b73ff 100644
@@ -27,20 +27,22 @@ Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt.
 
 Required properties (all function blocks):
 - compatible: "mediatek,<chip>-disp-<function>", one of
-	"mediatek,<chip>-disp-ovl"   - overlay (4 layers, blending, csc)
-	"mediatek,<chip>-disp-rdma"  - read DMA / line buffer
-	"mediatek,<chip>-disp-wdma"  - write DMA
-	"mediatek,<chip>-disp-color" - color processor

Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt. · line 30

Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1 -9
-	"mediatek,<chip>-disp-aal"   - adaptive ambient light controller
-	"mediatek,<chip>-disp-gamma" - gamma correction
-	"mediatek,<chip>-disp-merge" - merge streams from two RDMA sources
-	"mediatek,<chip>-disp-split" - split stream to two encoders
-	"mediatek,<chip>-disp-ufoe"  - data compression engine
-	"mediatek,<chip>-dsi"        - DSI controller, see mediatek,dsi.txt
-	"mediatek,<chip>-dpi"        - DPI controller, see mediatek,dpi.txt
-	"mediatek,<chip>-disp-mutex" - display mutex
-	"mediatek,<chip>-disp-od"    - overdrive
+	"mediatek,<chip>-disp-ovl"		- overlay (4 layers, blending, csc)

This patch conflicts with 5.5-rc, please resend this patch base on 5.5-rc1.

Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +4 -0
+	"mediatek,<chip>-disp-rdma"		- read DMA / line buffer
+	"mediatek,<chip>-disp-wdma"		- write DMA
+	"mediatek,<chip>-disp-color"		- color processor
+	"mediatek,<chip>-disp-aal"		- adaptive ambient light controller

Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt. · line 44

Quoted 10 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +9 -0
+	"mediatek,<chip>-disp-gamma"		- gamma correction
+	"mediatek,<chip>-disp-merge"		- merge streams from two RDMA sources
+	"mediatek,<chip>-disp-split"		- split stream to two encoders
+	"mediatek,<chip>-disp-ufoe"		- data compression engine
+	"mediatek,<chip>-dsi"			- DSI controller, see mediatek,dsi.txt
+	"mediatek,<chip>-dpi"			- DPI controller, see mediatek,dpi.txt
+	"mediatek,<chip>-disp-mutex"		- display mutex
+	"mediatek,<chip>-disp-od"		- overdrive
+	"mediatek,<chip>-mmsys", "syscon"	- provide clocks and components management
   the supported chips are mt2701, mt2712 and mt8173.

The original binding document for mmsys is in [1], I think we should not define it in duplicate. Maybe you could remove the original document.

Quoted 2 lines

[1]
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/mediatek/mediatek%2Cmmsys.txt

I think we should keep it, as it describes some requirements that are otherwise lost. I'll adapt the mmsys description and add a hint to it, like we do for dsi and dpi.

Regards,
Matthias

Quoted 9 lines

Regards,
CK

Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt. · line 48

Quoted 4 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1 -0
+
 - reg: Physical base address and length of the function block register space
 - interrupts: The interrupt signal from the function block (required, except for
   merge and split function blocks).
Quoted 5 lines

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

maintainer Acked-by on v6 1/12
#5 lore raw

Re: [resend PATCH v6 01/12] dt-bindings: display: mediatek: Add mmsys binding description

In reply to [email protected]
Quoted 4 lines · On Sat, Dec 07, 2019 at 11:47:29PM +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The MediaTek DRM has a block called mmsys, which sets the routing and enalbes the different blocks.

typo

Quoted 6 lines

This patch adds one line for the mmsys bindings description.

---
 .../display/mediatek/mediatek,disp.txt        | 28 ++++++++++---------
 1 file changed, 15 insertions(+), 13 deletions(-)

Otherwise,

#6 lore raw

PATCH RESEND v6 2/12 dt-bindings: mediatek: Add compatible for mt7623

In reply to [email protected]

From: Matthias Brugger <[email protected]>

MediaTek mt7623 uses the mt2701 binings as fallback. Document this in the binding description.

---
 .../devicetree/bindings/display/mediatek/mediatek,disp.txt      | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +2 -0
index c71c8a4b73ff..a747895574f1 100644
@@ -42,6 +42,8 @@ Required properties (all function blocks):
 	"mediatek,<chip>-disp-od"		- overdrive
 	"mediatek,<chip>-mmsys", "syscon"	- provide clocks and components management
   the supported chips are mt2701, mt2712 and mt8173.
+  For mt7623, compatible must be:
+        "mediatek,mt7623-<component>" , "mediatek,mt2701-<component>"
 
 - reg: Physical base address and length of the function block register space
 - interrupts: The interrupt signal from the function block (required, except for
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw

Re: [resend PATCH v6 02/12] dt-bindings: mediatek: Add compatible for mt7623

Hi Matthias,

Quoted 3 lines · On 7/12/19 23:47, [email protected] wrote:

From: Matthias Brugger <[email protected]>

MediaTek mt7623 uses the mt2701 binings as fallback.

typo s/binings/bindings/

Quoted 21 lines

Document this in the binding description.

---
 .../devicetree/bindings/display/mediatek/mediatek,disp.txt      | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +2 -0
index c71c8a4b73ff..a747895574f1 100644
@@ -42,6 +42,8 @@ Required properties (all function blocks):
 	"mediatek,<chip>-disp-od"		- overdrive
 	"mediatek,<chip>-mmsys", "syscon"	- provide clocks and components management
   the supported chips are mt2701, mt2712 and mt8173.
+  For mt7623, compatible must be:
+        "mediatek,mt7623-<component>" , "mediatek,mt2701-<component>"
 
 - reg: Physical base address and length of the function block register space
 - interrupts: The interrupt signal from the function block (required, except for
maintainer Acked-by on v6 2/12
#8 lore raw

Re: [resend PATCH v6 02/12] dt-bindings: mediatek: Add compatible for mt7623

In reply to [email protected]
Quoted 10 lines · On Sat, 7 Dec 2019 23:47:30 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

MediaTek mt7623 uses the mt2701 binings as fallback. Document this in the binding description.

---
 .../devicetree/bindings/display/mediatek/mediatek,disp.txt      | 2 ++
 1 file changed, 2 insertions(+)
#9 lore raw

PATCH RESEND v6 3/12 drm/mediatek: Use regmap for register access

In reply to [email protected]

From: Matthias Brugger <[email protected]>

The mmsys memory space is shared between the drm and the clk driver. Use regmap to access it.

---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c |  4 +-
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 50 +++++++++++--------------
 drivers/gpu/drm/mediatek/mtk_drm_ddp.h  |  4 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 13 ++-----
 drivers/gpu/drm/mediatek/mtk_drm_drv.h  |  2 +-
 5 files changed, 30 insertions(+), 43 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +2 -2
index 34a731755791..259e2f4fa5fa 100644
@@ -27,7 +27,7 @@
  * @enabled: records whether crtc_enable succeeded
  * @planes: array of 4 drm_plane structures, one for each overlay plane
  * @pending_planes: whether any plane has pending changes to be applied
- * @config_regs: memory mapped mmsys configuration register space
+ * @config_regs: regmap mapped mmsys configuration register space
  * @mutex: handle to one of the ten disp_mutex streams
  * @ddp_comp_nr: number of components in ddp_comp
  * @ddp_comp: array of pointers the mtk_ddp_comp structures used by this crtc
@@ -43,7 +43,7 @@ struct mtk_drm_crtc {
 	unsigned int			layer_nr;
 	bool				pending_planes;
 
-	void __iomem			*config_regs;
+	struct regmap			*config_regs;
 	struct mtk_disp_mutex		*mutex;
 	unsigned int			ddp_comp_nr;
 	struct mtk_ddp_comp		**ddp_comp;
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +21 -29

82 lines not on this page · raw message

drivers/gpu/drm/mediatek/mtk_drm_ddp.h +2 -2
index 827be424a148..01ff8b68881f 100644
@@ -12,10 +12,10 @@ struct regmap;
 struct device;
 struct mtk_disp_mutex;
 
-void mtk_ddp_add_comp_to_path(void __iomem *config_regs,
+void mtk_ddp_add_comp_to_path(struct regmap *config_regs,
 			      enum mtk_ddp_comp_id cur,
 			      enum mtk_ddp_comp_id next);
-void mtk_ddp_remove_comp_from_path(void __iomem *config_regs,
+void mtk_ddp_remove_comp_from_path(struct regmap *config_regs,
 				   enum mtk_ddp_comp_id cur,
 				   enum mtk_ddp_comp_id next);
 
drivers/gpu/drm/mediatek/mtk_drm_drv.c +4 -9
index 352b81a7a670..210455e9f46c 100644
@@ -6,6 +6,7 @@
 
 #include <linux/component.h>
 #include <linux/iommu.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
@@ -485,7 +486,6 @@ static int mtk_drm_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtk_drm_private *private;
-	struct resource *mem;
 	struct device_node *node;
 	struct component_match *match = NULL;
 	int ret;
@@ -499,14 +499,9 @@ static int mtk_drm_probe(struct platform_device *pdev)
 	INIT_WORK(&private->commit.work, mtk_atomic_work);
 	private->data = of_device_get_match_data(dev);
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	private->config_regs = devm_ioremap_resource(dev, mem);
-	if (IS_ERR(private->config_regs)) {
-		ret = PTR_ERR(private->config_regs);
-		dev_err(dev, "Failed to ioremap mmsys-config resource: %d\n",
-			ret);
-		return ret;
-	}
+	private->config_regs = syscon_node_to_regmap(dev->of_node);
+	if (IS_ERR(private->config_regs))
+		return PTR_ERR(private->config_regs);
 
 	/* Iterate over sibling DISP function blocks */
 	for_each_child_of_node(dev->of_node->parent, node) {
drivers/gpu/drm/mediatek/mtk_drm_drv.h +1 -1
index e03fea12ff59..63a121577dcb 100644
@@ -39,7 +39,7 @@ struct mtk_drm_private {
 
 	struct device_node *mutex_node;
 	struct device *mutex_dev;
-	void __iomem *config_regs;
+	struct regmap *config_regs;
 	struct device_node *comp_node[DDP_COMPONENT_ID_MAX];
 	struct mtk_ddp_comp *ddp_comp[DDP_COMPONENT_ID_MAX];
 	const struct mtk_mmsys_driver_data *data;
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v6 3/12
#10 lore raw

Re: [resend PATCH v6 03/12] drm/mediatek: Use regmap for register access

Hi, Matthias:

Quoted 4 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The mmsys memory space is shared between the drm and the clk driver. Use regmap to access it.

Quoted 180 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c |  4 +-
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 50 +++++++++++--------------
 drivers/gpu/drm/mediatek/mtk_drm_ddp.h  |  4 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c  | 13 ++-----
 drivers/gpu/drm/mediatek/mtk_drm_drv.h  |  2 +-
 5 files changed, 30 insertions(+), 43 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +2 -2
index 34a731755791..259e2f4fa5fa 100644
@@ -27,7 +27,7 @@
  * @enabled: records whether crtc_enable succeeded
  * @planes: array of 4 drm_plane structures, one for each overlay plane
  * @pending_planes: whether any plane has pending changes to be applied
- * @config_regs: memory mapped mmsys configuration register space
+ * @config_regs: regmap mapped mmsys configuration register space
  * @mutex: handle to one of the ten disp_mutex streams
  * @ddp_comp_nr: number of components in ddp_comp
  * @ddp_comp: array of pointers the mtk_ddp_comp structures used by this crtc
@@ -43,7 +43,7 @@ struct mtk_drm_crtc {
 	unsigned int			layer_nr;
 	bool				pending_planes;
 
-	void __iomem			*config_regs;
+	struct regmap			*config_regs;
 	struct mtk_disp_mutex		*mutex;
 	unsigned int			ddp_comp_nr;
 	struct mtk_ddp_comp		**ddp_comp;
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +21 -29
index 8106a71a7404..b765181223e6 100644
@@ -331,61 +331,53 @@ static unsigned int mtk_ddp_sel_in(enum mtk_ddp_comp_id cur,
 	return value;
 }
 
-static void mtk_ddp_sout_sel(void __iomem *config_regs,
+static void mtk_ddp_sout_sel(struct regmap *config_regs,
 			     enum mtk_ddp_comp_id cur,
 			     enum mtk_ddp_comp_id next)
 {
 	if (cur == DDP_COMPONENT_BLS && next == DDP_COMPONENT_DSI0) {
-		writel_relaxed(BLS_TO_DSI_RDMA1_TO_DPI1,
-			       config_regs + DISP_REG_CONFIG_OUT_SEL);
+		regmap_write(config_regs, DISP_REG_CONFIG_OUT_SEL,
+				BLS_TO_DSI_RDMA1_TO_DPI1);
 	} else if (cur == DDP_COMPONENT_BLS && next == DDP_COMPONENT_DPI0) {
-		writel_relaxed(BLS_TO_DPI_RDMA1_TO_DSI,
-			       config_regs + DISP_REG_CONFIG_OUT_SEL);
-		writel_relaxed(DSI_SEL_IN_RDMA,
-			       config_regs + DISP_REG_CONFIG_DSI_SEL);
-		writel_relaxed(DPI_SEL_IN_BLS,
-			       config_regs + DISP_REG_CONFIG_DPI_SEL);
+		regmap_write(config_regs, DISP_REG_CONFIG_OUT_SEL,
+				BLS_TO_DPI_RDMA1_TO_DSI);
+		regmap_write(config_regs, DISP_REG_CONFIG_DSI_SEL,
+				DSI_SEL_IN_RDMA);
+		regmap_write(config_regs, DISP_REG_CONFIG_DPI_SEL,
+				DPI_SEL_IN_BLS);
 	}
 }
 
-void mtk_ddp_add_comp_to_path(void __iomem *config_regs,
+void mtk_ddp_add_comp_to_path(struct regmap *config_regs,
 			      enum mtk_ddp_comp_id cur,
 			      enum mtk_ddp_comp_id next)
 {
-	unsigned int addr, value, reg;
+	unsigned int addr, value;
 
 	value = mtk_ddp_mout_en(cur, next, &addr);
-	if (value) {
-		reg = readl_relaxed(config_regs + addr) | value;
-		writel_relaxed(reg, config_regs + addr);
-	}
+	if (value)
+		regmap_update_bits(config_regs, addr, value, value);
 
 	mtk_ddp_sout_sel(config_regs, cur, next);
 
 	value = mtk_ddp_sel_in(cur, next, &addr);
-	if (value) {
-		reg = readl_relaxed(config_regs + addr) | value;
-		writel_relaxed(reg, config_regs + addr);
-	}
+	if (value)
+		regmap_update_bits(config_regs, addr, value, value);
 }
 
-void mtk_ddp_remove_comp_from_path(void __iomem *config_regs,
+void mtk_ddp_remove_comp_from_path(struct regmap *config_regs,
 				   enum mtk_ddp_comp_id cur,
 				   enum mtk_ddp_comp_id next)
 {
-	unsigned int addr, value, reg;
+	unsigned int addr, value;
 
 	value = mtk_ddp_mout_en(cur, next, &addr);
-	if (value) {
-		reg = readl_relaxed(config_regs + addr) & ~value;
-		writel_relaxed(reg, config_regs + addr);
-	}
+	if (value)
+		regmap_update_bits(config_regs, addr, value, 0);
 
 	value = mtk_ddp_sel_in(cur, next, &addr);
-	if (value) {
-		reg = readl_relaxed(config_regs + addr) & ~value;
-		writel_relaxed(reg, config_regs + addr);
-	}
+	if (value)
+		regmap_update_bits(config_regs, addr, value, 0);
 }
 
 struct mtk_disp_mutex *mtk_disp_mutex_get(struct device *dev, unsigned int id)
drivers/gpu/drm/mediatek/mtk_drm_ddp.h +2 -2
index 827be424a148..01ff8b68881f 100644
@@ -12,10 +12,10 @@ struct regmap;
 struct device;
 struct mtk_disp_mutex;
 
-void mtk_ddp_add_comp_to_path(void __iomem *config_regs,
+void mtk_ddp_add_comp_to_path(struct regmap *config_regs,
 			      enum mtk_ddp_comp_id cur,
 			      enum mtk_ddp_comp_id next);
-void mtk_ddp_remove_comp_from_path(void __iomem *config_regs,
+void mtk_ddp_remove_comp_from_path(struct regmap *config_regs,
 				   enum mtk_ddp_comp_id cur,
 				   enum mtk_ddp_comp_id next);
 
drivers/gpu/drm/mediatek/mtk_drm_drv.c +4 -9
index 352b81a7a670..210455e9f46c 100644
@@ -6,6 +6,7 @@
 
 #include <linux/component.h>
 #include <linux/iommu.h>
+#include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
@@ -485,7 +486,6 @@ static int mtk_drm_probe(struct platform_device *pdev)
 {
 	struct device *dev = &pdev->dev;
 	struct mtk_drm_private *private;
-	struct resource *mem;
 	struct device_node *node;
 	struct component_match *match = NULL;
 	int ret;
@@ -499,14 +499,9 @@ static int mtk_drm_probe(struct platform_device *pdev)
 	INIT_WORK(&private->commit.work, mtk_atomic_work);
 	private->data = of_device_get_match_data(dev);
 
-	mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	private->config_regs = devm_ioremap_resource(dev, mem);
-	if (IS_ERR(private->config_regs)) {
-		ret = PTR_ERR(private->config_regs);
-		dev_err(dev, "Failed to ioremap mmsys-config resource: %d\n",
-			ret);
-		return ret;
-	}
+	private->config_regs = syscon_node_to_regmap(dev->of_node);
+	if (IS_ERR(private->config_regs))
+		return PTR_ERR(private->config_regs);
 
 	/* Iterate over sibling DISP function blocks */
 	for_each_child_of_node(dev->of_node->parent, node) {
drivers/gpu/drm/mediatek/mtk_drm_drv.h +0 -0
index e03fea12ff59..63a121577dcb 100644

drivers/gpu/drm/mediatek/mtk_drm_drv.h struct mtk_drm_private { · line 45

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.h +1 -1
@@ -39,7 +39,7 @@ struct mtk_drm_private {
 
 	struct device_node *mutex_node;
 	struct device *mutex_dev;
-	void __iomem *config_regs;
+	struct regmap *config_regs;
 	struct device_node *comp_node[DDP_COMPONENT_ID_MAX];
 	struct mtk_ddp_comp *ddp_comp[DDP_COMPONENT_ID_MAX];
 	const struct mtk_mmsys_driver_data *data;

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

#11 lore raw

PATCH RESEND v6 4/12 drm: mediatek: Omit warning on probe defers

In reply to [email protected]

From: Matthias Brugger <[email protected]>

It can happen that the mmsys clock drivers aren't probed before the platform driver gets invoked. The platform driver used to print a warning that the driver failed to get the clocks. Omit this error on the defered probe path.

---
 drivers/gpu/drm/mediatek/mtk_disp_color.c |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c   |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c  |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_dpi.c        | 12 +++++++++---
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c    |  4 +++-
 drivers/gpu/drm/mediatek/mtk_dsi.c        |  8 ++++++--
 drivers/gpu/drm/mediatek/mtk_hdmi.c       |  4 +++-
 7 files changed, 33 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_color.c +4 -1
index 59de2a46aa49..8f0fc96ef7bc 100644
@@ -118,7 +118,10 @@ static int mtk_disp_color_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_color_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4 -1
index 21851756c579..7487b0182c05 100644
@@ -285,7 +285,10 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_ovl_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_disp_rdma.c +4 -1
index 405afef31407..835ea8f8dab9 100644
@@ -287,7 +287,10 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_rdma_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_dpi.c +9 -3
index be6d95c5ff25..9ed32470ad02 100644
@@ -700,21 +700,27 @@ static int mtk_dpi_probe(struct platform_device *pdev)
 	dpi->engine_clk = devm_clk_get(dev, "engine");
 	if (IS_ERR(dpi->engine_clk)) {
 		ret = PTR_ERR(dpi->engine_clk);
-		dev_err(dev, "Failed to get engine clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get engine clock: %d\n", ret);
+
 		return ret;
 	}
 
 	dpi->pixel_clk = devm_clk_get(dev, "pixel");
 	if (IS_ERR(dpi->pixel_clk)) {
 		ret = PTR_ERR(dpi->pixel_clk);
-		dev_err(dev, "Failed to get pixel clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get pixel clock: %d\n", ret);
+
 		return ret;
 	}
 
 	dpi->tvd_clk = devm_clk_get(dev, "pll");
 	if (IS_ERR(dpi->tvd_clk)) {
 		ret = PTR_ERR(dpi->tvd_clk);
-		dev_err(dev, "Failed to get tvdpll clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get tvdpll clock: %d\n", ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +3 -1
index b765181223e6..6054e2b675f9 100644
@@ -558,7 +558,9 @@ static int mtk_ddp_probe(struct platform_device *pdev)
 
 	ddp->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(ddp->clk)) {
-		dev_err(dev, "Failed to get clock\n");
+		if (PTR_ERR(ddp->clk) != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get clock\n");
+
 		return PTR_ERR(ddp->clk);
 	}
 
drivers/gpu/drm/mediatek/mtk_dsi.c +6 -2
index 4332563df952..66d5b0fdd678 100644
@@ -1110,14 +1110,18 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 	dsi->engine_clk = devm_clk_get(dev, "engine");
 	if (IS_ERR(dsi->engine_clk)) {
 		ret = PTR_ERR(dsi->engine_clk);
-		dev_err(dev, "Failed to get engine clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get engine clock: %d\n", ret);
+
 		return ret;
 	}
 
 	dsi->digital_clk = devm_clk_get(dev, "digital");
 	if (IS_ERR(dsi->digital_clk)) {
 		ret = PTR_ERR(dsi->digital_clk);
-		dev_err(dev, "Failed to get digital clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get digital clock: %d\n", ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_hdmi.c +3 -1
index ce91b61364eb..62f9ca2308ee 100644
@@ -1447,7 +1447,9 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
 
 	ret = mtk_hdmi_get_all_clk(hdmi, np);
 	if (ret) {
-		dev_err(dev, "Failed to get clocks: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get clocks: %d\n", ret);
+
 		return ret;
 	}
 
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v6 4/12
#12 lore raw

Re: [resend PATCH v6 04/12] drm: mediatek: Omit warning on probe defers

Hi, Matthias:

Quoted 6 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

It can happen that the mmsys clock drivers aren't probed before the platform driver gets invoked. The platform driver used to print a warning that the driver failed to get the clocks. Omit this error on the defered probe path.

Quoted 150 lines
---
 drivers/gpu/drm/mediatek/mtk_disp_color.c |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c   |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c  |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_dpi.c        | 12 +++++++++---
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c    |  4 +++-
 drivers/gpu/drm/mediatek/mtk_dsi.c        |  8 ++++++--
 drivers/gpu/drm/mediatek/mtk_hdmi.c       |  4 +++-
 7 files changed, 33 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_color.c +4 -1
index 59de2a46aa49..8f0fc96ef7bc 100644
@@ -118,7 +118,10 @@ static int mtk_disp_color_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_color_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4 -1
index 21851756c579..7487b0182c05 100644
@@ -285,7 +285,10 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_ovl_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_disp_rdma.c +4 -1
index 405afef31407..835ea8f8dab9 100644
@@ -287,7 +287,10 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_rdma_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_dpi.c +9 -3
index be6d95c5ff25..9ed32470ad02 100644
@@ -700,21 +700,27 @@ static int mtk_dpi_probe(struct platform_device *pdev)
 	dpi->engine_clk = devm_clk_get(dev, "engine");
 	if (IS_ERR(dpi->engine_clk)) {
 		ret = PTR_ERR(dpi->engine_clk);
-		dev_err(dev, "Failed to get engine clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get engine clock: %d\n", ret);
+
 		return ret;
 	}
 
 	dpi->pixel_clk = devm_clk_get(dev, "pixel");
 	if (IS_ERR(dpi->pixel_clk)) {
 		ret = PTR_ERR(dpi->pixel_clk);
-		dev_err(dev, "Failed to get pixel clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get pixel clock: %d\n", ret);
+
 		return ret;
 	}
 
 	dpi->tvd_clk = devm_clk_get(dev, "pll");
 	if (IS_ERR(dpi->tvd_clk)) {
 		ret = PTR_ERR(dpi->tvd_clk);
-		dev_err(dev, "Failed to get tvdpll clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get tvdpll clock: %d\n", ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +3 -1
index b765181223e6..6054e2b675f9 100644
@@ -558,7 +558,9 @@ static int mtk_ddp_probe(struct platform_device *pdev)
 
 	ddp->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(ddp->clk)) {
-		dev_err(dev, "Failed to get clock\n");
+		if (PTR_ERR(ddp->clk) != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get clock\n");
+
 		return PTR_ERR(ddp->clk);
 	}
 
drivers/gpu/drm/mediatek/mtk_dsi.c +6 -2
index 4332563df952..66d5b0fdd678 100644
@@ -1110,14 +1110,18 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 	dsi->engine_clk = devm_clk_get(dev, "engine");
 	if (IS_ERR(dsi->engine_clk)) {
 		ret = PTR_ERR(dsi->engine_clk);
-		dev_err(dev, "Failed to get engine clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get engine clock: %d\n", ret);
+
 		return ret;
 	}
 
 	dsi->digital_clk = devm_clk_get(dev, "digital");
 	if (IS_ERR(dsi->digital_clk)) {
 		ret = PTR_ERR(dsi->digital_clk);
-		dev_err(dev, "Failed to get digital clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get digital clock: %d\n", ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_hdmi.c +3 -1
index ce91b61364eb..62f9ca2308ee 100644
@@ -1447,7 +1447,9 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
 
 	ret = mtk_hdmi_get_all_clk(hdmi, np);
 	if (ret) {
-		dev_err(dev, "Failed to get clocks: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get clocks: %d\n", ret);
+
 		return ret;
 	}
 
#13 lore raw

Re: [resend PATCH v6 04/12] drm: mediatek: Omit warning on probe defers

In reply to [email protected]

Hi Matthias,

Quoted 71 lines · On 7/12/19 23:47, [email protected] wrote:

From: Matthias Brugger <[email protected]>

It can happen that the mmsys clock drivers aren't probed before the platform driver gets invoked. The platform driver used to print a warning that the driver failed to get the clocks. Omit this error on the defered probe path.

---
 drivers/gpu/drm/mediatek/mtk_disp_color.c |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c   |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c  |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_dpi.c        | 12 +++++++++---
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c    |  4 +++-
 drivers/gpu/drm/mediatek/mtk_dsi.c        |  8 ++++++--
 drivers/gpu/drm/mediatek/mtk_hdmi.c       |  4 +++-
 7 files changed, 33 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_color.c +4 -1
index 59de2a46aa49..8f0fc96ef7bc 100644
@@ -118,7 +118,10 @@ static int mtk_disp_color_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_color_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4 -1
index 21851756c579..7487b0182c05 100644
@@ -285,7 +285,10 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_ovl_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_disp_rdma.c +4 -1
index 405afef31407..835ea8f8dab9 100644
@@ -287,7 +287,10 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_rdma_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
index be6d95c5ff25..9ed32470ad02 100644

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_probe(struct platform_device *pdev) · line 704

Quoted 6 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
@@ -700,21 +700,27 @@ static int mtk_dpi_probe(struct platform_device *pdev)
 	dpi->engine_clk = devm_clk_get(dev, "engine");
 	if (IS_ERR(dpi->engine_clk)) {
 		ret = PTR_ERR(dpi->engine_clk);
-		dev_err(dev, "Failed to get engine clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get engine clock: %d\n", ret);

This is only to print an error and I think that devm_clk_get will print a warning if the clk is not found. I guess that you can just remove the dev_err print logic, here and below.

In case there is an optional clock you could use devm_clk_get_optional, not sure if there is any, though.

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_probe(struct platform_device *pdev) · line 714

Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +4 -1
+
 		return ret;
 	}
 
 	dpi->pixel_clk = devm_clk_get(dev, "pixel");
 	if (IS_ERR(dpi->pixel_clk)) {
 		ret = PTR_ERR(dpi->pixel_clk);
-		dev_err(dev, "Failed to get pixel clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get pixel clock: %d\n", ret);
+

ditto

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_probe(struct platform_device *pdev) · line 723

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -1
 		return ret;
 	}
 
 	dpi->tvd_clk = devm_clk_get(dev, "pll");
 	if (IS_ERR(dpi->tvd_clk)) {
 		ret = PTR_ERR(dpi->tvd_clk);
-		dev_err(dev, "Failed to get tvdpll clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get tvdpll clock: %d\n", ret);
+

ditto

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +0 -0
index b765181223e6..6054e2b675f9 100644

drivers/gpu/drm/mediatek/mtk_drm_ddp.c static int mtk_ddp_probe(struct platform_device *pdev) · line 563

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +3 -1
@@ -558,7 +558,9 @@ static int mtk_ddp_probe(struct platform_device *pdev)
 
 	ddp->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(ddp->clk)) {
-		dev_err(dev, "Failed to get clock\n");
+		if (PTR_ERR(ddp->clk) != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get clock\n");
+

ditto

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +0 -0
 		return PTR_ERR(ddp->clk);
 	}
 
drivers/gpu/drm/mediatek/mtk_dsi.c +0 -0
index 4332563df952..66d5b0fdd678 100644

drivers/gpu/drm/mediatek/mtk_dsi.c static int mtk_dsi_probe(struct platform_device *pdev) · line 1115

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dsi.c +3 -1
@@ -1110,14 +1110,18 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 	dsi->engine_clk = devm_clk_get(dev, "engine");
 	if (IS_ERR(dsi->engine_clk)) {
 		ret = PTR_ERR(dsi->engine_clk);
-		dev_err(dev, "Failed to get engine clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get engine clock: %d\n", ret);
+

ditto

drivers/gpu/drm/mediatek/mtk_dsi.c static int mtk_dsi_probe(struct platform_device *pdev) · line 1124

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dsi.c +3 -1
 		return ret;
 	}
 
 	dsi->digital_clk = devm_clk_get(dev, "digital");
 	if (IS_ERR(dsi->digital_clk)) {
 		ret = PTR_ERR(dsi->digital_clk);
-		dev_err(dev, "Failed to get digital clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get digital clock: %d\n", ret);
+

ditto

Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dsi.c +0 -0
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_hdmi.c +0 -0
index ce91b61364eb..62f9ca2308ee 100644

drivers/gpu/drm/mediatek/mtk_hdmi.c static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, · line 1455

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_hdmi.c +3 -1
@@ -1447,7 +1447,9 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
 
 	ret = mtk_hdmi_get_all_clk(hdmi, np);
 	if (ret) {
-		dev_err(dev, "Failed to get clocks: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get clocks: %d\n", ret);
+
 		return ret;
 	}
 

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

maintainer
#14 lore raw

Re: [resend PATCH v6 04/12] drm: mediatek: Omit warning on probe defers

Quoted 69 lines · Enric Balletbo i Serra

Hi Matthias,

Quoted 66 lines · On 7/12/19 23:47, [email protected] wrote:

From: Matthias Brugger <[email protected]>

It can happen that the mmsys clock drivers aren't probed before the platform driver gets invoked. The platform driver used to print a warning that the driver failed to get the clocks. Omit this error on the defered probe path.

---
 drivers/gpu/drm/mediatek/mtk_disp_color.c |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c   |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c  |  5 ++++-
 drivers/gpu/drm/mediatek/mtk_dpi.c        | 12 +++++++++---
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c    |  4 +++-
 drivers/gpu/drm/mediatek/mtk_dsi.c        |  8 ++++++--
 drivers/gpu/drm/mediatek/mtk_hdmi.c       |  4 +++-
 7 files changed, 33 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_color.c +4 -1
index 59de2a46aa49..8f0fc96ef7bc 100644
@@ -118,7 +118,10 @@ static int mtk_disp_color_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_color_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +4 -1
index 21851756c579..7487b0182c05 100644
@@ -285,7 +285,10 @@ static int mtk_disp_ovl_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_ovl_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_disp_rdma.c +4 -1
index 405afef31407..835ea8f8dab9 100644
@@ -287,7 +287,10 @@ static int mtk_disp_rdma_probe(struct platform_device *pdev)
 	ret = mtk_ddp_comp_init(dev, dev->of_node, &priv->ddp_comp, comp_id,
 				&mtk_disp_rdma_funcs);
 	if (ret) {
-		dev_err(dev, "Failed to initialize component: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to initialize component: %d\n",
+				ret);
+
 		return ret;
 	}
 
Quoted 16 lines

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_probe(struct platform_device *pdev) · line 704

Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +2 -1
index be6d95c5ff25..9ed32470ad02 100644
@@ -700,21 +700,27 @@ static int mtk_dpi_probe(struct platform_device *pdev)
 	dpi->engine_clk = devm_clk_get(dev, "engine");
 	if (IS_ERR(dpi->engine_clk)) {
 		ret = PTR_ERR(dpi->engine_clk);
-		dev_err(dev, "Failed to get engine clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get engine clock: %d\n", ret);

This is only to print an error and I think that devm_clk_get will print a warning if the clk is not found. I guess that you can just remove the dev_err print logic, here and below.

I didn't follow all the paths, but at least devres_alloc in devm_clk_get isn't able to alloc the memory, it will silently return -ENOMEM. So I think it is OK to print an error message here.

Regards,
Matthias

Quoted 88 lines

In case there is an optional clock you could use devm_clk_get_optional, not sure if there is any, though.

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_probe(struct platform_device *pdev) · line 714

Quoted 11 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +4 -1
+
 		return ret;
 	}
 
 	dpi->pixel_clk = devm_clk_get(dev, "pixel");
 	if (IS_ERR(dpi->pixel_clk)) {
 		ret = PTR_ERR(dpi->pixel_clk);
-		dev_err(dev, "Failed to get pixel clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get pixel clock: %d\n", ret);
+

ditto

drivers/gpu/drm/mediatek/mtk_dpi.c static int mtk_dpi_probe(struct platform_device *pdev) · line 723

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +3 -1
 		return ret;
 	}
 
 	dpi->tvd_clk = devm_clk_get(dev, "pll");
 	if (IS_ERR(dpi->tvd_clk)) {
 		ret = PTR_ERR(dpi->tvd_clk);
-		dev_err(dev, "Failed to get tvdpll clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get tvdpll clock: %d\n", ret);
+

ditto

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_dpi.c +0 -0
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +0 -0
index b765181223e6..6054e2b675f9 100644

drivers/gpu/drm/mediatek/mtk_drm_ddp.c static int mtk_ddp_probe(struct platform_device *pdev) · line 563

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +3 -1
@@ -558,7 +558,9 @@ static int mtk_ddp_probe(struct platform_device *pdev)
 
 	ddp->clk = devm_clk_get(dev, NULL);
 	if (IS_ERR(ddp->clk)) {
-		dev_err(dev, "Failed to get clock\n");
+		if (PTR_ERR(ddp->clk) != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get clock\n");
+

ditto

Quoted 8 lines
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +0 -0
 		return PTR_ERR(ddp->clk);
 	}
 
drivers/gpu/drm/mediatek/mtk_dsi.c +0 -0
index 4332563df952..66d5b0fdd678 100644

drivers/gpu/drm/mediatek/mtk_dsi.c static int mtk_dsi_probe(struct platform_device *pdev) · line 1115

Quoted 7 lines
drivers/gpu/drm/mediatek/mtk_dsi.c +3 -1
@@ -1110,14 +1110,18 @@ static int mtk_dsi_probe(struct platform_device *pdev)
 	dsi->engine_clk = devm_clk_get(dev, "engine");
 	if (IS_ERR(dsi->engine_clk)) {
 		ret = PTR_ERR(dsi->engine_clk);
-		dev_err(dev, "Failed to get engine clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get engine clock: %d\n", ret);
+

ditto

drivers/gpu/drm/mediatek/mtk_dsi.c static int mtk_dsi_probe(struct platform_device *pdev) · line 1124

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_dsi.c +3 -1
 		return ret;
 	}
 
 	dsi->digital_clk = devm_clk_get(dev, "digital");
 	if (IS_ERR(dsi->digital_clk)) {
 		ret = PTR_ERR(dsi->digital_clk);
-		dev_err(dev, "Failed to get digital clock: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get digital clock: %d\n", ret);
+

ditto

Quoted 9 lines
drivers/gpu/drm/mediatek/mtk_dsi.c +0 -0
 		return ret;
 	}
 
drivers/gpu/drm/mediatek/mtk_hdmi.c +0 -0
index ce91b61364eb..62f9ca2308ee 100644
@@ -1447,7 +1447,9 @@ static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi,
 
Quoted 10 lines

drivers/gpu/drm/mediatek/mtk_hdmi.c static int mtk_hdmi_dt_parse_pdata(struct mtk_hdmi *hdmi, · line 1455

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_hdmi.c +3 -1
 	ret = mtk_hdmi_get_all_clk(hdmi, np);
 	if (ret) {
-		dev_err(dev, "Failed to get clocks: %d\n", ret);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "Failed to get clocks: %d\n", ret);
+
 		return ret;
 	}
 

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#15 lore raw

PATCH RESEND v6 5/12 media: mtk-mdp: Check return value of of_clk_get

In reply to [email protected]

From: Matthias Brugger <[email protected]>

Check the return value of of_clk_get and print an error message if not EPROBE_DEFER.

---
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +6 -0
index 9afe8161a8c0..4e2fc1337b80 100644
@@ -110,6 +110,12 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
 
 	for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
 		comp->clk[i] = of_clk_get(node, i);
+		if (IS_ERR(comp->clk[i])i) {
+			if (PTR_ERR(comp->clk[i] != -EPROBE_DEFER)
+					dev_err(dev, "Failed to get clock\n");
+
+			return PTR_ERR(comp->clk[i]);
+		}
 
 		/* Only RDMA needs two clocks */
 		if (comp->type != MTK_MDP_RDMA)
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#16 lore raw

Re: [resend PATCH v6 05/12] media: mtk-mdp: Check return value of of_clk_get

Hi Matthias,

Quoted 15 lines · On 7/12/19 23:47, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Check the return value of of_clk_get and print an error message if not EPROBE_DEFER.

---
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +0 -0
index 9afe8161a8c0..4e2fc1337b80 100644

drivers/media/platform/mtk-mdp/mtk_mdp_comp.c int mtk_mdp_comp_init(struct device *dev, struct device_node *node, · line 113

Quoted 4 lines
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +1 -0
@@ -110,6 +110,12 @@ int mtk_mdp_comp_init(struct device *dev, struct device_node *node,
 
 	for (i = 0; i < ARRAY_SIZE(comp->clk); i++) {
 		comp->clk[i] = of_clk_get(node, i);
+		if (IS_ERR(comp->clk[i])i) {

Oops ^

drivers/media/platform/mtk-mdp/mtk_mdp_comp.c int mtk_mdp_comp_init(struct device *dev, struct device_node *node, · line 114

Quoted 1 line
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +1 -0
+			if (PTR_ERR(comp->clk[i] != -EPROBE_DEFER)

and missing closing )

drivers/media/platform/mtk-mdp/mtk_mdp_comp.c int mtk_mdp_comp_init(struct device *dev, struct device_node *node, · line 115

Quoted 1 line
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +1 -0
+					dev_err(dev, "Failed to get clock\n");

Like the previous patch I think that the clk core will print a message if the clock is not found and you can just this redundand dev_err.

Quoted 7 lines
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +3 -0
+
+			return PTR_ERR(comp->clk[i]);
+		}
 
 		/* Only RDMA needs two clocks */
 		if (comp->type != MTK_MDP_RDMA)
#17 lore raw

PATCH RESEND v6 6/12 clk: mediatek: mt2701: switch mmsys to platform device probing

In reply to [email protected]

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt2701-mm.c | 41 ++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 12 deletions(-)
drivers/clk/mediatek/clk-mt2701-mm.c +29 -12
index 054b597d4a73..4a9433c2b2b8 100644
@@ -4,14 +4,20 @@
  * Author: Shunli Wang <[email protected]>
  */
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
 #include <dt-bindings/clock/mt2701-clk.h>
 
+struct clk_mt2701_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs disp0_cg_regs = {
 	.set_ofs = 0x0104,
 	.clr_ofs = 0x0108,
@@ -79,23 +85,25 @@ static const struct mtk_gate mm_clks[] = {
 	GATE_DISP1(CLK_MM_TVE_FMM, "mm_tve_fmm", "mm_sel", 14),
 };
 
-static const struct of_device_id of_match_clk_mt2701_mm[] = {
-	{ .compatible = "mediatek,mt2701-mmsys", },
-	{}
-};
-
 static int clk_mt2701_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
 	int r;
-	struct device_node *node = pdev->dev.of_node;
+	struct device_node *node = pdev->dev.parent->of_node;
+	struct clk_mt2701_mm_priv *private;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR);
+
+	platform_set_drvdata(pdev, private);
 
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-						clk_data);
+					private->clk_data);
 
-	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	r = of_clk_add_provider(node, of_clk_src_onecell_get,
+					private->clk_data);
 	if (r)
 		dev_err(&pdev->dev,
 			"could not register clock provider: %s: %d\n",
@@ -104,12 +112,21 @@ static int clk_mt2701_mm_probe(struct platform_device *pdev)
 	return r;
 }
 
+static int clk_mt2701_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt2701_mm_priv *private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
+}
+
 static struct platform_driver clk_mt2701_mm_drv = {
 	.probe = clk_mt2701_mm_probe,
+	.remove = clk_mt2701_mm_remove,
 	.driver = {
 		.name = "clk-mt2701-mm",
-		.of_match_table = of_match_clk_mt2701_mm,
 	},
 };
 
-builtin_platform_driver(clk_mt2701_mm_drv);
+module_platform_driver(clk_mt2701_mm_drv);
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#18 lore raw

Re: [resend PATCH v6 06/12] clk: mediatek: mt2701: switch mmsys to platform device probing

Hi Matthias,

Quoted 72 lines · On 7/12/19 23:47, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt2701-mm.c | 41 ++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 12 deletions(-)
drivers/clk/mediatek/clk-mt2701-mm.c +18 -10
index 054b597d4a73..4a9433c2b2b8 100644
@@ -4,14 +4,20 @@
  * Author: Shunli Wang <[email protected]>
  */
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
 #include <dt-bindings/clock/mt2701-clk.h>
 
+struct clk_mt2701_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs disp0_cg_regs = {
 	.set_ofs = 0x0104,
 	.clr_ofs = 0x0108,
@@ -79,23 +85,25 @@ static const struct mtk_gate mm_clks[] = {
 	GATE_DISP1(CLK_MM_TVE_FMM, "mm_tve_fmm", "mm_sel", 14),
 };
 
-static const struct of_device_id of_match_clk_mt2701_mm[] = {
-	{ .compatible = "mediatek,mt2701-mmsys", },
-	{}
-};
-
 static int clk_mt2701_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
 	int r;
-	struct device_node *node = pdev->dev.of_node;
+	struct device_node *node = pdev->dev.parent->of_node;
+	struct clk_mt2701_mm_priv *private;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR);
+
+	platform_set_drvdata(pdev, private);
 
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-						clk_data);
+					private->clk_data);
 
-	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	r = of_clk_add_provider(node, of_clk_src_onecell_get,
+					private->clk_data);
 	if (r)
 		dev_err(&pdev->dev,
 			"could not register clock provider: %s: %d\n",

drivers/clk/mediatek/clk-mt2701-mm.c static int clk_mt2701_mm_probe(struct platform_device *pdev) · line 118

Quoted 7 lines
drivers/clk/mediatek/clk-mt2701-mm.c +4 -0
@@ -104,12 +112,21 @@ static int clk_mt2701_mm_probe(struct platform_device *pdev)
 	return r;
 }
 
+static int clk_mt2701_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt2701_mm_priv *private = platform_get_drvdata(pdev);
+

I think that private->clk_data->clks is also kallocated and need to be freed?

But I think that the best approach now is to switch to use devm allocations in clk-mt2701-mm.c and this remove function will not be needed.

Quoted 17 lines
drivers/clk/mediatek/clk-mt2701-mm.c +7 -2
+	kfree(private->clk_data);
+
+	return 0;
+}
+
 static struct platform_driver clk_mt2701_mm_drv = {
 	.probe = clk_mt2701_mm_probe,
+	.remove = clk_mt2701_mm_remove,
 	.driver = {
 		.name = "clk-mt2701-mm",
-		.of_match_table = of_match_clk_mt2701_mm,
 	},
 };
 
-builtin_platform_driver(clk_mt2701_mm_drv);
+module_platform_driver(clk_mt2701_mm_drv);
maintainer
#19 lore raw

Re: [resend PATCH v6 06/12] clk: mediatek: mt2701: switch mmsys to platform device probing

Quoted 85 lines · Enric Balletbo i Serra

Hi Matthias,

Quoted 72 lines · On 7/12/19 23:47, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt2701-mm.c | 41 ++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 12 deletions(-)
drivers/clk/mediatek/clk-mt2701-mm.c +18 -10
index 054b597d4a73..4a9433c2b2b8 100644
@@ -4,14 +4,20 @@
  * Author: Shunli Wang <[email protected]>
  */
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
 #include <dt-bindings/clock/mt2701-clk.h>
 
+struct clk_mt2701_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs disp0_cg_regs = {
 	.set_ofs = 0x0104,
 	.clr_ofs = 0x0108,
@@ -79,23 +85,25 @@ static const struct mtk_gate mm_clks[] = {
 	GATE_DISP1(CLK_MM_TVE_FMM, "mm_tve_fmm", "mm_sel", 14),
 };
 
-static const struct of_device_id of_match_clk_mt2701_mm[] = {
-	{ .compatible = "mediatek,mt2701-mmsys", },
-	{}
-};
-
 static int clk_mt2701_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
 	int r;
-	struct device_node *node = pdev->dev.of_node;
+	struct device_node *node = pdev->dev.parent->of_node;
+	struct clk_mt2701_mm_priv *private;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR);
+
+	platform_set_drvdata(pdev, private);
 
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-						clk_data);
+					private->clk_data);
 
-	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	r = of_clk_add_provider(node, of_clk_src_onecell_get,
+					private->clk_data);
 	if (r)
 		dev_err(&pdev->dev,
 			"could not register clock provider: %s: %d\n",

drivers/clk/mediatek/clk-mt2701-mm.c static int clk_mt2701_mm_probe(struct platform_device *pdev) · line 118

Quoted 7 lines
drivers/clk/mediatek/clk-mt2701-mm.c +4 -0
@@ -104,12 +112,21 @@ static int clk_mt2701_mm_probe(struct platform_device *pdev)
 	return r;
 }
 
+static int clk_mt2701_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt2701_mm_priv *private = platform_get_drvdata(pdev);
+

I think that private->clk_data->clks is also kallocated and need to be freed?

Quoted 3 lines

But I think that the best approach now is to switch to use devm allocations in clk-mt2701-mm.c and this remove function will not be needed.

This is an API change which will affect over 50 drivers. For now I'll fix it by adding a kfree here. I will send a follow-up patch to fix it in the API.

Good catch!
Matthias

Quoted 14 lines
Quoted 14 lines
drivers/clk/mediatek/clk-mt2701-mm.c +6 -1
+	kfree(private->clk_data);
+
+	return 0;
+}
+
 static struct platform_driver clk_mt2701_mm_drv = {
 	.probe = clk_mt2701_mm_probe,
+	.remove = clk_mt2701_mm_remove,
 	.driver = {
 		.name = "clk-mt2701-mm",
-		.of_match_table = of_match_clk_mt2701_mm,
 	},
 };
 
Quoted 3 lines

drivers/clk/mediatek/clk-mt2701-mm.c static int clk_mt2701_mm_probe(struct platform_device *pdev) · line 132

Quoted 3 lines
drivers/clk/mediatek/clk-mt2701-mm.c +1 -1
-builtin_platform_driver(clk_mt2701_mm_drv);
+module_platform_driver(clk_mt2701_mm_drv);

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#20 lore raw

PATCH RESEND v6 7/12 clk: mediatek: mt2712e: switch to platform device probing

In reply to [email protected]

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt2712-mm.c | 39 +++++++++++++++++++---------
 1 file changed, 27 insertions(+), 12 deletions(-)
drivers/clk/mediatek/clk-mt2712-mm.c +27 -12
index 1c5948be35f3..d018db568263 100644
@@ -4,14 +4,20 @@
  * Author: Weiyi Lu <[email protected]>
  */
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
 #include <dt-bindings/clock/mt2712-clk.h>
 
+struct clk_mt2712_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs mm0_cg_regs = {
 	.set_ofs = 0x104,
 	.clr_ofs = 0x108,
@@ -128,16 +134,22 @@ static const struct mtk_gate mm_clks[] = {
 
 static int clk_mt2712_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
 	int r;
-	struct device_node *node = pdev->dev.of_node;
+	struct device_node *node = pdev->dev.parent->of_node;
+	struct clk_mt2712_mm_priv *private;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, private);
 
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			clk_data);
+			private->clk_data);
 
-	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	r = of_clk_add_provider(node, of_clk_src_onecell_get,
+			private->clk_data);
 
 	if (r != 0)
 		pr_err("%s(): could not register clock provider: %d\n",
@@ -146,17 +158,20 @@ static int clk_mt2712_mm_probe(struct platform_device *pdev)
 	return r;
 }
 
-static const struct of_device_id of_match_clk_mt2712_mm[] = {
-	{ .compatible = "mediatek,mt2712-mmsys", },
-	{}
-};
+static int clk_mt2712_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt2712_mm_priv *private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
+}
 
 static struct platform_driver clk_mt2712_mm_drv = {
 	.probe = clk_mt2712_mm_probe,
+	.remove = clk_mt2712_mm_remove,
 	.driver = {
 		.name = "clk-mt2712-mm",
-		.of_match_table = of_match_clk_mt2712_mm,
 	},
 };
-
-builtin_platform_driver(clk_mt2712_mm_drv);
+module_platform_driver(clk_mt2712_mm_drv);
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#21 lore raw

Re: [resend PATCH v6 07/12] clk: mediatek: mt2712e: switch to platform device probing

Hi Matthias,

Quoted 8 lines · On 7/12/19 23:47, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt2712-mm.c | 39 +++++++++++++++++++---------

Same comments as previous patch.

Quoted 84 lines
 1 file changed, 27 insertions(+), 12 deletions(-)
drivers/clk/mediatek/clk-mt2712-mm.c +27 -12
index 1c5948be35f3..d018db568263 100644
@@ -4,14 +4,20 @@
  * Author: Weiyi Lu <[email protected]>
  */
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
 #include <dt-bindings/clock/mt2712-clk.h>
 
+struct clk_mt2712_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs mm0_cg_regs = {
 	.set_ofs = 0x104,
 	.clr_ofs = 0x108,
@@ -128,16 +134,22 @@ static const struct mtk_gate mm_clks[] = {
 
 static int clk_mt2712_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
 	int r;
-	struct device_node *node = pdev->dev.of_node;
+	struct device_node *node = pdev->dev.parent->of_node;
+	struct clk_mt2712_mm_priv *private;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, private);
 
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			clk_data);
+			private->clk_data);
 
-	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	r = of_clk_add_provider(node, of_clk_src_onecell_get,
+			private->clk_data);
 
 	if (r != 0)
 		pr_err("%s(): could not register clock provider: %d\n",
@@ -146,17 +158,20 @@ static int clk_mt2712_mm_probe(struct platform_device *pdev)
 	return r;
 }
 
-static const struct of_device_id of_match_clk_mt2712_mm[] = {
-	{ .compatible = "mediatek,mt2712-mmsys", },
-	{}
-};
+static int clk_mt2712_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt2712_mm_priv *private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
+}
 
 static struct platform_driver clk_mt2712_mm_drv = {
 	.probe = clk_mt2712_mm_probe,
+	.remove = clk_mt2712_mm_remove,
 	.driver = {
 		.name = "clk-mt2712-mm",
-		.of_match_table = of_match_clk_mt2712_mm,
 	},
 };
-
-builtin_platform_driver(clk_mt2712_mm_drv);
+module_platform_driver(clk_mt2712_mm_drv);
#22 lore raw

PATCH RESEND v6 8/12 clk: mediatek: mt6779: switch mmsys to platform device probing

In reply to [email protected]

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt6779-mm.c | 41 +++++++++++++++++++---------
 1 file changed, 28 insertions(+), 13 deletions(-)
drivers/clk/mediatek/clk-mt6779-mm.c +28 -13
index fb5fbb8e3e41..439ec460c166 100644
@@ -4,13 +4,19 @@
  * Author: Wendell Lin <[email protected]>
  */
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
 #include <dt-bindings/clock/mt6779-clk.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
+struct clk_mt6779_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs mm0_cg_regs = {
 	.set_ofs = 0x0104,
 	.clr_ofs = 0x0108,
@@ -84,30 +90,39 @@ static const struct mtk_gate mm_clks[] = {
 	GATE_MM1(CLK_MM_DISP_OVL_FBDC, "mm_disp_ovl_fbdc", "mm_sel", 16),
 };
 
-static const struct of_device_id of_match_clk_mt6779_mm[] = {
-	{ .compatible = "mediatek,mt6779-mmsys", },
-	{}
-};
-
 static int clk_mt6779_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
-	struct device_node *node = pdev->dev.of_node;
+	struct clk_mt6779_mm_priv *private;
+	struct device_node *node = pdev->dev.parent->of_node;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, private);
 
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			       clk_data);
+			       private->clk_data);
 
-	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	return of_clk_add_provider(node, of_clk_src_onecell_get,
+						private->clk_data);
+}
+
+static int clk_mt6779_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt6779_mm_priv *private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
 }
 
 static struct platform_driver clk_mt6779_mm_drv = {
 	.probe = clk_mt6779_mm_probe,
+	.remove = clk_mt6779_mm_remove,
 	.driver = {
 		.name = "clk-mt6779-mm",
-		.of_match_table = of_match_clk_mt6779_mm,
 	},
 };
-
-builtin_platform_driver(clk_mt6779_mm_drv);
+module_platform_driver(clk_mt6779_mm_drv);
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#23 lore raw

Re: [resend PATCH v6 08/12] clk: mediatek: mt6779: switch mmsys to platform device probing

Hi Matthias,

Quoted 8 lines · On 7/12/19 23:47, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt6779-mm.c | 41 +++++++++++++++++++---------

And the same comment from previous patch. The comment applies to patches until 11.

Quoted 80 lines
 1 file changed, 28 insertions(+), 13 deletions(-)
drivers/clk/mediatek/clk-mt6779-mm.c +28 -13
index fb5fbb8e3e41..439ec460c166 100644
@@ -4,13 +4,19 @@
  * Author: Wendell Lin <[email protected]>
  */
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
 #include <dt-bindings/clock/mt6779-clk.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
+struct clk_mt6779_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs mm0_cg_regs = {
 	.set_ofs = 0x0104,
 	.clr_ofs = 0x0108,
@@ -84,30 +90,39 @@ static const struct mtk_gate mm_clks[] = {
 	GATE_MM1(CLK_MM_DISP_OVL_FBDC, "mm_disp_ovl_fbdc", "mm_sel", 16),
 };
 
-static const struct of_device_id of_match_clk_mt6779_mm[] = {
-	{ .compatible = "mediatek,mt6779-mmsys", },
-	{}
-};
-
 static int clk_mt6779_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
-	struct device_node *node = pdev->dev.of_node;
+	struct clk_mt6779_mm_priv *private;
+	struct device_node *node = pdev->dev.parent->of_node;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, private);
 
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			       clk_data);
+			       private->clk_data);
 
-	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	return of_clk_add_provider(node, of_clk_src_onecell_get,
+						private->clk_data);
+}
+
+static int clk_mt6779_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt6779_mm_priv *private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
 }
 
 static struct platform_driver clk_mt6779_mm_drv = {
 	.probe = clk_mt6779_mm_probe,
+	.remove = clk_mt6779_mm_remove,
 	.driver = {
 		.name = "clk-mt6779-mm",
-		.of_match_table = of_match_clk_mt6779_mm,
 	},
 };
-
-builtin_platform_driver(clk_mt6779_mm_drv);
+module_platform_driver(clk_mt6779_mm_drv);
#24 lore raw

PATCH RESEND v6 9/12 clk: mediatek: mt6797: switch to platform device probing

In reply to [email protected]

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt6797-mm.c | 43 +++++++++++++++++++---------
 1 file changed, 29 insertions(+), 14 deletions(-)
drivers/clk/mediatek/clk-mt6797-mm.c +29 -14
index 8f05653b387d..1aea4f8d5a9d 100644
@@ -4,13 +4,19 @@
  * Author: Kevin Chen <[email protected]>
  */
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 #include <dt-bindings/clock/mt6797-clk.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
+struct clk_mt6797_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs mm0_cg_regs = {
 	.set_ofs = 0x0104,
 	.clr_ofs = 0x0108,
@@ -92,23 +98,24 @@ static const struct mtk_gate mm_clks[] = {
 		 "clk26m", 3),
 };
 
-static const struct of_device_id of_match_clk_mt6797_mm[] = {
-	{ .compatible = "mediatek,mt6797-mmsys", },
-	{}
-};
-
 static int clk_mt6797_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
+	struct clk_mt6797_mm_priv *private;
 	int r;
-	struct device_node *node = pdev->dev.of_node;
+	struct device *parent = pdev->dev.parent;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR);
+	platform_set_drvdata(pdev, private);
 
-	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			       clk_data);
+	mtk_clk_register_gates(parent->of_node, mm_clks, ARRAY_SIZE(mm_clks),
+			       private->clk_data);
 
-	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	r = of_clk_add_provider(parent->of_node, of_clk_src_onecell_get,
+			private->clk_data);
 	if (r)
 		dev_err(&pdev->dev,
 			"could not register clock provider: %s: %d\n",
@@ -117,12 +124,20 @@ static int clk_mt6797_mm_probe(struct platform_device *pdev)
 	return r;
 }
 
+static int clk_mt6797_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt6797_mm_priv *private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
+}
+
 static struct platform_driver clk_mt6797_mm_drv = {
 	.probe = clk_mt6797_mm_probe,
+	.remove = clk_mt6797_mm_remove,
 	.driver = {
 		.name = "clk-mt6797-mm",
-		.of_match_table = of_match_clk_mt6797_mm,
 	},
 };
-
-builtin_platform_driver(clk_mt6797_mm_drv);
+module_platform_driver(clk_mt6797_mm_drv);
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#25 lore raw

PATCH RESEND v6 10/12 clk: mediatek: mt8183: switch mmsys to platform device probing

In reply to [email protected]

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt8183-mm.c | 39 +++++++++++++++++++---------
 1 file changed, 27 insertions(+), 12 deletions(-)
drivers/clk/mediatek/clk-mt8183-mm.c +27 -12
index 720c696b506d..e6dcad18d81a 100644
@@ -3,14 +3,20 @@
 // Copyright (c) 2018 MediaTek Inc.
 // Author: Weiyi Lu <[email protected]>
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
 #include <dt-bindings/clock/mt8183-clk.h>
 
+struct clk_mt8183_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs mm0_cg_regs = {
 	.set_ofs = 0x104,
 	.clr_ofs = 0x108,
@@ -84,28 +90,37 @@ static const struct mtk_gate mm_clks[] = {
 
 static int clk_mt8183_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
-	struct device_node *node = pdev->dev.of_node;
+	struct clk_mt8183_mm_priv *private;
+	struct device_node *node = pdev->dev.parent->of_node;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, private);
 
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			clk_data);
+			private->clk_data);
 
-	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	return of_clk_add_provider(node, of_clk_src_onecell_get,
+			private->clk_data);
 }
 
-static const struct of_device_id of_match_clk_mt8183_mm[] = {
-	{ .compatible = "mediatek,mt8183-mmsys", },
-	{}
-};
+static int clk_mt8183_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt8183_mm_priv *private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
+}
 
 static struct platform_driver clk_mt8183_mm_drv = {
 	.probe = clk_mt8183_mm_probe,
+	.remove = clk_mt8183_mm_remove,
 	.driver = {
 		.name = "clk-mt8183-mm",
-		.of_match_table = of_match_clk_mt8183_mm,
 	},
 };
-
-builtin_platform_driver(clk_mt8183_mm_drv);
+module_platform_driver(clk_mt8183_mm_drv);
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#26 lore raw

Re: [resend PATCH v6 10/12] clk: mediatek: mt8183: switch mmsys to platform device probing

Hi, Matthias:

Quoted 41 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt8183-mm.c | 39 +++++++++++++++++++---------
 1 file changed, 27 insertions(+), 12 deletions(-)
drivers/clk/mediatek/clk-mt8183-mm.c +6 -2
index 720c696b506d..e6dcad18d81a 100644
@@ -3,14 +3,20 @@
 // Copyright (c) 2018 MediaTek Inc.
 // Author: Weiyi Lu <[email protected]>
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
 #include <dt-bindings/clock/mt8183-clk.h>
 
+struct clk_mt8183_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs mm0_cg_regs = {
 	.set_ofs = 0x104,
 	.clr_ofs = 0x108,
@@ -84,28 +90,37 @@ static const struct mtk_gate mm_clks[] = {
 
 static int clk_mt8183_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
-	struct device_node *node = pdev->dev.of_node;

drivers/clk/mediatek/clk-mt8183-mm.c static const struct mtk_gate mm_clks[] = { · line 101

Quoted 10 lines
drivers/clk/mediatek/clk-mt8183-mm.c +8 -1
+	struct clk_mt8183_mm_priv *private;
+	struct device_node *node = pdev->dev.parent->of_node;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, private);

There is a more simple modification that you need not to define struct clk_mt8183_mm_priv,

clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
platform_set_drvdata(pdev, clk_data);

Regards,
CK

Quoted 34 lines
drivers/clk/mediatek/clk-mt8183-mm.c +13 -9
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			clk_data);
+			private->clk_data);
 
-	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	return of_clk_add_provider(node, of_clk_src_onecell_get,
+			private->clk_data);
 }
 
-static const struct of_device_id of_match_clk_mt8183_mm[] = {
-	{ .compatible = "mediatek,mt8183-mmsys", },
-	{}
-};
+static int clk_mt8183_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt8183_mm_priv *private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
+}
 
 static struct platform_driver clk_mt8183_mm_drv = {
 	.probe = clk_mt8183_mm_probe,
+	.remove = clk_mt8183_mm_remove,
 	.driver = {
 		.name = "clk-mt8183-mm",
-		.of_match_table = of_match_clk_mt8183_mm,
 	},
 };
-
-builtin_platform_driver(clk_mt8183_mm_drv);
+module_platform_driver(clk_mt8183_mm_drv);
maintainer
#27 lore raw

Re: [resend PATCH v6 10/12] clk: mediatek: mt8183: switch mmsys to platform device probing

Quoted 58 lines · CK Hu

Hi, Matthias:

Quoted 41 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt8183-mm.c | 39 +++++++++++++++++++---------
 1 file changed, 27 insertions(+), 12 deletions(-)
drivers/clk/mediatek/clk-mt8183-mm.c +6 -2
index 720c696b506d..e6dcad18d81a 100644
@@ -3,14 +3,20 @@
 // Copyright (c) 2018 MediaTek Inc.
 // Author: Weiyi Lu <[email protected]>
 
+#include <linux/module.h>
 #include <linux/clk-provider.h>
 #include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
 
 #include <dt-bindings/clock/mt8183-clk.h>
 
+struct clk_mt8183_mm_priv {
+	struct clk_onecell_data *clk_data;
+};
+
 static const struct mtk_gate_regs mm0_cg_regs = {
 	.set_ofs = 0x104,
 	.clr_ofs = 0x108,
@@ -84,28 +90,37 @@ static const struct mtk_gate mm_clks[] = {
 
 static int clk_mt8183_mm_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
-	struct device_node *node = pdev->dev.of_node;

drivers/clk/mediatek/clk-mt8183-mm.c static const struct mtk_gate mm_clks[] = { · line 101

Quoted 10 lines
drivers/clk/mediatek/clk-mt8183-mm.c +8 -1
+	struct clk_mt8183_mm_priv *private;
+	struct device_node *node = pdev->dev.parent->of_node;
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, private);

There is a more simple modification that you need not to define struct clk_mt8183_mm_priv,

Quoted 3 lines

clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
platform_set_drvdata(pdev, clk_data);

Yes you are right, I'll fix that for all the drivers.

Thanks,
Matthias

Quoted 26 lines

Regards,
CK

Quoted 23 lines
drivers/clk/mediatek/clk-mt8183-mm.c +11 -6
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			clk_data);
+			private->clk_data);
 
-	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	return of_clk_add_provider(node, of_clk_src_onecell_get,
+			private->clk_data);
 }
 
-static const struct of_device_id of_match_clk_mt8183_mm[] = {
-	{ .compatible = "mediatek,mt8183-mmsys", },
-	{}
-};
+static int clk_mt8183_mm_remove(struct platform_device *pdev)
+{
+	struct clk_mt8183_mm_priv *private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
+}
 
Quoted 12 lines

drivers/clk/mediatek/clk-mt8183-mm.c static const struct mtk_gate mm_clks[] = { · line 126

Quoted 11 lines
drivers/clk/mediatek/clk-mt8183-mm.c +2 -3
 static struct platform_driver clk_mt8183_mm_drv = {
 	.probe = clk_mt8183_mm_probe,
+	.remove = clk_mt8183_mm_remove,
 	.driver = {
 		.name = "clk-mt8183-mm",
-		.of_match_table = of_match_clk_mt8183_mm,
 	},
 };
-
-builtin_platform_driver(clk_mt8183_mm_drv);
+module_platform_driver(clk_mt8183_mm_drv);

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#28 lore raw

PATCH RESEND v6 11/12 clk: mediatek: mt8173: switch mmsys to platform device probing

In reply to [email protected]

From: Matthias Brugger <[email protected]>

Switch probing for the MMSYS to support invocation to a plain paltform device. The driver will be probed by the DRM subsystem.

---
 drivers/clk/mediatek/clk-mt8173.c | 51 ++++++++++++++++++++++++++-----
 1 file changed, 44 insertions(+), 7 deletions(-)
drivers/clk/mediatek/clk-mt8173.c +44 -7
index 537a7f49b0f7..1e6a390534e4 100644
@@ -5,8 +5,11 @@
  */
 
 #include <linux/clk.h>
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
@@ -783,7 +786,7 @@ static const struct mtk_gate_regs mm1_cg_regs __initconst = {
 		.ops = &mtk_clk_gate_ops_setclr,		\
 	}
 
-static const struct mtk_gate mm_clks[] __initconst = {
+static const struct mtk_gate mm_clks[] = {
 	/* MM0 */
 	GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0),
 	GATE_MM0(CLK_MM_SMI_LARB0, "mm_smi_larb0", "mm_sel", 1),
@@ -1144,22 +1147,56 @@ static void __init mtk_imgsys_init(struct device_node *node)
 }
 CLK_OF_DECLARE(mtk_imgsys, "mediatek,mt8173-imgsys", mtk_imgsys_init);
 
-static void __init mtk_mmsys_init(struct device_node *node)
-{
+struct mtk_mmsys_priv {
 	struct clk_onecell_data *clk_data;
+};
+
+static int mtk_mmsys_probe(struct platform_device *pdev)
+{
 	int r;
+	struct device_node *node;
+	struct mtk_mmsys_priv *private;
+
+	node = pdev->dev.parent->of_node;
 
-	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
+
+	private->clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+
+	platform_set_drvdata(pdev, private);
 
 	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-						clk_data);
+					private->clk_data);
 
-	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
+	r = of_clk_add_provider(node, of_clk_src_onecell_get,
+					private->clk_data);
 	if (r)
 		pr_err("%s(): could not register clock provider: %d\n",
 			__func__, r);
+
+	return r;
+}
+
+static int mtk_mmsys_remove(struct platform_device *pdev)
+{
+	struct mtk_mmsys_priv *private;
+	private = platform_get_drvdata(pdev);
+
+	kfree(private->clk_data);
+
+	return 0;
 }
-CLK_OF_DECLARE(mtk_mmsys, "mediatek,mt8173-mmsys", mtk_mmsys_init);
+
+static struct platform_driver clk_mt8173_mm_drv = {
+	.probe = mtk_mmsys_probe,
+	.remove = mtk_mmsys_remove,
+	.driver = {
+		.name = "clk-mt8173-mm",
+	},
+};
+module_platform_driver(clk_mt8173_mm_drv);
 
 static void __init mtk_vdecsys_init(struct device_node *node)
 {
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#29 lore raw

PATCH RESEND v6 12/12 drm/mediatek: Add support for mmsys through a pdev

In reply to [email protected]

From: Matthias Brugger <[email protected]>

The MMSYS subsystem includes clocks and drm components. This patch adds an initailization path through a platform device for the clock part, so that both drivers get probed from the same device tree compatible.

---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 24 ++++++++++++++++++++++++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |  2 ++
 2 files changed, 26 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +24 -0
index 210455e9f46c..5ada74d8d0c9 100644
@@ -186,6 +186,7 @@ static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = {
 	.ext_path = mt2701_mtk_ddp_ext,
 	.ext_len = ARRAY_SIZE(mt2701_mtk_ddp_ext),
 	.shadow_register = true,
+	.clk_drv_name = "clk-mt2701-mm",
 };
 
 static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = {
@@ -195,6 +196,7 @@ static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = {
 	.ext_len = ARRAY_SIZE(mt2712_mtk_ddp_ext),
 	.third_path = mt2712_mtk_ddp_third,
 	.third_len = ARRAY_SIZE(mt2712_mtk_ddp_third),
+	.clk_drv_name = "clk-mt2712-mm",
 };
 
 static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
@@ -202,6 +204,7 @@ static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
 	.main_len = ARRAY_SIZE(mt8173_mtk_ddp_main),
 	.ext_path = mt8173_mtk_ddp_ext,
 	.ext_len = ARRAY_SIZE(mt8173_mtk_ddp_ext),
+	.clk_drv_name = "clk-mt8173-mm",
 };
 
 static int mtk_drm_kms_init(struct drm_device *drm)
@@ -499,6 +502,24 @@ static int mtk_drm_probe(struct platform_device *pdev)
 	INIT_WORK(&private->commit.work, mtk_atomic_work);
 	private->data = of_device_get_match_data(dev);
 
+	/*
+	 * MMSYS includes apart from components management a block providing
+	 * clocks for the subsystem. We probe this clock driver via a platform
+	 * device.
+	 */
+	if (private->data->clk_drv_name) {
+		private->clk_dev = platform_device_register_data(dev,
+						private->data->clk_drv_name, -1,
+						NULL, 0);
+
+		if (IS_ERR(private->clk_dev)) {
+			dev_err(dev, "failed to register %s platform device\n",
+				private->data->clk_drv_name);
+
+			return PTR_ERR(private->clk_dev);
+		}
+	}
+
 	private->config_regs = syscon_node_to_regmap(dev->of_node);
 	if (IS_ERR(private->config_regs))
 		return PTR_ERR(private->config_regs);
@@ -605,6 +626,9 @@ static int mtk_drm_remove(struct platform_device *pdev)
 	for (i = 0; i < DDP_COMPONENT_ID_MAX; i++)
 		of_node_put(private->comp_node[i]);
 
+	if (private->clk_dev)
+		platform_device_unregister(private->clk_dev);
+
 	return 0;
 }
 
drivers/gpu/drm/mediatek/mtk_drm_drv.h +2 -0
index 63a121577dcb..8fe9136adc38 100644
@@ -29,11 +29,13 @@ struct mtk_mmsys_driver_data {
 	unsigned int third_len;
 
 	bool shadow_register;
+	const char *clk_drv_name;
 };
 
 struct mtk_drm_private {
 	struct drm_device *drm;
 	struct device *dma_dev;
+	struct platform_device *clk_dev;
 
 	unsigned int num_pipes;
 
Signature · 6 lines
2.24.0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#30 lore raw

Re: [resend PATCH v6 12/12] drm/mediatek: Add support for mmsys through a pdev

Hi, Matthias:

Quoted 6 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The MMSYS subsystem includes clocks and drm components. This patch adds an initailization path through a platform device for the clock part, so that both drivers get probed from the same device tree compatible.

You've switched mt6779 and mt6797 clock driver to platform device probing, but you does not probe then in drm driver, so your design is to let mmsys clock not work if drm driver is not enabled? It's fine for me because it seems that drm driver is the only user of mmsys clock now.

Regards,
CK

Quoted 78 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 24 ++++++++++++++++++++++++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |  2 ++
 2 files changed, 26 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +24 -0
index 210455e9f46c..5ada74d8d0c9 100644
@@ -186,6 +186,7 @@ static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = {
 	.ext_path = mt2701_mtk_ddp_ext,
 	.ext_len = ARRAY_SIZE(mt2701_mtk_ddp_ext),
 	.shadow_register = true,
+	.clk_drv_name = "clk-mt2701-mm",
 };
 
 static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = {
@@ -195,6 +196,7 @@ static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = {
 	.ext_len = ARRAY_SIZE(mt2712_mtk_ddp_ext),
 	.third_path = mt2712_mtk_ddp_third,
 	.third_len = ARRAY_SIZE(mt2712_mtk_ddp_third),
+	.clk_drv_name = "clk-mt2712-mm",
 };
 
 static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
@@ -202,6 +204,7 @@ static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
 	.main_len = ARRAY_SIZE(mt8173_mtk_ddp_main),
 	.ext_path = mt8173_mtk_ddp_ext,
 	.ext_len = ARRAY_SIZE(mt8173_mtk_ddp_ext),
+	.clk_drv_name = "clk-mt8173-mm",
 };
 
 static int mtk_drm_kms_init(struct drm_device *drm)
@@ -499,6 +502,24 @@ static int mtk_drm_probe(struct platform_device *pdev)
 	INIT_WORK(&private->commit.work, mtk_atomic_work);
 	private->data = of_device_get_match_data(dev);
 
+	/*
+	 * MMSYS includes apart from components management a block providing
+	 * clocks for the subsystem. We probe this clock driver via a platform
+	 * device.
+	 */
+	if (private->data->clk_drv_name) {
+		private->clk_dev = platform_device_register_data(dev,
+						private->data->clk_drv_name, -1,
+						NULL, 0);
+
+		if (IS_ERR(private->clk_dev)) {
+			dev_err(dev, "failed to register %s platform device\n",
+				private->data->clk_drv_name);
+
+			return PTR_ERR(private->clk_dev);
+		}
+	}
+
 	private->config_regs = syscon_node_to_regmap(dev->of_node);
 	if (IS_ERR(private->config_regs))
 		return PTR_ERR(private->config_regs);
@@ -605,6 +626,9 @@ static int mtk_drm_remove(struct platform_device *pdev)
 	for (i = 0; i < DDP_COMPONENT_ID_MAX; i++)
 		of_node_put(private->comp_node[i]);
 
+	if (private->clk_dev)
+		platform_device_unregister(private->clk_dev);
+
 	return 0;
 }
 
drivers/gpu/drm/mediatek/mtk_drm_drv.h +0 -0
index 63a121577dcb..8fe9136adc38 100644
@@ -29,11 +29,13 @@ struct mtk_mmsys_driver_data {
 	unsigned int third_len;
 
 	bool shadow_register;

drivers/gpu/drm/mediatek/mtk_drm_drv.h struct mtk_mmsys_driver_data { · line 41

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.h +2 -0
+	const char *clk_drv_name;
 };
 
 struct mtk_drm_private {
 	struct drm_device *drm;
 	struct device *dma_dev;
+	struct platform_device *clk_dev;
 
 	unsigned int num_pipes;
 

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

maintainer
#31 lore raw

Re: [resend PATCH v6 12/12] drm/mediatek: Add support for mmsys through a pdev

Quoted 10 lines · CK Hu

Hi, Matthias:

Quoted 6 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The MMSYS subsystem includes clocks and drm components. This patch adds an initailization path through a platform device for the clock part, so that both drivers get probed from the same device tree compatible.

Quoted 5 lines

You've switched mt6779 and mt6797 clock driver to platform device probing, but you does not probe then in drm driver, so your design is to let mmsys clock not work if drm driver is not enabled? It's fine for me because it seems that drm driver is the only user of mmsys clock now.

Exactly. The mmsys clocks are only needed for the drm driver. Therefor we only probe them when probing the drm driver.

Regards,
Matthias

Quoted 89 lines

Regards,
CK

Quoted 86 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 24 ++++++++++++++++++++++++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |  2 ++
 2 files changed, 26 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +24 -0
index 210455e9f46c..5ada74d8d0c9 100644
@@ -186,6 +186,7 @@ static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = {
 	.ext_path = mt2701_mtk_ddp_ext,
 	.ext_len = ARRAY_SIZE(mt2701_mtk_ddp_ext),
 	.shadow_register = true,
+	.clk_drv_name = "clk-mt2701-mm",
 };
 
 static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = {
@@ -195,6 +196,7 @@ static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = {
 	.ext_len = ARRAY_SIZE(mt2712_mtk_ddp_ext),
 	.third_path = mt2712_mtk_ddp_third,
 	.third_len = ARRAY_SIZE(mt2712_mtk_ddp_third),
+	.clk_drv_name = "clk-mt2712-mm",
 };
 
 static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
@@ -202,6 +204,7 @@ static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
 	.main_len = ARRAY_SIZE(mt8173_mtk_ddp_main),
 	.ext_path = mt8173_mtk_ddp_ext,
 	.ext_len = ARRAY_SIZE(mt8173_mtk_ddp_ext),
+	.clk_drv_name = "clk-mt8173-mm",
 };
 
 static int mtk_drm_kms_init(struct drm_device *drm)
@@ -499,6 +502,24 @@ static int mtk_drm_probe(struct platform_device *pdev)
 	INIT_WORK(&private->commit.work, mtk_atomic_work);
 	private->data = of_device_get_match_data(dev);
 
+	/*
+	 * MMSYS includes apart from components management a block providing
+	 * clocks for the subsystem. We probe this clock driver via a platform
+	 * device.
+	 */
+	if (private->data->clk_drv_name) {
+		private->clk_dev = platform_device_register_data(dev,
+						private->data->clk_drv_name, -1,
+						NULL, 0);
+
+		if (IS_ERR(private->clk_dev)) {
+			dev_err(dev, "failed to register %s platform device\n",
+				private->data->clk_drv_name);
+
+			return PTR_ERR(private->clk_dev);
+		}
+	}
+
 	private->config_regs = syscon_node_to_regmap(dev->of_node);
 	if (IS_ERR(private->config_regs))
 		return PTR_ERR(private->config_regs);
@@ -605,6 +626,9 @@ static int mtk_drm_remove(struct platform_device *pdev)
 	for (i = 0; i < DDP_COMPONENT_ID_MAX; i++)
 		of_node_put(private->comp_node[i]);
 
+	if (private->clk_dev)
+		platform_device_unregister(private->clk_dev);
+
 	return 0;
 }
 
drivers/gpu/drm/mediatek/mtk_drm_drv.h +2 -0
index 63a121577dcb..8fe9136adc38 100644
@@ -29,11 +29,13 @@ struct mtk_mmsys_driver_data {
 	unsigned int third_len;
 
 	bool shadow_register;
+	const char *clk_drv_name;
 };
 
 struct mtk_drm_private {
 	struct drm_device *drm;
 	struct device *dma_dev;
+	struct platform_device *clk_dev;
 
Quoted 8 lines

drivers/gpu/drm/mediatek/mtk_drm_drv.h struct mtk_mmsys_driver_data { · line 41

Quoted 2 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.h +0 -0
 	unsigned int num_pipes;
 

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by on v6 12/12
#32 lore raw

Re: [resend PATCH v6 12/12] drm/mediatek: Add support for mmsys through a pdev

In reply to [email protected]

Hi Matthias,

Just one nit below and LGTM

Quoted 8 lines · On 7/12/19 23:47, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The MMSYS subsystem includes clocks and drm components. This patch adds an initailization path through a platform device for the clock part, so that both drivers get probed from the same device tree compatible.

Quoted 36 lines
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 24 ++++++++++++++++++++++++
 drivers/gpu/drm/mediatek/mtk_drm_drv.h |  2 ++
 2 files changed, 26 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +3 -0
index 210455e9f46c..5ada74d8d0c9 100644
@@ -186,6 +186,7 @@ static const struct mtk_mmsys_driver_data mt2701_mmsys_driver_data = {
 	.ext_path = mt2701_mtk_ddp_ext,
 	.ext_len = ARRAY_SIZE(mt2701_mtk_ddp_ext),
 	.shadow_register = true,
+	.clk_drv_name = "clk-mt2701-mm",
 };
 
 static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = {
@@ -195,6 +196,7 @@ static const struct mtk_mmsys_driver_data mt2712_mmsys_driver_data = {
 	.ext_len = ARRAY_SIZE(mt2712_mtk_ddp_ext),
 	.third_path = mt2712_mtk_ddp_third,
 	.third_len = ARRAY_SIZE(mt2712_mtk_ddp_third),
+	.clk_drv_name = "clk-mt2712-mm",
 };
 
 static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
@@ -202,6 +204,7 @@ static const struct mtk_mmsys_driver_data mt8173_mmsys_driver_data = {
 	.main_len = ARRAY_SIZE(mt8173_mtk_ddp_main),
 	.ext_path = mt8173_mtk_ddp_ext,
 	.ext_len = ARRAY_SIZE(mt8173_mtk_ddp_ext),
+	.clk_drv_name = "clk-mt8173-mm",
 };
 
 static int mtk_drm_kms_init(struct drm_device *drm)
@@ -499,6 +502,24 @@ static int mtk_drm_probe(struct platform_device *pdev)
 	INIT_WORK(&private->commit.work, mtk_atomic_work);
 	private->data = of_device_get_match_data(dev);

drivers/gpu/drm/mediatek/mtk_drm_drv.c static int mtk_drm_probe(struct platform_device *pdev) · line 513

Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +9 -0
 
+	/*
+	 * MMSYS includes apart from components management a block providing
+	 * clocks for the subsystem. We probe this clock driver via a platform
+	 * device.
+	 */
+	if (private->data->clk_drv_name) {
+		private->clk_dev = platform_device_register_data(dev,
+						private->data->clk_drv_name, -1,
+						NULL, 0);

Replace -1 for PLATFORM_DEVID_NONE

Quoted 41 lines
drivers/gpu/drm/mediatek/mtk_drm_drv.c +12 -0
+
+		if (IS_ERR(private->clk_dev)) {
+			dev_err(dev, "failed to register %s platform device\n",
+				private->data->clk_drv_name);
+
+			return PTR_ERR(private->clk_dev);
+		}
+	}
+
 	private->config_regs = syscon_node_to_regmap(dev->of_node);
 	if (IS_ERR(private->config_regs))
 		return PTR_ERR(private->config_regs);
@@ -605,6 +626,9 @@ static int mtk_drm_remove(struct platform_device *pdev)
 	for (i = 0; i < DDP_COMPONENT_ID_MAX; i++)
 		of_node_put(private->comp_node[i]);
 
+	if (private->clk_dev)
+		platform_device_unregister(private->clk_dev);
+
 	return 0;
 }
 
drivers/gpu/drm/mediatek/mtk_drm_drv.h +2 -0
index 63a121577dcb..8fe9136adc38 100644
@@ -29,11 +29,13 @@ struct mtk_mmsys_driver_data {
 	unsigned int third_len;
 
 	bool shadow_register;
+	const char *clk_drv_name;
 };
 
 struct mtk_drm_private {
 	struct drm_device *drm;
 	struct device *dma_dev;
+	struct platform_device *clk_dev;
 
 	unsigned int num_pipes;
 
#33 lore raw
In reply to [email protected]

Hi, Matthias:

Would you work on this series in a short time? Some Yongqiang's patches
[1] also modify mmsys driver, and now it depend on your patch to prevent conflicts. If you would not work on this series in a short time, I would like to apply Yongqiang's patch without this series.

[1]
https://patchwork.kernel.org/project/linux-mediatek/list/?series=223221

Regards,
CK

Quoted 88 lines · On Sat, 2019-12-07 at 23:47 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

[reseding due to wrong mail of Stephen]

This is version five of the series. It's a long time this wasn't worked on, so as a reminder, version four can be found here:
https://patchwork.kernel.org/cover/10686247/

The biggest changes this new version does, is to implement the clock probing through a platform driver. The corresponding platform device get's created in the DRM driver. I converted all the clock drivers to platform drivers and tested the approach on the Acer Chromebook R13 (mt8173 based).
Apart from that I reordered the patches so that the DT bindings update are the first patches.

Changes since v5:
- re-arrange the patch order
- generate platform_device for mmsys clock driver inside the DRM driver
- fix DTS binding accordingly
- switch all mmsys clock driver to platform probing
- fix mt8173 platform driver remove function
- fix probe defer path in HDMI driver
- fix probe defer path in mtk_mdp_comp
- fix identation of error messages

Changes since v4:
- fix missing regmap accessors in drm diver (patch 1)
- omit probe deffered warning on all drivers (patch 5)
- update drm and clk bindings (patch 6 and 7)
- put mmsys clock part in dts child node of mmsys. Only done for HW where no dts backport compatible breakage is expected (either DRM driver not yet implemented or no HW available to the public) (patch 9 to 12)

Changes since v3:
- use platform device to probe clock driver
- add Acked-by CK Hu for the probe deferred patch

Changes since v2:
- fix kconfig typo (shame on me)
- delete __initconst from mm_clocks as converted to a platform driver

Changes since v1:
- add binding documentation
- ddp: use regmap_update_bits
- ddp: ignore EPROBE_DEFER on clock probing
- mfd: delete mmsys_private
- add Reviewed-by and Acked-by tags

MMSYS in Mediatek SoCs has some registers to control clock gates (which is used in the clk driver) and some registers to set the routing and enable the differnet blocks of the display subsystem.

Up to now both drivers, clock and drm are probed with the same device tree compatible. But only the first driver get probed, which in effect breaks graphics on mt8173 and mt2701.

This patch uses a platform device registration in the DRM driver, which will trigger the probe of the corresponding clock driver. It was tested on the bananapi-r2 and the Acer R13 Chromebook.

Matthias Brugger (12):
dt-bindings: display: mediatek: Add mmsys binding description
dt-bindings: mediatek: Add compatible for mt7623 drm/mediatek: Use regmap for register access
drm: mediatek: Omit warning on probe defers
media: mtk-mdp: Check return value of of_clk_get
clk: mediatek: mt2701: switch mmsys to platform device probing
clk: mediatek: mt2712e: switch to platform device probing
clk: mediatek: mt6779: switch mmsys to platform device probing
clk: mediatek: mt6797: switch to platform device probing
clk: mediatek: mt8183: switch mmsys to platform device probing
clk: mediatek: mt8173: switch mmsys to platform device probing drm/mediatek: Add support for mmsys through a pdev

 .../display/mediatek/mediatek,disp.txt        | 30 ++++++-----
 drivers/clk/mediatek/clk-mt2701-mm.c          | 41 +++++++++-----
 drivers/clk/mediatek/clk-mt2712-mm.c          | 39 +++++++++-----
 drivers/clk/mediatek/clk-mt6779-mm.c          | 41 +++++++++-----
 drivers/clk/mediatek/clk-mt6797-mm.c          | 43 ++++++++++-----
 drivers/clk/mediatek/clk-mt8173.c             | 51 +++++++++++++++---
 drivers/clk/mediatek/clk-mt8183-mm.c          | 39 +++++++++-----
 drivers/gpu/drm/mediatek/mtk_disp_color.c     |  5 +-
 drivers/gpu/drm/mediatek/mtk_disp_ovl.c       |  5 +-
 drivers/gpu/drm/mediatek/mtk_disp_rdma.c      |  5 +-
 drivers/gpu/drm/mediatek/mtk_dpi.c            | 12 +++--
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c       |  4 +-
Quoted 9 lines
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c        | 54 +++++++++----------
 drivers/gpu/drm/mediatek/mtk_drm_ddp.h        |  4 +-
 drivers/gpu/drm/mediatek/mtk_drm_drv.c        | 35 +++++++++---
 drivers/gpu/drm/mediatek/mtk_drm_drv.h        |  4 +-
 drivers/gpu/drm/mediatek/mtk_dsi.c            |  8 ++-
 drivers/gpu/drm/mediatek/mtk_hdmi.c           |  4 +-
 drivers/media/platform/mtk-mdp/mtk_mdp_comp.c |  6 +++
 19 files changed, 295 insertions(+), 135 deletions(-)

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