Skip to content

Commit 567e58c

Browse files
YongWu-HFjoergroedel
authored andcommitted
memory: mtk-smi: Add bus_sel for mt8183
There are 2 mmu cells in a M4U HW. we could adjust some larbs entering mmu0 or mmu1 to balance the bandwidth via the smi-common register SMI_BUS_SEL(0x220)(Each larb occupy 2 bits). In mt8183, For better performance, we switch larb1/2/5/7 to enter mmu1 while the others still keep enter mmu0. In mt8173 and mt2712, we don't get the performance issue, Keep its default value(0x0), that means all the larbs enter mmu0. Note: smi gen1(mt2701/mt7623) don't have this bus_sel. And, the base of smi-common is completely different with smi_ao_base of gen1, thus I add new variable for that. CC: Matthias Brugger <[email protected]> Signed-off-by: Yong Wu <[email protected]> Reviewed-by: Evan Green <[email protected]> Reviewed-by: Matthias Brugger <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent 4f0a1a1 commit 567e58c

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

drivers/memory/mtk-smi.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@
4141
#define SMI_LARB_NONSEC_CON(id) (0x380 + ((id) * 4))
4242
#define F_MMU_EN BIT(0)
4343

44+
/* SMI COMMON */
45+
#define SMI_BUS_SEL 0x220
46+
#define SMI_BUS_LARB_SHIFT(larbid) ((larbid) << 1)
47+
/* All are MMU0 defaultly. Only specialize mmu1 here. */
48+
#define F_MMU1_LARB(larbid) (0x1 << SMI_BUS_LARB_SHIFT(larbid))
49+
4450
enum mtk_smi_gen {
4551
MTK_SMI_GEN1,
4652
MTK_SMI_GEN2
@@ -49,6 +55,7 @@ enum mtk_smi_gen {
4955
struct mtk_smi_common_plat {
5056
enum mtk_smi_gen gen;
5157
bool has_gals;
58+
u32 bus_sel; /* Balance some larbs to enter mmu0 or mmu1 */
5259
};
5360

5461
struct mtk_smi_larb_gen {
@@ -64,8 +71,10 @@ struct mtk_smi {
6471
struct clk *clk_apb, *clk_smi;
6572
struct clk *clk_gals0, *clk_gals1;
6673
struct clk *clk_async; /*only needed by mt2701*/
67-
void __iomem *smi_ao_base;
68-
74+
union {
75+
void __iomem *smi_ao_base; /* only for gen1 */
76+
void __iomem *base; /* only for gen2 */
77+
};
6978
const struct mtk_smi_common_plat *plat;
7079
};
7180

@@ -402,6 +411,8 @@ static const struct mtk_smi_common_plat mtk_smi_common_gen2 = {
402411
static const struct mtk_smi_common_plat mtk_smi_common_mt8183 = {
403412
.gen = MTK_SMI_GEN2,
404413
.has_gals = true,
414+
.bus_sel = F_MMU1_LARB(1) | F_MMU1_LARB(2) | F_MMU1_LARB(5) |
415+
F_MMU1_LARB(7),
405416
};
406417

407418
static const struct of_device_id mtk_smi_common_of_ids[] = {
@@ -474,6 +485,11 @@ static int mtk_smi_common_probe(struct platform_device *pdev)
474485
ret = clk_prepare_enable(common->clk_async);
475486
if (ret)
476487
return ret;
488+
} else {
489+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
490+
common->base = devm_ioremap_resource(dev, res);
491+
if (IS_ERR(common->base))
492+
return PTR_ERR(common->base);
477493
}
478494
pm_runtime_enable(dev);
479495
platform_set_drvdata(pdev, common);
@@ -489,13 +505,17 @@ static int mtk_smi_common_remove(struct platform_device *pdev)
489505
static int __maybe_unused mtk_smi_common_resume(struct device *dev)
490506
{
491507
struct mtk_smi *common = dev_get_drvdata(dev);
508+
u32 bus_sel = common->plat->bus_sel;
492509
int ret;
493510

494511
ret = mtk_smi_clk_enable(common);
495512
if (ret) {
496513
dev_err(common->dev, "Failed to enable clock(%d).\n", ret);
497514
return ret;
498515
}
516+
517+
if (common->plat->gen == MTK_SMI_GEN2 && bus_sel)
518+
writel(bus_sel, common->base + SMI_BUS_SEL);
499519
return 0;
500520
}
501521

0 commit comments

Comments
 (0)