linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing
@ 2017-11-14 21:41 Matthias Brugger
  2017-11-14 21:41 ` [PATCH 1/8] drm/mediatek: Use regmap for register access Matthias Brugger
                   ` (7 more replies)
  0 siblings, 8 replies; 27+ messages in thread
From: Matthias Brugger @ 2017-11-14 21:41 UTC (permalink / raw)
  To: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, matthias.bgg, dri-devel, linux-kernel,
	linux-arm-kernel, linux-mediatek, Matthias Brugger

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 set introduces a new mfd device, which binds against the mmsys
compatible and takes care of probing the needed devices. It was tested on the
bananapi-r2 and the Acer R13 Chromebook.

Matthias Brugger (8):
  drm/mediatek: Use regmap for register access
  mfd: mtk-mmsys: Add mmsys driver
  drm/mediatek: mt2701: switch to mfd probing.
  clk: mediatek: mt2701-mm: switch to mfd device
  mfd: mtk-mmsys: Add mt8173 nodes
  drm/mediatek: Add mfd support for mt8173
  clk: mediatek: mt8173-mm: switch to mfd device
  MAINTAINERS: update Mediatek Soc entry

 MAINTAINERS                             |   2 +
 drivers/clk/mediatek/clk-mt2701-mm.c    |  13 ++--
 drivers/clk/mediatek/clk-mt8173.c       |  21 ++++++-
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c |   4 +-
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c  |  30 +++++----
 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  |   2 +-
 drivers/mfd/Kconfig                     |   9 +++
 drivers/mfd/Makefile                    |   2 +
 drivers/mfd/mtk-mmsys.c                 | 105 ++++++++++++++++++++++++++++++++
 include/linux/mfd/mmsys.h               |  18 ++++++
 12 files changed, 200 insertions(+), 45 deletions(-)
 create mode 100644 drivers/mfd/mtk-mmsys.c
 create mode 100644 include/linux/mfd/mmsys.h

