Skip to contentSkip to conversation

arm/arm64: mediatek: Fix mmsys device probing

PATCH In review [email protected] 6 participants 22 messages Feb 13, 2020 – Feb 24, 2020

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

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

From: Matthias Brugger <[email protected]>

This is version seven of the series. The biggest change is, that I added a first patch that actually moves the mmsys binding from arm/mediatek to display/mediatek, as in effect the mmsys is part of the display subsystem.

Since version five, the clock probing is implemented 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.

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 Acer R13 Chromebook.

Changes in v7:
- move the binding description
- add hint to the mmsys binding document
- make mmsys description generic
- fix typo in commit message
- fix check of return value of of_clk_get
- free clk_data->clks as well
- get rid of private data structure

Changes in v6:
- 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 in v5:
- 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 in v4:
- use platform device to probe clock driver
- add Acked-by CK Hu for the probe deferred patch

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

Changes in v2:
- 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

Matthias Brugger (13):
dt-bindings: arm: move mmsys description to display
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        |  5 ++
 .../mediatek/mediatek,mmsys.txt               |  9 +---
 drivers/clk/mediatek/clk-mt2701-mm.c          | 34 ++++++++----
 drivers/clk/mediatek/clk-mt2712-mm.c          | 32 +++++++----
 drivers/clk/mediatek/clk-mt6779-mm.c          | 32 +++++++----
 drivers/clk/mediatek/clk-mt6797-mm.c          | 34 ++++++++----
 drivers/clk/mediatek/clk-mt8173.c             | 45 +++++++++++++---
 drivers/clk/mediatek/clk-mt8183-mm.c          | 30 +++++++----
 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        | 53 ++++++++-----------
 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 +++
 20 files changed, 246 insertions(+), 120 deletions(-)
 rename Documentation/devicetree/bindings/{arm => display}/mediatek/mediatek,mmsys.txt (61%)
Signature · 6 lines
2.24.1

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

PATCH v7 1/13 dt-bindings: arm: move mmsys description to display

From: Matthias Brugger <[email protected]>

The mmsys block provides registers and clocks for the display subsystem. The binding description should therefore live together with the rest of the display descriptions. Move it to display/mediatek.

---

Changes in v7:
- move the binding description

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 .../bindings/{arm => display}/mediatek/mediatek,mmsys.txt         | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/{arm => display}/mediatek/mediatek,mmsys.txt (100%)
Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt renamed from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt +0 -0
similarity index 100%
rename from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
rename to Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt
Signature · 1 line
2.24.1
#6 lore raw

PATCH v7 2/13 dt-bindings: display: mediatek: Add mmsys binding description

In reply to [email protected]

From: Matthias Brugger <[email protected]>

The MediaTek DRM has a block called mmsys, which sets
the routing and enables the different blocks.
This patch adds one line for the mmsys bindings description and changes the mmsys description to use the generic form of referring to a specific Soc.

---

Changes in v7:
- add hint to the mmsys binding document
- make mmsys description generic
- fix typo in commit message

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 .../bindings/display/mediatek/mediatek,disp.txt          | 3 +++
 .../bindings/display/mediatek/mediatek,mmsys.txt         | 9 +--------
 2 files changed, 4 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +3 -0
index b91e709db7a4..8e453026ef78 100644
@@ -24,6 +24,7 @@ connected to.
 For a description of the display interface sink function blocks, see
 Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt and
 Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt.
+Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt.
 
 Required properties (all function blocks):
 - compatible: "mediatek,<chip>-disp-<function>", one of
@@ -43,7 +44,9 @@ Required properties (all function blocks):
 	"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).
Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt +1 -8
index 301eefbe1618..7bbadee820e3 100644
@@ -5,14 +5,7 @@ The Mediatek mmsys controller provides various clocks to the system.
 
 Required Properties:
 
