io_32.h 3.7 KB
Newer Older
1 2 3 4 5 6
#ifndef __SPARC_IO_H
#define __SPARC_IO_H

#include <linux/kernel.h>
#include <linux/ioport.h>  /* struct resource */

7
#define IO_SPACE_LIMIT 0xffffffff
8

9 10 11
#define memset_io(d,c,sz)     _memset_io(d,c,sz)
#define memcpy_fromio(d,s,sz) _memcpy_fromio(d,s,sz)
#define memcpy_toio(d,s,sz)   _memcpy_toio(d,s,sz)
12

13
#include <asm-generic/io.h>
14

15 16
static inline void _memset_io(volatile void __iomem *dst,
                              int c, __kernel_size_t n)
17
{
18
	volatile void __iomem *d = dst;
19

20 21 22 23
	while (n--) {
		writeb(c, d);
		d++;
	}
24 25
}

26 27
static inline void _memcpy_fromio(void *dst, const volatile void __iomem *src,
                                  __kernel_size_t n)
28
{
29
	char *d = dst;
30

31 32 33 34 35
	while (n--) {
		char tmp = readb(src);
		*d++ = tmp;
		src++;
	}
36 37
}

38 39
static inline void _memcpy_toio(volatile void __iomem *dst, const void *src,
                                __kernel_size_t n)
40
{
41 42
	const char *s = src;
	volatile void __iomem *d = dst;
43

44 45 46 47 48
	while (n--) {
		char tmp = *s++;
		writeb(tmp, d);
		d++;
	}
49 50 51 52 53 54 55 56
}

/*
 * SBus accessors.
 *
 * SBus has only one, memory mapped, I/O space.
 * We do not need to flip bytes for SBus of course.
 */
S
Sam Ravnborg 已提交
57
static inline u8 sbus_readb(const volatile void __iomem *addr)
58 59 60 61
{
	return *(__force volatile u8 *)addr;
}

S
Sam Ravnborg 已提交
62
static inline u16 sbus_readw(const volatile void __iomem *addr)
63 64 65 66
{
	return *(__force volatile u16 *)addr;
}

S
Sam Ravnborg 已提交
67
static inline u32 sbus_readl(const volatile void __iomem *addr)
68 69 70 71
{
	return *(__force volatile u32 *)addr;
}

S
Sam Ravnborg 已提交
72
static inline void sbus_writeb(u8 b, volatile void __iomem *addr)
73 74 75 76
{
	*(__force volatile u8 *)addr = b;
}

S
Sam Ravnborg 已提交
77
static inline void sbus_writew(u16 w, volatile void __iomem *addr)
78 79 80 81
{
	*(__force volatile u16 *)addr = w;
}

S
Sam Ravnborg 已提交
82
static inline void sbus_writel(u32 l, volatile void __iomem *addr)
83 84 85 86
{
	*(__force volatile u32 *)addr = l;
}

S
Sam Ravnborg 已提交
87 88
static inline void sbus_memset_io(volatile void __iomem *__dst, int c,
                                  __kernel_size_t n)
89 90 91 92 93 94 95
{
	while(n--) {
		sbus_writeb(c, __dst);
		__dst++;
	}
}

S
Sam Ravnborg 已提交
96 97 98
static inline void sbus_memcpy_fromio(void *dst,
                                      const volatile void __iomem *src,
                                      __kernel_size_t n)
99 100 101 102 103 104 105 106 107 108
{
	char *d = dst;

	while (n--) {
		char tmp = sbus_readb(src);
		*d++ = tmp;
		src++;
	}
}

S
Sam Ravnborg 已提交
109 110 111
static inline void sbus_memcpy_toio(volatile void __iomem *dst,
                                    const void *src,
                                    __kernel_size_t n)
112 113 114 115 116 117 118 119 120 121 122
{
	const char *s = src;
	volatile void __iomem *d = dst;

	while (n--) {
		char tmp = *s++;
		sbus_writeb(tmp, d);
		d++;
	}
}

123 124 125 126 127 128
#ifdef __KERNEL__

/*
 * Bus number may be embedded in the higher bits of the physical address.
 * This is why we have no bus number argument to ioremap().
 */
129
void __iomem *ioremap(unsigned long offset, unsigned long size);
130
#define ioremap_nocache(X,Y)	ioremap((X),(Y))
131
#define ioremap_wc(X,Y)		ioremap((X),(Y))
132
#define ioremap_wt(X,Y)		ioremap((X),(Y))
133
void iounmap(volatile void __iomem *addr);
134 135

/* Create a virtual mapping cookie for an IO port range */
136 137
void __iomem *ioport_map(unsigned long port, unsigned int nr);
void ioport_unmap(void __iomem *);
138 139 140

/* Create a virtual mapping cookie for a PCI BAR (memory or IO) */
struct pci_dev;
141
void pci_iounmap(struct pci_dev *dev, void __iomem *);
142

143 144


145 146 147 148 149 150 151 152
/*
 * At the moment, we do not use CMOS_READ anywhere outside of rtc.c,
 * so rtc_port is static in it. This should not change unless a new
 * hardware pops up.
 */
#define RTC_PORT(x)   (rtc_port + (x))
#define RTC_ALWAYS_BCD  0

153 154 155 156 157 158 159 160 161
static inline int sbus_can_dma_64bit(void)
{
	return 0; /* actually, sparc_cpu_model==sun4d */
}
static inline int sbus_can_burst64(void)
{
	return 0; /* actually, sparc_cpu_model==sun4d */
}
struct device;
162
void sbus_set_sbus64(struct device *, int);
163

164 165 166 167 168 169
#endif

#define __ARCH_HAS_NO_PAGE_ZERO_MAPPED		1


#endif /* !(__SPARC_IO_H) */