Lines Matching +full:mt2701 +full:- +full:bdpsys

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2015-2016 MediaTek Inc.
6 #include <linux/arm-smccc.h>
20 #include <dt-bindings/memory/mt2701-larb-port.h>
21 #include <dt-bindings/memory/mtk-memory-port.h>
55 /* gen1: mt2701 */
66 * or non-security.
70 /* mt2701 domain should be set to 3 */
143 struct clk *clk_async; /*only needed by mt2701*/
155 struct device *smi_common_dev; /* common or sub-common dev */
171 larb->larbid = i; in mtk_smi_larb_bind()
172 larb->mmu = &larb_mmu[i].mmu; in mtk_smi_larb_bind()
173 larb->bank = larb_mmu[i].bank; in mtk_smi_larb_bind()
177 return -ENODEV; in mtk_smi_larb_bind()
194 const struct mtk_smi_larb_gen *larb_gen = larb->larb_gen; in mtk_smi_larb_config_port_gen1()
195 struct mtk_smi *common = dev_get_drvdata(larb->smi_common_dev); in mtk_smi_larb_config_port_gen1()
199 m4u_port_id = larb_gen->port_in_larb[larb->larbid]; in mtk_smi_larb_config_port_gen1()
200 larb_port_num = larb_gen->port_in_larb[larb->larbid + 1] in mtk_smi_larb_config_port_gen1()
201 - larb_gen->port_in_larb[larb->larbid]; in mtk_smi_larb_config_port_gen1()
204 if (*larb->mmu & BIT(i)) { in mtk_smi_larb_config_port_gen1()
211 reg_val = readl(common->smi_ao_base in mtk_smi_larb_config_port_gen1()
217 common->smi_ao_base in mtk_smi_larb_config_port_gen1()
227 writel(*larb->mmu, larb->base + MT8167_SMI_LARB_MMU_EN); in mtk_smi_larb_config_port_mt8167()
235 writel(*larb->mmu, larb->base + MT8173_SMI_LARB_MMU_EN); in mtk_smi_larb_config_port_mt8173()
242 u32 reg, flags_general = larb->larb_gen->flags_general; in mtk_smi_larb_config_port_gen2_general()
243 const u8 *larbostd = larb->larb_gen->ostd ? larb->larb_gen->ostd[larb->larbid] : NULL; in mtk_smi_larb_config_port_gen2_general()
247 if (BIT(larb->larbid) & larb->larb_gen->larb_direct_to_common_mask) in mtk_smi_larb_config_port_gen2_general()
251 reg = readl_relaxed(larb->base + SMI_LARB_CMD_THRT_CON); in mtk_smi_larb_config_port_gen2_general()
254 writel_relaxed(reg, larb->base + SMI_LARB_CMD_THRT_CON); in mtk_smi_larb_config_port_gen2_general()
258 writel_relaxed(SMI_LARB_SW_FLAG_1, larb->base + SMI_LARB_SW_FLAG); in mtk_smi_larb_config_port_gen2_general()
261 writel_relaxed(larbostd[i], larb->base + SMI_LARB_OSTDL_PORTx(i)); in mtk_smi_larb_config_port_gen2_general()
270 larb->larbid, *larb->mmu, 0, 0, 0, 0, &res); in mtk_smi_larb_config_port_gen2_general()
273 return -EINVAL; in mtk_smi_larb_config_port_gen2_general()
277 for_each_set_bit(i, (unsigned long *)larb->mmu, 32) { in mtk_smi_larb_config_port_gen2_general()
278 reg = readl_relaxed(larb->base + SMI_LARB_NONSEC_CON(i)); in mtk_smi_larb_config_port_gen2_general()
280 reg |= BANK_SEL(larb->bank[i]); in mtk_smi_larb_config_port_gen2_general()
281 writel(reg, larb->base + SMI_LARB_NONSEC_CON(i)); in mtk_smi_larb_config_port_gen2_general()
390 .larb_direct_to_common_mask = BIT(8) | BIT(9), /* bdpsys */
440 {.compatible = "mediatek,mt2701-smi-larb", .data = &mtk_smi_larb_mt2701},
441 {.compatible = "mediatek,mt2712-smi-larb", .data = &mtk_smi_larb_mt2712},
442 {.compatible = "mediatek,mt6779-smi-larb", .data = &mtk_smi_larb_mt6779},
443 {.compatible = "mediatek,mt6795-smi-larb", .data = &mtk_smi_larb_mt8173},
444 {.compatible = "mediatek,mt8167-smi-larb", .data = &mtk_smi_larb_mt8167},
445 {.compatible = "mediatek,mt8173-smi-larb", .data = &mtk_smi_larb_mt8173},
446 {.compatible = "mediatek,mt8183-smi-larb", .data = &mtk_smi_larb_mt8183},
447 {.compatible = "mediatek,mt8186-smi-larb", .data = &mtk_smi_larb_mt8186},
448 {.compatible = "mediatek,mt8188-smi-larb", .data = &mtk_smi_larb_mt8188},
449 {.compatible = "mediatek,mt8192-smi-larb", .data = &mtk_smi_larb_mt8192},
450 {.compatible = "mediatek,mt8195-smi-larb", .data = &mtk_smi_larb_mt8195},
460 writel_relaxed(SLP_PROT_EN, larb->base + SMI_LARB_SLP_CON); in mtk_smi_larb_sleep_ctrl_enable()
461 ret = readl_poll_timeout_atomic(larb->base + SMI_LARB_SLP_CON, in mtk_smi_larb_sleep_ctrl_enable()
465 dev_err(larb->smi.dev, "sleep ctrl is not ready(0x%x).\n", tmp); in mtk_smi_larb_sleep_ctrl_enable()
472 writel_relaxed(0, larb->base + SMI_LARB_SLP_CON); in mtk_smi_larb_sleep_ctrl_disable()
482 smi_com_node = of_parse_phandle(dev->of_node, "mediatek,smi", 0); in mtk_smi_device_link_common()
484 return -EINVAL; in mtk_smi_device_link_common()
491 put_device(&smi_com_pdev->dev); in mtk_smi_device_link_common()
492 return -EPROBE_DEFER; in mtk_smi_device_link_common()
494 smi_com_dev = &smi_com_pdev->dev; in mtk_smi_device_link_common()
498 dev_err(dev, "Unable to link smi-common dev\n"); in mtk_smi_device_link_common()
499 put_device(&smi_com_pdev->dev); in mtk_smi_device_link_common()
500 return -ENODEV; in mtk_smi_device_link_common()
505 return -EINVAL; in mtk_smi_device_link_common()
518 smi->clks[i].id = clks[i]; in mtk_smi_dts_clk_init()
519 ret = devm_clk_bulk_get(dev, clk_nr_required, smi->clks); in mtk_smi_dts_clk_init()
524 smi->clks[i].id = clks[i]; in mtk_smi_dts_clk_init()
526 smi->clks + clk_nr_required); in mtk_smi_dts_clk_init()
527 smi->clk_num = clk_nr_required + clk_nr_optional; in mtk_smi_dts_clk_init()
534 struct device *dev = &pdev->dev; in mtk_smi_larb_probe()
539 return -ENOMEM; in mtk_smi_larb_probe()
541 larb->larb_gen = of_device_get_match_data(dev); in mtk_smi_larb_probe()
542 larb->base = devm_platform_ioremap_resource(pdev, 0); in mtk_smi_larb_probe()
543 if (IS_ERR(larb->base)) in mtk_smi_larb_probe()
544 return PTR_ERR(larb->base); in mtk_smi_larb_probe()
546 ret = mtk_smi_dts_clk_init(dev, &larb->smi, mtk_smi_larb_clks, in mtk_smi_larb_probe()
551 larb->smi.dev = dev; in mtk_smi_larb_probe()
553 ret = mtk_smi_device_link_common(dev, &larb->smi_common_dev); in mtk_smi_larb_probe()
566 device_link_remove(dev, larb->smi_common_dev); in mtk_smi_larb_probe()
574 device_link_remove(&pdev->dev, larb->smi_common_dev); in mtk_smi_larb_remove()
575 pm_runtime_disable(&pdev->dev); in mtk_smi_larb_remove()
576 component_del(&pdev->dev, &mtk_smi_larb_component_ops); in mtk_smi_larb_remove()
582 const struct mtk_smi_larb_gen *larb_gen = larb->larb_gen; in mtk_smi_larb_resume()
585 ret = clk_bulk_prepare_enable(larb->smi.clk_num, larb->smi.clks); in mtk_smi_larb_resume()
589 if (MTK_SMI_CAPS(larb->larb_gen->flags_general, MTK_SMI_FLAG_SLEEP_CTL)) in mtk_smi_larb_resume()
593 return larb_gen->config_port(dev); in mtk_smi_larb_resume()
601 if (MTK_SMI_CAPS(larb->larb_gen->flags_general, MTK_SMI_FLAG_SLEEP_CTL)) { in mtk_smi_larb_suspend()
607 clk_bulk_disable_unprepare(larb->smi.clk_num, larb->smi.clks); in mtk_smi_larb_suspend()
621 .name = "mtk-smi-larb",
722 {.compatible = "mediatek,mt2701-smi-common", .data = &mtk_smi_common_gen1},
723 {.compatible = "mediatek,mt2712-smi-common", .data = &mtk_smi_common_gen2},
724 {.compatible = "mediatek,mt6779-smi-common", .data = &mtk_smi_common_mt6779},
725 {.compatible = "mediatek,mt6795-smi-common", .data = &mtk_smi_common_mt6795},
726 {.compatible = "mediatek,mt8167-smi-common", .data = &mtk_smi_common_gen2},
727 {.compatible = "mediatek,mt8173-smi-common", .data = &mtk_smi_common_gen2},
728 {.compatible = "mediatek,mt8183-smi-common", .data = &mtk_smi_common_mt8183},
729 {.compatible = "mediatek,mt8186-smi-common", .data = &mtk_smi_common_mt8186},
730 {.compatible = "mediatek,mt8188-smi-common-vdo", .data = &mtk_smi_common_mt8188_vdo},
731 {.compatible = "mediatek,mt8188-smi-common-vpp", .data = &mtk_smi_common_mt8188_vpp},
732 {.compatible = "mediatek,mt8192-smi-common", .data = &mtk_smi_common_mt8192},
733 {.compatible = "mediatek,mt8195-smi-common-vdo", .data = &mtk_smi_common_mt8195_vdo},
734 {.compatible = "mediatek,mt8195-smi-common-vpp", .data = &mtk_smi_common_mt8195_vpp},
735 {.compatible = "mediatek,mt8195-smi-sub-common", .data = &mtk_smi_sub_common_mt8195},
736 {.compatible = "mediatek,mt8365-smi-common", .data = &mtk_smi_common_mt8365},
743 struct device *dev = &pdev->dev; in mtk_smi_common_probe()
749 return -ENOMEM; in mtk_smi_common_probe()
750 common->dev = dev; in mtk_smi_common_probe()
751 common->plat = of_device_get_match_data(dev); in mtk_smi_common_probe()
753 if (common->plat->has_gals) { in mtk_smi_common_probe()
754 if (common->plat->type == MTK_SMI_GEN2) in mtk_smi_common_probe()
756 else if (common->plat->type == MTK_SMI_GEN2_SUB_COMM) in mtk_smi_common_probe()
769 if (common->plat->type == MTK_SMI_GEN1) { in mtk_smi_common_probe()
770 common->smi_ao_base = devm_platform_ioremap_resource(pdev, 0); in mtk_smi_common_probe()
771 if (IS_ERR(common->smi_ao_base)) in mtk_smi_common_probe()
772 return PTR_ERR(common->smi_ao_base); in mtk_smi_common_probe()
774 common->clk_async = devm_clk_get_enabled(dev, "async"); in mtk_smi_common_probe()
775 if (IS_ERR(common->clk_async)) in mtk_smi_common_probe()
776 return PTR_ERR(common->clk_async); in mtk_smi_common_probe()
778 common->base = devm_platform_ioremap_resource(pdev, 0); in mtk_smi_common_probe()
779 if (IS_ERR(common->base)) in mtk_smi_common_probe()
780 return PTR_ERR(common->base); in mtk_smi_common_probe()
783 /* link its smi-common if this is smi-sub-common */ in mtk_smi_common_probe()
784 if (common->plat->type == MTK_SMI_GEN2_SUB_COMM) { in mtk_smi_common_probe()
785 ret = mtk_smi_device_link_common(dev, &common->smi_common_dev); in mtk_smi_common_probe()
797 struct mtk_smi *common = dev_get_drvdata(&pdev->dev); in mtk_smi_common_remove()
799 if (common->plat->type == MTK_SMI_GEN2_SUB_COMM) in mtk_smi_common_remove()
800 device_link_remove(&pdev->dev, common->smi_common_dev); in mtk_smi_common_remove()
801 pm_runtime_disable(&pdev->dev); in mtk_smi_common_remove()
807 const struct mtk_smi_reg_pair *init = common->plat->init; in mtk_smi_common_resume()
808 u32 bus_sel = common->plat->bus_sel; /* default is 0 */ in mtk_smi_common_resume()
811 ret = clk_bulk_prepare_enable(common->clk_num, common->clks); in mtk_smi_common_resume()
815 if (common->plat->type != MTK_SMI_GEN2) in mtk_smi_common_resume()
819 writel_relaxed(init[i].value, common->base + init[i].offset); in mtk_smi_common_resume()
821 writel(bus_sel, common->base + SMI_BUS_SEL); in mtk_smi_common_resume()
829 clk_bulk_disable_unprepare(common->clk_num, common->clks); in mtk_smi_common_suspend()
843 .name = "mtk-smi-common",