-- compatible: Should be one of:
-	- "mediatek,mt2701-mmsys", "syscon"
-	- "mediatek,mt2712-mmsys", "syscon"
-	- "mediatek,mt6779-mmsys", "syscon"
-	- "mediatek,mt6797-mmsys", "syscon"
-	- "mediatek,mt7623-mmsys", "mediatek,mt2701-mmsys", "syscon"
-	- "mediatek,mt8173-mmsys", "syscon"
-	- "mediatek,mt8183-mmsys", "syscon"
+- compatible: "mediatek,<chip>-mmsys"
 - #clock-cells: Must be 1
 
 The mmsys controller uses the common clk binding from
Signature · 6 lines
2.24.1

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

PATCH v7 3/13 dt-bindings: mediatek: Add compatible for mt7623

In reply to [email protected]

From: Matthias Brugger <[email protected]>

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

---

Changes in v7:
- fix typo in commit message
- add Rob's ack

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 .../devicetree/bindings/display/mediatek/mediatek,disp.txt      | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +2 -0
index 8e453026ef78..456e502f538c 100644
@@ -46,6 +46,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.1

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

PATCH v7 4/13 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.

---

Changes in v7:
- add R-by from CK

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 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 0dfcd1787e65..ea003a225604 100644
@@ -28,7 +28,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
@@ -50,7 +50,7 @@ struct mtk_drm_crtc {
 	u32				cmdq_event;
 #endif
 
-	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 0563c6813333..b68837ea02b3 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>
@@ -425,7 +426,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;
@@ -437,14 +437,9 @@ static int mtk_drm_probe(struct platform_device *pdev)
 
 	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 17bc99b9f5d4..03201080688d 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 · 1 line
2.24.1
#10 lore raw

PATCH v7 5/13 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.

---

Changes in v7:
- add Rv-by from CK

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 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    |  3 ++-
 drivers/gpu/drm/mediatek/mtk_dsi.c        |  8 ++++++--
 drivers/gpu/drm/mediatek/mtk_hdmi.c       |  4 +++-
 7 files changed, 32 insertions(+), 10 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_color.c +4 -1
index 6fb0d6983a4a..3ae9c810845b 100644
@@ -119,7 +119,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 891d80c73e04..28651bc579bc 100644
@@ -386,7 +386,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 0cb848d64206..e04319fedf46 100644
@@ -294,7 +294,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 01fa8b8d763d..1b219edef541 100644
@@ -701,21 +701,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 +2 -1
index 302753744cc6..39700b9428b9 100644
@@ -620,7 +620,8 @@ static int mtk_ddp_probe(struct platform_device *pdev)
 	if (!ddp->data->no_clk) {
 		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 5fa1073cf26b..a45ed0270531 100644
@@ -1194,14 +1194,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);
 		goto err_unregister_host;
 	}
 
 	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);
 		goto err_unregister_host;
 	}
 
drivers/gpu/drm/mediatek/mtk_hdmi.c +3 -1
index 5e4a4dbda443..69c6a146c561 100644
@@ -1451,7 +1451,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.1

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

PATCH v7 6/13 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.

---

Changes in v7:
- fix check of return value of of_clk_get
- fix identation

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 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 0c4788af78dd..58abfbdfb82d 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])) {
+			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.1

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

PATCH v7 7/13 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.

---

Changes in v7:
- free clk_data->clks as well
- get rid of private data structure

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/clk/mediatek/clk-mt2701-mm.c | 34 +++++++++++++++++++---------
 1 file changed, 23 insertions(+), 11 deletions(-)
drivers/clk/mediatek/clk-mt2701-mm.c +23 -11
index 054b597d4a73..eab7dd4735ad 100644
@@ -4,8 +4,10 @@
  * 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"
@@ -79,21 +81,21 @@ 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_onecell_data *clk_data;
+
+	clk_data = devm_kzalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL);
+	if (!clk_data)
+		return -ENOMEM;
 
 	clk_data = mtk_alloc_clk_data(CLK_MM_NR);
 
-	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-						clk_data);
+	platform_set_drvdata(pdev, clk_data);
+
+	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), clk_data);
 
 	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
 	if (r)
