mirror of
https://github.com/openwrt/openwrt.git
synced 2025-02-02 01:08:05 +00:00
659f4a13dd
With Linux 6.1 many of our downstream patches and out-of-tree files can be removed or at least replaced by backported upstream commits. Signed-off-by: Daniel Golle <daniel@makrotopia.org> [fix CMDLINE_OVERRIDE for arm64] Signed-off-by: Bjørn Mork <bjorn@mork.no>
142 lines
4.7 KiB
C
142 lines
4.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* Copyright (c) 2023 MediaTek Inc.
|
|
* Author: Sam Shih <sam.shih@mediatek.com>
|
|
* Author: Xiufeng Li <Xiufeng.Li@mediatek.com>
|
|
*/
|
|
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/of.h>
|
|
#include <linux/of_address.h>
|
|
#include <linux/of_device.h>
|
|
#include <linux/platform_device.h>
|
|
#include "clk-mtk.h"
|
|
#include "clk-gate.h"
|
|
#include <dt-bindings/clock/mediatek,mt7988-clk.h>
|
|
|
|
static const struct mtk_gate_regs ethdma_cg_regs = {
|
|
.set_ofs = 0x30,
|
|
.clr_ofs = 0x30,
|
|
.sta_ofs = 0x30,
|
|
};
|
|
|
|
#define GATE_ETHDMA(_id, _name, _parent, _shift) \
|
|
{ \
|
|
.id = _id, .name = _name, .parent_name = _parent, \
|
|
.regs = ðdma_cg_regs, .shift = _shift, \
|
|
.ops = &mtk_clk_gate_ops_no_setclr_inv, \
|
|
}
|
|
|
|
static const struct mtk_gate ethdma_clks[] = {
|
|
GATE_ETHDMA(CLK_ETHDMA_XGP1_EN, "ethdma_xgp1_en", "top_xtal", 0),
|
|
GATE_ETHDMA(CLK_ETHDMA_XGP2_EN, "ethdma_xgp2_en", "top_xtal", 1),
|
|
GATE_ETHDMA(CLK_ETHDMA_XGP3_EN, "ethdma_xgp3_en", "top_xtal", 2),
|
|
GATE_ETHDMA(CLK_ETHDMA_FE_EN, "ethdma_fe_en", "netsys_2x_sel", 6),
|
|
GATE_ETHDMA(CLK_ETHDMA_GP2_EN, "ethdma_gp2_en", "top_xtal", 7),
|
|
GATE_ETHDMA(CLK_ETHDMA_GP1_EN, "ethdma_gp1_en", "top_xtal", 8),
|
|
GATE_ETHDMA(CLK_ETHDMA_GP3_EN, "ethdma_gp3_en", "top_xtal", 10),
|
|
GATE_ETHDMA(CLK_ETHDMA_ESW_EN, "ethdma_esw_en", "netsys_gsw_sel", 16),
|
|
GATE_ETHDMA(CLK_ETHDMA_CRYPT0_EN, "ethdma_crypt0_en", "eip197_sel",
|
|
29),
|
|
};
|
|
|
|
static const struct mtk_clk_desc ethdma_desc = {
|
|
.clks = ethdma_clks,
|
|
.num_clks = ARRAY_SIZE(ethdma_clks),
|
|
};
|
|
|
|
static const struct mtk_gate_regs sgmii0_cg_regs = {
|
|
.set_ofs = 0xe4,
|
|
.clr_ofs = 0xe4,
|
|
.sta_ofs = 0xe4,
|
|
};
|
|
|
|
#define GATE_SGMII0(_id, _name, _parent, _shift) \
|
|
{ \
|
|
.id = _id, .name = _name, .parent_name = _parent, \
|
|
.regs = &sgmii0_cg_regs, .shift = _shift, \
|
|
.ops = &mtk_clk_gate_ops_no_setclr_inv, \
|
|
}
|
|
|
|
static const struct mtk_gate sgmii0_clks[] = {
|
|
GATE_SGMII0(CLK_SGM0_TX_EN, "sgm0_tx_en", "top_xtal", 2),
|
|
GATE_SGMII0(CLK_SGM0_RX_EN, "sgm0_rx_en", "top_xtal", 3),
|
|
};
|
|
|
|
static const struct mtk_clk_desc sgmii0_desc = {
|
|
.clks = sgmii0_clks,
|
|
.num_clks = ARRAY_SIZE(sgmii0_clks),
|
|
};
|
|
|
|
static const struct mtk_gate_regs sgmii1_cg_regs = {
|
|
.set_ofs = 0xe4,
|
|
.clr_ofs = 0xe4,
|
|
.sta_ofs = 0xe4,
|
|
};
|
|
|
|
#define GATE_SGMII1(_id, _name, _parent, _shift) \
|
|
{ \
|
|
.id = _id, .name = _name, .parent_name = _parent, \
|
|
.regs = &sgmii1_cg_regs, .shift = _shift, \
|
|
.ops = &mtk_clk_gate_ops_no_setclr_inv, \
|
|
}
|
|
|
|
static const struct mtk_gate sgmii1_clks[] = {
|
|
GATE_SGMII1(CLK_SGM1_TX_EN, "sgm1_tx_en", "top_xtal", 2),
|
|
GATE_SGMII1(CLK_SGM1_RX_EN, "sgm1_rx_en", "top_xtal", 3),
|
|
};
|
|
|
|
static const struct mtk_clk_desc sgmii1_desc = {
|
|
.clks = sgmii1_clks,
|
|
.num_clks = ARRAY_SIZE(sgmii1_clks),
|
|
};
|
|
|
|
static const struct mtk_gate_regs ethwarp_cg_regs = {
|
|
.set_ofs = 0x14,
|
|
.clr_ofs = 0x14,
|
|
.sta_ofs = 0x14,
|
|
};
|
|
|
|
#define GATE_ETHWARP(_id, _name, _parent, _shift) \
|
|
{ \
|
|
.id = _id, .name = _name, .parent_name = _parent, \
|
|
.regs = ðwarp_cg_regs, .shift = _shift, \
|
|
.ops = &mtk_clk_gate_ops_no_setclr_inv, \
|
|
}
|
|
|
|
static const struct mtk_gate ethwarp_clks[] = {
|
|
GATE_ETHWARP(CLK_ETHWARP_WOCPU2_EN, "ethwarp_wocpu2_en",
|
|
"netsys_mcu_sel", 13),
|
|
GATE_ETHWARP(CLK_ETHWARP_WOCPU1_EN, "ethwarp_wocpu1_en",
|
|
"netsys_mcu_sel", 14),
|
|
GATE_ETHWARP(CLK_ETHWARP_WOCPU0_EN, "ethwarp_wocpu0_en",
|
|
"netsys_mcu_sel", 15),
|
|
};
|
|
|
|
static const struct mtk_clk_desc ethwarp_desc = {
|
|
.clks = ethwarp_clks,
|
|
.num_clks = ARRAY_SIZE(ethwarp_clks),
|
|
};
|
|
|
|
static const struct of_device_id of_match_clk_mt7986_eth[] = {
|
|
{ .compatible = "mediatek,mt7988-ethsys", .data = ðdma_desc },
|
|
{ .compatible = "mediatek,mt7988-sgmiisys_0", .data = &sgmii0_desc },
|
|
{ .compatible = "mediatek,mt7988-sgmiisys_1", .data = &sgmii1_desc },
|
|
{ .compatible = "mediatek,mt7988-ethwarp", .data = ðwarp_desc },
|
|
{ /* sentinel */ }
|
|
};
|
|
MODULE_DEVICE_TABLE(of, of_match_clk_mt7988_eth);
|
|
|
|
static struct platform_driver clk_mt7988_eth_drv = {
|
|
.driver = {
|
|
.name = "clk-mt7988-eth",
|
|
.of_match_table = of_match_clk_mt7986_eth,
|
|
},
|
|
.probe = mtk_clk_simple_probe,
|
|
.remove = mtk_clk_simple_remove,
|
|
};
|
|
module_platform_driver(clk_mt7988_eth_drv);
|
|
|
|
MODULE_DESCRIPTION("MediaTek MT7988 Ethernet clocks driver");
|
|
MODULE_LICENSE("GPL");
|