1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2019 MediaTek Inc.
4 * Author: Wendell Lin <wendell.lin@mediatek.com>
7 #include <linux/clk-provider.h>
8 #include <linux/platform_device.h>
9 #include <dt-bindings/clock/mt6779-clk.h>
14 static const struct mtk_gate_regs cam_cg_regs = {
20 #define GATE_CAM(_id, _name, _parent, _shift) \
21 GATE_MTK(_id, _name, _parent, &cam_cg_regs, _shift, \
22 &mtk_clk_gate_ops_setclr)
24 static const struct mtk_gate cam_clks[] = {
25 GATE_CAM(CLK_CAM_LARB10, "camsys_larb10", "cam_sel", 0),
26 GATE_CAM(CLK_CAM_DFP_VAD, "camsys_dfp_vad", "cam_sel", 1),
27 GATE_CAM(CLK_CAM_LARB11, "camsys_larb11", "cam_sel", 2),
28 GATE_CAM(CLK_CAM_LARB9, "camsys_larb9", "cam_sel", 3),
29 GATE_CAM(CLK_CAM_CAM, "camsys_cam", "cam_sel", 6),
30 GATE_CAM(CLK_CAM_CAMTG, "camsys_camtg", "cam_sel", 7),
31 GATE_CAM(CLK_CAM_SENINF, "camsys_seninf", "cam_sel", 8),
32 GATE_CAM(CLK_CAM_CAMSV0, "camsys_camsv0", "cam_sel", 9),
33 GATE_CAM(CLK_CAM_CAMSV1, "camsys_camsv1", "cam_sel", 10),
34 GATE_CAM(CLK_CAM_CAMSV2, "camsys_camsv2", "cam_sel", 11),
35 GATE_CAM(CLK_CAM_CAMSV3, "camsys_camsv3", "cam_sel", 12),
36 GATE_CAM(CLK_CAM_CCU, "camsys_ccu", "cam_sel", 13),
37 GATE_CAM(CLK_CAM_FAKE_ENG, "camsys_fake_eng", "cam_sel", 14),
40 static const struct of_device_id of_match_clk_mt6779_cam[] = {
41 { .compatible = "mediatek,mt6779-camsys", },
45 static int clk_mt6779_cam_probe(struct platform_device *pdev)
47 struct clk_onecell_data *clk_data;
48 struct device_node *node = pdev->dev.of_node;
50 clk_data = mtk_alloc_clk_data(CLK_CAM_NR_CLK);
52 mtk_clk_register_gates(node, cam_clks, ARRAY_SIZE(cam_clks),
55 return of_clk_add_provider(node, of_clk_src_onecell_get, clk_data);
58 static struct platform_driver clk_mt6779_cam_drv = {
59 .probe = clk_mt6779_cam_probe,
61 .name = "clk-mt6779-cam",
62 .of_match_table = of_match_clk_mt6779_cam,
66 builtin_platform_driver(clk_mt6779_cam_drv);