162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci// 362306a36Sopenharmony_ci// Copyright (c) 2018 MediaTek Inc. 462306a36Sopenharmony_ci// Author: Weiyi Lu <weiyi.lu@mediatek.com> 562306a36Sopenharmony_ci 662306a36Sopenharmony_ci#include <linux/clk-provider.h> 762306a36Sopenharmony_ci#include <linux/platform_device.h> 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include "clk-mtk.h" 1062306a36Sopenharmony_ci#include "clk-gate.h" 1162306a36Sopenharmony_ci 1262306a36Sopenharmony_ci#include <dt-bindings/clock/mt8183-clk.h> 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_cistatic const struct mtk_gate_regs ipu_conn_cg_regs = { 1562306a36Sopenharmony_ci .set_ofs = 0x4, 1662306a36Sopenharmony_ci .clr_ofs = 0x8, 1762306a36Sopenharmony_ci .sta_ofs = 0x0, 1862306a36Sopenharmony_ci}; 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_cistatic const struct mtk_gate_regs ipu_conn_apb_cg_regs = { 2162306a36Sopenharmony_ci .set_ofs = 0x10, 2262306a36Sopenharmony_ci .clr_ofs = 0x10, 2362306a36Sopenharmony_ci .sta_ofs = 0x10, 2462306a36Sopenharmony_ci}; 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_cistatic const struct mtk_gate_regs ipu_conn_axi_cg_regs = { 2762306a36Sopenharmony_ci .set_ofs = 0x18, 2862306a36Sopenharmony_ci .clr_ofs = 0x18, 2962306a36Sopenharmony_ci .sta_ofs = 0x18, 3062306a36Sopenharmony_ci}; 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_cistatic const struct mtk_gate_regs ipu_conn_axi1_cg_regs = { 3362306a36Sopenharmony_ci .set_ofs = 0x1c, 3462306a36Sopenharmony_ci .clr_ofs = 0x1c, 3562306a36Sopenharmony_ci .sta_ofs = 0x1c, 3662306a36Sopenharmony_ci}; 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_cistatic const struct mtk_gate_regs ipu_conn_axi2_cg_regs = { 3962306a36Sopenharmony_ci .set_ofs = 0x20, 4062306a36Sopenharmony_ci .clr_ofs = 0x20, 4162306a36Sopenharmony_ci .sta_ofs = 0x20, 4262306a36Sopenharmony_ci}; 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ci#define GATE_IPU_CONN(_id, _name, _parent, _shift) \ 4562306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &ipu_conn_cg_regs, _shift, \ 4662306a36Sopenharmony_ci &mtk_clk_gate_ops_setclr) 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define GATE_IPU_CONN_APB(_id, _name, _parent, _shift) \ 4962306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &ipu_conn_apb_cg_regs, _shift, \ 5062306a36Sopenharmony_ci &mtk_clk_gate_ops_no_setclr) 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define GATE_IPU_CONN_AXI_I(_id, _name, _parent, _shift) \ 5362306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &ipu_conn_axi_cg_regs, _shift, \ 5462306a36Sopenharmony_ci &mtk_clk_gate_ops_no_setclr_inv) 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#define GATE_IPU_CONN_AXI1_I(_id, _name, _parent, _shift) \ 5762306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &ipu_conn_axi1_cg_regs, _shift, \ 5862306a36Sopenharmony_ci &mtk_clk_gate_ops_no_setclr_inv) 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ci#define GATE_IPU_CONN_AXI2_I(_id, _name, _parent, _shift) \ 6162306a36Sopenharmony_ci GATE_MTK(_id, _name, _parent, &ipu_conn_axi2_cg_regs, _shift, \ 6262306a36Sopenharmony_ci &mtk_clk_gate_ops_no_setclr_inv) 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_cistatic const struct mtk_gate ipu_conn_clks[] = { 6562306a36Sopenharmony_ci GATE_IPU_CONN(CLK_IPU_CONN_IPU, 6662306a36Sopenharmony_ci "ipu_conn_ipu", "dsp_sel", 0), 6762306a36Sopenharmony_ci GATE_IPU_CONN(CLK_IPU_CONN_AHB, 6862306a36Sopenharmony_ci "ipu_conn_ahb", "dsp_sel", 1), 6962306a36Sopenharmony_ci GATE_IPU_CONN(CLK_IPU_CONN_AXI, 7062306a36Sopenharmony_ci "ipu_conn_axi", "dsp_sel", 2), 7162306a36Sopenharmony_ci GATE_IPU_CONN(CLK_IPU_CONN_ISP, 7262306a36Sopenharmony_ci "ipu_conn_isp", "dsp_sel", 3), 7362306a36Sopenharmony_ci GATE_IPU_CONN(CLK_IPU_CONN_CAM_ADL, 7462306a36Sopenharmony_ci "ipu_conn_cam_adl", "dsp_sel", 4), 7562306a36Sopenharmony_ci GATE_IPU_CONN(CLK_IPU_CONN_IMG_ADL, 7662306a36Sopenharmony_ci "ipu_conn_img_adl", "dsp_sel", 5), 7762306a36Sopenharmony_ci GATE_IPU_CONN_APB(CLK_IPU_CONN_DAP_RX, 7862306a36Sopenharmony_ci "ipu_conn_dap_rx", "dsp1_sel", 0), 7962306a36Sopenharmony_ci GATE_IPU_CONN_APB(CLK_IPU_CONN_APB2AXI, 8062306a36Sopenharmony_ci "ipu_conn_apb2axi", "dsp1_sel", 3), 8162306a36Sopenharmony_ci GATE_IPU_CONN_APB(CLK_IPU_CONN_APB2AHB, 8262306a36Sopenharmony_ci "ipu_conn_apb2ahb", "dsp1_sel", 20), 8362306a36Sopenharmony_ci GATE_IPU_CONN_AXI_I(CLK_IPU_CONN_IPU_CAB1TO2, 8462306a36Sopenharmony_ci "ipu_conn_ipu_cab1to2", "dsp1_sel", 6), 8562306a36Sopenharmony_ci GATE_IPU_CONN_AXI_I(CLK_IPU_CONN_IPU1_CAB1TO2, 8662306a36Sopenharmony_ci "ipu_conn_ipu1_cab1to2", "dsp1_sel", 13), 8762306a36Sopenharmony_ci GATE_IPU_CONN_AXI_I(CLK_IPU_CONN_IPU2_CAB1TO2, 8862306a36Sopenharmony_ci "ipu_conn_ipu2_cab1to2", "dsp1_sel", 20), 8962306a36Sopenharmony_ci GATE_IPU_CONN_AXI1_I(CLK_IPU_CONN_CAB3TO3, 9062306a36Sopenharmony_ci "ipu_conn_cab3to3", "dsp1_sel", 0), 9162306a36Sopenharmony_ci GATE_IPU_CONN_AXI2_I(CLK_IPU_CONN_CAB2TO1, 9262306a36Sopenharmony_ci "ipu_conn_cab2to1", "dsp1_sel", 14), 9362306a36Sopenharmony_ci GATE_IPU_CONN_AXI2_I(CLK_IPU_CONN_CAB3TO1_SLICE, 9462306a36Sopenharmony_ci "ipu_conn_cab3to1_slice", "dsp1_sel", 17), 9562306a36Sopenharmony_ci}; 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_cistatic const struct mtk_clk_desc ipu_conn_desc = { 9862306a36Sopenharmony_ci .clks = ipu_conn_clks, 9962306a36Sopenharmony_ci .num_clks = ARRAY_SIZE(ipu_conn_clks), 10062306a36Sopenharmony_ci}; 10162306a36Sopenharmony_ci 10262306a36Sopenharmony_cistatic const struct of_device_id of_match_clk_mt8183_ipu_conn[] = { 10362306a36Sopenharmony_ci { 10462306a36Sopenharmony_ci .compatible = "mediatek,mt8183-ipu_conn", 10562306a36Sopenharmony_ci .data = &ipu_conn_desc, 10662306a36Sopenharmony_ci }, { 10762306a36Sopenharmony_ci /* sentinel */ 10862306a36Sopenharmony_ci } 10962306a36Sopenharmony_ci}; 11062306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_match_clk_mt8183_ipu_conn); 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_cistatic struct platform_driver clk_mt8183_ipu_conn_drv = { 11362306a36Sopenharmony_ci .probe = mtk_clk_simple_probe, 11462306a36Sopenharmony_ci .remove_new = mtk_clk_simple_remove, 11562306a36Sopenharmony_ci .driver = { 11662306a36Sopenharmony_ci .name = "clk-mt8183-ipu_conn", 11762306a36Sopenharmony_ci .of_match_table = of_match_clk_mt8183_ipu_conn, 11862306a36Sopenharmony_ci }, 11962306a36Sopenharmony_ci}; 12062306a36Sopenharmony_cimodule_platform_driver(clk_mt8183_ipu_conn_drv); 12162306a36Sopenharmony_ciMODULE_LICENSE("GPL"); 122