Vineet Gupta | 3be80aa | 2013-01-18 15:12:17 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com) |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | */ |
| 8 | |
| 9 | #ifndef __ARC_ASM_CACHE_H |
| 10 | #define __ARC_ASM_CACHE_H |
| 11 | |
| 12 | /* In case $$ not config, setup a dummy number for rest of kernel */ |
| 13 | #ifndef CONFIG_ARC_CACHE_LINE_SHIFT |
| 14 | #define L1_CACHE_SHIFT 6 |
| 15 | #else |
| 16 | #define L1_CACHE_SHIFT CONFIG_ARC_CACHE_LINE_SHIFT |
| 17 | #endif |
| 18 | |
| 19 | #define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) |
Vineet Gupta | 63d2dfd | 2013-09-05 13:17:49 +0530 | [diff] [blame] | 20 | #define CACHE_LINE_MASK (~(L1_CACHE_BYTES - 1)) |
Vineet Gupta | 95d6976 | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 21 | |
Vineet Gupta | da1677b | 2013-05-14 13:28:17 +0530 | [diff] [blame] | 22 | /* |
Vineet Gupta | c4aa49d | 2014-09-19 01:28:24 +0530 | [diff] [blame] | 23 | * ARC700 doesn't cache any access in top 1G (0xc000_0000 to 0xFFFF_FFFF) |
Vineet Gupta | da1677b | 2013-05-14 13:28:17 +0530 | [diff] [blame] | 24 | * Ideal for wiring memory mapped peripherals as we don't need to do |
| 25 | * explicit uncached accesses (LD.di/ST.di) hence more portable drivers |
| 26 | */ |
| 27 | #define ARC_UNCACHED_ADDR_SPACE 0xc0000000 |
| 28 | |
Vineet Gupta | 95d6976 | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 29 | #ifndef __ASSEMBLY__ |
| 30 | |
| 31 | /* Uncached access macros */ |
| 32 | #define arc_read_uncached_32(ptr) \ |
| 33 | ({ \ |
| 34 | unsigned int __ret; \ |
| 35 | __asm__ __volatile__( \ |
| 36 | " ld.di %0, [%1] \n" \ |
| 37 | : "=r"(__ret) \ |
| 38 | : "r"(ptr)); \ |
| 39 | __ret; \ |
| 40 | }) |
| 41 | |
| 42 | #define arc_write_uncached_32(ptr, data)\ |
| 43 | ({ \ |
| 44 | __asm__ __volatile__( \ |
| 45 | " st.di %0, [%1] \n" \ |
| 46 | : \ |
| 47 | : "r"(data), "r"(ptr)); \ |
| 48 | }) |
| 49 | |
Vineet Gupta | 95d6976 | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 50 | #define ARCH_DMA_MINALIGN L1_CACHE_BYTES |
| 51 | |
Vineet Gupta | 95d6976 | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 52 | extern void arc_cache_init(void); |
| 53 | extern char *arc_cache_mumbojumbo(int cpu_id, char *buf, int len); |
Vineet Gupta | 07b9b65 | 2013-09-05 19:19:06 +0530 | [diff] [blame] | 54 | extern void read_decode_cache_bcr(void); |
Vineet Gupta | da1677b | 2013-05-14 13:28:17 +0530 | [diff] [blame] | 55 | |
Alexey Brodkin | f2b0b25 | 2015-05-25 19:54:28 +0300 | [diff] [blame] | 56 | extern int ioc_exists; |
| 57 | |
Vineet Gupta | da1677b | 2013-05-14 13:28:17 +0530 | [diff] [blame] | 58 | #endif /* !__ASSEMBLY__ */ |
Vineet Gupta | 95d6976 | 2013-01-18 15:12:19 +0530 | [diff] [blame] | 59 | |
Vineet Gupta | ef680cd | 2014-03-07 18:08:11 +0530 | [diff] [blame] | 60 | /* Instruction cache related Auxiliary registers */ |
| 61 | #define ARC_REG_IC_BCR 0x77 /* Build Config reg */ |
| 62 | #define ARC_REG_IC_IVIC 0x10 |
| 63 | #define ARC_REG_IC_CTRL 0x11 |
| 64 | #define ARC_REG_IC_IVIL 0x19 |
Vineet Gupta | ef680cd | 2014-03-07 18:08:11 +0530 | [diff] [blame] | 65 | #define ARC_REG_IC_PTAG 0x1E |
Vineet Gupta | 5a364c2 | 2015-02-06 18:44:57 +0300 | [diff] [blame] | 66 | #define ARC_REG_IC_PTAG_HI 0x1F |
Vineet Gupta | ef680cd | 2014-03-07 18:08:11 +0530 | [diff] [blame] | 67 | |
| 68 | /* Bit val in IC_CTRL */ |
| 69 | #define IC_CTRL_CACHE_DISABLE 0x1 |
| 70 | |
| 71 | /* Data cache related Auxiliary registers */ |
| 72 | #define ARC_REG_DC_BCR 0x72 /* Build Config reg */ |
| 73 | #define ARC_REG_DC_IVDC 0x47 |
| 74 | #define ARC_REG_DC_CTRL 0x48 |
| 75 | #define ARC_REG_DC_IVDL 0x4A |
| 76 | #define ARC_REG_DC_FLSH 0x4B |
| 77 | #define ARC_REG_DC_FLDL 0x4C |
Vineet Gupta | ef680cd | 2014-03-07 18:08:11 +0530 | [diff] [blame] | 78 | #define ARC_REG_DC_PTAG 0x5C |
Vineet Gupta | 5a364c2 | 2015-02-06 18:44:57 +0300 | [diff] [blame] | 79 | #define ARC_REG_DC_PTAG_HI 0x5F |
Vineet Gupta | ef680cd | 2014-03-07 18:08:11 +0530 | [diff] [blame] | 80 | |
| 81 | /* Bit val in DC_CTRL */ |
| 82 | #define DC_CTRL_INV_MODE_FLUSH 0x40 |
| 83 | #define DC_CTRL_FLUSH_STATUS 0x100 |
| 84 | |
Vineet Gupta | d1f317d | 2015-04-06 17:23:57 +0530 | [diff] [blame] | 85 | /*System-level cache (L2 cache) related Auxiliary registers */ |
| 86 | #define ARC_REG_SLC_CFG 0x901 |
Vineet Gupta | 795f455 | 2015-04-03 12:37:07 +0300 | [diff] [blame] | 87 | #define ARC_REG_SLC_CTRL 0x903 |
| 88 | #define ARC_REG_SLC_FLUSH 0x904 |
| 89 | #define ARC_REG_SLC_INVALIDATE 0x905 |
| 90 | #define ARC_REG_SLC_RGN_START 0x914 |
| 91 | #define ARC_REG_SLC_RGN_END 0x916 |
| 92 | |
| 93 | /* Bit val in SLC_CONTROL */ |
| 94 | #define SLC_CTRL_IM 0x040 |
| 95 | #define SLC_CTRL_DISABLE 0x001 |
| 96 | #define SLC_CTRL_BUSY 0x100 |
| 97 | #define SLC_CTRL_RGN_OP_INV 0x200 |
Vineet Gupta | d1f317d | 2015-04-06 17:23:57 +0530 | [diff] [blame] | 98 | |
Alexey Brodkin | f2b0b25 | 2015-05-25 19:54:28 +0300 | [diff] [blame] | 99 | /* IO coherency related Auxiliary registers */ |
| 100 | #define ARC_REG_IO_COH_ENABLE 0x500 |
| 101 | #define ARC_REG_IO_COH_PARTIAL 0x501 |
| 102 | #define ARC_REG_IO_COH_AP0_BASE 0x508 |
| 103 | #define ARC_REG_IO_COH_AP0_SIZE 0x509 |
| 104 | |
Vineet Gupta | 3be80aa | 2013-01-18 15:12:17 +0530 | [diff] [blame] | 105 | #endif /* _ASM_CACHE_H */ |