2022-09-22 14:58:55

by Bo-Chen Chen

[permalink] [raw]
Subject: [PATCH] reset: mediatek: Move mediatek system clock reset to reset folder

To manager mediatek system clock reset easier, we move the driver to
drivers/reset.

The modifications in this series:
- Move drivers/clk/mediatek/reset.c to drivers/reset/reset-mediatek-sysclk.c
- Move reset data which are scattered around the mediatek drivers to
reset-mediatek-sysclk.c
- For mtk clk drivers which support device, we can ues
mtk_reset_controller_register() to register reset controller using
auxiliary bus.
- For mtk clk drivers which do not support device (only support
device_node), we use mtk_reset_{init/remove}_with_node to register
reset controller.

Signed-off-by: Bo-Chen Chen <[email protected]>
---
drivers/clk/mediatek/Kconfig | 2 +
drivers/clk/mediatek/Makefile | 2 +-
drivers/clk/mediatek/clk-mt2701-eth.c | 10 +-
drivers/clk/mediatek/clk-mt2701-g3d.c | 10 +-
drivers/clk/mediatek/clk-mt2701-hif.c | 10 +-
drivers/clk/mediatek/clk-mt2701.c | 22 +-
drivers/clk/mediatek/clk-mt2712.c | 22 +-
drivers/clk/mediatek/clk-mt7622-eth.c | 10 +-
drivers/clk/mediatek/clk-mt7622-hif.c | 12 +-
drivers/clk/mediatek/clk-mt7622.c | 22 +-
drivers/clk/mediatek/clk-mt7629-eth.c | 10 +-
drivers/clk/mediatek/clk-mt7629-hif.c | 12 +-
drivers/clk/mediatek/clk-mt8135.c | 23 +-
drivers/clk/mediatek/clk-mt8173.c | 22 +-
drivers/clk/mediatek/clk-mt8183.c | 15 +-
drivers/clk/mediatek/clk-mt8186-infra_ao.c | 23 +-
drivers/clk/mediatek/clk-mt8192.c | 26 +-
drivers/clk/mediatek/clk-mt8195-infra_ao.c | 24 +-
drivers/clk/mediatek/clk-mtk.c | 61 ++-
drivers/clk/mediatek/clk-mtk.h | 9 +-
drivers/clk/mediatek/reset.c | 232 ---------
drivers/clk/mediatek/reset.h | 82 ---
drivers/reset/Kconfig | 7 +
drivers/reset/Makefile | 1 +
drivers/reset/reset-mediatek-sysclk.c | 578 +++++++++++++++++++++
25 files changed, 677 insertions(+), 570 deletions(-)
delete mode 100644 drivers/clk/mediatek/reset.c
delete mode 100644 drivers/clk/mediatek/reset.h
create mode 100644 drivers/reset/reset-mediatek-sysclk.c

diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig
index d5936cfb3bee..94daf62fe35b 100644
--- a/drivers/clk/mediatek/Kconfig
+++ b/drivers/clk/mediatek/Kconfig
@@ -8,6 +8,8 @@ menu "Clock driver for MediaTek SoC"
config COMMON_CLK_MEDIATEK
tristate
select RESET_CONTROLLER
+ select RESET_MEDIATEK_SYSCLK
+ select AUXILIARY_BUS
help
MediaTek SoCs' clock support.

diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile
index caf2ce93d666..cf0f092879a5 100644
--- a/drivers/clk/mediatek/Makefile
+++ b/drivers/clk/mediatek/Makefile
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o clk-apmixed.o clk-cpumux.o reset.o clk-mux.o
+obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o clk-apmixed.o clk-cpumux.o clk-mux.o

obj-$(CONFIG_COMMON_CLK_MT6765) += clk-mt6765.o
obj-$(CONFIG_COMMON_CLK_MT6765_AUDIOSYS) += clk-mt6765-audio.o
diff --git a/drivers/clk/mediatek/clk-mt2701-eth.c b/drivers/clk/mediatek/clk-mt2701-eth.c
index edf1e2ed2b59..2da95232e529 100644
--- a/drivers/clk/mediatek/clk-mt2701-eth.c
+++ b/drivers/clk/mediatek/clk-mt2701-eth.c
@@ -36,14 +36,6 @@ static const struct mtk_gate eth_clks[] = {
GATE_ETH(CLK_ETHSYS_CRYPTO, "crypto_clk", "ethif_sel", 29),
};

-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 of_device_id of_match_clk_mt2701_eth[] = {
{ .compatible = "mediatek,mt2701-ethsys", },
{}
@@ -66,7 +58,7 @@ static int clk_mt2701_eth_probe(struct platform_device *pdev)
"could not register clock provider: %s: %d\n",
pdev->name, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt2701-eth-rst");

return r;
}
diff --git a/drivers/clk/mediatek/clk-mt2701-g3d.c b/drivers/clk/mediatek/clk-mt2701-g3d.c
index 1458109d99d9..da43c422d452 100644
--- a/drivers/clk/mediatek/clk-mt2701-g3d.c
+++ b/drivers/clk/mediatek/clk-mt2701-g3d.c
@@ -35,14 +35,6 @@ static const struct mtk_gate g3d_clks[] = {
GATE_G3D(CLK_G3DSYS_CORE, "g3d_core", "mfg_sel", 0),
};

-static u16 rst_ofs[] = { 0xc, };
-
-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 int clk_mt2701_g3dsys_init(struct platform_device *pdev)
{
struct clk_hw_onecell_data *clk_data;
@@ -60,7 +52,7 @@ static int clk_mt2701_g3dsys_init(struct platform_device *pdev)
"could not register clock provider: %s: %d\n",
pdev->name, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt2701-g3d-rst");

return r;
}
diff --git a/drivers/clk/mediatek/clk-mt2701-hif.c b/drivers/clk/mediatek/clk-mt2701-hif.c
index 434cbbe8c037..2ecccf8fe16e 100644
--- a/drivers/clk/mediatek/clk-mt2701-hif.c
+++ b/drivers/clk/mediatek/clk-mt2701-hif.c
@@ -33,14 +33,6 @@ static const struct mtk_gate hif_clks[] = {
GATE_HIF(CLK_HIFSYS_PCIE2, "pcie2_clk", "ethpll_500m_ck", 26),
};

-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 of_device_id of_match_clk_mt2701_hif[] = {
{ .compatible = "mediatek,mt2701-hifsys", },
{}
@@ -65,7 +57,7 @@ static int clk_mt2701_hif_probe(struct platform_device *pdev)
return r;
}

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt2701-hif-rst");

return 0;
}
diff --git a/drivers/clk/mediatek/clk-mt2701.c b/drivers/clk/mediatek/clk-mt2701.c
index 9b442af37e67..b90f611a5b52 100644
--- a/drivers/clk/mediatek/clk-mt2701.c
+++ b/drivers/clk/mediatek/clk-mt2701.c
@@ -735,24 +735,6 @@ static const struct mtk_fixed_factor infra_fixed_divs[] = {
FACTOR(CLK_INFRA_CLK_13M, "clk13m", "clk26m", 1, 2),
};

-static u16 infrasys_rst_ofs[] = { 0x30, 0x34, };
-static u16 pericfg_rst_ofs[] = { 0x0, 0x4, };
-
-static const struct mtk_clk_rst_desc clk_rst_desc[] = {
- /* infrasys */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = infrasys_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
- },
- /* pericfg */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = pericfg_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs),
- },
-};
-
static struct clk_hw_onecell_data *infra_clk_data;

static void __init mtk_infrasys_init_early(struct device_node *node)
@@ -805,7 +787,7 @@ static int mtk_infrasys_init(struct platform_device *pdev)
if (r)
return r;

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[0]);
+ mtk_reset_controller_register(&pdev->dev, "mt2701-infrasys-rst");

return 0;
}
@@ -928,7 +910,7 @@ static int mtk_pericfg_init(struct platform_device *pdev)
if (r)
return r;

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[1]);
+ mtk_reset_controller_register(&pdev->dev, "mt2701-pericfg-rst");

return 0;
}
diff --git a/drivers/clk/mediatek/clk-mt2712.c b/drivers/clk/mediatek/clk-mt2712.c
index 56980dd6c2ea..bada923b60cf 100644
--- a/drivers/clk/mediatek/clk-mt2712.c
+++ b/drivers/clk/mediatek/clk-mt2712.c
@@ -1258,24 +1258,6 @@ static const struct mtk_pll_data plls[] = {
0, 31, 0x0300, 4, 0, 0, 0, 0x0304, 0),
};

-static u16 infrasys_rst_ofs[] = { 0x30, 0x34, };
-static u16 pericfg_rst_ofs[] = { 0x0, 0x4, };
-
-static const struct mtk_clk_rst_desc clk_rst_desc[] = {
- /* infra */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = infrasys_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
- },
- /* peri */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = pericfg_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs),
- },
-};
-
static int clk_mt2712_apmixed_probe(struct platform_device *pdev)
{
struct clk_hw_onecell_data *clk_data;
@@ -1379,7 +1361,7 @@ static int clk_mt2712_infra_probe(struct platform_device *pdev)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[0]);
+ mtk_reset_controller_register(&pdev->dev, "mt2712-infra-rst");

return r;
}
@@ -1401,7 +1383,7 @@ static int clk_mt2712_peri_probe(struct platform_device *pdev)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[1]);
+ mtk_reset_controller_register(&pdev->dev, "mt2712-peri-rst");

return r;
}
diff --git a/drivers/clk/mediatek/clk-mt7622-eth.c b/drivers/clk/mediatek/clk-mt7622-eth.c
index 43de0477d5d9..2e668ed78cd5 100644
--- a/drivers/clk/mediatek/clk-mt7622-eth.c
+++ b/drivers/clk/mediatek/clk-mt7622-eth.c
@@ -65,14 +65,6 @@ static const struct mtk_gate sgmii_clks[] = {
"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 int clk_mt7622_ethsys_init(struct platform_device *pdev)
{
struct clk_hw_onecell_data *clk_data;
@@ -90,7 +82,7 @@ static int clk_mt7622_ethsys_init(struct platform_device *pdev)
"could not register clock provider: %s: %d\n",
pdev->name, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt7622-eth-rst");

return r;
}
diff --git a/drivers/clk/mediatek/clk-mt7622-hif.c b/drivers/clk/mediatek/clk-mt7622-hif.c
index 67e96231dd25..0335d84b0043 100644
--- a/drivers/clk/mediatek/clk-mt7622-hif.c
+++ b/drivers/clk/mediatek/clk-mt7622-hif.c
@@ -76,14 +76,6 @@ static const struct mtk_gate pcie_clks[] = {
GATE_PCIE(CLK_SATA_PM_EN, "sata_pm_en", "univpll2_d4", 30),
};

-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 int clk_mt7622_ssusbsys_init(struct platform_device *pdev)
{
struct clk_hw_onecell_data *clk_data;
@@ -101,7 +93,7 @@ static int clk_mt7622_ssusbsys_init(struct platform_device *pdev)
"could not register clock provider: %s: %d\n",
pdev->name, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt7622-usb-rst");

return r;
}
@@ -123,7 +115,7 @@ static int clk_mt7622_pciesys_init(struct platform_device *pdev)
"could not register clock provider: %s: %d\n",
pdev->name, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt7622-pcie-rst");

return r;
}
diff --git a/drivers/clk/mediatek/clk-mt7622.c b/drivers/clk/mediatek/clk-mt7622.c
index 3b55f8641fae..ea4c21b9a6a0 100644
--- a/drivers/clk/mediatek/clk-mt7622.c
+++ b/drivers/clk/mediatek/clk-mt7622.c
@@ -610,24 +610,6 @@ static struct mtk_composite peri_muxes[] = {
MUX(CLK_PERIBUS_SEL, "peribus_ck_sel", peribus_ck_parents, 0x05C, 0, 1),
};

