18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef __ASM_CSKY_IO_H 58c2ecf20Sopenharmony_ci#define __ASM_CSKY_IO_H 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include <linux/pgtable.h> 88c2ecf20Sopenharmony_ci#include <linux/types.h> 98c2ecf20Sopenharmony_ci#include <linux/version.h> 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci/* 128c2ecf20Sopenharmony_ci * I/O memory access primitives. Reads are ordered relative to any 138c2ecf20Sopenharmony_ci * following Normal memory access. Writes are ordered relative to any prior 148c2ecf20Sopenharmony_ci * Normal memory access. 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * For CACHEV1 (807, 810), store instruction could fast retire, so we need 178c2ecf20Sopenharmony_ci * another mb() to prevent st fast retire. 188c2ecf20Sopenharmony_ci * 198c2ecf20Sopenharmony_ci * For CACHEV2 (860), store instruction with PAGE_ATTR_NO_BUFFERABLE won't 208c2ecf20Sopenharmony_ci * fast retire. 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci#define readb(c) ({ u8 __v = readb_relaxed(c); rmb(); __v; }) 238c2ecf20Sopenharmony_ci#define readw(c) ({ u16 __v = readw_relaxed(c); rmb(); __v; }) 248c2ecf20Sopenharmony_ci#define readl(c) ({ u32 __v = readl_relaxed(c); rmb(); __v; }) 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_HAS_CACHEV2 278c2ecf20Sopenharmony_ci#define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); }) 288c2ecf20Sopenharmony_ci#define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); }) 298c2ecf20Sopenharmony_ci#define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); }) 308c2ecf20Sopenharmony_ci#else 318c2ecf20Sopenharmony_ci#define writeb(v,c) ({ wmb(); writeb_relaxed((v),(c)); mb(); }) 328c2ecf20Sopenharmony_ci#define writew(v,c) ({ wmb(); writew_relaxed((v),(c)); mb(); }) 338c2ecf20Sopenharmony_ci#define writel(v,c) ({ wmb(); writel_relaxed((v),(c)); mb(); }) 348c2ecf20Sopenharmony_ci#endif 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* 378c2ecf20Sopenharmony_ci * I/O memory mapping functions. 388c2ecf20Sopenharmony_ci */ 398c2ecf20Sopenharmony_ci#define ioremap_wc(addr, size) \ 408c2ecf20Sopenharmony_ci ioremap_prot((addr), (size), \ 418c2ecf20Sopenharmony_ci (_PAGE_IOREMAP & ~_CACHE_MASK) | _CACHE_UNCACHED) 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci#include <asm-generic/io.h> 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#endif /* __ASM_CSKY_IO_H */ 46