From: Matthias Brugger <[email protected]>
Changes since v1:
- add binding documentation
- ddp: use regmap_update_bits
- ddp: ignore EPROBE_DEFER on clock probing
- mfd: delete mmsys_private
- add Reviewed-by and Acked-by tags
---
MMSYS in Mediatek SoCs has some registers to control clock gates (which is
used in the clk driver) and some registers to set the routing and enable
the differnet blocks of the display subsystem.
Up to now both drivers, clock and drm are probed with the same device tree
compatible. But only the first driver get probed, which in effect breaks
graphics on mt8173 and mt2701.
This patch 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 (10):
dt-bindings: mediatek: mmsys: Add support for mfd
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
drm: mediatek: Omit warning on probe defers
MAINTAINERS: update Mediatek Soc entry
.../bindings/arm/mediatek/mediatek,mmsys.txt | 2 -
.../bindings/display/mediatek/mediatek,disp.txt | 2 +-
.../devicetree/bindings/mfd/mediatek,mmsys.txt | 27 +++++++
MAINTAINERS | 2 +
drivers/clk/mediatek/clk-mt2701-mm.c | 10 +--
drivers/clk/mediatek/clk-mt8173.c | 17 +++-
drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 +-
drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 41 ++++------
drivers/gpu/drm/mediatek/mtk_drm_ddp.h | 4 +-
drivers/gpu/drm/mediatek/mtk_drm_drv.c | 33 ++++----
drivers/gpu/drm/mediatek/mtk_drm_drv.h | 2 +-
drivers/mfd/Kconfig | 9 +++
drivers/mfd/Makefile | 2 +
drivers/mfd/mtk-mmsys.c | 93 ++++++++++++++++++++++
14 files changed, 189 insertions(+), 59 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt
create mode 100644 drivers/mfd/mtk-mmsys.c
--
2.16.3
From: Matthias Brugger <[email protected]>
Add binding description for the mmsys mfd for some Mediatek
devices. mmsys 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.
Signed-off-by: Matthias Brugger <[email protected]>
---
.../bindings/arm/mediatek/mediatek,mmsys.txt | 2 --
.../bindings/display/mediatek/mediatek,disp.txt | 2 +-
.../devicetree/bindings/mfd/mediatek,mmsys.txt | 27 ++++++++++++++++++++++
3 files changed, 28 insertions(+), 3 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt
diff --git a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
index 4eb8bbe15c01..4468345f8b1a 100644
--- a/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
+++ b/Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt
@@ -6,10 +6,8 @@ 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,mt6797-mmsys", "syscon"
- - "mediatek,mt8173-mmsys", "syscon"
- #clock-cells: Must be 1
The mmsys controller uses the common clk binding from
diff --git a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
index 383183a89164..85a3b4ec06cd 100644
--- a/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
+++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
@@ -9,7 +9,7 @@ function block.
All DISP device tree nodes must be siblings to the central MMSYS_CONFIG node.
For a description of the MMSYS_CONFIG binding, see
-Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt.
+Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt
DISP function blocks
====================
diff --git a/Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt b/Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt
new file mode 100644
index 000000000000..2331ae16917e
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt
@@ -0,0 +1,27 @@
+MediaTek MMSYS Multifunction Device Driver
+
+MMSYS is a multifunction device with the following sub modules:
+- clocks for the multi-media subsystem
+- central node for the DRM subsystem.
+
+This document describes the binding for MFD device. The MFD takes care to initailize
+the clock driver and the DRM driver. More info see
+Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt
+
+Required properties:
+- compatible: Should be one of:
+ - "mediatek,mt2701-mmsys", "syscon"
+ - "mediatek,mt8173-mmsys", "syscon"
+- #clock-cells: Must be 1
+
+Optional properties:
+- power-domains: list of powerdomains needed for the subsystem to work
+
+Example:
+
+mmsys: clock-controller@14000000 {
+ compatible = "mediatek,mt8173-mmsys", "syscon";
+ reg = <0 0x14000000 0 0x1000>;
+ power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>;
+ #clock-cells = <1>;
+};
--
2.16.3
From: Matthias Brugger <[email protected]>
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 <[email protected]>
Acked-by: Stephen Boyd <[email protected]>
---
drivers/clk/mediatek/clk-mt2701-mm.c | 10 +++-------
1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/drivers/clk/mediatek/clk-mt2701-mm.c b/drivers/clk/mediatek/clk-mt2701-mm.c
index fe1f85072fc5..4517525887dd 100644
--- a/drivers/clk/mediatek/clk-mt2701-mm.c
+++ b/drivers/clk/mediatek/clk-mt2701-mm.c
@@ -87,16 +87,13 @@ 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;
+
+ node = pdev->dev.parent->of_node;
clk_data = mtk_alloc_clk_data(CLK_MM_NR);
@@ -116,7 +113,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.16.3
From: Matthias Brugger <[email protected]>
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 <[email protected]>
---
drivers/mfd/Kconfig | 9 ++++++
drivers/mfd/Makefile | 2 ++
drivers/mfd/mtk-mmsys.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 90 insertions(+)
create mode 100644 drivers/mfd/mtk-mmsys.c
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index b860eb5aa194..a2c928e26026 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -378,6 +378,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 d9d2cf0d32ef..b96118bd68d9 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -98,6 +98,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..c802343fb1c6
--- /dev/null
+++ b/drivers/mfd/mtk-mmsys.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/*
+ * mtk-mmsys.c -- Mediatek MMSYS multi-function driver
+ *
+ * Copyright (c) 2018 Matthias Brugger <[email protected]>
+ *
+ * Author: Matthias Brugger <[email protected]>
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/mfd/core.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)
+{
+ 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;
+ }
+
+ ret = devm_mfd_add_devices(&pdev->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");
--
2.16.3
From: Matthias Brugger <[email protected]>
Add devices for the mt8173 SoC.
Signed-off-by: Matthias Brugger <[email protected]>
Reviewed-by: Philipp Zabel <[email protected]>
---
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 c802343fb1c6..5585a561a02f 100644
--- a/drivers/mfd/mtk-mmsys.c
+++ b/drivers/mfd/mtk-mmsys.c
@@ -19,6 +19,7 @@
enum {
MMSYS_MT2701 = 1,
+ MMSYS_MT8173,
};
static const struct mfd_cell mmsys_mt2701_devs[] = {
@@ -26,6 +27,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)
{
const struct mfd_cell *mmsys_cells;
@@ -44,6 +51,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;
}
@@ -62,6 +73,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.16.3
From: Matthias Brugger <[email protected]>
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 <[email protected]>
Acked-by: Stephen Boyd <[email protected]>
---
drivers/clk/mediatek/clk-mt8173.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/drivers/clk/mediatek/clk-mt8173.c b/drivers/clk/mediatek/clk-mt8173.c
index 96c292c3e440..abd2592078d4 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -15,6 +15,7 @@
#include <linux/clk.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 +1153,13 @@ 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;
+
+ node = pdev->dev.parent->of_node;
clk_data = mtk_alloc_clk_data(CLK_MM_NR_CLK);
@@ -1166,8 +1170,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.16.3
From: Matthias Brugger <[email protected]>
Mediatek SoCs include several soc specific drivers as well
as a mfd device. Add these to the maintainers file.
Signed-off-by: Matthias Brugger <[email protected]>
---
MAINTAINERS | 2 ++
1 file changed, 2 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS
index 0a1410d5a621..74f7ea345096 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1621,6 +1621,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.16.3
From: Matthias Brugger <[email protected]>
When probe through the MFD, it can happen that the
clock drivers wasn't probed before the ddp driver gets
invoked. The driver used to omit a warning that the driver
failed to get the clocks. Omit this error on the defered probe path.
Signed-off-by: Matthias Brugger <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
index bafc5c77c4fb..6b399348a2dc 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
@@ -374,7 +374,8 @@ static int mtk_ddp_probe(struct platform_device *pdev)
ddp->clk = devm_clk_get(dev, NULL);
if (IS_ERR(ddp->clk)) {
- dev_err(dev, "Failed to get clock\n");
+ if (PTR_ERR(ddp->clk) != -EPROBE_DEFER)
+ dev_err(dev, "Failed to get clock\n");
return PTR_ERR(ddp->clk);
}
--
2.16.3
From: Matthias Brugger <[email protected]>
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 <[email protected]>
Reviewed-by: Philipp Zabel <[email protected]>
---
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 88ee35907744..3cc433ebfa8f 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -399,20 +399,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_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;
- } 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_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;
/* Iterate over sibling DISP function blocks */
for_each_child_of_node(parent_node, node) {
@@ -555,14 +547,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);
@@ -572,7 +559,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.16.3
From: Matthias Brugger <[email protected]>
The mmsys memory space is shared between the drm and the
clk driver. Use regmap to access it.
Signed-off-by: Matthias Brugger <[email protected]>
Reviewed-by: Philipp Zabel <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 ++--
drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 38 +++++++++++++--------------------
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, 24 insertions(+), 37 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..bafc5c77c4fb 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_ddp.c
@@ -185,53 +185,45 @@ 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)
{
- unsigned int addr, value, reg;
+ unsigned int addr, value;
value = mtk_ddp_mout_en(cur, next, &addr);
- if (value) {
- reg = readl_relaxed(config_regs + addr) | value;
- writel_relaxed(reg, config_regs + addr);
- }
+ if (value)
+ regmap_update_bits(config_regs, addr, value, value);
mtk_ddp_sout_sel(config_regs, cur, next);
value = mtk_ddp_sel_in(cur, next, &addr);
- if (value) {
- reg = readl_relaxed(config_regs + addr) | value;
- writel_relaxed(reg, config_regs + addr);
- }
+ if (value)
+ regmap_update_bits(config_regs, addr, value, value);
}
-void mtk_ddp_remove_comp_from_path(void __iomem *config_regs,
+void mtk_ddp_remove_comp_from_path(struct regmap *config_regs,
enum mtk_ddp_comp_id cur,
enum mtk_ddp_comp_id next)
{
- unsigned int addr, value, reg;
+ unsigned int addr, value;
value = mtk_ddp_mout_en(cur, next, &addr);
- if (value) {
- reg = readl_relaxed(config_regs + addr) & ~value;
- writel_relaxed(reg, config_regs + addr);
- }
+ if (value)
+ regmap_update_bits(config_regs, addr, value, 0);
value = mtk_ddp_sel_in(cur, next, &addr);
- if (value) {
- reg = readl_relaxed(config_regs + addr) & ~value;
- writel_relaxed(reg, config_regs + addr);
- }
+ if (value)
+ regmap_update_bits(config_regs, addr, value, 0);
}
struct mtk_disp_mutex *mtk_disp_mutex_get(struct device *dev, unsigned int id)
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 a2ca90fc403c..a48e28adad09 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>
@@ -385,7 +386,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;
@@ -399,14 +399,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 c3378c452c0a..c6fa0ad458e8 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.16.3
From: Matthias Brugger <[email protected]>
With the mtk-mmsys MFD device in place, we switch the probing for
mt2701 from device-tree to mfd.
Signed-off-by: Matthias Brugger <[email protected]>
---
drivers/gpu/drm/mediatek/mtk_drm_drv.c | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
index a48e28adad09..88ee35907744 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
@@ -386,7 +386,7 @@ static int mtk_drm_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct mtk_drm_private *private;
- struct device_node *node;
+ struct device_node *node, *parent_node, *mmsys_node;
struct component_match *match = NULL;
int ret;
int i;
@@ -399,12 +399,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_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;
+ } 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;
@@ -545,13 +556,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,
@@ -560,6 +575,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.16.3
On 04/24/2018 02:47 AM, [email protected] wrote:
> From: Matthias Brugger <[email protected]>
>
> 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 <[email protected]>
> ---
> drivers/mfd/Kconfig | 9 ++++++
> drivers/mfd/Makefile | 2 ++
> drivers/mfd/mtk-mmsys.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 90 insertions(+)
> create mode 100644 drivers/mfd/mtk-mmsys.c
>
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index b860eb5aa194..a2c928e26026 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -378,6 +378,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 MFD_CORE
tested??
> + 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
--
~Randy