Commit | Line | Data |
---|---|---|
3c1fbd51 MF |
1 | /* |
2 | * Blackfin cache control code (simpler control-style functions) | |
3 | * | |
ea426e6c | 4 | * Copyright 2004-2009 Analog Devices Inc. |
3c1fbd51 | 5 | * |
3c1fbd51 MF |
6 | * Licensed under the GPL-2 or later. |
7 | */ | |
8 | ||
9 | #include <asm/blackfin.h> | |
ea426e6c | 10 | #include <asm/cplbinit.h> |
3c1fbd51 MF |
11 | |
12 | /* Invalidate the Entire Data cache by | |
13 | * clearing DMC[1:0] bits | |
14 | */ | |
15 | void blackfin_invalidate_entire_dcache(void) | |
16 | { | |
17 | u32 dmem = bfin_read_DMEM_CONTROL(); | |
3c1fbd51 MF |
18 | bfin_write_DMEM_CONTROL(dmem & ~0xc); |
19 | SSYNC(); | |
20 | bfin_write_DMEM_CONTROL(dmem); | |
21 | SSYNC(); | |
22 | } | |
47e9dedb SZ |
23 | |
24 | /* Invalidate the Entire Instruction cache by | |
25 | * clearing IMC bit | |
26 | */ | |
27 | void blackfin_invalidate_entire_icache(void) | |
28 | { | |
29 | u32 imem = bfin_read_IMEM_CONTROL(); | |
30 | bfin_write_IMEM_CONTROL(imem & ~0x4); | |
31 | SSYNC(); | |
32 | bfin_write_IMEM_CONTROL(imem); | |
33 | SSYNC(); | |
34 | } | |
35 | ||
ea426e6c MF |
36 | #if defined(CONFIG_BFIN_ICACHE) || defined(CONFIG_BFIN_DCACHE) |
37 | ||
38 | static void | |
39 | bfin_cache_init(struct cplb_entry *cplb_tbl, unsigned long cplb_addr, | |
40 | unsigned long cplb_data, unsigned long mem_control, | |
41 | unsigned long mem_mask) | |
42 | { | |
43 | int i; | |
44 | ||
45 | for (i = 0; i < MAX_CPLBS; i++) { | |
46 | bfin_write32(cplb_addr + i * 4, cplb_tbl[i].addr); | |
47 | bfin_write32(cplb_data + i * 4, cplb_tbl[i].data); | |
48 | } | |
49 | ||
50 | _enable_cplb(mem_control, mem_mask); | |
51 | } | |
52 | ||
53 | #ifdef CONFIG_BFIN_ICACHE | |
13dff62d | 54 | void bfin_icache_init(struct cplb_entry *icplb_tbl) |
ea426e6c MF |
55 | { |
56 | bfin_cache_init(icplb_tbl, ICPLB_ADDR0, ICPLB_DATA0, IMEM_CONTROL, | |
57 | (IMC | ENICPLB)); | |
58 | } | |
59 | #endif | |
60 | ||
61 | #ifdef CONFIG_BFIN_DCACHE | |
13dff62d | 62 | void bfin_dcache_init(struct cplb_entry *dcplb_tbl) |
ea426e6c MF |
63 | { |
64 | /* | |
65 | * Anomaly notes: | |
66 | * 05000287 - We implement workaround #2 - Change the DMEM_CONTROL | |
67 | * register, so that the port preferences for DAG0 and DAG1 are set | |
68 | * to port B | |
69 | */ | |
70 | bfin_cache_init(dcplb_tbl, DCPLB_ADDR0, DCPLB_DATA0, DMEM_CONTROL, | |
71 | (DMEM_CNTR | PORT_PREF0 | (ANOMALY_05000287 ? PORT_PREF1 : 0))); | |
72 | } | |
73 | #endif | |
74 | ||
75 | #endif |