2 * Copyright 2015 Freescale Semiconductor, Inc.
4 * SPDX-License-Identifier: GPL-2.0+
12 #ifndef CONFIG_SYS_DCACHE_OFF
13 void enable_caches(void)
15 #if defined(CONFIG_SYS_ARM_CACHE_WRITETHROUGH)
16 enum dcache_option option = DCACHE_WRITETHROUGH;
18 enum dcache_option option = DCACHE_WRITEBACK;
20 /* Avoid random hang when download by usb */
21 invalidate_dcache_all();
23 /* Enable D-cache. I-cache is already enabled in start.S */
26 /* Enable caching on OCRAM and ROM */
27 mmu_set_region_dcache_behaviour(ROMCP_ARB_BASE_ADDR,
30 mmu_set_region_dcache_behaviour(IRAM_BASE_ADDR,
36 #ifndef CONFIG_SYS_L2CACHE_OFF
37 #ifdef CONFIG_SYS_L2_PL310
38 #define IOMUXC_GPR11_L2CACHE_AS_OCRAM 0x00000002
39 void v7_outer_cache_enable(void)
41 struct pl310_regs *const pl310 = (struct pl310_regs *)L2_PL310_BASE;
46 * Set bit 22 in the auxiliary control register. If this bit
47 * is cleared, PL310 treats Normal Shared Non-cacheable
48 * accesses as Cacheable no-allocate.
50 setbits_le32(&pl310->pl310_aux_ctrl, L310_SHARED_ATT_OVERRIDE_ENABLE);
52 #if defined CONFIG_MX6SL
53 struct iomuxc *iomux = (struct iomuxc *)IOMUXC_BASE_ADDR;
54 val = readl(&iomux->gpr[11]);
55 if (val & IOMUXC_GPR11_L2CACHE_AS_OCRAM) {
56 /* L2 cache configured as OCRAM, reset it */
57 val &= ~IOMUXC_GPR11_L2CACHE_AS_OCRAM;
58 writel(val, &iomux->gpr[11]);
62 /* Must disable the L2 before changing the latency parameters */
63 clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
65 writel(0x132, &pl310->pl310_tag_latency_ctrl);
66 writel(0x132, &pl310->pl310_data_latency_ctrl);
68 val = readl(&pl310->pl310_prefetch_ctrl);
70 /* Turn on the L2 I/D prefetch */
74 * The L2 cache controller(PL310) version on the i.MX6D/Q is r3p1-50rel0
75 * The L2 cache controller(PL310) version on the i.MX6DL/SOLO/SL is r3p2
76 * But according to ARM PL310 errata: 752271
77 * ID: 752271: Double linefill feature can cause data corruption
78 * Fault Status: Present in: r3p0, r3p1, r3p1-50rel0. Fixed in r3p2
79 * Workaround: The only workaround to this erratum is to disable the
80 * double linefill feature. This is the default behavior.
86 writel(val, &pl310->pl310_prefetch_ctrl);
88 val = readl(&pl310->pl310_power_ctrl);
89 val |= L2X0_DYNAMIC_CLK_GATING_EN;
90 val |= L2X0_STNDBY_MODE_EN;
91 writel(val, &pl310->pl310_power_ctrl);
93 setbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
96 void v7_outer_cache_disable(void)
98 struct pl310_regs *const pl310 = (struct pl310_regs *)L2_PL310_BASE;
100 clrbits_le32(&pl310->pl310_ctrl, L2X0_CTRL_EN);
102 #endif /* !CONFIG_SYS_L2_PL310 */
103 #endif /* !CONFIG_SYS_L2CACHE_OFF */