Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memory: mtk-smi: mt8195: Add initial setting for smi-larb

To improve the performance, We add some initial setting for smi larbs.
there are two part:
1), Each port has the special ostd(outstanding) value in each larb.
2), Two general settings for each larb.
a. THRT_UPDATE: the value in bits[7:4] of 0x24 is not so good.
The HW default is 4, and we expect it is 5, thus, add a flag to update
it. This is only a DE recommendatory value, not a actual issue.
The register name(THRT_CON) means: throttling control, and the field
RD_NU_LMT means: Read Non-ultra commands limit.
This change means update the Read non-ultra command from 4 to 5 here.

b. SW_FLAG: Set 1 to the FLAG register. this is only for helping
debug. We could confirm if the larb is reset from this value is 1 or 0.

In some SoC, this setting maybe changed dynamically for some special case
like 4K, and this initial setting is enough in mt8195.

Signed-off-by: Yong Wu <yong.wu@mediatek.com>
Link: https://lore.kernel.org/r/20210914113703.31466-13-yong.wu@mediatek.com
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

authored by

Yong Wu and committed by
Krzysztof Kozlowski
fe6dd2a4 431e9cab

+78 -1
+78 -1
drivers/memory/mtk-smi.c
··· 32 32 #define SMI_DUMMY 0x444 33 33 34 34 /* SMI LARB */ 35 + #define SMI_LARB_CMD_THRT_CON 0x24 36 + #define SMI_LARB_THRT_RD_NU_LMT_MSK GENMASK(7, 4) 37 + #define SMI_LARB_THRT_RD_NU_LMT (5 << 4) 38 + 39 + #define SMI_LARB_SW_FLAG 0x40 40 + #define SMI_LARB_SW_FLAG_1 0x1 41 + 42 + #define SMI_LARB_OSTDL_PORT 0x200 43 + #define SMI_LARB_OSTDL_PORTx(id) (SMI_LARB_OSTDL_PORT + (((id) & 0x1f) << 2)) 35 44 36 45 /* Below are about mmu enable registers, they are different in SoCs */ 37 46 /* gen1: mt2701 */ ··· 77 68 }) 78 69 79 70 #define SMI_COMMON_INIT_REGS_NR 6 71 + #define SMI_LARB_PORT_NR_MAX 32 72 + 73 + #define MTK_SMI_FLAG_THRT_UPDATE BIT(0) 74 + #define MTK_SMI_FLAG_SW_FLAG BIT(1) 75 + #define MTK_SMI_CAPS(flags, _x) (!!((flags) & (_x))) 80 76 81 77 struct mtk_smi_reg_pair { 82 78 unsigned int offset; ··· 122 108 int port_in_larb[MTK_LARB_NR_MAX + 1]; 123 109 void (*config_port)(struct device *dev); 124 110 unsigned int larb_direct_to_common_mask; 111 + unsigned int flags_general; 112 + const u8 (*ostd)[SMI_LARB_PORT_NR_MAX]; 125 113 }; 126 114 127 115 struct mtk_smi { ··· 240 224 static void mtk_smi_larb_config_port_gen2_general(struct device *dev) 241 225 { 242 226 struct mtk_smi_larb *larb = dev_get_drvdata(dev); 243 - u32 reg; 227 + u32 reg, flags_general = larb->larb_gen->flags_general; 228 + const u8 *larbostd = larb->larb_gen->ostd[larb->larbid]; 244 229 int i; 245 230 246 231 if (BIT(larb->larbid) & larb->larb_gen->larb_direct_to_common_mask) 247 232 return; 233 + 234 + if (MTK_SMI_CAPS(flags_general, MTK_SMI_FLAG_THRT_UPDATE)) { 235 + reg = readl_relaxed(larb->base + SMI_LARB_CMD_THRT_CON); 236 + reg &= ~SMI_LARB_THRT_RD_NU_LMT_MSK; 237 + reg |= SMI_LARB_THRT_RD_NU_LMT; 238 + writel_relaxed(reg, larb->base + SMI_LARB_CMD_THRT_CON); 239 + } 240 + 241 + if (MTK_SMI_CAPS(flags_general, MTK_SMI_FLAG_SW_FLAG)) 242 + writel_relaxed(SMI_LARB_SW_FLAG_1, larb->base + SMI_LARB_SW_FLAG); 243 + 244 + for (i = 0; i < SMI_LARB_PORT_NR_MAX && larbostd && !!larbostd[i]; i++) 245 + writel_relaxed(larbostd[i], larb->base + SMI_LARB_OSTDL_PORTx(i)); 248 246 249 247 for_each_set_bit(i, (unsigned long *)larb->mmu, 32) { 250 248 reg = readl_relaxed(larb->base + SMI_LARB_NONSEC_CON(i)); ··· 267 237 writel(reg, larb->base + SMI_LARB_NONSEC_CON(i)); 268 238 } 269 239 } 240 + 241 + static const u8 mtk_smi_larb_mt8195_ostd[][SMI_LARB_PORT_NR_MAX] = { 242 + [0] = {0x0a, 0xc, 0x22, 0x22, 0x01, 0x0a,}, /* larb0 */ 243 + [1] = {0x0a, 0xc, 0x22, 0x22, 0x01, 0x0a,}, /* larb1 */ 244 + [2] = {0x12, 0x12, 0x12, 0x12, 0x0a,}, /* ... */ 245 + [3] = {0x12, 0x12, 0x12, 0x12, 0x28, 0x28, 0x0a,}, 246 + [4] = {0x06, 0x01, 0x17, 0x06, 0x0a,}, 247 + [5] = {0x06, 0x01, 0x17, 0x06, 0x06, 0x01, 0x06, 0x0a,}, 248 + [6] = {0x06, 0x01, 0x06, 0x0a,}, 249 + [7] = {0x0c, 0x0c, 0x12,}, 250 + [8] = {0x0c, 0x0c, 0x12,}, 251 + [9] = {0x0a, 0x08, 0x04, 0x06, 0x01, 0x01, 0x10, 0x18, 0x11, 0x0a, 252 + 0x08, 0x04, 0x11, 0x06, 0x02, 0x06, 0x01, 0x11, 0x11, 0x06,}, 253 + [10] = {0x18, 0x08, 0x01, 0x01, 0x20, 0x12, 0x18, 0x06, 0x05, 0x10, 254 + 0x08, 0x08, 0x10, 0x08, 0x08, 0x18, 0x0c, 0x09, 0x0b, 0x0d, 255 + 0x0d, 0x06, 0x10, 0x10,}, 256 + [11] = {0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x0e, 0x01, 0x01, 0x01, 0x01,}, 257 + [12] = {0x09, 0x09, 0x05, 0x05, 0x0c, 0x18, 0x02, 0x02, 0x04, 0x02,}, 258 + [13] = {0x02, 0x02, 0x12, 0x12, 0x02, 0x02, 0x02, 0x02, 0x08, 0x01,}, 259 + [14] = {0x12, 0x12, 0x02, 0x02, 0x02, 0x02, 0x16, 0x01, 0x16, 0x01, 260 + 0x01, 0x02, 0x02, 0x08, 0x02,}, 261 + [15] = {}, 262 + [16] = {0x28, 0x02, 0x02, 0x12, 0x02, 0x12, 0x10, 0x02, 0x02, 0x0a, 263 + 0x12, 0x02, 0x0a, 0x16, 0x02, 0x04,}, 264 + [17] = {0x1a, 0x0e, 0x0a, 0x0a, 0x0c, 0x0e, 0x10,}, 265 + [18] = {0x12, 0x06, 0x12, 0x06,}, 266 + [19] = {0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x04, 0x01, 267 + 0x01, 0x01, 0x04, 0x0a, 0x06, 0x01, 0x01, 0x01, 0x0a, 0x06, 268 + 0x01, 0x01, 0x05, 0x03, 0x03, 0x04, 0x01,}, 269 + [20] = {0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x04, 0x01, 270 + 0x01, 0x01, 0x04, 0x0a, 0x06, 0x01, 0x01, 0x01, 0x0a, 0x06, 271 + 0x01, 0x01, 0x05, 0x03, 0x03, 0x04, 0x01,}, 272 + [21] = {0x28, 0x19, 0x0c, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04,}, 273 + [22] = {0x28, 0x19, 0x0c, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04,}, 274 + [23] = {0x18, 0x01,}, 275 + [24] = {0x01, 0x01, 0x04, 0x01, 0x01, 0x01, 0x01, 0x01, 0x04, 0x01, 276 + 0x01, 0x01,}, 277 + [25] = {0x02, 0x02, 0x02, 0x28, 0x16, 0x02, 0x02, 0x02, 0x12, 0x16, 278 + 0x02, 0x01,}, 279 + [26] = {0x02, 0x02, 0x02, 0x28, 0x16, 0x02, 0x02, 0x02, 0x12, 0x16, 280 + 0x02, 0x01,}, 281 + [27] = {0x02, 0x02, 0x02, 0x28, 0x16, 0x02, 0x02, 0x02, 0x12, 0x16, 282 + 0x02, 0x01,}, 283 + [28] = {0x1a, 0x0e, 0x0a, 0x0a, 0x0c, 0x0e, 0x10,}, 284 + }; 270 285 271 286 static const struct mtk_smi_larb_gen mtk_smi_larb_mt2701 = { 272 287 .port_in_larb = { ··· 355 280 356 281 static const struct mtk_smi_larb_gen mtk_smi_larb_mt8195 = { 357 282 .config_port = mtk_smi_larb_config_port_gen2_general, 283 + .flags_general = MTK_SMI_FLAG_THRT_UPDATE | MTK_SMI_FLAG_SW_FLAG, 284 + .ostd = mtk_smi_larb_mt8195_ostd, 358 285 }; 359 286 360 287 static const struct of_device_id mtk_smi_larb_of_ids[] = {