-static u16 infrasys_rst_ofs[] = { 0x30, };
-static u16 pericfg_rst_ofs[] = { 0x0, 0x4, };
-
-static const struct mtk_clk_rst_desc clk_rst_desc[] = {
- /* infrasys */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = infrasys_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
- },
- /* pericfg */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = pericfg_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs),
- },
-};
-
static int mtk_topckgen_init(struct platform_device *pdev)
{
struct clk_hw_onecell_data *clk_data;
@@ -681,7 +663,7 @@ static int mtk_infrasys_init(struct platform_device *pdev)
if (r)
return r;

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[0]);
+ mtk_reset_controller_register(&pdev->dev, "mt7622-infrasys-rst");

return 0;
}
@@ -732,7 +714,7 @@ static int mtk_pericfg_init(struct platform_device *pdev)

clk_prepare_enable(clk_data->hws[CLK_PERI_UART0_PD]->clk);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc[1]);
+ mtk_reset_controller_register(&pdev->dev, "mt7622-pericfg-rst");

return 0;
}
diff --git a/drivers/clk/mediatek/clk-mt7629-eth.c b/drivers/clk/mediatek/clk-mt7629-eth.c
index 282dd6559465..dadc76da899b 100644
--- a/drivers/clk/mediatek/clk-mt7629-eth.c
+++ b/drivers/clk/mediatek/clk-mt7629-eth.c
@@ -76,14 +76,6 @@ static const struct mtk_gate sgmii_clks[2][4] = {
}
};

-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 int clk_mt7629_ethsys_init(struct platform_device *pdev)
{
struct clk_hw_onecell_data *clk_data;
@@ -100,7 +92,7 @@ static int clk_mt7629_ethsys_init(struct platform_device *pdev)
"could not register clock provider: %s: %d\n",
pdev->name, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt7629-ethsys-rst");

return r;
}
diff --git a/drivers/clk/mediatek/clk-mt7629-hif.c b/drivers/clk/mediatek/clk-mt7629-hif.c
index 0c8b9e139789..bd6fdfd97504 100644
--- a/drivers/clk/mediatek/clk-mt7629-hif.c
+++ b/drivers/clk/mediatek/clk-mt7629-hif.c
@@ -71,14 +71,6 @@ static const struct mtk_gate pcie_clks[] = {
GATE_PCIE(CLK_PCIE_P0_PIPE_EN, "pcie_p0_pipe_en", "pcie0_pipe_en", 23),
};

-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 int clk_mt7629_ssusbsys_init(struct platform_device *pdev)
{
struct clk_hw_onecell_data *clk_data;
@@ -96,7 +88,7 @@ static int clk_mt7629_ssusbsys_init(struct platform_device *pdev)
"could not register clock provider: %s: %d\n",
pdev->name, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt7629-usb-rst");

return r;
}
@@ -118,7 +110,7 @@ static int clk_mt7629_pciesys_init(struct platform_device *pdev)
"could not register clock provider: %s: %d\n",
pdev->name, r);

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt7629-pcie-rst");

return r;
}
diff --git a/drivers/clk/mediatek/clk-mt8135.c b/drivers/clk/mediatek/clk-mt8135.c
index b68888a034c4..89cd8c492b91 100644
--- a/drivers/clk/mediatek/clk-mt8135.c
+++ b/drivers/clk/mediatek/clk-mt8135.c
@@ -514,24 +514,6 @@ static const struct mtk_composite peri_clks[] __initconst = {
MUX(CLK_PERI_UART3_SEL, "uart3_ck_sel", uart_ck_sel_parents, 0x40c, 3, 1),
};

-static u16 infrasys_rst_ofs[] = { 0x30, 0x34, };
-static u16 pericfg_rst_ofs[] = { 0x0, 0x4, };
-
-static const struct mtk_clk_rst_desc clk_rst_desc[] = {
- /* infrasys */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = infrasys_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
- },
- /* pericfg */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = pericfg_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs),
- }
-};
-
static void __init mtk_topckgen_init(struct device_node *node)
{
struct clk_hw_onecell_data *clk_data;
@@ -577,7 +559,8 @@ static void __init mtk_infrasys_init(struct device_node *node)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);

- mtk_register_reset_controller(node, &clk_rst_desc[0]);
+ mtk_reset_init_with_node(node, "clk_mt8135.mt8135-infrasys-rst");
+
}
CLK_OF_DECLARE(mtk_infrasys, "mediatek,mt8135-infracfg", mtk_infrasys_init);

@@ -605,7 +588,7 @@ static void __init mtk_pericfg_init(struct device_node *node)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);

- mtk_register_reset_controller(node, &clk_rst_desc[1]);
+ mtk_reset_init_with_node(node, "clk_mt8135.mt8135-pericfg-rst");
}
CLK_OF_DECLARE(mtk_pericfg, "mediatek,mt8135-pericfg", mtk_pericfg_init);

diff --git a/drivers/clk/mediatek/clk-mt8173.c b/drivers/clk/mediatek/clk-mt8173.c
index b8529ee7199d..ac01addf432f 100644
--- a/drivers/clk/mediatek/clk-mt8173.c
+++ b/drivers/clk/mediatek/clk-mt8173.c
@@ -819,24 +819,6 @@ static const struct mtk_gate venclt_clks[] __initconst = {
GATE_VENCLT(CLK_VENCLT_CKE1, "venclt_cke1", "venclt_sel", 4),
};

-static u16 infrasys_rst_ofs[] = { 0x30, 0x34, };
-static u16 pericfg_rst_ofs[] = { 0x0, 0x4, };
-
-static const struct mtk_clk_rst_desc clk_rst_desc[] = {
- /* infrasys */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = infrasys_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(infrasys_rst_ofs),
- },
- /* pericfg */
- {
- .version = MTK_RST_SIMPLE,
- .rst_bank_ofs = pericfg_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(pericfg_rst_ofs),
- }
-};
-
static struct clk_hw_onecell_data *mt8173_top_clk_data __initdata;
static struct clk_hw_onecell_data *mt8173_pll_clk_data __initdata;

@@ -900,7 +882,7 @@ static void __init mtk_infrasys_init(struct device_node *node)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);

- mtk_register_reset_controller(node, &clk_rst_desc[0]);
+ mtk_reset_init_with_node(node, "clk_mt8173.mt8173-infracfg-rst");
}
CLK_OF_DECLARE(mtk_infrasys, "mediatek,mt8173-infracfg", mtk_infrasys_init);

@@ -928,7 +910,7 @@ static void __init mtk_pericfg_init(struct device_node *node)
pr_err("%s(): could not register clock provider: %d\n",
__func__, r);

- mtk_register_reset_controller(node, &clk_rst_desc[1]);
+ mtk_reset_init_with_node(node, "clk_mt8173.mt8173-pericfg-rst");
}
CLK_OF_DECLARE(mtk_pericfg, "mediatek,mt8173-pericfg", mtk_pericfg_init);

diff --git a/drivers/clk/mediatek/clk-mt8183.c b/drivers/clk/mediatek/clk-mt8183.c
index 8512101e1189..a41c305d62a3 100644
--- a/drivers/clk/mediatek/clk-mt8183.c
+++ b/drivers/clk/mediatek/clk-mt8183.c
@@ -1150,19 +1150,6 @@ static const struct mtk_pll_data plls[] = {
0, 0, 32, 8, 0x02B4, 1, 0x02BC, 0x0014, 1, 0x02B8, 0, 0x02B4),
};

-static u16 infra_rst_ofs[] = {
- INFRA_RST0_SET_OFFSET,
- INFRA_RST1_SET_OFFSET,
- INFRA_RST2_SET_OFFSET,
- INFRA_RST3_SET_OFFSET,
-};
-
-static const struct mtk_clk_rst_desc clk_rst_desc = {
- .version = MTK_RST_SET_CLR,
- .rst_bank_ofs = infra_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(infra_rst_ofs),
-};
-
static int clk_mt8183_apmixed_probe(struct platform_device *pdev)
{
struct clk_hw_onecell_data *clk_data;
@@ -1250,7 +1237,7 @@ static int clk_mt8183_infra_probe(struct platform_device *pdev)
return r;
}

- mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ mtk_reset_controller_register(&pdev->dev, "mt8183-infra-rst");

return r;
}
diff --git a/drivers/clk/mediatek/clk-mt8186-infra_ao.c b/drivers/clk/mediatek/clk-mt8186-infra_ao.c
index df2a6bd1aefa..958e28472f2b 100644
--- a/drivers/clk/mediatek/clk-mt8186-infra_ao.c
+++ b/drivers/clk/mediatek/clk-mt8186-infra_ao.c
@@ -192,31 +192,10 @@ static const struct mtk_gate infra_ao_clks[] = {
GATE_INFRA_AO3(CLK_INFRA_AO_FLASHIF_66M, "infra_ao_flashif_66m", "top_axi", 29),
};

-static u16 infra_ao_rst_ofs[] = {
- INFRA_RST0_SET_OFFSET,
- INFRA_RST1_SET_OFFSET,
- INFRA_RST2_SET_OFFSET,
- INFRA_RST3_SET_OFFSET,
- INFRA_RST4_SET_OFFSET,
-};
-
-static u16 infra_ao_idx_map[] = {
- [MT8186_INFRA_THERMAL_CTRL_RST] = 0 * RST_NR_PER_BANK + 0,
- [MT8186_INFRA_PTP_CTRL_RST] = 1 * RST_NR_PER_BANK + 0,
-};
-
-static struct mtk_clk_rst_desc infra_ao_rst_desc = {
- .version = MTK_RST_SET_CLR,
- .rst_bank_ofs = infra_ao_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(infra_ao_rst_ofs),
- .rst_idx_map = infra_ao_idx_map,
- .rst_idx_map_nr = ARRAY_SIZE(infra_ao_idx_map),
-};
-
static const struct mtk_clk_desc infra_ao_desc = {
.clks = infra_ao_clks,
.num_clks = ARRAY_SIZE(infra_ao_clks),
- .rst_desc = &infra_ao_rst_desc,
+ .rst_name = "mt8186-infra-ao-rst",
};

static const struct of_device_id of_match_clk_mt8186_infra_ao[] = {
diff --git a/drivers/clk/mediatek/clk-mt8192.c b/drivers/clk/mediatek/clk-mt8192.c
index ebbd2798d9a3..4fd8e4d26fef 100644
--- a/drivers/clk/mediatek/clk-mt8192.c
+++ b/drivers/clk/mediatek/clk-mt8192.c
@@ -1115,30 +1115,6 @@ static const struct mtk_gate top_clks[] = {
GATE_TOP(CLK_TOP_SSUSB_PHY_REF, "ssusb_phy_ref", "clk26m", 25),
};

-static u16 infra_ao_rst_ofs[] = {
- INFRA_RST0_SET_OFFSET,
- INFRA_RST1_SET_OFFSET,
- INFRA_RST2_SET_OFFSET,
- INFRA_RST3_SET_OFFSET,
- INFRA_RST4_SET_OFFSET,
-};
-
-static u16 infra_ao_idx_map[] = {
- [MT8192_INFRA_RST0_THERM_CTRL_SWRST] = 0 * RST_NR_PER_BANK + 0,
- [MT8192_INFRA_RST2_PEXTP_PHY_SWRST] = 2 * RST_NR_PER_BANK + 15,
- [MT8192_INFRA_RST3_THERM_CTRL_PTP_SWRST] = 3 * RST_NR_PER_BANK + 5,
- [MT8192_INFRA_RST4_PCIE_TOP_SWRST] = 4 * RST_NR_PER_BANK + 1,
- [MT8192_INFRA_RST4_THERM_CTRL_MCU_SWRST] = 4 * RST_NR_PER_BANK + 12,
-};
-
-static const struct mtk_clk_rst_desc clk_rst_desc = {
- .version = MTK_RST_SET_CLR,
- .rst_bank_ofs = infra_ao_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(infra_ao_rst_ofs),
- .rst_idx_map = infra_ao_idx_map,
- .rst_idx_map_nr = ARRAY_SIZE(infra_ao_idx_map),
-};
-
#define MT8192_PLL_FMAX (3800UL * MHZ)
#define MT8192_PLL_FMIN (1500UL * MHZ)
#define MT8192_INTEGER_BITS 8
@@ -1265,7 +1241,7 @@ static int clk_mt8192_infra_probe(struct platform_device *pdev)
if (r)
goto free_clk_data;

- r = mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
+ r = mtk_reset_controller_register(&pdev->dev, "mt8192-infra-rst");
if (r)
goto free_clk_data;

diff --git a/drivers/clk/mediatek/clk-mt8195-infra_ao.c b/drivers/clk/mediatek/clk-mt8195-infra_ao.c
index 97657f255618..0861ba6e6673 100644
--- a/drivers/clk/mediatek/clk-mt8195-infra_ao.c
+++ b/drivers/clk/mediatek/clk-mt8195-infra_ao.c
@@ -183,32 +183,10 @@ static const struct mtk_gate infra_ao_clks[] = {
GATE_INFRA_AO4(CLK_INFRA_AO_PERI_UFS_MEM_SUB, "infra_ao_peri_ufs_mem_sub", "mem_466m", 31),
};

-static u16 infra_ao_rst_ofs[] = {
- INFRA_RST0_SET_OFFSET,
- INFRA_RST1_SET_OFFSET,
- INFRA_RST2_SET_OFFSET,
- INFRA_RST3_SET_OFFSET,
- INFRA_RST4_SET_OFFSET,
-};
-
-static u16 infra_ao_idx_map[] = {
- [MT8195_INFRA_RST0_THERM_CTRL_SWRST] = 0 * RST_NR_PER_BANK + 0,
- [MT8195_INFRA_RST3_THERM_CTRL_PTP_SWRST] = 3 * RST_NR_PER_BANK + 5,
- [MT8195_INFRA_RST4_THERM_CTRL_MCU_SWRST] = 4 * RST_NR_PER_BANK + 10,
-};
-
-static struct mtk_clk_rst_desc infra_ao_rst_desc = {
- .version = MTK_RST_SET_CLR,
- .rst_bank_ofs = infra_ao_rst_ofs,
- .rst_bank_nr = ARRAY_SIZE(infra_ao_rst_ofs),
- .rst_idx_map = infra_ao_idx_map,
- .rst_idx_map_nr = ARRAY_SIZE(infra_ao_idx_map),
-};
-
static const struct mtk_clk_desc infra_ao_desc = {
.clks = infra_ao_clks,
.num_clks = ARRAY_SIZE(infra_ao_clks),
- .rst_desc = &infra_ao_rst_desc,
+ .rst_name = "mt8195-infra-ao-rst",
};

static const struct of_device_id of_match_clk_mt8195_infra_ao[] = {
diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index 05a188c62119..8b0d3b3fd385 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -419,6 +419,62 @@ void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num,
}
}

+static void mtk_reset_unregister_adev(void *_adev)
+{
+ struct auxiliary_device *adev = _adev;
+
+ auxiliary_device_delete(adev);
+}
+
+static void mtk_reset_adev_release(struct device *dev)
+{
+ struct auxiliary_device *adev = to_auxiliary_dev(dev);
+
+ auxiliary_device_uninit(adev);
+
+ kfree(adev);
+}
+
+static struct auxiliary_device *mtk_reset_adev_alloc(struct device *dev, const char *name)
+{
+ struct auxiliary_device *adev;
+ int ret;
+
+ adev = kzalloc(sizeof(*adev), GFP_KERNEL);
+ if (!adev)
+ return ERR_PTR(-ENOMEM);
+
+ adev->name = name;
+ adev->dev.parent = dev;
+ adev->dev.release = mtk_reset_adev_release;
+
+ ret = auxiliary_device_init(adev);
+ if (ret) {
+ kfree(adev);
+ return ERR_PTR(ret);
+ }
+
+ return adev;
+}
+
+int mtk_reset_controller_register(struct device *dev, const char *name)
+{
+ struct auxiliary_device *adev;
+ int ret;
+
+ adev = mtk_reset_adev_alloc(dev, name);
+ if (IS_ERR(adev))
+ return PTR_ERR(adev);
+
+ ret = auxiliary_device_add(adev);
+ if (ret) {
+ auxiliary_device_uninit(adev);
+ return ret;
+ }
+
+ return devm_add_action_or_reset(dev, mtk_reset_unregister_adev, adev);
+}
+
int mtk_clk_simple_probe(struct platform_device *pdev)
{
const struct mtk_clk_desc *mcd;
@@ -444,9 +500,8 @@ int mtk_clk_simple_probe(struct platform_device *pdev)

platform_set_drvdata(pdev, clk_data);

- if (mcd->rst_desc) {
- r = mtk_register_reset_controller_with_dev(&pdev->dev,
- mcd->rst_desc);
+ if (mcd->rst_name) {
+ r = mtk_reset_controller_register(&pdev->dev, mcd->rst_name);
if (r)
goto unregister_clks;
}
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index 1b95c484d5aa..95b3893f5411 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -7,14 +7,13 @@
#ifndef __DRV_CLK_MTK_H
#define __DRV_CLK_MTK_H

+#include <linux/auxiliary_bus.h>
#include <linux/clk-provider.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/spinlock.h>
#include <linux/types.h>

-#include "reset.h"
-
#define MAX_MUX_GATE_BIT 31
#define INVALID_MUX_GATE_BIT (MAX_MUX_GATE_BIT + 1)

@@ -192,10 +191,14 @@ struct clk_hw *mtk_clk_register_ref2usb_tx(const char *name,
struct mtk_clk_desc {
const struct mtk_gate *clks;
size_t num_clks;
- const struct mtk_clk_rst_desc *rst_desc;
+ char *rst_name;
};

int mtk_clk_simple_probe(struct platform_device *pdev);
int mtk_clk_simple_remove(struct platform_device *pdev);

+int mtk_reset_controller_register(struct device *dev, const char *name);
+extern int mtk_reset_init_with_node(struct device_node *np, const char *name);
+extern void mtk_rst_remove_with_node(struct device_node *np, const char *name);
+
#endif /* __DRV_CLK_MTK_H */
diff --git a/drivers/clk/mediatek/reset.c b/drivers/clk/mediatek/reset.c
deleted file mode 100644
index 179505549a7c..000000000000
--- a/drivers/clk/mediatek/reset.c
+++ /dev/null
@@ -1,232 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * Copyright (c) 2014 MediaTek Inc.
- */
-
-#include <linux/mfd/syscon.h>
-#include <linux/module.h>
-#include <linux/of.h>
-#include <linux/platform_device.h>
-#include <linux/regmap.h>
-#include <linux/slab.h>
-
-#include "reset.h"
-
-static inline struct mtk_clk_rst_data *to_mtk_clk_rst_data(struct reset_controller_dev *rcdev)
-{
- return container_of(rcdev, struct mtk_clk_rst_data, rcdev);
-}
-
-static int mtk_reset_update(struct reset_controller_dev *rcdev,
- unsigned long id, bool deassert)
-{
- struct mtk_clk_rst_data *data = to_mtk_clk_rst_data(rcdev);
- unsigned int val = deassert ? 0 : ~0;
-
- return regmap_update_bits(data->regmap,
- data->desc->rst_bank_ofs[id / RST_NR_PER_BANK],
- BIT(id % RST_NR_PER_BANK), val);
-}
-
-static int mtk_reset_assert(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return mtk_reset_update(rcdev, id, false);
-}
-
-static int mtk_reset_deassert(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return mtk_reset_update(rcdev, id, true);
-}
-
-static int mtk_reset(struct reset_controller_dev *rcdev, unsigned long id)
-{
- int ret;
-
- ret = mtk_reset_assert(rcdev, id);
- if (ret)
- return ret;
-
- return mtk_reset_deassert(rcdev, id);
-}
-
-static int mtk_reset_update_set_clr(struct reset_controller_dev *rcdev,
- unsigned long id, bool deassert)
-{
- struct mtk_clk_rst_data *data = to_mtk_clk_rst_data(rcdev);
- unsigned int deassert_ofs = deassert ? 0x4 : 0;
-
- return regmap_write(data->regmap,
- data->desc->rst_bank_ofs[id / RST_NR_PER_BANK] +
- deassert_ofs,
- BIT(id % RST_NR_PER_BANK));
-}
-
-static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return mtk_reset_update_set_clr(rcdev, id, false);
-}
-
-static int mtk_reset_deassert_set_clr(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- return mtk_reset_update_set_clr(rcdev, id, true);
-}
-
-static int mtk_reset_set_clr(struct reset_controller_dev *rcdev,
- unsigned long id)
-{
- int ret;
-
- ret = mtk_reset_assert_set_clr(rcdev, id);
- if (ret)
- return ret;
- return mtk_reset_deassert_set_clr(rcdev, id);
-}
-
-static const struct reset_control_ops mtk_reset_ops = {
- .assert = mtk_reset_assert,
- .deassert = mtk_reset_deassert,
- .reset = mtk_reset,
-};
-
-static const struct reset_control_ops mtk_reset_ops_set_clr = {
- .assert = mtk_reset_assert_set_clr,
- .deassert = mtk_reset_deassert_set_clr,
- .reset = mtk_reset_set_clr,
-};
-
-static int reset_xlate(struct reset_controller_dev *rcdev,
- const struct of_phandle_args *reset_spec)
-{
- struct mtk_clk_rst_data *data = to_mtk_clk_rst_data(rcdev);
-
- if (reset_spec->args[0] >= rcdev->nr_resets ||
- reset_spec->args[0] >= data->desc->rst_idx_map_nr)
- return -EINVAL;
-
- return data->desc->rst_idx_map[reset_spec->args[0]];
-}
-
-int mtk_register_reset_controller(struct device_node *np,
- const struct mtk_clk_rst_desc *desc)
-{
- struct regmap *regmap;
- const struct reset_control_ops *rcops = NULL;
- struct mtk_clk_rst_data *data;
- int ret;
-
- if (!desc) {
- pr_err("mtk clock reset desc is NULL\n");
- return -EINVAL;
- }
-
- switch (desc->version) {
- case MTK_RST_SIMPLE:
- rcops = &mtk_reset_ops;
- break;
- case MTK_RST_SET_CLR:
- rcops = &mtk_reset_ops_set_clr;
- break;
- default:
- pr_err("Unknown reset version %d\n", desc->version);
- return -EINVAL;
- }
-
- regmap = device_node_to_regmap(np);
- if (IS_ERR(regmap)) {
- pr_err("Cannot find regmap for %pOF: %pe\n", np, regmap);
- return -EINVAL;
- }
-
- data = kzalloc(sizeof(*data), GFP_KERNEL);
- if (!data)
- return -ENOMEM;
-
- data->desc = desc;
- data->regmap = regmap;
- data->rcdev.owner = THIS_MODULE;
- data->rcdev.ops = rcops;
- data->rcdev.of_node = np;
-
- if (data->desc->rst_idx_map_nr > 0) {
- data->rcdev.of_reset_n_cells = 1;
- data->rcdev.nr_resets = desc->rst_idx_map_nr;
- data->rcdev.of_xlate = reset_xlate;
- } else {
- data->rcdev.nr_resets = desc->rst_bank_nr * RST_NR_PER_BANK;
- }
-
- ret = reset_controller_register(&data->rcdev);
- if (ret) {
- pr_err("could not register reset controller: %d\n", ret);
- kfree(data);
- return ret;
- }
-
- return 0;
-}
-
-int mtk_register_reset_controller_with_dev(struct device *dev,
- const struct mtk_clk_rst_desc *desc)
-{
- struct device_node *np = dev->of_node;
- struct regmap *regmap;
- const struct reset_control_ops *rcops = NULL;
- struct mtk_clk_rst_data *data;
- int ret;
-
- if (!desc) {
- dev_err(dev, "mtk clock reset desc is NULL\n");
- return -EINVAL;
- }
-
- switch (desc->version) {
- case MTK_RST_SIMPLE:
- rcops = &mtk_reset_ops;
- break;
- case MTK_RST_SET_CLR:
- rcops = &mtk_reset_ops_set_clr;
- break;
- default:
- dev_err(dev, "Unknown reset version %d\n", desc->version);
- return -EINVAL;
- }
-
- regmap = device_node_to_regmap(np);
- if (IS_ERR(regmap)) {
- dev_err(dev, "Cannot find regmap %pe\n", regmap);
- return -EINVAL;
- }
-
- data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
- if (!data)
- return -ENOMEM;
-
- data->desc = desc;
- data->regmap = regmap;
- data->rcdev.owner = THIS_MODULE;
- data->rcdev.ops = rcops;
- data->rcdev.of_node = np;
- data->rcdev.dev = dev;
-
- if (data->desc->rst_idx_map_nr > 0) {
- data->rcdev.of_reset_n_cells = 1;
- data->rcdev.nr_resets = desc->rst_idx_map_nr;
- data->rcdev.of_xlate = reset_xlate;
- } else {
- data->rcdev.nr_resets = desc->rst_bank_nr * RST_NR_PER_BANK;
- }
-
- ret = devm_reset_controller_register(dev, &data->rcdev);
- if (ret) {
- dev_err(dev, "could not register reset controller: %d\n", ret);
- return ret;
- }
-
- return 0;
-}
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/clk/mediatek/reset.h b/drivers/clk/mediatek/reset.h
deleted file mode 100644
index 6a58a3d59165..000000000000
--- a/drivers/clk/mediatek/reset.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * Copyright (c) 2022 MediaTek Inc.
- */
-
-#ifndef __DRV_CLK_MTK_RESET_H
-#define __DRV_CLK_MTK_RESET_H
-
-#include <linux/reset-controller.h>
-#include <linux/types.h>
-
-#define RST_NR_PER_BANK 32
-
-/* Infra global controller reset set register */
-#define INFRA_RST0_SET_OFFSET 0x120
-#define INFRA_RST1_SET_OFFSET 0x130
-#define INFRA_RST2_SET_OFFSET 0x140
-#define INFRA_RST3_SET_OFFSET 0x150
-#define INFRA_RST4_SET_OFFSET 0x730
-
-/**
- * enum mtk_reset_version - Version of MediaTek clock reset controller.
- * @MTK_RST_SIMPLE: Use the same registers for bit set and clear.
- * @MTK_RST_SET_CLR: Use separate registers for bit set and clear.
- * @MTK_RST_MAX: Total quantity of version for MediaTek clock reset controller.
- */
-enum mtk_reset_version {
- MTK_RST_SIMPLE = 0,
- MTK_RST_SET_CLR,
- MTK_RST_MAX,
-};
-
-/**
- * struct mtk_clk_rst_desc - Description of MediaTek clock reset.
- * @version: Reset version which is defined in enum mtk_reset_version.
- * @rst_bank_ofs: Pointer to an array containing base offsets of the reset register.
- * @rst_bank_nr: Quantity of reset bank.
- * @rst_idx_map:Pointer to an array containing ids if input argument is index.
- * This array is not necessary if our input argument does not mean index.
- * @rst_idx_map_nr: Quantity of reset index map.
- */
-struct mtk_clk_rst_desc {
- enum mtk_reset_version version;
- u16 *rst_bank_ofs;
- u32 rst_bank_nr;
- u16 *rst_idx_map;
- u32 rst_idx_map_nr;
-};
-
-/**
- * struct mtk_clk_rst_data - Data of MediaTek clock reset controller.
- * @regmap: Pointer to base address of reset register address.
- * @rcdev: Reset controller device.
- * @desc: Pointer to description of the reset controller.
- */
-struct mtk_clk_rst_data {
- struct regmap *regmap;
- struct reset_controller_dev rcdev;
- const struct mtk_clk_rst_desc *desc;
-};
-
-/**
- * mtk_register_reset_controller - Register MediaTek clock reset controller
- * @np: Pointer to device node.
- * @desc: Constant pointer to description of clock reset.
- *
- * Return: 0 on success and errorno otherwise.
- */
-int mtk_register_reset_controller(struct device_node *np,
- const struct mtk_clk_rst_desc *desc);
-
-/**
- * mtk_register_reset_controller - Register mediatek clock reset controller with device
- * @np: Pointer to device.
- * @desc: Constant pointer to description of clock reset.
- *
- * Return: 0 on success and errorno otherwise.
- */
-int mtk_register_reset_controller_with_dev(struct device *dev,
- const struct mtk_clk_rst_desc *desc);
-
-#endif /* __DRV_CLK_MTK_RESET_H */
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index 806773e88832..81231153e7f1 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -122,6 +122,13 @@ config RESET_MCHP_SPARX5
help
This driver supports switch core reset for the Microchip Sparx5 SoC.

+config RESET_MEDIATEK_SYSCLK
+ tristate "MediaTek System Clock Reset Driver"
+ depends on ARM || ARM64 || COMPILE_TEST
+ depends on AUXILIARY_BUS
+ help
+ This enables the system clock reset driver for MediaTek SoCs.
+
config RESET_MESON
tristate "Meson Reset Driver"
depends on ARCH_MESON || COMPILE_TEST
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index cd5cf8e7c6a7..2707511aaf5b 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_RESET_K210) += reset-k210.o
obj-$(CONFIG_RESET_LANTIQ) += reset-lantiq.o
obj-$(CONFIG_RESET_LPC18XX) += reset-lpc18xx.o
obj-$(CONFIG_RESET_MCHP_SPARX5) += reset-microchip-sparx5.o
+obj-$(CONFIG_RESET_MEDIATEK_SYSCLK) += reset-mediatek-sysclk.o
obj-$(CONFIG_RESET_MESON) += reset-meson.o
obj-$(CONFIG_RESET_MESON_AUDIO_ARB) += reset-meson-audio-arb.o
obj-$(CONFIG_RESET_NPCM) += reset-npcm.o
diff --git a/drivers/reset/reset-mediatek-sysclk.c b/drivers/reset/reset-mediatek-sysclk.c
new file mode 100644
index 000000000000..78194774d13d
--- /dev/null
+++ b/drivers/reset/reset-mediatek-sysclk.c
@@ -0,0 +1,578 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2022 MediaTek Inc.
+ */
+
+#include <linux/auxiliary_bus.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/reset-controller.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+
+#include <dt-bindings/reset/mt8186-resets.h>
+#include <dt-bindings/reset/mt8192-resets.h>
+#include <dt-bindings/reset/mt8195-resets.h>
+
+#define RST_NR_PER_BANK 32
+
+ /* Infra global controller reset set register */
+#define INFRA_RST0_SET_OFFSET 0x120
+#define INFRA_RST1_SET_OFFSET 0x130
+#define INFRA_RST2_SET_OFFSET 0x140
+#define INFRA_RST3_SET_OFFSET 0x150
+#define INFRA_RST4_SET_OFFSET 0x730
+
+enum {
+ MTK_RST_ID_MT2701_ETH = 0,
+ MTK_RST_ID_MT2701_G3D,
+ MTK_RST_ID_MT2701_HIF,
+ MTK_RST_ID_MT2701_INFRASYS,
+ MTK_RST_ID_MT2701_PERICFG,
+ MTK_RST_ID_MT2712_INFRA,
+ MTK_RST_ID_MT2712_PERI,
+ MTK_RST_ID_MT7622_ETH,
+ MTK_RST_ID_MT7622_SSUSBSYS,
+ MTK_RST_ID_MT7622_PCIESYS,
+ MTK_RST_ID_MT7622_INFRASYS,
+ MTK_RST_ID_MT7622_PERICFG,
+ MTK_RST_ID_MT7629_ETHSYS,
+ MTK_RST_ID_MT7629_SSUSBSYS,
+ MTK_RST_ID_MT7629_PCIESYS,
+ MTK_RST_ID_MT8135_INFRASYS,
+ MTK_RST_ID_MT8135_PERICFG,
+ MTK_RST_ID_MT8173_INFRACFG,
+ MTK_RST_ID_MT8173_PERICFG,
+ MTK_RST_ID_MT8183_INFRA,
+ MTK_RST_ID_MT8186_INFRA_AO,
+ MTK_RST_ID_MT8192_INFRA,
+ MTK_RST_ID_MT8195_INFRA_AO,
+ MTK_RST_ID_MAX,
+};
+
+/**
+ * enum mtk_reset_version - Version of MediaTek clock reset controller.
+ * @MTK_RST_SIMPLE: Use the same registers for bit set and clear.
+ * @MTK_RST_SET_CLR: Use separate registers for bit set and clear.
+ * @MTK_RST_MAX: Total quantity of version for MediaTek clock reset controller.
+ */
+enum mtk_reset_version {
+ MTK_RST_SIMPLE = 0,
+ MTK_RST_SET_CLR,
+ MTK_RST_MAX,
+};
+
+/**
+ * struct mtk_clk_rst_desc - Description of MediaTek clock reset.
+ * @version: Reset version which is defined in enum mtk_reset_version.
+ * @rst_bank_ofs: Pointer to an array containing base offsets of the reset register.
+ * @rst_bank_nr: Quantity of reset bank.
+ * @rst_idx_map:Pointer to an array containing ids if input argument is index.
+ * This array is not necessary if our input argument does not mean index.
+ * @rst_idx_map_nr: Quantity of reset index map.
+ */
+struct mtk_clk_rst_desc {
+ u8 version;
+ u16 *rst_bank_ofs;
+ u32 rst_bank_nr;
+ u16 *rst_idx_map;
+ u32 rst_idx_map_nr;
+};
+
+/**
+ * struct mtk_clk_rst_data - Data of MediaTek clock reset controller.
+ * @regmap: Pointer to base address of reset register address.
+ * @rcdev: Reset controller device.
+ * @desc: Pointer to description of the reset controller.
+ */
+struct mtk_clk_rst_data {
+ struct regmap *regmap;
+ struct reset_controller_dev rcdev;
+ const struct mtk_clk_rst_desc *desc;
+};
+
+static inline struct mtk_clk_rst_data *to_mtk_clk_rst_data(struct reset_controller_dev *rcdev)
+{
+ return container_of(rcdev, struct mtk_clk_rst_data, rcdev);
+}
+
+static int mtk_reset_update(struct reset_controller_dev *rcdev,
+ unsigned long id, bool deassert)
+{
+ struct mtk_clk_rst_data *data = to_mtk_clk_rst_data(rcdev);
+ unsigned int val = deassert ? 0 : ~0;
+
+ return regmap_update_bits(data->regmap,
+ data->desc->rst_bank_ofs[id / RST_NR_PER_BANK],
+ BIT(id % RST_NR_PER_BANK), val);
+}
+
+static int mtk_reset_assert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return mtk_reset_update(rcdev, id, false);
+}
+
+static int mtk_reset_deassert(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return mtk_reset_update(rcdev, id, true);
+}
+
+static int mtk_reset(struct reset_controller_dev *rcdev, unsigned long id)
+{
+ int ret;
+
+ ret = mtk_reset_assert(rcdev, id);
+ if (ret)
+ return ret;
+
+ return mtk_reset_deassert(rcdev, id);
+}
+
+static int mtk_reset_update_set_clr(struct reset_controller_dev *rcdev,
+ unsigned long id, bool deassert)
+{
+ struct mtk_clk_rst_data *data = to_mtk_clk_rst_data(rcdev);
+ unsigned int deassert_ofs = deassert ? 0x4 : 0;
+
+ return regmap_write(data->regmap,
+ data->desc->rst_bank_ofs[id / RST_NR_PER_BANK] +
+ deassert_ofs,
+ BIT(id % RST_NR_PER_BANK));
+}
+
+static int mtk_reset_assert_set_clr(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return mtk_reset_update_set_clr(rcdev, id, false);
+}
+
+static int mtk_reset_deassert_set_clr(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ return mtk_reset_update_set_clr(rcdev, id, true);
+}
+
+static int mtk_reset_set_clr(struct reset_controller_dev *rcdev,
+ unsigned long id)
+{
+ int ret;
+
+ ret = mtk_reset_assert_set_clr(rcdev, id);
+ if (ret)
+ return ret;
+ return mtk_reset_deassert_set_clr(rcdev, id);
+}
+
+static const struct reset_control_ops mtk_reset_ops = {
+ .assert = mtk_reset_assert,
+ .deassert = mtk_reset_deassert,
+ .reset = mtk_reset,
+};
+
+static const struct reset_control_ops mtk_reset_ops_set_clr = {
+ .assert = mtk_reset_assert_set_clr,
+ .deassert = mtk_reset_deassert_set_clr,
+ .reset = mtk_reset_set_clr,
+};
+
+static int reset_xlate(struct reset_controller_dev *rcdev,
+ const struct of_phandle_args *reset_spec)
+{
+ struct mtk_clk_rst_data *data = to_mtk_clk_rst_data(rcdev);
+
+ if (reset_spec->args[0] >= rcdev->nr_resets ||
+ reset_spec->args[0] >= data->desc->rst_idx_map_nr)
+ return -EINVAL;
+
+ return data->desc->rst_idx_map[reset_spec->args[0]];
+}
+
+static int register_rst_ctrl_with_node(struct device_node *np, struct mtk_clk_rst_data *data)
+{
+ struct regmap *regmap;
+ const struct reset_control_ops *rcops = NULL;
+ int ret;
+
+ if (!data) {
+ pr_err("invalid mtk clock reset data\n");
+ return -EINVAL;
+ }
+
+ switch (data->desc->version) {
+ case MTK_RST_SIMPLE:
+ rcops = &mtk_reset_ops;
+ break;
+ case MTK_RST_SET_CLR:
+ rcops = &mtk_reset_ops_set_clr;
+ break;
+ default:
+ pr_err("Unknown reset version %d\n", data->desc->version);
+ return -EINVAL;
+ }
+
+ regmap = device_node_to_regmap(np);
+ if (IS_ERR(regmap)) {
+ pr_err("Cannot find regmap for %pOF: %pe\n", np, regmap);
+ return -EINVAL;
+ }
+
+ data->regmap = regmap;
+ data->rcdev.owner = THIS_MODULE;
+ data->rcdev.ops = rcops;
+ data->rcdev.of_node = np;
+
+ if (data->desc->rst_idx_map_nr > 0) {
+ data->rcdev.of_reset_n_cells = 1;
+ data->rcdev.nr_resets = data->desc->rst_idx_map_nr;
+ data->rcdev.of_xlate = reset_xlate;
+ } else {
+ data->rcdev.nr_resets = data->desc->rst_bank_nr * RST_NR_PER_BANK;
+ }
+
+ ret = reset_controller_register(&data->rcdev);
+ if (ret) {
+ pr_err("could not register reset controller: %d\n", ret);
+ kfree(data);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int register_rst_ctrl_with_dev(struct device *dev, struct mtk_clk_rst_data *data)
+{
+ struct device_node *np = dev->of_node;
+ struct regmap *regmap;
+ const struct reset_control_ops *rcops = NULL;
+ int ret;
+
+ if (!data) {
+ dev_err(dev, "invalid mtk clock reset data\n");
+ return -EINVAL;
+ }
+
+ switch (data->desc->version) {
+ case MTK_RST_SIMPLE:
+ rcops = &mtk_reset_ops;
+ break;
+ case MTK_RST_SET_CLR:
+ rcops = &mtk_reset_ops_set_clr;
+ break;
+ default:
+ dev_err(dev, "Unknown reset version %d\n", data->desc->version);
+ return -EINVAL;
+ }
+
+ regmap = device_node_to_regmap(np);
+ if (IS_ERR(regmap)) {
+ dev_err(dev, "Cannot find regmap %pe\n", regmap);
+ return -EINVAL;
+ }
+
+ data->regmap = regmap;
+ data->rcdev.owner = THIS_MODULE;
+ data->rcdev.ops = rcops;
+ data->rcdev.of_node = np;
+ data->rcdev.dev = dev;
+
+ if (data->desc->rst_idx_map_nr > 0) {
+ data->rcdev.of_reset_n_cells = 1;
+ data->rcdev.nr_resets = data->desc->rst_idx_map_nr;
+ data->rcdev.of_xlate = reset_xlate;
+ } else {
+ data->rcdev.nr_resets = data->desc->rst_bank_nr * RST_NR_PER_BANK;
+ }
+
+ ret = devm_reset_controller_register(dev, &data->rcdev);
+ if (ret) {
+ dev_err(dev, "could not register reset controller: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+/* array of reset offset */
+static u16 mt2701_eth_rst_ofs[] = { 0x34, };
+static u16 mt2701_g3d_rst_ofs[] = { 0xc, };
+static u16 mt2701_infrasys_rst_ofs[] = { 0x30, 0x34, };
+static u16 mt2701_pericfg_rst_ofs[] = { 0x0, 0x4, };
+static u16 mt7622_infrasys_rst_ofs[] = { 0x30, };
+
+static u16 mt8183_infra_ao_rst_ofs[] = {
+ INFRA_RST0_SET_OFFSET,
+ INFRA_RST1_SET_OFFSET,
+ INFRA_RST2_SET_OFFSET,
+ INFRA_RST3_SET_OFFSET,
+};
+
+static u16 mt8192_infra_ao_rst_ofs[] = {
+ INFRA_RST0_SET_OFFSET,
+ INFRA_RST1_SET_OFFSET,
+ INFRA_RST2_SET_OFFSET,
+ INFRA_RST3_SET_OFFSET,
+ INFRA_RST4_SET_OFFSET,
+};
+
+/* array of reset index mapping */
+static u16 mt8192_infra_ao_idx_map[] = {
+ [MT8192_INFRA_RST0_THERM_CTRL_SWRST] = 0 * RST_NR_PER_BANK + 0,
+ [MT8192_INFRA_RST2_PEXTP_PHY_SWRST] = 2 * RST_NR_PER_BANK + 15,
+ [MT8192_INFRA_RST3_THERM_CTRL_PTP_SWRST] = 3 * RST_NR_PER_BANK + 5,
+ [MT8192_INFRA_RST4_PCIE_TOP_SWRST] = 4 * RST_NR_PER_BANK + 1,
+ [MT8192_INFRA_RST4_THERM_CTRL_MCU_SWRST] = 4 * RST_NR_PER_BANK + 12,
+};
+
+static u16 mt8186_infra_ao_idx_map[] = {
+ [MT8186_INFRA_THERMAL_CTRL_RST] = 0 * RST_NR_PER_BANK + 0,
+ [MT8186_INFRA_PTP_CTRL_RST] = 1 * RST_NR_PER_BANK + 0,
+};
+
+static u16 mt8195_infra_ao_idx_map[] = {
+ [MT8195_INFRA_RST0_THERM_CTRL_SWRST] = 0 * RST_NR_PER_BANK + 0,
+ [MT8195_INFRA_RST3_THERM_CTRL_PTP_SWRST] = 3 * RST_NR_PER_BANK + 5,
+ [MT8195_INFRA_RST4_THERM_CTRL_MCU_SWRST] = 4 * RST_NR_PER_BANK + 10,
+};
+
+/* reset description */
+static const struct mtk_clk_rst_desc mt2701_eth_rst_desc = {
+ .version = MTK_RST_SIMPLE,
+ .rst_bank_ofs = mt2701_eth_rst_ofs,
+ .rst_bank_nr = ARRAY_SIZE(mt2701_eth_rst_ofs),
+};
+
+static const struct mtk_clk_rst_desc mt2701_g3d_clk_rst_desc = {
+ .version = MTK_RST_SIMPLE,
+ .rst_bank_ofs = mt2701_g3d_rst_ofs,
+ .rst_bank_nr = ARRAY_SIZE(mt2701_g3d_rst_ofs),
+};
+
+static const struct mtk_clk_rst_desc mt2701_infrasys_clk_rst_desc = {
+ .version = MTK_RST_SIMPLE,
+ .rst_bank_ofs = mt2701_infrasys_rst_ofs,
+ .rst_bank_nr = ARRAY_SIZE(mt2701_infrasys_rst_ofs),
+};
+
+static const struct mtk_clk_rst_desc mt2701_pericfg_clk_rst_desc = {
+ .version = MTK_RST_SIMPLE,
+ .rst_bank_ofs = mt2701_pericfg_rst_ofs,
+ .rst_bank_nr = ARRAY_SIZE(mt2701_pericfg_rst_ofs),
+};
+
+static const struct mtk_clk_rst_desc mt7622_infrasys_clk_rst_desc = {
+ .version = MTK_RST_SIMPLE,
+ .rst_bank_ofs = mt7622_infrasys_rst_ofs,
+ .rst_bank_nr = ARRAY_SIZE(mt7622_infrasys_rst_ofs),
+};
+
+static struct mtk_clk_rst_desc mt8183_rst_desc = {
+ .version = MTK_RST_SET_CLR,
+ .rst_bank_ofs = mt8183_infra_ao_rst_ofs,
+ .rst_bank_nr = ARRAY_SIZE(mt8183_infra_ao_rst_ofs),
+};
+
+static struct mtk_clk_rst_desc mt8186_rst_desc = {
+ .version = MTK_RST_SET_CLR,
+ .rst_bank_ofs = mt8183_infra_ao_rst_ofs,
+ .rst_bank_nr = ARRAY_SIZE(mt8183_infra_ao_rst_ofs),
+ .rst_idx_map = mt8186_infra_ao_idx_map,
+ .rst_idx_map_nr = ARRAY_SIZE(mt8186_infra_ao_idx_map),
+};
+
+static struct mtk_clk_rst_desc mt8192_rst_desc = {
+ .version = MTK_RST_SET_CLR,
+ .rst_bank_ofs = mt8192_infra_ao_rst_ofs,
+ .rst_bank_nr = ARRAY_SIZE(mt8192_infra_ao_rst_ofs),
+ .rst_idx_map = mt8192_infra_ao_idx_map,
+ .rst_idx_map_nr = ARRAY_SIZE(mt8192_infra_ao_idx_map),
+};
+
+static struct mtk_clk_rst_desc mt8195_rst_desc = {
+ .version = MTK_RST_SET_CLR,
+ .rst_bank_ofs = mt8192_infra_ao_rst_ofs,
+ .rst_bank_nr = ARRAY_SIZE(mt8192_infra_ao_rst_ofs),
+ .rst_idx_map = mt8195_infra_ao_idx_map,
+ .rst_idx_map_nr = ARRAY_SIZE(mt8195_infra_ao_idx_map),
+};
+
+static struct auxiliary_device_id mtk_sysclk_reset_ids[] = {
+ {
+ .name = "clk_mt2701_eth.mt2701-eth-rst",
+ .driver_data = MTK_RST_ID_MT2701_ETH,
+ },
+ {
+ .name = "clk_mt2701_g3d.mt2701-g3d-rst",
+ .driver_data = MTK_RST_ID_MT2701_G3D,
+ },
+ {
+ .name = "clk_mt2701_hif.mt2701-hif-rst",
+ .driver_data = MTK_RST_ID_MT2701_HIF,
+ },
+ {
+ .name = "clk_mt2701.mt2701-infrasys-rst",
+ .driver_data = MTK_RST_ID_MT2701_INFRASYS,
+ },
+ {
+ .name = "clk_mt2701.mt2701-pericfg-rst",
+ .driver_data = MTK_RST_ID_MT2701_PERICFG,
+ },
+ {
+ .name = "clk_mt2712.mt2712-infra-rst",
+ .driver_data = MTK_RST_ID_MT2712_INFRA,
+ },
+ {
+ .name = "clk_mt2712.mt2712-peri-rst",
+ .driver_data = MTK_RST_ID_MT2712_PERI,
+ },
+ {
+ .name = "clk_mt7622_eth.mt7622-eth-rst",
+ .driver_data = MTK_RST_ID_MT7622_ETH,
+ },
+ {
+ .name = "clk_mt7622_hif.mt7622-usb-rst",
+ .driver_data = MTK_RST_ID_MT7622_SSUSBSYS,
+ },
+ {
+ .name = "clk_mt7622_hif.mt7622-pcie-rst",
+ .driver_data = MTK_RST_ID_MT7622_PCIESYS,
+ },
+ {
+ .name = "clk_mt7622.mt7622-infrasys-rst",
+ .driver_data = MTK_RST_ID_MT7622_INFRASYS,
+ },
+ {
+ .name = "clk_mt7622.mt7622-pericfg-rst",
+ .driver_data = MTK_RST_ID_MT7622_PERICFG,
+ },
+ {
+ .name = "clk_mt7629_eth.mt7629-ethsys-rst",
+ .driver_data = MTK_RST_ID_MT7629_ETHSYS,
+ },
+ {
+ .name = "clk_mt7629_hif.mt7629-usb-rst",
+ .driver_data = MTK_RST_ID_MT7629_SSUSBSYS,
+ },
+ {
+ .name = "clk_mt7629_hif.mt7629-pcie-rst",
+ .driver_data = MTK_RST_ID_MT7629_PCIESYS,
+ },
+ {
+ .name = "clk_mt8135.mt8135-infrasys-rst",
+ .driver_data = MTK_RST_ID_MT8135_INFRASYS,
+ },
+ {
+ .name = "clk_mt8135.mt8135-pericfg-rst",
+ .driver_data = MTK_RST_ID_MT8135_PERICFG,
+ },
+ {
+ .name = "clk_mt8173.mt8173-infracfg-rst",
+ .driver_data = MTK_RST_ID_MT8173_INFRACFG,
+ },
+ {
+ .name = "clk_mt8173.mt8173-pericfg-rst",
+ .driver_data = MTK_RST_ID_MT8173_PERICFG,
+ },
+ {
+ .name = "clk_mt8183.mt8183-infra-rst",
+ .driver_data = MTK_RST_ID_MT8183_INFRA,
+ },
+ {
+ .name = "clk_mtk.mt8186-infra-ao-rst",
+ .driver_data = MTK_RST_ID_MT8186_INFRA_AO,
+ },
+ {
+ .name = "clk_mt8192.mt8192-infra-rst",
+ .driver_data = MTK_RST_ID_MT8192_INFRA,
+ },
+ {
+ .name = "clk_mtk.mt8195-infra-ao-rst",
+ .driver_data = MTK_RST_ID_MT8195_INFRA_AO,
+ },
+ {
+ },
+};
+MODULE_DEVICE_TABLE(auxiliary, mtk_reset_ids);
+
+/* reset data */
+static struct mtk_clk_rst_data clk_rst_data[] = {
+ [MTK_RST_ID_MT2701_ETH] = { .desc = &mt2701_eth_rst_desc, },
+ [MTK_RST_ID_MT2701_G3D] = { .desc = &mt2701_g3d_clk_rst_desc, },
+ [MTK_RST_ID_MT2701_HIF] = { .desc = &mt2701_eth_rst_desc, },
+ [MTK_RST_ID_MT2701_INFRASYS] = { .desc = &mt2701_infrasys_clk_rst_desc, },
+ [MTK_RST_ID_MT2701_PERICFG] = { .desc = &mt2701_pericfg_clk_rst_desc, },
+ [MTK_RST_ID_MT2712_INFRA] = { .desc = &mt2701_infrasys_clk_rst_desc, },
+ [MTK_RST_ID_MT2712_PERI] = { .desc = &mt2701_pericfg_clk_rst_desc, },
+ [MTK_RST_ID_MT7622_ETH] = { .desc = &mt2701_eth_rst_desc, },
+ [MTK_RST_ID_MT7622_SSUSBSYS] = { .desc = &mt2701_eth_rst_desc, },
+ [MTK_RST_ID_MT7622_PCIESYS] = { .desc = &mt2701_eth_rst_desc, },
+ [MTK_RST_ID_MT7622_INFRASYS] = { .desc = &mt7622_infrasys_clk_rst_desc, },
+ [MTK_RST_ID_MT7622_PERICFG] = { .desc = &mt2701_pericfg_clk_rst_desc, },
+ [MTK_RST_ID_MT7629_ETHSYS] = { .desc = &mt2701_eth_rst_desc, },
+ [MTK_RST_ID_MT7629_SSUSBSYS] = { .desc = &mt2701_eth_rst_desc, },
+ [MTK_RST_ID_MT7629_PCIESYS] = { .desc = &mt2701_eth_rst_desc, },
+ [MTK_RST_ID_MT8135_INFRASYS] = { .desc = &mt2701_infrasys_clk_rst_desc, },
+ [MTK_RST_ID_MT8135_PERICFG] = { .desc = &mt2701_pericfg_clk_rst_desc, },
+ [MTK_RST_ID_MT8173_INFRACFG] = { .desc = &mt2701_infrasys_clk_rst_desc, },
+ [MTK_RST_ID_MT8173_PERICFG] = { .desc = &mt2701_pericfg_clk_rst_desc, },
+ [MTK_RST_ID_MT8183_INFRA] = { .desc = &mt8183_rst_desc, },
+ [MTK_RST_ID_MT8186_INFRA_AO] = { .desc = &mt8186_rst_desc, },
+ [MTK_RST_ID_MT8192_INFRA] = { .desc = &mt8192_rst_desc, },
+ [MTK_RST_ID_MT8195_INFRA_AO] = { .desc = &mt8195_rst_desc, },
+ {},
+};
+
+static struct mtk_clk_rst_data *find_rst_data(const char *name)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(mtk_sysclk_reset_ids); i++)
+ if (mtk_sysclk_reset_ids[i].name == name)
+ return &clk_rst_data[mtk_sysclk_reset_ids[i].driver_data];
+ return NULL;
+}
+
+int mtk_reset_init_with_node(struct device_node *np, const char *name)
+{
+ struct mtk_clk_rst_data *data = find_rst_data(name);
+
+ if (!np || !data)
+ return -EINVAL;
+
+ return register_rst_ctrl_with_node(np, data);
+}
+EXPORT_SYMBOL_GPL(mtk_reset_init_with_node);
+
+void mtk_rst_remove_with_node(struct device_node *np, const char *name)
+{
+ struct mtk_clk_rst_data *data = find_rst_data(name);
+
+ if (!np || !data)
+ return;
+
+ reset_controller_unregister(&data->rcdev);
+}
+EXPORT_SYMBOL_GPL(mtk_rst_remove_with_node);
+
+static int mtk_sysclk_reset_probe(struct auxiliary_device *adev,
+ const struct auxiliary_device_id *id)
+{
+ if (id->driver_data >= MTK_RST_ID_MAX)
+ return -EINVAL;
+
+ return register_rst_ctrl_with_dev(adev->dev.parent, &clk_rst_data[id->driver_data]);
+}
+
+static struct auxiliary_driver mtk_sysclk_reset_driver = {
+ .probe = mtk_sysclk_reset_probe,
+ .id_table = mtk_sysclk_reset_ids,
+};
+module_auxiliary_driver(mtk_sysclk_reset_driver);
+
+MODULE_DESCRIPTION("MediaTek System Clock Reset Driver");
+MODULE_AUTHOR("Bo-Chen Chen <[email protected]>");
+MODULE_LICENSE("GPL");
--
2.18.0


2022-09-23 01:41:56

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] reset: mediatek: Move mediatek system clock reset to reset folder

Hi Bo-Chen,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v6.0-rc6]
[also build test WARNING on linus/master]
[cannot apply to clk/clk-next pza/reset/next mbgg-mediatek/for-next next-20220921]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Bo-Chen-Chen/reset-mediatek-Move-mediatek-system-clock-reset-to-reset-folder/20220922-221303
base: 521a547ced6477c54b4b0cc206000406c221b4d6
config: s390-randconfig-r044-20220922 (https://download.01.org/0day-ci/archive/20220923/[email protected]/config)
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 791a7ae1ba3efd6bca96338e10ffde557ba83920)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/69ce72445492a02115b1e7c7527a8a107f48aab8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Bo-Chen-Chen/reset-mediatek-Move-mediatek-system-clock-reset-to-reset-folder/20220922-221303
git checkout 69ce72445492a02115b1e7c7527a8a107f48aab8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash drivers/reset/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All warnings (new ones prefixed by >>):

In file included from drivers/reset/reset-mediatek-sysclk.c:11:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __raw_readb(PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:37:59: note: expanded from macro '__le16_to_cpu'
#define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
^
include/uapi/linux/swab.h:102:54: note: expanded from macro '__swab16'
#define __swab16(x) (__u16)__builtin_bswap16((__u16)(x))
^
In file included from drivers/reset/reset-mediatek-sysclk.c:11:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
~~~~~~~~~~ ^
include/uapi/linux/byteorder/big_endian.h:35:59: note: expanded from macro '__le32_to_cpu'
#define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
^
include/uapi/linux/swab.h:115:54: note: expanded from macro '__swab32'
#define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
^
In file included from drivers/reset/reset-mediatek-sysclk.c:11:
In file included from include/linux/regmap.h:20:
In file included from include/linux/iopoll.h:14:
In file included from include/linux/io.h:13:
In file included from arch/s390/include/asm/io.h:75:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writeb(value, PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
readsl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesb(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesw(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
writesl(PCI_IOBASE + addr, buffer, count);
~~~~~~~~~~ ^
>> drivers/reset/reset-mediatek-sysclk.c:539:5: warning: no previous prototype for function 'mtk_reset_init_with_node' [-Wmissing-prototypes]
int mtk_reset_init_with_node(struct device_node *np, const char *name)
^
drivers/reset/reset-mediatek-sysclk.c:539:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int mtk_reset_init_with_node(struct device_node *np, const char *name)
^
static
>> drivers/reset/reset-mediatek-sysclk.c:550:6: warning: no previous prototype for function 'mtk_rst_remove_with_node' [-Wmissing-prototypes]
void mtk_rst_remove_with_node(struct device_node *np, const char *name)
^
drivers/reset/reset-mediatek-sysclk.c:550:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void mtk_rst_remove_with_node(struct device_node *np, const char *name)
^
static
14 warnings generated.


vim +/mtk_reset_init_with_node +539 drivers/reset/reset-mediatek-sysclk.c

538
> 539 int mtk_reset_init_with_node(struct device_node *np, const char *name)
540 {
541 struct mtk_clk_rst_data *data = find_rst_data(name);
542
543 if (!np || !data)
544 return -EINVAL;
545
546 return register_rst_ctrl_with_node(np, data);
547 }
548 EXPORT_SYMBOL_GPL(mtk_reset_init_with_node);
549
> 550 void mtk_rst_remove_with_node(struct device_node *np, const char *name)
551 {
552 struct mtk_clk_rst_data *data = find_rst_data(name);
553
554 if (!np || !data)
555 return;
556
557 reset_controller_unregister(&data->rcdev);
558 }
559 EXPORT_SYMBOL_GPL(mtk_rst_remove_with_node);
560

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-09-23 02:20:46

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] reset: mediatek: Move mediatek system clock reset to reset folder

Hi Bo-Chen,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v6.0-rc6]
[also build test ERROR on linus/master]
[cannot apply to clk/clk-next pza/reset/next mbgg-mediatek/for-next next-20220921]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Bo-Chen-Chen/reset-mediatek-Move-mediatek-system-clock-reset-to-reset-folder/20220922-221303
base: 521a547ced6477c54b4b0cc206000406c221b4d6
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20220923/[email protected]/config)
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/69ce72445492a02115b1e7c7527a8a107f48aab8
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Bo-Chen-Chen/reset-mediatek-Move-mediatek-system-clock-reset-to-reset-folder/20220922-221303
git checkout 69ce72445492a02115b1e7c7527a8a107f48aab8
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>

All error/warnings (new ones prefixed by >>):

In file included from include/linux/device/driver.h:21,
from include/linux/device.h:32,
from include/linux/auxiliary_bus.h:11,
from drivers/reset/reset-mediatek-sysclk.c:6:
>> drivers/reset/reset-mediatek-sysclk.c:499:32: error: 'mtk_reset_ids' undeclared here (not in a function); did you mean 'mtk_reset_ops'?
499 | MODULE_DEVICE_TABLE(auxiliary, mtk_reset_ids);
| ^~~~~~~~~~~~~
include/linux/module.h:244:15: note: in definition of macro 'MODULE_DEVICE_TABLE'
244 | extern typeof(name) __mod_##type##__##name##_device_table \
| ^~~~
>> drivers/reset/reset-mediatek-sysclk.c:539:5: warning: no previous prototype for 'mtk_reset_init_with_node' [-Wmissing-prototypes]
539 | int mtk_reset_init_with_node(struct device_node *np, const char *name)
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/reset/reset-mediatek-sysclk.c:550:6: warning: no previous prototype for 'mtk_rst_remove_with_node' [-Wmissing-prototypes]
550 | void mtk_rst_remove_with_node(struct device_node *np, const char *name)
| ^~~~~~~~~~~~~~~~~~~~~~~~
>> include/linux/module.h:244:21: error: '__mod_auxiliary__mtk_reset_ids_device_table' aliased to undefined symbol 'mtk_reset_ids'
244 | extern typeof(name) __mod_##type##__##name##_device_table \
| ^~~~~~
drivers/reset/reset-mediatek-sysclk.c:499:1: note: in expansion of macro 'MODULE_DEVICE_TABLE'
499 | MODULE_DEVICE_TABLE(auxiliary, mtk_reset_ids);
| ^~~~~~~~~~~~~~~~~~~


vim +499 drivers/reset/reset-mediatek-sysclk.c

402
403 static struct auxiliary_device_id mtk_sysclk_reset_ids[] = {
404 {
405 .name = "clk_mt2701_eth.mt2701-eth-rst",
406 .driver_data = MTK_RST_ID_MT2701_ETH,
407 },
408 {
409 .name = "clk_mt2701_g3d.mt2701-g3d-rst",
410 .driver_data = MTK_RST_ID_MT2701_G3D,
411 },
412 {
413 .name = "clk_mt2701_hif.mt2701-hif-rst",
414 .driver_data = MTK_RST_ID_MT2701_HIF,
415 },
416 {
417 .name = "clk_mt2701.mt2701-infrasys-rst",
418 .driver_data = MTK_RST_ID_MT2701_INFRASYS,
419 },
420 {
421 .name = "clk_mt2701.mt2701-pericfg-rst",
422 .driver_data = MTK_RST_ID_MT2701_PERICFG,
423 },
424 {
425 .name = "clk_mt2712.mt2712-infra-rst",
426 .driver_data = MTK_RST_ID_MT2712_INFRA,
427 },
428 {
429 .name = "clk_mt2712.mt2712-peri-rst",
430 .driver_data = MTK_RST_ID_MT2712_PERI,
431 },
432 {
433 .name = "clk_mt7622_eth.mt7622-eth-rst",
434 .driver_data = MTK_RST_ID_MT7622_ETH,
435 },
436 {
437 .name = "clk_mt7622_hif.mt7622-usb-rst",
438 .driver_data = MTK_RST_ID_MT7622_SSUSBSYS,
439 },
440 {
441 .name = "clk_mt7622_hif.mt7622-pcie-rst",
442 .driver_data = MTK_RST_ID_MT7622_PCIESYS,
443 },
444 {
445 .name = "clk_mt7622.mt7622-infrasys-rst",
446 .driver_data = MTK_RST_ID_MT7622_INFRASYS,
447 },
448 {
449 .name = "clk_mt7622.mt7622-pericfg-rst",
450 .driver_data = MTK_RST_ID_MT7622_PERICFG,
451 },
452 {
453 .name = "clk_mt7629_eth.mt7629-ethsys-rst",
454 .driver_data = MTK_RST_ID_MT7629_ETHSYS,
455 },
456 {
457 .name = "clk_mt7629_hif.mt7629-usb-rst",
458 .driver_data = MTK_RST_ID_MT7629_SSUSBSYS,
459 },
460 {
461 .name = "clk_mt7629_hif.mt7629-pcie-rst",
462 .driver_data = MTK_RST_ID_MT7629_PCIESYS,
463 },
464 {
465 .name = "clk_mt8135.mt8135-infrasys-rst",
466 .driver_data = MTK_RST_ID_MT8135_INFRASYS,
467 },
468 {
469 .name = "clk_mt8135.mt8135-pericfg-rst",
470 .driver_data = MTK_RST_ID_MT8135_PERICFG,
471 },
472 {
473 .name = "clk_mt8173.mt8173-infracfg-rst",
474 .driver_data = MTK_RST_ID_MT8173_INFRACFG,
475 },
476 {
477 .name = "clk_mt8173.mt8173-pericfg-rst",
478 .driver_data = MTK_RST_ID_MT8173_PERICFG,
479 },
480 {
481 .name = "clk_mt8183.mt8183-infra-rst",
482 .driver_data = MTK_RST_ID_MT8183_INFRA,
483 },
484 {
485 .name = "clk_mtk.mt8186-infra-ao-rst",
486 .driver_data = MTK_RST_ID_MT8186_INFRA_AO,
487 },
488 {
489 .name = "clk_mt8192.mt8192-infra-rst",
490 .driver_data = MTK_RST_ID_MT8192_INFRA,
491 },
492 {
493 .name = "clk_mtk.mt8195-infra-ao-rst",
494 .driver_data = MTK_RST_ID_MT8195_INFRA_AO,
495 },
496 {
497 },
498 };
> 499 MODULE_DEVICE_TABLE(auxiliary, mtk_reset_ids);
500
501 /* reset data */
502 static struct mtk_clk_rst_data clk_rst_data[] = {
503 [MTK_RST_ID_MT2701_ETH] = { .desc = &mt2701_eth_rst_desc, },
504 [MTK_RST_ID_MT2701_G3D] = { .desc = &mt2701_g3d_clk_rst_desc, },
505 [MTK_RST_ID_MT2701_HIF] = { .desc = &mt2701_eth_rst_desc, },
506 [MTK_RST_ID_MT2701_INFRASYS] = { .desc = &mt2701_infrasys_clk_rst_desc, },
507 [MTK_RST_ID_MT2701_PERICFG] = { .desc = &mt2701_pericfg_clk_rst_desc, },
508 [MTK_RST_ID_MT2712_INFRA] = { .desc = &mt2701_infrasys_clk_rst_desc, },
509 [MTK_RST_ID_MT2712_PERI] = { .desc = &mt2701_pericfg_clk_rst_desc, },
510 [MTK_RST_ID_MT7622_ETH] = { .desc = &mt2701_eth_rst_desc, },
511 [MTK_RST_ID_MT7622_SSUSBSYS] = { .desc = &mt2701_eth_rst_desc, },
512 [MTK_RST_ID_MT7622_PCIESYS] = { .desc = &mt2701_eth_rst_desc, },
513 [MTK_RST_ID_MT7622_INFRASYS] = { .desc = &mt7622_infrasys_clk_rst_desc, },
514 [MTK_RST_ID_MT7622_PERICFG] = { .desc = &mt2701_pericfg_clk_rst_desc, },
515 [MTK_RST_ID_MT7629_ETHSYS] = { .desc = &mt2701_eth_rst_desc, },
516 [MTK_RST_ID_MT7629_SSUSBSYS] = { .desc = &mt2701_eth_rst_desc, },
517 [MTK_RST_ID_MT7629_PCIESYS] = { .desc = &mt2701_eth_rst_desc, },
518 [MTK_RST_ID_MT8135_INFRASYS] = { .desc = &mt2701_infrasys_clk_rst_desc, },
519 [MTK_RST_ID_MT8135_PERICFG] = { .desc = &mt2701_pericfg_clk_rst_desc, },
520 [MTK_RST_ID_MT8173_INFRACFG] = { .desc = &mt2701_infrasys_clk_rst_desc, },
521 [MTK_RST_ID_MT8173_PERICFG] = { .desc = &mt2701_pericfg_clk_rst_desc, },
522 [MTK_RST_ID_MT8183_INFRA] = { .desc = &mt8183_rst_desc, },
523 [MTK_RST_ID_MT8186_INFRA_AO] = { .desc = &mt8186_rst_desc, },
524 [MTK_RST_ID_MT8192_INFRA] = { .desc = &mt8192_rst_desc, },
525 [MTK_RST_ID_MT8195_INFRA_AO] = { .desc = &mt8195_rst_desc, },
526 {},
527 };
528
529 static struct mtk_clk_rst_data *find_rst_data(const char *name)
530 {
531 int i;
532
533 for (i = 0; i < ARRAY_SIZE(mtk_sysclk_reset_ids); i++)
534 if (mtk_sysclk_reset_ids[i].name == name)
535 return &clk_rst_data[mtk_sysclk_reset_ids[i].driver_data];
536 return NULL;
537 }
538
> 539 int mtk_reset_init_with_node(struct device_node *np, const char *name)
540 {
541 struct mtk_clk_rst_data *data = find_rst_data(name);
542
543 if (!np || !data)
544 return -EINVAL;
545
546 return register_rst_ctrl_with_node(np, data);
547 }
548 EXPORT_SYMBOL_GPL(mtk_reset_init_with_node);
549
> 550 void mtk_rst_remove_with_node(struct device_node *np, const char *name)
551 {
552 struct mtk_clk_rst_data *data = find_rst_data(name);
553
554 if (!np || !data)
555 return;
556
557 reset_controller_unregister(&data->rcdev);
558 }
559 EXPORT_SYMBOL_GPL(mtk_rst_remove_with_node);
560

--
0-DAY CI Kernel Test Service
https://01.org/lkp

2022-09-23 03:18:06

by Bo-Chen Chen

[permalink] [raw]
Subject: Re: [PATCH] reset: mediatek: Move mediatek system clock reset to reset folder

On Fri, 2022-09-23 at 09:15 +0800, kernel test robot wrote:
> Hi Bo-Chen,
>
> Thank you for the patch! Yet something to improve:
>
> [auto build test ERROR on v6.0-rc6]
> [also build test ERROR on linus/master]
> [cannot apply to clk/clk-next pza/reset/next mbgg-mediatek/for-next
> next-20220921]
> [If your patch is applied to the wrong git tree, kindly drop us a
> note.
> And when submitting patch, we suggest to use '--base' as documented
> in
>
https://urldefense.com/v3/__https://git-scm.com/docs/git-format-patch*_base_tree_information__;Iw!!CTRNKA9wMg0ARbw!3qsHi0O4Vg0e-tqzlUswcsK-ssSqQiv9heXJFcsj0Jo9fdBpwJPyE8Cm7pi8HlvqkXZ3$
> ]
>
> url:
> https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux/commits/Bo-Chen-Chen/reset-mediatek-Move-mediatek-system-clock-reset-to-reset-folder/20220922-221303__;!!CTRNKA9wMg0ARbw!3qsHi0O4Vg0e-tqzlUswcsK-ssSqQiv9heXJFcsj0Jo9fdBpwJPyE8Cm7pi8HphCRXGt$
>
> base: 521a547ced6477c54b4b0cc206000406c221b4d6
> config: sh-allmodconfig (
> https://urldefense.com/v3/__https://download.01.org/0day-ci/archive/20220923/[email protected]/config__;!!CTRNKA9wMg0ARbw!3qsHi0O4Vg0e-tqzlUswcsK-ssSqQiv9heXJFcsj0Jo9fdBpwJPyE8Cm7pi8HgGJ4A5i$
> )
> compiler: sh4-linux-gcc (GCC) 12.1.0
> reproduce (this is a W=1 build):
> wget
> https://urldefense.com/v3/__https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross__;!!CTRNKA9wMg0ARbw!3qsHi0O4Vg0e-tqzlUswcsK-ssSqQiv9heXJFcsj0Jo9fdBpwJPyE8Cm7pi8HmjL7iLl$
> -O ~/bin/make.cross
> chmod +x ~/bin/make.cross
> #
> https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux/commit/69ce72445492a02115b1e7c7527a8a107f48aab8__;!!CTRNKA9wMg0ARbw!3qsHi0O4Vg0e-tqzlUswcsK-ssSqQiv9heXJFcsj0Jo9fdBpwJPyE8Cm7pi8HmwVGCNt$
>
> git remote add linux-review
> https://urldefense.com/v3/__https://github.com/intel-lab-lkp/linux__;!!CTRNKA9wMg0ARbw!3qsHi0O4Vg0e-tqzlUswcsK-ssSqQiv9heXJFcsj0Jo9fdBpwJPyE8Cm7pi8HnCYV8dW$
>
> git fetch --no-tags linux-review Bo-Chen-Chen/reset-mediatek-
> Move-mediatek-system-clock-reset-to-reset-folder/20220922-221303
> git checkout 69ce72445492a02115b1e7c7527a8a107f48aab8
> # save the config file
> mkdir build_dir && cp config build_dir/.config
> COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0
> make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash drivers/
>
> If you fix the issue, kindly add following tag where applicable
> > Reported-by: kernel test robot <[email protected]>
>
> All error/warnings (new ones prefixed by >>):
>
> In file included from include/linux/device/driver.h:21,
> from include/linux/device.h:32,
> from include/linux/auxiliary_bus.h:11,
> from drivers/reset/reset-mediatek-sysclk.c:6:
> > > drivers/reset/reset-mediatek-sysclk.c:499:32: error:
> > > 'mtk_reset_ids' undeclared here (not in a function); did you mean
> > > 'mtk_reset_ops'?
>
> 499 | MODULE_DEVICE_TABLE(auxiliary, mtk_reset_ids);
> | ^~~~~~~~~~~~~
> include/linux/module.h:244:15: note: in definition of macro
> 'MODULE_DEVICE_TABLE'
> 244 | extern typeof(name)
> __mod_##type##__##name##_device_table \
> | ^~~~
> > > drivers/reset/reset-mediatek-sysclk.c:539:5: warning: no previous
> > > prototype for 'mtk_reset_init_with_node' [-Wmissing-prototypes]
>
> 539 | int mtk_reset_init_with_node(struct device_node *np, const
> char *name)
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> > > drivers/reset/reset-mediatek-sysclk.c:550:6: warning: no previous
> > > prototype for 'mtk_rst_remove_with_node' [-Wmissing-prototypes]
>
> 550 | void mtk_rst_remove_with_node(struct device_node *np,
> const char *name)
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> > > include/linux/module.h:244:21: error:
> > > '__mod_auxiliary__mtk_reset_ids_device_table' aliased to
> > > undefined symbol 'mtk_reset_ids'
>
> 244 | extern typeof(name)
> __mod_##type##__##name##_device_table \
> | ^~~~~~
> drivers/reset/reset-mediatek-sysclk.c:499:1: note: in expansion of
> macro 'MODULE_DEVICE_TABLE'
> 499 | MODULE_DEVICE_TABLE(auxiliary, mtk_reset_ids);
> | ^~~~~~~~~~~~~~~~~~~
>
>
> vim +499 drivers/reset/reset-mediatek-sysclk.c
>
> 402
> 403 static struct auxiliary_device_id
> mtk_sysclk_reset_ids[] = {
> 404 {
> 405 .name = "clk_mt2701_eth.mt2701-eth-
> rst",
> 406 .driver_data = MTK_RST_ID_MT2701_ETH,
> 407 },
> 408 {
> 409 .name = "clk_mt2701_g3d.mt2701-g3d-
> rst",
> 410 .driver_data = MTK_RST_ID_MT2701_G3D,
> 411 },
> 412 {
> 413 .name = "clk_mt2701_hif.mt2701-hif-
> rst",
> 414 .driver_data = MTK_RST_ID_MT2701_HIF,
> 415 },
> 416 {
> 417 .name = "clk_mt2701.mt2701-infrasys-
> rst",
> 418 .driver_data =
> MTK_RST_ID_MT2701_INFRASYS,
> 419 },
> 420 {
> 421 .name = "clk_mt2701.mt2701-pericfg-
> rst",
> 422 .driver_data =
> MTK_RST_ID_MT2701_PERICFG,
> 423 },
> 424 {
> 425 .name = "clk_mt2712.mt2712-infra-rst",
> 426 .driver_data = MTK_RST_ID_MT2712_INFRA,
> 427 },
> 428 {
> 429 .name = "clk_mt2712.mt2712-peri-rst",
> 430 .driver_data = MTK_RST_ID_MT2712_PERI,
> 431 },
> 432 {
> 433 .name = "clk_mt7622_eth.mt7622-eth-
> rst",
> 434 .driver_data = MTK_RST_ID_MT7622_ETH,
> 435 },
> 436 {
> 437 .name = "clk_mt7622_hif.mt7622-usb-
> rst",
> 438 .driver_data =
> MTK_RST_ID_MT7622_SSUSBSYS,
> 439 },
> 440 {
> 441 .name = "clk_mt7622_hif.mt7622-pcie-
> rst",
> 442 .driver_data =
> MTK_RST_ID_MT7622_PCIESYS,
> 443 },
> 444 {
> 445 .name = "clk_mt7622.mt7622-infrasys-
> rst",
> 446 .driver_data =
> MTK_RST_ID_MT7622_INFRASYS,
> 447 },
> 448 {
> 449 .name = "clk_mt7622.mt7622-pericfg-
> rst",
> 450 .driver_data =
> MTK_RST_ID_MT7622_PERICFG,
> 451 },
> 452 {
> 453 .name = "clk_mt7629_eth.mt7629-ethsys-
> rst",
> 454 .driver_data =
> MTK_RST_ID_MT7629_ETHSYS,
> 455 },
> 456 {
> 457 .name = "clk_mt7629_hif.mt7629-usb-
> rst",
> 458 .driver_data =
> MTK_RST_ID_MT7629_SSUSBSYS,
> 459 },
> 460 {
> 461 .name = "clk_mt7629_hif.mt7629-pcie-
> rst",
> 462 .driver_data =
> MTK_RST_ID_MT7629_PCIESYS,
> 463 },
> 464 {
> 465 .name = "clk_mt8135.mt8135-infrasys-
> rst",
> 466 .driver_data =
> MTK_RST_ID_MT8135_INFRASYS,
> 467 },
> 468 {
> 469 .name = "clk_mt8135.mt8135-pericfg-
> rst",
> 470 .driver_data =
> MTK_RST_ID_MT8135_PERICFG,
> 471 },
> 472 {
> 473 .name = "clk_mt8173.mt8173-infracfg-
> rst",
> 474 .driver_data =
> MTK_RST_ID_MT8173_INFRACFG,
> 475 },
> 476 {
> 477 .name = "clk_mt8173.mt8173-pericfg-
> rst",
> 478 .driver_data =
> MTK_RST_ID_MT8173_PERICFG,
> 479 },
> 480 {
> 481 .name = "clk_mt8183.mt8183-infra-rst",
> 482 .driver_data = MTK_RST_ID_MT8183_INFRA,
> 483 },
> 484 {
> 485 .name = "clk_mtk.mt8186-infra-ao-rst",
> 486 .driver_data =
> MTK_RST_ID_MT8186_INFRA_AO,
> 487 },
> 488 {
> 489 .name = "clk_mt8192.mt8192-infra-rst",
> 490 .driver_data = MTK_RST_ID_MT8192_INFRA,
> 491 },
> 492 {
> 493 .name = "clk_mtk.mt8195-infra-ao-rst",
> 494 .driver_data =
> MTK_RST_ID_MT8195_INFRA_AO,
> 495 },
> 496 {
> 497 },
> 498 };
> > 499 MODULE_DEVICE_TABLE(auxiliary, mtk_reset_ids);
> 500
> 501 /* reset data */
> 502 static struct mtk_clk_rst_data clk_rst_data[] = {
> 503 [MTK_RST_ID_MT2701_ETH] = { .desc =
> &mt2701_eth_rst_desc, },
> 504 [MTK_RST_ID_MT2701_G3D] = { .desc =
> &mt2701_g3d_clk_rst_desc, },
> 505 [MTK_RST_ID_MT2701_HIF] = { .desc =
> &mt2701_eth_rst_desc, },
> 506 [MTK_RST_ID_MT2701_INFRASYS] = { .desc =
> &mt2701_infrasys_clk_rst_desc, },
> 507 [MTK_RST_ID_MT2701_PERICFG] = { .desc =
> &mt2701_pericfg_clk_rst_desc, },
> 508 [MTK_RST_ID_MT2712_INFRA] = { .desc =
> &mt2701_infrasys_clk_rst_desc, },
> 509 [MTK_RST_ID_MT2712_PERI] = { .desc =
> &mt2701_pericfg_clk_rst_desc, },
> 510 [MTK_RST_ID_MT7622_ETH] = { .desc =
> &mt2701_eth_rst_desc, },
> 511 [MTK_RST_ID_MT7622_SSUSBSYS] = { .desc =
> &mt2701_eth_rst_desc, },
> 512 [MTK_RST_ID_MT7622_PCIESYS] = { .desc =
> &mt2701_eth_rst_desc, },
> 513 [MTK_RST_ID_MT7622_INFRASYS] = { .desc =
> &mt7622_infrasys_clk_rst_desc, },
> 514 [MTK_RST_ID_MT7622_PERICFG] = { .desc =
> &mt2701_pericfg_clk_rst_desc, },
> 515 [MTK_RST_ID_MT7629_ETHSYS] = { .desc =
> &mt2701_eth_rst_desc, },
> 516 [MTK_RST_ID_MT7629_SSUSBSYS] = { .desc =
> &mt2701_eth_rst_desc, },
> 517 [MTK_RST_ID_MT7629_PCIESYS] = { .desc =
> &mt2701_eth_rst_desc, },
> 518 [MTK_RST_ID_MT8135_INFRASYS] = { .desc =
> &mt2701_infrasys_clk_rst_desc, },
> 519 [MTK_RST_ID_MT8135_PERICFG] = { .desc =
> &mt2701_pericfg_clk_rst_desc, },
> 520 [MTK_RST_ID_MT8173_INFRACFG] = { .desc =
> &mt2701_infrasys_clk_rst_desc, },
> 521 [MTK_RST_ID_MT8173_PERICFG] = { .desc =
> &mt2701_pericfg_clk_rst_desc, },
> 522 [MTK_RST_ID_MT8183_INFRA] = { .desc =
> &mt8183_rst_desc, },
> 523 [MTK_RST_ID_MT8186_INFRA_AO] = { .desc =
> &mt8186_rst_desc, },
> 524 [MTK_RST_ID_MT8192_INFRA] = { .desc =
> &mt8192_rst_desc, },
> 525 [MTK_RST_ID_MT8195_INFRA_AO] = { .desc =
> &mt8195_rst_desc, },
> 526 {},
> 527 };
> 528
> 529 static struct mtk_clk_rst_data *find_rst_data(const
> char *name)
> 530 {
> 531 int i;
> 532
> 533 for (i = 0; i <
> ARRAY_SIZE(mtk_sysclk_reset_ids); i++)
> 534 if (mtk_sysclk_reset_ids[i].name ==
> name)
> 535 return
> &clk_rst_data[mtk_sysclk_reset_ids[i].driver_data];
> 536 return NULL;
> 537 }
> 538
> > 539 int mtk_reset_init_with_node(struct device_node *np,
> const char *name)
> 540 {
> 541 struct mtk_clk_rst_data *data =
> find_rst_data(name);
> 542
> 543 if (!np || !data)
> 544 return -EINVAL;
> 545
> 546 return register_rst_ctrl_with_node(np, data);
> 547 }
> 548 EXPORT_SYMBOL_GPL(mtk_reset_init_with_node);
> 549
> > 550 void mtk_rst_remove_with_node(struct device_node *np,
> const char *name)
> 551 {
> 552 struct mtk_clk_rst_data *data =
> find_rst_data(name);
> 553
> 554 if (!np || !data)
> 555 return;
> 556
> 557 reset_controller_unregister(&data->rcdev);
> 558 }
> 559 EXPORT_SYMBOL_GPL(mtk_rst_remove_with_node);
> 560
>

Hello,

Thanks for the feedback.
I will fix this error and add include/linux/reset/reset-mediatek-
sysclk.h to fix this warning.

Also, I will try to base on linux-next to resolve these apply conflict.

BRs,
Bo-Chen