Skip to content

Commit 667c769

Browse files
Enric Balletbo i Serrambgg
authored andcommitted
soc / drm: mediatek: Fix mediatek-drm device probing
In the actual implementation the same compatible string "mediatek,<chip>-mmsys" is used to bind the clock drivers (drivers/soc/mediatek) as well as to the gpu driver (drivers/gpu/drm/mediatek/mtk_drm_drv.c). This ends with the problem that the only probed driver is the clock driver and there is no display at all. In any case having the same compatible string for two drivers is not correct and should be fixed. To fix this, and maintain backward compatibility, we can consider that the mmsys driver is the top-level entry point for the multimedia subsystem, so is not a pure clock controller but a system controller, and the drm driver is instantiated by that MMSYS driver. Signed-off-by: Enric Balletbo i Serra <[email protected]> Reviewed-by: CK Hu <[email protected]> Acked-by: CK Hu <[email protected]> Signed-off-by: Matthias Brugger <[email protected]>
1 parent 2c758e3 commit 667c769

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

drivers/gpu/drm/mediatek/mtk_drm_drv.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,21 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
422422
{ }
423423
};
424424

425+
static const struct of_device_id mtk_drm_of_ids[] = {
426+
{ .compatible = "mediatek,mt2701-mmsys",
427+
.data = &mt2701_mmsys_driver_data},
428+
{ .compatible = "mediatek,mt2712-mmsys",
429+
.data = &mt2712_mmsys_driver_data},
430+
{ .compatible = "mediatek,mt8173-mmsys",
431+
.data = &mt8173_mmsys_driver_data},
432+
{ }
433+
};
434+
425435
static int mtk_drm_probe(struct platform_device *pdev)
426436
{
427437
struct device *dev = &pdev->dev;
438+
struct device_node *phandle = dev->parent->of_node;
439+
const struct of_device_id *of_id;
428440
struct mtk_drm_private *private;
429441
struct device_node *node;
430442
struct component_match *match = NULL;
@@ -442,8 +454,14 @@ static int mtk_drm_probe(struct platform_device *pdev)
442454
return -ENODEV;
443455
}
444456

457+
of_id = of_match_node(mtk_drm_of_ids, phandle);
458+
if (!of_id)
459+
return -ENODEV;
460+
461+
private->data = of_id->data;
462+
445463
/* Iterate over sibling DISP function blocks */
446-
for_each_child_of_node(dev->of_node->parent, node) {
464+
for_each_child_of_node(phandle->parent, node) {
447465
const struct of_device_id *of_id;
448466
enum mtk_ddp_comp_type comp_type;
449467
int comp_id;
@@ -577,22 +595,11 @@ static int mtk_drm_sys_resume(struct device *dev)
577595
static SIMPLE_DEV_PM_OPS(mtk_drm_pm_ops, mtk_drm_sys_suspend,
578596
mtk_drm_sys_resume);
579597

580-
static const struct of_device_id mtk_drm_of_ids[] = {
581-
{ .compatible = "mediatek,mt2701-mmsys",
582-
.data = &mt2701_mmsys_driver_data},
583-
{ .compatible = "mediatek,mt2712-mmsys",
584-
.data = &mt2712_mmsys_driver_data},
585-
{ .compatible = "mediatek,mt8173-mmsys",
586-
.data = &mt8173_mmsys_driver_data},
587-
{ }
588-
};
589-
590598
static struct platform_driver mtk_drm_platform_driver = {
591599
.probe = mtk_drm_probe,
592600
.remove = mtk_drm_remove,
593601
.driver = {
594602
.name = "mediatek-drm",
595-
.of_match_table = mtk_drm_of_ids,
596603
.pm = &mtk_drm_pm_ops,
597604
},
598605
};

drivers/soc/mediatek/mtk-mmsys.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
287287
const struct mtk_mmsys_driver_data *data;
288288
struct device *dev = &pdev->dev;
289289
struct platform_device *clks;
290+
struct platform_device *drm;
290291
void __iomem *config_regs;
291292
struct resource *mem;
292293
int ret;
@@ -309,6 +310,11 @@ static int mtk_mmsys_probe(struct platform_device *pdev)
309310
if (IS_ERR(clks))
310311
return PTR_ERR(clks);
311312

313+
drm = platform_device_register_data(&pdev->dev, "mediatek-drm",
314+
PLATFORM_DEVID_AUTO, NULL, 0);
315+
if (IS_ERR(drm))
316+
return PTR_ERR(drm);
317+
312318
return 0;
313319
}
314320

0 commit comments

Comments
 (0)