arm/arm64: mediatek: Fix mmsys device probing
Subsystems (7)
v3 cover arm/arm64: mediatek: Fix mmsys device probing
From: Matthias Brugger <[email protected]>
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
Signature · 1 line
2.16.3
PATCH v3 1/10 dt-bindings: mediatek: mmsys: Add support for mfd
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.
--- .../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
Documentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt +0 -2
@@ -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
Documentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1 -1
@@ -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 ====================
Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +27 -0
@@ -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 at 14000000 { + compatible = "mediatek,mt8173-mmsys", "syscon"; + reg = <0 0x14000000 0 0x1000>; + power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>; + #clock-cells = <1>; +};
Signature · 1 line
2.16.3
PATCH v3 2/10 drm/mediatek: Use regmap for register access
In reply to [email protected]From: Matthias Brugger <[email protected]>
The mmsys memory space is shared between the drm and the clk driver. Use regmap to access it.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 ++-- drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 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(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +2 -2
@@ -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;
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +15 -23
@@ -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)
drivers/gpu/drm/mediatek/mtk_drm_ddp.h +2 -2
@@ -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);
drivers/gpu/drm/mediatek/mtk_drm_drv.c +4 -9
@@ -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) {
drivers/gpu/drm/mediatek/mtk_drm_drv.h +1 -1
@@ -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;
Signature · 1 line
2.16.3
PATCH v3 3/10 mfd: mtk-mmsys: Add mmsys driver
In reply to [email protected]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.
--- 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
drivers/mfd/Kconfig +9 -0
@@ -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
drivers/mfd/Makefile +2 -0
@@ -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
drivers/mfd/mtk-mmsys.c new file +79 -0
79 lines not on this page · raw message
Signature · 1 line
2.16.3
PATCH v3 4/10 drm/mediatek: mt2701: switch to mfd probing.
In reply to [email protected]From: Matthias Brugger <[email protected]>
With the mtk-mmsys MFD device in place, we switch the probing for mt2701 from device-tree to mfd.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +23 -7
@@ -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[] = {
Signature · 1 line
2.16.3
PATCH v3 5/10 clk: mediatek: mt2701-mm: switch to mfd device
In reply to [email protected]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.
--- drivers/clk/mediatek/clk-mt2701-mm.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/clk/mediatek/clk-mt2701-mm.c +3 -7
@@ -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, }, };
Signature · 1 line
2.16.3
PATCH v3 6/10 mfd: mtk-mmsys: Add mt8173 nodes
In reply to [email protected]From: Matthias Brugger <[email protected]>
Add devices for the mt8173 SoC.
--- drivers/mfd/mtk-mmsys.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/mfd/mtk-mmsys.c +14 -0
@@ -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 */ }, };
Signature · 1 line
2.16.3
PATCH v3 7/10 drm/mediatek: Add mfd support for mt8173
In reply to [email protected]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.
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_drv.c +7 -21
@@ -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,
Signature · 1 line
2.16.3
PATCH v3 8/10 clk: mediatek: mt8173-mm: switch to mfd device
In reply to [email protected]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.
--- drivers/clk/mediatek/clk-mt8173.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-)
drivers/clk/mediatek/clk-mt8173.c +16 -3
@@ -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) {
Signature · 1 line
2.16.3
PATCH v3 9/10 drm: mediatek: Omit warning on probe defers
In reply to [email protected]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.
--- drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_drm_ddp.c +2 -1
@@ -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); }
Signature · 1 line
2.16.3
PATCH v3 10/10 MAINTAINERS: update Mediatek Soc entry
In reply to [email protected]From: Matthias Brugger <[email protected]>
Mediatek SoCs include several soc specific drivers as well as a mfd device. Add these to the maintainers file.
--- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+)
MAINTAINERS +2 -0
@@ -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
Signature · 1 line
2.16.3
Re: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
In reply to [email protected]Quoted 102 lines · matthias.bgg at kernel.org
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.cdrivers/mfd/Kconfig +9
-0@@ -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_TESTdrivers/mfd/Makefile +2
-0@@ -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.odrivers/mfd/mtk-mmsys.c new file +49
-0@@ -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 ; + }
drivers/mfd/mtk-mmsys.c line 59
Quoted 10 lines
drivers/mfd/mtk-mmsys.c new file +10
-0+ + 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.
Quoted 19 lines
drivers/mfd/mtk-mmsys.c new file +19
-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" );
Signature · 4 lines
Lee Jones [???] Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [v3 01/10] dt-bindings: mediatek: mmsys: Add support for mfd
In reply to [email protected]Quoted 49 lines · matthias.bgg at kernel.org
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.txtDocumentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt +0
-2@@ -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 fromDocumentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1
-1@@ -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 ====================Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +0
-0
Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +1
-0@@ -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?
Quoted 25 lines
Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +25
-0+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 at 14000000 { + compatible = "mediatek,mt8173-mmsys", "syscon"; + reg = <0 0x14000000 0 0x1000>; + power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>; + #clock-cells = <1>; +};
Signature · 4 lines
Lee Jones [???] Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [v3 04/10] drm/mediatek: mt2701: switch to mfd probing.
In reply to [email protected]Hi, Matthias:
Quoted 6 lines · matthias.bgg at kernel.org
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]>
Regards,
CK
Quoted 73 lines
--- drivers/gpu/drm/mediatek/mtk_drm_drv.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-)drivers/gpu/drm/mediatek/mtk_drm_drv.c +23
-7@@ -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[] = {
Re: [v3 09/10] drm: mediatek: Omit warning on probe defers
In reply to [email protected]Hi, Matthias:
Quoted 8 lines · matthias.bgg at kernel.org
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]>
It's better to use 'drm/mediatek:' for title to align drm commits. For the modification,
Regards,
CK
Quoted 18 lines
--- drivers/gpu/drm/mediatek/mtk_drm_ddp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/gpu/drm/mediatek/mtk_drm_ddp.c +2
-1@@ -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); }
Re: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
In reply to Lee JonesQuoted 13 lines · Lee Jones
Quoted 11 lines · On Fri, 27 Apr 2018, [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 +++++++++++++++++++++++++++++++++++++++++++++++++
[ ... ]
Quoted 6 lines
Quoted 1 line
+};
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
Quoted 20 lines
Quoted 19 lines
drivers/mfd/mtk-mmsys.c new file +19
-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" );
Matthias Brugger
maintainerRe: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
In reply to Lee JonesQuoted 117 lines · Lee Jones
Quoted 102 lines · On Fri, 27 Apr 2018, [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.cdrivers/mfd/Kconfig +9
-0@@ -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_TESTdrivers/mfd/Makefile +2
-0@@ -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.odrivers/mfd/mtk-mmsys.c new file +49
-0@@ -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 ; + }drivers/mfd/mtk-mmsys.c line 59
Quoted 10 lines
drivers/mfd/mtk-mmsys.c new file +10
-0+ + 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.
Quoted 2 lines
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
Matthias Brugger
maintainerRe: [v3 01/10] dt-bindings: mediatek: mmsys: Add support for mfd
In reply to Lee JonesQuoted 55 lines · Lee Jones
Quoted 49 lines · On Fri, 27 Apr 2018, [email protected] wrote:
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.txtDocumentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt +0
-2@@ -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 fromDocumentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1
-1@@ -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 ====================Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +0
-0Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +1
-0@@ -0,0 +1,27 @@ +MediaTek MMSYS Multifunction Device DriverWhat is "MMSYS"?
Quoted 4 lines
"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
Quoted 26 lines
Quoted 25 lines
Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +25
-0+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>; +};
Re: [v3 01/10] dt-bindings: mediatek: mmsys: Add support for mfd
Quoted 13 lines · Matthias Brugger
Quoted 9 lines · Lee Jones
Quoted 7 lines · matthias.bgg at kernel.org
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.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
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
Please CC DT list on bindings.
Rob
Re: [v3 01/10] dt-bindings: mediatek: mmsys: Add support for mfd
In reply to Matthias BruggerQuoted 58 lines · Matthias Brugger
Quoted 55 lines · Lee Jones
Quoted 49 lines · matthias.bgg at kernel.org
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.txtDocumentation/devicetree/bindings/arm/mediatek/mediatek,mmsys.txt +0
-2@@ -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 fromDocumentation/devicetree/bindings/display/mediatek/mediatek,disp.txt +1
-1@@ -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 ====================Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +0
-0Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +1
-0@@ -0,0 +1,27 @@ +MediaTek MMSYS Multifunction Device DriverWhat is "MMSYS"?
Quoted 6 lines
Quoted 3 lines
"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?
Quoted 26 lines
Quoted 26 lines
Quoted 25 lines
Documentation/devicetree/bindings/mfd/mediatek,mmsys.txt new file +25
-0+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 at 14000000 { + compatible = "mediatek,mt8173-mmsys", "syscon"; + reg = <0 0x14000000 0 0x1000>; + power-domains = <&scpsys MT8173_POWER_DOMAIN_MM>; + #clock-cells = <1>; +};
Signature · 4 lines
Lee Jones [???] Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
In reply to Matthias BruggerQuoted 118 lines · Matthias Brugger
Quoted 117 lines · Lee Jones
Quoted 102 lines · matthias.bgg at kernel.org
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.cdrivers/mfd/Kconfig +9
-0@@ -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_TESTdrivers/mfd/Makefile +2
-0@@ -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.odrivers/mfd/mtk-mmsys.c new file +49
-0@@ -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 ; + }drivers/mfd/mtk-mmsys.c line 59
Quoted 10 lines
drivers/mfd/mtk-mmsys.c new file +10
-0+ + 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.
Quoted 6 lines
Quoted 2 lines
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?
Signature · 4 lines
Lee Jones [???] Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
Quoted 122 lines · Lee Jones
Quoted 121 lines · Matthias Brugger
Quoted 119 lines · Lee Jones
Quoted 102 lines · On Fri, 27 Apr 2018, [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.cdrivers/mfd/Kconfig +9
-0@@ -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_TESTdrivers/mfd/Makefile +2
-0@@ -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.odrivers/mfd/mtk-mmsys.c new file +49
-0@@ -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 ; + }drivers/mfd/mtk-mmsys.c line 59
Quoted 10 lines
drivers/mfd/mtk-mmsys.c new file +10
-0+ + 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.
Quoted 7 lines
Quoted 3 lines
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
Re: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
Quoted 133 lines · Matthias Brugger
Quoted 122 lines · Lee Jones
Quoted 121 lines · Matthias Brugger
Quoted 119 lines · Lee Jones
Quoted 102 lines · matthias.bgg at kernel.org
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.cdrivers/mfd/Kconfig +9
-0@@ -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_TESTdrivers/mfd/Makefile +2
-0@@ -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.odrivers/mfd/mtk-mmsys.c new file +49
-0@@ -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 ; + }drivers/mfd/mtk-mmsys.c line 59
Quoted 10 lines
drivers/mfd/mtk-mmsys.c new file +10
-0+ + 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.
Quoted 7 lines
Quoted 3 lines
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?
Quoted 5 lines
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?
Quoted 5 lines
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.
Signature · 4 lines
Lee Jones [???] Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
In reply to Matthias BruggerQuoted 133 lines · Matthias Brugger
Quoted 122 lines · Lee Jones
Quoted 121 lines · Matthias Brugger
Quoted 119 lines · Lee Jones
Quoted 102 lines · matthias.bgg at kernel.org
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.cdrivers/mfd/Kconfig +9
-0@@ -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_TESTdrivers/mfd/Makefile +2
-0@@ -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.odrivers/mfd/mtk-mmsys.c new file +49
-0@@ -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 ; + }drivers/mfd/mtk-mmsys.c line 59
Quoted 10 lines
drivers/mfd/mtk-mmsys.c new file +10
-0+ + 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.
Quoted 7 lines
Quoted 3 lines
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?
Quoted 5 lines
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
Quoted 14 lines
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 at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
In reply to Lee JonesQuoted 141 lines · Lee Jones
Quoted 133 lines · Matthias Brugger
Quoted 122 lines · Lee Jones
Quoted 121 lines · Matthias Brugger
Quoted 119 lines · Lee Jones
Quoted 102 lines · On Fri, 27 Apr 2018, [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.cdrivers/mfd/Kconfig +9
-0@@ -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_TESTdrivers/mfd/Makefile +2
-0@@ -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.odrivers/mfd/mtk-mmsys.c new file +49
-0@@ -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 ; + }drivers/mfd/mtk-mmsys.c line 59
Quoted 10 lines
drivers/mfd/mtk-mmsys.c new file +10
-0+ + 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.
Quoted 7 lines
Quoted 3 lines
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?
Quoted 5 lines
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.
Quoted 4 lines
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/docs/MT6797_Register_Table_Part_2.pdf
[2] http://lists.infradead.org/pipermail/linux-mediatek/2017-October/010979.html
Quoted 6 lines
Quoted 5 lines
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.
Re: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
Quoted 144 lines · Matthias Brugger
Quoted 138 lines · Lee Jones
Quoted 131 lines · Matthias Brugger
Quoted 122 lines · Lee Jones
Quoted 121 lines · Matthias Brugger
Quoted 119 lines · Lee Jones
Quoted 102 lines · matthias.bgg at kernel.org
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.cdrivers/mfd/Kconfig +9
-0@@ -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_TESTdrivers/mfd/Makefile +2
-0@@ -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.odrivers/mfd/mtk-mmsys.c new file +49
-0@@ -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 ; + }drivers/mfd/mtk-mmsys.c line 59
Quoted 10 lines
drivers/mfd/mtk-mmsys.c new file +10
-0+ + 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.
Quoted 7 lines
Quoted 3 lines
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?
Quoted 5 lines
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.
Quoted 4 lines
Okay, that is what I was getting at. Thanks for the explanation.
Do you have a datasheet I can look at?
Quoted 8 lines
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/docs/MT6797_Register_Table_Part_2.pdf
[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.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
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.
Signature · 4 lines
Lee Jones [???] Linaro Services Technical Lead Linaro.org ? Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [v3 03/10] mfd: mtk-mmsys: Add mmsys driver
Quoted 7 lines · Lee Jones
Quoted 6 lines · Matthias Brugger
Quoted 5 lines · Lee Jones
Quoted 4 lines · Matthias Brugger
Quoted 3 lines · Lee Jones
Quoted 2 lines · Matthias Brugger
Quoted 1 line · Lee Jones
On Fri, 27 Apr 2018, [email protected] wrote:
[...]
Quoted 67 lines
Quoted 56 lines
Quoted 51 lines
Quoted 45 lines
Quoted 37 lines
Quoted 37 lines
Quoted 36 lines
Quoted 21 lines
(quoted diff) +21
-0+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; + }Review
Quoted 10 lines
(quoted diff) +10
-0+ + 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.
Quoted 7 lines
Quoted 3 lines
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?
Quoted 5 lines
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.
Quoted 4 lines
Okay, that is what I was getting at. Thanks for the explanation.
Do you have a datasheet I can look at?
Quoted 8 lines
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/docs/MT6797_Register_Table_Part_2.pdf
[2] http://lists.infradead.org/pipermail/linux-mediatek/2017-October/010979.htmlAnd now we have some history. Thanks for providing those.
Quoted 9 lines
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