]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - arch/nds32/lib/cache.c
2 * Copyright (C) 2012 Andes Technology Corporation
3 * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
4 * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
6 * SPDX-License-Identifier: GPL-2.0+
11 static inline unsigned long CACHE_LINE_SIZE(enum cache_t cache
)
14 return 8 << (((GET_ICM_CFG() & ICM_CFG_MSK_ISZ
) \
15 >> ICM_CFG_OFF_ISZ
) - 1);
17 return 8 << (((GET_DCM_CFG() & DCM_CFG_MSK_DSZ
) \
18 >> DCM_CFG_OFF_DSZ
) - 1);
21 void flush_dcache_range(unsigned long start
, unsigned long end
)
23 unsigned long line_size
;
25 line_size
= CACHE_LINE_SIZE(DCACHE
);
29 "\n\tcctl %0, L1D_VA_WB"
30 "\n\tcctl %0, L1D_VA_INVAL"
38 void invalidate_icache_range(unsigned long start
, unsigned long end
)
40 unsigned long line_size
;
42 line_size
= CACHE_LINE_SIZE(ICACHE
);
45 "\n\tcctl %0, L1I_VA_INVAL"
53 void invalidate_dcache_range(unsigned long start
, unsigned long end
)
55 unsigned long line_size
;
57 line_size
= CACHE_LINE_SIZE(DCACHE
);
60 "\n\tcctl %0, L1D_VA_INVAL"
68 void flush_cache(unsigned long addr
, unsigned long size
)
70 flush_dcache_range(addr
, addr
+ size
);
71 invalidate_icache_range(addr
, addr
+ size
);
74 void icache_enable(void)
78 "ori $p0, $p0, 0x01\n\t"
84 void icache_disable(void)
89 "and $p0, $p0, $p1\n\t"
95 int icache_status(void)
101 "andi %0, $p0, 0x01\n\t"
110 void dcache_enable(void)
114 "ori $p0, $p0, 0x02\n\t"
120 void dcache_disable(void)
125 "and $p0, $p0, $p1\n\t"
131 int dcache_status(void)
137 "andi %0, $p0, 0x02\n\t"