io.h 2.5 KB
Newer Older
1 2
/* SPARC I/O definitions
 *
3 4
 * (C) Copyright 2007, 2015
 * Daniel Hellstrom, Cobham Gaisler, daniel@gaisler.com.
5
 *
6
 * SPDX-License-Identifier:	GPL-2.0+
7 8 9 10 11 12 13 14
 */

#ifndef _SPARC_IO_H
#define _SPARC_IO_H

/* Nothing to sync, total store ordering (TSO)... */
#define sync()

15 16 17 18 19 20
/*
 * Generic virtual read/write.
 */

#ifndef CONFIG_SYS_HAS_NO_CACHE

21 22 23 24 25
/* Forces a cache miss on read/load.
 * On some architectures we need to bypass the cache when reading
 * I/O registers so that we are not reading the same status word
 * over and over again resulting in a hang (until an IRQ if lucky)
 */
26 27 28 29 30 31

#define __arch_getb(a)		SPARC_NOCACHE_READ_BYTE((unsigned int)(a))
#define __arch_getw(a)		SPARC_NOCACHE_READ_HWORD((unsigned int)(a))
#define __arch_getl(a)		SPARC_NOCACHE_READ((unsigned int)(a))
#define __arch_getq(a)		SPARC_NOCACHE_READ_DWORD((unsigned int)(a))

32 33
#else

34 35 36 37 38 39
#define __arch_getb(a)		(*(volatile unsigned char *)(a))
#define __arch_getw(a)		(*(volatile unsigned short *)(a))
#define __arch_getl(a)		(*(volatile unsigned int *)(a))
#define __arch_getq(a)		(*(volatile unsigned long long *)(a))

#endif /* CONFIG_SYS_HAS_NO_CACHE */
40

41 42 43 44
#define __arch_putb(v, a)	(*(volatile unsigned char *)(a) = (v))
#define __arch_putw(v, a)	(*(volatile unsigned short *)(a) = (v))
#define __arch_putl(v, a)	(*(volatile unsigned int *)(a) = (v))
#define __arch_putq(v, a)	(*(volatile unsigned long long *)(a) = (v))
45

46 47 48 49
#define __raw_writeb(v, a)		__arch_putb(v, a)
#define __raw_writew(v, a)		__arch_putw(v, a)
#define __raw_writel(v, a)		__arch_putl(v, a)
#define __raw_writeq(v, a)		__arch_putq(v, a)
50 51 52 53 54 55

#define __raw_readb(a)			__arch_getb(a)
#define __raw_readw(a)			__arch_getw(a)
#define __raw_readl(a)			__arch_getl(a)
#define __raw_readq(a)			__arch_getq(a)

56 57 58 59 60 61 62 63 64 65
#define writeb				__raw_writeb
#define writew				__raw_writew
#define writel				__raw_writel
#define writeq				__raw_writeq

#define readb				__raw_readb
#define readw				__raw_readw
#define readl				__raw_readl
#define readq				__raw_readq

66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
/*
 * Given a physical address and a length, return a virtual address
 * that can be used to access the memory range with the caching
 * properties specified by "flags".
 */

#define MAP_NOCACHE	(0)
#define MAP_WRCOMBINE	(0)
#define MAP_WRBACK	(0)
#define MAP_WRTHROUGH	(0)

static inline void *map_physmem(phys_addr_t paddr, unsigned long len,
				unsigned long flags)
{
	return (void *)paddr;
}

/*
 * Take down a mapping set up by map_physmem().
 */
static inline void unmap_physmem(void *vaddr, unsigned long flags)
{

}

K
Kumar Gala 已提交
91 92 93 94 95
static inline phys_addr_t virt_to_phys(void * vaddr)
{
	return (phys_addr_t)(vaddr);
}

96
#endif