The hdmi_phy for mt8167 and the apmixedsys clocks share the same IO memory region and they both map it using devm_platform_ioremap_resource, which implies exclusive access. Switch the apmixedsys driver to of_iomap, like it is done in the mt8173-apmixedsys driver. Also, implement the remove function while we're at it.
Fixes the following runtime error: hdmi-phy: error -EBUSY: can't request region for resource [mem 0x10018300-0x1001831f] Signed-off-by: Luca Leonardo Scorcia <[email protected]> --- drivers/clk/mediatek/clk-mt8167-apmixedsys.c | 24 ++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/clk/mediatek/clk-mt8167-apmixedsys.c b/drivers/clk/mediatek/clk-mt8167-apmixedsys.c index fb6c21bbeef8..3e8611991de7 100644 --- a/drivers/clk/mediatek/clk-mt8167-apmixedsys.c +++ b/drivers/clk/mediatek/clk-mt8167-apmixedsys.c @@ -8,6 +8,7 @@ #include <dt-bindings/clock/mt8167-clk.h> #include <linux/clk.h> #include <linux/of.h> +#include <linux/of_address.h> #include <linux/platform_device.h> #include "clk-pll.h" @@ -97,17 +98,19 @@ static int clk_mt8167_apmixed_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; int ret; - base = devm_platform_ioremap_resource(pdev, 0); + base = of_iomap(node, 0); if (IS_ERR(base)) return PTR_ERR(base); clk_data = mtk_devm_alloc_clk_data(dev, MT8167_CLK_APMIXED_NR_CLK); - if (!clk_data) - return -ENOMEM; + if (IS_ERR_OR_NULL(clk_data)) { + ret = -ENOMEM; + goto unmap_io; + } ret = mtk_clk_register_plls(dev, plls, ARRAY_SIZE(plls), clk_data); if (ret) - return ret; + goto unmap_io; ret = mtk_clk_register_dividers(dev, adj_divs, ARRAY_SIZE(adj_divs), base, &mt8167_apmixed_clk_lock, clk_data); @@ -124,10 +127,22 @@ static int clk_mt8167_apmixed_probe(struct platform_device *pdev) mtk_clk_unregister_dividers(adj_divs, ARRAY_SIZE(adj_divs), clk_data); unregister_plls: mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); +unmap_io: + iounmap(base); return ret; } +static void clk_mt8167_apmixed_remove(struct platform_device *pdev) +{ + struct device_node *node = pdev->dev.of_node; + struct clk_hw_onecell_data *clk_data = platform_get_drvdata(pdev); + + of_clk_del_provider(node); + mtk_clk_unregister_dividers(adj_divs, ARRAY_SIZE(adj_divs), clk_data); + mtk_clk_unregister_plls(plls, ARRAY_SIZE(plls), clk_data); +} + static const struct of_device_id of_match_clk_mt8167_apmixed[] = { { .compatible = "mediatek,mt8167-apmixedsys" }, { /* sentinel */ } @@ -136,6 +151,7 @@ MODULE_DEVICE_TABLE(of, of_match_clk_mt8167_apmixed); static struct platform_driver clk_mt8167_apmixed_drv = { .probe = clk_mt8167_apmixed_probe, + .remove = clk_mt8167_apmixed_remove, .driver = { .name = "clk-mt8167-apmixed", .of_match_table = of_match_clk_mt8167_apmixed, -- 2.43.0
