blob: 6e7692ff6f2cb1a7416a8b12c44d0aed0748f3ae [file] [log] [blame]
Brian Swetland30421022007-11-26 04:11:43 -08001/* 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 Kingfced80c2008-09-06 12:10:45 +010021#include <linux/io.h>
Brian Swetland30421022007-11-26 04:11:43 -080022
Russell Kinga09e64f2008-08-05 16:14:15 +010023#include <mach/hardware.h>
Brian Swetland30421022007-11-26 04:11:43 -080024#include <asm/page.h>
Russell Kinga09e64f2008-08-05 16:14:15 +010025#include <mach/msm_iomap.h>
Brian Swetland30421022007-11-26 04:11:43 -080026#include <asm/mach/map.h>
27
Russell Kinga09e64f2008-08-05 16:14:15 +010028#include <mach/board.h>
Brian Swetland30421022007-11-26 04:11:43 -080029
30#define MSM_DEVICE(name) { \
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070031 .virtual = (unsigned long) MSM_##name##_BASE, \
Brian Swetland30421022007-11-26 04:11:43 -080032 .pfn = __phys_to_pfn(MSM_##name##_PHYS), \
33 .length = MSM_##name##_SIZE, \
34 .type = MT_DEVICE_NONSHARED, \
35 }
36
37static struct map_desc msm_io_desc[] __initdata = {
38 MSM_DEVICE(VIC),
39 MSM_DEVICE(CSR),
40 MSM_DEVICE(GPT),
41 MSM_DEVICE(DMOV),
Brian Swetland30421022007-11-26 04:11:43 -080042 MSM_DEVICE(GPIO1),
43 MSM_DEVICE(GPIO2),
Brian Swetland30421022007-11-26 04:11:43 -080044 MSM_DEVICE(CLK_CTL),
Brian Swetland30421022007-11-26 04:11:43 -080045 {
Brian Swetlandbcc0f6a2008-09-10 14:00:53 -070046 .virtual = (unsigned long) MSM_SHARED_RAM_BASE,
Brian Swetland30421022007-11-26 04:11:43 -080047 .pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
48 .length = MSM_SHARED_RAM_SIZE,
49 .type = MT_DEVICE,
50 },
51};
52
53void __init msm_map_common_io(void)
54{
55 /* Make sure the peripheral register window is closed, since
56 * we will use PTE flags (TEX[1]=1,B=0,C=1) to determine which
57 * pages are peripheral interface or not.
58 */
59 asm("mcr p15, 0, %0, c15, c2, 4" : : "r" (0));
60
61 iotable_init(msm_io_desc, ARRAY_SIZE(msm_io_desc));
62}
63
64void __iomem *
65__msm_ioremap(unsigned long phys_addr, size_t size, unsigned int mtype)
66{
67 if (mtype == MT_DEVICE) {
68 /* The peripherals in the 88000000 - D0000000 range
69 * are only accessable by type MT_DEVICE_NONSHARED.
70 * Adjust mtype as necessary to make this "just work."
71 */
72 if ((phys_addr >= 0x88000000) && (phys_addr < 0xD0000000))
73 mtype = MT_DEVICE_NONSHARED;
74 }
75
76 return __arm_ioremap(phys_addr, size, mtype);
77}