Add linux-next specific files for 20110831
[linux-2.6/next.git] / arch / arm / mach-omap2 / board-h4.c
blob82421a4cfa928af257af4e02280c4e067d0a5317
1 /*
2 * linux/arch/arm/mach-omap2/board-h4.c
4 * Copyright (C) 2005 Nokia Corporation
5 * Author: Paul Mundt <paul.mundt@nokia.com>
7 * Modified from mach-omap/omap1/board-generic.c
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 #include <linux/gpio.h>
14 #include <linux/kernel.h>
15 #include <linux/init.h>
16 #include <linux/platform_device.h>
17 #include <linux/mtd/mtd.h>
18 #include <linux/mtd/partitions.h>
19 #include <linux/mtd/physmap.h>
20 #include <linux/delay.h>
21 #include <linux/workqueue.h>
22 #include <linux/i2c.h>
23 #include <linux/i2c/at24.h>
24 #include <linux/input.h>
25 #include <linux/err.h>
26 #include <linux/clk.h>
27 #include <linux/io.h>
29 #include <mach/hardware.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
34 #include <plat/usb.h>
35 #include <plat/board.h>
36 #include <plat/common.h>
37 #include <plat/keypad.h>
38 #include <plat/menelaus.h>
39 #include <plat/dma.h>
40 #include <plat/gpmc.h>
42 #include "mux.h"
43 #include "control.h"
45 #define H4_FLASH_CS 0
46 #define H4_SMC91X_CS 1
48 #define H4_ETHR_GPIO_IRQ 92
50 static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
51 static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
53 static const unsigned int h4_keymap[] = {
54 KEY(0, 0, KEY_LEFT),
55 KEY(1, 0, KEY_RIGHT),
56 KEY(2, 0, KEY_A),
57 KEY(3, 0, KEY_B),
58 KEY(4, 0, KEY_C),
59 KEY(0, 1, KEY_DOWN),
60 KEY(1, 1, KEY_UP),
61 KEY(2, 1, KEY_E),
62 KEY(3, 1, KEY_F),
63 KEY(4, 1, KEY_G),
64 KEY(0, 2, KEY_ENTER),
65 KEY(1, 2, KEY_I),
66 KEY(2, 2, KEY_J),
67 KEY(3, 2, KEY_K),
68 KEY(4, 2, KEY_3),
69 KEY(0, 3, KEY_M),
70 KEY(1, 3, KEY_N),
71 KEY(2, 3, KEY_O),
72 KEY(3, 3, KEY_P),
73 KEY(4, 3, KEY_Q),
74 KEY(0, 4, KEY_R),
75 KEY(1, 4, KEY_4),
76 KEY(2, 4, KEY_T),
77 KEY(3, 4, KEY_U),
78 KEY(4, 4, KEY_ENTER),
79 KEY(0, 5, KEY_V),
80 KEY(1, 5, KEY_W),
81 KEY(2, 5, KEY_L),
82 KEY(3, 5, KEY_S),
83 KEY(4, 5, KEY_ENTER),
86 static struct mtd_partition h4_partitions[] = {
87 /* bootloader (U-Boot, etc) in first sector */
89 .name = "bootloader",
90 .offset = 0,
91 .size = SZ_128K,
92 .mask_flags = MTD_WRITEABLE, /* force read-only */
94 /* bootloader params in the next sector */
96 .name = "params",
97 .offset = MTDPART_OFS_APPEND,
98 .size = SZ_128K,
99 .mask_flags = 0,
101 /* kernel */
103 .name = "kernel",
104 .offset = MTDPART_OFS_APPEND,
105 .size = SZ_2M,
106 .mask_flags = 0
108 /* file system */
110 .name = "filesystem",
111 .offset = MTDPART_OFS_APPEND,
112 .size = MTDPART_SIZ_FULL,
113 .mask_flags = 0
117 static struct physmap_flash_data h4_flash_data = {
118 .width = 2,
119 .parts = h4_partitions,
120 .nr_parts = ARRAY_SIZE(h4_partitions),
123 static struct resource h4_flash_resource = {
124 .flags = IORESOURCE_MEM,
127 static struct platform_device h4_flash_device = {
128 .name = "physmap-flash",
129 .id = 0,
130 .dev = {
131 .platform_data = &h4_flash_data,
133 .num_resources = 1,
134 .resource = &h4_flash_resource,
137 static const struct matrix_keymap_data h4_keymap_data = {
138 .keymap = h4_keymap,
139 .keymap_size = ARRAY_SIZE(h4_keymap),
142 static struct omap_kp_platform_data h4_kp_data = {
143 .rows = 6,
144 .cols = 7,
145 .keymap_data = &h4_keymap_data,
146 .rep = true,
147 .row_gpios = row_gpios,
148 .col_gpios = col_gpios,
151 static struct platform_device h4_kp_device = {
152 .name = "omap-keypad",
153 .id = -1,
154 .dev = {
155 .platform_data = &h4_kp_data,
159 static struct platform_device h4_lcd_device = {
160 .name = "lcd_h4",
161 .id = -1,
164 static struct platform_device *h4_devices[] __initdata = {
165 &h4_flash_device,
166 &h4_kp_device,
167 &h4_lcd_device,
170 /* 2420 Sysboot setup (2430 is different) */
171 static u32 get_sysboot_value(void)
173 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
174 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
175 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
176 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
179 /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
181 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
182 * correctly. The macro needs to look at production_id not just hawkeye.
184 static u32 is_gpmc_muxed(void)
186 u32 mux;
187 mux = get_sysboot_value();
188 if ((mux & 0xF) == 0xd)
189 return 1; /* NAND config (could be either) */
190 if (mux & 0x2) /* if mux'ed */
191 return 1;
192 else
193 return 0;
196 static inline void __init h4_init_debug(void)
198 int eth_cs;
199 unsigned long cs_mem_base;
200 unsigned int muxed, rate;
201 struct clk *gpmc_fck;
203 eth_cs = H4_SMC91X_CS;
205 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
206 if (IS_ERR(gpmc_fck)) {
207 WARN_ON(1);
208 return;
211 clk_enable(gpmc_fck);
212 rate = clk_get_rate(gpmc_fck);
213 clk_disable(gpmc_fck);
214 clk_put(gpmc_fck);
216 if (is_gpmc_muxed())
217 muxed = 0x200;
218 else
219 muxed = 0;
221 /* Make sure CS1 timings are correct */
222 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
223 0x00011000 | muxed);
225 if (rate >= 160000000) {
226 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
227 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
228 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
229 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
230 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
231 } else if (rate >= 130000000) {
232 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
233 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
234 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
235 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
236 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
237 } else {/* rate = 100000000 */
238 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
239 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
240 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
241 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
242 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
245 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
246 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
247 goto out;
250 udelay(100);
252 omap_mux_init_gpio(92, 0);
253 if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0)
254 gpmc_cs_free(eth_cs);
256 out:
257 clk_disable(gpmc_fck);
258 clk_put(gpmc_fck);
261 static void __init h4_init_flash(void)
263 unsigned long base;
265 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
266 printk("Can't request GPMC CS for flash\n");
267 return;
269 h4_flash_resource.start = base;
270 h4_flash_resource.end = base + SZ_64M - 1;
273 static struct omap_lcd_config h4_lcd_config __initdata = {
274 .ctrl_name = "internal",
277 static struct omap_usb_config h4_usb_config __initdata = {
278 /* S1.10 OFF -- usb "download port"
279 * usb0 switched to Mini-B port and isp1105 transceiver;
280 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
282 .register_dev = 1,
283 .pins[0] = 3,
284 /* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */
285 .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */
288 static struct omap_board_config_kernel h4_config[] __initdata = {
289 { OMAP_TAG_LCD, &h4_lcd_config },
292 static void __init omap_h4_init_early(void)
294 omap2_init_common_infrastructure();
295 omap2_init_common_devices(NULL, NULL);
298 static void __init omap_h4_init_irq(void)
300 omap2_init_irq();
303 static struct at24_platform_data m24c01 = {
304 .byte_len = SZ_1K / 8,
305 .page_size = 16,
308 static struct i2c_board_info __initdata h4_i2c_board_info[] = {
310 I2C_BOARD_INFO("isp1301_omap", 0x2d),
311 .irq = OMAP_GPIO_IRQ(125),
313 { /* EEPROM on mainboard */
314 I2C_BOARD_INFO("24c01", 0x52),
315 .platform_data = &m24c01,
317 { /* EEPROM on cpu card */
318 I2C_BOARD_INFO("24c01", 0x57),
319 .platform_data = &m24c01,
323 #ifdef CONFIG_OMAP_MUX
324 static struct omap_board_mux board_mux[] __initdata = {
325 { .reg_offset = OMAP_MUX_TERMINATOR },
327 #endif
329 static void __init omap_h4_init(void)
331 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF);
333 omap_board_config = h4_config;
334 omap_board_config_size = ARRAY_SIZE(h4_config);
337 * Make sure the serial ports are muxed on at this point.
338 * You have to mux them off in device drivers later on
339 * if not needed.
342 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
343 omap_mux_init_gpio(88, OMAP_PULL_ENA | OMAP_PULL_UP);
344 omap_mux_init_gpio(89, OMAP_PULL_ENA | OMAP_PULL_UP);
345 omap_mux_init_gpio(124, OMAP_PULL_ENA | OMAP_PULL_UP);
346 omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
347 if (omap_has_menelaus()) {
348 omap_mux_init_signal("sdrc_a14.gpio0",
349 OMAP_PULL_ENA | OMAP_PULL_UP);
350 omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
351 omap_mux_init_signal("gpio_98", 0);
352 row_gpios[5] = 0;
353 col_gpios[2] = 15;
354 col_gpios[6] = 18;
355 } else {
356 omap_mux_init_signal("gpio_96", OMAP_PULL_ENA | OMAP_PULL_UP);
357 omap_mux_init_signal("gpio_100", 0);
358 omap_mux_init_signal("gpio_98", 0);
360 omap_mux_init_signal("gpio_90", 0);
361 omap_mux_init_signal("gpio_91", 0);
362 omap_mux_init_signal("gpio_36", 0);
363 omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
364 omap_mux_init_signal("gpio_97", 0);
365 #endif
367 i2c_register_board_info(1, h4_i2c_board_info,
368 ARRAY_SIZE(h4_i2c_board_info));
370 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
371 omap2_usbfs_init(&h4_usb_config);
372 omap_serial_init();
373 h4_init_flash();
376 static void __init omap_h4_map_io(void)
378 omap2_set_globals_242x();
379 omap242x_map_common_io();
382 MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
383 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
384 .atag_offset = 0x100,
385 .reserve = omap_reserve,
386 .map_io = omap_h4_map_io,
387 .init_early = omap_h4_init_early,
388 .init_irq = omap_h4_init_irq,
389 .init_machine = omap_h4_init,
390 .timer = &omap2_timer,
391 MACHINE_END