162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
262306a36Sopenharmony_ci//
362306a36Sopenharmony_ci// Copyright (c) 2021 MediaTek Inc.
462306a36Sopenharmony_ci// Author: Chun-Jie Chen <chun-jie.chen@mediatek.com>
562306a36Sopenharmony_ci
662306a36Sopenharmony_ci#include <linux/clk-provider.h>
762306a36Sopenharmony_ci#include <linux/mod_devicetable.h>
862306a36Sopenharmony_ci#include <linux/platform_device.h>
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci#include "clk-mtk.h"
1162306a36Sopenharmony_ci#include "clk-gate.h"
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci#include <dt-bindings/clock/mt8192-clk.h>
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_cistatic const struct mtk_gate_regs imp_iic_wrap_cg_regs = {
1662306a36Sopenharmony_ci	.set_ofs = 0xe08,
1762306a36Sopenharmony_ci	.clr_ofs = 0xe04,
1862306a36Sopenharmony_ci	.sta_ofs = 0xe00,
1962306a36Sopenharmony_ci};
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#define GATE_IMP_IIC_WRAP(_id, _name, _parent, _shift)			\
2262306a36Sopenharmony_ci	GATE_MTK_FLAGS(_id, _name, _parent, &imp_iic_wrap_cg_regs, _shift,	\
2362306a36Sopenharmony_ci		&mtk_clk_gate_ops_setclr, CLK_OPS_PARENT_ENABLE)
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_cistatic const struct mtk_gate imp_iic_wrap_c_clks[] = {
2662306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C10, "imp_iic_wrap_c_i2c10", "infra_i2c0", 0),
2762306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C11, "imp_iic_wrap_c_i2c11", "infra_i2c0", 1),
2862306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C12, "imp_iic_wrap_c_i2c12", "infra_i2c0", 2),
2962306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_I2C13, "imp_iic_wrap_c_i2c13", "infra_i2c0", 3),
3062306a36Sopenharmony_ci};
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_cistatic const struct mtk_gate imp_iic_wrap_e_clks[] = {
3362306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_E_I2C3, "imp_iic_wrap_e_i2c3", "infra_i2c0", 0),
3462306a36Sopenharmony_ci};
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_cistatic const struct mtk_gate imp_iic_wrap_n_clks[] = {
3762306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_N_I2C0, "imp_iic_wrap_n_i2c0", "infra_i2c0", 0),
3862306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_N_I2C6, "imp_iic_wrap_n_i2c6", "infra_i2c0", 1),
3962306a36Sopenharmony_ci};
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_cistatic const struct mtk_gate imp_iic_wrap_s_clks[] = {
4262306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C7, "imp_iic_wrap_s_i2c7", "infra_i2c0", 0),
4362306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C8, "imp_iic_wrap_s_i2c8", "infra_i2c0", 1),
4462306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_S_I2C9, "imp_iic_wrap_s_i2c9", "infra_i2c0", 2),
4562306a36Sopenharmony_ci};
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_cistatic const struct mtk_gate imp_iic_wrap_w_clks[] = {
4862306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_I2C5, "imp_iic_wrap_w_i2c5", "infra_i2c0", 0),
4962306a36Sopenharmony_ci};
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_cistatic const struct mtk_gate imp_iic_wrap_ws_clks[] = {
5262306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C1, "imp_iic_wrap_ws_i2c1", "infra_i2c0", 0),
5362306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C2, "imp_iic_wrap_ws_i2c2", "infra_i2c0", 1),
5462306a36Sopenharmony_ci	GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_WS_I2C4, "imp_iic_wrap_ws_i2c4", "infra_i2c0", 2),
5562306a36Sopenharmony_ci};
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_cistatic const struct mtk_clk_desc imp_iic_wrap_c_desc = {
5862306a36Sopenharmony_ci	.clks = imp_iic_wrap_c_clks,
5962306a36Sopenharmony_ci	.num_clks = ARRAY_SIZE(imp_iic_wrap_c_clks),
6062306a36Sopenharmony_ci};
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cistatic const struct mtk_clk_desc imp_iic_wrap_e_desc = {
6362306a36Sopenharmony_ci	.clks = imp_iic_wrap_e_clks,
6462306a36Sopenharmony_ci	.num_clks = ARRAY_SIZE(imp_iic_wrap_e_clks),
6562306a36Sopenharmony_ci};
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_cistatic const struct mtk_clk_desc imp_iic_wrap_n_desc = {
6862306a36Sopenharmony_ci	.clks = imp_iic_wrap_n_clks,
6962306a36Sopenharmony_ci	.num_clks = ARRAY_SIZE(imp_iic_wrap_n_clks),
7062306a36Sopenharmony_ci};
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_cistatic const struct mtk_clk_desc imp_iic_wrap_s_desc = {
7362306a36Sopenharmony_ci	.clks = imp_iic_wrap_s_clks,
7462306a36Sopenharmony_ci	.num_clks = ARRAY_SIZE(imp_iic_wrap_s_clks),
7562306a36Sopenharmony_ci};
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_cistatic const struct mtk_clk_desc imp_iic_wrap_w_desc = {
7862306a36Sopenharmony_ci	.clks = imp_iic_wrap_w_clks,
7962306a36Sopenharmony_ci	.num_clks = ARRAY_SIZE(imp_iic_wrap_w_clks),
8062306a36Sopenharmony_ci};
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_cistatic const struct mtk_clk_desc imp_iic_wrap_ws_desc = {
8362306a36Sopenharmony_ci	.clks = imp_iic_wrap_ws_clks,
8462306a36Sopenharmony_ci	.num_clks = ARRAY_SIZE(imp_iic_wrap_ws_clks),
8562306a36Sopenharmony_ci};
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_cistatic const struct of_device_id of_match_clk_mt8192_imp_iic_wrap[] = {
8862306a36Sopenharmony_ci	{
8962306a36Sopenharmony_ci		.compatible = "mediatek,mt8192-imp_iic_wrap_c",
9062306a36Sopenharmony_ci		.data = &imp_iic_wrap_c_desc,
9162306a36Sopenharmony_ci	}, {
9262306a36Sopenharmony_ci		.compatible = "mediatek,mt8192-imp_iic_wrap_e",
9362306a36Sopenharmony_ci		.data = &imp_iic_wrap_e_desc,
9462306a36Sopenharmony_ci	}, {
9562306a36Sopenharmony_ci		.compatible = "mediatek,mt8192-imp_iic_wrap_n",
9662306a36Sopenharmony_ci		.data = &imp_iic_wrap_n_desc,
9762306a36Sopenharmony_ci	}, {
9862306a36Sopenharmony_ci		.compatible = "mediatek,mt8192-imp_iic_wrap_s",
9962306a36Sopenharmony_ci		.data = &imp_iic_wrap_s_desc,
10062306a36Sopenharmony_ci	}, {
10162306a36Sopenharmony_ci		.compatible = "mediatek,mt8192-imp_iic_wrap_w",
10262306a36Sopenharmony_ci		.data = &imp_iic_wrap_w_desc,
10362306a36Sopenharmony_ci	}, {
10462306a36Sopenharmony_ci		.compatible = "mediatek,mt8192-imp_iic_wrap_ws",
10562306a36Sopenharmony_ci		.data = &imp_iic_wrap_ws_desc,
10662306a36Sopenharmony_ci	}, {
10762306a36Sopenharmony_ci		/* sentinel */
10862306a36Sopenharmony_ci	}
10962306a36Sopenharmony_ci};
11062306a36Sopenharmony_ciMODULE_DEVICE_TABLE(of, of_match_clk_mt8192_imp_iic_wrap);
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_cistatic struct platform_driver clk_mt8192_imp_iic_wrap_drv = {
11362306a36Sopenharmony_ci	.probe = mtk_clk_simple_probe,
11462306a36Sopenharmony_ci	.remove_new = mtk_clk_simple_remove,
11562306a36Sopenharmony_ci	.driver = {
11662306a36Sopenharmony_ci		.name = "clk-mt8192-imp_iic_wrap",
11762306a36Sopenharmony_ci		.of_match_table = of_match_clk_mt8192_imp_iic_wrap,
11862306a36Sopenharmony_ci	},
11962306a36Sopenharmony_ci};
12062306a36Sopenharmony_cimodule_platform_driver(clk_mt8192_imp_iic_wrap_drv);
12162306a36Sopenharmony_ciMODULE_LICENSE("GPL");
122