From: Matthias Brugger mbrugger@suse.com
Changes since v2: - fix kconfig typo (shame on me) - delete __initconst from mm_clocks as converted to a platform driver
Changes since v1: - add binding documentation - ddp: use regmap_update_bits - ddp: ignore EPROBE_DEFER on clock probing - mfd: delete mmsys_private - add Reviewed-by and Acked-by tags
---
MMSYS in Mediatek SoCs has some registers to control clock gates (which is used in the clk driver) and some registers to set the routing and enable the differnet blocks of the display subsystem.
Up to now both drivers, clock and drm are probed with the same device tree compatible. But only the first driver get probed, which in effect breaks graphics on mt8173 and mt2701.
This patch 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 | 19 ++++- 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, 190 insertions(+), 60 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt create mode 100644 drivers/mfd/mtk-mmsys.c
From: Matthias Brugger mbrugger@suse.com
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 mbrugger@suse.com --- .../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>; +};
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 mbrugger@suse.com
.../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
What is "MMSYS"?
"Multi-Function Driver"s are specific to Linux.
What actually is the device?
+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>;
+};
On 30/04/18 12:30, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 mbrugger@suse.com
.../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
What is "MMSYS"?
"Multi-Function Driver"s are specific to Linux.
What actually is the device?
It's includes all the DRM parts of the SoC together with the clocks for the device. MMSYS IMHO stands for Multi-Media-System.
Regards, Matthias
+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>;
+};
On Mon, Jun 25, 2018 at 9:39 AM Matthias Brugger matthias.bgg@gmail.com wrote:
On 30/04/18 12:30, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 mbrugger@suse.com
.../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
Please CC DT list on bindings.
Rob
On Mon, 25 Jun 2018, Matthias Brugger wrote:
On 30/04/18 12:30, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 mbrugger@suse.com
.../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
What is "MMSYS"?
"Multi-Function Driver"s are specific to Linux.
What actually is the device?
It's includes all the DRM parts of the SoC together with the clocks for the device. MMSYS IMHO stands for Multi-Media-System.
Please update the document with that information.
Is there a datasheet I can view?
+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>;
+};
From: Matthias Brugger mbrugger@suse.com
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 Reviewed-by: Philipp Zabel p.zabel@pengutronix.de --- 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;
From: Matthias Brugger mbrugger@suse.com
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 | 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..d23a3b9a2c58 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 MFD_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 matthias.bgg@gmail.com + * + * Author: Matthias Brugger matthias.bgg@gmail.com + */ + +#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");
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 | 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..d23a3b9a2c58 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 MFD_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 matthias.bgg@gmail.com
- Author: Matthias Brugger matthias.bgg@gmail.com
- */
+#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;
+};
This driver is pretty pointless. It doesn't actually do anything.
I think you just want to use "simple-mfd" instead.
+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");
On Mon, 2018-04-30 at 11:18 +0100, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 | 79 +++++++++++++++++++++++++++++++++++++++++++++++++
[ ... ]
+};
This driver is pretty pointless. It doesn't actually do anything.
I think you just want to use "simple-mfd" instead.
Hi, Matthias
Why not embedded a platform_device_register_data call into existent MMSYS driver ?
It looks elegant and makes sense that mmsys device is being as parent device for all its DRM components device and no need to create an additional node representing the same device with mmsys simply in order to probe its DRM components.
I'm planing to send a bunch of HDMI, MIPI related to MMSYS nodes for MT7623 SoC when 4.18 rc1 comes out, so we should want to solve the dt-binding violation issue first.
Though there are two same mmsys-compatible strings involving in dts though, it seems that hdmi still can work fine in my setup.
Sean
+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");
On 30/04/18 12:18, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 | 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..d23a3b9a2c58 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 MFD_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 matthias.bgg@gmail.com
- Author: Matthias Brugger matthias.bgg@gmail.com
- */
+#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;
+};
This driver is pretty pointless. It doesn't actually do anything.
I think you just want to use "simple-mfd" instead.
I think the problem is, that right now we have two drivers which use the same devicetree binding, which are clk and drm driver. With a simple-mfd we would need two compatibles, and this would break backwards compatibility.
Regards, Matthias
On Mon, 25 Jun 2018, Matthias Brugger wrote:
On 30/04/18 12:18, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 | 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..d23a3b9a2c58 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 MFD_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 matthias.bgg@gmail.com
- Author: Matthias Brugger matthias.bgg@gmail.com
- */
+#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;
+};
This driver is pretty pointless. It doesn't actually do anything.
I think you just want to use "simple-mfd" instead.
I think the problem is, that right now we have two drivers which use the same devicetree binding, which are clk and drm driver. With a simple-mfd we would need two compatibles, and this would break backwards compatibility.
So what functionality does this driver provide you with that you do not have currently?
On 03/07/18 09:11, Lee Jones wrote:
On Mon, 25 Jun 2018, Matthias Brugger wrote:
On 30/04/18 12:18, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 | 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..d23a3b9a2c58 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 MFD_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 matthias.bgg@gmail.com
- Author: Matthias Brugger matthias.bgg@gmail.com
- */
+#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;
+};
This driver is pretty pointless. It doesn't actually do anything.
I think you just want to use "simple-mfd" instead.
I think the problem is, that right now we have two drivers which use the same devicetree binding, which are clk and drm driver. With a simple-mfd we would need two compatibles, and this would break backwards compatibility.
So what functionality does this driver provide you with that you do not have currently?
I'm not sure if I get your question. Point is, that the MMSYS implementation for mt8173 is broken, as it assumes that we can probe two drivers with the mediatek,mt8173-mmsys compatible. Somehow it used to work, but from what I understand it was a bug. So older devicetrees use just on mt8173-mmsys compatible in ther DTB.
I would like to keep backwards compatibility for the device tree, that's why I was searching for a solution where we can probe two drivers and came up with this mfd solution.
So no new functionality, the clk driver provides the clock the drm components need.
Regards, Matthias
On Wed, 04 Jul 2018, Matthias Brugger wrote:
On 03/07/18 09:11, Lee Jones wrote:
On Mon, 25 Jun 2018, Matthias Brugger wrote:
On 30/04/18 12:18, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 | 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..d23a3b9a2c58 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 MFD_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 matthias.bgg@gmail.com
- Author: Matthias Brugger matthias.bgg@gmail.com
- */
+#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;
+};
This driver is pretty pointless. It doesn't actually do anything.
I think you just want to use "simple-mfd" instead.
I think the problem is, that right now we have two drivers which use the same devicetree binding, which are clk and drm driver. With a simple-mfd we would need two compatibles, and this would break backwards compatibility.
So what functionality does this driver provide you with that you do not have currently?
I'm not sure if I get your question. Point is, that the MMSYS implementation for mt8173 is broken, as it assumes that we can probe two drivers with the mediatek,mt8173-mmsys compatible. Somehow it used to work, but from what I understand it was a bug. So older devicetrees use just on mt8173-mmsys compatible in ther DTB.
Okay, that is what I was getting at. Thanks for the explanation.
Do you have a datasheet I can look at?
I would like to keep backwards compatibility for the device tree, that's why I was searching for a solution where we can probe two drivers and came up with this mfd solution.
So no new functionality, the clk driver provides the clock the drm components need.
On 04/07/18 18:45, Lee Jones wrote:
On Wed, 04 Jul 2018, Matthias Brugger wrote:
On 03/07/18 09:11, Lee Jones wrote:
On Mon, 25 Jun 2018, Matthias Brugger wrote:
On 30/04/18 12:18, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 | 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..d23a3b9a2c58 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 MFD_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 matthias.bgg@gmail.com
- Author: Matthias Brugger matthias.bgg@gmail.com
- */
+#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;
+};
This driver is pretty pointless. It doesn't actually do anything.
I think you just want to use "simple-mfd" instead.
I think the problem is, that right now we have two drivers which use the same devicetree binding, which are clk and drm driver. With a simple-mfd we would need two compatibles, and this would break backwards compatibility.
So what functionality does this driver provide you with that you do not have currently?
I'm not sure if I get your question. Point is, that the MMSYS implementation for mt8173 is broken, as it assumes that we can probe two drivers with the mediatek,mt8173-mmsys compatible. Somehow it used to work, but from what I understand it was a bug. So older devicetrees use just on mt8173-mmsys compatible in ther DTB.
Okay, that is what I was getting at. Thanks for the explanation.
Do you have a datasheet I can look at?
Unfortunately there is no datasheet you can get without a NDA. The only public available information I'm aware of is for the (not upstream supported) 96board [1]. And it's only the register description. You can find some more explanation about the MMSYS in older threads which tried to solve the very same problem [2]
Regards, Matthias
[1] https://www.96boards.org/documentation/consumer/mediatekx20/additional-docs/... [2] http://lists.infradead.org/pipermail/linux-mediatek/2017-October/010979.html
I would like to keep backwards compatibility for the device tree, that's why I was searching for a solution where we can probe two drivers and came up with this mfd solution.
So no new functionality, the clk driver provides the clock the drm components need.
On Thu, 05 Jul 2018, Matthias Brugger wrote:
On 04/07/18 18:45, Lee Jones wrote:
On Wed, 04 Jul 2018, Matthias Brugger wrote:
On 03/07/18 09:11, Lee Jones wrote:
On Mon, 25 Jun 2018, Matthias Brugger wrote:
On 30/04/18 12:18, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
> From: Matthias Brugger mbrugger@suse.com > > 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 | 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..d23a3b9a2c58 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 MFD_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 matthias.bgg@gmail.com > + * > + * Author: Matthias Brugger matthias.bgg@gmail.com > + */ > + > +#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; > +};
This driver is pretty pointless. It doesn't actually do anything.
I think you just want to use "simple-mfd" instead.
I think the problem is, that right now we have two drivers which use the same devicetree binding, which are clk and drm driver. With a simple-mfd we would need two compatibles, and this would break backwards compatibility.
So what functionality does this driver provide you with that you do not have currently?
I'm not sure if I get your question. Point is, that the MMSYS implementation for mt8173 is broken, as it assumes that we can probe two drivers with the mediatek,mt8173-mmsys compatible. Somehow it used to work, but from what I understand it was a bug. So older devicetrees use just on mt8173-mmsys compatible in ther DTB.
Okay, that is what I was getting at. Thanks for the explanation.
Do you have a datasheet I can look at?
Unfortunately there is no datasheet you can get without a NDA. The only public available information I'm aware of is for the (not upstream supported) 96board [1]. And it's only the register description. You can find some more explanation about the MMSYS in older threads which tried to solve the very same problem [2]
[1] https://www.96boards.org/documentation/consumer/mediatekx20/additional-docs/... [2] http://lists.infradead.org/pipermail/linux-mediatek/2017-October/010979.html
And now we have some history. Thanks for providing those.
So my initial reaction is the one I have just confirmed for myself. MFD is being used as a work-around in this odd use-case and really isn't the right place for it.
If you're adamant that you do not wish to change the Device Tree, my suggestion is to either move the clk functionality into the DRM driver, or register the clk driver from DRM using standard platform_device_register() API.
I would like to keep backwards compatibility for the device tree, that's why I was searching for a solution where we can probe two drivers and came up with this mfd solution.
So no new functionality, the clk driver provides the clock the drm components need.
On 05/07/18 14:22, Lee Jones wrote:
On Thu, 05 Jul 2018, Matthias Brugger wrote:
On 04/07/18 18:45, Lee Jones wrote:
On Wed, 04 Jul 2018, Matthias Brugger wrote:
On 03/07/18 09:11, Lee Jones wrote:
On Mon, 25 Jun 2018, Matthias Brugger wrote:
On 30/04/18 12:18, Lee Jones wrote: > On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
[...]
>> +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; >> +}; > > This driver is pretty pointless. It doesn't actually do anything. > > I think you just want to use "simple-mfd" instead. >
I think the problem is, that right now we have two drivers which use the same devicetree binding, which are clk and drm driver. With a simple-mfd we would need two compatibles, and this would break backwards compatibility.
So what functionality does this driver provide you with that you do not have currently?
I'm not sure if I get your question. Point is, that the MMSYS implementation for mt8173 is broken, as it assumes that we can probe two drivers with the mediatek,mt8173-mmsys compatible. Somehow it used to work, but from what I understand it was a bug. So older devicetrees use just on mt8173-mmsys compatible in ther DTB.
Okay, that is what I was getting at. Thanks for the explanation.
Do you have a datasheet I can look at?
Unfortunately there is no datasheet you can get without a NDA. The only public available information I'm aware of is for the (not upstream supported) 96board [1]. And it's only the register description. You can find some more explanation about the MMSYS in older threads which tried to solve the very same problem [2]
[1] https://www.96boards.org/documentation/consumer/mediatekx20/additional-docs/... [2] http://lists.infradead.org/pipermail/linux-mediatek/2017-October/010979.html
And now we have some history. Thanks for providing those.
So my initial reaction is the one I have just confirmed for myself. MFD is being used as a work-around in this odd use-case and really isn't the right place for it.
If you're adamant that you do not wish to change the Device Tree, my suggestion is to either move the clk functionality into the DRM driver, or register the clk driver from DRM using standard platform_device_register() API.
Ok, I'll try to come up with a solution with a platform device for the clocks. Stay tuened. Thanks for your feedback!
Matthias
On Thu, Jul 5, 2018 at 12:17 AM, Matthias Brugger mbrugger@suse.com wrote:
On 03/07/18 09:11, Lee Jones wrote:
On Mon, 25 Jun 2018, Matthias Brugger wrote:
On 30/04/18 12:18, Lee Jones wrote:
On Fri, 27 Apr 2018, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 | 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..d23a3b9a2c58 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 MFD_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 matthias.bgg@gmail.com
- Author: Matthias Brugger matthias.bgg@gmail.com
- */
+#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;
+};
This driver is pretty pointless. It doesn't actually do anything.
I think you just want to use "simple-mfd" instead.
I think the problem is, that right now we have two drivers which use the same devicetree binding, which are clk and drm driver. With a simple-mfd we would need two compatibles, and this would break backwards compatibility.
So what functionality does this driver provide you with that you do not have currently?
I'm not sure if I get your question. Point is, that the MMSYS implementation for mt8173 is broken, as it assumes that we can probe two drivers with the mediatek,mt8173-mmsys compatible. Somehow it used to work, but from what I understand it was a bug. So older devicetrees use just on mt8173-mmsys compatible in ther DTB.
This works probably because the clk driver is using CLK_OF_DECLARE, which does not use the device model (i.e. no attached struct dev). So later on, when the device model scans and adds this device, it's considered not probed yet, and the drm driver will probe.
This breaks horribly if you try to move the clk driver to a platform device driver based implementation. On the other hand, if you need the clk in early init, you can't use a platform or mfd device.
Regards ChenYu
I would like to keep backwards compatibility for the device tree, that's why I was searching for a solution where we can probe two drivers and came up with this mfd solution.
So no new functionality, the clk driver provides the clock the drm components need.
Regards, Matthias
linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Matthias Brugger mbrugger@suse.com
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 | 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[] = {
Hi, Matthias:
On Fri, 2018-04-27 at 11:23 +0200, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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
Reviewed-by: CK Hu ck.hu@mediatek.com
Regards, CK
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",
{ .compatible = "mediatek,mt8173-mmsys", .data = &mt8173_mmsys_driver_data}, { }.data = &mt2701_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[] = {
From: Matthias Brugger mbrugger@suse.com
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 --- 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, }, };
From: Matthias Brugger mbrugger@suse.com
Add devices for the mt8173 SoC.
Signed-off-by: Matthias Brugger mbrugger@suse.com Reviewed-by: Philipp Zabel p.zabel@pengutronix.de --- 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 */ }, };
From: Matthias Brugger mbrugger@suse.com
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 Reviewed-by: Philipp Zabel p.zabel@pengutronix.de --- 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,
From: Matthias Brugger mbrugger@suse.com
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 --- drivers/clk/mediatek/clk-mt8173.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/mediatek/clk-mt8173.c b/drivers/clk/mediatek/clk-mt8173.c index 96c292c3e440..e31b3ee3e968 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" @@ -791,7 +792,7 @@ static const struct mtk_gate_regs mm1_cg_regs __initconst = { .ops = &mtk_clk_gate_ops_setclr, \ }
-static const struct mtk_gate mm_clks[] __initconst = { +static const struct mtk_gate mm_clks[] = { /* MM0 */ GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0), GATE_MM0(CLK_MM_SMI_LARB0, "mm_smi_larb0", "mm_sel", 1), @@ -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) {
From: Matthias Brugger mbrugger@suse.com
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 mbrugger@suse.com --- 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); }
Hi, Matthias:
On Fri, 2018-04-27 at 11:24 +0200, matthias.bgg@kernel.org wrote:
From: Matthias Brugger mbrugger@suse.com
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 mbrugger@suse.com
It's better to use 'drm/mediatek:' for title to align drm commits. For the modification,
Acked-by: CK Hu ck.hu@mediatek.com
Regards, CK
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)
return PTR_ERR(ddp->clk); }dev_err(dev, "Failed to get clock\n");
From: Matthias Brugger mbrugger@suse.com
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 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
dri-devel@lists.freedesktop.org