19c4fec14SChun-Jie Chen // SPDX-License-Identifier: GPL-2.0-only 29c4fec14SChun-Jie Chen // 39c4fec14SChun-Jie Chen // Copyright (c) 2021 MediaTek Inc. 49c4fec14SChun-Jie Chen // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> 59c4fec14SChun-Jie Chen 69c4fec14SChun-Jie Chen #include "clk-gate.h" 79c4fec14SChun-Jie Chen #include "clk-mtk.h" 89c4fec14SChun-Jie Chen 99c4fec14SChun-Jie Chen #include <dt-bindings/clock/mt8195-clk.h> 109c4fec14SChun-Jie Chen #include <linux/clk-provider.h> 119c4fec14SChun-Jie Chen #include <linux/platform_device.h> 129c4fec14SChun-Jie Chen 139c4fec14SChun-Jie Chen static const struct mtk_gate_regs img_cg_regs = { 149c4fec14SChun-Jie Chen .set_ofs = 0x4, 159c4fec14SChun-Jie Chen .clr_ofs = 0x8, 169c4fec14SChun-Jie Chen .sta_ofs = 0x0, 179c4fec14SChun-Jie Chen }; 189c4fec14SChun-Jie Chen 199c4fec14SChun-Jie Chen #define GATE_IMG(_id, _name, _parent, _shift) \ 209c4fec14SChun-Jie Chen GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 219c4fec14SChun-Jie Chen 229c4fec14SChun-Jie Chen static const struct mtk_gate img_clks[] = { 239c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_LARB9, "img_larb9", "top_img", 0), 249c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_TRAW0, "img_traw0", "top_img", 1), 259c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_TRAW1, "img_traw1", "top_img", 2), 269c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_TRAW2, "img_traw2", "top_img", 3), 279c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_TRAW3, "img_traw3", "top_img", 4), 289c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_DIP0, "img_dip0", "top_img", 8), 299c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_WPE0, "img_wpe0", "top_img", 9), 309c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_IPE, "img_ipe", "top_img", 10), 319c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_DIP1, "img_dip1", "top_img", 11), 329c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_WPE1, "img_wpe1", "top_img", 12), 339c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG_GALS, "img_gals", "top_img", 31), 349c4fec14SChun-Jie Chen }; 359c4fec14SChun-Jie Chen 369c4fec14SChun-Jie Chen static const struct mtk_gate img1_dip_top_clks[] = { 379c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG1_DIP_TOP_LARB10, "img1_dip_top_larb10", "top_img", 0), 389c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG1_DIP_TOP_DIP_TOP, "img1_dip_top_dip_top", "top_img", 1), 399c4fec14SChun-Jie Chen }; 409c4fec14SChun-Jie Chen 419c4fec14SChun-Jie Chen static const struct mtk_gate img1_dip_nr_clks[] = { 429c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG1_DIP_NR_RESERVE, "img1_dip_nr_reserve", "top_img", 0), 439c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG1_DIP_NR_DIP_NR, "img1_dip_nr_dip_nr", "top_img", 1), 449c4fec14SChun-Jie Chen }; 459c4fec14SChun-Jie Chen 469c4fec14SChun-Jie Chen static const struct mtk_gate img1_wpe_clks[] = { 479c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG1_WPE_LARB11, "img1_wpe_larb11", "top_img", 0), 489c4fec14SChun-Jie Chen GATE_IMG(CLK_IMG1_WPE_WPE, "img1_wpe_wpe", "top_img", 1), 499c4fec14SChun-Jie Chen }; 509c4fec14SChun-Jie Chen 519c4fec14SChun-Jie Chen static const struct mtk_clk_desc img_desc = { 529c4fec14SChun-Jie Chen .clks = img_clks, 539c4fec14SChun-Jie Chen .num_clks = ARRAY_SIZE(img_clks), 549c4fec14SChun-Jie Chen }; 559c4fec14SChun-Jie Chen 569c4fec14SChun-Jie Chen static const struct mtk_clk_desc img1_dip_top_desc = { 579c4fec14SChun-Jie Chen .clks = img1_dip_top_clks, 589c4fec14SChun-Jie Chen .num_clks = ARRAY_SIZE(img1_dip_top_clks), 599c4fec14SChun-Jie Chen }; 609c4fec14SChun-Jie Chen 619c4fec14SChun-Jie Chen static const struct mtk_clk_desc img1_dip_nr_desc = { 629c4fec14SChun-Jie Chen .clks = img1_dip_nr_clks, 639c4fec14SChun-Jie Chen .num_clks = ARRAY_SIZE(img1_dip_nr_clks), 649c4fec14SChun-Jie Chen }; 659c4fec14SChun-Jie Chen 669c4fec14SChun-Jie Chen static const struct mtk_clk_desc img1_wpe_desc = { 679c4fec14SChun-Jie Chen .clks = img1_wpe_clks, 689c4fec14SChun-Jie Chen .num_clks = ARRAY_SIZE(img1_wpe_clks), 699c4fec14SChun-Jie Chen }; 709c4fec14SChun-Jie Chen 719c4fec14SChun-Jie Chen static const struct of_device_id of_match_clk_mt8195_img[] = { 729c4fec14SChun-Jie Chen { 739c4fec14SChun-Jie Chen .compatible = "mediatek,mt8195-imgsys", 749c4fec14SChun-Jie Chen .data = &img_desc, 759c4fec14SChun-Jie Chen }, { 769c4fec14SChun-Jie Chen .compatible = "mediatek,mt8195-imgsys1_dip_top", 779c4fec14SChun-Jie Chen .data = &img1_dip_top_desc, 789c4fec14SChun-Jie Chen }, { 799c4fec14SChun-Jie Chen .compatible = "mediatek,mt8195-imgsys1_dip_nr", 809c4fec14SChun-Jie Chen .data = &img1_dip_nr_desc, 819c4fec14SChun-Jie Chen }, { 829c4fec14SChun-Jie Chen .compatible = "mediatek,mt8195-imgsys1_wpe", 839c4fec14SChun-Jie Chen .data = &img1_wpe_desc, 849c4fec14SChun-Jie Chen }, { 859c4fec14SChun-Jie Chen /* sentinel */ 869c4fec14SChun-Jie Chen } 879c4fec14SChun-Jie Chen }; 88*65c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(of, of_match_clk_mt8195_img); 899c4fec14SChun-Jie Chen 909c4fec14SChun-Jie Chen static struct platform_driver clk_mt8195_img_drv = { 919c4fec14SChun-Jie Chen .probe = mtk_clk_simple_probe, 92cd3a77a0SChen-Yu Tsai .remove_new = mtk_clk_simple_remove, 939c4fec14SChun-Jie Chen .driver = { 949c4fec14SChun-Jie Chen .name = "clk-mt8195-img", 959c4fec14SChun-Jie Chen .of_match_table = of_match_clk_mt8195_img, 969c4fec14SChun-Jie Chen }, 979c4fec14SChun-Jie Chen }; 98164d240dSAngeloGioacchino Del Regno module_platform_driver(clk_mt8195_img_drv); 99a451da86SAngeloGioacchino Del Regno MODULE_LICENSE("GPL"); 100