xref: /linux/drivers/clk/mediatek/clk-mt8186-cam.c (revision 3a39d672e7f48b8d6b91a09afa4b55352773b4b5)
16f2e1208SChun-Jie Chen // SPDX-License-Identifier: GPL-2.0-only
26f2e1208SChun-Jie Chen //
36f2e1208SChun-Jie Chen // Copyright (c) 2022 MediaTek Inc.
46f2e1208SChun-Jie Chen // Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
56f2e1208SChun-Jie Chen 
66f2e1208SChun-Jie Chen #include <linux/clk-provider.h>
76f2e1208SChun-Jie Chen #include <linux/platform_device.h>
86f2e1208SChun-Jie Chen #include <dt-bindings/clock/mt8186-clk.h>
96f2e1208SChun-Jie Chen 
106f2e1208SChun-Jie Chen #include "clk-gate.h"
116f2e1208SChun-Jie Chen #include "clk-mtk.h"
126f2e1208SChun-Jie Chen 
136f2e1208SChun-Jie Chen static const struct mtk_gate_regs cam_cg_regs = {
146f2e1208SChun-Jie Chen 	.set_ofs = 0x4,
156f2e1208SChun-Jie Chen 	.clr_ofs = 0x8,
166f2e1208SChun-Jie Chen 	.sta_ofs = 0x0,
176f2e1208SChun-Jie Chen };
186f2e1208SChun-Jie Chen 
196f2e1208SChun-Jie Chen #define GATE_CAM(_id, _name, _parent, _shift)			\
206f2e1208SChun-Jie Chen 	GATE_MTK(_id, _name, _parent, &cam_cg_regs, _shift, &mtk_clk_gate_ops_setclr)
216f2e1208SChun-Jie Chen 
226f2e1208SChun-Jie Chen static const struct mtk_gate cam_clks[] = {
236f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_LARB13, "cam_larb13", "top_cam", 0),
246f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_DFP_VAD, "cam_dfp_vad", "top_cam", 1),
256f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_LARB14, "cam_larb14", "top_cam", 2),
266f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM, "cam", "top_cam", 6),
276f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAMTG, "camtg", "top_cam", 7),
286f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_SENINF, "cam_seninf", "top_cam", 8),
296f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAMSV1, "camsv1", "top_cam", 10),
306f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAMSV2, "camsv2", "top_cam", 11),
316f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAMSV3, "camsv3", "top_cam", 12),
326f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_CCU0, "cam_ccu0", "top_cam", 13),
336f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_CCU1, "cam_ccu1", "top_cam", 14),
346f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_MRAW0, "cam_mraw0", "top_cam", 15),
356f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_FAKE_ENG, "cam_fake_eng", "top_cam", 17),
366f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_CCU_GALS, "cam_ccu_gals", "top_cam", 18),
376f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM2MM_GALS, "cam2mm_gals", "top_cam", 19),
386f2e1208SChun-Jie Chen };
396f2e1208SChun-Jie Chen 
406f2e1208SChun-Jie Chen static const struct mtk_gate cam_rawa_clks[] = {
416f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_RAWA_LARBX_RAWA, "cam_rawa_larbx_rawa", "top_cam", 0),
426f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_RAWA, "cam_rawa", "top_cam", 1),
436f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_RAWA_CAMTG_RAWA, "cam_rawa_camtg_rawa", "top_cam", 2),
446f2e1208SChun-Jie Chen };
456f2e1208SChun-Jie Chen 
466f2e1208SChun-Jie Chen static const struct mtk_gate cam_rawb_clks[] = {
476f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_RAWB_LARBX_RAWB, "cam_rawb_larbx_rawb", "top_cam", 0),
486f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_RAWB, "cam_rawb", "top_cam", 1),
496f2e1208SChun-Jie Chen 	GATE_CAM(CLK_CAM_RAWB_CAMTG_RAWB, "cam_rawb_camtg_rawb", "top_cam", 2),
506f2e1208SChun-Jie Chen };
516f2e1208SChun-Jie Chen 
526f2e1208SChun-Jie Chen static const struct mtk_clk_desc cam_desc = {
536f2e1208SChun-Jie Chen 	.clks = cam_clks,
546f2e1208SChun-Jie Chen 	.num_clks = ARRAY_SIZE(cam_clks),
556f2e1208SChun-Jie Chen };
566f2e1208SChun-Jie Chen 
576f2e1208SChun-Jie Chen static const struct mtk_clk_desc cam_rawa_desc = {
586f2e1208SChun-Jie Chen 	.clks = cam_rawa_clks,
596f2e1208SChun-Jie Chen 	.num_clks = ARRAY_SIZE(cam_rawa_clks),
606f2e1208SChun-Jie Chen };
616f2e1208SChun-Jie Chen 
626f2e1208SChun-Jie Chen static const struct mtk_clk_desc cam_rawb_desc = {
636f2e1208SChun-Jie Chen 	.clks = cam_rawb_clks,
646f2e1208SChun-Jie Chen 	.num_clks = ARRAY_SIZE(cam_rawb_clks),
656f2e1208SChun-Jie Chen };
666f2e1208SChun-Jie Chen 
676f2e1208SChun-Jie Chen static const struct of_device_id of_match_clk_mt8186_cam[] = {
686f2e1208SChun-Jie Chen 	{
696f2e1208SChun-Jie Chen 		.compatible = "mediatek,mt8186-camsys",
706f2e1208SChun-Jie Chen 		.data = &cam_desc,
716f2e1208SChun-Jie Chen 	}, {
726f2e1208SChun-Jie Chen 		.compatible = "mediatek,mt8186-camsys_rawa",
736f2e1208SChun-Jie Chen 		.data = &cam_rawa_desc,
746f2e1208SChun-Jie Chen 	}, {
756f2e1208SChun-Jie Chen 		.compatible = "mediatek,mt8186-camsys_rawb",
766f2e1208SChun-Jie Chen 		.data = &cam_rawb_desc,
776f2e1208SChun-Jie Chen 	}, {
786f2e1208SChun-Jie Chen 		/* sentinel */
796f2e1208SChun-Jie Chen 	}
806f2e1208SChun-Jie Chen };
8165c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(of, of_match_clk_mt8186_cam);
826f2e1208SChun-Jie Chen 
836f2e1208SChun-Jie Chen static struct platform_driver clk_mt8186_cam_drv = {
846f2e1208SChun-Jie Chen 	.probe = mtk_clk_simple_probe,
85*f00b45dbSUwe Kleine-König 	.remove = mtk_clk_simple_remove,
866f2e1208SChun-Jie Chen 	.driver = {
876f2e1208SChun-Jie Chen 		.name = "clk-mt8186-cam",
886f2e1208SChun-Jie Chen 		.of_match_table = of_match_clk_mt8186_cam,
896f2e1208SChun-Jie Chen 	},
906f2e1208SChun-Jie Chen };
91164d240dSAngeloGioacchino Del Regno module_platform_driver(clk_mt8186_cam_drv);
92f5100c41SAngeloGioacchino Del Regno 
93f5100c41SAngeloGioacchino Del Regno MODULE_DESCRIPTION("MediaTek MT8186 Camera clocks driver");
94a451da86SAngeloGioacchino Del Regno MODULE_LICENSE("GPL");
95