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"
42 #include <asm/delay.h>
44 static unsigned int row_gpios
[6] = { 88, 89, 124, 11, 6, 96 };
45 static unsigned int col_gpios
[7] = { 90, 91, 100, 36, 12, 97, 98 };
47 static int h4_keymap
[] = {
81 static struct mtd_partition h4_partitions
[] = {
82 /* bootloader (U-Boot, etc) in first sector */
87 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
89 /* bootloader params in the next sector */
92 .offset
= MTDPART_OFS_APPEND
,
99 .offset
= MTDPART_OFS_APPEND
,
105 .name
= "filesystem",
106 .offset
= MTDPART_OFS_APPEND
,
107 .size
= MTDPART_SIZ_FULL
,
112 static struct flash_platform_data h4_flash_data
= {
113 .map_name
= "cfi_probe",
115 .parts
= h4_partitions
,
116 .nr_parts
= ARRAY_SIZE(h4_partitions
),
119 static struct resource h4_flash_resource
= {
120 .start
= H4_CS0_BASE
,
121 .end
= H4_CS0_BASE
+ SZ_64M
- 1,
122 .flags
= IORESOURCE_MEM
,
125 static struct platform_device h4_flash_device
= {
129 .platform_data
= &h4_flash_data
,
132 .resource
= &h4_flash_resource
,
135 static struct resource h4_smc91x_resources
[] = {
137 .start
= OMAP24XX_ETHR_START
, /* Physical */
138 .end
= OMAP24XX_ETHR_START
+ 0xf,
139 .flags
= IORESOURCE_MEM
,
142 .start
= OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ
),
143 .end
= OMAP_GPIO_IRQ(OMAP24XX_ETHR_GPIO_IRQ
),
144 .flags
= IORESOURCE_IRQ
,
148 static struct platform_device h4_smc91x_device
= {
151 .num_resources
= ARRAY_SIZE(h4_smc91x_resources
),
152 .resource
= h4_smc91x_resources
,
155 /* Select between the IrDA and aGPS module
157 static int h4_select_irda(struct device
*dev
, int state
)
162 if ((err
= read_gpio_expa(&expa
, 0x21))) {
163 printk(KERN_ERR
"Error reading from I/O expander\n");
167 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
168 if (state
& IR_SEL
) { /* IrDa */
169 if ((err
= write_gpio_expa(expa
| 0x01, 0x21))) {
170 printk(KERN_ERR
"Error writing to I/O expander\n");
174 if ((err
= write_gpio_expa(expa
& ~0x01, 0x21))) {
175 printk(KERN_ERR
"Error writing to I/O expander\n");
182 static void set_trans_mode(void *data
)
188 if ((err
= read_gpio_expa(&expa
, 0x20)) != 0) {
189 printk(KERN_ERR
"Error reading from I/O expander\n");
194 if (!(*mode
& IR_SIRMODE
)) { /* MIR/FIR */
198 if ((err
= write_gpio_expa(expa
, 0x20)) != 0) {
199 printk(KERN_ERR
"Error writing to I/O expander\n");
203 static int h4_transceiver_mode(struct device
*dev
, int mode
)
205 struct omap_irda_config
*irda_config
= dev
->platform_data
;
207 cancel_delayed_work(&irda_config
->gpio_expa
);
208 PREPARE_WORK(&irda_config
->gpio_expa
, set_trans_mode
, &mode
);
209 #error this is not permitted - mode is an argument variable
210 schedule_delayed_work(&irda_config
->gpio_expa
, 0);
215 static struct omap_irda_config h4_irda_data
= {
216 .transceiver_cap
= IR_SIRMODE
| IR_MIRMODE
| IR_FIRMODE
,
217 .transceiver_mode
= h4_transceiver_mode
,
218 .select_irda
= h4_select_irda
,
219 .rx_channel
= OMAP24XX_DMA_UART3_RX
,
220 .tx_channel
= OMAP24XX_DMA_UART3_TX
,
221 .dest_start
= OMAP_UART3_BASE
,
222 .src_start
= OMAP_UART3_BASE
,
223 .tx_trigger
= OMAP24XX_DMA_UART3_TX
,
224 .rx_trigger
= OMAP24XX_DMA_UART3_RX
,
227 static struct resource h4_irda_resources
[] = {
229 .start
= INT_24XX_UART3_IRQ
,
230 .end
= INT_24XX_UART3_IRQ
,
231 .flags
= IORESOURCE_IRQ
,
235 static struct platform_device h4_irda_device
= {
239 .platform_data
= &h4_irda_data
,
242 .resource
= h4_irda_resources
,
245 static struct omap_kp_platform_data h4_kp_data
= {
249 .keymapsize
= ARRAY_SIZE(h4_keymap
),
251 .row_gpios
= row_gpios
,
252 .col_gpios
= col_gpios
,
255 static struct platform_device h4_kp_device
= {
256 .name
= "omap-keypad",
259 .platform_data
= &h4_kp_data
,
263 static struct platform_device h4_lcd_device
= {
268 static struct platform_device
*h4_devices
[] __initdata
= {
276 static inline void __init
h4_init_smc91x(void)
278 /* Make sure CS1 timings are correct */
279 GPMC_CONFIG1_1
= 0x00011200;
280 GPMC_CONFIG2_1
= 0x001f1f01;
281 GPMC_CONFIG3_1
= 0x00080803;
282 GPMC_CONFIG4_1
= 0x1c091c09;
283 GPMC_CONFIG5_1
= 0x041f1f1f;
284 GPMC_CONFIG6_1
= 0x000004c4;
285 GPMC_CONFIG7_1
= 0x00000f40 | (0x08000000 >> 24);
288 omap_cfg_reg(M15_24XX_GPIO92
);
289 if (omap_request_gpio(OMAP24XX_ETHR_GPIO_IRQ
) < 0) {
290 printk(KERN_ERR
"Failed to request GPIO%d for smc91x IRQ\n",
291 OMAP24XX_ETHR_GPIO_IRQ
);
294 omap_set_gpio_direction(OMAP24XX_ETHR_GPIO_IRQ
, 1);
297 static void __init
omap_h4_init_irq(void)
299 omap2_init_common_hw();
305 static struct omap_uart_config h4_uart_config __initdata
= {
306 .enabled_uarts
= ((1 << 0) | (1 << 1) | (1 << 2)),
309 static struct omap_mmc_config h4_mmc_config __initdata
= {
319 static struct omap_lcd_config h4_lcd_config __initdata
= {
320 .ctrl_name
= "internal",
323 static struct omap_board_config_kernel h4_config
[] = {
324 { OMAP_TAG_UART
, &h4_uart_config
},
325 { OMAP_TAG_MMC
, &h4_mmc_config
},
326 { OMAP_TAG_LCD
, &h4_lcd_config
},
329 static void __init
omap_h4_init(void)
332 * Make sure the serial ports are muxed on at this point.
333 * You have to mux them off in device drivers later on
336 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
337 omap_cfg_reg(K15_24XX_UART3_TX
);
338 omap_cfg_reg(K14_24XX_UART3_RX
);
341 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
342 if (omap_has_menelaus()) {
349 platform_add_devices(h4_devices
, ARRAY_SIZE(h4_devices
));
350 omap_board_config
= h4_config
;
351 omap_board_config_size
= ARRAY_SIZE(h4_config
);
355 static void __init
omap_h4_map_io(void)
357 omap2_map_common_io();
360 MACHINE_START(OMAP_H4
, "OMAP2420 H4 board")
361 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
362 .phys_io
= 0x48000000,
363 .io_pg_offst
= ((0xd8000000) >> 18) & 0xfffc,
364 .boot_params
= 0x80000100,
365 .map_io
= omap_h4_map_io
,
366 .init_irq
= omap_h4_init_irq
,
367 .init_machine
= omap_h4_init
,
368 .timer
= &omap_timer
,