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>
28 #include <linux/input/matrix_keypad.h>
30 #include <mach/hardware.h>
31 #include <asm/mach-types.h>
32 #include <asm/mach/arch.h>
33 #include <asm/mach/map.h>
35 #include <plat/board.h>
37 #include <plat/menelaus.h>
39 #include <plat/gpmc.h>
41 #include <video/omapdss.h>
42 #include <video/omap-panel-generic-dpi.h>
48 #define H4_SMC91X_CS 1
50 #define H4_ETHR_GPIO_IRQ 92
52 #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
53 static const uint32_t board_matrix_keys[] = {
86 static const struct matrix_keymap_data board_keymap_data = {
87 .keymap = board_matrix_keys,
88 .keymap_size = ARRAY_SIZE(board_matrix_keys),
91 static unsigned int board_keypad_row_gpios[] = {
92 88, 89, 124, 11, 6, 96
95 static unsigned int board_keypad_col_gpios[] = {
96 90, 91, 100, 36, 12, 97, 98
99 static struct matrix_keypad_platform_data board_keypad_platform_data = {
100 .keymap_data = &board_keymap_data,
101 .row_gpios = board_keypad_row_gpios,
102 .num_row_gpios = ARRAY_SIZE(board_keypad_row_gpios),
103 .col_gpios = board_keypad_col_gpios,
104 .num_col_gpios = ARRAY_SIZE(board_keypad_col_gpios),
108 .col_scan_delay_us = 5,
111 static struct platform_device board_keyboard = {
112 .name = "matrix-keypad",
115 .platform_data = &board_keypad_platform_data,
118 static void __init board_mkp_init(void)
120 omap_mux_init_gpio(88, OMAP_PULL_ENA | OMAP_PULL_UP);
121 omap_mux_init_gpio(89, OMAP_PULL_ENA | OMAP_PULL_UP);
122 omap_mux_init_gpio(124, OMAP_PULL_ENA | OMAP_PULL_UP);
123 omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
124 if (omap_has_menelaus()) {
125 omap_mux_init_signal("sdrc_a14.gpio0",
126 OMAP_PULL_ENA | OMAP_PULL_UP);
127 omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
128 omap_mux_init_signal("gpio_98", 0);
129 board_keypad_row_gpios[5] = 0;
130 board_keypad_col_gpios[2] = 15;
131 board_keypad_col_gpios[6] = 18;
133 omap_mux_init_signal("gpio_96", OMAP_PULL_ENA | OMAP_PULL_UP);
134 omap_mux_init_signal("gpio_100", 0);
135 omap_mux_init_signal("gpio_98", 0);
137 omap_mux_init_signal("gpio_90", 0);
138 omap_mux_init_signal("gpio_91", 0);
139 omap_mux_init_signal("gpio_36", 0);
140 omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
141 omap_mux_init_signal("gpio_97", 0);
143 platform_device_register(&board_keyboard);
146 static inline void board_mkp_init(void)
151 static struct mtd_partition h4_partitions[] = {
152 /* bootloader (U-Boot, etc) in first sector */
154 .name = "bootloader",
157 .mask_flags = MTD_WRITEABLE, /* force read-only */
159 /* bootloader params in the next sector */
162 .offset = MTDPART_OFS_APPEND,
169 .offset = MTDPART_OFS_APPEND,
175 .name = "filesystem",
176 .offset = MTDPART_OFS_APPEND,
177 .size = MTDPART_SIZ_FULL,
182 static struct physmap_flash_data h4_flash_data = {
184 .parts = h4_partitions,
185 .nr_parts = ARRAY_SIZE(h4_partitions),
188 static struct resource h4_flash_resource = {
189 .flags = IORESOURCE_MEM,
192 static struct platform_device h4_flash_device = {
193 .name = "physmap-flash",
196 .platform_data = &h4_flash_data,
199 .resource = &h4_flash_resource,
202 static struct platform_device *h4_devices[] __initdata = {
206 static struct panel_generic_dpi_data h4_panel_data = {
210 static struct omap_dss_device h4_lcd_device = {
212 .driver_name = "generic_dpi_panel",
213 .type = OMAP_DISPLAY_TYPE_DPI,
214 .phy.dpi.data_lines = 16,
215 .data = &h4_panel_data,
218 static struct omap_dss_device *h4_dss_devices[] = {
222 static struct omap_dss_board_info h4_dss_data = {
223 .num_devices = ARRAY_SIZE(h4_dss_devices),
224 .devices = h4_dss_devices,
225 .default_device = &h4_lcd_device,
228 /* 2420 Sysboot setup (2430 is different) */
229 static u32 get_sysboot_value(void)
231 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
232 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
233 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
234 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
237 /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
239 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
240 * correctly. The macro needs to look at production_id not just hawkeye.
242 static u32 is_gpmc_muxed(void)
245 mux = get_sysboot_value();
246 if ((mux & 0xF) == 0xd)
247 return 1; /* NAND config (could be either) */
248 if (mux & 0x2) /* if mux'ed */
254 static inline void __init h4_init_debug(void)
257 unsigned long cs_mem_base;
258 unsigned int muxed, rate;
259 struct clk *gpmc_fck;
261 eth_cs = H4_SMC91X_CS;
263 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
264 if (IS_ERR(gpmc_fck)) {
269 clk_enable(gpmc_fck);
270 rate = clk_get_rate(gpmc_fck);
271 clk_disable(gpmc_fck);
279 /* Make sure CS1 timings are correct */
280 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
283 if (rate >= 160000000) {
284 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
285 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
286 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
287 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
288 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
289 } else if (rate >= 130000000) {
290 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
291 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
292 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
293 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
294 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
295 } else {/* rate = 100000000 */
296 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
297 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
298 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
299 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
300 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
303 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
304 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
310 omap_mux_init_gpio(92, 0);
311 if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0)
312 gpmc_cs_free(eth_cs);
315 clk_disable(gpmc_fck);
319 static void __init h4_init_flash(void)
323 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
324 printk("Can't request GPMC CS for flash\n");
327 h4_flash_resource.start = base;
328 h4_flash_resource.end = base + SZ_64M - 1;
331 static struct at24_platform_data m24c01 = {
332 .byte_len = SZ_1K / 8,
336 static struct i2c_board_info __initdata h4_i2c_board_info[] = {
338 I2C_BOARD_INFO("isp1301_omap", 0x2d),
340 { /* EEPROM on mainboard */
341 I2C_BOARD_INFO("24c01", 0x52),
342 .platform_data = &m24c01,
344 { /* EEPROM on cpu card */
345 I2C_BOARD_INFO("24c01", 0x57),
346 .platform_data = &m24c01,
350 #ifdef CONFIG_OMAP_MUX
351 static struct omap_board_mux board_mux[] __initdata = {
352 { .reg_offset = OMAP_MUX_TERMINATOR },
356 static void __init omap_h4_init(void)
358 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF);
361 * Make sure the serial ports are muxed on at this point.
362 * You have to mux them off in device drivers later on
367 h4_i2c_board_info[0].irq = gpio_to_irq(125);
368 i2c_register_board_info(1, h4_i2c_board_info,
369 ARRAY_SIZE(h4_i2c_board_info));
371 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
373 omap_sdrc_init(NULL, NULL);
376 omap_display_init(&h4_dss_data);
379 MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
380 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
381 .atag_offset = 0x100,
382 .reserve = omap_reserve,
383 .map_io = omap242x_map_io,
384 .init_early = omap2420_init_early,
385 .init_irq = omap2_init_irq,
386 .handle_irq = omap2_intc_handle_irq,
387 .init_machine = omap_h4_init,
388 .init_late = omap2420_init_late,
389 .timer = &omap2_timer,
390 .restart = omap_prcm_restart,