@@ -104,12 +106,22 @@ static int clk_mt2701_mm_probe(struct platform_device *pdev)
 	return r;
 }
 
+static int clk_mt2701_mm_remove(struct platform_device *pdev)
+{
+	struct clk_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+	kfree(clk_data->clks);
+	kfree(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.1

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

PATCH v7 8/13 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.

---

Changes in v7:
- free clk_data->clks as well
- get rid of private data structure

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/clk/mediatek/clk-mt2712-mm.c | 32 ++++++++++++++++++----------
 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/clk/mediatek/clk-mt2712-mm.c +21 -11
index 1c5948be35f3..2ab86262dc17 100644
@@ -4,8 +4,10 @@
  * 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"
@@ -128,14 +130,18 @@ 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_onecell_data *clk_data;
+
+	clk_data = devm_kzalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL);
+	if (!clk_data)
+		return -ENOMEM;
 
 	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, clk_data);
 
-	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			clk_data);
+	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), clk_data);
 
 	r = of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
 
@@ -146,17 +152,21 @@ 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_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+	kfree(clk_data->clks);
+	kfree(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.1

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

PATCH v7 9/13 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.

---

Changes in v7:
- free clk_data->clks as well
- get rid of private data structure

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/clk/mediatek/clk-mt6779-mm.c | 32 ++++++++++++++++++----------
 1 file changed, 21 insertions(+), 11 deletions(-)
drivers/clk/mediatek/clk-mt6779-mm.c +21 -11
index fb5fbb8e3e41..70a1f3b413ba 100644
@@ -4,9 +4,11 @@
  * 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"
@@ -84,30 +86,38 @@ 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 device_node *node = pdev->dev.parent->of_node;
+
+	clk_data = devm_kzalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL);
+	if (!clk_data)
+		return -ENOMEM;
 
 	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, clk_data);
 
-	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			       clk_data);
+	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), clk_data);
 
 	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
 }
 
