| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | #ifndef __SPARC_IO_H
 | 
					
						
							|  |  |  | #define __SPARC_IO_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/ioport.h>  /* struct resource */
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | #define IO_SPACE_LIMIT 0xffffffff
 | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | #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)
 | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | #include <asm-generic/io.h>
 | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | static inline void _memset_io(volatile void __iomem *dst, | 
					
						
							|  |  |  |                               int c, __kernel_size_t n) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | 	volatile void __iomem *d = dst; | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | 	while (n--) { | 
					
						
							|  |  |  | 		writeb(c, d); | 
					
						
							|  |  |  | 		d++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | static inline void _memcpy_fromio(void *dst, const volatile void __iomem *src, | 
					
						
							|  |  |  |                                   __kernel_size_t n) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | 	char *d = dst; | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | 	while (n--) { | 
					
						
							|  |  |  | 		char tmp = readb(src); | 
					
						
							|  |  |  | 		*d++ = tmp; | 
					
						
							|  |  |  | 		src++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | static inline void _memcpy_toio(volatile void __iomem *dst, const void *src, | 
					
						
							|  |  |  |                                 __kernel_size_t n) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | 	const char *s = src; | 
					
						
							|  |  |  | 	volatile void __iomem *d = dst; | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | 	while (n--) { | 
					
						
							|  |  |  | 		char tmp = *s++; | 
					
						
							|  |  |  | 		writeb(tmp, d); | 
					
						
							|  |  |  | 		d++; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*
 | 
					
						
							|  |  |  |  * SBus accessors. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * SBus has only one, memory mapped, I/O space. | 
					
						
							|  |  |  |  * We do not need to flip bytes for SBus of course. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:37 +02:00
										 |  |  | static inline u8 sbus_readb(const volatile void __iomem *addr) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	return *(__force volatile u8 *)addr; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:37 +02:00
										 |  |  | static inline u16 sbus_readw(const volatile void __iomem *addr) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	return *(__force volatile u16 *)addr; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:37 +02:00
										 |  |  | static inline u32 sbus_readl(const volatile void __iomem *addr) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	return *(__force volatile u32 *)addr; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:37 +02:00
										 |  |  | static inline void sbus_writeb(u8 b, volatile void __iomem *addr) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	*(__force volatile u8 *)addr = b; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:37 +02:00
										 |  |  | static inline void sbus_writew(u16 w, volatile void __iomem *addr) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	*(__force volatile u16 *)addr = w; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:37 +02:00
										 |  |  | static inline void sbus_writel(u32 l, volatile void __iomem *addr) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	*(__force volatile u32 *)addr = l; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:37 +02:00
										 |  |  | static inline void sbus_memset_io(volatile void __iomem *__dst, int c, | 
					
						
							|  |  |  |                                   __kernel_size_t n) | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	while(n--) { | 
					
						
							|  |  |  | 		sbus_writeb(c, __dst); | 
					
						
							|  |  |  | 		__dst++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:37 +02:00
										 |  |  | static inline void sbus_memcpy_fromio(void *dst, | 
					
						
							|  |  |  |                                       const volatile void __iomem *src, | 
					
						
							|  |  |  |                                       __kernel_size_t n) | 
					
						
							| 
									
										
										
											
												fbmem: fix fb_read, fb_write unaligned accesses
fb_{read,write} access the framebuffer using lots of fb_{read,write}l's
but don't check that the file position is aligned which can cause problems
on some architectures which do not support unaligned accesses.
Since the operations are essentially memcpy_{from,to}io, new
fb_memcpy_{from,to}fb macros have been defined and these are used instead.
For Sparc, fb_{read,write} macros use sbus_{read,write}, so this defines
new sbus_memcpy_{from,to}io functions the same as memcpy_{from,to}io but
using sbus_{read,write}b instead of {read,write}b.
Signed-off-by: James Hogan <james@albanarts.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
											
										 
											2010-10-27 15:33:28 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	char *d = dst; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while (n--) { | 
					
						
							|  |  |  | 		char tmp = sbus_readb(src); | 
					
						
							|  |  |  | 		*d++ = tmp; | 
					
						
							|  |  |  | 		src++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:37 +02:00
										 |  |  | static inline void sbus_memcpy_toio(volatile void __iomem *dst, | 
					
						
							|  |  |  |                                     const void *src, | 
					
						
							|  |  |  |                                     __kernel_size_t n) | 
					
						
							| 
									
										
										
											
												fbmem: fix fb_read, fb_write unaligned accesses
fb_{read,write} access the framebuffer using lots of fb_{read,write}l's
but don't check that the file position is aligned which can cause problems
on some architectures which do not support unaligned accesses.
Since the operations are essentially memcpy_{from,to}io, new
fb_memcpy_{from,to}fb macros have been defined and these are used instead.
For Sparc, fb_{read,write} macros use sbus_{read,write}, so this defines
new sbus_memcpy_{from,to}io functions the same as memcpy_{from,to}io but
using sbus_{read,write}b instead of {read,write}b.
Signed-off-by: James Hogan <james@albanarts.com>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Florian Tobias Schandinat <FlorianSchandinat@gmx.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
											
										 
											2010-10-27 15:33:28 -07:00
										 |  |  | { | 
					
						
							|  |  |  | 	const char *s = src; | 
					
						
							|  |  |  | 	volatile void __iomem *d = dst; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while (n--) { | 
					
						
							|  |  |  | 		char tmp = *s++; | 
					
						
							|  |  |  | 		sbus_writeb(tmp, d); | 
					
						
							|  |  |  | 		d++; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | #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(). | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2014-05-16 23:25:50 +02:00
										 |  |  | void __iomem *ioremap(unsigned long offset, unsigned long size); | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | #define ioremap_nocache(X,Y)	ioremap((X),(Y))
 | 
					
						
							| 
									
										
										
										
											2008-07-22 14:30:55 -07:00
										 |  |  | #define ioremap_wc(X,Y)		ioremap((X),(Y))
 | 
					
						
							| 
									
										
										
										
											2015-06-04 18:55:16 +02:00
										 |  |  | #define ioremap_wt(X,Y)		ioremap((X),(Y))
 | 
					
						
							| 
									
										
										
										
											2014-05-16 23:25:50 +02:00
										 |  |  | void iounmap(volatile void __iomem *addr); | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Create a virtual mapping cookie for an IO port range */ | 
					
						
							| 
									
										
										
										
											2014-05-16 23:25:50 +02:00
										 |  |  | void __iomem *ioport_map(unsigned long port, unsigned int nr); | 
					
						
							|  |  |  | void ioport_unmap(void __iomem *); | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* Create a virtual mapping cookie for a PCI BAR (memory or IO) */ | 
					
						
							|  |  |  | struct pci_dev; | 
					
						
							| 
									
										
										
										
											2014-05-16 23:25:50 +02:00
										 |  |  | void pci_iounmap(struct pci_dev *dev, void __iomem *); | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-26 09:57:36 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * 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
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-08-26 23:33:42 -07:00
										 |  |  | 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; | 
					
						
							| 
									
										
										
										
											2014-05-16 23:25:50 +02:00
										 |  |  | void sbus_set_sbus64(struct device *, int); | 
					
						
							| 
									
										
										
										
											2008-08-26 23:33:42 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-17 21:55:51 -07:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define __ARCH_HAS_NO_PAGE_ZERO_MAPPED		1
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* !(__SPARC_IO_H) */
 |