170282c90SChun-Jie Chen // SPDX-License-Identifier: GPL-2.0-only 270282c90SChun-Jie Chen // 370282c90SChun-Jie Chen // Copyright (c) 2021 MediaTek Inc. 470282c90SChun-Jie Chen // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com> 570282c90SChun-Jie Chen 670282c90SChun-Jie Chen #include "clk-gate.h" 770282c90SChun-Jie Chen #include "clk-mtk.h" 870282c90SChun-Jie Chen 970282c90SChun-Jie Chen #include <dt-bindings/clock/mt8195-clk.h> 1070282c90SChun-Jie Chen #include <linux/clk-provider.h> 1170282c90SChun-Jie Chen #include <linux/platform_device.h> 1270282c90SChun-Jie Chen 1370282c90SChun-Jie Chen static const struct mtk_gate_regs vdo0_0_cg_regs = { 1470282c90SChun-Jie Chen .set_ofs = 0x104, 1570282c90SChun-Jie Chen .clr_ofs = 0x108, 1670282c90SChun-Jie Chen .sta_ofs = 0x100, 1770282c90SChun-Jie Chen }; 1870282c90SChun-Jie Chen 1970282c90SChun-Jie Chen static const struct mtk_gate_regs vdo0_1_cg_regs = { 2070282c90SChun-Jie Chen .set_ofs = 0x114, 2170282c90SChun-Jie Chen .clr_ofs = 0x118, 2270282c90SChun-Jie Chen .sta_ofs = 0x110, 2370282c90SChun-Jie Chen }; 2470282c90SChun-Jie Chen 2570282c90SChun-Jie Chen static const struct mtk_gate_regs vdo0_2_cg_regs = { 2670282c90SChun-Jie Chen .set_ofs = 0x124, 2770282c90SChun-Jie Chen .clr_ofs = 0x128, 2870282c90SChun-Jie Chen .sta_ofs = 0x120, 2970282c90SChun-Jie Chen }; 3070282c90SChun-Jie Chen 3170282c90SChun-Jie Chen #define GATE_VDO0_0(_id, _name, _parent, _shift) \ 3270282c90SChun-Jie Chen GATE_MTK(_id, _name, _parent, &vdo0_0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 3370282c90SChun-Jie Chen 3470282c90SChun-Jie Chen #define GATE_VDO0_1(_id, _name, _parent, _shift) \ 3570282c90SChun-Jie Chen GATE_MTK(_id, _name, _parent, &vdo0_1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 3670282c90SChun-Jie Chen 3770282c90SChun-Jie Chen #define GATE_VDO0_2(_id, _name, _parent, _shift) \ 3870282c90SChun-Jie Chen GATE_MTK(_id, _name, _parent, &vdo0_2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 3970282c90SChun-Jie Chen 403f0dadd2SAngeloGioacchino Del Regno #define GATE_VDO0_2_FLAGS(_id, _name, _parent, _shift, _flags) \ 413f0dadd2SAngeloGioacchino Del Regno GATE_MTK_FLAGS(_id, _name, _parent, &vdo0_2_cg_regs, _shift, \ 423f0dadd2SAngeloGioacchino Del Regno &mtk_clk_gate_ops_setclr, _flags) 433f0dadd2SAngeloGioacchino Del Regno 4470282c90SChun-Jie Chen static const struct mtk_gate vdo0_clks[] = { 4570282c90SChun-Jie Chen /* VDO0_0 */ 4670282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_OVL0, "vdo0_disp_ovl0", "top_vpp", 0), 4770282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_COLOR0, "vdo0_disp_color0", "top_vpp", 2), 4870282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_COLOR1, "vdo0_disp_color1", "top_vpp", 3), 4970282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_CCORR0, "vdo0_disp_ccorr0", "top_vpp", 4), 5070282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_CCORR1, "vdo0_disp_ccorr1", "top_vpp", 5), 5170282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_AAL0, "vdo0_disp_aal0", "top_vpp", 6), 5270282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_AAL1, "vdo0_disp_aal1", "top_vpp", 7), 5370282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_GAMMA0, "vdo0_disp_gamma0", "top_vpp", 8), 5470282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_GAMMA1, "vdo0_disp_gamma1", "top_vpp", 9), 5570282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_DITHER0, "vdo0_disp_dither0", "top_vpp", 10), 5670282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_DITHER1, "vdo0_disp_dither1", "top_vpp", 11), 5770282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_OVL1, "vdo0_disp_ovl1", "top_vpp", 16), 5870282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_WDMA0, "vdo0_disp_wdma0", "top_vpp", 17), 5970282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_WDMA1, "vdo0_disp_wdma1", "top_vpp", 18), 6070282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_RDMA0, "vdo0_disp_rdma0", "top_vpp", 19), 6170282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_RDMA1, "vdo0_disp_rdma1", "top_vpp", 20), 6270282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DSI0, "vdo0_dsi0", "top_vpp", 21), 6370282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DSI1, "vdo0_dsi1", "top_vpp", 22), 6470282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DSC_WRAP0, "vdo0_dsc_wrap0", "top_vpp", 23), 6570282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_VPP_MERGE0, "vdo0_vpp_merge0", "top_vpp", 24), 6670282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DP_INTF0, "vdo0_dp_intf0", "top_vpp", 25), 6770282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_MUTEX0, "vdo0_disp_mutex0", "top_vpp", 26), 6870282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_DISP_IL_ROT0, "vdo0_disp_il_rot0", "top_vpp", 27), 6970282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_APB_BUS, "vdo0_apb_bus", "top_vpp", 28), 7070282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_FAKE_ENG0, "vdo0_fake_eng0", "top_vpp", 29), 7170282c90SChun-Jie Chen GATE_VDO0_0(CLK_VDO0_FAKE_ENG1, "vdo0_fake_eng1", "top_vpp", 30), 7270282c90SChun-Jie Chen /* VDO0_1 */ 7370282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DL_ASYNC0, "vdo0_dl_async0", "top_vpp", 0), 7470282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DL_ASYNC1, "vdo0_dl_async1", "top_vpp", 1), 7570282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DL_ASYNC2, "vdo0_dl_async2", "top_vpp", 2), 7670282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DL_ASYNC3, "vdo0_dl_async3", "top_vpp", 3), 7770282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DL_ASYNC4, "vdo0_dl_async4", "top_vpp", 4), 7870282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DISP_MONITOR0, "vdo0_disp_monitor0", "top_vpp", 5), 7970282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DISP_MONITOR1, "vdo0_disp_monitor1", "top_vpp", 6), 8070282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DISP_MONITOR2, "vdo0_disp_monitor2", "top_vpp", 7), 8170282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DISP_MONITOR3, "vdo0_disp_monitor3", "top_vpp", 8), 8270282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_DISP_MONITOR4, "vdo0_disp_monitor4", "top_vpp", 9), 8370282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_SMI_GALS, "vdo0_smi_gals", "top_vpp", 10), 8470282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_SMI_COMMON, "vdo0_smi_common", "top_vpp", 11), 8570282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_SMI_EMI, "vdo0_smi_emi", "top_vpp", 12), 8670282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_SMI_IOMMU, "vdo0_smi_iommu", "top_vpp", 13), 8770282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_SMI_LARB, "vdo0_smi_larb", "top_vpp", 14), 8870282c90SChun-Jie Chen GATE_VDO0_1(CLK_VDO0_SMI_RSI, "vdo0_smi_rsi", "top_vpp", 15), 8970282c90SChun-Jie Chen /* VDO0_2 */ 9070282c90SChun-Jie Chen GATE_VDO0_2(CLK_VDO0_DSI0_DSI, "vdo0_dsi0_dsi", "top_dsi_occ", 0), 9170282c90SChun-Jie Chen GATE_VDO0_2(CLK_VDO0_DSI1_DSI, "vdo0_dsi1_dsi", "top_dsi_occ", 8), 923f0dadd2SAngeloGioacchino Del Regno GATE_VDO0_2_FLAGS(CLK_VDO0_DP_INTF0_DP_INTF, "vdo0_dp_intf0_dp_intf", 933f0dadd2SAngeloGioacchino Del Regno "top_edp", 16, CLK_SET_RATE_PARENT), 9470282c90SChun-Jie Chen }; 9570282c90SChun-Jie Chen 9665c10c50SAngeloGioacchino Del Regno static const struct mtk_clk_desc vdo0_desc = { 9765c10c50SAngeloGioacchino Del Regno .clks = vdo0_clks, 9865c10c50SAngeloGioacchino Del Regno .num_clks = ARRAY_SIZE(vdo0_clks), 9965c10c50SAngeloGioacchino Del Regno }; 10070282c90SChun-Jie Chen 10165c10c50SAngeloGioacchino Del Regno static const struct platform_device_id clk_mt8195_vdo0_id_table[] = { 10265c10c50SAngeloGioacchino Del Regno { .name = "clk-mt8195-vdo0", .driver_data = (kernel_ulong_t)&vdo0_desc }, 10365c10c50SAngeloGioacchino Del Regno { /* sentinel */ } 10465c10c50SAngeloGioacchino Del Regno }; 105*164d240dSAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(platform, clk_mt8195_vdo0_id_table); 106cf8a482aSChen-Yu Tsai 10770282c90SChun-Jie Chen static struct platform_driver clk_mt8195_vdo0_drv = { 10865c10c50SAngeloGioacchino Del Regno .probe = mtk_clk_pdev_probe, 10965c10c50SAngeloGioacchino Del Regno .remove = mtk_clk_pdev_remove, 11070282c90SChun-Jie Chen .driver = { 11170282c90SChun-Jie Chen .name = "clk-mt8195-vdo0", 11270282c90SChun-Jie Chen }, 11365c10c50SAngeloGioacchino Del Regno .id_table = clk_mt8195_vdo0_id_table, 11470282c90SChun-Jie Chen }; 115*164d240dSAngeloGioacchino Del Regno module_platform_driver(clk_mt8195_vdo0_drv); 116