| /* SPDX-License-Identifier: GPL-2.0-only */ |
| /* |
| * From Linux arch/riscv/include/asm/mmio.h |
| */ |
| #ifndef _ASMRISCV_IO_H_ |
| #define _ASMRISCV_IO_H_ |
| #include <libcflat.h> |
| |
| #define __iomem |
| |
| /* Generic IO read/write. These perform native-endian accesses. */ |
| #define __raw_writeb __raw_writeb |
| static inline void __raw_writeb(u8 val, volatile void __iomem *addr) |
| { |
| asm volatile("sb %0, 0(%1)" : : "r" (val), "r" (addr)); |
| } |
| |
| #define __raw_writew __raw_writew |
| static inline void __raw_writew(u16 val, volatile void __iomem *addr) |
| { |
| asm volatile("sh %0, 0(%1)" : : "r" (val), "r" (addr)); |
| } |
| |
| #define __raw_writel __raw_writel |
| static inline void __raw_writel(u32 val, volatile void __iomem *addr) |
| { |
| asm volatile("sw %0, 0(%1)" : : "r" (val), "r" (addr)); |
| } |
| |
| #ifdef CONFIG_64BIT |
| #define __raw_writeq __raw_writeq |
| static inline void __raw_writeq(u64 val, volatile void __iomem *addr) |
| { |
| asm volatile("sd %0, 0(%1)" : : "r" (val), "r" (addr)); |
| } |
| #endif |
| |
| #define __raw_readb __raw_readb |
| static inline u8 __raw_readb(const volatile void __iomem *addr) |
| { |
| u8 val; |
| |
| asm volatile("lb %0, 0(%1)" : "=r" (val) : "r" (addr)); |
| return val; |
| } |
| |
| #define __raw_readw __raw_readw |
| static inline u16 __raw_readw(const volatile void __iomem *addr) |
| { |
| u16 val; |
| |
| asm volatile("lh %0, 0(%1)" : "=r" (val) : "r" (addr)); |
| return val; |
| } |
| |
| #define __raw_readl __raw_readl |
| static inline u32 __raw_readl(const volatile void __iomem *addr) |
| { |
| u32 val; |
| |
| asm volatile("lw %0, 0(%1)" : "=r" (val) : "r" (addr)); |
| return val; |
| } |
| |
| #ifdef CONFIG_64BIT |
| #define __raw_readq __raw_readq |
| static inline u64 __raw_readq(const volatile void __iomem *addr) |
| { |
| u64 val; |
| |
| asm volatile("ld %0, 0(%1)" : "=r" (val) : "r" (addr)); |
| return val; |
| } |
| #endif |
| |
| #define ioremap ioremap |
| void __iomem *ioremap(phys_addr_t phys_addr, size_t size); |
| |
| #define virt_to_phys virt_to_phys |
| phys_addr_t virt_to_phys(volatile void *address); |
| |
| #define phys_to_virt phys_to_virt |
| void *phys_to_virt(phys_addr_t address); |
| |
| #include <asm-generic/io.h> |
| |
| #endif /* _ASMRISCV_IO_H_ */ |