0001
0002
0003
0004
0005
0006 #include <linux/clk-provider.h>
0007 #include <linux/platform_device.h>
0008
0009 #include "clk-mtk.h"
0010 #include "clk-gate.h"
0011
0012 #include <dt-bindings/clock/mt8183-clk.h>
0013
0014 static const struct mtk_gate_regs img_cg_regs = {
0015 .set_ofs = 0x4,
0016 .clr_ofs = 0x8,
0017 .sta_ofs = 0x0,
0018 };
0019
0020 #define GATE_IMG(_id, _name, _parent, _shift) \
0021 GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift, \
0022 &mtk_clk_gate_ops_setclr)
0023
0024 static const struct mtk_gate img_clks[] = {
0025 GATE_IMG(CLK_IMG_LARB5, "img_larb5", "img_sel", 0),
0026 GATE_IMG(CLK_IMG_LARB2, "img_larb2", "img_sel", 1),
0027 GATE_IMG(CLK_IMG_DIP, "img_dip", "img_sel", 2),
0028 GATE_IMG(CLK_IMG_FDVT, "img_fdvt", "img_sel", 3),
0029 GATE_IMG(CLK_IMG_DPE, "img_dpe", "img_sel", 4),
0030 GATE_IMG(CLK_IMG_RSC, "img_rsc", "img_sel", 5),
0031 GATE_IMG(CLK_IMG_MFB, "img_mfb", "img_sel", 6),
0032 GATE_IMG(CLK_IMG_WPE_A, "img_wpe_a", "img_sel", 7),
0033 GATE_IMG(CLK_IMG_WPE_B, "img_wpe_b", "img_sel", 8),
0034 GATE_IMG(CLK_IMG_OWE, "img_owe", "img_sel", 9),
0035 };
0036
0037 static int clk_mt8183_img_probe(struct platform_device *pdev)
0038 {
0039 struct clk_hw_onecell_data *clk_data;
0040 struct device_node *node = pdev->dev.of_node;
0041
0042 clk_data = mtk_alloc_clk_data(CLK_IMG_NR_CLK);
0043
0044 mtk_clk_register_gates(node, img_clks, ARRAY_SIZE(img_clks),
0045 clk_data);
0046
0047 return of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
0048 }
0049
0050 static const struct of_device_id of_match_clk_mt8183_img[] = {
0051 { .compatible = "mediatek,mt8183-imgsys", },
0052 {}
0053 };
0054
0055 static struct platform_driver clk_mt8183_img_drv = {
0056 .probe = clk_mt8183_img_probe,
0057 .driver = {
0058 .name = "clk-mt8183-img",
0059 .of_match_table = of_match_clk_mt8183_img,
0060 },
0061 };
0062
0063 builtin_platform_driver(clk_mt8183_img_drv);