diff options
author | Vineet Gupta <vgupta@synopsys.com> | 2016-06-22 06:13:22 -0400 |
---|---|---|
committer | Vineet Gupta <vgupta@synopsys.com> | 2017-01-18 17:35:10 -0500 |
commit | d4911cdd3270da45d3a1c55bf28e88a932bbba7b (patch) | |
tree | 6fc1514bb32dbaa0b27441857d973e5613b2227d | |
parent | eb1357d942e5d96de6b4c20a8ffa55acf96233a2 (diff) |
ARCv2: IOC: refactor the IOC and SLC operations into own functions
- Move IOC setup into arc_ioc_setup()
- Move SLC disabling into arc_slc_disable()
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
-rw-r--r-- | arch/arc/include/asm/cache.h | 2 | ||||
-rw-r--r-- | arch/arc/mm/cache.c | 68 |
2 files changed, 48 insertions, 22 deletions
diff --git a/arch/arc/include/asm/cache.h b/arch/arc/include/asm/cache.h index b3410ff6a62d..5f924a1024fa 100644 --- a/arch/arc/include/asm/cache.h +++ b/arch/arc/include/asm/cache.h | |||
@@ -92,8 +92,8 @@ extern unsigned long perip_base, perip_end; | |||
92 | #define ARC_REG_SLC_RGN_END 0x916 | 92 | #define ARC_REG_SLC_RGN_END 0x916 |
93 | 93 | ||
94 | /* Bit val in SLC_CONTROL */ | 94 | /* Bit val in SLC_CONTROL */ |
95 | #define SLC_CTRL_DIS 0x001 | ||
95 | #define SLC_CTRL_IM 0x040 | 96 | #define SLC_CTRL_IM 0x040 |
96 | #define SLC_CTRL_DISABLE 0x001 | ||
97 | #define SLC_CTRL_BUSY 0x100 | 97 | #define SLC_CTRL_BUSY 0x100 |
98 | #define SLC_CTRL_RGN_OP_INV 0x200 | 98 | #define SLC_CTRL_RGN_OP_INV 0x200 |
99 | 99 | ||
diff --git a/arch/arc/mm/cache.c b/arch/arc/mm/cache.c index 6d98e1d57a18..2c36370a1689 100644 --- a/arch/arc/mm/cache.c +++ b/arch/arc/mm/cache.c | |||
@@ -601,6 +601,40 @@ noinline void slc_op(phys_addr_t paddr, unsigned long sz, const int op) | |||
601 | #endif | 601 | #endif |
602 | } | 602 | } |
603 | 603 | ||
604 | noinline static void slc_entire_op(const int op) | ||
605 | { | ||
606 | unsigned int ctrl, r = ARC_REG_SLC_CTRL; | ||
607 | |||
608 | ctrl = read_aux_reg(r); | ||
609 | |||
610 | if (!(op & OP_FLUSH)) /* i.e. OP_INV */ | ||
611 | ctrl &= ~SLC_CTRL_IM; /* clear IM: Disable flush before Inv */ | ||
612 | else | ||
613 | ctrl |= SLC_CTRL_IM; | ||
614 | |||
615 | write_aux_reg(r, ctrl); | ||
616 | |||
617 | write_aux_reg(ARC_REG_SLC_INVALIDATE, 1); | ||
618 | |||
619 | /* Important to wait for flush to complete */ | ||
620 | while (read_aux_reg(r) & SLC_CTRL_BUSY); | ||
621 | } | ||
622 | |||
623 | static inline void arc_slc_disable(void) | ||
624 | { | ||
625 | const int r = ARC_REG_SLC_CTRL; | ||
626 | |||
627 | slc_entire_op(OP_FLUSH_N_INV); | ||
628 | write_aux_reg(r, read_aux_reg(r) | SLC_CTRL_DIS); | ||
629 | } | ||
630 | |||
631 | static inline void arc_slc_enable(void) | ||
632 | { | ||
633 | const int r = ARC_REG_SLC_CTRL; | ||
634 | |||
635 | write_aux_reg(r, read_aux_reg(r) & ~SLC_CTRL_DIS); | ||
636 | } | ||
637 | |||
604 | /*********************************************************** | 638 | /*********************************************************** |
605 | * Exported APIs | 639 | * Exported APIs |
606 | */ | 640 | */ |
@@ -927,6 +961,14 @@ SYSCALL_DEFINE3(cacheflush, uint32_t, start, uint32_t, sz, uint32_t, flags) | |||
927 | return 0; | 961 | return 0; |
928 | } | 962 | } |
929 | 963 | ||
964 | noinline void arc_ioc_setup(void) | ||
965 | { | ||
966 | write_aux_reg(ARC_REG_IO_COH_AP0_BASE, 0x80000); | ||
967 | write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, 0x11); | ||
968 | write_aux_reg(ARC_REG_IO_COH_PARTIAL, 1); | ||
969 | write_aux_reg(ARC_REG_IO_COH_ENABLE, 1); | ||
970 | } | ||
971 | |||
930 | void arc_cache_init(void) | 972 | void arc_cache_init(void) |
931 | { | 973 | { |
932 | unsigned int __maybe_unused cpu = smp_processor_id(); | 974 | unsigned int __maybe_unused cpu = smp_processor_id(); |
@@ -989,30 +1031,14 @@ void arc_cache_init(void) | |||
989 | } | 1031 | } |
990 | } | 1032 | } |
991 | 1033 | ||
992 | if (is_isa_arcv2() && l2_line_sz && !slc_enable) { | 1034 | /* Note that SLC disable not formally supported till HS 3.0 */ |
993 | 1035 | if (is_isa_arcv2() && l2_line_sz && !slc_enable) | |
994 | /* IM set : flush before invalidate */ | 1036 | arc_slc_disable(); |
995 | write_aux_reg(ARC_REG_SLC_CTRL, | ||
996 | read_aux_reg(ARC_REG_SLC_CTRL) | SLC_CTRL_IM); | ||
997 | 1037 | ||
998 | write_aux_reg(ARC_REG_SLC_INVALIDATE, 1); | 1038 | if (is_isa_arcv2() && ioc_enable) |
999 | 1039 | arc_ioc_setup(); | |
1000 | /* Important to wait for flush to complete */ | ||
1001 | while (read_aux_reg(ARC_REG_SLC_CTRL) & SLC_CTRL_BUSY); | ||
1002 | write_aux_reg(ARC_REG_SLC_CTRL, | ||
1003 | read_aux_reg(ARC_REG_SLC_CTRL) | SLC_CTRL_DISABLE); | ||
1004 | } | ||
1005 | 1040 | ||
1006 | if (is_isa_arcv2() && ioc_enable) { | 1041 | if (is_isa_arcv2() && ioc_enable) { |
1007 | /* IO coherency base - 0x8z */ | ||
1008 | write_aux_reg(ARC_REG_IO_COH_AP0_BASE, 0x80000); | ||
1009 | /* IO coherency aperture size - 512Mb: 0x8z-0xAz */ | ||
1010 | write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, 0x11); | ||
1011 | /* Enable partial writes */ | ||
1012 | write_aux_reg(ARC_REG_IO_COH_PARTIAL, 1); | ||
1013 | /* Enable IO coherency */ | ||
1014 | write_aux_reg(ARC_REG_IO_COH_ENABLE, 1); | ||
1015 | |||
1016 | __dma_cache_wback_inv = __dma_cache_wback_inv_ioc; | 1042 | __dma_cache_wback_inv = __dma_cache_wback_inv_ioc; |
1017 | __dma_cache_inv = __dma_cache_inv_ioc; | 1043 | __dma_cache_inv = __dma_cache_inv_ioc; |
1018 | __dma_cache_wback = __dma_cache_wback_ioc; | 1044 | __dma_cache_wback = __dma_cache_wback_ioc; |