Skip to content

Commit a0bc8ae

Browse files
mtk-rex-bc-chenbebarino
authored andcommitted
clk: mediatek: reset: Add infra_ao reset support for MT8192/MT8195
The infra_ao reset is needed for MT8192 and MT8195. - Add mtk_clk_rst_desc for MT8192 and MT8195 - Add register reset controller function for MT8192 infra_ao. - Move definition of infra reset from cl-mt8183.c to reset.h because it's the same definition with MT8192 and MT8195. - Add new definition of infra reset_4 for MT8192 and MT8195. - Add infra_ao_idx_map for MT8192 and MT8195. Signed-off-by: Rex-BC Chen <rex-bc.chen@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Reviewed-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> [Nícolas: Test for MT8192] Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> Link: https://lore.kernel.org/r/20220523093346.28493-15-rex-bc.chen@mediatek.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent fb91526 commit a0bc8ae

4 files changed

Lines changed: 60 additions & 6 deletions

File tree

drivers/clk/mediatek/clk-mt8183.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,6 @@
1818

1919
#include <dt-bindings/clock/mt8183-clk.h>
2020

21-
/* Infra global controller reset set register */
22-
#define INFRA_RST0_SET_OFFSET 0x120
23-
#define INFRA_RST1_SET_OFFSET 0x130
24-
#define INFRA_RST2_SET_OFFSET 0x140
25-
#define INFRA_RST3_SET_OFFSET 0x150
26-
2721
static DEFINE_SPINLOCK(mt8183_clk_lock);
2822

2923
static const struct mtk_fixed_clk top_fixed_clks[] = {

drivers/clk/mediatek/clk-mt8192.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "clk-pll.h"
1919

2020
#include <dt-bindings/clock/mt8192-clk.h>
21+
#include <dt-bindings/reset/mt8192-resets.h>
2122

2223
static DEFINE_SPINLOCK(mt8192_clk_lock);
2324

@@ -1114,6 +1115,30 @@ static const struct mtk_gate top_clks[] = {
11141115
GATE_TOP(CLK_TOP_SSUSB_PHY_REF, "ssusb_phy_ref", "clk26m", 25),
11151116
};
11161117

1118+
static u16 infra_ao_rst_ofs[] = {
1119+
INFRA_RST0_SET_OFFSET,
1120+
INFRA_RST1_SET_OFFSET,
1121+
INFRA_RST2_SET_OFFSET,
1122+
INFRA_RST3_SET_OFFSET,
1123+
INFRA_RST4_SET_OFFSET,
1124+
};
1125+
1126+
static u16 infra_ao_idx_map[] = {
1127+
[MT8192_INFRA_RST0_THERM_CTRL_SWRST] = 0 * RST_NR_PER_BANK + 0,
1128+
[MT8192_INFRA_RST2_PEXTP_PHY_SWRST] = 2 * RST_NR_PER_BANK + 15,
1129+
[MT8192_INFRA_RST3_THERM_CTRL_PTP_SWRST] = 3 * RST_NR_PER_BANK + 5,
1130+
[MT8192_INFRA_RST4_PCIE_TOP_SWRST] = 4 * RST_NR_PER_BANK + 1,
1131+
[MT8192_INFRA_RST4_THERM_CTRL_MCU_SWRST] = 4 * RST_NR_PER_BANK + 12,
1132+
};
1133+
1134+
static const struct mtk_clk_rst_desc clk_rst_desc = {
1135+
.version = MTK_RST_SET_CLR,
1136+
.rst_bank_ofs = infra_ao_rst_ofs,
1137+
.rst_bank_nr = ARRAY_SIZE(infra_ao_rst_ofs),
1138+
.rst_idx_map = infra_ao_idx_map,
1139+
.rst_idx_map_nr = ARRAY_SIZE(infra_ao_idx_map),
1140+
};
1141+
11171142
#define MT8192_PLL_FMAX (3800UL * MHZ)
11181143
#define MT8192_PLL_FMIN (1500UL * MHZ)
11191144
#define MT8192_INTEGER_BITS 8
@@ -1240,6 +1265,10 @@ static int clk_mt8192_infra_probe(struct platform_device *pdev)
12401265
if (r)
12411266
goto free_clk_data;
12421267

1268+
r = mtk_register_reset_controller_with_dev(&pdev->dev, &clk_rst_desc);
1269+
if (r)
1270+
goto free_clk_data;
1271+
12431272
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
12441273
if (r)
12451274
goto free_clk_data;

drivers/clk/mediatek/clk-mt8195-infra_ao.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "clk-mtk.h"
88

99
#include <dt-bindings/clock/mt8195-clk.h>
10+
#include <dt-bindings/reset/mt8195-resets.h>
1011
#include <linux/clk-provider.h>
1112
#include <linux/platform_device.h>
1213

@@ -182,9 +183,32 @@ static const struct mtk_gate infra_ao_clks[] = {
182183
GATE_INFRA_AO4(CLK_INFRA_AO_PERI_UFS_MEM_SUB, "infra_ao_peri_ufs_mem_sub", "mem_466m", 31),
183184
};
184185

186+
static u16 infra_ao_rst_ofs[] = {
187+
INFRA_RST0_SET_OFFSET,
188+
INFRA_RST1_SET_OFFSET,
189+
INFRA_RST2_SET_OFFSET,
190+
INFRA_RST3_SET_OFFSET,
191+
INFRA_RST4_SET_OFFSET,
192+
};
193+
194+
static u16 infra_ao_idx_map[] = {
195+
[MT8195_INFRA_RST0_THERM_CTRL_SWRST] = 0 * RST_NR_PER_BANK + 0,
196+
[MT8195_INFRA_RST3_THERM_CTRL_PTP_SWRST] = 3 * RST_NR_PER_BANK + 5,
197+
[MT8195_INFRA_RST4_THERM_CTRL_MCU_SWRST] = 4 * RST_NR_PER_BANK + 10,
198+
};
199+
200+
static struct mtk_clk_rst_desc infra_ao_rst_desc = {
201+
.version = MTK_RST_SET_CLR,
202+
.rst_bank_ofs = infra_ao_rst_ofs,
203+
.rst_bank_nr = ARRAY_SIZE(infra_ao_rst_ofs),
204+
.rst_idx_map = infra_ao_idx_map,
205+
.rst_idx_map_nr = ARRAY_SIZE(infra_ao_idx_map),
206+
};
207+
185208
static const struct mtk_clk_desc infra_ao_desc = {
186209
.clks = infra_ao_clks,
187210
.num_clks = ARRAY_SIZE(infra_ao_clks),
211+
.rst_desc = &infra_ao_rst_desc,
188212
};
189213

190214
static const struct of_device_id of_match_clk_mt8195_infra_ao[] = {

drivers/clk/mediatek/reset.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111

1212
#define RST_NR_PER_BANK 32
1313

14+
/* Infra global controller reset set register */
15+
#define INFRA_RST0_SET_OFFSET 0x120
16+
#define INFRA_RST1_SET_OFFSET 0x130
17+
#define INFRA_RST2_SET_OFFSET 0x140
18+
#define INFRA_RST3_SET_OFFSET 0x150
19+
#define INFRA_RST4_SET_OFFSET 0x730
20+
1421
/**
1522
* enum mtk_reset_version - Version of MediaTek clock reset controller.
1623
* @MTK_RST_SIMPLE: Use the same registers for bit set and clear.

0 commit comments

Comments
 (0)