+static int clk_mt6779_mm_remove(struct platform_device *pdev)
+{
+	struct clk_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+	kfree(clk_data->clks);
+	kfree(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.1

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

PATCH v7 10/13 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.

---

Changes in v7:
- free clk_data->clks as well
- get rid of private data structure

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/clk/mediatek/clk-mt6797-mm.c | 34 +++++++++++++++++++---------
 1 file changed, 23 insertions(+), 11 deletions(-)
drivers/clk/mediatek/clk-mt6797-mm.c +23 -11
index 8f05653b387d..6a3c54b6b793 100644
@@ -4,8 +4,10 @@
  * 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"
@@ -92,23 +94,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;
 	int r;
-	struct device_node *node = pdev->dev.of_node;
+	struct device *parent = pdev->dev.parent;
+
+	clk_data = devm_kzalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL);
+	if (!clk_data)
+		return -ENOMEM;
 
 	clk_data = mtk_alloc_clk_data(CLK_MM_NR);
+	platform_set_drvdata(pdev, clk_data);
 
-	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
+	mtk_clk_register_gates(parent->of_node, mm_clks, ARRAY_SIZE(mm_clks),
 			       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,
+				clk_data);
 	if (r)
 		dev_err(&pdev->dev,
 			"could not register clock provider: %s: %d\n",
@@ -117,12 +120,21 @@ static int clk_mt6797_mm_probe(struct platform_device *pdev)
 	return r;
 }
 
+static int clk_mt6797_mm_remove(struct platform_device *pdev)
+{
+	struct clk_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+	kfree(clk_data->clks);
+	kfree(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.1

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

PATCH v7 11/13 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.

---

Changes in v7:
- free clk_data->clks as well
- get rid of private data structure

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/clk/mediatek/clk-mt8183-mm.c | 30 ++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/clk/mediatek/clk-mt8183-mm.c +20 -10
index 720c696b506d..7576cd231be3 100644
@@ -3,8 +3,10 @@
 // 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"
@@ -85,27 +87,35 @@ 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 device_node *node = pdev->dev.parent->of_node;
+
+	clk_data = devm_kzalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL);
+	if (!clk_data)
+		return -ENOMEM;
 
 	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, clk_data);
 
-	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			clk_data);
+	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), clk_data);
 
 	return of_clk_add_provider(node, of_clk_src_onecell_get, 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_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+	kfree(clk_data->clks);
+	kfree(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.1

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

PATCH v7 12/13 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.

---

Changes in v7:
- add blank line after declaration
- free clk_data->clks as well
- get rid of private data structure

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/clk/mediatek/clk-mt8173.c | 45 ++++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 6 deletions(-)
drivers/clk/mediatek/clk-mt8173.c +39 -6
index 537a7f49b0f7..0608d9fffef7 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,52 @@ 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)
+static int mtk_mmsys_probe(struct platform_device *pdev)
 {
-	struct clk_onecell_data *clk_data;
 	int r;
+	struct device_node *node;
+	struct clk_onecell_data *clk_data;
+
+	node = pdev->dev.parent->of_node;
+
+	clk_data = devm_kzalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL);
+	if (!clk_data)
+		return -ENOMEM;
 
 	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
 
-	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-						clk_data);
+	platform_set_drvdata(pdev, clk_data);
+
+	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), clk_data);
 
 	r = of_clk_add_provider(node, of_clk_src_onecell_get, 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 clk_onecell_data *clk_data;
+
+	clk_data = platform_get_drvdata(pdev);
+
+	kfree(clk_data->clks);
+	kfree(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.1

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

PATCH v7 13/13 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.

---

Changes in v7:
- Add Rv-by from Enric

Changes in v6:
- 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 in v5:
- 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 in v4:
- use platform device to probe clock driver
- add Acked-by CK Hu for the probe deferred patch

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

Changes in v2:
- 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

 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 b68837ea02b3..68605dedf997 100644
@@ -125,6 +125,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 = {
@@ -134,6 +135,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 = {
@@ -141,6 +143,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)
@@ -437,6 +440,24 @@ static int mtk_drm_probe(struct platform_device *pdev)
 
 	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);
@@ -544,6 +565,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 03201080688d..15652264c233 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.1

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

Re: [PATCH v7 11/13] clk: mediatek: mt8183: switch mmsys to platform device probing

In reply to [email protected]

Hi, Matthias:

Quoted 38 lines · On Thu, 2020-02-13 at 21:19 +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.

---

Changes in v7:
- free clk_data->clks as well
- get rid of private data structure

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 drivers/clk/mediatek/clk-mt8183-mm.c | 30 ++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)
drivers/clk/mediatek/clk-mt8183-mm.c +2 -0
index 720c696b506d..7576cd231be3 100644
@@ -3,8 +3,10 @@
 // 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"

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

Quoted 7 lines
drivers/clk/mediatek/clk-mt8183-mm.c +3 -1
@@ -85,27 +87,35 @@ 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 device_node *node = pdev->dev.parent->of_node;
+
+	clk_data = devm_kzalloc(&pdev->dev, sizeof(*clk_data), GFP_KERNEL);

I think this is redundant.

Quoted 13 lines
drivers/clk/mediatek/clk-mt8183-mm.c +4 -2
+	if (!clk_data)
+		return -ENOMEM;
 
 	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
+	platform_set_drvdata(pdev, clk_data);
 
-	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks),
-			clk_data);
+	mtk_clk_register_gates(node, mm_clks, ARRAY_SIZE(mm_clks), clk_data);
 
 	return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
 }
 

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

Quoted 10 lines
drivers/clk/mediatek/clk-mt8183-mm.c +6 -4
-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_onecell_data *clk_data = platform_get_drvdata(pdev);
+
+	kfree(clk_data->clks);
+	kfree(clk_data);

These two statement looks like a reverse of mtk_alloc_clk_data() and exist in many files. It is worth to have a function (maybe mtk_free_clk_data()) to do this.

