11f2967a1SChun-Jie Chen // SPDX-License-Identifier: GPL-2.0-only 21f2967a1SChun-Jie Chen // 31f2967a1SChun-Jie Chen // Copyright (c) 2022 MediaTek Inc. 41f2967a1SChun-Jie Chen // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> 51f2967a1SChun-Jie Chen 61f2967a1SChun-Jie Chen #include <linux/clk-provider.h> 71f2967a1SChun-Jie Chen #include <linux/platform_device.h> 81f2967a1SChun-Jie Chen #include <dt-bindings/clock/mt8186-clk.h> 91f2967a1SChun-Jie Chen 101f2967a1SChun-Jie Chen #include "clk-mtk.h" 111f2967a1SChun-Jie Chen 121f2967a1SChun-Jie Chen static const char * const mcu_armpll_ll_parents[] = { 131f2967a1SChun-Jie Chen "clk26m", 141f2967a1SChun-Jie Chen "armpll_ll", 151f2967a1SChun-Jie Chen "mainpll", 161f2967a1SChun-Jie Chen "univpll_d2" 171f2967a1SChun-Jie Chen }; 181f2967a1SChun-Jie Chen 191f2967a1SChun-Jie Chen static const char * const mcu_armpll_bl_parents[] = { 201f2967a1SChun-Jie Chen "clk26m", 211f2967a1SChun-Jie Chen "armpll_bl", 221f2967a1SChun-Jie Chen "mainpll", 231f2967a1SChun-Jie Chen "univpll_d2" 241f2967a1SChun-Jie Chen }; 251f2967a1SChun-Jie Chen 261f2967a1SChun-Jie Chen static const char * const mcu_armpll_bus_parents[] = { 271f2967a1SChun-Jie Chen "clk26m", 281f2967a1SChun-Jie Chen "ccipll", 291f2967a1SChun-Jie Chen "mainpll", 301f2967a1SChun-Jie Chen "univpll_d2" 311f2967a1SChun-Jie Chen }; 321f2967a1SChun-Jie Chen 331f2967a1SChun-Jie Chen /* 341f2967a1SChun-Jie Chen * We only configure the CPU muxes when adjust CPU frequency in MediaTek CPUFreq Driver. 351f2967a1SChun-Jie Chen * Other fields like divider always keep the same value. (set once in bootloader) 361f2967a1SChun-Jie Chen */ 371f2967a1SChun-Jie Chen static struct mtk_composite mcu_muxes[] = { 381f2967a1SChun-Jie Chen /* CPU_PLLDIV_CFG0 */ 391f2967a1SChun-Jie Chen MUX(CLK_MCU_ARMPLL_LL_SEL, "mcu_armpll_ll_sel", mcu_armpll_ll_parents, 0x2A0, 9, 2), 401f2967a1SChun-Jie Chen /* CPU_PLLDIV_CFG1 */ 411f2967a1SChun-Jie Chen MUX(CLK_MCU_ARMPLL_BL_SEL, "mcu_armpll_bl_sel", mcu_armpll_bl_parents, 0x2A4, 9, 2), 421f2967a1SChun-Jie Chen /* BUS_PLLDIV_CFG */ 431f2967a1SChun-Jie Chen MUX(CLK_MCU_ARMPLL_BUS_SEL, "mcu_armpll_bus_sel", mcu_armpll_bus_parents, 0x2E0, 9, 2), 441f2967a1SChun-Jie Chen }; 451f2967a1SChun-Jie Chen 46c5f34f63SAngeloGioacchino Del Regno static const struct mtk_clk_desc mcu_desc = { 47c5f34f63SAngeloGioacchino Del Regno .composite_clks = mcu_muxes, 48c5f34f63SAngeloGioacchino Del Regno .num_composite_clks = ARRAY_SIZE(mcu_muxes), 491f2967a1SChun-Jie Chen }; 501f2967a1SChun-Jie Chen 51c5f34f63SAngeloGioacchino Del Regno static const struct of_device_id of_match_clk_mt8186_mcu[] = { 52c5f34f63SAngeloGioacchino Del Regno { .compatible = "mediatek,mt8186-mcusys", .data = &mcu_desc }, 53c5f34f63SAngeloGioacchino Del Regno { /* sentinel */} 54c5f34f63SAngeloGioacchino Del Regno }; 5565c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_mcu); 561f2967a1SChun-Jie Chen 571f2967a1SChun-Jie Chen static struct platform_driver clk_mt8186_mcu_drv = { 581f2967a1SChun-Jie Chen .driver = { 591f2967a1SChun-Jie Chen .name = "clk-mt8186-mcu", 601f2967a1SChun-Jie Chen .of_match_table = of_match_clk_mt8186_mcu, 611f2967a1SChun-Jie Chen }, 62c5f34f63SAngeloGioacchino Del Regno .probe = mtk_clk_simple_probe, 63*f00b45dbSUwe Kleine-König .remove = mtk_clk_simple_remove, 641f2967a1SChun-Jie Chen }; 65c5f34f63SAngeloGioacchino Del Regno module_platform_driver(clk_mt8186_mcu_drv); 66c5f34f63SAngeloGioacchino Del Regno 67c5f34f63SAngeloGioacchino Del Regno MODULE_DESCRIPTION("MediaTek MT8186 mcusys clocks driver"); 68c5f34f63SAngeloGioacchino Del Regno MODULE_LICENSE("GPL"); 69