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>
29 #include <mach/hardware.h>
30 #include <asm/mach-types.h>
31 #include <asm/mach/arch.h>
32 #include <asm/mach/map.h>
35 #include <plat/board.h>
36 #include <plat/common.h>
37 #include <plat/keypad.h>
38 #include <plat/menelaus.h>
40 #include <plat/gpmc.h>
42 #include <video/omapdss.h>
43 #include <video/omap-panel-generic-dpi.h>
49 #define H4_SMC91X_CS 1
51 #define H4_ETHR_GPIO_IRQ 92
53 static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
54 static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
56 static const unsigned int h4_keymap[] = {
89 static struct mtd_partition h4_partitions[] = {
90 /* bootloader (U-Boot, etc) in first sector */
95 .mask_flags = MTD_WRITEABLE, /* force read-only */
97 /* bootloader params in the next sector */
100 .offset = MTDPART_OFS_APPEND,
107 .offset = MTDPART_OFS_APPEND,
113 .name = "filesystem",
114 .offset = MTDPART_OFS_APPEND,
115 .size = MTDPART_SIZ_FULL,
120 static struct physmap_flash_data h4_flash_data = {
122 .parts = h4_partitions,
123 .nr_parts = ARRAY_SIZE(h4_partitions),
126 static struct resource h4_flash_resource = {
127 .flags = IORESOURCE_MEM,
130 static struct platform_device h4_flash_device = {
131 .name = "physmap-flash",
134 .platform_data = &h4_flash_data,
137 .resource = &h4_flash_resource,
140 static const struct matrix_keymap_data h4_keymap_data = {
142 .keymap_size = ARRAY_SIZE(h4_keymap),
145 static struct omap_kp_platform_data h4_kp_data = {
148 .keymap_data = &h4_keymap_data,
150 .row_gpios = row_gpios,
151 .col_gpios = col_gpios,
154 static struct platform_device h4_kp_device = {
155 .name = "omap-keypad",
158 .platform_data = &h4_kp_data,
162 static struct platform_device *h4_devices[] __initdata = {
167 static struct panel_generic_dpi_data h4_panel_data = {
171 static struct omap_dss_device h4_lcd_device = {
173 .driver_name = "generic_dpi_panel",
174 .type = OMAP_DISPLAY_TYPE_DPI,
175 .phy.dpi.data_lines = 16,
176 .data = &h4_panel_data,
179 static struct omap_dss_device *h4_dss_devices[] = {
183 static struct omap_dss_board_info h4_dss_data = {
184 .num_devices = ARRAY_SIZE(h4_dss_devices),
185 .devices = h4_dss_devices,
186 .default_device = &h4_lcd_device,
189 /* 2420 Sysboot setup (2430 is different) */
190 static u32 get_sysboot_value(void)
192 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
193 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
194 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
195 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
198 /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
200 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
201 * correctly. The macro needs to look at production_id not just hawkeye.
203 static u32 is_gpmc_muxed(void)
206 mux = get_sysboot_value();
207 if ((mux & 0xF) == 0xd)
208 return 1; /* NAND config (could be either) */
209 if (mux & 0x2) /* if mux'ed */
215 static inline void __init h4_init_debug(void)
218 unsigned long cs_mem_base;
219 unsigned int muxed, rate;
220 struct clk *gpmc_fck;
222 eth_cs = H4_SMC91X_CS;
224 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
225 if (IS_ERR(gpmc_fck)) {
230 clk_enable(gpmc_fck);
231 rate = clk_get_rate(gpmc_fck);
232 clk_disable(gpmc_fck);
240 /* Make sure CS1 timings are correct */
241 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
244 if (rate >= 160000000) {
245 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
246 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
247 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
248 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
249 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
250 } else if (rate >= 130000000) {
251 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
252 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
253 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
254 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
255 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
256 } else {/* rate = 100000000 */
257 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
258 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
259 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
260 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
261 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
264 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
265 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
271 omap_mux_init_gpio(92, 0);
272 if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0)
273 gpmc_cs_free(eth_cs);
276 clk_disable(gpmc_fck);
280 static void __init h4_init_flash(void)
284 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
285 printk("Can't request GPMC CS for flash\n");
288 h4_flash_resource.start = base;
289 h4_flash_resource.end = base + SZ_64M - 1;
292 static struct omap_usb_config h4_usb_config __initdata = {
293 /* S1.10 OFF -- usb "download port"
294 * usb0 switched to Mini-B port and isp1105 transceiver;
295 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
299 /* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */
300 .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */
303 static struct at24_platform_data m24c01 = {
304 .byte_len = SZ_1K / 8,
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 },
329 static void __init omap_h4_init(void)
331 omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAF);
334 * Make sure the serial ports are muxed on at this point.
335 * You have to mux them off in device drivers later on
339 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
340 omap_mux_init_gpio(88, OMAP_PULL_ENA | OMAP_PULL_UP);
341 omap_mux_init_gpio(89, OMAP_PULL_ENA | OMAP_PULL_UP);
342 omap_mux_init_gpio(124, OMAP_PULL_ENA | OMAP_PULL_UP);
343 omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
344 if (omap_has_menelaus()) {
345 omap_mux_init_signal("sdrc_a14.gpio0",
346 OMAP_PULL_ENA | OMAP_PULL_UP);
347 omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
348 omap_mux_init_signal("gpio_98", 0);
353 omap_mux_init_signal("gpio_96", OMAP_PULL_ENA | OMAP_PULL_UP);
354 omap_mux_init_signal("gpio_100", 0);
355 omap_mux_init_signal("gpio_98", 0);
357 omap_mux_init_signal("gpio_90", 0);
358 omap_mux_init_signal("gpio_91", 0);
359 omap_mux_init_signal("gpio_36", 0);
360 omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
361 omap_mux_init_signal("gpio_97", 0);
364 i2c_register_board_info(1, h4_i2c_board_info,
365 ARRAY_SIZE(h4_i2c_board_info));
367 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
368 omap2_usbfs_init(&h4_usb_config);
370 omap_sdrc_init(NULL, NULL);
373 omap_display_init(&h4_dss_data);
376 MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
377 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
378 .atag_offset = 0x100,
379 .reserve = omap_reserve,
380 .map_io = omap242x_map_io,
381 .init_early = omap2420_init_early,
382 .init_irq = omap2_init_irq,
383 .init_machine = omap_h4_init,
384 .timer = &omap2_timer,