ARM: mach-shmobile: kota2: add comment out separator
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / arm / mach-shmobile / board-g3evm.c
1 /*
2 * G3EVM board support
3 *
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20 #include <linux/kernel.h>
21 #include <linux/init.h>
22 #include <linux/interrupt.h>
23 #include <linux/irq.h>
24 #include <linux/platform_device.h>
25 #include <linux/delay.h>
26 #include <linux/mtd/mtd.h>
27 #include <linux/mtd/partitions.h>
28 #include <linux/mtd/physmap.h>
29 #include <linux/mtd/sh_flctl.h>
30 #include <linux/usb/r8a66597.h>
31 #include <linux/io.h>
32 #include <linux/gpio.h>
33 #include <linux/input.h>
34 #include <linux/input/sh_keysc.h>
35 #include <linux/dma-mapping.h>
36 #include <mach/sh7367.h>
37 #include <mach/common.h>
38 #include <asm/mach-types.h>
39 #include <asm/mach/arch.h>
40 #include <asm/mach/map.h>
41 #include <asm/mach/time.h>
42
43 /*
44 * IrDA
45 *
46 * S67: 5bit : ON power
47 * : 6bit : ON remote control
48 * OFF IrDA
49 */
50
51 static struct mtd_partition nor_flash_partitions[] = {
52 {
53 .name = "loader",
54 .offset = 0x00000000,
55 .size = 512 * 1024,
56 },
57 {
58 .name = "bootenv",
59 .offset = MTDPART_OFS_APPEND,
60 .size = 512 * 1024,
61 },
62 {
63 .name = "kernel_ro",
64 .offset = MTDPART_OFS_APPEND,
65 .size = 8 * 1024 * 1024,
66 .mask_flags = MTD_WRITEABLE,
67 },
68 {
69 .name = "kernel",
70 .offset = MTDPART_OFS_APPEND,
71 .size = 8 * 1024 * 1024,
72 },
73 {
74 .name = "data",
75 .offset = MTDPART_OFS_APPEND,
76 .size = MTDPART_SIZ_FULL,
77 },
78 };
79
80 static struct physmap_flash_data nor_flash_data = {
81 .width = 2,
82 .parts = nor_flash_partitions,
83 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
84 };
85
86 static struct resource nor_flash_resources[] = {
87 [0] = {
88 .start = 0x00000000,
89 .end = 0x08000000 - 1,
90 .flags = IORESOURCE_MEM,
91 }
92 };
93
94 static struct platform_device nor_flash_device = {
95 .name = "physmap-flash",
96 .dev = {
97 .platform_data = &nor_flash_data,
98 },
99 .num_resources = ARRAY_SIZE(nor_flash_resources),
100 .resource = nor_flash_resources,
101 };
102
103 /* USBHS */
104 static void usb_host_port_power(int port, int power)
105 {
106 if (!power) /* only power-on supported for now */
107 return;
108
109 /* set VBOUT/PWEN and EXTLP0 in DVSTCTR */
110 __raw_writew(__raw_readw(0xe6890008) | 0x600, 0xe6890008);
111 }
112
113 static struct r8a66597_platdata usb_host_data = {
114 .on_chip = 1,
115 .port_power = usb_host_port_power,
116 };
117
118 static struct resource usb_host_resources[] = {
119 [0] = {
120 .name = "USBHS",
121 .start = 0xe6890000,
122 .end = 0xe68900e5,
123 .flags = IORESOURCE_MEM,
124 },
125 [1] = {
126 .start = evt2irq(0xa20), /* USBHS_USHI0 */
127 .flags = IORESOURCE_IRQ,
128 },
129 };
130
131 static struct platform_device usb_host_device = {
132 .name = "r8a66597_hcd",
133 .id = 0,
134 .dev = {
135 .platform_data = &usb_host_data,
136 .dma_mask = NULL,
137 .coherent_dma_mask = 0xffffffff,
138 },
139 .num_resources = ARRAY_SIZE(usb_host_resources),
140 .resource = usb_host_resources,
141 };
142
143 /* KEYSC */
144 static struct sh_keysc_info keysc_info = {
145 .mode = SH_KEYSC_MODE_5,
146 .scan_timing = 3,
147 .delay = 100,
148 .keycodes = {
149 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F, KEY_G,
150 KEY_H, KEY_I, KEY_J, KEY_K, KEY_L, KEY_M, KEY_N,
151 KEY_O, KEY_P, KEY_Q, KEY_R, KEY_S, KEY_T, KEY_U,
152 KEY_V, KEY_W, KEY_X, KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP,
153 KEY_WAKEUP, KEY_COFFEE, KEY_0, KEY_1, KEY_2, KEY_3, KEY_4,
154 KEY_5, KEY_6, KEY_7, KEY_8, KEY_9, KEY_STOP, KEY_COMPUTER,
155 },
156 };
157
158 static struct resource keysc_resources[] = {
159 [0] = {
160 .name = "KEYSC",
161 .start = 0xe61b0000,
162 .end = 0xe61b000f,
163 .flags = IORESOURCE_MEM,
164 },
165 [1] = {
166 .start = evt2irq(0xbe0), /* KEYSC_KEY */
167 .flags = IORESOURCE_IRQ,
168 },
169 };
170
171 static struct platform_device keysc_device = {
172 .name = "sh_keysc",
173 .num_resources = ARRAY_SIZE(keysc_resources),
174 .resource = keysc_resources,
175 .dev = {
176 .platform_data = &keysc_info,
177 },
178 };
179
180 static struct mtd_partition nand_partition_info[] = {
181 {
182 .name = "system",
183 .offset = 0,
184 .size = 64 * 1024 * 1024,
185 },
186 {
187 .name = "userdata",
188 .offset = MTDPART_OFS_APPEND,
189 .size = 128 * 1024 * 1024,
190 },
191 {
192 .name = "cache",
193 .offset = MTDPART_OFS_APPEND,
194 .size = 64 * 1024 * 1024,
195 },
196 };
197
198 static struct resource nand_flash_resources[] = {
199 [0] = {
200 .start = 0xe6a30000,
201 .end = 0xe6a3009b,
202 .flags = IORESOURCE_MEM,
203 }
204 };
205
206 static struct sh_flctl_platform_data nand_flash_data = {
207 .parts = nand_partition_info,
208 .nr_parts = ARRAY_SIZE(nand_partition_info),
209 .flcmncr_val = QTSEL_E | FCKSEL_E | TYPESEL_SET | NANWF_E
210 | SHBUSSEL | SEL_16BIT,
211 };
212
213 static struct platform_device nand_flash_device = {
214 .name = "sh_flctl",
215 .resource = nand_flash_resources,
216 .num_resources = ARRAY_SIZE(nand_flash_resources),
217 .dev = {
218 .platform_data = &nand_flash_data,
219 },
220 };
221
222 static struct resource irda_resources[] = {
223 [0] = {
224 .start = 0xE6D00000,
225 .end = 0xE6D01FD4 - 1,
226 .flags = IORESOURCE_MEM,
227 },
228 [1] = {
229 .start = evt2irq(0x480), /* IRDA */
230 .flags = IORESOURCE_IRQ,
231 },
232 };
233
234 static struct platform_device irda_device = {
235 .name = "sh_irda",
236 .id = -1,
237 .resource = irda_resources,
238 .num_resources = ARRAY_SIZE(irda_resources),
239 };
240
241 static struct platform_device *g3evm_devices[] __initdata = {
242 &nor_flash_device,
243 &usb_host_device,
244 &keysc_device,
245 &nand_flash_device,
246 &irda_device,
247 };
248
249 static struct map_desc g3evm_io_desc[] __initdata = {
250 /* create a 1:1 entity map for 0xe6xxxxxx
251 * used by CPGA, INTC and PFC.
252 */
253 {
254 .virtual = 0xe6000000,
255 .pfn = __phys_to_pfn(0xe6000000),
256 .length = 256 << 20,
257 .type = MT_DEVICE_NONSHARED
258 },
259 };
260
261 static void __init g3evm_map_io(void)
262 {
263 iotable_init(g3evm_io_desc, ARRAY_SIZE(g3evm_io_desc));
264 /* DMA memory at 0xf6000000 - 0xffdfffff */
265 init_consistent_dma_size(158 << 20);
266
267 /* setup early devices and console here as well */
268 sh7367_add_early_devices();
269 shmobile_setup_console();
270 }
271
272 static void __init g3evm_init(void)
273 {
274 sh7367_pinmux_init();
275
276 /* Lit DS4 LED */
277 gpio_request(GPIO_PORT22, NULL);
278 gpio_direction_output(GPIO_PORT22, 1);
279 gpio_export(GPIO_PORT22, 0);
280
281 /* Lit DS8 LED */
282 gpio_request(GPIO_PORT23, NULL);
283 gpio_direction_output(GPIO_PORT23, 1);
284 gpio_export(GPIO_PORT23, 0);
285
286 /* Lit DS3 LED */
287 gpio_request(GPIO_PORT24, NULL);
288 gpio_direction_output(GPIO_PORT24, 1);
289 gpio_export(GPIO_PORT24, 0);
290
291 /* SCIFA1 */
292 gpio_request(GPIO_FN_SCIFA1_TXD, NULL);
293 gpio_request(GPIO_FN_SCIFA1_RXD, NULL);
294 gpio_request(GPIO_FN_SCIFA1_CTS, NULL);
295 gpio_request(GPIO_FN_SCIFA1_RTS, NULL);
296
297 /* USBHS */
298 gpio_request(GPIO_FN_VBUS0, NULL);
299 gpio_request(GPIO_FN_PWEN, NULL);
300 gpio_request(GPIO_FN_OVCN, NULL);
301 gpio_request(GPIO_FN_OVCN2, NULL);
302 gpio_request(GPIO_FN_EXTLP, NULL);
303 gpio_request(GPIO_FN_IDIN, NULL);
304
305 /* setup USB phy */
306 __raw_writew(0x0300, 0xe605810a); /* USBCR1 */
307 __raw_writew(0x00e0, 0xe60581c0); /* CPFCH */
308 __raw_writew(0x6010, 0xe60581c6); /* CGPOSR */
309 __raw_writew(0x8a0a, 0xe605810c); /* USBCR2 */
310
311 /* KEYSC @ CN7 */
312 gpio_request(GPIO_FN_PORT42_KEYOUT0, NULL);
313 gpio_request(GPIO_FN_PORT43_KEYOUT1, NULL);
314 gpio_request(GPIO_FN_PORT44_KEYOUT2, NULL);
315 gpio_request(GPIO_FN_PORT45_KEYOUT3, NULL);
316 gpio_request(GPIO_FN_PORT46_KEYOUT4, NULL);
317 gpio_request(GPIO_FN_PORT47_KEYOUT5, NULL);
318 gpio_request(GPIO_FN_PORT48_KEYIN0_PU, NULL);
319 gpio_request(GPIO_FN_PORT49_KEYIN1_PU, NULL);
320 gpio_request(GPIO_FN_PORT50_KEYIN2_PU, NULL);
321 gpio_request(GPIO_FN_PORT55_KEYIN3_PU, NULL);
322 gpio_request(GPIO_FN_PORT56_KEYIN4_PU, NULL);
323 gpio_request(GPIO_FN_PORT57_KEYIN5_PU, NULL);
324 gpio_request(GPIO_FN_PORT58_KEYIN6_PU, NULL);
325
326 /* FLCTL */
327 gpio_request(GPIO_FN_FCE0, NULL);
328 gpio_request(GPIO_FN_D0_ED0_NAF0, NULL);
329 gpio_request(GPIO_FN_D1_ED1_NAF1, NULL);
330 gpio_request(GPIO_FN_D2_ED2_NAF2, NULL);
331 gpio_request(GPIO_FN_D3_ED3_NAF3, NULL);
332 gpio_request(GPIO_FN_D4_ED4_NAF4, NULL);
333 gpio_request(GPIO_FN_D5_ED5_NAF5, NULL);
334 gpio_request(GPIO_FN_D6_ED6_NAF6, NULL);
335 gpio_request(GPIO_FN_D7_ED7_NAF7, NULL);
336 gpio_request(GPIO_FN_D8_ED8_NAF8, NULL);
337 gpio_request(GPIO_FN_D9_ED9_NAF9, NULL);
338 gpio_request(GPIO_FN_D10_ED10_NAF10, NULL);
339 gpio_request(GPIO_FN_D11_ED11_NAF11, NULL);
340 gpio_request(GPIO_FN_D12_ED12_NAF12, NULL);
341 gpio_request(GPIO_FN_D13_ED13_NAF13, NULL);
342 gpio_request(GPIO_FN_D14_ED14_NAF14, NULL);
343 gpio_request(GPIO_FN_D15_ED15_NAF15, NULL);
344 gpio_request(GPIO_FN_WE0_XWR0_FWE, NULL);
345 gpio_request(GPIO_FN_FRB, NULL);
346 /* FOE, FCDE, FSC on dedicated pins */
347 __raw_writel(__raw_readl(0xe6158048) & ~(1 << 15), 0xe6158048);
348
349 /* IrDA */
350 gpio_request(GPIO_FN_IRDA_OUT, NULL);
351 gpio_request(GPIO_FN_IRDA_IN, NULL);
352 gpio_request(GPIO_FN_IRDA_FIRSEL, NULL);
353
354 sh7367_add_standard_devices();
355
356 platform_add_devices(g3evm_devices, ARRAY_SIZE(g3evm_devices));
357 }
358
359 static void __init g3evm_timer_init(void)
360 {
361 sh7367_clock_init();
362 shmobile_timer.init();
363 }
364
365 static struct sys_timer g3evm_timer = {
366 .init = g3evm_timer_init,
367 };
368
369 MACHINE_START(G3EVM, "g3evm")
370 .map_io = g3evm_map_io,
371 .init_irq = sh7367_init_irq,
372 .handle_irq = shmobile_handle_irq_intc,
373 .init_machine = g3evm_init,
374 .timer = &g3evm_timer,
375 MACHINE_END