Santosh Shilimkar | 4416907 | 2009-05-28 14:16:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Common io.c file |
| 3 | * This file is created by Russell King <rmk+kernel@arm.linux.org.uk> |
| 4 | * |
| 5 | * Copyright (C) 2009 Texas Instruments |
| 6 | * Added OMAP4 support - Santosh Shilimkar <santosh.shilimkar@ti.com> |
| 7 | * |
| 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. |
| 11 | */ |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 12 | #include <linux/module.h> |
| 13 | #include <linux/io.h> |
| 14 | #include <linux/mm.h> |
Jon Medhurst | 009426a | 2011-08-03 16:57:19 +0100 | [diff] [blame^] | 15 | #include <linux/dma-mapping.h> |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 16 | |
Tony Lindgren | ce491cf | 2009-10-20 09:40:47 -0700 | [diff] [blame] | 17 | #include <plat/omap7xx.h> |
| 18 | #include <plat/omap1510.h> |
| 19 | #include <plat/omap16xx.h> |
| 20 | #include <plat/omap24xx.h> |
| 21 | #include <plat/omap34xx.h> |
| 22 | #include <plat/omap44xx.h> |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 23 | |
| 24 | #define BETWEEN(p,st,sz) ((p) >= (st) && (p) < ((st) + (sz))) |
| 25 | #define XLATE(p,pst,vst) ((void __iomem *)((p) - (pst) + (vst))) |
| 26 | |
| 27 | /* |
| 28 | * Intercept ioremap() requests for addresses in our fixed mapping regions. |
| 29 | */ |
| 30 | void __iomem *omap_ioremap(unsigned long p, size_t size, unsigned int type) |
| 31 | { |
| 32 | #ifdef CONFIG_ARCH_OMAP1 |
| 33 | if (cpu_class_is_omap1()) { |
Tony Lindgren | db326be | 2009-08-28 10:50:37 -0700 | [diff] [blame] | 34 | if (BETWEEN(p, OMAP1_IO_PHYS, OMAP1_IO_SIZE)) |
| 35 | return XLATE(p, OMAP1_IO_PHYS, OMAP1_IO_VIRT); |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 36 | } |
Alistair Buxton | ab49df7 | 2009-09-22 05:58:08 +0100 | [diff] [blame] | 37 | if (cpu_is_omap7xx()) { |
Alistair Buxton | b51988d | 2009-09-22 07:34:13 +0100 | [diff] [blame] | 38 | if (BETWEEN(p, OMAP7XX_DSP_BASE, OMAP7XX_DSP_SIZE)) |
| 39 | return XLATE(p, OMAP7XX_DSP_BASE, OMAP7XX_DSP_START); |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 40 | |
Alistair Buxton | b51988d | 2009-09-22 07:34:13 +0100 | [diff] [blame] | 41 | if (BETWEEN(p, OMAP7XX_DSPREG_BASE, OMAP7XX_DSPREG_SIZE)) |
| 42 | return XLATE(p, OMAP7XX_DSPREG_BASE, |
| 43 | OMAP7XX_DSPREG_START); |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 44 | } |
| 45 | if (cpu_is_omap15xx()) { |
| 46 | if (BETWEEN(p, OMAP1510_DSP_BASE, OMAP1510_DSP_SIZE)) |
| 47 | return XLATE(p, OMAP1510_DSP_BASE, OMAP1510_DSP_START); |
| 48 | |
| 49 | if (BETWEEN(p, OMAP1510_DSPREG_BASE, OMAP1510_DSPREG_SIZE)) |
| 50 | return XLATE(p, OMAP1510_DSPREG_BASE, |
| 51 | OMAP1510_DSPREG_START); |
| 52 | } |
| 53 | if (cpu_is_omap16xx()) { |
| 54 | if (BETWEEN(p, OMAP16XX_DSP_BASE, OMAP16XX_DSP_SIZE)) |
| 55 | return XLATE(p, OMAP16XX_DSP_BASE, OMAP16XX_DSP_START); |
| 56 | |
| 57 | if (BETWEEN(p, OMAP16XX_DSPREG_BASE, OMAP16XX_DSPREG_SIZE)) |
| 58 | return XLATE(p, OMAP16XX_DSPREG_BASE, |
| 59 | OMAP16XX_DSPREG_START); |
| 60 | } |
| 61 | #endif |
| 62 | #ifdef CONFIG_ARCH_OMAP2 |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 63 | if (cpu_is_omap24xx()) { |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 64 | if (BETWEEN(p, L3_24XX_PHYS, L3_24XX_SIZE)) |
| 65 | return XLATE(p, L3_24XX_PHYS, L3_24XX_VIRT); |
| 66 | if (BETWEEN(p, L4_24XX_PHYS, L4_24XX_SIZE)) |
| 67 | return XLATE(p, L4_24XX_PHYS, L4_24XX_VIRT); |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 68 | } |
| 69 | if (cpu_is_omap2420()) { |
Paul Walmsley | 7adb998 | 2010-01-08 15:23:05 -0700 | [diff] [blame] | 70 | if (BETWEEN(p, DSP_MEM_2420_PHYS, DSP_MEM_2420_SIZE)) |
| 71 | return XLATE(p, DSP_MEM_2420_PHYS, DSP_MEM_2420_VIRT); |
| 72 | if (BETWEEN(p, DSP_IPI_2420_PHYS, DSP_IPI_2420_SIZE)) |
| 73 | return XLATE(p, DSP_IPI_2420_PHYS, DSP_IPI_2420_SIZE); |
| 74 | if (BETWEEN(p, DSP_MMU_2420_PHYS, DSP_MMU_2420_SIZE)) |
| 75 | return XLATE(p, DSP_MMU_2420_PHYS, DSP_MMU_2420_VIRT); |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 76 | } |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 77 | if (cpu_is_omap2430()) { |
| 78 | if (BETWEEN(p, L4_WK_243X_PHYS, L4_WK_243X_SIZE)) |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 79 | return XLATE(p, L4_WK_243X_PHYS, L4_WK_243X_VIRT); |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 80 | if (BETWEEN(p, OMAP243X_GPMC_PHYS, OMAP243X_GPMC_SIZE)) |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 81 | return XLATE(p, OMAP243X_GPMC_PHYS, OMAP243X_GPMC_VIRT); |
| 82 | if (BETWEEN(p, OMAP243X_SDRC_PHYS, OMAP243X_SDRC_SIZE)) |
| 83 | return XLATE(p, OMAP243X_SDRC_PHYS, OMAP243X_SDRC_VIRT); |
| 84 | if (BETWEEN(p, OMAP243X_SMS_PHYS, OMAP243X_SMS_SIZE)) |
| 85 | return XLATE(p, OMAP243X_SMS_PHYS, OMAP243X_SMS_VIRT); |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 86 | } |
| 87 | #endif |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 88 | #ifdef CONFIG_ARCH_OMAP3 |
Hemant Pedanekar | 0100171 | 2011-02-16 08:31:39 -0800 | [diff] [blame] | 89 | if (cpu_is_ti816x()) { |
| 90 | if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE)) |
| 91 | return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT); |
| 92 | } else if (cpu_is_omap34xx()) { |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 93 | if (BETWEEN(p, L3_34XX_PHYS, L3_34XX_SIZE)) |
| 94 | return XLATE(p, L3_34XX_PHYS, L3_34XX_VIRT); |
| 95 | if (BETWEEN(p, L4_34XX_PHYS, L4_34XX_SIZE)) |
| 96 | return XLATE(p, L4_34XX_PHYS, L4_34XX_VIRT); |
Syed Mohammed, Khasim | cc26b3b | 2008-10-09 17:51:41 +0300 | [diff] [blame] | 97 | if (BETWEEN(p, OMAP34XX_GPMC_PHYS, OMAP34XX_GPMC_SIZE)) |
| 98 | return XLATE(p, OMAP34XX_GPMC_PHYS, OMAP34XX_GPMC_VIRT); |
| 99 | if (BETWEEN(p, OMAP343X_SMS_PHYS, OMAP343X_SMS_SIZE)) |
| 100 | return XLATE(p, OMAP343X_SMS_PHYS, OMAP343X_SMS_VIRT); |
| 101 | if (BETWEEN(p, OMAP343X_SDRC_PHYS, OMAP343X_SDRC_SIZE)) |
| 102 | return XLATE(p, OMAP343X_SDRC_PHYS, OMAP343X_SDRC_VIRT); |
| 103 | if (BETWEEN(p, L4_PER_34XX_PHYS, L4_PER_34XX_SIZE)) |
| 104 | return XLATE(p, L4_PER_34XX_PHYS, L4_PER_34XX_VIRT); |
| 105 | if (BETWEEN(p, L4_EMU_34XX_PHYS, L4_EMU_34XX_SIZE)) |
| 106 | return XLATE(p, L4_EMU_34XX_PHYS, L4_EMU_34XX_VIRT); |
| 107 | } |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 108 | #endif |
Santosh Shilimkar | 4416907 | 2009-05-28 14:16:04 -0700 | [diff] [blame] | 109 | #ifdef CONFIG_ARCH_OMAP4 |
| 110 | if (cpu_is_omap44xx()) { |
| 111 | if (BETWEEN(p, L3_44XX_PHYS, L3_44XX_SIZE)) |
| 112 | return XLATE(p, L3_44XX_PHYS, L3_44XX_VIRT); |
| 113 | if (BETWEEN(p, L4_44XX_PHYS, L4_44XX_SIZE)) |
| 114 | return XLATE(p, L4_44XX_PHYS, L4_44XX_VIRT); |
Santosh Shilimkar | 4416907 | 2009-05-28 14:16:04 -0700 | [diff] [blame] | 115 | if (BETWEEN(p, OMAP44XX_GPMC_PHYS, OMAP44XX_GPMC_SIZE)) |
| 116 | return XLATE(p, OMAP44XX_GPMC_PHYS, OMAP44XX_GPMC_VIRT); |
Santosh Shilimkar | f5d2d65 | 2009-10-19 17:25:57 -0700 | [diff] [blame] | 117 | if (BETWEEN(p, OMAP44XX_EMIF1_PHYS, OMAP44XX_EMIF1_SIZE)) |
| 118 | return XLATE(p, OMAP44XX_EMIF1_PHYS, \ |
| 119 | OMAP44XX_EMIF1_VIRT); |
| 120 | if (BETWEEN(p, OMAP44XX_EMIF2_PHYS, OMAP44XX_EMIF2_SIZE)) |
| 121 | return XLATE(p, OMAP44XX_EMIF2_PHYS, \ |
| 122 | OMAP44XX_EMIF2_VIRT); |
| 123 | if (BETWEEN(p, OMAP44XX_DMM_PHYS, OMAP44XX_DMM_SIZE)) |
| 124 | return XLATE(p, OMAP44XX_DMM_PHYS, OMAP44XX_DMM_VIRT); |
Santosh Shilimkar | 4416907 | 2009-05-28 14:16:04 -0700 | [diff] [blame] | 125 | if (BETWEEN(p, L4_PER_44XX_PHYS, L4_PER_44XX_SIZE)) |
| 126 | return XLATE(p, L4_PER_44XX_PHYS, L4_PER_44XX_VIRT); |
| 127 | if (BETWEEN(p, L4_EMU_44XX_PHYS, L4_EMU_44XX_SIZE)) |
| 128 | return XLATE(p, L4_EMU_44XX_PHYS, L4_EMU_44XX_VIRT); |
| 129 | } |
| 130 | #endif |
Russell King | 31aa8fd | 2009-12-18 11:10:03 +0000 | [diff] [blame] | 131 | return __arm_ioremap_caller(p, size, type, __builtin_return_address(0)); |
Russell King | 690b5a1 | 2008-09-04 12:07:44 +0100 | [diff] [blame] | 132 | } |
| 133 | EXPORT_SYMBOL(omap_ioremap); |
| 134 | |
| 135 | void omap_iounmap(volatile void __iomem *addr) |
| 136 | { |
| 137 | unsigned long virt = (unsigned long)addr; |
| 138 | |
| 139 | if (virt >= VMALLOC_START && virt < VMALLOC_END) |
| 140 | __iounmap(addr); |
| 141 | } |
| 142 | EXPORT_SYMBOL(omap_iounmap); |
Jon Medhurst | 009426a | 2011-08-03 16:57:19 +0100 | [diff] [blame^] | 143 | |
| 144 | void __init omap_init_consistent_dma_size(void) |
| 145 | { |
| 146 | #ifdef CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE |
| 147 | init_consistent_dma_size(CONFIG_FB_OMAP_CONSISTENT_DMA_SIZE << 20); |
| 148 | #endif |
| 149 | } |