~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/sh/mm/cache-sh2.c

Version: ~ [ linux-5.9 ] ~ [ linux-5.8.14 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.70 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.150 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.200 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.238 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.238 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.85 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * arch/sh/mm/cache-sh2.c
  3  *
  4  * Copyright (C) 2002 Paul Mundt
  5  * Copyright (C) 2008 Yoshinori Sato
  6  *
  7  * Released under the terms of the GNU GPL v2.0.
  8  */
  9 
 10 #include <linux/init.h>
 11 #include <linux/mm.h>
 12 
 13 #include <asm/cache.h>
 14 #include <asm/addrspace.h>
 15 #include <asm/processor.h>
 16 #include <asm/cacheflush.h>
 17 #include <asm/io.h>
 18 
 19 static void sh2__flush_wback_region(void *start, int size)
 20 {
 21         unsigned long v;
 22         unsigned long begin, end;
 23 
 24         begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
 25         end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
 26                 & ~(L1_CACHE_BYTES-1);
 27         for (v = begin; v < end; v+=L1_CACHE_BYTES) {
 28                 unsigned long addr = CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0);
 29                 int way;
 30                 for (way = 0; way < 4; way++) {
 31                         unsigned long data =  __raw_readl(addr | (way << 12));
 32                         if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) {
 33                                 data &= ~SH_CACHE_UPDATED;
 34                                 __raw_writel(data, addr | (way << 12));
 35                         }
 36                 }
 37         }
 38 }
 39 
 40 static void sh2__flush_purge_region(void *start, int size)
 41 {
 42         unsigned long v;
 43         unsigned long begin, end;
 44 
 45         begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
 46         end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
 47                 & ~(L1_CACHE_BYTES-1);
 48 
 49         for (v = begin; v < end; v+=L1_CACHE_BYTES)
 50                 __raw_writel((v & CACHE_PHYSADDR_MASK),
 51                           CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0) | 0x00000008);
 52 }
 53 
 54 static void sh2__flush_invalidate_region(void *start, int size)
 55 {
 56 #ifdef CONFIG_CACHE_WRITEBACK
 57         /*
 58          * SH-2 does not support individual line invalidation, only a
 59          * global invalidate.
 60          */
 61         unsigned long ccr;
 62         unsigned long flags;
 63         local_irq_save(flags);
 64         jump_to_uncached();
 65 
 66         ccr = __raw_readl(SH_CCR);
 67         ccr |= CCR_CACHE_INVALIDATE;
 68         __raw_writel(ccr, SH_CCR);
 69 
 70         back_to_cached();
 71         local_irq_restore(flags);
 72 #else
 73         unsigned long v;
 74         unsigned long begin, end;
 75 
 76         begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
 77         end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
 78                 & ~(L1_CACHE_BYTES-1);
 79 
 80         for (v = begin; v < end; v+=L1_CACHE_BYTES)
 81                 __raw_writel((v & CACHE_PHYSADDR_MASK),
 82                           CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0) | 0x00000008);
 83 #endif
 84 }
 85 
 86 void __init sh2_cache_init(void)
 87 {
 88         __flush_wback_region            = sh2__flush_wback_region;
 89         __flush_purge_region            = sh2__flush_purge_region;
 90         __flush_invalidate_region       = sh2__flush_invalidate_region;
 91 }
 92 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp