xref: /linux/drivers/clk/mediatek/clk-mt6797-mm.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
11802d0beSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
296596aa0SKevin-CW Chen /*
396596aa0SKevin-CW Chen  * Copyright (c) 2017 MediaTek Inc.
496596aa0SKevin-CW Chen  * Author: Kevin Chen <kevin-cw.chen@mediatek.com>
596596aa0SKevin-CW Chen  */
696596aa0SKevin-CW Chen 
796596aa0SKevin-CW Chen #include <linux/clk-provider.h>
896596aa0SKevin-CW Chen #include <linux/platform_device.h>
996596aa0SKevin-CW Chen #include <dt-bindings/clock/mt6797-clk.h>
1096596aa0SKevin-CW Chen 
1196596aa0SKevin-CW Chen #include "clk-mtk.h"
1296596aa0SKevin-CW Chen #include "clk-gate.h"
1396596aa0SKevin-CW Chen 
1496596aa0SKevin-CW Chen static const struct mtk_gate_regs mm0_cg_regs = {
1596596aa0SKevin-CW Chen 	.set_ofs = 0x0104,
1696596aa0SKevin-CW Chen 	.clr_ofs = 0x0108,
1796596aa0SKevin-CW Chen 	.sta_ofs = 0x0100,
1896596aa0SKevin-CW Chen };
1996596aa0SKevin-CW Chen 
2096596aa0SKevin-CW Chen static const struct mtk_gate_regs mm1_cg_regs = {
2196596aa0SKevin-CW Chen 	.set_ofs = 0x0114,
2296596aa0SKevin-CW Chen 	.clr_ofs = 0x0118,
2396596aa0SKevin-CW Chen 	.sta_ofs = 0x0110,
2496596aa0SKevin-CW Chen };
2596596aa0SKevin-CW Chen 
264c85e20bSAngeloGioacchino Del Regno #define GATE_MM0(_id, _name, _parent, _shift)	\
274c85e20bSAngeloGioacchino Del Regno 	GATE_MTK(_id, _name, _parent, &mm0_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
2896596aa0SKevin-CW Chen 
294c85e20bSAngeloGioacchino Del Regno #define GATE_MM1(_id, _name, _parent, _shift)	\
304c85e20bSAngeloGioacchino Del Regno 	GATE_MTK(_id, _name, _parent, &mm1_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
3196596aa0SKevin-CW Chen 
3296596aa0SKevin-CW Chen static const struct mtk_gate mm_clks[] = {
3396596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_SMI_COMMON, "mm_smi_common", "mm_sel", 0),
3496596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_SMI_LARB0, "mm_smi_larb0", "mm_sel", 1),
3596596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_SMI_LARB5, "mm_smi_larb5", "mm_sel", 2),
3696596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_CAM_MDP, "mm_cam_mdp", "mm_sel", 3),
3796596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_RDMA0, "mm_mdp_rdma0", "mm_sel", 4),
3896596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_RDMA1, "mm_mdp_rdma1", "mm_sel", 5),
3996596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_RSZ0, "mm_mdp_rsz0", "mm_sel", 6),
4096596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_RSZ1, "mm_mdp_rsz1", "mm_sel", 7),
4196596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_RSZ2, "mm_mdp_rsz2", "mm_sel", 8),
4296596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_TDSHP, "mm_mdp_tdshp", "mm_sel", 9),
4396596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_COLOR, "mm_mdp_color", "mm_sel", 10),
4496596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_WDMA, "mm_mdp_wdma", "mm_sel", 11),
4596596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_WROT0, "mm_mdp_wrot0", "mm_sel", 12),
4696596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_MDP_WROT1, "mm_mdp_wrot1", "mm_sel", 13),
4796596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_FAKE_ENG, "mm_fake_eng", "mm_sel", 14),
4896596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_OVL0, "mm_disp_ovl0", "mm_sel", 15),
4996596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_OVL1, "mm_disp_ovl1", "mm_sel", 16),
5096596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_OVL0_2L, "mm_disp_ovl0_2l", "mm_sel", 17),
5196596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_OVL1_2L, "mm_disp_ovl1_2l", "mm_sel", 18),
5296596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_RDMA0, "mm_disp_rdma0", "mm_sel", 19),
5396596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_RDMA1, "mm_disp_rdma1", "mm_sel", 20),
5496596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_WDMA0, "mm_disp_wdma0", "mm_sel", 21),
5596596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_WDMA1, "mm_disp_wdma1", "mm_sel", 22),
5696596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_COLOR, "mm_disp_color", "mm_sel", 23),
5796596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_CCORR, "mm_disp_ccorr", "mm_sel", 24),
5896596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_AAL, "mm_disp_aal", "mm_sel", 25),
5996596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_GAMMA, "mm_disp_gamma", "mm_sel", 26),
6096596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_OD, "mm_disp_od", "mm_sel", 27),
6196596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_DITHER, "mm_disp_dither", "mm_sel", 28),
6296596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_UFOE, "mm_disp_ufoe", "mm_sel", 29),
6396596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_DSC, "mm_disp_dsc", "mm_sel", 30),
6496596aa0SKevin-CW Chen 	GATE_MM0(CLK_MM_DISP_SPLIT, "mm_disp_split", "mm_sel", 31),
6596596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_DSI0_MM_CLOCK, "mm_dsi0_mm_clock", "mm_sel", 0),
6696596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_DSI1_MM_CLOCK, "mm_dsi1_mm_clock", "mm_sel", 2),
6796596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_DPI_MM_CLOCK, "mm_dpi_mm_clock", "mm_sel", 4),
6896596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_DPI_INTERFACE_CLOCK, "mm_dpi_interface_clock",
6996596aa0SKevin-CW Chen 		 "dpi0_sel", 5),
7096596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_LARB4_AXI_ASIF_MM_CLOCK, "mm_larb4_axi_asif_mm_clock",
7196596aa0SKevin-CW Chen 		 "mm_sel", 6),
7296596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_LARB4_AXI_ASIF_MJC_CLOCK, "mm_larb4_axi_asif_mjc_clock",
7396596aa0SKevin-CW Chen 		 "mjc_sel", 7),
7496596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_DISP_OVL0_MOUT_CLOCK, "mm_disp_ovl0_mout_clock",
7596596aa0SKevin-CW Chen 		 "mm_sel", 8),
7696596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_FAKE_ENG2, "mm_fake_eng2", "mm_sel", 9),
7796596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_DSI0_INTERFACE_CLOCK, "mm_dsi0_interface_clock",
7896596aa0SKevin-CW Chen 		 "clk26m", 1),
7996596aa0SKevin-CW Chen 	GATE_MM1(CLK_MM_DSI1_INTERFACE_CLOCK, "mm_dsi1_interface_clock",
8096596aa0SKevin-CW Chen 		 "clk26m", 3),
8196596aa0SKevin-CW Chen };
8296596aa0SKevin-CW 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 };
8796596aa0SKevin-CW Chen 
8865c10c50SAngeloGioacchino Del Regno static const struct platform_device_id clk_mt6797_mm_id_table[] = {
8965c10c50SAngeloGioacchino Del Regno 	{ .name = "clk-mt6797-mm", .driver_data = (kernel_ulong_t)&mm_desc },
9065c10c50SAngeloGioacchino Del Regno 	{ /* sentinel */ }
9165c10c50SAngeloGioacchino Del Regno };
9265c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(platform, clk_mt6797_mm_id_table);
9396596aa0SKevin-CW Chen 
9496596aa0SKevin-CW Chen static struct platform_driver clk_mt6797_mm_drv = {
9565c10c50SAngeloGioacchino Del Regno 	.probe = mtk_clk_pdev_probe,
96*f00b45dbSUwe Kleine-König 	.remove = mtk_clk_pdev_remove,
9796596aa0SKevin-CW Chen 	.driver = {
9896596aa0SKevin-CW Chen 		.name = "clk-mt6797-mm",
9996596aa0SKevin-CW Chen 	},
10065c10c50SAngeloGioacchino Del Regno 	.id_table = clk_mt6797_mm_id_table,
10196596aa0SKevin-CW Chen };
102164d240dSAngeloGioacchino Del Regno module_platform_driver(clk_mt6797_mm_drv);
103f5100c41SAngeloGioacchino Del Regno 
104f5100c41SAngeloGioacchino Del Regno MODULE_DESCRIPTION("MediaTek MT6797 MultiMedia clocks driver");
105a451da86SAngeloGioacchino Del Regno MODULE_LICENSE("GPL");
106