In addition, should we undo what is done in clk_mt8183_mm_probe() such as mtk_clk_register_gates() and of_clk_add_provider()?

Regards,
CK

Quoted 5 lines
drivers/clk/mediatek/clk-mt8183-mm.c +3 -0
+
+	return 0;
+}
 
 static struct platform_driver clk_mt8183_mm_drv = {

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

Quoted 10 lines
drivers/clk/mediatek/clk-mt8183-mm.c +2 -3
 	.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);

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

#2 lore raw

Re: [PATCH v7 01/13] dt-bindings: arm: move mmsys description to display

In reply to [email protected]

Hi, Matthias:

Quoted 6 lines · On Thu, 2020-02-13 at 21:19 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The mmsys block provides registers and clocks for the display subsystem. The binding description should therefore live together with the rest of the display descriptions. Move it to display/mediatek.

Yes, for the upstreamed driver, only display (DRM) use mmsys clock. For some MDP patches [1] in progress, MDP also use mmsys clock. So we just consider what's upstreamed now?

[1] https://patchwork.kernel.org/patch/11140747/

Regards,
CK

Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt

Quoted 21 lines

---

Changes in v7:
- move the binding description

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 .../bindings/{arm => display}/mediatek/mediatek,mmsys.txt         | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/{arm => display}/mediatek/mediatek,mmsys.txt (100%)
Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt renamed from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt +0 -0
similarity index 100%
rename from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
rename to Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt

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

maintainer
#3 lore raw

Re: [PATCH v7 01/13] dt-bindings: arm: move mmsys description to display

Quoted 5 lines · CK Hu

Hi, Matthias:

Quoted 2 lines · On Thu, 2020-02-13 at 21:19 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Quoted 8 lines
Quoted 4 lines

The mmsys block provides registers and clocks for the display subsystem. The binding description should therefore live together with the rest of the display descriptions. Move it to display/mediatek.

Yes, for the upstreamed driver, only display (DRM) use mmsys clock. For some MDP patches [1] in progress, MDP also use mmsys clock. So we just consider what's upstreamed now?

I'm not sure if I understand you correctly. Are you proposing to keep the binding description in arm/mediatek?

Regards,
Matthias

Quoted 33 lines

[1] https://patchwork.kernel.org/patch/11140747/

Regards,
CK

Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt

Quoted 21 lines

---

Changes in v7:
- move the binding description

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 .../bindings/{arm => display}/mediatek/mediatek,mmsys.txt         | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/{arm => display}/mediatek/mediatek,mmsys.txt (100%)
Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt renamed from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt +0 -0
similarity index 100%
rename from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
rename to Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt

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

#4 lore raw

Re: [PATCH v7 01/13] dt-bindings: arm: move mmsys description to display

Hi CK,

Quoted 8 lines · Matthias Brugger
Quoted 5 lines · CK Hu

Hi, Matthias:

Quoted 2 lines · On Thu, 2020-02-13 at 21:19 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

The mmsys block provides registers and clocks for the display subsystem. The binding description should therefore live together with the rest of the display descriptions. Move it to display/mediatek.

Yes, for the upstreamed driver, only display (DRM) use mmsys clock. For some MDP patches [1] in progress, MDP also use mmsys clock. So we just consider what's upstreamed now?

Let me jump into the discussion, and sorry if my question is silly because I'm just starting to look at this code.

IMO we should consider all the cases to find a proper fix on all this, and if MDP uses also mmsys clocks this approach will not work. I think the main problem here and the big question is what exactly is the MMSYS block, is an independent clock controller that provides clocks to DRM and other blocks? or is hardly tied to the DRM block in some way?

Could you give us a block schema on how the things are interconnected?

If is an independent clock controller I think there was a mistake when the first drm driver was pushed by using the compatible = "mediatek,mt8173-mmsys" as id for that driver.

Thanks,
Enric

Quoted 39 lines