-- 
2.14.2

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [PATCH 1/8] drm/mediatek: Use regmap for register access
  2017-11-14 21:41 [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing Matthias Brugger
@ 2017-11-14 21:41 ` Matthias Brugger
  2017-11-23  5:44   ` CK Hu
  2017-11-23  8:54   ` Philipp Zabel
  2017-11-14 21:41 ` [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver Matthias Brugger
                   ` (6 subsequent siblings)
  7 siblings, 2 replies; 27+ messages in thread
From: Matthias Brugger @ 2017-11-14 21:41 UTC (permalink / raw)
  To: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, matthias.bgg, dri-devel, linux-kernel,
	linux-arm-kernel, linux-mediatek, Matthias Brugger

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

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c |  4 ++--
 drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 30 +++++++++++++++++-------------
 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, 26 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 658b8dd45b83..4c65873b4867 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -33,7 +33,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
@@ -48,7 +48,7 @@ struct mtk_drm_crtc {
 	struct drm_plane		planes[OVL_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;
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
index 8130f3dab661..1227d6db07da 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
@@ -185,16 +185,16 @@ 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);
 }
 
-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)
 {
@@ -202,20 +202,22 @@ void mtk_ddp_add_comp_to_path(void __iomem *config_regs,
 
 	value = mtk_ddp_mout_en(cur, next, &addr);
 	if (value) {
-		reg = readl_relaxed(config_regs + addr) | value;
-		writel_relaxed(reg, config_regs + addr);
+		regmap_read(config_regs, addr, &reg);
+		reg |= value;
+		regmap_write(config_regs, addr, reg);
 	}
 
 	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);
+		regmap_read(config_regs, addr, &reg);
+		reg |= value;
+		regmap_write(config_regs, addr, reg);
 	}
 }
 
-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)
 {
@@ -223,14 +225,16 @@ void mtk_ddp_remove_comp_from_path(void __iomem *config_regs,
 
 	value = mtk_ddp_mout_en(cur, next, &addr);
 	if (value) {
-		reg = readl_relaxed(config_regs + addr) & ~value;
-		writel_relaxed(reg, config_regs + addr);
+		regmap_read(config_regs, addr, &reg);
+		reg &= ~value;
+		regmap_write(config_regs, addr, reg);
 	}
 
 	value = mtk_ddp_sel_in(cur, next, &addr);
 	if (value) {
-		reg = readl_relaxed(config_regs + addr) & ~value;
-		writel_relaxed(reg, config_regs + addr);
+		regmap_read(config_regs, addr, &reg);
+		reg &= ~value;
+		regmap_write(config_regs, addr, reg);
 	}
 }
 
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp.h
index f9a799168077..32e12f33b76a 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.h
@@ -20,10 +20,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);
 
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index b2ad19bd1e00..dd249cf5121e 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -21,6 +21,7 @@
 #include <drm/drm_of.h>
 #include <linux/component.h>
 #include <linux/iommu.h>
+#include <linux/mfd/syscon.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/pm_runtime.h>
@@ -393,7 +394,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;
@@ -407,14 +407,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) {
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
index 4edc0023684c..86cec19193c4 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
@@ -44,7 +44,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;
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver
  2017-11-14 21:41 [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing Matthias Brugger
  2017-11-14 21:41 ` [PATCH 1/8] drm/mediatek: Use regmap for register access Matthias Brugger
@ 2017-11-14 21:41 ` Matthias Brugger
  2017-11-23  9:04   ` CK Hu
  2017-11-23  9:09   ` Philipp Zabel
  2017-11-14 21:41 ` [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing Matthias Brugger
                   ` (5 subsequent siblings)
  7 siblings, 2 replies; 27+ messages in thread
From: Matthias Brugger @ 2017-11-14 21:41 UTC (permalink / raw)
  To: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, matthias.bgg, dri-devel, linux-kernel,
	linux-arm-kernel, linux-mediatek, Matthias Brugger

The MMSYS subsystem includes clocks and drm components.
This patch adds a MFD device to probe both drivers from the same
device tree compatible.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 drivers/mfd/Kconfig       |  9 +++++
 drivers/mfd/Makefile      |  2 ++
 drivers/mfd/mtk-mmsys.c   | 91 +++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/mmsys.h | 18 ++++++++++
 4 files changed, 120 insertions(+)
 create mode 100644 drivers/mfd/mtk-mmsys.c
 create mode 100644 include/linux/mfd/mmsys.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index fc5e4fef89d2..3250ce5d205a 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -368,6 +368,15 @@ config MFD_MC13XXX_I2C
 	help
 	  Select this if your MC13xxx is connected via an I2C bus.
 
+config MFD_MEDIATEK_MMSYS
+	tristate "Mediatek MMSYS interface"
+	select MDF_CORE
+	select REGMAP_MMIO
+	help
+	  Select this if you have a MMSYS subsystem in your SoC. The
+	  MMSYS subsystem has at least a clock driver part and some
+	  DRM components.
+
 config MFD_MXS_LRADC
 	tristate "Freescale i.MX23/i.MX28 LRADC"
 	depends on ARCH_MXS || COMPILE_TEST
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 8703ff17998e..d4fc99df784c 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -100,6 +100,8 @@ obj-$(CONFIG_MFD_MC13XXX)	+= mc13xxx-core.o
 obj-$(CONFIG_MFD_MC13XXX_SPI)	+= mc13xxx-spi.o
 obj-$(CONFIG_MFD_MC13XXX_I2C)	+= mc13xxx-i2c.o
 
+obj-$(CONFIG_MFD_MEDIATEK_MMSYS) += mtk-mmsys.o
+
 obj-$(CONFIG_MFD_CORE)		+= mfd-core.o
 
 obj-$(CONFIG_EZX_PCAP)		+= ezx-pcap.o
diff --git a/drivers/mfd/mtk-mmsys.c b/drivers/mfd/mtk-mmsys.c
new file mode 100644
index 000000000000..102b491aa28f
--- /dev/null
+++ b/drivers/mfd/mtk-mmsys.c
@@ -0,0 +1,91 @@
+/*
+ * mtk-mmsys.c  --  Mediatek MMSYS multi-function driver
+ *
+ *  Copyright (c) 2017 Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * Author: Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * For licencing details see kernel-base/COPYING
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/mmsys.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+
+enum {
+	MMSYS_MT2701 = 1,
+};
+
+static const struct mfd_cell mmsys_mt2701_devs[] = {
+	{ .name = "clk-mt2701-mm", },
+	{ .name = "drm-mt2701-mm", },
+};
+
+static int mmsys_probe(struct platform_device *pdev)
+{
+	struct mmsys_dev *private;
+	const struct mfd_cell *mmsys_cells;
+	int nr_cells;
+	long id;
+	int ret;
+
+	id = (long) of_device_get_match_data(&pdev->dev);
+	if (!id) {
+		dev_err(&pdev->dev, "of_device_get match_data() failed\n");
+		return -EINVAL;
+	}
+
+	switch (id) {
+	case MMSYS_MT2701:
+		mmsys_cells = mmsys_mt2701_devs;
+		nr_cells = ARRAY_SIZE(mmsys_mt2701_devs);
+		break;
+	default:
+		return -ENODEV;
+	}
+
+	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
+	if (!private)
+		return -ENOMEM;
+
+	private->dev = &pdev->dev;
+	dev_set_drvdata(private->dev, private);
+
+	private->of_node = pdev->dev.of_node;
+
+	ret = devm_mfd_add_devices(private->dev, 0, mmsys_cells, nr_cells,
+					NULL, 0, NULL);
+	if (ret) {
+		dev_err(&pdev->dev, "failed to add MFD devices %d\n", ret);
+		return ret;
+	}
+
+	return 0;
+};
+
+static const struct of_device_id of_match_mmsys[] = {
+	{ .compatible = "mediatek,mt2701-mmsys",
+	  .data = (void *) MMSYS_MT2701,
+	},
+	{ /* sentinel */ },
+};
+
+static struct platform_driver mmsys_drv = {
+	.probe = mmsys_probe,
+	.driver = {
+		.name = "mediatek-mmysys",
+		.of_match_table = of_match_ptr(of_match_mmsys),
+	},
+};
+
+builtin_platform_driver(mmsys_drv);
+
+MODULE_DESCRIPTION("Mediatek MMSYS multi-function driver");
+MODULE_LICENSE("GPL");
diff --git a/include/linux/mfd/mmsys.h b/include/linux/mfd/mmsys.h
new file mode 100644
index 000000000000..274b9ee03ada
--- /dev/null
+++ b/include/linux/mfd/mmsys.h
@@ -0,0 +1,18 @@
+/* Header of MMSYS MFD core driver for Mediatek platforms
+ *
+ * Copyright (c) 2017 Matthias Brugger <matthias.bgg@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+
+#ifndef __MEDIATEK_MMSYS__H__
+#define __MEDIATEK_MMSYS__H__
+
+struct mmsys_dev {
+	struct device		*dev;
+	struct device_node	*of_node;
+};
+
+#endif
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing.
  2017-11-14 21:41 [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing Matthias Brugger
  2017-11-14 21:41 ` [PATCH 1/8] drm/mediatek: Use regmap for register access Matthias Brugger
  2017-11-14 21:41 ` [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver Matthias Brugger
@ 2017-11-14 21:41 ` Matthias Brugger
  2017-11-23  5:48   ` CK Hu
  2017-11-23  9:12   ` Philipp Zabel
  2017-11-14 21:41 ` [PATCH 4/8] clk: mediatek: mt2701-mm: switch to mfd device Matthias Brugger
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 27+ messages in thread
From: Matthias Brugger @ 2017-11-14 21:41 UTC (permalink / raw)
  To: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, matthias.bgg, dri-devel, linux-kernel,
	linux-arm-kernel, linux-mediatek, Matthias Brugger

With the mtk-mmsys MFD device in place, we switch the probing for
mt2701 from device-tree to mfd.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index dd249cf5121e..5a263aa3ab6e 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -21,6 +21,7 @@
 #include <drm/drm_of.h>
 #include <linux/component.h>
 #include <linux/iommu.h>
+#include <linux/mfd/mmsys.h>
 #include <linux/mfd/syscon.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
@@ -392,9 +393,10 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
 
 static int mtk_drm_probe(struct platform_device *pdev)
 {
+	struct mmsys_dev *mmsys_private;
 	struct device *dev = &pdev->dev;
 	struct mtk_drm_private *private;
-	struct device_node *node;
+	struct device_node *node, *parent_node;
 	struct component_match *match = NULL;
 	int ret;
 	int i;
@@ -407,12 +409,23 @@ 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);
 
-	private->config_regs = syscon_node_to_regmap(dev->of_node);
-	if (IS_ERR(private->config_regs))
-		return PTR_ERR(private->config_regs);
+	/* Check if called from mfd */
+	if (!dev->of_node) {
+		mmsys_private = dev_get_drvdata(pdev->dev.parent);
+		private->data = (struct mtk_mmsys_driver_data *)
+				platform_get_device_id(pdev)->driver_data;
+		private->config_regs =
+			syscon_node_to_regmap(mmsys_private->of_node);
+		parent_node = mmsys_private->of_node->parent;
+	} else {
+		private->config_regs = syscon_node_to_regmap(dev->of_node);
+		if (IS_ERR(private->config_regs))
+			return PTR_ERR(private->config_regs);
+		parent_node = dev->of_node->parent;
+	}
 
 	/* Iterate over sibling DISP function blocks */
-	for_each_child_of_node(dev->of_node->parent, node) {
+	for_each_child_of_node(parent_node, node) {
 		const struct of_device_id *of_id;
 		enum mtk_ddp_comp_type comp_type;
 		int comp_id;
@@ -553,13 +566,17 @@ static SIMPLE_DEV_PM_OPS(mtk_drm_pm_ops, mtk_drm_sys_suspend,
 			 mtk_drm_sys_resume);
 
 static const struct of_device_id mtk_drm_of_ids[] = {
-	{ .compatible = "mediatek,mt2701-mmsys",
-	  .data = &mt2701_mmsys_driver_data},
 	{ .compatible = "mediatek,mt8173-mmsys",
 	  .data = &mt8173_mmsys_driver_data},
 	{ }
 };
 
+static const struct platform_device_id mtk_drm_ids[] = {
+	{ "drm-mt2701-mm", (kernel_ulong_t)&mt2701_mmsys_driver_data },
+	{ /* sentinel */ },
+};
+MODULE_DEVICE_TABLE(platform, mtk_drm_ids);
+
 static struct platform_driver mtk_drm_platform_driver = {
 	.probe	= mtk_drm_probe,
 	.remove	= mtk_drm_remove,
@@ -568,6 +585,7 @@ static struct platform_driver mtk_drm_platform_driver = {
 		.of_match_table = mtk_drm_of_ids,
 		.pm     = &mtk_drm_pm_ops,
 	},
+	.id_table = mtk_drm_ids,
 };
 
 static struct platform_driver * const mtk_drm_drivers[] = {
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 4/8] clk: mediatek: mt2701-mm: switch to mfd device
  2017-11-14 21:41 [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing Matthias Brugger
                   ` (2 preceding siblings ...)
  2017-11-14 21:41 ` [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing Matthias Brugger
@ 2017-11-14 21:41 ` Matthias Brugger
  2017-11-15  0:17   ` Stephen Boyd
  2017-11-14 21:41 ` [PATCH 5/8] mfd: mtk-mmsys: Add mt8173 nodes Matthias Brugger
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 27+ messages in thread
From: Matthias Brugger @ 2017-11-14 21:41 UTC (permalink / raw)
  To: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, matthias.bgg, dri-devel, linux-kernel,
	linux-arm-kernel, linux-mediatek, Matthias Brugger

As the new mfd device is in place, switch probing
for the MMSYS to support invocation from the mfd device.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 drivers/clk/mediatek/clk-mt2701-mm.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt2701-mm.c b/drivers/clk/mediatek/clk-mt2701-mm.c
index fe1f85072fc5..1725c2c17ca3 100644
--- a/drivers/clk/mediatek/clk-mt2701-mm.c
+++ b/drivers/clk/mediatek/clk-mt2701-mm.c
@@ -13,6 +13,7 @@
  */
 
 #include <linux/clk-provider.h>
+#include <linux/mfd/mmsys.h>
 #include <linux/platform_device.h>
 
 #include "clk-mtk.h"
@@ -87,16 +88,15 @@ 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;
+	struct mmsys_dev *mmsys_private;
+
+	mmsys_private = dev_get_drvdata(pdev->dev.parent);
+	node = mmsys_private->of_node;
 
 	clk_data = mtk_alloc_clk_data(CLK_MM_NR);
 
@@ -116,7 +116,6 @@ static struct platform_driver clk_mt2701_mm_drv = {
 	.probe = clk_mt2701_mm_probe,
 	.driver = {
 		.name = "clk-mt2701-mm",
-		.of_match_table = of_match_clk_mt2701_mm,
 	},
 };
 
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 5/8] mfd: mtk-mmsys: Add mt8173 nodes
  2017-11-14 21:41 [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing Matthias Brugger
                   ` (3 preceding siblings ...)
  2017-11-14 21:41 ` [PATCH 4/8] clk: mediatek: mt2701-mm: switch to mfd device Matthias Brugger
@ 2017-11-14 21:41 ` Matthias Brugger
  2017-11-23  9:13   ` Philipp Zabel
  2017-11-14 21:41 ` [PATCH 6/8] drm/mediatek: Add mfd support for mt8173 Matthias Brugger
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 27+ messages in thread
From: Matthias Brugger @ 2017-11-14 21:41 UTC (permalink / raw)
  To: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, matthias.bgg, dri-devel, linux-kernel,
	linux-arm-kernel, linux-mediatek, Matthias Brugger

Add devices for the mt8173 SoC.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 drivers/mfd/mtk-mmsys.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/mfd/mtk-mmsys.c b/drivers/mfd/mtk-mmsys.c
index 102b491aa28f..45973dfc6010 100644
--- a/drivers/mfd/mtk-mmsys.c
+++ b/drivers/mfd/mtk-mmsys.c
@@ -21,6 +21,7 @@
 
 enum {
 	MMSYS_MT2701 = 1,
+	MMSYS_MT8173,
 };
 
 static const struct mfd_cell mmsys_mt2701_devs[] = {
@@ -28,6 +29,12 @@ static const struct mfd_cell mmsys_mt2701_devs[] = {
 	{ .name = "drm-mt2701-mm", },
 };
 
+static const struct mfd_cell mmsys_mt8173_devs[] = {
+	{ .name = "clk-mt8173-mm", },
+	{ .name = "drm-mt8173-mm", },
+};
+
+
 static int mmsys_probe(struct platform_device *pdev)
 {
 	struct mmsys_dev *private;
@@ -47,6 +54,10 @@ static int mmsys_probe(struct platform_device *pdev)
 		mmsys_cells = mmsys_mt2701_devs;
 		nr_cells = ARRAY_SIZE(mmsys_mt2701_devs);
 		break;
+	case MMSYS_MT8173:
+		mmsys_cells = mmsys_mt8173_devs;
+		nr_cells = ARRAY_SIZE(mmsys_mt8173_devs);
+		break;
 	default:
 		return -ENODEV;
 	}
@@ -74,6 +85,9 @@ static const struct of_device_id of_match_mmsys[] = {
 	{ .compatible = "mediatek,mt2701-mmsys",
 	  .data = (void *) MMSYS_MT2701,
 	},
+	{ .compatible = "mediatek,mt8173-mmsys",
+	  .data = (void *) MMSYS_MT8173,
+	},
 	{ /* sentinel */ },
 };
 
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 6/8] drm/mediatek: Add mfd support for mt8173
  2017-11-14 21:41 [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing Matthias Brugger
                   ` (4 preceding siblings ...)
  2017-11-14 21:41 ` [PATCH 5/8] mfd: mtk-mmsys: Add mt8173 nodes Matthias Brugger
@ 2017-11-14 21:41 ` Matthias Brugger
  2017-11-23  8:51   ` CK Hu
  2017-11-23  9:13   ` Philipp Zabel
  2017-11-14 21:41 ` [PATCH 7/8] clk: mediatek: mt8173-mm: switch to mfd device Matthias Brugger
  2017-11-14 21:41 ` [PATCH 8/8] MAINTAINERS: update Mediatek Soc entry Matthias Brugger
  7 siblings, 2 replies; 27+ messages in thread
From: Matthias Brugger @ 2017-11-14 21:41 UTC (permalink / raw)
  To: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, matthias.bgg, dri-devel, linux-kernel,
	linux-arm-kernel, linux-mediatek, Matthias Brugger

Use the MFD device for SoC mt8173. Probing via devicetree
is no longer needed for any SoC, so delete it.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_drv.c | 28 +++++++---------------------
 1 file changed, 7 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index 5a263aa3ab6e..1eb02acf229a 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -409,20 +409,12 @@ 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);
 
-	/* Check if called from mfd */
-	if (!dev->of_node) {
-		mmsys_private = dev_get_drvdata(pdev->dev.parent);
-		private->data = (struct mtk_mmsys_driver_data *)
-				platform_get_device_id(pdev)->driver_data;
-		private->config_regs =
-			syscon_node_to_regmap(mmsys_private->of_node);
-		parent_node = mmsys_private->of_node->parent;
-	} else {
-		private->config_regs = syscon_node_to_regmap(dev->of_node);
-		if (IS_ERR(private->config_regs))
-			return PTR_ERR(private->config_regs);
-		parent_node = dev->of_node->parent;
-	}
+	mmsys_private = dev_get_drvdata(pdev->dev.parent);
+	private->data = (struct mtk_mmsys_driver_data *)
+			platform_get_device_id(pdev)->driver_data;
+	private->config_regs =
+		syscon_node_to_regmap(mmsys_private->of_node);
+	parent_node = mmsys_private->of_node->parent;
 
 	/* Iterate over sibling DISP function blocks */
 	for_each_child_of_node(parent_node, node) {
@@ -565,14 +557,9 @@ static int mtk_drm_sys_resume(struct device *dev)
 static SIMPLE_DEV_PM_OPS(mtk_drm_pm_ops, mtk_drm_sys_suspend,
 			 mtk_drm_sys_resume);
 
-static const struct of_device_id mtk_drm_of_ids[] = {
-	{ .compatible = "mediatek,mt8173-mmsys",
-	  .data = &mt8173_mmsys_driver_data},
-	{ }
-};
-
 static const struct platform_device_id mtk_drm_ids[] = {
 	{ "drm-mt2701-mm", (kernel_ulong_t)&mt2701_mmsys_driver_data },
+	{ "drm-mt8173-mm", (kernel_ulong_t)&mt8173_mmsys_driver_data },
 	{ /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(platform, mtk_drm_ids);
@@ -582,7 +569,6 @@ static struct platform_driver mtk_drm_platform_driver = {
 	.remove	= mtk_drm_remove,
 	.driver	= {
 		.name	= "mediatek-drm",
-		.of_match_table = mtk_drm_of_ids,
 		.pm     = &mtk_drm_pm_ops,
 	},
 	.id_table = mtk_drm_ids,
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 7/8] clk: mediatek: mt8173-mm: switch to mfd device
  2017-11-14 21:41 [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing Matthias Brugger
                   ` (5 preceding siblings ...)
  2017-11-14 21:41 ` [PATCH 6/8] drm/mediatek: Add mfd support for mt8173 Matthias Brugger
@ 2017-11-14 21:41 ` Matthias Brugger
  2017-11-15  0:16   ` Stephen Boyd
  2017-11-14 21:41 ` [PATCH 8/8] MAINTAINERS: update Mediatek Soc entry Matthias Brugger
  7 siblings, 1 reply; 27+ messages in thread
From: Matthias Brugger @ 2017-11-14 21:41 UTC (permalink / raw)
  To: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, matthias.bgg, dri-devel, linux-kernel,
	linux-arm-kernel, linux-mediatek, Matthias Brugger

As the new mfd device is in place, switch probing
for the MMSYS to support invocation from the mfd device.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 drivers/clk/mediatek/clk-mt8173.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt8173.c b/drivers/clk/mediatek/clk-mt8173.c
index 96c292c3e440..0fd39228eef4 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -13,8 +13,10 @@
  */
 
 #include <linux/clk.h>
+#include <linux/mfd/mmsys.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
+#include <linux/platform_device.h>
 
 #include "clk-mtk.h"
 #include "clk-gate.h"
@@ -1152,10 +1154,16 @@ 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 mmsys_dev *mmsys_private;
+
+	mmsys_private = dev_get_drvdata(pdev->dev.parent);
+	node = mmsys_private->of_node;
+
 
 	clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
 
@@ -1166,8 +1174,17 @@ static void __init mtk_mmsys_init(struct device_node *node)
 	if (r)
 		pr_err("%s(): could not register clock provider: %d\n",
 			__func__, r);
+
+	return r;
 }
-CLK_OF_DECLARE(mtk_mmsys, "mediatek,mt8173-mmsys", mtk_mmsys_init);
+
+static struct platform_driver clk_mt8173_mm_drv = {
+	.probe = mtk_mmsys_probe,
+	.driver = {
+		.name = "clk-mt8173-mm",
+	},
+};
+builtin_platform_driver(clk_mt8173_mm_drv);
 
 static void __init mtk_vdecsys_init(struct device_node *node)
 {
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [PATCH 8/8] MAINTAINERS: update Mediatek Soc entry
  2017-11-14 21:41 [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing Matthias Brugger
                   ` (6 preceding siblings ...)
  2017-11-14 21:41 ` [PATCH 7/8] clk: mediatek: mt8173-mm: switch to mfd device Matthias Brugger
@ 2017-11-14 21:41 ` Matthias Brugger
  7 siblings, 0 replies; 27+ messages in thread
From: Matthias Brugger @ 2017-11-14 21:41 UTC (permalink / raw)
  To: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, matthias.bgg, dri-devel, linux-kernel,
	linux-arm-kernel, linux-mediatek, Matthias Brugger

Mediatek SoCs include several soc specific drivers as well
as a mfd device. Add these to the maintainers file.

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 2811a211632c..586797908865 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1606,6 +1606,8 @@ F:	arch/arm/boot/dts/mt7*
 F:	arch/arm/boot/dts/mt8*
 F:	arch/arm/mach-mediatek/
 F:	arch/arm64/boot/dts/mediatek/
+F:	drivers/soc/mediatek/
+F:	drivers/mfd/mtk-mmsys.c
 N:	mtk
 K:	mediatek
 
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [PATCH 7/8] clk: mediatek: mt8173-mm: switch to mfd device
  2017-11-14 21:41 ` [PATCH 7/8] clk: mediatek: mt8173-mm: switch to mfd device Matthias Brugger
@ 2017-11-15  0:16   ` Stephen Boyd
  0 siblings, 0 replies; 27+ messages in thread
From: Stephen Boyd @ 2017-11-15  0:16 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, lee.jones, davem, gregkh,
	mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk, linux,
	dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek,
	Matthias Brugger

On 11/14, Matthias Brugger wrote:
> As the new mfd device is in place, switch probing
> for the MMSYS to support invocation from the mfd device.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> ---

Acked-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/8] clk: mediatek: mt2701-mm: switch to mfd device
  2017-11-14 21:41 ` [PATCH 4/8] clk: mediatek: mt2701-mm: switch to mfd device Matthias Brugger
@ 2017-11-15  0:17   ` Stephen Boyd
  2018-04-20 13:00     ` Matthias Brugger
  0 siblings, 1 reply; 27+ messages in thread
From: Stephen Boyd @ 2017-11-15  0:17 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, lee.jones, davem, gregkh,
	mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk, linux,
	dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek,
	Matthias Brugger

On 11/14, Matthias Brugger wrote:
> As the new mfd device is in place, switch probing
> for the MMSYS to support invocation from the mfd device.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> ---

Acked-by: Stephen Boyd <sboyd@codeaurora.org>

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/8] drm/mediatek: Use regmap for register access
  2017-11-14 21:41 ` [PATCH 1/8] drm/mediatek: Use regmap for register access Matthias Brugger
@ 2017-11-23  5:44   ` CK Hu
  2017-11-23  8:54   ` Philipp Zabel
  1 sibling, 0 replies; 27+ messages in thread
From: CK Hu @ 2017-11-23  5:44 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: ulrich.hecht+renesas, laurent.pinchart, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones, davem,
	gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk,
	linux, dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek,
	Matthias Brugger

Hi, Matthias:

On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> The mmsys memory space is shared between the drm and the
> clk driver. Use regmap to access it.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>

Acked-by: CK Hu <ck.hu@mediatek.com>

> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c |  4 ++--
>  drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 30 +++++++++++++++++-------------
>  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, 26 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> index 658b8dd45b83..4c65873b4867 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
> @@ -33,7 +33,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
> @@ -48,7 +48,7 @@ struct mtk_drm_crtc {
>  	struct drm_plane		planes[OVL_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;
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> index 8130f3dab661..1227d6db07da 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> @@ -185,16 +185,16 @@ 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);
>  }
>  
> -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)
>  {
> @@ -202,20 +202,22 @@ void mtk_ddp_add_comp_to_path(void __iomem *config_regs,
>  
>  	value = mtk_ddp_mout_en(cur, next, &addr);
>  	if (value) {
> -		reg = readl_relaxed(config_regs + addr) | value;
> -		writel_relaxed(reg, config_regs + addr);
> +		regmap_read(config_regs, addr, &reg);
> +		reg |= value;
> +		regmap_write(config_regs, addr, reg);
>  	}
>  
>  	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);
> +		regmap_read(config_regs, addr, &reg);
> +		reg |= value;
> +		regmap_write(config_regs, addr, reg);
>  	}
>  }
>  
> -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)
>  {
> @@ -223,14 +225,16 @@ void mtk_ddp_remove_comp_from_path(void __iomem *config_regs,
>  
>  	value = mtk_ddp_mout_en(cur, next, &addr);
>  	if (value) {
> -		reg = readl_relaxed(config_regs + addr) & ~value;
> -		writel_relaxed(reg, config_regs + addr);
> +		regmap_read(config_regs, addr, &reg);
> +		reg &= ~value;
> +		regmap_write(config_regs, addr, reg);
>  	}
>  
>  	value = mtk_ddp_sel_in(cur, next, &addr);
>  	if (value) {
> -		reg = readl_relaxed(config_regs + addr) & ~value;
> -		writel_relaxed(reg, config_regs + addr);
> +		regmap_read(config_regs, addr, &reg);
> +		reg &= ~value;
> +		regmap_write(config_regs, addr, reg);
>  	}
>  }
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.h b/drivers/gpu/drm/mediatek/mtk_drm_ddp.h
> index f9a799168077..32e12f33b76a 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.h
> @@ -20,10 +20,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);
>  
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index b2ad19bd1e00..dd249cf5121e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -21,6 +21,7 @@
>  #include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
> +#include <linux/mfd/syscon.h>
>  #include <linux/of_address.h>
>  #include <linux/of_platform.h>
>  #include <linux/pm_runtime.h>
> @@ -393,7 +394,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;
> @@ -407,14 +407,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) {
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.h b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> index 4edc0023684c..86cec19193c4 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.h
> @@ -44,7 +44,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;

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing.
  2017-11-14 21:41 ` [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing Matthias Brugger
@ 2017-11-23  5:48   ` CK Hu
  2017-11-23  8:30     ` Matthias Brugger
  2017-11-23  9:12   ` Philipp Zabel
  1 sibling, 1 reply; 27+ messages in thread
From: CK Hu @ 2017-11-23  5:48 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: ulrich.hecht+renesas, laurent.pinchart, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones, davem,
	gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk,
	linux, dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek,
	Matthias Brugger

Hi, Matthias:

On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> With the mtk-mmsys MFD device in place, we switch the probing for
> mt2701 from device-tree to mfd.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 32 +++++++++++++++++++++++++-------
>  1 file changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index dd249cf5121e..5a263aa3ab6e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -21,6 +21,7 @@
>  #include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
> +#include <linux/mfd/mmsys.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/of_address.h>
>  #include <linux/of_platform.h>
> @@ -392,9 +393,10 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
>  
>  static int mtk_drm_probe(struct platform_device *pdev)
>  {
> +	struct mmsys_dev *mmsys_private;
>  	struct device *dev = &pdev->dev;
>  	struct mtk_drm_private *private;
> -	struct device_node *node;
> +	struct device_node *node, *parent_node;
>  	struct component_match *match = NULL;
>  	int ret;
>  	int i;
> @@ -407,12 +409,23 @@ 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);
>  
> -	private->config_regs = syscon_node_to_regmap(dev->of_node);
> -	if (IS_ERR(private->config_regs))
> -		return PTR_ERR(private->config_regs);
> +	/* Check if called from mfd */
> +	if (!dev->of_node) {
> +		mmsys_private = dev_get_drvdata(pdev->dev.parent);

Why do you directly access parent's driver data? You just need the
device node of mmsys, maybe you could refer to [1].

[1]
https://elixir.free-electrons.com/linux/latest/source/drivers/reset/reset-berlin.c#L78

Regards,
CK

> +		private->data = (struct mtk_mmsys_driver_data *)
> +				platform_get_device_id(pdev)->driver_data;
> +		private->config_regs =
> +			syscon_node_to_regmap(mmsys_private->of_node);
> +		parent_node = mmsys_private->of_node->parent;
> +	} else {
> +		private->config_regs = syscon_node_to_regmap(dev->of_node);
> +		if (IS_ERR(private->config_regs))
> +			return PTR_ERR(private->config_regs);
> +		parent_node = dev->of_node->parent;
> +	}
>  
>  	/* Iterate over sibling DISP function blocks */
> -	for_each_child_of_node(dev->of_node->parent, node) {
> +	for_each_child_of_node(parent_node, node) {
>  		const struct of_device_id *of_id;
>  		enum mtk_ddp_comp_type comp_type;
>  		int comp_id;
> @@ -553,13 +566,17 @@ static SIMPLE_DEV_PM_OPS(mtk_drm_pm_ops, mtk_drm_sys_suspend,
>  			 mtk_drm_sys_resume);
>  
>  static const struct of_device_id mtk_drm_of_ids[] = {
> -	{ .compatible = "mediatek,mt2701-mmsys",
> -	  .data = &mt2701_mmsys_driver_data},
>  	{ .compatible = "mediatek,mt8173-mmsys",
>  	  .data = &mt8173_mmsys_driver_data},
>  	{ }
>  };
>  
> +static const struct platform_device_id mtk_drm_ids[] = {
> +	{ "drm-mt2701-mm", (kernel_ulong_t)&mt2701_mmsys_driver_data },
> +	{ /* sentinel */ },
> +};
> +MODULE_DEVICE_TABLE(platform, mtk_drm_ids);
> +
>  static struct platform_driver mtk_drm_platform_driver = {
>  	.probe	= mtk_drm_probe,
>  	.remove	= mtk_drm_remove,
> @@ -568,6 +585,7 @@ static struct platform_driver mtk_drm_platform_driver = {
>  		.of_match_table = mtk_drm_of_ids,
>  		.pm     = &mtk_drm_pm_ops,
>  	},
> +	.id_table = mtk_drm_ids,
>  };
>  
>  static struct platform_driver * const mtk_drm_drivers[] = {

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing.
  2017-11-23  5:48   ` CK Hu
@ 2017-11-23  8:30     ` Matthias Brugger
  2017-11-23  8:47       ` CK Hu
  0 siblings, 1 reply; 27+ messages in thread
From: Matthias Brugger @ 2017-11-23  8:30 UTC (permalink / raw)
  To: CK Hu, Matthias Brugger
  Cc: ulrich.hecht+renesas, laurent.pinchart, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones, davem,
	gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk,
	linux, dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek



On 11/23/2017 06:48 AM, CK Hu wrote:
> Hi, Matthias:
> 
> On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
>> With the mtk-mmsys MFD device in place, we switch the probing for
>> mt2701 from device-tree to mfd.
>>
>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
>> ---
>>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 32 +++++++++++++++++++++++++-------
>>  1 file changed, 25 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> index dd249cf5121e..5a263aa3ab6e 100644
>> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
>> @@ -21,6 +21,7 @@
>>  #include <drm/drm_of.h>
>>  #include <linux/component.h>
>>  #include <linux/iommu.h>
>> +#include <linux/mfd/mmsys.h>
>>  #include <linux/mfd/syscon.h>
>>  #include <linux/of_address.h>
>>  #include <linux/of_platform.h>
>> @@ -392,9 +393,10 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
>>  
>>  static int mtk_drm_probe(struct platform_device *pdev)
>>  {
>> +	struct mmsys_dev *mmsys_private;
>>  	struct device *dev = &pdev->dev;
>>  	struct mtk_drm_private *private;
>> -	struct device_node *node;
>> +	struct device_node *node, *parent_node;
>>  	struct component_match *match = NULL;
>>  	int ret;
>>  	int i;
>> @@ -407,12 +409,23 @@ 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);
>>  
>> -	private->config_regs = syscon_node_to_regmap(dev->of_node);
>> -	if (IS_ERR(private->config_regs))
>> -		return PTR_ERR(private->config_regs);
>> +	/* Check if called from mfd */
>> +	if (!dev->of_node) {
>> +		mmsys_private = dev_get_drvdata(pdev->dev.parent);
> 
> Why do you directly access parent's driver data? You just need the
> device node of mmsys, maybe you could refer to [1].
> 
> [1]
> https://elixir.free-electrons.com/linux/latest/source/drivers/reset/reset-berlin.c#L78
> 

The difference is, that the driver you mentioned gets probed via device tree
matching, while we get invoked here through the id_table. So there is no device
node (the if actually checkes for pdev->dev.of_node to identify exactly this case).

Regards,
Matthias

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing.
  2017-11-23  8:30     ` Matthias Brugger
@ 2017-11-23  8:47       ` CK Hu
  0 siblings, 0 replies; 27+ messages in thread
From: CK Hu @ 2017-11-23  8:47 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: Matthias Brugger, mark.rutland, sean.wang, airlied, gregkh,
	mturquette, rdunlap, sboyd, linux, dri-devel, linux-clk,
	pi-cheng.chen, robh+dt, linux-mediatek, laurent.pinchart,
	p.zabel, ulrich.hecht+renesas, mchehab, lee.jones, davem,
	linux-kernel, linux-arm-kernel

Hi, Matthias:

On Thu, 2017-11-23 at 09:30 +0100, Matthias Brugger wrote:
> 
> On 11/23/2017 06:48 AM, CK Hu wrote:
> > Hi, Matthias:
> > 
> > On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> >> With the mtk-mmsys MFD device in place, we switch the probing for
> >> mt2701 from device-tree to mfd.
> >>
> >> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> >> ---
> >>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 32 +++++++++++++++++++++++++-------
> >>  1 file changed, 25 insertions(+), 7 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> >> index dd249cf5121e..5a263aa3ab6e 100644
> >> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> >> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> >> @@ -21,6 +21,7 @@
> >>  #include <drm/drm_of.h>
> >>  #include <linux/component.h>
> >>  #include <linux/iommu.h>
> >> +#include <linux/mfd/mmsys.h>
> >>  #include <linux/mfd/syscon.h>
> >>  #include <linux/of_address.h>
> >>  #include <linux/of_platform.h>
> >> @@ -392,9 +393,10 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
> >>  
> >>  static int mtk_drm_probe(struct platform_device *pdev)
> >>  {
> >> +	struct mmsys_dev *mmsys_private;
> >>  	struct device *dev = &pdev->dev;
> >>  	struct mtk_drm_private *private;
> >> -	struct device_node *node;
> >> +	struct device_node *node, *parent_node;
> >>  	struct component_match *match = NULL;
> >>  	int ret;
> >>  	int i;
> >> @@ -407,12 +409,23 @@ 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);
> >>  
> >> -	private->config_regs = syscon_node_to_regmap(dev->of_node);
> >> -	if (IS_ERR(private->config_regs))
> >> -		return PTR_ERR(private->config_regs);
> >> +	/* Check if called from mfd */
> >> +	if (!dev->of_node) {
> >> +		mmsys_private = dev_get_drvdata(pdev->dev.parent);
> > 
> > Why do you directly access parent's driver data? You just need the
> > device node of mmsys, maybe you could refer to [1].
> > 
> > [1]
> > https://elixir.free-electrons.com/linux/latest/source/drivers/reset/reset-berlin.c#L78
> > 
> 
> The difference is, that the driver you mentioned gets probed via device tree
> matching, while we get invoked here through the id_table. So there is no device
> node (the if actually checkes for pdev->dev.of_node to identify exactly this case).
> 
> Regards,
> Matthias

Yes, you are right. So

Acked-by: CK Hu <ck.hu@mediatek.com>

Regards,
CK
> 
> _______________________________________________
> Linux-mediatek mailing list
> Linux-mediatek@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 6/8] drm/mediatek: Add mfd support for mt8173
  2017-11-14 21:41 ` [PATCH 6/8] drm/mediatek: Add mfd support for mt8173 Matthias Brugger
@ 2017-11-23  8:51   ` CK Hu
  2017-11-23  9:13   ` Philipp Zabel
  1 sibling, 0 replies; 27+ messages in thread
From: CK Hu @ 2017-11-23  8:51 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: ulrich.hecht+renesas, laurent.pinchart, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones, davem,
	gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk,
	linux, dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek,
	Matthias Brugger

Hi, Matthias:

On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> Use the MFD device for SoC mt8173. Probing via devicetree
> is no longer needed for any SoC, so delete it.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>

Acked-by: CK Hu <ck.hu@mediatek.com>

> ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 28 +++++++---------------------
>  1 file changed, 7 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 5a263aa3ab6e..1eb02acf229a 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -409,20 +409,12 @@ 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);
>  
> -	/* Check if called from mfd */
> -	if (!dev->of_node) {
> -		mmsys_private = dev_get_drvdata(pdev->dev.parent);
> -		private->data = (struct mtk_mmsys_driver_data *)
> -				platform_get_device_id(pdev)->driver_data;
> -		private->config_regs =
> -			syscon_node_to_regmap(mmsys_private->of_node);
> -		parent_node = mmsys_private->of_node->parent;
> -	} else {
> -		private->config_regs = syscon_node_to_regmap(dev->of_node);
> -		if (IS_ERR(private->config_regs))
> -			return PTR_ERR(private->config_regs);
> -		parent_node = dev->of_node->parent;
> -	}
> +	mmsys_private = dev_get_drvdata(pdev->dev.parent);
> +	private->data = (struct mtk_mmsys_driver_data *)
> +			platform_get_device_id(pdev)->driver_data;
> +	private->config_regs =
> +		syscon_node_to_regmap(mmsys_private->of_node);
> +	parent_node = mmsys_private->of_node->parent;
>  
>  	/* Iterate over sibling DISP function blocks */
>  	for_each_child_of_node(parent_node, node) {
> @@ -565,14 +557,9 @@ static int mtk_drm_sys_resume(struct device *dev)
>  static SIMPLE_DEV_PM_OPS(mtk_drm_pm_ops, mtk_drm_sys_suspend,
>  			 mtk_drm_sys_resume);
>  
> -static const struct of_device_id mtk_drm_of_ids[] = {
> -	{ .compatible = "mediatek,mt8173-mmsys",
> -	  .data = &mt8173_mmsys_driver_data},
> -	{ }
> -};
> -
>  static const struct platform_device_id mtk_drm_ids[] = {
>  	{ "drm-mt2701-mm", (kernel_ulong_t)&mt2701_mmsys_driver_data },
> +	{ "drm-mt8173-mm", (kernel_ulong_t)&mt8173_mmsys_driver_data },
>  	{ /* sentinel */ },
>  };
>  MODULE_DEVICE_TABLE(platform, mtk_drm_ids);
> @@ -582,7 +569,6 @@ static struct platform_driver mtk_drm_platform_driver = {
>  	.remove	= mtk_drm_remove,
>  	.driver	= {
>  		.name	= "mediatek-drm",
> -		.of_match_table = mtk_drm_of_ids,
>  		.pm     = &mtk_drm_pm_ops,
>  	},
>  	.id_table = mtk_drm_ids,

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/8] drm/mediatek: Use regmap for register access
  2017-11-14 21:41 ` [PATCH 1/8] drm/mediatek: Use regmap for register access Matthias Brugger
  2017-11-23  5:44   ` CK Hu
@ 2017-11-23  8:54   ` Philipp Zabel
  2018-04-20  9:41     ` Matthias Brugger
  1 sibling, 1 reply; 27+ messages in thread
From: Philipp Zabel @ 2017-11-23  8:54 UTC (permalink / raw)
  To: Matthias Brugger, ulrich.hecht+renesas, laurent.pinchart, ck.hu,
	airlied, robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, dri-devel, linux-kernel, linux-arm-kernel,
	linux-mediatek, Matthias Brugger

Hi Matthias,

On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> The mmsys memory space is shared between the drm and the
> clk driver. Use regmap to access it.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c |  4 ++--
>  drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 30 +++++++++++++++++-------------
>  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, 26 insertions(+), 27 deletions(-)
[...]
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> index 8130f3dab661..1227d6db07da 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
> @@ -185,16 +185,16 @@ 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);
>  }
>  
> -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)
>  {
> @@ -202,20 +202,22 @@ void mtk_ddp_add_comp_to_path(void __iomem *config_regs,
>  
>  	value = mtk_ddp_mout_en(cur, next, &addr);
>  	if (value) {
> -		reg = readl_relaxed(config_regs + addr) | value;
> -		writel_relaxed(reg, config_regs + addr);
> +		regmap_read(config_regs, addr, &reg);
> +		reg |= value;
> +		regmap_write(config_regs, addr, reg);

You can use

		regmap_update_bits(config_regs, addr, value, value);

here and drop the local variable reg.

>  	}
>  
>  	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);
> +		regmap_read(config_regs, addr, &reg);
> +		reg |= value;
> +		regmap_write(config_regs, addr, reg);

		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)
>  {
> @@ -223,14 +225,16 @@ void mtk_ddp_remove_comp_from_path(void __iomem *config_regs,
>  
>  	value = mtk_ddp_mout_en(cur, next, &addr);
>  	if (value) {
> -		reg = readl_relaxed(config_regs + addr) & ~value;
> -		writel_relaxed(reg, config_regs + addr);
> +		regmap_read(config_regs, addr, &reg);
> +		reg &= ~value;
> +		regmap_write(config_regs, addr, reg);

		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);
> +		regmap_read(config_regs, addr, &reg);
> +		reg &= ~value;
> +		regmap_write(config_regs, addr, reg);

		regmap_update_bits(config_regs, addr, value, 0);

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver
  2017-11-14 21:41 ` [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver Matthias Brugger
@ 2017-11-23  9:04   ` CK Hu
  2017-11-23 18:37     ` Matthias Brugger
  2017-11-23  9:09   ` Philipp Zabel
  1 sibling, 1 reply; 27+ messages in thread
From: CK Hu @ 2017-11-23  9:04 UTC (permalink / raw)
  To: Matthias Brugger
  Cc: ulrich.hecht+renesas, laurent.pinchart, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones, davem,
	gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk,
	linux, dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek,
	Matthias Brugger

Hi, Matthias:

On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> The MMSYS subsystem includes clocks and drm components.
> This patch adds a MFD device to probe both drivers from the same
> device tree compatible.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> ---
>  drivers/mfd/Kconfig       |  9 +++++
>  drivers/mfd/Makefile      |  2 ++
>  drivers/mfd/mtk-mmsys.c   | 91 +++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/mmsys.h | 18 ++++++++++
>  4 files changed, 120 insertions(+)
>  create mode 100644 drivers/mfd/mtk-mmsys.c
>  create mode 100644 include/linux/mfd/mmsys.h
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index fc5e4fef89d2..3250ce5d205a 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -368,6 +368,15 @@ config MFD_MC13XXX_I2C
>  	help
>  	  Select this if your MC13xxx is connected via an I2C bus.
>  
> +config MFD_MEDIATEK_MMSYS
> +	tristate "Mediatek MMSYS interface"
> +	select MDF_CORE
> +	select REGMAP_MMIO
> +	help
> +	  Select this if you have a MMSYS subsystem in your SoC. The
> +	  MMSYS subsystem has at least a clock driver part and some
> +	  DRM components.
> +
>  config MFD_MXS_LRADC
>  	tristate "Freescale i.MX23/i.MX28 LRADC"
>  	depends on ARCH_MXS || COMPILE_TEST
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 8703ff17998e..d4fc99df784c 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -100,6 +100,8 @@ obj-$(CONFIG_MFD_MC13XXX)	+= mc13xxx-core.o
>  obj-$(CONFIG_MFD_MC13XXX_SPI)	+= mc13xxx-spi.o
>  obj-$(CONFIG_MFD_MC13XXX_I2C)	+= mc13xxx-i2c.o
>  
> +obj-$(CONFIG_MFD_MEDIATEK_MMSYS) += mtk-mmsys.o
> +
>  obj-$(CONFIG_MFD_CORE)		+= mfd-core.o
>  
>  obj-$(CONFIG_EZX_PCAP)		+= ezx-pcap.o
> diff --git a/drivers/mfd/mtk-mmsys.c b/drivers/mfd/mtk-mmsys.c
> new file mode 100644
> index 000000000000..102b491aa28f
> --- /dev/null
> +++ b/drivers/mfd/mtk-mmsys.c
> @@ -0,0 +1,91 @@
> +/*
> + * mtk-mmsys.c  --  Mediatek MMSYS multi-function driver
> + *
> + *  Copyright (c) 2017 Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * For licencing details see kernel-base/COPYING
> + *
> + */
> +
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/mfd/core.h>
> +#include <linux/mfd/mmsys.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +
> +enum {
> +	MMSYS_MT2701 = 1,
> +};
> +
> +static const struct mfd_cell mmsys_mt2701_devs[] = {
> +	{ .name = "clk-mt2701-mm", },
> +	{ .name = "drm-mt2701-mm", },
> +};
> +
> +static int mmsys_probe(struct platform_device *pdev)
> +{
> +	struct mmsys_dev *private;
> +	const struct mfd_cell *mmsys_cells;
> +	int nr_cells;
> +	long id;
> +	int ret;
> +
> +	id = (long) of_device_get_match_data(&pdev->dev);
> +	if (!id) {
> +		dev_err(&pdev->dev, "of_device_get match_data() failed\n");
> +		return -EINVAL;
> +	}
> +
> +	switch (id) {
> +	case MMSYS_MT2701:
> +		mmsys_cells = mmsys_mt2701_devs;
> +		nr_cells = ARRAY_SIZE(mmsys_mt2701_devs);
> +		break;
> +	default:
> +		return -ENODEV;
> +	}
> +
> +	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
> +	if (!private)
> +		return -ENOMEM;
> +
> +	private->dev = &pdev->dev;
> +	dev_set_drvdata(private->dev, private);
> +
> +	private->of_node = pdev->dev.of_node;
> +
> +	ret = devm_mfd_add_devices(private->dev, 0, mmsys_cells, nr_cells,
> +					NULL, 0, NULL);
> +	if (ret) {
> +		dev_err(&pdev->dev, "failed to add MFD devices %d\n", ret);
> +		return ret;
> +	}
> +
> +	return 0;
> +};
> +
> +static const struct of_device_id of_match_mmsys[] = {
> +	{ .compatible = "mediatek,mt2701-mmsys",

Because this driver replace the original "mediatek,mt2701-mmsys" driver,
could you modify the binding document of "mediatek,mt2701-mmsys" [1]?

[1]
https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt

Regards,
CK

> +	  .data = (void *) MMSYS_MT2701,
> +	},
> +	{ /* sentinel */ },
> +};
> +
> +static struct platform_driver mmsys_drv = {
> +	.probe = mmsys_probe,
> +	.driver = {
> +		.name = "mediatek-mmysys",
> +		.of_match_table = of_match_ptr(of_match_mmsys),
> +	},
> +};
> +
> +builtin_platform_driver(mmsys_drv);
> +
> +MODULE_DESCRIPTION("Mediatek MMSYS multi-function driver");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/mfd/mmsys.h b/include/linux/mfd/mmsys.h
> new file mode 100644
> index 000000000000..274b9ee03ada
> --- /dev/null
> +++ b/include/linux/mfd/mmsys.h
> @@ -0,0 +1,18 @@
> +/* Header of MMSYS MFD core driver for Mediatek platforms
> + *
> + * Copyright (c) 2017 Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it under
> + * the terms of the GNU General Public License version 2 as published by the
> + * Free Software Foundation.
> + */
> +
> +#ifndef __MEDIATEK_MMSYS__H__
> +#define __MEDIATEK_MMSYS__H__
> +
> +struct mmsys_dev {
> +	struct device		*dev;
> +	struct device_node	*of_node;
> +};
> +
> +#endif

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver
  2017-11-14 21:41 ` [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver Matthias Brugger
  2017-11-23  9:04   ` CK Hu
@ 2017-11-23  9:09   ` Philipp Zabel
  1 sibling, 0 replies; 27+ messages in thread
From: Philipp Zabel @ 2017-11-23  9:09 UTC (permalink / raw)
  To: Matthias Brugger, ulrich.hecht+renesas, laurent.pinchart, ck.hu,
	airlied, robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, dri-devel, linux-kernel, linux-arm-kernel,
	linux-mediatek, Matthias Brugger

Hi Matthias,

On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> The MMSYS subsystem includes clocks and drm components.
> This patch adds a MFD device to probe both drivers from the same
> device tree compatible.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> ---
>  drivers/mfd/Kconfig       |  9 +++++
>  drivers/mfd/Makefile      |  2 ++
>  drivers/mfd/mtk-mmsys.c   | 91 +++++++++++++++++++++++++++++++++++++++++++++++
>  include/linux/mfd/mmsys.h | 18 ++++++++++
>  4 files changed, 120 insertions(+)
>  create mode 100644 drivers/mfd/mtk-mmsys.c
>  create mode 100644 include/linux/mfd/mmsys.h
> 
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index fc5e4fef89d2..3250ce5d205a 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -368,6 +368,15 @@ config MFD_MC13XXX_I2C
>  	help
>  	  Select this if your MC13xxx is connected via an I2C bus.
>  
> +config MFD_MEDIATEK_MMSYS
> +	tristate "Mediatek MMSYS interface"
> +	select MDF_CORE
> +	select REGMAP_MMIO
> +	help
> +	  Select this if you have a MMSYS subsystem in your SoC. The
> +	  MMSYS subsystem has at least a clock driver part and some
> +	  DRM components.
> +
>  config MFD_MXS_LRADC
>  	tristate "Freescale i.MX23/i.MX28 LRADC"
>  	depends on ARCH_MXS || COMPILE_TEST
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 8703ff17998e..d4fc99df784c 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -100,6 +100,8 @@ obj-$(CONFIG_MFD_MC13XXX)	+= mc13xxx-core.o
>  obj-$(CONFIG_MFD_MC13XXX_SPI)	+= mc13xxx-spi.o
>  obj-$(CONFIG_MFD_MC13XXX_I2C)	+= mc13xxx-i2c.o
>  
> +obj-$(CONFIG_MFD_MEDIATEK_MMSYS) += mtk-mmsys.o
> +
>  obj-$(CONFIG_MFD_CORE)		+= mfd-core.o
>  
>  obj-$(CONFIG_EZX_PCAP)		+= ezx-pcap.o
> diff --git a/drivers/mfd/mtk-mmsys.c b/drivers/mfd/mtk-mmsys.c
> new file mode 100644
> index 000000000000..102b491aa28f
> --- /dev/null
> +++ b/drivers/mfd/mtk-mmsys.c
> @@ -0,0 +1,91 @@
> +/*
> + * mtk-mmsys.c  --  Mediatek MMSYS multi-function driver
> + *
> + *  Copyright (c) 2017 Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * Author: Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * For licencing details see kernel-base/COPYING
> + *
> + */
> +
> +#include <linux/module.h>
> +#include <linux/init.h>
> +#include <linux/mfd/core.h>
> +#include <linux/mfd/mmsys.h>
> +#include <linux/of.h>
> +#include <linux/of_address.h>
> +#include <linux/of_device.h>
> +#include <linux/platform_device.h>
> +#include <linux/regmap.h>
> +
> +enum {
> +	MMSYS_MT2701 = 1,
> +};
> +
> +static const struct mfd_cell mmsys_mt2701_devs[] = {
> +	{ .name = "clk-mt2701-mm", },
> +	{ .name = "drm-mt2701-mm", },
> +};
> +
> +static int mmsys_probe(struct platform_device *pdev)
> +{
> +	struct mmsys_dev *private;
> +	const struct mfd_cell *mmsys_cells;
> +	int nr_cells;
> +	long id;
> +	int ret;
> +
> +	id = (long) of_device_get_match_data(&pdev->dev);
> +	if (!id) {
> +		dev_err(&pdev->dev, "of_device_get match_data() failed\n");
> +		return -EINVAL;
> +	}
> +
> +	switch (id) {
> +	case MMSYS_MT2701:
> +		mmsys_cells = mmsys_mt2701_devs;
> +		nr_cells = ARRAY_SIZE(mmsys_mt2701_devs);
> +		break;
> +	default:
> +		return -ENODEV;
> +	}
> +
> +	private = devm_kzalloc(&pdev->dev, sizeof(*private), GFP_KERNEL);
> +	if (!private)
> +		return -ENOMEM;
> +
> +	private->dev = &pdev->dev;
> +	dev_set_drvdata(private->dev, private);
> +
> +	private->of_node = pdev->dev.of_node;

This seems superfluous to me. The of_node can be obtained from the
device, and the device itself is already needed to get to the drvdata.

Instead of

	mmsys_private = drv_get_drvdata(pdev->dev.parent);
	mmsys_dev = mmsys_private.dev;
	mmsys_of_node = mmsys_private.of_node;

couldn't the mfd children just do

	mmsys_dev = pdev->dev.parent;
	mmsys_of_node = pdev->dev.parent->of_node;

?

> +
> +	ret = devm_mfd_add_devices(private->dev, 0, mmsys_cells, nr_cells,
> +					NULL, 0, NULL);
> +	if (ret) {
> +		dev_err(&pdev->dev, "failed to add MFD devices %d\n", ret);
> +		return ret;
> +	}
> +
> +	return 0;
> +};
> +
> +static const struct of_device_id of_match_mmsys[] = {
> +	{ .compatible = "mediatek,mt2701-mmsys",
> +	  .data = (void *) MMSYS_MT2701,
> +	},
> +	{ /* sentinel */ },
> +};
> +
> +static struct platform_driver mmsys_drv = {
> +	.probe = mmsys_probe,
> +	.driver = {
> +		.name = "mediatek-mmysys",
> +		.of_match_table = of_match_ptr(of_match_mmsys),
> +	},
> +};
> +
> +builtin_platform_driver(mmsys_drv);
> +
> +MODULE_DESCRIPTION("Mediatek MMSYS multi-function driver");
> +MODULE_LICENSE("GPL");
> diff --git a/include/linux/mfd/mmsys.h b/include/linux/mfd/mmsys.h
> new file mode 100644
> index 000000000000..274b9ee03ada
> --- /dev/null
> +++ b/include/linux/mfd/mmsys.h
> @@ -0,0 +1,18 @@
> +/* Header of MMSYS MFD core driver for Mediatek platforms
> + *
> + * Copyright (c) 2017 Matthias Brugger <matthias.bgg@gmail.com>
> + *
> + * This program is free software; you can redistribute it and/or modify it under
> + * the terms of the GNU General Public License version 2 as published by the
> + * Free Software Foundation.
> + */
> +
> +#ifndef __MEDIATEK_MMSYS__H__
> +#define __MEDIATEK_MMSYS__H__
> +
> +struct mmsys_dev {
> +	struct device		*dev;
> +	struct device_node	*of_node;
> +};

This wouldn't be needed, then.

regards
Philipp

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing.
  2017-11-14 21:41 ` [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing Matthias Brugger
  2017-11-23  5:48   ` CK Hu
@ 2017-11-23  9:12   ` Philipp Zabel
  1 sibling, 0 replies; 27+ messages in thread
From: Philipp Zabel @ 2017-11-23  9:12 UTC (permalink / raw)
  To: Matthias Brugger, ulrich.hecht+renesas, laurent.pinchart, ck.hu,
	airlied, robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, dri-devel, linux-kernel, linux-arm-kernel,
	linux-mediatek, Matthias Brugger

On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> With the mtk-mmsys MFD device in place, we switch the probing for
> mt2701 from device-tree to mfd.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 32 +++++++++++++++++++++++++-------
>  1 file changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index dd249cf5121e..5a263aa3ab6e 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -21,6 +21,7 @@
>  #include <drm/drm_of.h>
>  #include <linux/component.h>
>  #include <linux/iommu.h>
> +#include <linux/mfd/mmsys.h>
>  #include <linux/mfd/syscon.h>
>  #include <linux/of_address.h>
>  #include <linux/of_platform.h>
> @@ -392,9 +393,10 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
>  
>  static int mtk_drm_probe(struct platform_device *pdev)
>  {
> +	struct mmsys_dev *mmsys_private;
>  	struct device *dev = &pdev->dev;
>  	struct mtk_drm_private *private;
> -	struct device_node *node;
> +	struct device_node *node, *parent_node;
>  	struct component_match *match = NULL;
>  	int ret;
>  	int i;
> @@ -407,12 +409,23 @@ 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);
>  
> -	private->config_regs = syscon_node_to_regmap(dev->of_node);
> -	if (IS_ERR(private->config_regs))
> -		return PTR_ERR(private->config_regs);
> +	/* Check if called from mfd */
> +	if (!dev->of_node) {
> +		mmsys_private = dev_get_drvdata(pdev->dev.parent);
> +		private->data = (struct mtk_mmsys_driver_data *)
> +				platform_get_device_id(pdev)->driver_data;
> +		private->config_regs =
> +			syscon_node_to_regmap(mmsys_private->of_node);
> +		parent_node = mmsys_private->of_node->parent;

I think this could be just:

		mmsys_node = pdev->dev.parent->of_node;
		private->data = (struct mtk_mmsys_driver_data *)> +	
			platform_get_device_id(pdev)->driver_data;
		private->config_regs = syscon_node_to_regmap(mmsys_node);
		parent_node = mmsys_node->parent;

regards
Philipp

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 5/8] mfd: mtk-mmsys: Add mt8173 nodes
  2017-11-14 21:41 ` [PATCH 5/8] mfd: mtk-mmsys: Add mt8173 nodes Matthias Brugger
@ 2017-11-23  9:13   ` Philipp Zabel
  0 siblings, 0 replies; 27+ messages in thread
From: Philipp Zabel @ 2017-11-23  9:13 UTC (permalink / raw)
  To: Matthias Brugger, ulrich.hecht+renesas, laurent.pinchart, ck.hu,
	airlied, robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, dri-devel, linux-kernel, linux-arm-kernel,
	linux-mediatek, Matthias Brugger

On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> Add devices for the mt8173 SoC.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 6/8] drm/mediatek: Add mfd support for mt8173
  2017-11-14 21:41 ` [PATCH 6/8] drm/mediatek: Add mfd support for mt8173 Matthias Brugger
  2017-11-23  8:51   ` CK Hu
@ 2017-11-23  9:13   ` Philipp Zabel
  1 sibling, 0 replies; 27+ messages in thread
From: Philipp Zabel @ 2017-11-23  9:13 UTC (permalink / raw)
  To: Matthias Brugger, ulrich.hecht+renesas, laurent.pinchart, ck.hu,
	airlied, robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, dri-devel, linux-kernel, linux-arm-kernel,
	linux-mediatek, Matthias Brugger

On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> Use the MFD device for SoC mt8173. Probing via devicetree
> is no longer needed for any SoC, so delete it.
> 
> Signed-off-by: Matthias Brugger <mbrugger@suse.com>

Apart from the mmsys_private issue noted in previous patches,

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver
  2017-11-23  9:04   ` CK Hu
@ 2017-11-23 18:37     ` Matthias Brugger
  0 siblings, 0 replies; 27+ messages in thread
From: Matthias Brugger @ 2017-11-23 18:37 UTC (permalink / raw)
  To: CK Hu
  Cc: ulrich.hecht+renesas, laurent.pinchart, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, sboyd, lee.jones, davem,
	gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk,
	linux, dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek,
	Matthias Brugger



On 11/23/2017 10:04 AM, CK Hu wrote:

>> +static const struct of_device_id of_match_mmsys[] = {
>> +	{ .compatible = "mediatek,mt2701-mmsys",
> 
> Because this driver replace the original "mediatek,mt2701-mmsys" driver,
> could you modify the binding document of "mediatek,mt2701-mmsys" [1]?
> 
> [1]
> https://www.kernel.org/doc/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
> 

Well we are actually no replacing the compatible but keeping it. But yes, the
documentation should be updated.

Apart right now we have the definition twice. The other location is here:
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt

Regards,
Matthias

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/8] drm/mediatek: Use regmap for register access
  2017-11-23  8:54   ` Philipp Zabel
@ 2018-04-20  9:41     ` Matthias Brugger
  2018-04-20 10:00       ` Philipp Zabel
  0 siblings, 1 reply; 27+ messages in thread
From: Matthias Brugger @ 2018-04-20  9:41 UTC (permalink / raw)
  To: Philipp Zabel, ulrich.hecht+renesas, laurent.pinchart, ck.hu,
	airlied, robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, dri-devel, linux-kernel, linux-arm-kernel,
	linux-mediatek, Matthias Brugger

Hi Philipp,

On 11/23/2017 09:54 AM, Philipp Zabel wrote:
> Hi Matthias,
> 
> On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
>> The mmsys memory space is shared between the drm and the
>> clk driver. Use regmap to access it.
>>
>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
>> ---
>>  drivers/gpu/drm/mediatek/mtk_drm_crtc.c |  4 ++--
>>  drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 30 +++++++++++++++++-------------
>>  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, 26 insertions(+), 27 deletions(-)
> [...]
[...]
>>  	}
>>  
>>  	value = mtk_ddp_sel_in(cur, next, &addr);
>>  	if (value) {
>> -		reg = readl_relaxed(config_regs + addr) & ~value;
>> -		writel_relaxed(reg, config_regs + addr);
>> +		regmap_read(config_regs, addr, &reg);
>> +		reg &= ~value;
>> +		regmap_write(config_regs, addr, reg);
> 
> 		regmap_update_bits(config_regs, addr, value, 0);
> 
> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
> 

Thanks for having a look on that.

I'll update the next version with regmap_update_bits and leave your Reviewed-by,
hope that's ok.

Regards,
Matthias

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 1/8] drm/mediatek: Use regmap for register access
  2018-04-20  9:41     ` Matthias Brugger
@ 2018-04-20 10:00       ` Philipp Zabel
  0 siblings, 0 replies; 27+ messages in thread
From: Philipp Zabel @ 2018-04-20 10:00 UTC (permalink / raw)
  To: Matthias Brugger, ulrich.hecht+renesas, laurent.pinchart, ck.hu,
	airlied, robh+dt, mark.rutland, mturquette, sboyd, lee.jones
  Cc: davem, gregkh, mchehab, rdunlap, pi-cheng.chen, sean.wang,
	linux-clk, linux, dri-devel, linux-kernel, linux-arm-kernel,
	linux-mediatek, Matthias Brugger

Hi Matthias,

On Fri, 2018-04-20 at 11:41 +0200, Matthias Brugger wrote:
> Hi Philipp,
> 
> On 11/23/2017 09:54 AM, Philipp Zabel wrote:
> > Hi Matthias,
> > 
> > On Tue, 2017-11-14 at 22:41 +0100, Matthias Brugger wrote:
> > > The mmsys memory space is shared between the drm and the
> > > clk driver. Use regmap to access it.
> > > 
> > > Signed-off-by: Matthias Brugger <mbrugger@suse.com>
> > > ---
> > >  drivers/gpu/drm/mediatek/mtk_drm_crtc.c |  4 ++--
> > >  drivers/gpu/drm/mediatek/mtk_drm_ddp.c  | 30 +++++++++++++++++-------------
> > >  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, 26 insertions(+), 27 deletions(-)
> > 
> > [...]
> 
> [...]
> > >  	}
> > >  
> > >  	value = mtk_ddp_sel_in(cur, next, &addr);
> > >  	if (value) {
> > > -		reg = readl_relaxed(config_regs + addr) & ~value;
> > > -		writel_relaxed(reg, config_regs + addr);
> > > +		regmap_read(config_regs, addr, &reg);
> > > +		reg &= ~value;
> > > +		regmap_write(config_regs, addr, reg);
> > 
> > 		regmap_update_bits(config_regs, addr, value, 0);
> > 
> > Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
> > 
> 
> Thanks for having a look on that.
> 
> I'll update the next version with regmap_update_bits and leave your Reviewed-by,
> hope that's ok.

Yes, that's fine.

regards
Philipp

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/8] clk: mediatek: mt2701-mm: switch to mfd device
  2017-11-15  0:17   ` Stephen Boyd
@ 2018-04-20 13:00     ` Matthias Brugger
  2018-04-20 13:04       ` Matthias Brugger
  0 siblings, 1 reply; 27+ messages in thread
From: Matthias Brugger @ 2018-04-20 13:00 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, lee.jones, davem, gregkh,
	mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk, linux,
	dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek,
	Matthias Brugger

Hi Stephen,

On 11/15/2017 01:17 AM, Stephen Boyd wrote:
> On 11/14, Matthias Brugger wrote:
>> As the new mfd device is in place, switch probing
>> for the MMSYS to support invocation from the mfd device.
>>
>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
>> ---
> 
> Acked-by: Stephen Boyd <sboyd@codeaurora.org>
> 

I did a minor change to this patch and patch 7/8 to get rid of mmsys_private
variable. Nevertheless I kept your Acked-by, as it only changes how we get the
device tree node.

Hope that's OK with you.

Regards,
Matthias

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [PATCH 4/8] clk: mediatek: mt2701-mm: switch to mfd device
  2018-04-20 13:00     ` Matthias Brugger
@ 2018-04-20 13:04       ` Matthias Brugger
  0 siblings, 0 replies; 27+ messages in thread
From: Matthias Brugger @ 2018-04-20 13:04 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: ulrich.hecht+renesas, laurent.pinchart, ck.hu, p.zabel, airlied,
	robh+dt, mark.rutland, mturquette, lee.jones, davem, gregkh,
	mchehab, rdunlap, pi-cheng.chen, sean.wang, linux-clk, linux,
	dri-devel, linux-kernel, linux-arm-kernel, linux-mediatek,
	Matthias Brugger



On 04/20/2018 03:00 PM, Matthias Brugger wrote:
> Hi Stephen,
> 
> On 11/15/2017 01:17 AM, Stephen Boyd wrote:
>> On 11/14, Matthias Brugger wrote:
>>> As the new mfd device is in place, switch probing
>>> for the MMSYS to support invocation from the mfd device.
>>>
>>> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
>>> ---
>>
>> Acked-by: Stephen Boyd <sboyd@codeaurora.org>
>>
> 
> I did a minor change to this patch and patch 7/8 to get rid of mmsys_private
> variable. Nevertheless I kept your Acked-by, as it only changes how we get the
> device tree node.
> 
> Hope that's OK with you.
> 

Sorry, I didn't explain me. I'm talking about v2 of the series, which I'm
working on right now.

Regards,
Matthias

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2018-04-20 13:04 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-14 21:41 [PATCH 0/8] arm/arm64: mediatek: Fix mmsys device probing Matthias Brugger
2017-11-14 21:41 ` [PATCH 1/8] drm/mediatek: Use regmap for register access Matthias Brugger
2017-11-23  5:44   ` CK Hu
2017-11-23  8:54   ` Philipp Zabel
2018-04-20  9:41     ` Matthias Brugger
2018-04-20 10:00       ` Philipp Zabel
2017-11-14 21:41 ` [PATCH 2/8] mfd: mtk-mmsys: Add mmsys driver Matthias Brugger
2017-11-23  9:04   ` CK Hu
2017-11-23 18:37     ` Matthias Brugger
2017-11-23  9:09   ` Philipp Zabel
2017-11-14 21:41 ` [PATCH 3/8] drm/mediatek: mt2701: switch to mfd probing Matthias Brugger
2017-11-23  5:48   ` CK Hu
2017-11-23  8:30     ` Matthias Brugger
2017-11-23  8:47       ` CK Hu
2017-11-23  9:12   ` Philipp Zabel
2017-11-14 21:41 ` [PATCH 4/8] clk: mediatek: mt2701-mm: switch to mfd device Matthias Brugger
2017-11-15  0:17   ` Stephen Boyd
2018-04-20 13:00     ` Matthias Brugger
2018-04-20 13:04       ` Matthias Brugger
2017-11-14 21:41 ` [PATCH 5/8] mfd: mtk-mmsys: Add mt8173 nodes Matthias Brugger
2017-11-23  9:13   ` Philipp Zabel
2017-11-14 21:41 ` [PATCH 6/8] drm/mediatek: Add mfd support for mt8173 Matthias Brugger
2017-11-23  8:51   ` CK Hu
2017-11-23  9:13   ` Philipp Zabel
2017-11-14 21:41 ` [PATCH 7/8] clk: mediatek: mt8173-mm: switch to mfd device Matthias Brugger
2017-11-15  0:16   ` Stephen Boyd
2017-11-14 21:41 ` [PATCH 8/8] MAINTAINERS: update Mediatek Soc entry Matthias Brugger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).