11802d0beSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only 2e2f744a8Sweiyi.lu@mediatek.com /* 3e2f744a8Sweiyi.lu@mediatek.com * Copyright (c) 2017 MediaTek Inc. 4e2f744a8Sweiyi.lu@mediatek.com * Author: Weiyi Lu <weiyi.lu@mediatek.com> 5e2f744a8Sweiyi.lu@mediatek.com */ 6e2f744a8Sweiyi.lu@mediatek.com 7e2f744a8Sweiyi.lu@mediatek.com #include <linux/clk-provider.h> 8e2f744a8Sweiyi.lu@mediatek.com #include <linux/platform_device.h> 9e2f744a8Sweiyi.lu@mediatek.com 10e2f744a8Sweiyi.lu@mediatek.com #include "clk-mtk.h" 11e2f744a8Sweiyi.lu@mediatek.com #include "clk-gate.h" 12e2f744a8Sweiyi.lu@mediatek.com 13e2f744a8Sweiyi.lu@mediatek.com #include <dt-bindings/clock/mt2712-clk.h> 14e2f744a8Sweiyi.lu@mediatek.com 15e2f744a8Sweiyi.lu@mediatek.com static const struct mtk_gate_regs mm0_cg_regs = { 16e2f744a8Sweiyi.lu@mediatek.com .set_ofs = 0x104, 17e2f744a8Sweiyi.lu@mediatek.com .clr_ofs = 0x108, 18e2f744a8Sweiyi.lu@mediatek.com .sta_ofs = 0x100, 19e2f744a8Sweiyi.lu@mediatek.com }; 20e2f744a8Sweiyi.lu@mediatek.com 21e2f744a8Sweiyi.lu@mediatek.com static const struct mtk_gate_regs mm1_cg_regs = { 22e2f744a8Sweiyi.lu@mediatek.com .set_ofs = 0x114, 23e2f744a8Sweiyi.lu@mediatek.com .clr_ofs = 0x118, 24e2f744a8Sweiyi.lu@mediatek.com .sta_ofs = 0x110, 25e2f744a8Sweiyi.lu@mediatek.com }; 26e2f744a8Sweiyi.lu@mediatek.com 27e2f744a8Sweiyi.lu@mediatek.com static const struct mtk_gate_regs mm2_cg_regs = { 28e2f744a8Sweiyi.lu@mediatek.com .set_ofs = 0x224, 29e2f744a8Sweiyi.lu@mediatek.com .clr_ofs = 0x228, 30e2f744a8Sweiyi.lu@mediatek.com .sta_ofs = 0x220, 31e2f744a8Sweiyi.lu@mediatek.com }; 32e2f744a8Sweiyi.lu@mediatek.com 334c85e20bSAngeloGioacchino Del Regno #define GATE_MM0(_id, _name, _parent, _shift) \ 344c85e20bSAngeloGioacchino Del Regno GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 35e2f744a8Sweiyi.lu@mediatek.com 364c85e20bSAngeloGioacchino Del Regno #define GATE_MM1(_id, _name, _parent, _shift) \ 374c85e20bSAngeloGioacchino Del Regno GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 38e2f744a8Sweiyi.lu@mediatek.com 394c85e20bSAngeloGioacchino Del Regno #define GATE_MM2(_id, _name, _parent, _shift) \ 404c85e20bSAngeloGioacchino Del Regno GATE_MTK(_id, _name, _parent, &mm2_cg_regs, _shift, &mtk_clk_gate_ops_setclr) 41e2f744a8Sweiyi.lu@mediatek.com 42e2f744a8Sweiyi.lu@mediatek.com static const struct mtk_gate mm_clks[] = { 43e2f744a8Sweiyi.lu@mediatek.com /* MM0 */ 44e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0), 45e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_SMI_LARB0, "mm_smi_larb0", "mm_sel", 1), 46e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_CAM_MDP, "mm_cam_mdp", "mm_sel", 2), 47e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_RDMA0, "mm_mdp_rdma0", "mm_sel", 3), 48e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_RDMA1, "mm_mdp_rdma1", "mm_sel", 4), 49e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_RSZ0, "mm_mdp_rsz0", "mm_sel", 5), 50e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_RSZ1, "mm_mdp_rsz1", "mm_sel", 6), 51e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_RSZ2, "mm_mdp_rsz2", "mm_sel", 7), 52e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_TDSHP0, "mm_mdp_tdshp0", "mm_sel", 8), 53e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_TDSHP1, "mm_mdp_tdshp1", "mm_sel", 9), 54e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_CROP, "mm_mdp_crop", "mm_sel", 10), 55e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_WDMA, "mm_mdp_wdma", "mm_sel", 11), 56e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_WROT0, "mm_mdp_wrot0", "mm_sel", 12), 57e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MDP_WROT1, "mm_mdp_wrot1", "mm_sel", 13), 58e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_FAKE_ENG, "mm_fake_eng", "mm_sel", 14), 59e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_MUTEX_32K, "mm_mutex_32k", "clk32k", 15), 60e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_OVL0, "mm_disp_ovl0", "mm_sel", 16), 61e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_OVL1, "mm_disp_ovl1", "mm_sel", 17), 62e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_RDMA0, "mm_disp_rdma0", "mm_sel", 18), 63e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_RDMA1, "mm_disp_rdma1", "mm_sel", 19), 64e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_RDMA2, "mm_disp_rdma2", "mm_sel", 20), 65e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_WDMA0, "mm_disp_wdma0", "mm_sel", 21), 66e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_WDMA1, "mm_disp_wdma1", "mm_sel", 22), 67e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_COLOR0, "mm_disp_color0", "mm_sel", 23), 68e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_COLOR1, "mm_disp_color1", "mm_sel", 24), 69e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_AAL, "mm_disp_aal", "mm_sel", 25), 70e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_GAMMA, "mm_disp_gamma", "mm_sel", 26), 71e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_UFOE, "mm_disp_ufoe", "mm_sel", 27), 72e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_SPLIT0, "mm_disp_split0", "mm_sel", 28), 73e2f744a8Sweiyi.lu@mediatek.com GATE_MM0(CLK_MM_DISP_OD, "mm_disp_od", "mm_sel", 31), 74e2f744a8Sweiyi.lu@mediatek.com /* MM1 */ 75e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DISP_PWM0_MM, "mm_pwm0_mm", "mm_sel", 0), 76e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DISP_PWM0_26M, "mm_pwm0_26m", "pwm_sel", 1), 77e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DISP_PWM1_MM, "mm_pwm1_mm", "mm_sel", 2), 78e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DISP_PWM1_26M, "mm_pwm1_26m", "pwm_sel", 3), 79e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DSI0_ENGINE, "mm_dsi0_engine", "mm_sel", 4), 80e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DSI0_DIGITAL, "mm_dsi0_digital", "dsi0_lntc", 5), 81e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DSI1_ENGINE, "mm_dsi1_engine", "mm_sel", 6), 82e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DSI1_DIGITAL, "mm_dsi1_digital", "dsi1_lntc", 7), 83e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DPI_PIXEL, "mm_dpi_pixel", "vpll_dpix", 8), 84e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DPI_ENGINE, "mm_dpi_engine", "mm_sel", 9), 85e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DPI1_PIXEL, "mm_dpi1_pixel", "vpll3_dpix", 10), 86e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DPI1_ENGINE, "mm_dpi1_engine", "mm_sel", 11), 87e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_LVDS_PIXEL, "mm_lvds_pixel", "vpll_dpix", 16), 88e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_LVDS_CTS, "mm_lvds_cts", "lvdstx", 17), 89e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_SMI_LARB4, "mm_smi_larb4", "mm_sel", 18), 90e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_SMI_COMMON1, "mm_smi_common1", "mm_sel", 21), 91e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_SMI_LARB5, "mm_smi_larb5", "mm_sel", 22), 92e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_MDP_RDMA2, "mm_mdp_rdma2", "mm_sel", 23), 93e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_MDP_TDSHP2, "mm_mdp_tdshp2", "mm_sel", 24), 94e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DISP_OVL2, "mm_disp_ovl2", "mm_sel", 25), 95e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DISP_WDMA2, "mm_disp_wdma2", "mm_sel", 26), 96e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DISP_COLOR2, "mm_disp_color2", "mm_sel", 27), 97e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DISP_AAL1, "mm_disp_aal1", "mm_sel", 28), 98e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_DISP_OD1, "mm_disp_od1", "mm_sel", 29), 99e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_LVDS1_PIXEL, "mm_lvds1_pixel", "vpll3_dpix", 30), 100e2f744a8Sweiyi.lu@mediatek.com GATE_MM1(CLK_MM_LVDS1_CTS, "mm_lvds1_cts", "lvdstx3", 31), 101e2f744a8Sweiyi.lu@mediatek.com /* MM2 */ 102e2f744a8Sweiyi.lu@mediatek.com GATE_MM2(CLK_MM_SMI_LARB7, "mm_smi_larb7", "mm_sel", 0), 103e2f744a8Sweiyi.lu@mediatek.com GATE_MM2(CLK_MM_MDP_RDMA3, "mm_mdp_rdma3", "mm_sel", 1), 104e2f744a8Sweiyi.lu@mediatek.com GATE_MM2(CLK_MM_MDP_WROT2, "mm_mdp_wrot2", "mm_sel", 2), 105e2f744a8Sweiyi.lu@mediatek.com GATE_MM2(CLK_MM_DSI2, "mm_dsi2", "mm_sel", 3), 106e2f744a8Sweiyi.lu@mediatek.com GATE_MM2(CLK_MM_DSI2_DIGITAL, "mm_dsi2_digital", "dsi0_lntc", 4), 107e2f744a8Sweiyi.lu@mediatek.com GATE_MM2(CLK_MM_DSI3, "mm_dsi3", "mm_sel", 5), 108e2f744a8Sweiyi.lu@mediatek.com GATE_MM2(CLK_MM_DSI3_DIGITAL, "mm_dsi3_digital", "dsi1_lntc", 6), 109e2f744a8Sweiyi.lu@mediatek.com }; 110e2f744a8Sweiyi.lu@mediatek.com 11165c10c50SAngeloGioacchino Del Regno static const struct mtk_clk_desc mm_desc = { 11265c10c50SAngeloGioacchino Del Regno .clks = mm_clks, 11365c10c50SAngeloGioacchino Del Regno .num_clks = ARRAY_SIZE(mm_clks), 11465c10c50SAngeloGioacchino Del Regno }; 115e2f744a8Sweiyi.lu@mediatek.com 11665c10c50SAngeloGioacchino Del Regno static const struct platform_device_id clk_mt2712_mm_id_table[] = { 11765c10c50SAngeloGioacchino Del Regno { .name = "clk-mt2712-mm", .driver_data = (kernel_ulong_t)&mm_desc }, 11865c10c50SAngeloGioacchino Del Regno { /* sentinel */ } 11965c10c50SAngeloGioacchino Del Regno }; 120*65c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(platform, clk_mt2712_mm_id_table); 121e2f744a8Sweiyi.lu@mediatek.com 122e2f744a8Sweiyi.lu@mediatek.com static struct platform_driver clk_mt2712_mm_drv = { 12365c10c50SAngeloGioacchino Del Regno .probe = mtk_clk_pdev_probe, 12465c10c50SAngeloGioacchino Del Regno .remove_new = mtk_clk_pdev_remove, 125e2f744a8Sweiyi.lu@mediatek.com .driver = { 126e2f744a8Sweiyi.lu@mediatek.com .name = "clk-mt2712-mm", 127e2f744a8Sweiyi.lu@mediatek.com }, 12865c10c50SAngeloGioacchino Del Regno .id_table = clk_mt2712_mm_id_table, 129e2f744a8Sweiyi.lu@mediatek.com }; 130164d240dSAngeloGioacchino Del Regno module_platform_driver(clk_mt2712_mm_drv); 131a451da86SAngeloGioacchino Del Regno MODULE_LICENSE("GPL"); 132