I'm not sure if I understand you correctly. Are you proposing to keep the binding description in arm/mediatek?

Regards,
Matthias

Quoted 33 lines

[1] https://patchwork.kernel.org/patch/11140747/

Regards,
CK

Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt

Quoted 21 lines

---

Changes in v7:
- move the binding description

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 .../bindings/{arm => display}/mediatek/mediatek,mmsys.txt         | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/{arm => display}/mediatek/mediatek,mmsys.txt (100%)
Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt renamed from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt +0 -0
similarity index 100%
rename from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
rename to Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt

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

#5 lore raw

Re: [PATCH v7 01/13] dt-bindings: arm: move mmsys description to display

Hi, Matthias & Enric:

Quoted 30 lines · Enric Balletbo i Serra

Hi CK,

Quoted 8 lines · Matthias Brugger
Quoted 5 lines · CK Hu

Hi, Matthias:

Quoted 2 lines · On Thu, 2020-02-13 at 21:19 +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines

The mmsys block provides registers and clocks for the display subsystem. The binding description should therefore live together with the rest of the display descriptions. Move it to display/mediatek.

Yes, for the upstreamed driver, only display (DRM) use mmsys clock. For some MDP patches [1] in progress, MDP also use mmsys clock. So we just consider what's upstreamed now?

Let me jump into the discussion, and sorry if my question is silly because I'm just starting to look at this code.

IMO we should consider all the cases to find a proper fix on all this, and if MDP uses also mmsys clocks this approach will not work. I think the main problem here and the big question is what exactly is the MMSYS block, is an independent clock controller that provides clocks to DRM and other blocks? or is hardly tied to the DRM block in some way?

Quoted 6 lines

Could you give us a block schema on how the things are interconnected?

If is an independent clock controller I think there was a mistake when the first drm driver was pushed by using the compatible = "mediatek,mt8173-mmsys" as id for that driver.

I correct my mistake first. In mt8173, mdp has already upstreamed [1].

There are many partitions in Mediatek SoC. mmsys is one of these partition. There are many function blocks in mmsys such as OVL, RDMA, RSZ, WROT, .... Some data routing between these blocks are fixed but some are changeable. For application, we group them into display path and mdp path. Clock gating register of these blocks are in the range of 0x14000000 ~ 0x14000fff. The routing control register of these blocks are also in the range of 0x14000000 ~ 0x14000fff. So the control function belong to mmsys partition but not belong to specific function block would in the register range of 0x14000000 ~ 0x14000fff. I think there could be two definition of mmsys device. One is that mmsys device is the whole mmsys partiotion, so OVL, RDMA, ... would be sub device of it. Another is that mmsys just control register of 0x14000000 ~ 0x14000fff, so it's part of mmsys partition like OVL, RDMA, ..... Currently we define mmsys as the latter one. I've no idea how to map mmsys into current Linux hardware category, but I think it is not just a display device.

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arm64/boot/dts/mediatek/mt8173.dtsi?h=v5.6-rc1

Regards,
CK

Quoted 44 lines

Thanks,
Enric

Quoted 39 lines

I'm not sure if I understand you correctly. Are you proposing to keep the binding description in arm/mediatek?

Regards,
Matthias

Quoted 33 lines

[1] https://patchwork.kernel.org/patch/11140747/

Regards,
CK

Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt

Quoted 21 lines

---

Changes in v7:
- move the binding description

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 .../bindings/{arm => display}/mediatek/mediatek,mmsys.txt         | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/devicetree/bindings/{arm => display}/mediatek/mediatek,mmsys.txt (100%)
Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt renamed from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt +0 -0
similarity index 100%
rename from Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
rename to Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt

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

Quoted 4 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
#7 lore raw

Re: [PATCH v7 02/13] dt-bindings: display: mediatek: Add mmsys binding description

In reply to [email protected]
Quoted 54 lines · On Thu, Feb 13, 2020 at 09:19:42PM +0100, [email protected] wrote:

From: Matthias Brugger <[email protected]>

