3 * This file is created by Russell King <rmk+kernel@arm.linux.org.uk>
5 * Copyright (C) 2009 Texas Instruments
6 * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 #include <linux/module.h>
16 #include <plat/omap7xx.h>
17 #include <plat/omap1510.h>
18 #include <plat/omap16xx.h>
19 #include <plat/omap24xx.h>
20 #include <plat/omap34xx.h>
21 #include <plat/omap44xx.h>
23 #define BETWEEN(p,st,sz) ((p) >= (st) && (p) < ((st) + (sz)))
24 #define XLATE(p,pst,vst) ((void __iomem *)((p) - (pst) + (vst)))
26 static int initialized;
29 * Intercept ioremap() requests for addresses in our fixed mapping regions.
31 void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type)
34 WARN(!initialized, "Do not use ioremap before init_early\n");
36 #ifdef CONFIG_ARCH_OMAP1
37 if (cpu_class_is_omap1()) {
38 if (BETWEEN(p, OMAP1_IO_PHYS, OMAP1_IO_SIZE))
39 return XLATE(p, OMAP1_IO_PHYS, OMAP1_IO_VIRT);
41 if (cpu_is_omap7xx()) {
42 if (BETWEEN(p, OMAP7XX_DSP_BASE, OMAP7XX_DSP_SIZE))
43 return XLATE(p, OMAP7XX_DSP_BASE, OMAP7XX_DSP_START);
45 if (BETWEEN(p, OMAP7XX_DSPREG_BASE, OMAP7XX_DSPREG_SIZE))
46 return XLATE(p, OMAP7XX_DSPREG_BASE,
47 OMAP7XX_DSPREG_START);
49 if (cpu_is_omap15xx()) {
50 if (BETWEEN(p, OMAP1510_DSP_BASE, OMAP1510_DSP_SIZE))
51 return XLATE(p, OMAP1510_DSP_BASE, OMAP1510_DSP_START);
53 if (BETWEEN(p, OMAP1510_DSPREG_BASE, OMAP1510_DSPREG_SIZE))
54 return XLATE(p, OMAP1510_DSPREG_BASE,
55 OMAP1510_DSPREG_START);
57 if (cpu_is_omap16xx()) {
58 if (BETWEEN(p, OMAP16XX_DSP_BASE, OMAP16XX_DSP_SIZE))
59 return XLATE(p, OMAP16XX_DSP_BASE, OMAP16XX_DSP_START);
61 if (BETWEEN(p, OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_SIZE))
62 return XLATE(p, OMAP16XX_DSPREG_BASE,
63 OMAP16XX_DSPREG_START);
66 #ifdef CONFIG_ARCH_OMAP2
67 if (cpu_is_omap24xx()) {
68 if (BETWEEN(p, L3_24XX_PHYS, L3_24XX_SIZE))
69 return XLATE(p, L3_24XX_PHYS, L3_24XX_VIRT);
70 if (BETWEEN(p, L4_24XX_PHYS, L4_24XX_SIZE))
71 return XLATE(p, L4_24XX_PHYS, L4_24XX_VIRT);
73 if (cpu_is_omap2420()) {
74 if (BETWEEN(p, DSP_MEM_2420_PHYS, DSP_MEM_2420_SIZE))
75 return XLATE(p, DSP_MEM_2420_PHYS, DSP_MEM_2420_VIRT);
76 if (BETWEEN(p, DSP_IPI_2420_PHYS, DSP_IPI_2420_SIZE))
77 return XLATE(p, DSP_IPI_2420_PHYS, DSP_IPI_2420_SIZE);
78 if (BETWEEN(p, DSP_MMU_2420_PHYS, DSP_MMU_2420_SIZE))
79 return XLATE(p, DSP_MMU_2420_PHYS, DSP_MMU_2420_VIRT);
81 if (cpu_is_omap2430()) {
82 if (BETWEEN(p, L4_WK_243X_PHYS, L4_WK_243X_SIZE))
83 return XLATE(p, L4_WK_243X_PHYS, L4_WK_243X_VIRT);
84 if (BETWEEN(p, OMAP243X_GPMC_PHYS, OMAP243X_GPMC_SIZE))
85 return XLATE(p, OMAP243X_GPMC_PHYS, OMAP243X_GPMC_VIRT);
86 if (BETWEEN(p, OMAP243X_SDRC_PHYS, OMAP243X_SDRC_SIZE))
87 return XLATE(p, OMAP243X_SDRC_PHYS, OMAP243X_SDRC_VIRT);
88 if (BETWEEN(p, OMAP243X_SMS_PHYS, OMAP243X_SMS_SIZE))
89 return XLATE(p, OMAP243X_SMS_PHYS, OMAP243X_SMS_VIRT);
92 #ifdef CONFIG_ARCH_OMAP3
93 if (cpu_is_ti816x()) {
94 if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
95 return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
96 } else if (cpu_is_omap34xx()) {
97 if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE))
98 return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT);
99 if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE))
100 return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT);
101 if (BETWEEN(p, OMAP34XX_GPMC_PHYS, OMAP34XX_GPMC_SIZE))
102 return XLATE(p, OMAP34XX_GPMC_PHYS, OMAP34XX_GPMC_VIRT);
103 if (BETWEEN(p, OMAP343X_SMS_PHYS, OMAP343X_SMS_SIZE))
104 return XLATE(p, OMAP343X_SMS_PHYS, OMAP343X_SMS_VIRT);
105 if (BETWEEN(p, OMAP343X_SDRC_PHYS, OMAP343X_SDRC_SIZE))
106 return XLATE(p, OMAP343X_SDRC_PHYS, OMAP343X_SDRC_VIRT);
107 if (BETWEEN(p, L4_PER_34XX_PHYS, L4_PER_34XX_SIZE))
108 return XLATE(p, L4_PER_34XX_PHYS, L4_PER_34XX_VIRT);
109 if (BETWEEN(p, L4_EMU_34XX_PHYS, L4_EMU_34XX_SIZE))
110 return XLATE(p, L4_EMU_34XX_PHYS, L4_EMU_34XX_VIRT);
113 #ifdef CONFIG_ARCH_OMAP4
114 if (cpu_is_omap44xx()) {
115 if (BETWEEN(p, L3_44XX_PHYS, L3_44XX_SIZE))
116 return XLATE(p, L3_44XX_PHYS, L3_44XX_VIRT);
117 if (BETWEEN(p, L4_44XX_PHYS, L4_44XX_SIZE))
118 return XLATE(p, L4_44XX_PHYS, L4_44XX_VIRT);
119 if (BETWEEN(p, OMAP44XX_GPMC_PHYS, OMAP44XX_GPMC_SIZE))
120 return XLATE(p, OMAP44XX_GPMC_PHYS, OMAP44XX_GPMC_VIRT);
121 if (BETWEEN(p, OMAP44XX_EMIF1_PHYS, OMAP44XX_EMIF1_SIZE))
122 return XLATE(p, OMAP44XX_EMIF1_PHYS, \
123 OMAP44XX_EMIF1_VIRT);
124 if (BETWEEN(p, OMAP44XX_EMIF2_PHYS, OMAP44XX_EMIF2_SIZE))
125 return XLATE(p, OMAP44XX_EMIF2_PHYS, \
126 OMAP44XX_EMIF2_VIRT);
127 if (BETWEEN(p, OMAP44XX_DMM_PHYS, OMAP44XX_DMM_SIZE))
128 return XLATE(p, OMAP44XX_DMM_PHYS, OMAP44XX_DMM_VIRT);
129 if (BETWEEN(p, L4_PER_44XX_PHYS, L4_PER_44XX_SIZE))
130 return XLATE(p, L4_PER_44XX_PHYS, L4_PER_44XX_VIRT);
131 if (BETWEEN(p, L4_EMU_44XX_PHYS, L4_EMU_44XX_SIZE))
132 return XLATE(p, L4_EMU_44XX_PHYS, L4_EMU_44XX_VIRT);
135 return __arm_ioremap_caller(p, size, type, __builtin_return_address(0));
137 EXPORT_SYMBOL(omap_ioremap);
139 void omap_iounmap(volatile void __iomem *addr)
141 unsigned long virt = (unsigned long)addr;
143 if (virt >= VMALLOC_START && virt < VMALLOC_END)
146 EXPORT_SYMBOL(omap_iounmap);
148 void __init omap_ioremap_init(void)