Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 
0003 #ifndef __ASM_CSKY_IO_H
0004 #define __ASM_CSKY_IO_H
0005 
0006 #include <linux/pgtable.h>
0007 #include <linux/types.h>
0008 
0009 /*
0010  * I/O memory access primitives. Reads are ordered relative to any
0011  * following Normal memory access. Writes are ordered relative to any prior
0012  * Normal memory access.
0013  *
0014  * For CACHEV1 (807, 810), store instruction could fast retire, so we need
0015  * another mb() to prevent st fast retire.
0016  *
0017  * For CACHEV2 (860), store instruction with PAGE_ATTR_NO_BUFFERABLE won't
0018  * fast retire.
0019  */
0020 #define readb(c)        ({ u8  __v = readb_relaxed(c); rmb(); __v; })
0021 #define readw(c)        ({ u16 __v = readw_relaxed(c); rmb(); __v; })
0022 #define readl(c)        ({ u32 __v = readl_relaxed(c); rmb(); __v; })
0023 
0024 #ifdef CONFIG_CPU_HAS_CACHEV2
0025 #define writeb(v,c)     ({ wmb(); writeb_relaxed((v),(c)); })
0026 #define writew(v,c)     ({ wmb(); writew_relaxed((v),(c)); })
0027 #define writel(v,c)     ({ wmb(); writel_relaxed((v),(c)); })
0028 #else
0029 #define writeb(v,c)     ({ wmb(); writeb_relaxed((v),(c)); mb(); })
0030 #define writew(v,c)     ({ wmb(); writew_relaxed((v),(c)); mb(); })
0031 #define writel(v,c)     ({ wmb(); writel_relaxed((v),(c)); mb(); })
0032 #endif
0033 
0034 /*
0035  * String version of I/O memory access operations.
0036  */
0037 extern void __memcpy_fromio(void *, const volatile void __iomem *, size_t);
0038 extern void __memcpy_toio(volatile void __iomem *, const void *, size_t);
0039 extern void __memset_io(volatile void __iomem *, int, size_t);
0040 
0041 #define memset_io(c,v,l)        __memset_io((c),(v),(l))
0042 #define memcpy_fromio(a,c,l)    __memcpy_fromio((a),(c),(l))
0043 #define memcpy_toio(c,a,l)      __memcpy_toio((c),(a),(l))
0044 
0045 /*
0046  * I/O memory mapping functions.
0047  */
0048 #define ioremap_wc(addr, size) \
0049     ioremap_prot((addr), (size), \
0050         (_PAGE_IOREMAP & ~_CACHE_MASK) | _CACHE_UNCACHED)
0051 
0052 #include <asm-generic/io.h>
0053 
0054 #endif /* __ASM_CSKY_IO_H */