reset: mediatek: Move mediatek system clock reset to reset folder
Subsystems (3)
PATCH v5 1/1 reset: mediatek: Move mediatek system clock reset to reset folder
To manager mediatek system clock reset easier, we move the driver to drivers/reset.
- Create reset/mediatek folder.
- Move clk/mediatek/reset.c to reset/mediatek/reset-mediatek-sysclk.c
- Because we don't want to build in unsed static variable (For example, if we use mt8186, we don't want to build in the variable of MT8195.), we use clk KConfig to do this.
- Move reset data which are scattered around the mediatek drivers to reset-mtxxxx.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.
---
Changes for v5:
1. Replace reset-mtxxxx.h with reset-mtxxxx.c and after using this, we don't need to add many "#if #endif" in reset-mediatek-sysclk.c.
2. Use mediatek clock common KConfig to control whether to build in reset-mtxxxx.c.
3. Rebased on linux-next-1007.
Changes for v4:
1. Rebased oo linux-next-1004.
2. Move reset data which are scattered around the mediatek drivers to reset-mtxxxx.h.
3. Add reset data of mt6795.
Version for this series:
v4 : https://lore.kernel.org/all/[email protected]/
v3 : https://lore.kernel.org/all/[email protected]/
v2 : https://lore.kernel.org/all/[email protected]/
v1 : https://lore.kernel.org/all/[email protected]/
RFC: https://lore.kernel.org/all/[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-mt6795-infracfg.c | 22 +- drivers/clk/mediatek/clk-mt6795-pericfg.c | 20 +- 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 | 27 +- drivers/clk/mediatek/clk-mt8195-infra_ao.c | 28 +- drivers/clk/mediatek/clk-mtk.c | 62 ++- drivers/clk/mediatek/clk-mtk.h | 8 +- drivers/clk/mediatek/reset.c | 233 ----------- drivers/reset/Kconfig | 1 + drivers/reset/Makefile | 1 + drivers/reset/mediatek/Kconfig | 6 + drivers/reset/mediatek/Makefile | 13 + .../reset/mediatek/reset-mediatek-sysclk.c | 389 ++++++++++++++++++ drivers/reset/mediatek/reset-mt2701.c | 102 +++++ drivers/reset/mediatek/reset-mt2712.c | 42 ++ drivers/reset/mediatek/reset-mt6795.c | 61 +++ drivers/reset/mediatek/reset-mt7622.c | 91 ++++ drivers/reset/mediatek/reset-mt7629.c | 62 +++ drivers/reset/mediatek/reset-mt8135.c | 43 ++ drivers/reset/mediatek/reset-mt8173.c | 43 ++ drivers/reset/mediatek/reset-mt8183.c | 31 ++ drivers/reset/mediatek/reset-mt8186.c | 39 ++ drivers/reset/mediatek/reset-mt8192.c | 43 ++ drivers/reset/mediatek/reset-mt8195.c | 44 ++ .../linux/reset/reset-mediatek-sysclk.h | 61 +-- 40 files changed, 1142 insertions(+), 557 deletions(-) delete mode 100644 drivers/clk/mediatek/reset.c create mode 100644 drivers/reset/mediatek/Kconfig create mode 100644 drivers/reset/mediatek/Makefile create mode 100644 drivers/reset/mediatek/reset-mediatek-sysclk.c create mode 100644 drivers/reset/mediatek/reset-mt2701.c create mode 100644 drivers/reset/mediatek/reset-mt2712.c create mode 100644 drivers/reset/mediatek/reset-mt6795.c create mode 100644 drivers/reset/mediatek/reset-mt7622.c create mode 100644 drivers/reset/mediatek/reset-mt7629.c create mode 100644 drivers/reset/mediatek/reset-mt8135.c create mode 100644 drivers/reset/mediatek/reset-mt8173.c create mode 100644 drivers/reset/mediatek/reset-mt8183.c create mode 100644 drivers/reset/mediatek/reset-mt8186.c create mode 100644 drivers/reset/mediatek/reset-mt8192.c create mode 100644 drivers/reset/mediatek/reset-mt8195.c rename drivers/clk/mediatek/reset.h => include/linux/reset/reset-mediatek-sysclk.h (60%)
drivers/clk/mediatek/Kconfig +2 -0
@@ -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.
drivers/clk/mediatek/Makefile +1 -1
@@ -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
drivers/clk/mediatek/clk-mt2701-eth.c +1 -9
@@ -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; }
drivers/clk/mediatek/clk-mt2701-g3d.c +1 -9
@@ -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; }
drivers/clk/mediatek/clk-mt2701-hif.c +1 -9
@@ -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 ; }
drivers/clk/mediatek/clk-mt2701.c +2 -20
@@ -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 ; }
drivers/clk/mediatek/clk-mt2712.c +2 -20
@@ -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; }
drivers/clk/mediatek/clk-mt6795-infracfg.c +1 -21
@@ -5,13 +5,11 @@*/ #include <dt-bindings/clock/mediatek,mt6795-clk.h> -#include <dt-bindings/reset/mediatek,mt6795-resets.h> #include <linux/module.h> #include <linux/platform_device.h> #include "clk-cpumux.h" #include "clk-gate.h" #include "clk-mtk.h" -#include "reset.h" #define GATE_ICG (_id, _name, _parent, _shift) \ GATE_MTK(_id, _name, _parent, &infra_cg_regs, \
@@ -59,24 +57,6 @@ static const struct mtk_gate infra_gates[] = { GATE_ICG(CLK_INFRA_KP, "infra_kp", "axi_sel", 16), }; -static u16 infra_ao_rst_ofs[] = {0x30 ,0x34 }; - -static u16 infra_ao_idx_map[] = { - [MT6795_INFRA_RST0_SCPSYS_RST ] =0 *RST_NR_PER_BANK +5 , - [MT6795_INFRA_RST0_PMIC_WRAP_RST ] =0 *RST_NR_PER_BANK +7 , - [MT6795_INFRA_RST1_MIPI_DSI_RST ] =1 *RST_NR_PER_BANK +4 , - [MT6795_INFRA_RST1_MIPI_CSI_RST ] =1 *RST_NR_PER_BANK +7 , - [MT6795_INFRA_RST1_MM_IOMMU_RST ] =1 *RST_NR_PER_BANK +15 , -}; - -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), -}; -static const struct of_device_id of_match_clk_mt6795_infracfg[] = { { .compatible ="mediatek,mt6795-infracfg" }, {/* sentinel */ }
@@ -97,7 +77,7 @@ static int clk_mt6795_infracfg_probe(struct platform_device *pdev)if (!clk_data)return -ENOMEM ; - ret =mtk_register_reset_controller_with_dev (&pdev->dev, &clk_rst_desc); + ret =mtk_reset_controller_register (&pdev->dev,"mt6795-ifa" );if (ret) goto free_clk_data;
drivers/clk/mediatek/clk-mt6795-pericfg.c +1 -19
@@ -5,12 +5,10 @@*/ #include <dt-bindings/clock/mediatek,mt6795-clk.h> -#include <dt-bindings/reset/mediatek,mt6795-resets.h> #include <linux/module.h> #include <linux/platform_device.h> #include "clk-gate.h" #include "clk-mtk.h" -#include "reset.h" #define GATE_PERI (_id, _name, _parent, _shift) \ GATE_MTK(_id, _name, _parent, &peri_cg_regs, \
@@ -69,22 +67,6 @@ static const struct mtk_gate peri_gates[] = { GATE_PERI(CLK_PERI_SPI0, "peri_spi0", "spi_sel", 29), }; -static u16 peri_rst_ofs[] = {0x0 }; - -static u16 peri_idx_map[] = { - [MT6795_PERI_NFI_SW_RST ] =14 , - [MT6795_PERI_THERM_SW_RST ] =16 , - [MT6795_PERI_MSDC1_SW_RST ] =20 , -}; - -static const struct mtk_clk_rst_desc clk_rst_desc = { - .version =MTK_RST_SIMPLE , - .rst_bank_ofs = peri_rst_ofs, - .rst_bank_nr =ARRAY_SIZE (peri_rst_ofs), - .rst_idx_map = peri_idx_map, - .rst_idx_map_nr =ARRAY_SIZE (peri_idx_map), -}; -static const struct of_device_id of_match_clk_mt6795_pericfg[] = { { .compatible ="mediatek,mt6795-pericfg" }, {/* sentinel */ }
@@ -105,7 +87,7 @@ static int clk_mt6795_pericfg_probe(struct platform_device *pdev)if (!clk_data)return -ENOMEM ; - ret =mtk_register_reset_controller_with_dev (&pdev->dev, &clk_rst_desc); + ret =mtk_reset_controller_register (&pdev->dev,"mt6795-peri" );if (ret) goto free_clk_data;
drivers/clk/mediatek/clk-mt7622-eth.c +1 -9
@@ -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; }
drivers/clk/mediatek/clk-mt7622-hif.c +2 -10
@@ -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; }
drivers/clk/mediatek/clk-mt7622.c +2 -20
@@ -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 ; }
drivers/clk/mediatek/clk-mt7629-eth.c +1 -9
@@ -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; }
drivers/clk/mediatek/clk-mt7629-hif.c +2 -10
@@ -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; }
drivers/clk/mediatek/clk-mt8135.c +3 -20
@@ -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);
drivers/clk/mediatek/clk-mt8173.c +2 -20
@@ -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);
drivers/clk/mediatek/clk-mt8183.c +1 -14
@@ -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;
@@ -1278,7 +1265,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; }
drivers/clk/mediatek/clk-mt8186-infra_ao.c +1 -22
@@ -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[] = {
drivers/clk/mediatek/clk-mt8192.c +1 -26
@@ -18,7 +18,6 @@#include "clk-pll.h" #include <dt-bindings/clock/mt8192-clk.h> -#include <dt-bindings/reset/mt8192-resets.h> static DEFINE_SPINLOCK (mt8192_clk_lock);
@@ -959,30 +958,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
@@ -1137,7 +1112,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;
drivers/clk/mediatek/clk-mt8195-infra_ao.c +1 -27
@@ -7,7 +7,6 @@#include "clk-mtk.h" #include <dt-bindings/clock/mt8195-clk.h> -#include <dt-bindings/reset/mt8195-resets.h> #include <linux/clk-provider.h> #include <linux/platform_device.h>
@@ -190,35 +189,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_RST2_USBSIF_P1_SWRST ] =2 *RST_NR_PER_BANK +18 , - [MT8195_INFRA_RST2_PCIE_P0_SWRST ] =2 *RST_NR_PER_BANK +26 , - [MT8195_INFRA_RST2_PCIE_P1_SWRST ] =2 *RST_NR_PER_BANK +27 , - [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[] = {
drivers/clk/mediatek/clk-mtk.c +59 -3
74 lines not on this page · raw message
drivers/clk/mediatek/clk-mtk.h +5 -3
@@ -7,14 +7,14 @@#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/reset/reset-mediatek-sysclk.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)
@@ -195,10 +195,12 @@ void mtk_clk_unregister_ref2usb_tx(struct clk_hw *hw);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); +#endif /* __DRV_CLK_MTK_H */
drivers/clk/mediatek/reset.c deleted +0 -233
233 lines not on this page · raw message
drivers/reset/Kconfig +1 -0
@@ -320,6 +320,7 @@ config RESET_ZYNQ help This enables the reset controller driver for Xilinx Zynq SoCs. +source "drivers/reset/mediatek/Kconfig" source "drivers/reset/sti/Kconfig" source "drivers/reset/hisilicon/Kconfig" source "drivers/reset/tegra/Kconfig"
drivers/reset/Makefile +1 -0
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-y += core.o obj-y += hisilicon/ +obj-y += mediatek/ obj-$(CONFIG_ARCH_STI) += sti/ obj-$(CONFIG_ARCH_TEGRA) += tegra/ obj-$(CONFIG_RESET_A10SR) += reset-a10sr.o
drivers/reset/mediatek/Kconfig new file +6 -0
@@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +config RESET_MEDIATEK_SYSCLK + tristate "MediaTek System Clock Reset Driver" + depends on AUXILIARY_BUS + help + This enables the system clock reset driver for MediaTek SoCs.
drivers/reset/mediatek/Makefile new file +13 -0
@@ -0,0 +1,13 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_RESET_MEDIATEK_SYSCLK) += reset-mediatek-sysclk.o +obj-$(CONFIG_COMMON_CLK_MT2701) += reset-mt2701.o +obj-$(CONFIG_COMMON_CLK_MT2712) += reset-mt2712.o +obj-$(CONFIG_COMMON_CLK_MT6795) += reset-mt6795.o +obj-$(CONFIG_COMMON_CLK_MT7622) += reset-mt7622.o +obj-$(CONFIG_COMMON_CLK_MT7629) += reset-mt7629.o +obj-$(CONFIG_COMMON_CLK_MT8135) += reset-mt8135.o +obj-$(CONFIG_COMMON_CLK_MT8173) += reset-mt8173.o +obj-$(CONFIG_COMMON_CLK_MT8183) += reset-mt8183.o +obj-$(CONFIG_COMMON_CLK_MT8186) += reset-mt8186.o +obj-$(CONFIG_COMMON_CLK_MT8192) += reset-mt8192.o +obj-$(CONFIG_COMMON_CLK_MT8195) += reset-mt8195.o
drivers/reset/mediatek/reset-mediatek-sysclk.c new file +389 -0
389 lines not on this page · raw message
drivers/reset/mediatek/reset-mt2701.c new file +102 -0
102 lines not on this page · raw message
drivers/reset/mediatek/reset-mt2712.c new file +42 -0
42 lines not on this page · raw message
drivers/reset/mediatek/reset-mt6795.c new file +61 -0
61 lines not on this page · raw message
drivers/reset/mediatek/reset-mt7622.c new file +91 -0
91 lines not on this page · raw message
drivers/reset/mediatek/reset-mt7629.c new file +62 -0
62 lines not on this page · raw message
drivers/reset/mediatek/reset-mt8135.c new file +43 -0
43 lines not on this page · raw message
drivers/reset/mediatek/reset-mt8173.c new file +43 -0
43 lines not on this page · raw message
drivers/reset/mediatek/reset-mt8183.c new file +31 -0
@@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2022 MediaTek Inc. +*/ + +#include <linux/reset/reset-mediatek-sysclk.h> + +static u16 mt8183_infra_ao_rst_ofs[] = { +INFRA_RST0_SET_OFFSET , +INFRA_RST1_SET_OFFSET , +INFRA_RST2_SET_OFFSET , +INFRA_RST3_SET_OFFSET , +}; + +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_data mt8183_clk_rst_data = { + .desc = &mt8183_rst_desc, +}; + +static int __init mt8183_rst_desc_init (void ) +{ +return mtk_rst_register_clk_rst_data (MTK_RST_ID_MT8183_INFRA , &mt8183_clk_rst_data); +} +arch_initcall (mt8183_rst_desc_init); + +MODULE_LICENSE ("GPL" );
drivers/reset/mediatek/reset-mt8186.c new file +39 -0
@@ -0,0 +1,39 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Copyright (c) 2022 MediaTek Inc. +*/ + +#include <dt-bindings/reset/mt8186-resets.h> +#include <linux/reset/reset-mediatek-sysclk.h> + +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 mt8186_infra_ao_rst_ofs[] = { +INFRA_RST0_SET_OFFSET , +INFRA_RST1_SET_OFFSET , +INFRA_RST2_SET_OFFSET , +INFRA_RST3_SET_OFFSET , +}; + +static struct mtk_clk_rst_desc mt8186_rst_desc = { + .version =MTK_RST_SET_CLR , + .rst_bank_ofs = mt8186_infra_ao_rst_ofs, + .rst_bank_nr =ARRAY_SIZE (mt8186_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_data mt8186_clk_rst_data = { + .desc = &mt8186_rst_desc, +}; + +static int __init mt8186_rst_desc_init (void ) +{ +return mtk_rst_register_clk_rst_data (MTK_RST_ID_MT8186_INFRA_AO , &mt8186_clk_rst_data); +} +arch_initcall (mt8186_rst_desc_init); + +MODULE_LICENSE ("GPL" );
drivers/reset/mediatek/reset-mt8192.c new file +43 -0
43 lines not on this page · raw message
drivers/reset/mediatek/reset-mt8195.c new file +44 -0
44 lines not on this page · raw message
include/linux/reset/reset-mediatek-sysclk.h renamed from drivers/clk/mediatek/reset.h +38 -23
84 lines not on this page · raw message
Signature · 1 line
2.18.0
Stephen Boyd
maintainerQuoting Bo-Chen Chen (2022-10-07 03:48:42)
Quoted 18 lines
To manager mediatek system clock reset easier, we move the driver to
drivers/reset.- Create reset/mediatek folder.
- Moveclk/mediatek/reset.ctoreset/mediatek/reset-mediatek-sysclk.c
- Because we don't want to build in unsed static variable (For example, if we use mt8186, we don't want to build in the variable of MT8195.), we use clk KConfig to do this.
- Move reset data which are scattered around the mediatek drivers toreset-mtxxxx.c.
- For mtk clk drivers which support device, we can uesmtk_reset_controller_register()to register reset controller using auxiliary bus.
- For mtk clk drivers which do not support device (only supportdevice_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 menu "Clock driver for MediaTek SoC" · line 11
Quoted 9 lines
drivers/clk/mediatek/Kconfig +1
-0@@ -8,6 +8,8 @@ menu "Clock driver for MediaTek SoC" config COMMON_CLK_MEDIATEK tristate select RESET_CONTROLLER + select RESET_MEDIATEK_SYSCLK
Is this select necessary?
Quoted 74 lines
drivers/clk/mediatek/Kconfig +1
-0+ select AUXILIARY_BUS help MediaTek SoCs' clock support.drivers/clk/mediatek/clk-mtk.c +57
-0@@ -444,6 +444,63 @@ void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, }EXPORT_SYMBOL_GPL (mtk_clk_unregister_dividers); +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); +} +EXPORT_SYMBOL_GPL (mtk_reset_controller_register); +int mtk_clk_simple_probe (struct platform_device *pdev) {const struct mtk_clk_desc *mcd;@@ -470,9 +527,8 @@ int mtk_clk_simple_probe(struct platform_device *pdev)
drivers/clk/mediatek/clk-mtk.c int mtk_clk_simple_probe(struct platform_device *pdev) · line 534
Quoted 10 lines
drivers/clk/mediatek/clk-mtk.c +2
-3platform_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; }
Can you split this part off to a different patch? It would make it easier to review. And then you stack the reset part of the patch after this.
drivers/clk/mediatek/reset.c
Quoted 40 lines
drivers/clk/mediatek/clk-mtk.h +5
-3@@ -7,14 +7,14 @@#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/reset/reset-mediatek-sysclk.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)@@ -195,10 +195,12 @@ void mtk_clk_unregister_ref2usb_tx(struct clk_hw *hw);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); +#endif /* __DRV_CLK_MTK_H */ drivers/clk/mediatek/reset.c deleted +0
-0
This file could probably be deleted in yet another patch once nobody is using it.
Quoted 28 lines · Stephen Boyd
Quoting Bo-Chen Chen (2022-10-07 03:48:42)
Quoted 25 lines
To manager mediatek system clock reset easier, we move the driver to
drivers/reset.- Create reset/mediatek folder.
- Moveclk/mediatek/reset.cto reset/mediatek/reset-mediatek-sysclk.c
- Because we don't want to build in unsed static variable (For example,
if we use mt8186, we don't want to build in the variable of
MT8195.),
we use clk KConfig to do this.
- Move reset data which are scattered around the mediatek drivers to
reset-mtxxxx.c.
- For mtk clk drivers which support device, we can uesmtk_reset_controller_register()to register reset controller
using
auxiliary bus.
- For mtk clk drivers which do not support device (only supportdevice_node), we use mtk_reset_{init/remove}_with_node to
register
reset controller.Signed-off-by Bo-Chen Chen <[email protected]>[...]
Quoted 13 lines
drivers/clk/mediatek/Kconfig menu "Clock driver for MediaTek SoC" · line 11
Quoted 10 lines
drivers/clk/mediatek/Kconfig +1
-0@@ -8,6 +8,8 @@ menu "Clock driver for MediaTek SoC" config COMMON_CLK_MEDIATEK tristate select RESET_CONTROLLER + select RESET_MEDIATEK_SYSCLKIs this select necessary?
Hello Stephen,
Thanks for your review.
The system clock reset driver is original built with mediatek clk. Therefore, I think we should select this.
Please refer to drivers/clk/mediatek/Makefile
"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"
Quoted 90 lines
Quoted 90 lines
drivers/clk/mediatek/Kconfig +1
-0+ select AUXILIARY_BUS help MediaTek SoCs' clock support.drivers/clk/mediatek/clk-mtk.c +54
-0@@ -444,6 +444,63 @@ void mtk_clk_unregister_dividers(const struct mtk_clk_divider *mcds, int num, }EXPORT_SYMBOL_GPL (mtk_clk_unregister_dividers ); +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);drivers/clk/mediatek/clk-mtk.c +5
-3+} +EXPORT_SYMBOL_GPL (mtk_reset_controller_register); +int mtk_clk_simple_probe (struct platform_device *pdev) {const struct mtk_clk_desc *mcd;@@ -470,9 +527,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-Quoted 1 line
rst_name);
Quoted 9 lines
Quoted 3 lines
if (r) goto unregister_clks; }Can you split this part off to a different patch? It would make it easier to review. And then you stack the reset part of the patch after
this.
OK, I will separate this part to another patch.
Quoted 34 lines
Quoted 34 lines
drivers/clk/mediatek/clk-mtk.h +3
-3@@ -7,14 +7,14 @@#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/reset/reset-mediatek-sysclk.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)@@ -195,10 +195,12 @@ void mtk_clk_unregister_ref2usb_tx(struct clk_hw *hw);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);
Quoted 14 lines
drivers/clk/mediatek/reset.c
Quoted 10 lines
drivers/clk/mediatek/clk-mtk.h +1
-0+int mtk_reset_controller_register(struct device *dev, const char*name);
drivers/clk/mediatek/clk-mtk.h +1
-0+#endif /* __DRV_CLK_MTK_H */ drivers/clk/mediatek/reset.c deleted +0
-0This file could probably be deleted in yet another patch once nobody is
using it.
I am not sure what do you mean.
This series is for move reset.c to drivers/reset/mediatek. Should I not delete this file?
BRs,
Bo-Chen