Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/ide-2.6
[pandora-kernel.git] / arch / arm / mach-msm / board-msm7x27.c
1 /*
2  * Copyright (C) 2007 Google, Inc.
3  * Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
4  * Author: Brian Swetland <swetland@google.com>
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17 #include <linux/kernel.h>
18 #include <linux/init.h>
19 #include <linux/platform_device.h>
20 #include <linux/input.h>
21 #include <linux/io.h>
22 #include <linux/delay.h>
23 #include <linux/bootmem.h>
24 #include <linux/power_supply.h>
25
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/flash.h>
31 #include <asm/setup.h>
32 #ifdef CONFIG_CACHE_L2X0
33 #include <asm/hardware/cache-l2x0.h>
34 #endif
35
36 #include <mach/vreg.h>
37 #include <mach/mpp.h>
38 #include <mach/gpio.h>
39 #include <mach/board.h>
40 #include <mach/msm_iomap.h>
41
42 #include <linux/mtd/nand.h>
43 #include <linux/mtd/partitions.h>
44
45 #include "devices.h"
46 #include "socinfo.h"
47 #include "clock.h"
48
49 static struct resource smc91x_resources[] = {
50         [0] = {
51                 .start  = 0x9C004300,
52                 .end    = 0x9C0043ff,
53                 .flags  = IORESOURCE_MEM,
54         },
55         [1] = {
56                 .start  = MSM_GPIO_TO_INT(132),
57                 .end    = MSM_GPIO_TO_INT(132),
58                 .flags  = IORESOURCE_IRQ,
59         },
60 };
61
62 static struct platform_device smc91x_device = {
63         .name           = "smc91x",
64         .id             = 0,
65         .num_resources  = ARRAY_SIZE(smc91x_resources),
66         .resource       = smc91x_resources,
67 };
68
69 static struct platform_device *devices[] __initdata = {
70         &msm_device_uart3,
71         &msm_device_smd,
72         &msm_device_dmov,
73         &msm_device_nand,
74         &smc91x_device,
75 };
76
77 extern struct sys_timer msm_timer;
78
79 static void __init msm7x2x_init_irq(void)
80 {
81         msm_init_irq();
82 }
83
84 static void __init msm7x2x_init(void)
85 {
86         if (socinfo_init() < 0)
87                 BUG();
88
89         if (machine_is_msm7x25_ffa() || machine_is_msm7x27_ffa()) {
90                 smc91x_resources[0].start = 0x98000300;
91                 smc91x_resources[0].end = 0x980003ff;
92                 smc91x_resources[1].start = MSM_GPIO_TO_INT(85);
93                 smc91x_resources[1].end = MSM_GPIO_TO_INT(85);
94                 if (gpio_tlmm_config(GPIO_CFG(85, 0,
95                                               GPIO_INPUT,
96                                               GPIO_PULL_DOWN,
97                                               GPIO_2MA),
98                                      GPIO_ENABLE)) {
99                         printk(KERN_ERR
100                                "%s: Err: Config GPIO-85 INT\n",
101                                 __func__);
102                 }
103         }
104
105         platform_add_devices(devices, ARRAY_SIZE(devices));
106 }
107
108 static void __init msm7x2x_map_io(void)
109 {
110         msm_map_common_io();
111         /* Technically dependent on the SoC but using machine_is
112          * macros since socinfo is not available this early and there
113          * are plans to restructure the code which will eliminate the
114          * need for socinfo.
115          */
116         if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa())
117                 msm_clock_init(msm_clocks_7x27, msm_num_clocks_7x27);
118
119         if (machine_is_msm7x25_surf() || machine_is_msm7x25_ffa())
120                 msm_clock_init(msm_clocks_7x25, msm_num_clocks_7x25);
121
122 #ifdef CONFIG_CACHE_L2X0
123         if (machine_is_msm7x27_surf() || machine_is_msm7x27_ffa()) {
124                 /* 7x27 has 256KB L2 cache:
125                         64Kb/Way and 4-Way Associativity;
126                         R/W latency: 3 cycles;
127                         evmon/parity/share disabled. */
128                 l2x0_init(MSM_L2CC_BASE, 0x00068012, 0xfe000000);
129         }
130 #endif
131 }
132
133 MACHINE_START(MSM7X27_SURF, "QCT MSM7x27 SURF")
134 #ifdef CONFIG_MSM_DEBUG_UART
135         .phys_io        = MSM_DEBUG_UART_PHYS,
136         .io_pg_offst    = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
137 #endif
138         .boot_params    = PHYS_OFFSET + 0x100,
139         .map_io         = msm7x2x_map_io,
140         .init_irq       = msm7x2x_init_irq,
141         .init_machine   = msm7x2x_init,
142         .timer          = &msm_timer,
143 MACHINE_END
144
145 MACHINE_START(MSM7X27_FFA, "QCT MSM7x27 FFA")
146 #ifdef CONFIG_MSM_DEBUG_UART
147         .phys_io        = MSM_DEBUG_UART_PHYS,
148         .io_pg_offst    = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
149 #endif
150         .boot_params    = PHYS_OFFSET + 0x100,
151         .map_io         = msm7x2x_map_io,
152         .init_irq       = msm7x2x_init_irq,
153         .init_machine   = msm7x2x_init,
154         .timer          = &msm_timer,
155 MACHINE_END
156
157 MACHINE_START(MSM7X25_SURF, "QCT MSM7x25 SURF")
158 #ifdef CONFIG_MSM_DEBUG_UART
159         .phys_io        = MSM_DEBUG_UART_PHYS,
160         .io_pg_offst    = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
161 #endif
162         .boot_params    = PHYS_OFFSET + 0x100,
163         .map_io         = msm7x2x_map_io,
164         .init_irq       = msm7x2x_init_irq,
165         .init_machine   = msm7x2x_init,
166         .timer          = &msm_timer,
167 MACHINE_END
168
169 MACHINE_START(MSM7X25_FFA, "QCT MSM7x25 FFA")
170 #ifdef CONFIG_MSM_DEBUG_UART
171         .phys_io        = MSM_DEBUG_UART_PHYS,
172         .io_pg_offst    = ((MSM_DEBUG_UART_BASE) >> 18) & 0xfffc,
173 #endif
174         .boot_params    = PHYS_OFFSET + 0x100,
175         .map_io         = msm7x2x_map_io,
176         .init_irq       = msm7x2x_init_irq,
177         .init_machine   = msm7x2x_init,
178         .timer          = &msm_timer,
179 MACHINE_END