Skip to content

Commit 1b5e529

Browse files
garminchangbebarino
authored andcommitted
clk: mediatek: Add MT8188 imp i2c wrapper clock support
Add MT8188 imp i2c wrapper clock controllers which provide clock gate control in I2C IP blocks. Signed-off-by: Garmin.Chang <Garmin.Chang@mediatek.com> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Link: https://lore.kernel.org/r/20230331123621.16167-19-Garmin.Chang@mediatek.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent f42b9e9 commit 1b5e529

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

drivers/clk/mediatek/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,13 @@ config COMMON_CLK_MT8188_IMGSYS
706706
help
707707
This driver supports MediaTek MT8188 imgsys and imgsys2 clocks.
708708

709+
config COMMON_CLK_MT8188_IMP_IIC_WRAP
710+
tristate "Clock driver for MediaTek MT8188 imp_iic_wrap"
711+
depends on COMMON_CLK_MT8188
712+
default COMMON_CLK_MT8188
713+
help
714+
This driver supports MediaTek MT8188 I2C/I3C clocks.
715+
709716
config COMMON_CLK_MT8188_IPESYS
710717
tristate "Clock driver for MediaTek MT8188 ipesys"
711718
depends on COMMON_CLK_MT8188_IMGSYS

drivers/clk/mediatek/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ obj-$(CONFIG_COMMON_CLK_MT8188) += clk-mt8188-apmixedsys.o clk-mt8188-topckgen.o
104104
clk-mt8188-peri_ao.o clk-mt8188-infra_ao.o
105105
obj-$(CONFIG_COMMON_CLK_MT8188_CAMSYS) += clk-mt8188-cam.o clk-mt8188-ccu.o
106106
obj-$(CONFIG_COMMON_CLK_MT8188_IMGSYS) += clk-mt8188-img.o
107+
obj-$(CONFIG_COMMON_CLK_MT8188_IMP_IIC_WRAP) += clk-mt8188-imp_iic_wrap.o
107108
obj-$(CONFIG_COMMON_CLK_MT8188_IPESYS) += clk-mt8188-ipe.o
108109
obj-$(CONFIG_COMMON_CLK_MT8188_MFGCFG) += clk-mt8188-mfg.o
109110
obj-$(CONFIG_COMMON_CLK_MT8188_VDECSYS) += clk-mt8188-vdec.o
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (c) 2022 MediaTek Inc.
4+
* Author: Garmin Chang <garmin.chang@mediatek.com>
5+
*/
6+
7+
#include <dt-bindings/clock/mediatek,mt8188-clk.h>
8+
#include <linux/clk-provider.h>
9+
#include <linux/platform_device.h>
10+
11+
#include "clk-gate.h"
12+
#include "clk-mtk.h"
13+
14+
static const struct mtk_gate_regs imp_iic_wrap_cg_regs = {
15+
.set_ofs = 0xe08,
16+
.clr_ofs = 0xe04,
17+
.sta_ofs = 0xe00,
18+
};
19+
20+
#define GATE_IMP_IIC_WRAP(_id, _name, _parent, _shift) \
21+
GATE_MTK_FLAGS(_id, _name, _parent, &imp_iic_wrap_cg_regs, _shift, \
22+
&mtk_clk_gate_ops_setclr, CLK_OPS_PARENT_ENABLE)
23+
24+
static const struct mtk_gate imp_iic_wrap_c_clks[] = {
25+
GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C0,
26+
"imp_iic_wrap_c_ap_clock_i2c0", "top_i2c", 0),
27+
GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C2,
28+
"imp_iic_wrap_c_ap_clock_i2c2", "top_i2c", 1),
29+
GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_C_AP_CLOCK_I2C3,
30+
"imp_iic_wrap_c_ap_clock_i2c3", "top_i2c", 2),
31+
};
32+
33+
static const struct mtk_gate imp_iic_wrap_w_clks[] = {
34+
GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C1,
35+
"imp_iic_wrap_w_ap_clock_i2c1", "top_i2c", 0),
36+
GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_W_AP_CLOCK_I2C4,
37+
"imp_iic_wrap_w_ap_clock_i2c4", "top_i2c", 1),
38+
};
39+
40+
static const struct mtk_gate imp_iic_wrap_en_clks[] = {
41+
GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C5,
42+
"imp_iic_wrap_en_ap_clock_i2c5", "top_i2c", 0),
43+
GATE_IMP_IIC_WRAP(CLK_IMP_IIC_WRAP_EN_AP_CLOCK_I2C6,
44+
"imp_iic_wrap_en_ap_clock_i2c6", "top_i2c", 1),
45+
};
46+
47+
static const struct mtk_clk_desc imp_iic_wrap_c_desc = {
48+
.clks = imp_iic_wrap_c_clks,
49+
.num_clks = ARRAY_SIZE(imp_iic_wrap_c_clks),
50+
};
51+
52+
static const struct mtk_clk_desc imp_iic_wrap_w_desc = {
53+
.clks = imp_iic_wrap_w_clks,
54+
.num_clks = ARRAY_SIZE(imp_iic_wrap_w_clks),
55+
};
56+
57+
static const struct mtk_clk_desc imp_iic_wrap_en_desc = {
58+
.clks = imp_iic_wrap_en_clks,
59+
.num_clks = ARRAY_SIZE(imp_iic_wrap_en_clks),
60+
};
61+
62+
static const struct of_device_id of_match_clk_mt8188_imp_iic_wrap[] = {
63+
{ .compatible = "mediatek,mt8188-imp-iic-wrap-c", .data = &imp_iic_wrap_c_desc },
64+
{ .compatible = "mediatek,mt8188-imp-iic-wrap-w", .data = &imp_iic_wrap_w_desc },
65+
{ .compatible = "mediatek,mt8188-imp-iic-wrap-en", .data = &imp_iic_wrap_en_desc },
66+
{ /* sentinel */ }
67+
};
68+
MODULE_DEVICE_TABLE(platform, of_match_clk_mt8188_imp_iic_wrap);
69+
70+
static struct platform_driver clk_mt8188_imp_iic_wrap_drv = {
71+
.probe = mtk_clk_simple_probe,
72+
.remove = mtk_clk_simple_remove,
73+
.driver = {
74+
.name = "clk-mt8188-imp_iic_wrap",
75+
.of_match_table = of_match_clk_mt8188_imp_iic_wrap,
76+
},
77+
};
78+
79+
module_platform_driver(clk_mt8188_imp_iic_wrap_drv);
80+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)