xref: /openbmc/linux/drivers/clk/mediatek/clk-mt6779-cam.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
1710774e0Smtk01761 // SPDX-License-Identifier: GPL-2.0
2710774e0Smtk01761 /*
3710774e0Smtk01761  * Copyright (c) 2019 MediaTek Inc.
4710774e0Smtk01761  * Author: Wendell Lin <wendell.lin@mediatek.com>
5710774e0Smtk01761  */
6710774e0Smtk01761 
7f09b9460SMiles Chen #include <linux/module.h>
8710774e0Smtk01761 #include <linux/clk-provider.h>
9710774e0Smtk01761 #include <linux/platform_device.h>
10710774e0Smtk01761 #include <dt-bindings/clock/mt6779-clk.h>
11710774e0Smtk01761 
12710774e0Smtk01761 #include "clk-mtk.h"
13710774e0Smtk01761 #include "clk-gate.h"
14710774e0Smtk01761 
15710774e0Smtk01761 static const struct mtk_gate_regs cam_cg_regs = {
16710774e0Smtk01761 	.set_ofs = 0x0004,
17710774e0Smtk01761 	.clr_ofs = 0x0008,
18710774e0Smtk01761 	.sta_ofs = 0x0000,
19710774e0Smtk01761 };
20710774e0Smtk01761 
21710774e0Smtk01761 #define GATE_CAM(_id, _name, _parent, _shift)			\
22710774e0Smtk01761 	GATE_MTK(_id, _name, _parent, &cam_cg_regs, _shift,	\
23710774e0Smtk01761 		&mtk_clk_gate_ops_setclr)
24710774e0Smtk01761 
25710774e0Smtk01761 static const struct mtk_gate cam_clks[] = {
26710774e0Smtk01761 	GATE_CAM(CLK_CAM_LARB10, "camsys_larb10", "cam_sel", 0),
27710774e0Smtk01761 	GATE_CAM(CLK_CAM_DFP_VAD, "camsys_dfp_vad", "cam_sel", 1),
28710774e0Smtk01761 	GATE_CAM(CLK_CAM_LARB11, "camsys_larb11", "cam_sel", 2),
29710774e0Smtk01761 	GATE_CAM(CLK_CAM_LARB9, "camsys_larb9", "cam_sel", 3),
30710774e0Smtk01761 	GATE_CAM(CLK_CAM_CAM, "camsys_cam", "cam_sel", 6),
31710774e0Smtk01761 	GATE_CAM(CLK_CAM_CAMTG, "camsys_camtg", "cam_sel", 7),
32710774e0Smtk01761 	GATE_CAM(CLK_CAM_SENINF, "camsys_seninf", "cam_sel", 8),
33710774e0Smtk01761 	GATE_CAM(CLK_CAM_CAMSV0, "camsys_camsv0", "cam_sel", 9),
34710774e0Smtk01761 	GATE_CAM(CLK_CAM_CAMSV1, "camsys_camsv1", "cam_sel", 10),
35710774e0Smtk01761 	GATE_CAM(CLK_CAM_CAMSV2, "camsys_camsv2", "cam_sel", 11),
36710774e0Smtk01761 	GATE_CAM(CLK_CAM_CAMSV3, "camsys_camsv3", "cam_sel", 12),
37710774e0Smtk01761 	GATE_CAM(CLK_CAM_CCU, "camsys_ccu", "cam_sel", 13),
38710774e0Smtk01761 	GATE_CAM(CLK_CAM_FAKE_ENG, "camsys_fake_eng", "cam_sel", 14),
39710774e0Smtk01761 };
40710774e0Smtk01761 
41dc6fdd8aSMiles Chen static const struct mtk_clk_desc cam_desc = {
42dc6fdd8aSMiles Chen 	.clks = cam_clks,
43dc6fdd8aSMiles Chen 	.num_clks = ARRAY_SIZE(cam_clks),
44710774e0Smtk01761 };
45710774e0Smtk01761 
46dc6fdd8aSMiles Chen static const struct of_device_id of_match_clk_mt6779_cam[] = {
47710774e0Smtk01761 	{
48dc6fdd8aSMiles Chen 		.compatible = "mediatek,mt6779-camsys",
49dc6fdd8aSMiles Chen 		.data = &cam_desc,
50dc6fdd8aSMiles Chen 	}, {
51dc6fdd8aSMiles Chen 		/* sentinel */
52710774e0Smtk01761 	}
53dc6fdd8aSMiles Chen };
54*65c9ad77SAngeloGioacchino Del Regno MODULE_DEVICE_TABLE(of, of_match_clk_mt6779_cam);
55710774e0Smtk01761 
56710774e0Smtk01761 static struct platform_driver clk_mt6779_cam_drv = {
57dc6fdd8aSMiles Chen 	.probe = mtk_clk_simple_probe,
58dc6fdd8aSMiles Chen 	.remove_new = mtk_clk_simple_remove,
59710774e0Smtk01761 	.driver = {
60710774e0Smtk01761 		.name = "clk-mt6779-cam",
61710774e0Smtk01761 		.of_match_table = of_match_clk_mt6779_cam,
62710774e0Smtk01761 	},
63710774e0Smtk01761 };
64710774e0Smtk01761 
65f09b9460SMiles Chen module_platform_driver(clk_mt6779_cam_drv);
66f09b9460SMiles Chen MODULE_LICENSE("GPL");
67