162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2022 MediaTek Inc. 462306a36Sopenharmony_ci * Author: Garmin Chang <garmin.chang@mediatek.com> 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci 762306a36Sopenharmony_ci#include <linux/clk-provider.h> 862306a36Sopenharmony_ci#include <linux/mod_devicetable.h> 962306a36Sopenharmony_ci#include <linux/platform_device.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include <dt-bindings/clock/mediatek,mt8188-clk.h> 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include "clk-gate.h" 1462306a36Sopenharmony_ci#include "clk-mtk.h" 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_cistatic const struct mtk_gate_regs wpe_top_cg_regs = { 1762306a36Sopenharmony_ci .set_ofs = 0x0, 1862306a36Sopenharmony_ci .clr_ofs = 0x0, 1962306a36Sopenharmony_ci .sta_ofs = 0x0, 2062306a36Sopenharmony_ci}; 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_cistatic const struct mtk_gate_regs wpe_vpp0_0_cg_regs = { 2362306a36Sopenharmony_ci .set_ofs = 0x58, 2462306a36Sopenharmony_ci .clr_ofs = 0x58, 2562306a36Sopenharmony_ci .sta_ofs = 0x58, 2662306a36Sopenharmony_ci}; 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_cistatic const struct mtk_gate_regs wpe_vpp0_1_cg_regs = { 2962306a36Sopenharmony_ci .set_ofs = 0x5c, 3062306a36Sopenharmony_ci .clr_ofs = 0x5c, 3162306a36Sopenharmony_ci .sta_ofs = 0x5c, 3262306a36Sopenharmony_ci}; 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#define GATE_WPE_TOP(_id, _name, _parent, _shift) \ 3562306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &wpe_top_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ci#define GATE_WPE_VPP0_0(_id, _name, _parent, _shift) \ 3862306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &wpe_vpp0_0_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci#define GATE_WPE_VPP0_1(_id, _name, _parent, _shift) \ 4162306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &wpe_vpp0_1_cg_regs, _shift, &mtk_clk_gate_ops_no_setclr_inv) 4262306a36Sopenharmony_ci 4362306a36Sopenharmony_cistatic const struct mtk_gate wpe_top_clks[] = { 4462306a36Sopenharmony_ci GATE_WPE_TOP(CLK_WPE_TOP_WPE_VPP0, "wpe_wpe_vpp0", "top_wpe_vpp", 16), 4562306a36Sopenharmony_ci GATE_WPE_TOP(CLK_WPE_TOP_SMI_LARB7, "wpe_smi_larb7", "top_wpe_vpp", 18), 4662306a36Sopenharmony_ci GATE_WPE_TOP(CLK_WPE_TOP_WPESYS_EVENT_TX, "wpe_wpesys_event_tx", "top_wpe_vpp", 20), 4762306a36Sopenharmony_ci GATE_WPE_TOP(CLK_WPE_TOP_SMI_LARB7_PCLK_EN, "wpe_smi_larb7_p_en", "top_wpe_vpp", 24), 4862306a36Sopenharmony_ci}; 4962306a36Sopenharmony_ci 5062306a36Sopenharmony_cistatic const struct mtk_gate wpe_vpp0_clks[] = { 5162306a36Sopenharmony_ci /* WPE_VPP00 */ 5262306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_VGEN, "wpe_vpp0_vgen", "top_img", 0), 5362306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_EXT, "wpe_vpp0_ext", "top_img", 1), 5462306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_VFC, "wpe_vpp0_vfc", "top_img", 2), 5562306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH0_TOP, "wpe_vpp0_cach0_top", "top_img", 3), 5662306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH0_DMA, "wpe_vpp0_cach0_dma", "top_img", 4), 5762306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH1_TOP, "wpe_vpp0_cach1_top", "top_img", 5), 5862306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH1_DMA, "wpe_vpp0_cach1_dma", "top_img", 6), 5962306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH2_TOP, "wpe_vpp0_cach2_top", "top_img", 7), 6062306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH2_DMA, "wpe_vpp0_cach2_dma", "top_img", 8), 6162306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH3_TOP, "wpe_vpp0_cach3_top", "top_img", 9), 6262306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_CACH3_DMA, "wpe_vpp0_cach3_dma", "top_img", 10), 6362306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_PSP, "wpe_vpp0_psp", "top_img", 11), 6462306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_PSP2, "wpe_vpp0_psp2", "top_img", 12), 6562306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_SYNC, "wpe_vpp0_sync", "top_img", 13), 6662306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_C24, "wpe_vpp0_c24", "top_img", 14), 6762306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_MDP_CROP, "wpe_vpp0_mdp_crop", "top_img", 15), 6862306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_ISP_CROP, "wpe_vpp0_isp_crop", "top_img", 16), 6962306a36Sopenharmony_ci GATE_WPE_VPP0_0(CLK_WPE_VPP0_TOP, "wpe_vpp0_top", "top_img", 17), 7062306a36Sopenharmony_ci /* WPE_VPP0_1 */ 7162306a36Sopenharmony_ci GATE_WPE_VPP0_1(CLK_WPE_VPP0_VECI, "wpe_vpp0_veci", "top_img", 0), 7262306a36Sopenharmony_ci GATE_WPE_VPP0_1(CLK_WPE_VPP0_VEC2I, "wpe_vpp0_vec2i", "top_img", 1), 7362306a36Sopenharmony_ci GATE_WPE_VPP0_1(CLK_WPE_VPP0_VEC3I, "wpe_vpp0_vec3i", "top_img", 2), 7462306a36Sopenharmony_ci GATE_WPE_VPP0_1(CLK_WPE_VPP0_WPEO, "wpe_vpp0_wpeo", "top_img", 3), 7562306a36Sopenharmony_ci GATE_WPE_VPP0_1(CLK_WPE_VPP0_MSKO, "wpe_vpp0_msko", "top_img", 4), 7662306a36Sopenharmony_ci}; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_cistatic const struct mtk_clk_desc wpe_top_desc = { 7962306a36Sopenharmony_ci .clks = wpe_top_clks, 8062306a36Sopenharmony_ci .num_clks = ARRAY_SIZE(wpe_top_clks), 8162306a36Sopenharmony_ci}; 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_cistatic const struct mtk_clk_desc wpe_vpp0_desc = { 8462306a36Sopenharmony_ci .clks = wpe_vpp0_clks, 8562306a36Sopenharmony_ci .num_clks = ARRAY_SIZE(wpe_vpp0_clks), 8662306a36Sopenharmony_ci}; 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_cistatic const struct of_device_id of_match_clk_mt8188_wpe[] = { 8962306a36Sopenharmony_ci { .compatible = "mediatek,mt8188-wpesys", .data = &wpe_top_desc }, 9062306a36Sopenharmony_ci { .compatible = "mediatek,mt8188-wpesys-vpp0", .data = &wpe_vpp0_desc }, 9162306a36Sopenharmony_ci { /* sentinel */ } 9262306a36Sopenharmony_ci}; 9362306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_match_clk_mt8188_wpe); 9462306a36Sopenharmony_ci 9562306a36Sopenharmony_cistatic struct platform_driver clk_mt8188_wpe_drv = { 9662306a36Sopenharmony_ci .probe = mtk_clk_simple_probe, 9762306a36Sopenharmony_ci .remove_new = mtk_clk_simple_remove, 9862306a36Sopenharmony_ci .driver = { 9962306a36Sopenharmony_ci .name = "clk-mt8188-wpe", 10062306a36Sopenharmony_ci .of_match_table = of_match_clk_mt8188_wpe, 10162306a36Sopenharmony_ci }, 10262306a36Sopenharmony_ci}; 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_cimodule_platform_driver(clk_mt8188_wpe_drv); 10562306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 106