Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 1 | /* arch/arm/mach-msm/io.c |
| 2 | * |
| 3 | * MSM7K io support |
| 4 | * |
| 5 | * Copyright (C) 2007 Google, Inc. |
| 6 | * Author: Brian Swetland <swetland@google.com> |
| 7 | * |
| 8 | * This software is licensed under the terms of the GNU General Public |
| 9 | * License version 2, as published by the Free Software Foundation, and |
| 10 | * may be copied, distributed, and modified under those terms. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | */ |
| 18 | |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/init.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 21 | #include <linux/io.h> |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 22 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 23 | #include <mach/hardware.h> |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 24 | #include <asm/page.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 25 | #include <mach/msm_iomap.h> |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 26 | #include <asm/mach/map.h> |
| 27 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 28 | #include <mach/board.h> |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 29 | |
| 30 | #define MSM_DEVICE(name) { \ |
Brian Swetland | bcc0f6a | 2008-09-10 14:00:53 -0700 | [diff] [blame] | 31 | .virtual = (unsigned long) MSM_##name##_BASE, \ |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 32 | .pfn = __phys_to_pfn(MSM_##name##_PHYS), \ |
| 33 | .length = MSM_##name##_SIZE, \ |
| 34 | .type = MT_DEVICE_NONSHARED, \ |
| 35 | } |
| 36 | |
| 37 | static struct map_desc msm_io_desc[] __initdata = { |
| 38 | MSM_DEVICE(VIC), |
| 39 | MSM_DEVICE(CSR), |
| 40 | MSM_DEVICE(GPT), |
| 41 | MSM_DEVICE(DMOV), |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 42 | MSM_DEVICE(GPIO1), |
| 43 | MSM_DEVICE(GPIO2), |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 44 | MSM_DEVICE(CLK_CTL), |
Pavel Machek | 6339f669 | 2009-11-02 11:48:29 +0100 | [diff] [blame] | 45 | #ifdef CONFIG_MSM_DEBUG_UART |
| 46 | MSM_DEVICE(DEBUG_UART), |
| 47 | #endif |
Dima Zavin | b42dc44 | 2010-01-29 11:43:42 -0800 | [diff] [blame] | 48 | #ifdef CONFIG_ARCH_MSM7X30 |
| 49 | MSM_DEVICE(GCC), |
| 50 | #endif |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 51 | { |
Brian Swetland | bcc0f6a | 2008-09-10 14:00:53 -0700 | [diff] [blame] | 52 | .virtual = (unsigned long) MSM_SHARED_RAM_BASE, |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 53 | .pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS), |
| 54 | .length = MSM_SHARED_RAM_SIZE, |
| 55 | .type = MT_DEVICE, |
| 56 | }, |
| 57 | }; |
| 58 | |
| 59 | void __init msm_map_common_io(void) |
| 60 | { |
| 61 | /* Make sure the peripheral register window is closed, since |
| 62 | * we will use PTE flags (TEX[1]=1,B=0,C=1) to determine which |
| 63 | * pages are peripheral interface or not. |
| 64 | */ |
| 65 | asm("mcr p15, 0, %0, c15, c2, 4" : : "r" (0)); |
| 66 | |
| 67 | iotable_init(msm_io_desc, ARRAY_SIZE(msm_io_desc)); |
| 68 | } |
| 69 | |
| 70 | void __iomem * |
| 71 | __msm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype) |
| 72 | { |
| 73 | if (mtype == MT_DEVICE) { |
| 74 | /* The peripherals in the 88000000 - D0000000 range |
| 75 | * are only accessable by type MT_DEVICE_NONSHARED. |
| 76 | * Adjust mtype as necessary to make this "just work." |
| 77 | */ |
| 78 | if ((phys_addr >= 0x88000000) && (phys_addr < 0xD0000000)) |
| 79 | mtype = MT_DEVICE_NONSHARED; |
| 80 | } |
| 81 | |
Russell King | 31aa8fd | 2009-12-18 11:10:03 +0000 | [diff] [blame] | 82 | return __arm_ioremap_caller(phys_addr, size, mtype, |
| 83 | __builtin_return_address(0)); |
Brian Swetland | 3042102 | 2007-11-26 04:11:43 -0800 | [diff] [blame] | 84 | } |