xref: /openbmc/linux/drivers/clk/mediatek/clk-mt8192-mm.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
19d44859bSChun-Jie Chen // SPDX-License-Identifier: GPL-2.0-only
29d44859bSChun-Jie Chen //
39d44859bSChun-Jie Chen // Copyright (c) 2021 MediaTek Inc.
49d44859bSChun-Jie Chen // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
59d44859bSChun-Jie Chen 
69d44859bSChun-Jie Chen #include <linux/clk-provider.h>
79d44859bSChun-Jie Chen #include <linux/platform_device.h>
89d44859bSChun-Jie Chen 
99d44859bSChun-Jie Chen #include "clk-mtk.h"
109d44859bSChun-Jie Chen #include "clk-gate.h"
119d44859bSChun-Jie Chen 
129d44859bSChun-Jie Chen #include <dt-bindings/clock/mt8192-clk.h>
139d44859bSChun-Jie Chen 
149d44859bSChun-Jie Chen static const struct mtk_gate_regs mm0_cg_regs = {
159d44859bSChun-Jie Chen 	.set_ofs = 0x104,
169d44859bSChun-Jie Chen 	.clr_ofs = 0x108,
179d44859bSChun-Jie Chen 	.sta_ofs = 0x100,
189d44859bSChun-Jie Chen };
199d44859bSChun-Jie Chen 
209d44859bSChun-Jie Chen static const struct mtk_gate_regs mm1_cg_regs = {
219d44859bSChun-Jie Chen 	.set_ofs = 0x114,
229d44859bSChun-Jie Chen 	.clr_ofs = 0x118,
239d44859bSChun-Jie Chen 	.sta_ofs = 0x110,
249d44859bSChun-Jie Chen };
259d44859bSChun-Jie Chen 
269d44859bSChun-Jie Chen static const struct mtk_gate_regs mm2_cg_regs = {
279d44859bSChun-Jie Chen 	.set_ofs = 0x1a4,
289d44859bSChun-Jie Chen 	.clr_ofs = 0x1a8,
299d44859bSChun-Jie Chen 	.sta_ofs = 0x1a0,
309d44859bSChun-Jie Chen };
319d44859bSChun-Jie Chen 
329d44859bSChun-Jie Chen #define GATE_MM0(_id, _name, _parent, _shift)	\
339d44859bSChun-Jie Chen 	GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
349d44859bSChun-Jie Chen 
359d44859bSChun-Jie Chen #define GATE_MM1(_id, _name, _parent, _shift)	\
369d44859bSChun-Jie Chen 	GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
379d44859bSChun-Jie Chen 
389d44859bSChun-Jie Chen #define GATE_MM2(_id, _name, _parent, _shift)	\
399d44859bSChun-Jie Chen 	GATE_MTK(_id, _name, _parent, &mm2_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
409d44859bSChun-Jie Chen 
419d44859bSChun-Jie Chen static const struct mtk_gate mm_clks[] = {
429d44859bSChun-Jie Chen 	/* MM0 */
439d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_MUTEX0, "mm_disp_mutex0", "disp_sel", 0),
449d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_CONFIG, "mm_disp_config", "disp_sel", 1),
459d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_OVL0, "mm_disp_ovl0", "disp_sel", 2),
469d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_RDMA0, "mm_disp_rdma0", "disp_sel", 3),
479d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_OVL0_2L, "mm_disp_ovl0_2l", "disp_sel", 4),
489d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_WDMA0, "mm_disp_wdma0", "disp_sel", 5),
499d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_UFBC_WDMA0, "mm_disp_ufbc_wdma0", "disp_sel", 6),
509d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_RSZ0, "mm_disp_rsz0", "disp_sel", 7),
519d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_AAL0, "mm_disp_aal0", "disp_sel", 8),
529d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_CCORR0, "mm_disp_ccorr0", "disp_sel", 9),
539d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_DITHER0, "mm_disp_dither0", "disp_sel", 10),
549d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_SMI_INFRA, "mm_smi_infra", "disp_sel", 11),
559d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_GAMMA0, "mm_disp_gamma0", "disp_sel", 12),
569d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_POSTMASK0, "mm_disp_postmask0", "disp_sel", 13),
579d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_DSC_WRAP0, "mm_disp_dsc_wrap0", "disp_sel", 14),
589d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DSI0, "mm_dsi0", "disp_sel", 15),
599d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_COLOR0, "mm_disp_color0", "disp_sel", 16),
609d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "disp_sel", 17),
619d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_FAKE_ENG0, "mm_disp_fake_eng0", "disp_sel", 18),
629d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_FAKE_ENG1, "mm_disp_fake_eng1", "disp_sel", 19),
639d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_MDP_TDSHP4, "mm_mdp_tdshp4", "disp_sel", 20),
649d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_MDP_RSZ4, "mm_mdp_rsz4", "disp_sel", 21),
659d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_MDP_AAL4, "mm_mdp_aal4", "disp_sel", 22),
669d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_MDP_HDR4, "mm_mdp_hdr4", "disp_sel", 23),
679d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_MDP_RDMA4, "mm_mdp_rdma4", "disp_sel", 24),
689d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_MDP_COLOR4, "mm_mdp_color4", "disp_sel", 25),
699d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_Y2R0, "mm_disp_y2r0", "disp_sel", 26),
709d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_SMI_GALS, "mm_smi_gals", "disp_sel", 27),
719d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_OVL2_2L, "mm_disp_ovl2_2l", "disp_sel", 28),
729d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_RDMA4, "mm_disp_rdma4", "disp_sel", 29),
739d44859bSChun-Jie Chen 	GATE_MM0(CLK_MM_DISP_DPI0, "mm_disp_dpi0", "disp_sel", 30),
749d44859bSChun-Jie Chen 	/* MM1 */
759d44859bSChun-Jie Chen 	GATE_MM1(CLK_MM_SMI_IOMMU, "mm_smi_iommu", "disp_sel", 0),
769d44859bSChun-Jie Chen 	/* MM2 */
779d44859bSChun-Jie Chen 	GATE_MM2(CLK_MM_DSI_DSI0, "mm_dsi_dsi0", "disp_sel", 0),
789d44859bSChun-Jie Chen 	GATE_MM2(CLK_MM_DPI_DPI0, "mm_dpi_dpi0", "dpi_sel", 8),
799d44859bSChun-Jie Chen 	GATE_MM2(CLK_MM_26MHZ, "mm_26mhz", "clk26m", 24),
809d44859bSChun-Jie Chen 	GATE_MM2(CLK_MM_32KHZ, "mm_32khz", "clk32k", 25),
819d44859bSChun-Jie Chen };
829d44859bSChun-Jie Chen 
8365c10c50SAngeloGioacchino Del Regno static const struct mtk_clk_desc mm_desc = {
8465c10c50SAngeloGioacchino Del Regno 	.clks = mm_clks,
8565c10c50SAngeloGioacchino Del Regno 	.num_clks = ARRAY_SIZE(mm_clks),
8665c10c50SAngeloGioacchino Del Regno };
879d44859bSChun-Jie Chen 
8865c10c50SAngeloGioacchino Del Regno static const struct platform_device_id clk_mt8192_mm_id_table[] = {
8965c10c50SAngeloGioacchino Del Regno 	{ .name = "clk-mt8192-mm", .driver_data = (kernel_ulong_t)&mm_desc },
9065c10c50SAngeloGioacchino Del Regno 	{ /* sentinel */ }
9165c10c50SAngeloGioacchino Del Regno };
92*65c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(platform, clk_mt8192_mm_id_table);
939d44859bSChun-Jie Chen 
949d44859bSChun-Jie Chen static struct platform_driver clk_mt8192_mm_drv = {
9565c10c50SAngeloGioacchino Del Regno 	.probe = mtk_clk_pdev_probe,
9665c10c50SAngeloGioacchino Del Regno 	.remove_new = mtk_clk_pdev_remove,
979d44859bSChun-Jie Chen 	.driver = {
989d44859bSChun-Jie Chen 		.name = "clk-mt8192-mm",
999d44859bSChun-Jie Chen 	},
10065c10c50SAngeloGioacchino Del Regno 	.id_table = clk_mt8192_mm_id_table,
1019d44859bSChun-Jie Chen };
102164d240dSAngeloGioacchino Del Regno module_platform_driver(clk_mt8192_mm_drv);
103a451da86SAngeloGioacchino Del Regno MODULE_LICENSE("GPL");
104