mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 07:04:28 +00:00
asm-generic: Import functions from Linux
Currently {read,write}s{b,w,lq}() functions are available only on some architectures, and there are no io{read,write}{8,16,32,64}_rep() functions in u-boot. This patch adds generic versions that may be used without arch-specific implementation. Since some of added functions were already added locally in some files, remove them to avoid redeclaration errors. Signed-off-by: Igor Prusov <ivprusov@salutedevices.com>
This commit is contained in:
parent
02585ad9e5
commit
fa34fbf9a1
3 changed files with 348 additions and 67 deletions
|
@ -352,40 +352,6 @@ static int atmel_nfc_wait(struct atmel_hsmc_nand_controller *nc, bool poll,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void iowrite8_rep(void *addr, const uint8_t *buf, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
writeb(buf[i], addr);
|
||||
}
|
||||
|
||||
static void ioread8_rep(void *addr, uint8_t *buf, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
buf[i] = readb(addr);
|
||||
}
|
||||
|
||||
static void ioread16_rep(void *addr, void *buf, int len)
|
||||
{
|
||||
int i;
|
||||
u16 *p = (u16 *)buf;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
p[i] = readw(addr);
|
||||
}
|
||||
|
||||
static void iowrite16_rep(void *addr, const void *buf, int len)
|
||||
{
|
||||
int i;
|
||||
u16 *p = (u16 *)buf;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
writew(p[i], addr);
|
||||
}
|
||||
|
||||
static u8 atmel_nand_read_byte(struct mtd_info *mtd)
|
||||
{
|
||||
struct nand_chip *chip = mtd_to_nand(mtd);
|
||||
|
|
|
@ -245,39 +245,6 @@ static void nand_write_byte16(struct mtd_info *mtd, uint8_t byte)
|
|||
chip->write_buf(mtd, (uint8_t *)&word, 2);
|
||||
}
|
||||
|
||||
static void iowrite8_rep(void *addr, const uint8_t *buf, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
writeb(buf[i], addr);
|
||||
}
|
||||
static void ioread8_rep(void *addr, uint8_t *buf, int len)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
buf[i] = readb(addr);
|
||||
}
|
||||
|
||||
static void ioread16_rep(void *addr, void *buf, int len)
|
||||
{
|
||||
int i;
|
||||
u16 *p = (u16 *) buf;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
p[i] = readw(addr);
|
||||
}
|
||||
|
||||
static void iowrite16_rep(void *addr, void *buf, int len)
|
||||
{
|
||||
int i;
|
||||
u16 *p = (u16 *) buf;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
writew(p[i], addr);
|
||||
}
|
||||
|
||||
/**
|
||||
* nand_write_buf - [DEFAULT] write buffer to chip
|
||||
* @mtd: MTD device structure
|
||||
|
|
|
@ -105,5 +105,353 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
|
|||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* __raw_{read,write}{b,w,l,q}() access memory in native endianness.
|
||||
*
|
||||
* On some architectures memory mapped IO needs to be accessed differently.
|
||||
* On the simple architectures, we just read/write the memory location
|
||||
* directly.
|
||||
*/
|
||||
|
||||
#ifndef __raw_readb
|
||||
#define __raw_readb __raw_readb
|
||||
static inline u8 __raw_readb(const volatile void __iomem *addr)
|
||||
{
|
||||
return *(const volatile u8 __force *)addr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __raw_readw
|
||||
#define __raw_readw __raw_readw
|
||||
static inline u16 __raw_readw(const volatile void __iomem *addr)
|
||||
{
|
||||
return *(const volatile u16 __force *)addr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __raw_readl
|
||||
#define __raw_readl __raw_readl
|
||||
static inline u32 __raw_readl(const volatile void __iomem *addr)
|
||||
{
|
||||
return *(const volatile u32 __force *)addr;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#ifndef __raw_readq
|
||||
#define __raw_readq __raw_readq
|
||||
static inline u64 __raw_readq(const volatile void __iomem *addr)
|
||||
{
|
||||
return *(const volatile u64 __force *)addr;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_64BIT */
|
||||
|
||||
#ifndef __raw_writeb
|
||||
#define __raw_writeb __raw_writeb
|
||||
static inline void __raw_writeb(u8 value, volatile void __iomem *addr)
|
||||
{
|
||||
*(volatile u8 __force *)addr = value;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __raw_writew
|
||||
#define __raw_writew __raw_writew
|
||||
static inline void __raw_writew(u16 value, volatile void __iomem *addr)
|
||||
{
|
||||
*(volatile u16 __force *)addr = value;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __raw_writel
|
||||
#define __raw_writel __raw_writel
|
||||
static inline void __raw_writel(u32 value, volatile void __iomem *addr)
|
||||
{
|
||||
*(volatile u32 __force *)addr = value;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#ifndef __raw_writeq
|
||||
#define __raw_writeq __raw_writeq
|
||||
static inline void __raw_writeq(u64 value, volatile void __iomem *addr)
|
||||
{
|
||||
*(volatile u64 __force *)addr = value;
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_64BIT */
|
||||
|
||||
/*
|
||||
* {read,write}s{b,w,l,q}() repeatedly access the same memory address in
|
||||
* native endianness in 8-, 16-, 32- or 64-bit chunks (@count times).
|
||||
*/
|
||||
#ifndef readsb
|
||||
#define readsb readsb
|
||||
static inline void readsb(const volatile void __iomem *addr, void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
if (count) {
|
||||
u8 *buf = buffer;
|
||||
|
||||
do {
|
||||
u8 x = __raw_readb(addr);
|
||||
*buf++ = x;
|
||||
} while (--count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef readsw
|
||||
#define readsw readsw
|
||||
static inline void readsw(const volatile void __iomem *addr, void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
if (count) {
|
||||
u16 *buf = buffer;
|
||||
|
||||
do {
|
||||
u16 x = __raw_readw(addr);
|
||||
*buf++ = x;
|
||||
} while (--count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef readsl
|
||||
#define readsl readsl
|
||||
static inline void readsl(const volatile void __iomem *addr, void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
if (count) {
|
||||
u32 *buf = buffer;
|
||||
|
||||
do {
|
||||
u32 x = __raw_readl(addr);
|
||||
*buf++ = x;
|
||||
} while (--count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#ifndef readsq
|
||||
#define readsq readsq
|
||||
static inline void readsq(const volatile void __iomem *addr, void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
if (count) {
|
||||
u64 *buf = buffer;
|
||||
|
||||
do {
|
||||
u64 x = __raw_readq(addr);
|
||||
*buf++ = x;
|
||||
} while (--count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_64BIT */
|
||||
|
||||
#ifndef writesb
|
||||
#define writesb writesb
|
||||
static inline void writesb(volatile void __iomem *addr, const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
if (count) {
|
||||
const u8 *buf = buffer;
|
||||
|
||||
do {
|
||||
__raw_writeb(*buf++, addr);
|
||||
} while (--count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef writesw
|
||||
#define writesw writesw
|
||||
static inline void writesw(volatile void __iomem *addr, const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
if (count) {
|
||||
const u16 *buf = buffer;
|
||||
|
||||
do {
|
||||
__raw_writew(*buf++, addr);
|
||||
} while (--count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef writesl
|
||||
#define writesl writesl
|
||||
static inline void writesl(volatile void __iomem *addr, const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
if (count) {
|
||||
const u32 *buf = buffer;
|
||||
|
||||
do {
|
||||
__raw_writel(*buf++, addr);
|
||||
} while (--count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#ifndef writesq
|
||||
#define writesq writesq
|
||||
static inline void writesq(volatile void __iomem *addr, const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
if (count) {
|
||||
const u64 *buf = buffer;
|
||||
|
||||
do {
|
||||
__raw_writeq(*buf++, addr);
|
||||
} while (--count);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_64BIT */
|
||||
|
||||
#ifndef PCI_IOBASE
|
||||
#define PCI_IOBASE ((void __iomem *)0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* {in,out}s{b,w,l}{,_p}() are variants of the above that repeatedly access a
|
||||
* single I/O port multiple times.
|
||||
*/
|
||||
|
||||
#ifndef insb
|
||||
#define insb insb
|
||||
static inline void insb(unsigned long addr, void *buffer, unsigned int count)
|
||||
{
|
||||
readsb(PCI_IOBASE + addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef insw
|
||||
#define insw insw
|
||||
static inline void insw(unsigned long addr, void *buffer, unsigned int count)
|
||||
{
|
||||
readsw(PCI_IOBASE + addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef insl
|
||||
#define insl insl
|
||||
static inline void insl(unsigned long addr, void *buffer, unsigned int count)
|
||||
{
|
||||
readsl(PCI_IOBASE + addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef outsb
|
||||
#define outsb outsb
|
||||
static inline void outsb(unsigned long addr, const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
writesb(PCI_IOBASE + addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef outsw
|
||||
#define outsw outsw
|
||||
static inline void outsw(unsigned long addr, const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
writesw(PCI_IOBASE + addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef outsl
|
||||
#define outsl outsl
|
||||
static inline void outsl(unsigned long addr, const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
writesl(PCI_IOBASE + addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef ioread8_rep
|
||||
#define ioread8_rep ioread8_rep
|
||||
static inline void ioread8_rep(const volatile void __iomem *addr, void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
readsb(addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef ioread16_rep
|
||||
#define ioread16_rep ioread16_rep
|
||||
static inline void ioread16_rep(const volatile void __iomem *addr,
|
||||
void *buffer, unsigned int count)
|
||||
{
|
||||
readsw(addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef ioread32_rep
|
||||
#define ioread32_rep ioread32_rep
|
||||
static inline void ioread32_rep(const volatile void __iomem *addr,
|
||||
void *buffer, unsigned int count)
|
||||
{
|
||||
readsl(addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#ifndef ioread64_rep
|
||||
#define ioread64_rep ioread64_rep
|
||||
static inline void ioread64_rep(const volatile void __iomem *addr,
|
||||
void *buffer, unsigned int count)
|
||||
{
|
||||
readsq(addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_64BIT */
|
||||
|
||||
#ifndef iowrite8_rep
|
||||
#define iowrite8_rep iowrite8_rep
|
||||
static inline void iowrite8_rep(volatile void __iomem *addr,
|
||||
const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
writesb(addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef iowrite16_rep
|
||||
#define iowrite16_rep iowrite16_rep
|
||||
static inline void iowrite16_rep(volatile void __iomem *addr,
|
||||
const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
writesw(addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef iowrite32_rep
|
||||
#define iowrite32_rep iowrite32_rep
|
||||
static inline void iowrite32_rep(volatile void __iomem *addr,
|
||||
const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
writesl(addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_64BIT
|
||||
#ifndef iowrite64_rep
|
||||
#define iowrite64_rep iowrite64_rep
|
||||
static inline void iowrite64_rep(volatile void __iomem *addr,
|
||||
const void *buffer,
|
||||
unsigned int count)
|
||||
{
|
||||
writesq(addr, buffer, count);
|
||||
}
|
||||
#endif
|
||||
#endif /* CONFIG_64BIT */
|
||||
|
||||
#endif /* !__ASSEMBLY__ */
|
||||
#endif /* __ASM_GENERIC_IO_H__ */
|
||||
|
|
Loading…
Reference in a new issue