Merge tag 'arm-drivers-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc
[linux-2.6-microblaze.git] / drivers / gpu / drm / mediatek / mtk_drm_drv.c
index ce57028..6bd3694 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/pm_runtime.h>
+#include <linux/soc/mediatek/mtk-mmsys.h>
 #include <linux/dma-mapping.h>
 
 #include <drm/drm_atomic.h>
@@ -418,11 +419,22 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
        { }
 };
 
+static const struct of_device_id mtk_drm_of_ids[] = {
+       { .compatible = "mediatek,mt2701-mmsys",
+         .data = &mt2701_mmsys_driver_data},
+       { .compatible = "mediatek,mt2712-mmsys",
+         .data = &mt2712_mmsys_driver_data},
+       { .compatible = "mediatek,mt8173-mmsys",
+         .data = &mt8173_mmsys_driver_data},
+       { }
+};
+
 static int mtk_drm_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
+       struct device_node *phandle = dev->parent->of_node;
+       const struct of_device_id *of_id;
        struct mtk_drm_private *private;
-       struct resource *mem;
        struct device_node *node;
        struct component_match *match = NULL;
        int ret;
@@ -433,18 +445,20 @@ static int mtk_drm_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        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->mmsys_dev = dev->parent;
+       if (!private->mmsys_dev) {
+               dev_err(dev, "Failed to get MMSYS device\n");
+               return -ENODEV;
        }
 
+       of_id = of_match_node(mtk_drm_of_ids, phandle);
+       if (!of_id)
+               return -ENODEV;
+
+       private->data = of_id->data;
+
        /* Iterate over sibling DISP function blocks */
-       for_each_child_of_node(dev->of_node->parent, node) {
+       for_each_child_of_node(phandle->parent, node) {
                const struct of_device_id *of_id;
                enum mtk_ddp_comp_type comp_type;
                int comp_id;
@@ -578,22 +592,11 @@ 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,mt2701-mmsys",
-         .data = &mt2701_mmsys_driver_data},
-       { .compatible = "mediatek,mt2712-mmsys",
-         .data = &mt2712_mmsys_driver_data},
-       { .compatible = "mediatek,mt8173-mmsys",
-         .data = &mt8173_mmsys_driver_data},
-       { }
-};
-
 static struct platform_driver mtk_drm_platform_driver = {
        .probe  = mtk_drm_probe,
        .remove = mtk_drm_remove,
        .driver = {
                .name   = "mediatek-drm",
-               .of_match_table = mtk_drm_of_ids,
                .pm     = &mtk_drm_pm_ops,
        },
 };