162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci//
362306a36Sopenharmony_ci// Copyright (c) 2018 MediaTek Inc.
462306a36Sopenharmony_ci// Author: Weiyi Lu <weiyi.lu@mediatek.com>
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#include <linux/clk-provider.h>
762306a36Sopenharmony_ci#include <linux/platform_device.h>
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#include "clk-mtk.h"
1062306a36Sopenharmony_ci#include "clk-gate.h"
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <dt-bindings/clock/mt8183-clk.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_cistatic const struct mtk_gate_regs img_cg_regs = {
1562306a36Sopenharmony_ci	.set_ofs = 0x4,
1662306a36Sopenharmony_ci	.clr_ofs = 0x8,
1762306a36Sopenharmony_ci	.sta_ofs = 0x0,
1862306a36Sopenharmony_ci};
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define GATE_IMG(_id, _name, _parent, _shift)			\
2162306a36Sopenharmony_ci	GATE_MTK(_id, _name, _parent, &img_cg_regs, _shift,	\
2262306a36Sopenharmony_ci		&mtk_clk_gate_ops_setclr)
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_cistatic const struct mtk_gate img_clks[] = {
2562306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_LARB5, "img_larb5", "img_sel", 0),
2662306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_LARB2, "img_larb2", "img_sel", 1),
2762306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_DIP, "img_dip", "img_sel", 2),
2862306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_FDVT, "img_fdvt", "img_sel", 3),
2962306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_DPE, "img_dpe", "img_sel", 4),
3062306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_RSC, "img_rsc", "img_sel", 5),
3162306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_MFB, "img_mfb", "img_sel", 6),
3262306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_WPE_A, "img_wpe_a", "img_sel", 7),
3362306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_WPE_B, "img_wpe_b", "img_sel", 8),
3462306a36Sopenharmony_ci	GATE_IMG(CLK_IMG_OWE, "img_owe", "img_sel", 9),
3562306a36Sopenharmony_ci};
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_cistatic const struct mtk_clk_desc img_desc = {
3862306a36Sopenharmony_ci	.clks = img_clks,
3962306a36Sopenharmony_ci	.num_clks = ARRAY_SIZE(img_clks),
4062306a36Sopenharmony_ci};
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_cistatic const struct of_device_id of_match_clk_mt8183_img[] = {
4362306a36Sopenharmony_ci	{
4462306a36Sopenharmony_ci		.compatible = "mediatek,mt8183-imgsys",
4562306a36Sopenharmony_ci		.data = &img_desc,
4662306a36Sopenharmony_ci	}, {
4762306a36Sopenharmony_ci		/* sentinel */
4862306a36Sopenharmony_ci	}
4962306a36Sopenharmony_ci};
5062306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_match_clk_mt8183_img);
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_cistatic struct platform_driver clk_mt8183_img_drv = {
5362306a36Sopenharmony_ci	.probe = mtk_clk_simple_probe,
5462306a36Sopenharmony_ci	.remove_new = mtk_clk_simple_remove,
5562306a36Sopenharmony_ci	.driver = {
5662306a36Sopenharmony_ci		.name = "clk-mt8183-img",
5762306a36Sopenharmony_ci		.of_match_table = of_match_clk_mt8183_img,
5862306a36Sopenharmony_ci	},
5962306a36Sopenharmony_ci};
6062306a36Sopenharmony_cimodule_platform_driver(clk_mt8183_img_drv);
6162306a36Sopenharmony_ciMODULE_LICENSE("GPL");
62