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 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 int h4_keymap[] = {
87 static struct mtd_partition h4_partitions[] = {
88 /* bootloader (U-Boot, etc) in first sector */
93 .mask_flags = MTD_WRITEABLE, /* force read-only */
95 /* bootloader params in the next sector */
98 .offset = MTDPART_OFS_APPEND,
105 .offset = MTDPART_OFS_APPEND,
111 .name = "filesystem",
112 .offset = MTDPART_OFS_APPEND,
113 .size = MTDPART_SIZ_FULL,
118 static struct flash_platform_data h4_flash_data = {
119 .map_name = "cfi_probe",
121 .parts = h4_partitions,
122 .nr_parts = ARRAY_SIZE(h4_partitions),
125 static struct resource h4_flash_resource = {
126 .flags = IORESOURCE_MEM,
129 static struct platform_device h4_flash_device = {
133 .platform_data = &h4_flash_data,
136 .resource = &h4_flash_resource,
139 /* Select between the IrDA and aGPS module
141 static int h4_select_irda(struct device *dev, int state)
146 if ((err = read_gpio_expa(&expa, 0x21))) {
147 printk(KERN_ERR "Error reading from I/O expander\n");
151 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
152 if (state & IR_SEL) { /* IrDa */
153 if ((err = write_gpio_expa(expa | 0x01, 0x21))) {
154 printk(KERN_ERR "Error writing to I/O expander\n");
158 if ((err = write_gpio_expa(expa & ~0x01, 0x21))) {
159 printk(KERN_ERR "Error writing to I/O expander\n");
166 static void set_trans_mode(struct work_struct *work)
168 struct omap_irda_config *irda_config =
169 container_of(work, struct omap_irda_config, gpio_expa.work);
170 int mode = irda_config->mode;
174 if ((err = read_gpio_expa(&expa, 0x20)) != 0) {
175 printk(KERN_ERR "Error reading from I/O expander\n");
180 if (!(mode & IR_SIRMODE)) { /* MIR/FIR */
184 if ((err = write_gpio_expa(expa, 0x20)) != 0) {
185 printk(KERN_ERR "Error writing to I/O expander\n");
189 static int h4_transceiver_mode(struct device *dev, int mode)
191 struct omap_irda_config *irda_config = dev->platform_data;
193 irda_config->mode = mode;
194 cancel_delayed_work(&irda_config->gpio_expa);
195 PREPARE_DELAYED_WORK(&irda_config->gpio_expa, set_trans_mode);
196 schedule_delayed_work(&irda_config->gpio_expa, 0);
201 static struct omap_irda_config h4_irda_data = {
202 .transceiver_cap = IR_SIRMODE | IR_MIRMODE | IR_FIRMODE,
203 .transceiver_mode = h4_transceiver_mode,
204 .select_irda = h4_select_irda,
205 .rx_channel = OMAP24XX_DMA_UART3_RX,
206 .tx_channel = OMAP24XX_DMA_UART3_TX,
207 .dest_start = OMAP_UART3_BASE,
208 .src_start = OMAP_UART3_BASE,
209 .tx_trigger = OMAP24XX_DMA_UART3_TX,
210 .rx_trigger = OMAP24XX_DMA_UART3_RX,
213 static struct resource h4_irda_resources[] = {
215 .start = INT_24XX_UART3_IRQ,
216 .end = INT_24XX_UART3_IRQ,
217 .flags = IORESOURCE_IRQ,
221 static struct platform_device h4_irda_device = {
225 .platform_data = &h4_irda_data,
228 .resource = h4_irda_resources,
231 static struct omap_kp_platform_data h4_kp_data = {
235 .keymapsize = ARRAY_SIZE(h4_keymap),
237 .row_gpios = row_gpios,
238 .col_gpios = col_gpios,
241 static struct platform_device h4_kp_device = {
242 .name = "omap-keypad",
245 .platform_data = &h4_kp_data,
249 static struct platform_device h4_lcd_device = {
254 static struct platform_device *h4_devices[] __initdata = {
261 /* 2420 Sysboot setup (2430 is different) */
262 static u32 get_sysboot_value(void)
264 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS) &
265 (OMAP2_SYSBOOT_5_MASK | OMAP2_SYSBOOT_4_MASK |
266 OMAP2_SYSBOOT_3_MASK | OMAP2_SYSBOOT_2_MASK |
267 OMAP2_SYSBOOT_1_MASK | OMAP2_SYSBOOT_0_MASK));
270 /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
272 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
273 * correctly. The macro needs to look at production_id not just hawkeye.
275 static u32 is_gpmc_muxed(void)
278 mux = get_sysboot_value();
279 if ((mux & 0xF) == 0xd)
280 return 1; /* NAND config (could be either) */
281 if (mux & 0x2) /* if mux'ed */
287 static inline void __init h4_init_debug(void)
290 unsigned long cs_mem_base;
291 unsigned int muxed, rate;
292 struct clk *gpmc_fck;
294 eth_cs = H4_SMC91X_CS;
296 gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
297 if (IS_ERR(gpmc_fck)) {
302 clk_enable(gpmc_fck);
303 rate = clk_get_rate(gpmc_fck);
304 clk_disable(gpmc_fck);
312 /* Make sure CS1 timings are correct */
313 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1,
316 if (rate >= 160000000) {
317 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
318 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
319 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
320 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
321 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
322 } else if (rate >= 130000000) {
323 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
324 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
325 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
326 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
327 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
328 } else {/* rate = 100000000 */
329 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
330 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
331 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
332 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
333 gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
336 if (gpmc_cs_request(eth_cs, SZ_16M, &cs_mem_base) < 0) {
337 printk(KERN_ERR "Failed to request GPMC mem for smc91x\n");
343 omap_cfg_reg(M15_24XX_GPIO92);
344 if (debug_card_init(cs_mem_base, OMAP24XX_ETHR_GPIO_IRQ) < 0)
345 gpmc_cs_free(eth_cs);
348 clk_disable(gpmc_fck);
352 static void __init h4_init_flash(void)
356 if (gpmc_cs_request(H4_FLASH_CS, SZ_64M, &base) < 0) {
357 printk("Can't request GPMC CS for flash\n");
360 h4_flash_resource.start = base;
361 h4_flash_resource.end = base + SZ_64M - 1;
364 static void __init omap_h4_init_irq(void)
366 omap2_init_common_hw();
372 static struct omap_uart_config h4_uart_config __initdata = {
373 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
376 static struct omap_lcd_config h4_lcd_config __initdata = {
377 .ctrl_name = "internal",
380 static struct omap_board_config_kernel h4_config[] = {
381 { OMAP_TAG_UART, &h4_uart_config },
382 { OMAP_TAG_LCD, &h4_lcd_config },
385 static struct at24_platform_data m24c01 = {
386 .byte_len = SZ_1K / 8,
390 static struct i2c_board_info __initdata h4_i2c_board_info[] = {
392 I2C_BOARD_INFO("isp1301_omap", 0x2d),
393 .irq = OMAP_GPIO_IRQ(125),
395 { /* EEPROM on mainboard */
396 I2C_BOARD_INFO("24c01", 0x52),
397 .platform_data = &m24c01,
399 { /* EEPROM on cpu card */
400 I2C_BOARD_INFO("24c01", 0x57),
401 .platform_data = &m24c01,
405 static void __init omap_h4_init(void)
408 * Make sure the serial ports are muxed on at this point.
409 * You have to mux them off in device drivers later on
412 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
413 omap_cfg_reg(K15_24XX_UART3_TX);
414 omap_cfg_reg(K14_24XX_UART3_RX);
417 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
418 if (omap_has_menelaus()) {
425 i2c_register_board_info(1, h4_i2c_board_info,
426 ARRAY_SIZE(h4_i2c_board_info));
428 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
429 omap_board_config = h4_config;
430 omap_board_config_size = ARRAY_SIZE(h4_config);
434 static void __init omap_h4_map_io(void)
436 omap2_set_globals_242x();
437 omap2_map_common_io();
440 MACHINE_START(OMAP_H4, "OMAP2420 H4 board")
441 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
442 .phys_io = 0x48000000,
443 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
444 .boot_params = 0x80000100,
445 .map_io = omap_h4_map_io,
446 .init_irq = omap_h4_init_irq,
447 .init_machine = omap_h4_init,
448 .timer = &omap_timer,