mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 06:33:34 +00:00
0f69a423c4
mtk_clk_simple_probe() is a function that registers mtk gate clocks and, if reset data is present, a reset controller and across all of the MTK clock drivers, such a function is duplicated many times: switch to the common mtk_clk_simple_probe() function for all of the clock drivers that are registering as platform drivers. Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Miles Chen <miles.chen@mediatek.com> Tested-by: Miles Chen <miles.chen@mediatek.com> Link: https://lore.kernel.org/r/20230120092053.182923-12-angelogioacchino.delregno@collabora.com Tested-by: Mingming Su <mingming.su@mediatek.com> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
103 lines
2.6 KiB
C
103 lines
2.6 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* Copyright (c) 2017 MediaTek Inc.
|
|
* Author: Chen Zhong <chen.zhong@mediatek.com>
|
|
* Sean Wang <sean.wang@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/mt7622-clk.h>
|
|
|
|
#define GATE_ETH(_id, _name, _parent, _shift) { \
|
|
.id = _id, \
|
|
.name = _name, \
|
|
.parent_name = _parent, \
|
|
.regs = ð_cg_regs, \
|
|
.shift = _shift, \
|
|
.ops = &mtk_clk_gate_ops_no_setclr_inv, \
|
|
}
|
|
|
|
static const struct mtk_gate_regs eth_cg_regs = {
|
|
.set_ofs = 0x30,
|
|
.clr_ofs = 0x30,
|
|
.sta_ofs = 0x30,
|
|
};
|
|
|
|
static const struct mtk_gate eth_clks[] = {
|
|
GATE_ETH(CLK_ETH_HSDMA_EN, "eth_hsdma_en", "eth_sel", 5),
|
|
GATE_ETH(CLK_ETH_ESW_EN, "eth_esw_en", "eth_500m", 6),
|
|
GATE_ETH(CLK_ETH_GP2_EN, "eth_gp2_en", "txclk_src_pre", 7),
|
|
GATE_ETH(CLK_ETH_GP1_EN, "eth_gp1_en", "txclk_src_pre", 8),
|
|
GATE_ETH(CLK_ETH_GP0_EN, "eth_gp0_en", "txclk_src_pre", 9),
|
|
};
|
|
|
|
static const struct mtk_gate_regs sgmii_cg_regs = {
|
|
.set_ofs = 0xE4,
|
|
.clr_ofs = 0xE4,
|
|
.sta_ofs = 0xE4,
|
|
};
|
|
|
|
#define GATE_SGMII(_id, _name, _parent, _shift) { \
|
|
.id = _id, \
|
|
.name = _name, \
|
|
.parent_name = _parent, \
|
|
.regs = &sgmii_cg_regs, \
|
|
.shift = _shift, \
|
|
.ops = &mtk_clk_gate_ops_no_setclr_inv, \
|
|
}
|
|
|
|
static const struct mtk_gate sgmii_clks[] = {
|
|
GATE_SGMII(CLK_SGMII_TX250M_EN, "sgmii_tx250m_en",
|
|
"ssusb_tx250m", 2),
|
|
GATE_SGMII(CLK_SGMII_RX250M_EN, "sgmii_rx250m_en",
|
|
"ssusb_eq_rx250m", 3),
|
|
GATE_SGMII(CLK_SGMII_CDR_REF, "sgmii_cdr_ref",
|
|
"ssusb_cdr_ref", 4),
|
|
GATE_SGMII(CLK_SGMII_CDR_FB, "sgmii_cdr_fb",
|
|
"ssusb_cdr_fb", 5),
|
|
};
|
|
|
|
static u16 rst_ofs[] = { 0x34, };
|
|
|
|
static const struct mtk_clk_rst_desc clk_rst_desc = {
|
|
.version = MTK_RST_SIMPLE,
|
|
.rst_bank_ofs = rst_ofs,
|
|
.rst_bank_nr = ARRAY_SIZE(rst_ofs),
|
|
};
|
|
|
|
static const struct mtk_clk_desc eth_desc = {
|
|
.clks = eth_clks,
|
|
.num_clks = ARRAY_SIZE(eth_clks),
|
|
.rst_desc = &clk_rst_desc,
|
|
};
|
|
|
|
static const struct mtk_clk_desc sgmii_desc = {
|
|
.clks = sgmii_clks,
|
|
.num_clks = ARRAY_SIZE(sgmii_clks),
|
|
};
|
|
|
|
static const struct of_device_id of_match_clk_mt7622_eth[] = {
|
|
{ .compatible = "mediatek,mt7622-ethsys", .data = ð_desc },
|
|
{ .compatible = "mediatek,mt7622-sgmiisys", .data = &sgmii_desc },
|
|
{ /* sentinel */ }
|
|
};
|
|
|
|
static struct platform_driver clk_mt7622_eth_drv = {
|
|
.probe = mtk_clk_simple_probe,
|
|
.remove = mtk_clk_simple_remove,
|
|
.driver = {
|
|
.name = "clk-mt7622-eth",
|
|
.of_match_table = of_match_clk_mt7622_eth,
|
|
},
|
|
};
|
|
|
|
builtin_platform_driver(clk_mt7622_eth_drv);
|