io.c 5.3 KB
Newer Older
1 2
/* arch/arm/mach-msm/io.c
 *
D
Daniel Walker 已提交
3
 * MSM7K, QSD io support
4 5
 *
 * Copyright (C) 2007 Google, Inc.
6
 * Copyright (c) 2008-2011, Code Aurora Forum. All rights reserved.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * Author: Brian Swetland <swetland@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.
 *
 */

#include <linux/kernel.h>
#include <linux/init.h>
22
#include <linux/io.h>
23
#include <linux/export.h>
24

25
#include <mach/hardware.h>
26
#include <asm/page.h>
27
#include <mach/msm_iomap.h>
28 29
#include <asm/mach/map.h>

30
#include <mach/board.h>
31

32
#define MSM_CHIP_DEVICE_TYPE(name, chip, mem_type) {			      \
33
		.virtual = (unsigned long) MSM_##name##_BASE, \
34 35
		.pfn = __phys_to_pfn(chip##_##name##_PHYS), \
		.length = chip##_##name##_SIZE, \
36
		.type = mem_type, \
37 38
	 }

39 40 41 42
#define MSM_DEVICE_TYPE(name, mem_type) \
		MSM_CHIP_DEVICE_TYPE(name, MSM, mem_type)
#define MSM_CHIP_DEVICE(name, chip) \
		MSM_CHIP_DEVICE_TYPE(name, chip, MT_DEVICE)
43 44
#define MSM_DEVICE(name) MSM_CHIP_DEVICE(name, MSM)

D
Daniel Walker 已提交
45 46
#if defined(CONFIG_ARCH_MSM7X00A) || defined(CONFIG_ARCH_MSM7X27) \
	|| defined(CONFIG_ARCH_MSM7X25)
47
static struct map_desc msm_io_desc[] __initdata = {
48 49 50 51 52 53
	MSM_DEVICE_TYPE(VIC, MT_DEVICE_NONSHARED),
	MSM_CHIP_DEVICE_TYPE(CSR, MSM7X00, MT_DEVICE_NONSHARED),
	MSM_DEVICE_TYPE(DMOV, MT_DEVICE_NONSHARED),
	MSM_CHIP_DEVICE_TYPE(GPIO1, MSM7X00, MT_DEVICE_NONSHARED),
	MSM_CHIP_DEVICE_TYPE(GPIO2, MSM7X00, MT_DEVICE_NONSHARED),
	MSM_DEVICE_TYPE(CLK_CTL, MT_DEVICE_NONSHARED),
54 55
#if defined(CONFIG_DEBUG_MSM_UART1) || defined(CONFIG_DEBUG_MSM_UART2) || \
	defined(CONFIG_DEBUG_MSM_UART3)
56
	MSM_DEVICE_TYPE(DEBUG_UART, MT_DEVICE_NONSHARED),
57
#endif
58
	{
59
		.virtual =  (unsigned long) MSM_SHARED_RAM_BASE,
D
Daniel Walker 已提交
60
		.pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
61 62 63 64 65 66 67 68 69 70 71 72 73 74
		.length =   MSM_SHARED_RAM_SIZE,
		.type =     MT_DEVICE,
	},
};

void __init msm_map_common_io(void)
{
	/* Make sure the peripheral register window is closed, since
	 * we will use PTE flags (TEX[1]=1,B=0,C=1) to determine which
	 * pages are peripheral interface or not.
	 */
	asm("mcr p15, 0, %0, c15, c2, 4" : : "r" (0));
	iotable_init(msm_io_desc, ARRAY_SIZE(msm_io_desc));
}
D
Daniel Walker 已提交
75 76 77 78 79
#endif

#ifdef CONFIG_ARCH_QSD8X50
static struct map_desc qsd8x50_io_desc[] __initdata = {
	MSM_DEVICE(VIC),
80
	MSM_CHIP_DEVICE(CSR, QSD8X50),
D
Daniel Walker 已提交
81
	MSM_DEVICE(DMOV),
82 83
	MSM_CHIP_DEVICE(GPIO1, QSD8X50),
	MSM_CHIP_DEVICE(GPIO2, QSD8X50),
D
Daniel Walker 已提交
84 85 86 87 88
	MSM_DEVICE(CLK_CTL),
	MSM_DEVICE(SIRC),
	MSM_DEVICE(SCPLL),
	MSM_DEVICE(AD5),
	MSM_DEVICE(MDC),
89 90
#if defined(CONFIG_DEBUG_MSM_UART1) || defined(CONFIG_DEBUG_MSM_UART2) || \
	defined(CONFIG_DEBUG_MSM_UART3)
D
Daniel Walker 已提交
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
	MSM_DEVICE(DEBUG_UART),
#endif
	{
		.virtual =  (unsigned long) MSM_SHARED_RAM_BASE,
		.pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
		.length =   MSM_SHARED_RAM_SIZE,
		.type =     MT_DEVICE,
	},
};

