| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * arch/arm/mach-tegra/include/mach/io.h | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2010 Google, Inc. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Author: | 
					
						
							|  |  |  |  *	Colin Cross <ccross@google.com> | 
					
						
							|  |  |  |  *	Erik Gilling <konkers@google.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This software is licensed under the terms of the GNU General Public | 
					
						
							|  |  |  |  * License version 2, as published by the Free Software Foundation, and | 
					
						
							|  |  |  |  * may be copied, distributed, and modified under those terms. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __MACH_TEGRA_IO_H
 | 
					
						
							|  |  |  | #define __MACH_TEGRA_IO_H
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-27 11:26:33 +02:00
										 |  |  | #define IO_SPACE_LIMIT 0xffff
 | 
					
						
							| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* On TEGRA, many peripherals are very closely packed in
 | 
					
						
							|  |  |  |  * two 256MB io windows (that actually only use about 64KB | 
					
						
							|  |  |  |  * at the start of each). | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * We will just map the first 1MB of each window (to minimize | 
					
						
							|  |  |  |  * pt entries needed) and provide a macro to transform physical | 
					
						
							|  |  |  |  * io addresses to an appropriate void __iomem *. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-09 21:05:44 -07:00
										 |  |  | #ifdef __ASSEMBLY__
 | 
					
						
							|  |  |  | #define IOMEM(x)	(x)
 | 
					
						
							|  |  |  | #else
 | 
					
						
							|  |  |  | #define IOMEM(x)	((void __force __iomem *)(x))
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-07-27 21:34:38 -07:00
										 |  |  | #define IO_IRAM_PHYS	0x40000000
 | 
					
						
							| 
									
										
										
										
											2011-10-09 21:05:44 -07:00
										 |  |  | #define IO_IRAM_VIRT	IOMEM(0xFE400000)
 | 
					
						
							| 
									
										
										
										
											2010-07-27 21:34:38 -07:00
										 |  |  | #define IO_IRAM_SIZE	SZ_256K
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | #define IO_CPU_PHYS     0x50040000
 | 
					
						
							| 
									
										
										
										
											2011-10-09 21:05:44 -07:00
										 |  |  | #define IO_CPU_VIRT     IOMEM(0xFE000000)
 | 
					
						
							| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | #define IO_CPU_SIZE	SZ_16K
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define IO_PPSB_PHYS	0x60000000
 | 
					
						
							| 
									
										
										
										
											2011-10-09 21:05:44 -07:00
										 |  |  | #define IO_PPSB_VIRT	IOMEM(0xFE200000)
 | 
					
						
							| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | #define IO_PPSB_SIZE	SZ_1M
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define IO_APB_PHYS	0x70000000
 | 
					
						
							| 
									
										
										
										
											2011-10-09 21:05:44 -07:00
										 |  |  | #define IO_APB_VIRT	IOMEM(0xFE300000)
 | 
					
						
							| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | #define IO_APB_SIZE	SZ_1M
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define IO_TO_VIRT_BETWEEN(p, st, sz)	((p) >= (st) && (p) < ((st) + (sz)))
 | 
					
						
							|  |  |  | #define IO_TO_VIRT_XLATE(p, pst, vst)	(((p) - (pst) + (vst)))
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define IO_TO_VIRT(n) ( \
 | 
					
						
							|  |  |  | 	IO_TO_VIRT_BETWEEN((n), IO_PPSB_PHYS, IO_PPSB_SIZE) ?		\ | 
					
						
							|  |  |  | 		IO_TO_VIRT_XLATE((n), IO_PPSB_PHYS, IO_PPSB_VIRT) :	\ | 
					
						
							|  |  |  | 	IO_TO_VIRT_BETWEEN((n), IO_APB_PHYS, IO_APB_SIZE) ?		\ | 
					
						
							|  |  |  | 		IO_TO_VIRT_XLATE((n), IO_APB_PHYS, IO_APB_VIRT) :	\ | 
					
						
							|  |  |  | 	IO_TO_VIRT_BETWEEN((n), IO_CPU_PHYS, IO_CPU_SIZE) ?		\ | 
					
						
							|  |  |  | 		IO_TO_VIRT_XLATE((n), IO_CPU_PHYS, IO_CPU_VIRT) :	\ | 
					
						
							| 
									
										
										
										
											2010-07-27 21:34:38 -07:00
										 |  |  | 	IO_TO_VIRT_BETWEEN((n), IO_IRAM_PHYS, IO_IRAM_SIZE) ?		\ | 
					
						
							|  |  |  | 		IO_TO_VIRT_XLATE((n), IO_IRAM_PHYS, IO_IRAM_VIRT) :	\ | 
					
						
							| 
									
										
										
										
											2011-10-09 21:05:44 -07:00
										 |  |  | 	NULL) | 
					
						
							| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifndef __ASSEMBLER__
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-10-09 21:05:44 -07:00
										 |  |  | #define IO_ADDRESS(n) (IO_TO_VIRT(n))
 | 
					
						
							| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-27 11:26:33 +02:00
										 |  |  | #ifdef CONFIG_TEGRA_PCI
 | 
					
						
							|  |  |  | extern void __iomem *tegra_pcie_io_base; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static inline void __iomem *__io(unsigned long addr) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return tegra_pcie_io_base + (addr & IO_SPACE_LIMIT); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | #else
 | 
					
						
							| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | static inline void __iomem *__io(unsigned long addr) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	return (void __iomem *)addr; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2010-09-27 11:26:33 +02:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-01-21 16:53:02 -08:00
										 |  |  | #define __io(a)         __io(a)
 | 
					
						
							|  |  |  | #define __mem_pci(a)    (a)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |