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/input.h>
23 #include <asm/hardware.h>
24 #include <asm/mach-types.h>
25 #include <asm/mach/arch.h>
26 #include <asm/mach/map.h>
27 #include <asm/mach/flash.h>
29 #include <asm/arch/gpio.h>
30 #include <asm/arch/gpioexpander.h>
31 #include <asm/arch/mux.h>
32 #include <asm/arch/usb.h>
33 #include <asm/arch/irda.h>
34 #include <asm/arch/board.h>
35 #include <asm/arch/common.h>
36 #include <asm/arch/keypad.h>
37 #include <asm/arch/menelaus.h>
38 #include <asm/arch/dma.h>
39 #include "prcm-regs.h"
43 static unsigned int row_gpios
[6] = { 88, 89, 124, 11, 6, 96 };
44 static unsigned int col_gpios
[7] = { 90, 91, 100, 36, 12, 97, 98 };
46 static int h4_keymap
[] = {
80 static struct mtd_partition h4_partitions
[] = {
81 /* bootloader (U-Boot, etc) in first sector */
86 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
88 /* bootloader params in the next sector */
91 .offset
= MTDPART_OFS_APPEND
,
98 .offset
= MTDPART_OFS_APPEND
,
104 .name
= "filesystem",
105 .offset
= MTDPART_OFS_APPEND
,
106 .size
= MTDPART_SIZ_FULL
,
111 static struct flash_platform_data h4_flash_data
= {
112 .map_name
= "cfi_probe",
114 .parts
= h4_partitions
,
115 .nr_parts
= ARRAY_SIZE(h4_partitions
),
118 static struct resource h4_flash_resource
= {
119 .start
= H4_CS0_BASE
,
120 .end
= H4_CS0_BASE
+ SZ_64M
- 1,
121 .flags
= IORESOURCE_MEM
,
124 static struct platform_device h4_flash_device
= {
128 .platform_data
= &h4_flash_data
,
131 .resource
= &h4_flash_resource
,
134 static struct resource h4_smc91x_resources
[] = {
136 .start
= OMAP24XX_ETHR_START
, /* Physical */
137 .end
= OMAP24XX_ETHR_START
+ 0xf,
138 .flags
= IORESOURCE_MEM
,
141 .start
= OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ
),
142 .end
= OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ
),
143 .flags
= IORESOURCE_IRQ
,
147 static struct platform_device h4_smc91x_device
= {
150 .num_resources
= ARRAY_SIZE(h4_smc91x_resources
),
151 .resource
= h4_smc91x_resources
,
154 /* Select between the IrDA and aGPS module
156 static int h4_select_irda(struct device
*dev
, int state
)
161 if ((err
= read_gpio_expa(&expa
, 0x21))) {
162 printk(KERN_ERR
"Error reading from I/O expander\n");
166 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
167 if (state
& IR_SEL
) { /* IrDa */
168 if ((err
= write_gpio_expa(expa
| 0x01, 0x21))) {
169 printk(KERN_ERR
"Error writing to I/O expander\n");
173 if ((err
= write_gpio_expa(expa
& ~0x01, 0x21))) {
174 printk(KERN_ERR
"Error writing to I/O expander\n");
181 static void set_trans_mode(struct work_struct
*work
)
183 struct omap_irda_config
*irda_config
=
184 container_of(work
, struct omap_irda_config
, gpio_expa
.work
);
185 int mode
= irda_config
->mode
;
189 if ((err
= read_gpio_expa(&expa
, 0x20)) != 0) {
190 printk(KERN_ERR
"Error reading from I/O expander\n");
195 if (!(mode
& IR_SIRMODE
)) { /* MIR/FIR */
199 if ((err
= write_gpio_expa(expa
, 0x20)) != 0) {
200 printk(KERN_ERR
"Error writing to I/O expander\n");
204 static int h4_transceiver_mode(struct device
*dev
, int mode
)
206 struct omap_irda_config
*irda_config
= dev
->platform_data
;
208 irda_config
->mode
= mode
;
209 cancel_delayed_work(&irda_config
->gpio_expa
);
210 PREPARE_DELAYED_WORK(&irda_config
->gpio_expa
, set_trans_mode
);
211 schedule_delayed_work(&irda_config
->gpio_expa
, 0);
216 static struct omap_irda_config h4_irda_data
= {
217 .transceiver_cap
= IR_SIRMODE
| IR_MIRMODE
| IR_FIRMODE
,
218 .transceiver_mode
= h4_transceiver_mode
,
219 .select_irda
= h4_select_irda
,
220 .rx_channel
= OMAP24XX_DMA_UART3_RX
,
221 .tx_channel
= OMAP24XX_DMA_UART3_TX
,
222 .dest_start
= OMAP_UART3_BASE
,
223 .src_start
= OMAP_UART3_BASE
,
224 .tx_trigger
= OMAP24XX_DMA_UART3_TX
,
225 .rx_trigger
= OMAP24XX_DMA_UART3_RX
,
228 static struct resource h4_irda_resources
[] = {
230 .start
= INT_24XX_UART3_IRQ
,
231 .end
= INT_24XX_UART3_IRQ
,
232 .flags
= IORESOURCE_IRQ
,
236 static struct platform_device h4_irda_device
= {
240 .platform_data
= &h4_irda_data
,
243 .resource
= h4_irda_resources
,
246 static struct omap_kp_platform_data h4_kp_data
= {
250 .keymapsize
= ARRAY_SIZE(h4_keymap
),
252 .row_gpios
= row_gpios
,
253 .col_gpios
= col_gpios
,
256 static struct platform_device h4_kp_device
= {
257 .name
= "omap-keypad",
260 .platform_data
= &h4_kp_data
,
264 static struct platform_device h4_lcd_device
= {
269 static struct resource h4_led_resources
[] = {
271 .flags
= IORESOURCE_MEM
,
275 static struct platform_device h4_led_device
= {
276 .name
= "omap_dbg_led",
278 .num_resources
= ARRAY_SIZE(h4_led_resources
),
279 .resource
= h4_led_resources
,
282 static struct platform_device
*h4_devices
[] __initdata
= {
291 static inline void __init
h4_init_smc91x(void)
293 /* Make sure CS1 timings are correct */
294 GPMC_CONFIG1_1
= 0x00011200;
295 GPMC_CONFIG2_1
= 0x001f1f01;
296 GPMC_CONFIG3_1
= 0x00080803;
297 GPMC_CONFIG4_1
= 0x1c091c09;
298 GPMC_CONFIG5_1
= 0x041f1f1f;
299 GPMC_CONFIG6_1
= 0x000004c4;
300 GPMC_CONFIG7_1
= 0x00000f40 | (0x08000000 >> 24);
303 omap_cfg_reg(M15_24XX_GPIO92
);
304 if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ
) < 0) {
305 printk(KERN_ERR
"Failed to request GPIO%d for smc91x IRQ\n",
306 OMAP24XX_ETHR_GPIO_IRQ
);
309 omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ
, 1);
312 static void __init
omap_h4_init_irq(void)
314 omap2_init_common_hw();
320 static struct omap_uart_config h4_uart_config __initdata
= {
321 .enabled_uarts
= ((1 << 0) | (1 << 1) | (1 << 2)),
324 static struct omap_mmc_config h4_mmc_config __initdata
= {
334 static struct omap_lcd_config h4_lcd_config __initdata
= {
335 .ctrl_name
= "internal",
338 static struct omap_board_config_kernel h4_config
[] = {
339 { OMAP_TAG_UART
, &h4_uart_config
},
340 { OMAP_TAG_MMC
, &h4_mmc_config
},
341 { OMAP_TAG_LCD
, &h4_lcd_config
},
344 static void __init
omap_h4_init(void)
347 * Make sure the serial ports are muxed on at this point.
348 * You have to mux them off in device drivers later on
351 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
352 omap_cfg_reg(K15_24XX_UART3_TX
);
353 omap_cfg_reg(K14_24XX_UART3_RX
);
356 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
357 if (omap_has_menelaus()) {
364 platform_add_devices(h4_devices
, ARRAY_SIZE(h4_devices
));
365 omap_board_config
= h4_config
;
366 omap_board_config_size
= ARRAY_SIZE(h4_config
);
370 static void __init
omap_h4_map_io(void)
372 omap2_map_common_io();
375 MACHINE_START(OMAP_H4
, "OMAP2420 H4 board")
376 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
377 .phys_io
= 0x48000000,
378 .io_pg_offst
= ((0xd8000000) >> 18) & 0xfffc,
379 .boot_params
= 0x80000100,
380 .map_io
= omap_h4_map_io
,
381 .init_irq
= omap_h4_init_irq
,
382 .init_machine
= omap_h4_init
,
383 .timer
= &omap_timer
,