void __init msm_map_qsd8x50_io(void)
{
	iotable_init(qsd8x50_io_desc, ARRAY_SIZE(qsd8x50_io_desc));
}
#endif /* CONFIG_ARCH_QSD8X50 */
106

S
Steve Muckle 已提交
107 108
#ifdef CONFIG_ARCH_MSM8X60
static struct map_desc msm8x60_io_desc[] __initdata = {
D
David Brown 已提交
109 110
	MSM_CHIP_DEVICE(QGIC_DIST, MSM8X60),
	MSM_CHIP_DEVICE(QGIC_CPU, MSM8X60),
111 112
	MSM_CHIP_DEVICE(TMR, MSM8X60),
	MSM_CHIP_DEVICE(TMR0, MSM8X60),
S
Steve Muckle 已提交
113 114
	MSM_DEVICE(ACC),
	MSM_DEVICE(GCC),
115 116 117
#ifdef CONFIG_DEBUG_MSM8660_UART
	MSM_DEVICE(DEBUG_UART),
#endif
S
Steve Muckle 已提交
118 119 120 121 122 123 124 125
};

void __init msm_map_msm8x60_io(void)
{
	iotable_init(msm8x60_io_desc, ARRAY_SIZE(msm8x60_io_desc));
}
#endif /* CONFIG_ARCH_MSM8X60 */

126 127 128 129 130 131
#ifdef CONFIG_ARCH_MSM8960
static struct map_desc msm8960_io_desc[] __initdata = {
	MSM_CHIP_DEVICE(QGIC_DIST, MSM8960),
	MSM_CHIP_DEVICE(QGIC_CPU, MSM8960),
	MSM_CHIP_DEVICE(TMR, MSM8960),
	MSM_CHIP_DEVICE(TMR0, MSM8960),
132 133 134
#ifdef CONFIG_DEBUG_MSM8960_UART
	MSM_DEVICE(DEBUG_UART),
#endif
135 136 137 138 139 140 141 142
};

void __init msm_map_msm8960_io(void)
{
	iotable_init(msm8960_io_desc, ARRAY_SIZE(msm8960_io_desc));
}
#endif /* CONFIG_ARCH_MSM8960 */

D
Daniel Walker 已提交
143 144 145
#ifdef CONFIG_ARCH_MSM7X30
static struct map_desc msm7x30_io_desc[] __initdata = {
	MSM_DEVICE(VIC),
146
	MSM_CHIP_DEVICE(CSR, MSM7X30),
D
Daniel Walker 已提交
147
	MSM_DEVICE(DMOV),
148 149
	MSM_CHIP_DEVICE(GPIO1, MSM7X30),
	MSM_CHIP_DEVICE(GPIO2, MSM7X30),
D
Daniel Walker 已提交
150 151 152 153 154 155 156 157
	MSM_DEVICE(CLK_CTL),
	MSM_DEVICE(CLK_CTL_SH2),
	MSM_DEVICE(AD5),
	MSM_DEVICE(MDC),
	MSM_DEVICE(ACC),
	MSM_DEVICE(SAW),
	MSM_DEVICE(GCC),
	MSM_DEVICE(TCSR),
158 159
#if defined(CONFIG_DEBUG_MSM_UART1) || defined(CONFIG_DEBUG_MSM_UART2) || \
	defined(CONFIG_DEBUG_MSM_UART3)
D
Daniel Walker 已提交
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
	MSM_DEVICE(DEBUG_UART),
#endif
	{
		.virtual =  (unsigned long) MSM_SHARED_RAM_BASE,
		.pfn = __phys_to_pfn(MSM_SHARED_RAM_PHYS),
		.length =   MSM_SHARED_RAM_SIZE,
		.type =     MT_DEVICE,
	},
};

void __init msm_map_msm7x30_io(void)
{
	iotable_init(msm7x30_io_desc, ARRAY_SIZE(msm7x30_io_desc));
}
#endif /* CONFIG_ARCH_MSM7X30 */

R
Rob Herring 已提交
176 177
void __iomem *__msm_ioremap_caller(unsigned long phys_addr, size_t size,
				   unsigned int mtype, void *caller)
178 179 180
{
	if (mtype == MT_DEVICE) {
		/* The peripherals in the 88000000 - D0000000 range
181
		 * are only accessible by type MT_DEVICE_NONSHARED.
182 183 184 185 186 187
		 * Adjust mtype as necessary to make this "just work."
		 */
		if ((phys_addr >= 0x88000000) && (phys_addr < 0xD0000000))
			mtype = MT_DEVICE_NONSHARED;
	}

R
Rob Herring 已提交
188
	return __arm_ioremap_caller(phys_addr, size, mtype, caller);
189
}