Lines Matching +full:mt8173 +full:- +full:mmsys
1 // SPDX-License-Identifier: GPL-2.0-only
12 #include <linux/reset-controller.h>
13 #include <linux/soc/mediatek/mtk-mmsys.h>
15 #include "mtk-mmsys.h"
16 #include "mt8167-mmsys.h"
17 #include "mt8183-mmsys.h"
18 #include "mt8186-mmsys.h"
19 #include "mt8192-mmsys.h"
20 #include "mt8195-mmsys.h"
21 #include "mt8365-mmsys.h"
24 .clk_driver = "clk-mt2701-mm",
37 .clk_driver = "clk-mt2712-mm",
50 .clk_driver = "clk-mt6779-mm",
61 .clk_driver = "clk-mt6797-mm",
72 .clk_driver = "clk-mt8167-mm",
85 .clk_driver = "clk-mt8173-mm",
99 .clk_driver = "clk-mt8183-mm",
113 .clk_driver = "clk-mt8186-mm",
127 .clk_driver = "clk-mt8192-mm",
142 .clk_driver = "clk-mt8195-vdo0",
149 .clk_driver = "clk-mt8195-vdo1",
161 .clk_driver = "clk-mt8365-mm",
181 static int mtk_mmsys_find_match_drvdata(struct mtk_mmsys *mmsys, in mtk_mmsys_find_match_drvdata() argument
186 for (i = 0; i < match->num_drv_data; i++) in mtk_mmsys_find_match_drvdata()
187 if (mmsys->io_start == match->drv_data[i]->io_start) in mtk_mmsys_find_match_drvdata()
190 return -EINVAL; in mtk_mmsys_find_match_drvdata()
197 struct mtk_mmsys *mmsys = dev_get_drvdata(dev); in mtk_mmsys_ddp_connect() local
198 const struct mtk_mmsys_routes *routes = mmsys->data->routes; in mtk_mmsys_ddp_connect()
202 for (i = 0; i < mmsys->data->num_routes; i++) in mtk_mmsys_ddp_connect()
204 reg = readl_relaxed(mmsys->regs + routes[i].addr); in mtk_mmsys_ddp_connect()
207 writel_relaxed(reg, mmsys->regs + routes[i].addr); in mtk_mmsys_ddp_connect()
216 struct mtk_mmsys *mmsys = dev_get_drvdata(dev); in mtk_mmsys_ddp_disconnect() local
217 const struct mtk_mmsys_routes *routes = mmsys->data->routes; in mtk_mmsys_ddp_disconnect()
221 for (i = 0; i < mmsys->data->num_routes; i++) in mtk_mmsys_ddp_disconnect()
223 reg = readl_relaxed(mmsys->regs + routes[i].addr); in mtk_mmsys_ddp_disconnect()
225 writel_relaxed(reg, mmsys->regs + routes[i].addr); in mtk_mmsys_ddp_disconnect()
230 static void mtk_mmsys_update_bits(struct mtk_mmsys *mmsys, u32 offset, u32 mask, u32 val) in mtk_mmsys_update_bits() argument
234 tmp = readl_relaxed(mmsys->regs + offset); in mtk_mmsys_update_bits()
236 writel_relaxed(tmp, mmsys->regs + offset); in mtk_mmsys_update_bits()
253 struct mtk_mmsys *mmsys = container_of(rcdev, struct mtk_mmsys, rcdev); in mtk_mmsys_reset_update() local
257 spin_lock_irqsave(&mmsys->lock, flags); in mtk_mmsys_reset_update()
259 reg = readl_relaxed(mmsys->regs + mmsys->data->sw0_rst_offset); in mtk_mmsys_reset_update()
266 writel_relaxed(reg, mmsys->regs + mmsys->data->sw0_rst_offset); in mtk_mmsys_reset_update()
268 spin_unlock_irqrestore(&mmsys->lock, flags); in mtk_mmsys_reset_update()
304 struct device *dev = &pdev->dev; in mtk_mmsys_probe()
308 struct mtk_mmsys *mmsys; in mtk_mmsys_probe() local
312 mmsys = devm_kzalloc(dev, sizeof(*mmsys), GFP_KERNEL); in mtk_mmsys_probe()
313 if (!mmsys) in mtk_mmsys_probe()
314 return -ENOMEM; in mtk_mmsys_probe()
316 mmsys->regs = devm_platform_ioremap_resource(pdev, 0); in mtk_mmsys_probe()
317 if (IS_ERR(mmsys->regs)) { in mtk_mmsys_probe()
318 ret = PTR_ERR(mmsys->regs); in mtk_mmsys_probe()
319 dev_err(dev, "Failed to ioremap mmsys registers: %d\n", ret); in mtk_mmsys_probe()
323 spin_lock_init(&mmsys->lock); in mtk_mmsys_probe()
325 mmsys->rcdev.owner = THIS_MODULE; in mtk_mmsys_probe()
326 mmsys->rcdev.nr_resets = 32; in mtk_mmsys_probe()
327 mmsys->rcdev.ops = &mtk_mmsys_reset_ops; in mtk_mmsys_probe()
328 mmsys->rcdev.of_node = pdev->dev.of_node; in mtk_mmsys_probe()
329 ret = devm_reset_controller_register(&pdev->dev, &mmsys->rcdev); in mtk_mmsys_probe()
331 dev_err(&pdev->dev, "Couldn't register mmsys reset controller: %d\n", ret); in mtk_mmsys_probe()
337 dev_err(dev, "Couldn't get mmsys resource\n"); in mtk_mmsys_probe()
338 return -EINVAL; in mtk_mmsys_probe()
340 mmsys->io_start = res->start; in mtk_mmsys_probe()
343 if (match_data->num_drv_data > 1) { in mtk_mmsys_probe()
344 /* This SoC has multiple mmsys channels */ in mtk_mmsys_probe()
345 ret = mtk_mmsys_find_match_drvdata(mmsys, match_data); in mtk_mmsys_probe()
350 mmsys->data = match_data->drv_data[ret]; in mtk_mmsys_probe()
352 dev_dbg(dev, "Using single mmsys channel\n"); in mtk_mmsys_probe()
353 mmsys->data = match_data->drv_data[0]; in mtk_mmsys_probe()
356 platform_set_drvdata(pdev, mmsys); in mtk_mmsys_probe()
358 clks = platform_device_register_data(&pdev->dev, mmsys->data->clk_driver, in mtk_mmsys_probe()
363 drm = platform_device_register_data(&pdev->dev, "mediatek-drm", in mtk_mmsys_probe()
375 .compatible = "mediatek,mt2701-mmsys",
379 .compatible = "mediatek,mt2712-mmsys",
383 .compatible = "mediatek,mt6779-mmsys",
387 .compatible = "mediatek,mt6797-mmsys",
391 .compatible = "mediatek,mt8167-mmsys",
395 .compatible = "mediatek,mt8173-mmsys",
399 .compatible = "mediatek,mt8183-mmsys",
403 .compatible = "mediatek,mt8186-mmsys",
407 .compatible = "mediatek,mt8192-mmsys",
411 .compatible = "mediatek,mt8195-mmsys",
415 .compatible = "mediatek,mt8365-mmsys",
423 .name = "mtk-mmsys",