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.
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/delay.h>
20 #include <linux/workqueue.h>
21 #include <linux/i2c.h>
22 #include <linux/i2c/at24.h>
23 #include <linux/input.h>
24 #include <linux/err.h>
25 #include <linux/clk.h>
28 #include <mach/hardware.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <asm/mach/map.h>
32 #include <asm/mach/flash.h>
34 #include <mach/control.h>
35 #include <mach/gpio.h>
36 #include <mach/gpioexpander.h>
39 #include <mach/irda.h>
40 #include <mach/board.h>
41 #include <mach/common.h>
42 #include <mach/keypad.h>
43 #include <mach/menelaus.h>
45 #include <mach/gpmc.h>
48 #define H4_SMC91X_CS 1
50 #define H4_ETHR_GPIO_IRQ 92
52 static unsigned int row_gpios[6] = { 88, 89, 124, 11, 6, 96 };
53 static unsigned int col_gpios[7] = { 90, 91, 100, 36, 12, 97, 98 };
55 static 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 flash_platform_data h4_flash_data = {
121 .map_name = "cfi_probe",
123 .parts = h4_partitions,
124 .nr_parts = ARRAY_SIZE(h4_partitions),
127 static struct resource h4_flash_resource = {
128 .flags = IORESOURCE_MEM,
131 static struct platform_device h4_flash_device = {
135 .platform_data = &h4_flash_data,
138 .resource = &h4_flash_resource,
141 /* Select between the IrDA and aGPS module
143 static int h4_select_irda(struct device *dev, int state)
148 if ((err = read_gpio_expa(&expa, 0x21))) {
149 printk(KERN_ERR "Error reading from I/O expander\n");
153 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
154 if (state & IR_SEL) { /* IrDa */
155 if ((err = write_gpio_expa(expa | 0x01, 0x21))) {
156 printk(KERN_ERR "Error writing to I/O expander\n");
160 if ((err = write_gpio_expa(expa & ~0x01, 0x21))) {
161 printk(KERN_ERR "Error writing to I/O expander\n");
168 static void set_trans_mode(struct work_struct *work)
170 struct omap_irda_config *irda_config =
171 container_of(work, struct omap_irda_config, gpio_expa.work);
172 int mode = irda_config->mode;
176 if ((err = read_gpio_expa(&expa, 0x20)) != 0) {
177 printk(KERN_ERR "Error reading from I/O expander\n");
182 if (!(mode & IR_SIRMODE)) { /* MIR/FIR */
186 if ((err = write_gpio_expa(expa, 0x20)) != 0) {
187 printk(KERN_ERR "Error writing to I/O expander\n");
191 static int h4_transceiver_mode(struct device *dev, int mode)
193 struct omap_irda_config *irda_config = dev->platform_data;
195 irda_config->mode = mode;
196 cancel_delayed_work(&irda_config->gpio_expa);
197 PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode);
198 schedule_delayed_work(&irda_config->gpio_expa, 0);
203 static struct omap_irda_config h4_irda_data = {
204 .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
205 .transceiver_mode = h4_transceiver_mode,
206 .select_irda = h4_select_irda,
207 .rx_channel = OMAP24XX_DMA_UART3_RX,
208 .tx_channel = OMAP24XX_DMA_UART3_TX,
209 .dest_start = OMAP_UART3_BASE,
210 .src_start = OMAP_UART3_BASE,
211 .tx_trigger = OMAP24XX_DMA_UART3_TX,
212 .rx_trigger = OMAP24XX_DMA_UART3_RX,
215 static struct resource h4_irda_resources[] = {
217 .start = INT_24XX_UART3_IRQ,
218 .end = INT_24XX_UART3_IRQ,
219 .flags = IORESOURCE_IRQ,
223 static struct platform_device h4_irda_device = {
227 .platform_data = &h4_irda_data,
230 .resource = h4_irda_resources,
233 static struct omap_kp_platform_data h4_kp_data = {
237 .keymapsize = ARRAY_SIZE(h4_keymap),
239 .row_gpios = row_gpios,
240 .col_gpios = col_gpios,
243 static struct platform_device h4_kp_device = {
244 .name = "omap-keypad",
247 .platform_data = &h4_kp_data,
251 static struct platform_device h4_lcd_device = {
256 static struct platform_device *h4_devices[] __initdata = {
263 /* 2420 Sysboot setup (2430 is different) */
264 static u32 get_sysboot_value(void)
266 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
267 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
268 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
269 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
272 /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
274 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
275 * correctly. The macro needs to look at production_id not just hawkeye.
277 static u32 is_gpmc_muxed(void)
280 mux = get_sysboot_value();
281 if ((mux & 0xF) == 0xd)
282 return 1; /* NAND config (could be either) */
283 if (mux & 0x2) /* if mux'ed */
289 static inline void __init h4_init_debug(void)
292 unsigned long cs_mem_base;
293 unsigned int muxed, rate;
294 struct clk *gpmc_fck;
296 eth_cs = H4_SMC91X_CS;
298 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
299 if (IS_ERR(gpmc_fck)) {
304 clk_enable(gpmc_fck);
305 rate = clk_get_rate(gpmc_fck);
306 clk_disable(gpmc_fck);
314 /* Make sure CS1 timings are correct */
315 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
318 if (rate >= 160000000) {
319 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
320 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
321 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
322 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
323 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
324 } else if (rate >= 130000000) {
325 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
326 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
327 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
328 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
329 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
330 } else {/* rate = 100000000 */
331 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
332 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
333 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
334 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
335 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
338 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
339 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
345 omap_cfg_reg(M15_24XX_GPIO92);
346 if (debug_card_init(cs_mem_base, H4_ETHR_GPIO_IRQ) < 0)
347 gpmc_cs_free(eth_cs);
350 clk_disable(gpmc_fck);
354 static void __init h4_init_flash(void)
358 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
359 printk("Can't request GPMC CS for flash\n");
362 h4_flash_resource.start = base;
363 h4_flash_resource.end = base + SZ_64M - 1;
366 static void __init omap_h4_init_irq(void)
368 omap2_init_common_hw(NULL);
374 static struct omap_uart_config h4_uart_config __initdata = {
375 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
378 static struct omap_lcd_config h4_lcd_config __initdata = {
379 .ctrl_name = "internal",
382 static struct omap_usb_config h4_usb_config __initdata = {
383 #ifdef CONFIG_MACH_OMAP2_H4_USB1
384 /* NOTE: usb1 could also be used with 3 wire signaling */
388 #ifdef CONFIG_MACH_OMAP_H4_OTG
389 /* S1.10 ON -- USB OTG port
390 * usb0 switched to Mini-AB port and isp1301 transceiver;
391 * S2.POS3 = OFF, S2.POS4 = ON ... to allow battery charging
395 #ifdef CONFIG_USB_GADGET_OMAP
396 /* use OTG cable, or standard A-to-MiniB */
397 .hmc_mode = 0x14, /* 0:dev/otg 1:host 2:disable */
398 #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
399 /* use OTG cable, or NONSTANDARD (B-to-MiniB) */
400 .hmc_mode = 0x11, /* 0:host 1:host 2:disable */
404 /* S1.10 OFF -- usb "download port"
405 * usb0 switched to Mini-B port and isp1105 transceiver;
406 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
410 /* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */
411 .hmc_mode = 0x00, /* 0:dev|otg 1:disable 2:disable */
415 static struct omap_board_config_kernel h4_config[] = {
416 { OMAP_TAG_UART, &h4_uart_config },
417 { OMAP_TAG_LCD, &h4_lcd_config },
420 static struct at24_platform_data m24c01 = {
421 .byte_len = SZ_1K / 8,
425 static struct i2c_board_info __initdata h4_i2c_board_info[] = {
427 I2C_BOARD_INFO("isp1301_omap", 0x2d),
428 .irq = OMAP_GPIO_IRQ(125),
430 { /* EEPROM on mainboard */
431 I2C_BOARD_INFO("24c01", 0x52),
432 .platform_data = &m24c01,
434 { /* EEPROM on cpu card */
435 I2C_BOARD_INFO("24c01", 0x57),
436 .platform_data = &m24c01,
440 static void __init omap_h4_init(void)
443 * Make sure the serial ports are muxed on at this point.
444 * You have to mux them off in device drivers later on
447 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
448 omap_cfg_reg(K15_24XX_UART3_TX);
449 omap_cfg_reg(K14_24XX_UART3_RX);
452 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
453 if (omap_has_menelaus()) {
460 i2c_register_board_info(1, h4_i2c_board_info,
461 ARRAY_SIZE(h4_i2c_board_info));
463 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
464 omap_board_config = h4_config;
465 omap_board_config_size = ARRAY_SIZE(h4_config);
466 omap_usb_init(&h4_usb_config);
470 static void __init omap_h4_map_io(void)
472 omap2_set_globals_242x();
473 omap2_map_common_io();
476 MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
477 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
478 .phys_io = 0x48000000,
479 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
480 .boot_params = 0x80000100,
481 .map_io = omap_h4_map_io,
482 .init_irq = omap_h4_init_irq,
483 .init_machine = omap_h4_init,
484 .timer = &omap_timer,