drm/i915|intel-gtt: consolidate intel-gtt.h headers
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / arm / mach-shmobile / board-g4evm.c
blob5b3b582ef3f25fefd4430c071e89f42355832fb1
1 /*
2 * G4EVM board support
4 * Copyright (C) 2010 Magnus Damm
5 * Copyright (C) 2008 Yoshihiro Shimoda
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.
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.
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
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/usb/r8a66597.h>
30 #include <linux/io.h>
31 #include <linux/input.h>
32 #include <linux/input/sh_keysc.h>
33 #include <linux/mfd/sh_mobile_sdhi.h>
34 #include <linux/gpio.h>
35 #include <mach/sh7377.h>
36 #include <mach/common.h>
37 #include <asm/mach-types.h>
38 #include <asm/mach/arch.h>
39 #include <asm/mach/map.h>
40 #include <asm/mach/time.h>
43 * SDHI
45 * SDHI0 : card detection is possible
46 * SDHI1 : card detection is impossible
48 * [G4-MAIN-BOARD]
49 * JP74 : short # DBG_2V8A for SDHI0
50 * JP75 : NC # DBG_3V3A for SDHI0
51 * JP76 : NC # DBG_3V3A_SD for SDHI0
52 * JP77 : NC # 3V3A_SDIO for SDHI1
53 * JP78 : short # DBG_2V8A for SDHI1
54 * JP79 : NC # DBG_3V3A for SDHI1
55 * JP80 : NC # DBG_3V3A_SD for SDHI1
57 * [G4-CORE-BOARD]
58 * S32 : all off # to dissever from G3-CORE_DBG board
59 * S33 : all off # to dissever from G3-CORE_DBG board
61 * [G3-CORE_DBG-BOARD]
62 * S1 : all off # to dissever from G3-CORE_DBG board
63 * S3 : all off # to dissever from G3-CORE_DBG board
64 * S4 : all off # to dissever from G3-CORE_DBG board
67 static struct mtd_partition nor_flash_partitions[] = {
69 .name = "loader",
70 .offset = 0x00000000,
71 .size = 512 * 1024,
74 .name = "bootenv",
75 .offset = MTDPART_OFS_APPEND,
76 .size = 512 * 1024,
79 .name = "kernel_ro",
80 .offset = MTDPART_OFS_APPEND,
81 .size = 8 * 1024 * 1024,
82 .mask_flags = MTD_WRITEABLE,
85 .name = "kernel",
86 .offset = MTDPART_OFS_APPEND,
87 .size = 8 * 1024 * 1024,
90 .name = "data",
91 .offset = MTDPART_OFS_APPEND,
92 .size = MTDPART_SIZ_FULL,
96 static struct physmap_flash_data nor_flash_data = {
97 .width = 2,
98 .parts = nor_flash_partitions,
99 .nr_parts = ARRAY_SIZE(nor_flash_partitions),
102 static struct resource nor_flash_resources[] = {
103 [0] = {
104 .start = 0x00000000,
105 .end = 0x08000000 - 1,
106 .flags = IORESOURCE_MEM,
110 static struct platform_device nor_flash_device = {
111 .name = "physmap-flash",
112 .dev = {
113 .platform_data = &nor_flash_data,
115 .num_resources = ARRAY_SIZE(nor_flash_resources),
116 .resource = nor_flash_resources,
119 /* USBHS */
120 static void usb_host_port_power(int port, int power)
122 if (!power) /* only power-on supported for now */
123 return;
125 /* set VBOUT/PWEN and EXTLP0 in DVSTCTR */
126 __raw_writew(__raw_readw(0xe6890008) | 0x600, 0xe6890008);
129 static struct r8a66597_platdata usb_host_data = {
130 .on_chip = 1,
131 .port_power = usb_host_port_power,
134 static struct resource usb_host_resources[] = {
135 [0] = {
136 .name = "USBHS",
137 .start = 0xe6890000,
138 .end = 0xe68900e5,
139 .flags = IORESOURCE_MEM,
141 [1] = {
142 .start = evt2irq(0x0a20), /* USBHS_USHI0 */
143 .flags = IORESOURCE_IRQ,
147 static struct platform_device usb_host_device = {
148 .name = "r8a66597_hcd",
149 .id = 0,
150 .dev = {
151 .platform_data = &usb_host_data,
152 .dma_mask = NULL,
153 .coherent_dma_mask = 0xffffffff,
155 .num_resources = ARRAY_SIZE(usb_host_resources),
156 .resource = usb_host_resources,
159 /* KEYSC */
160 static struct sh_keysc_info keysc_info = {
161 .mode = SH_KEYSC_MODE_5,
162 .scan_timing = 3,
163 .delay = 100,
164 .keycodes = {
165 KEY_A, KEY_B, KEY_C, KEY_D, KEY_E, KEY_F,
166 KEY_G, KEY_H, KEY_I, KEY_J, KEY_K, KEY_L,
167 KEY_M, KEY_N, KEY_U, KEY_P, KEY_Q, KEY_R,
168 KEY_S, KEY_T, KEY_U, KEY_V, KEY_W, KEY_X,
169 KEY_Y, KEY_Z, KEY_HOME, KEY_SLEEP, KEY_WAKEUP, KEY_COFFEE,
170 KEY_0, KEY_1, KEY_2, KEY_3, KEY_4, KEY_5,
171 KEY_6, KEY_7, KEY_8, KEY_9, KEY_STOP, KEY_COMPUTER,
175 static struct resource keysc_resources[] = {
176 [0] = {
177 .name = "KEYSC",
178 .start = 0xe61b0000,
179 .end = 0xe61b000f,
180 .flags = IORESOURCE_MEM,
182 [1] = {
183 .start = evt2irq(0x0be0), /* KEYSC_KEY */
184 .flags = IORESOURCE_IRQ,
188 static struct platform_device keysc_device = {
189 .name = "sh_keysc",
190 .id = 0, /* keysc0 clock */
191 .num_resources = ARRAY_SIZE(keysc_resources),
192 .resource = keysc_resources,
193 .dev = {
194 .platform_data = &keysc_info,
198 /* SDHI */
199 static struct resource sdhi0_resources[] = {
200 [0] = {
201 .name = "SDHI0",
202 .start = 0xe6d50000,
203 .end = 0xe6d501ff,
204 .flags = IORESOURCE_MEM,
206 [1] = {
207 .start = evt2irq(0x0e00), /* SDHI0 */
208 .flags = IORESOURCE_IRQ,
212 static struct platform_device sdhi0_device = {
213 .name = "sh_mobile_sdhi",
214 .num_resources = ARRAY_SIZE(sdhi0_resources),
215 .resource = sdhi0_resources,
216 .id = 0,
219 static struct resource sdhi1_resources[] = {
220 [0] = {
221 .name = "SDHI1",
222 .start = 0xe6d60000,
223 .end = 0xe6d601ff,
224 .flags = IORESOURCE_MEM,
226 [1] = {
227 .start = evt2irq(0x0e80), /* SDHI1 */
228 .flags = IORESOURCE_IRQ,
232 static struct platform_device sdhi1_device = {
233 .name = "sh_mobile_sdhi",
234 .num_resources = ARRAY_SIZE(sdhi1_resources),
235 .resource = sdhi1_resources,
236 .id = 1,
239 static struct platform_device *g4evm_devices[] __initdata = {
240 &nor_flash_device,
241 &usb_host_device,
242 &keysc_device,
243 &sdhi0_device,
244 &sdhi1_device,
247 static struct map_desc g4evm_io_desc[] __initdata = {
248 /* create a 1:1 entity map for 0xe6xxxxxx
249 * used by CPGA, INTC and PFC.
252 .virtual = 0xe6000000,
253 .pfn = __phys_to_pfn(0xe6000000),
254 .length = 256 << 20,
255 .type = MT_DEVICE_NONSHARED
259 static void __init g4evm_map_io(void)
261 iotable_init(g4evm_io_desc, ARRAY_SIZE(g4evm_io_desc));
263 /* setup early devices and console here as well */
264 sh7377_add_early_devices();
265 shmobile_setup_console();
268 #define GPIO_SDHID0_D0 0xe60520fc
269 #define GPIO_SDHID0_D1 0xe60520fd
270 #define GPIO_SDHID0_D2 0xe60520fe
271 #define GPIO_SDHID0_D3 0xe60520ff
272 #define GPIO_SDHICMD0 0xe6052100
274 #define GPIO_SDHID1_D0 0xe6052103
275 #define GPIO_SDHID1_D1 0xe6052104
276 #define GPIO_SDHID1_D2 0xe6052105
277 #define GPIO_SDHID1_D3 0xe6052106
278 #define GPIO_SDHICMD1 0xe6052107
281 * FIXME !!
283 * gpio_pull_up is quick_hack.
285 * current gpio frame work doesn't have
286 * the method to control only pull up/down/free.
287 * this function should be replaced by correct gpio function
289 static void __init gpio_pull_up(u32 addr)
291 u8 data = __raw_readb(addr);
293 data &= 0x0F;
294 data |= 0xC0;
295 __raw_writeb(data, addr);
298 static void __init g4evm_init(void)
300 sh7377_pinmux_init();
302 /* Lit DS14 LED */
303 gpio_request(GPIO_PORT109, NULL);
304 gpio_direction_output(GPIO_PORT109, 1);
305 gpio_export(GPIO_PORT109, 1);
307 /* Lit DS15 LED */
308 gpio_request(GPIO_PORT110, NULL);
309 gpio_direction_output(GPIO_PORT110, 1);
310 gpio_export(GPIO_PORT110, 1);
312 /* Lit DS16 LED */
313 gpio_request(GPIO_PORT112, NULL);
314 gpio_direction_output(GPIO_PORT112, 1);
315 gpio_export(GPIO_PORT112, 1);
317 /* Lit DS17 LED */
318 gpio_request(GPIO_PORT113, NULL);
319 gpio_direction_output(GPIO_PORT113, 1);
320 gpio_export(GPIO_PORT113, 1);
322 /* USBHS */
323 gpio_request(GPIO_FN_VBUS_0, NULL);
324 gpio_request(GPIO_FN_PWEN, NULL);
325 gpio_request(GPIO_FN_OVCN, NULL);
326 gpio_request(GPIO_FN_OVCN2, NULL);
327 gpio_request(GPIO_FN_EXTLP, NULL);
328 gpio_request(GPIO_FN_IDIN, NULL);
330 /* setup USB phy */
331 __raw_writew(0x0200, 0xe605810a); /* USBCR1 */
332 __raw_writew(0x00e0, 0xe60581c0); /* CPFCH */
333 __raw_writew(0x6010, 0xe60581c6); /* CGPOSR */
334 __raw_writew(0x8a0a, 0xe605810c); /* USBCR2 */
336 /* KEYSC @ CN31 */
337 gpio_request(GPIO_FN_PORT60_KEYOUT5, NULL);
338 gpio_request(GPIO_FN_PORT61_KEYOUT4, NULL);
339 gpio_request(GPIO_FN_PORT62_KEYOUT3, NULL);
340 gpio_request(GPIO_FN_PORT63_KEYOUT2, NULL);
341 gpio_request(GPIO_FN_PORT64_KEYOUT1, NULL);
342 gpio_request(GPIO_FN_PORT65_KEYOUT0, NULL);
343 gpio_request(GPIO_FN_PORT66_KEYIN0_PU, NULL);
344 gpio_request(GPIO_FN_PORT67_KEYIN1_PU, NULL);
345 gpio_request(GPIO_FN_PORT68_KEYIN2_PU, NULL);
346 gpio_request(GPIO_FN_PORT69_KEYIN3_PU, NULL);
347 gpio_request(GPIO_FN_PORT70_KEYIN4_PU, NULL);
348 gpio_request(GPIO_FN_PORT71_KEYIN5_PU, NULL);
349 gpio_request(GPIO_FN_PORT72_KEYIN6_PU, NULL);
351 /* SDHI0 */
352 gpio_request(GPIO_FN_SDHICLK0, NULL);
353 gpio_request(GPIO_FN_SDHICD0, NULL);
354 gpio_request(GPIO_FN_SDHID0_0, NULL);
355 gpio_request(GPIO_FN_SDHID0_1, NULL);
356 gpio_request(GPIO_FN_SDHID0_2, NULL);
357 gpio_request(GPIO_FN_SDHID0_3, NULL);
358 gpio_request(GPIO_FN_SDHICMD0, NULL);
359 gpio_request(GPIO_FN_SDHIWP0, NULL);
360 gpio_pull_up(GPIO_SDHID0_D0);
361 gpio_pull_up(GPIO_SDHID0_D1);
362 gpio_pull_up(GPIO_SDHID0_D2);
363 gpio_pull_up(GPIO_SDHID0_D3);
364 gpio_pull_up(GPIO_SDHICMD0);
366 /* SDHI1 */
367 gpio_request(GPIO_FN_SDHICLK1, NULL);
368 gpio_request(GPIO_FN_SDHID1_0, NULL);
369 gpio_request(GPIO_FN_SDHID1_1, NULL);
370 gpio_request(GPIO_FN_SDHID1_2, NULL);
371 gpio_request(GPIO_FN_SDHID1_3, NULL);
372 gpio_request(GPIO_FN_SDHICMD1, NULL);
373 gpio_pull_up(GPIO_SDHID1_D0);
374 gpio_pull_up(GPIO_SDHID1_D1);
375 gpio_pull_up(GPIO_SDHID1_D2);
376 gpio_pull_up(GPIO_SDHID1_D3);
377 gpio_pull_up(GPIO_SDHICMD1);
379 sh7377_add_standard_devices();
381 platform_add_devices(g4evm_devices, ARRAY_SIZE(g4evm_devices));
384 static void __init g4evm_timer_init(void)
386 sh7377_clock_init();
387 shmobile_timer.init();
390 static struct sys_timer g4evm_timer = {
391 .init = g4evm_timer_init,
394 MACHINE_START(G4EVM, "g4evm")
395 .map_io = g4evm_map_io,
396 .init_irq = sh7377_init_irq,
397 .init_machine = g4evm_init,
398 .timer = &g4evm_timer,
399 MACHINE_END