The MediaTek DRM has a block called mmsys, which sets
the routing and enables the different blocks.
This patch adds one line for the mmsys bindings description and changes the mmsys description to use the generic form of referring to a specific Soc.

---

Changes in v7:
- add hint to the mmsys binding document
- make mmsys description generic
- fix typo in commit message

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 .../bindings/display/mediatek/mediatek,disp.txt          | 3 +++
 .../bindings/display/mediatek/mediatek,mmsys.txt         | 9 +--------
 2 files changed, 4 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +3 -0
index b91e709db7a4..8e453026ef78 100644
@@ -24,6 +24,7 @@ connected to.
 For a description of the display interface sink function blocks, see
 Documentation/devicetree/bindings/display/mediatek/mediatek,dsi.txt and
 Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt.
+Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt.
 
 Required properties (all function blocks):
 - compatible: "mediatek,<chip>-disp-<function>", one of
@@ -43,7 +44,9 @@ Required properties (all function blocks):
 	"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).
Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt +0 -0
index 301eefbe1618..7bbadee820e3 100644

Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt The Mediatek mmsys controller provides various clocks to the system. · line 13

Quoted 9 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt +0 -6
@@ -5,14 +5,7 @@ The Mediatek mmsys controller provides various clocks to the system.
 
 Required Properties:
 
-- compatible: Should be one of:
-	- "mediatek,mt2701-mmsys", "syscon"
-	- "mediatek,mt2712-mmsys", "syscon"
-	- "mediatek,mt6779-mmsys", "syscon"
-	- "mediatek,mt6797-mmsys", "syscon"
-	- "mediatek,mt7623-mmsys", "mediatek,mt2701-mmsys", "syscon"

You've lost this information about the fallback...

Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt The Mediatek mmsys controller provides various clocks to the system. · line 8

Quoted 3 lines
Documentation/devicetree/bindings/display/mediatek/mediatek,mmsys.txt +1 -2
-	- "mediatek,mt8173-mmsys", "syscon"
-	- "mediatek,mt8183-mmsys", "syscon"
+- compatible: "mediatek,<chip>-mmsys"

You are just going to have to add these all back when this is converted to schema.

Rob

#12 lore raw

Re: [PATCH v7 06/13] media: mtk-mdp: Check return value of of_clk_get

In reply to [email protected]

Hi Matthias,

Quoted 6 lines · On 2/13/20 9:19 PM, [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.

This patch is independent from the remainder of this series, right? It looks good to me, so is it OK if I merge this in the media subsystem?

Regards,

Hans

Quoted 34 lines

---

Changes in v7:
- fix check of return value of of_clk_get
- fix identation

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 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 0c4788af78dd..58abfbdfb82d 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])) {
+			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)
maintainer
#13 lore raw

Re: [PATCH v7 06/13] media: mtk-mdp: Check return value of of_clk_get

Quoted 5 lines · Hans Verkuil

Hi Matthias,

Quoted 2 lines · On 2/13/20 9:19 PM, [email protected] wrote:

From: Matthias Brugger <[email protected]>

Quoted 8 lines
Quoted 4 lines

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

This patch is independent from the remainder of this series, right? It looks good to me, so is it OK if I merge this in the media subsystem?

Yes it is independent. Please merge it to the media subsystem.

Thanks,
Matthias

Quoted 35 lines

Regards,

Hans

Quoted 31 lines

---

Changes in v7:
- fix check of return value of of_clk_get
- fix identation

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 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 0c4788af78dd..58abfbdfb82d 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])) {
+			if (PTR_ERR(comp->clk[i]) != -EPROBE_DEFER)
+				dev_err(dev, "Failed to get clock\n");
+
+			return PTR_ERR(comp->clk[i]);
+		}
 
Quoted 4 lines

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

Quoted 3 lines
drivers/media/platform/mtk-mdp/mtk_mdp_comp.c +0 -0
 		/* Only RDMA needs two clocks */
 		if (comp->type != MTK_MDP_RDMA)

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