1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2021 MediaTek Inc.
4 * Author: Sam Shih <sam.shih@mediatek.com>
5 * Author: Wenzhen Yu <wenzhen.yu@mediatek.com>
6 * Author: Jianhui Zhao <zhaojh329@gmail.com>
7 * Author: Daniel Golle <daniel@makrotopia.org>
10 #include <linux/clk-provider.h>
11 #include <linux/mod_devicetable.h>
12 #include <linux/platform_device.h>
17 #include <dt-bindings/clock/mediatek,mt7981-clk.h>
19 static const struct mtk_gate_regs sgmii0_cg_regs
= {
25 #define GATE_SGMII0(_id, _name, _parent, _shift) { \
28 .parent_name = _parent, \
29 .regs = &sgmii0_cg_regs, \
31 .ops = &mtk_clk_gate_ops_no_setclr_inv, \
34 static const struct mtk_gate sgmii0_clks
[] __initconst
= {
35 GATE_SGMII0(CLK_SGM0_TX_EN
, "sgm0_tx_en", "usb_tx250m", 2),
36 GATE_SGMII0(CLK_SGM0_RX_EN
, "sgm0_rx_en", "usb_eq_rx250m", 3),
37 GATE_SGMII0(CLK_SGM0_CK0_EN
, "sgm0_ck0_en", "usb_ln0", 4),
38 GATE_SGMII0(CLK_SGM0_CDR_CK0_EN
, "sgm0_cdr_ck0_en", "usb_cdr", 5),
41 static const struct mtk_gate_regs sgmii1_cg_regs
= {
47 #define GATE_SGMII1(_id, _name, _parent, _shift) { \
50 .parent_name = _parent, \
51 .regs = &sgmii1_cg_regs, \
53 .ops = &mtk_clk_gate_ops_no_setclr_inv, \
56 static const struct mtk_gate sgmii1_clks
[] __initconst
= {
57 GATE_SGMII1(CLK_SGM1_TX_EN
, "sgm1_tx_en", "usb_tx250m", 2),
58 GATE_SGMII1(CLK_SGM1_RX_EN
, "sgm1_rx_en", "usb_eq_rx250m", 3),
59 GATE_SGMII1(CLK_SGM1_CK1_EN
, "sgm1_ck1_en", "usb_ln0", 4),
60 GATE_SGMII1(CLK_SGM1_CDR_CK1_EN
, "sgm1_cdr_ck1_en", "usb_cdr", 5),
63 static const struct mtk_gate_regs eth_cg_regs
= {
69 #define GATE_ETH(_id, _name, _parent, _shift) { \
72 .parent_name = _parent, \
73 .regs = ð_cg_regs, \
75 .ops = &mtk_clk_gate_ops_no_setclr_inv, \
78 static const struct mtk_gate eth_clks
[] __initconst
= {
79 GATE_ETH(CLK_ETH_FE_EN
, "eth_fe_en", "netsys_2x", 6),
80 GATE_ETH(CLK_ETH_GP2_EN
, "eth_gp2_en", "sgm_325m", 7),
81 GATE_ETH(CLK_ETH_GP1_EN
, "eth_gp1_en", "sgm_325m", 8),
82 GATE_ETH(CLK_ETH_WOCPU0_EN
, "eth_wocpu0_en", "netsys_wed_mcu", 15),
85 static const struct mtk_clk_desc eth_desc
= {
87 .num_clks
= ARRAY_SIZE(eth_clks
),
90 static const struct mtk_clk_desc sgmii0_desc
= {
92 .num_clks
= ARRAY_SIZE(sgmii0_clks
),
95 static const struct mtk_clk_desc sgmii1_desc
= {
97 .num_clks
= ARRAY_SIZE(sgmii1_clks
),
100 static const struct of_device_id of_match_clk_mt7981_eth
[] = {
101 { .compatible
= "mediatek,mt7981-ethsys", .data
= ð_desc
},
102 { .compatible
= "mediatek,mt7981-sgmiisys_0", .data
= &sgmii0_desc
},
103 { .compatible
= "mediatek,mt7981-sgmiisys_1", .data
= &sgmii1_desc
},
106 MODULE_DEVICE_TABLE(of
, of_match_clk_mt7981_eth
);
108 static struct platform_driver clk_mt7981_eth_drv
= {
109 .probe
= mtk_clk_simple_probe
,
110 .remove
= mtk_clk_simple_remove
,
112 .name
= "clk-mt7981-eth",
113 .of_match_table
= of_match_clk_mt7981_eth
,
116 module_platform_driver(clk_mt7981_eth_drv
);
118 MODULE_DESCRIPTION("MediaTek MT7981 Ethernet clocks driver");
119 MODULE_LICENSE("GPL");