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>
22 #include <linux/err.h>
23 #include <linux/clk.h>
25 #include <asm/arch/hardware.h>
26 #include <asm/mach-types.h>
27 #include <asm/mach/arch.h>
28 #include <asm/mach/map.h>
29 #include <asm/mach/flash.h>
31 #include <asm/arch/control.h>
32 #include <asm/arch/gpio.h>
33 #include <asm/arch/gpioexpander.h>
34 #include <asm/arch/mux.h>
35 #include <asm/arch/usb.h>
36 #include <asm/arch/irda.h>
37 #include <asm/arch/board.h>
38 #include <asm/arch/common.h>
39 #include <asm/arch/keypad.h>
40 #include <asm/arch/menelaus.h>
41 #include <asm/arch/dma.h>
42 #include <asm/arch/gpmc.h>
47 #define H4_SMC91X_CS 1
49 static unsigned int row_gpios
[6] = { 88, 89, 124, 11, 6, 96 };
50 static unsigned int col_gpios
[7] = { 90, 91, 100, 36, 12, 97, 98 };
52 static int h4_keymap
[] = {
86 static struct mtd_partition h4_partitions
[] = {
87 /* bootloader (U-Boot, etc) in first sector */
92 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
94 /* bootloader params in the next sector */
97 .offset
= MTDPART_OFS_APPEND
,
104 .offset
= MTDPART_OFS_APPEND
,
110 .name
= "filesystem",
111 .offset
= MTDPART_OFS_APPEND
,
112 .size
= MTDPART_SIZ_FULL
,
117 static struct flash_platform_data h4_flash_data
= {
118 .map_name
= "cfi_probe",
120 .parts
= h4_partitions
,
121 .nr_parts
= ARRAY_SIZE(h4_partitions
),
124 static struct resource h4_flash_resource
= {
125 .flags
= IORESOURCE_MEM
,
128 static struct platform_device h4_flash_device
= {
132 .platform_data
= &h4_flash_data
,
135 .resource
= &h4_flash_resource
,
138 /* Select between the IrDA and aGPS module
140 static int h4_select_irda(struct device
*dev
, int state
)
145 if ((err
= read_gpio_expa(&expa
, 0x21))) {
146 printk(KERN_ERR
"Error reading from I/O expander\n");
150 /* 'P6' enable/disable IRDA_TX and IRDA_RX */
151 if (state
& IR_SEL
) { /* IrDa */
152 if ((err
= write_gpio_expa(expa
| 0x01, 0x21))) {
153 printk(KERN_ERR
"Error writing to I/O expander\n");
157 if ((err
= write_gpio_expa(expa
& ~0x01, 0x21))) {
158 printk(KERN_ERR
"Error writing to I/O expander\n");
165 static void set_trans_mode(struct work_struct
*work
)
167 struct omap_irda_config
*irda_config
=
168 container_of(work
, struct omap_irda_config
, gpio_expa
.work
);
169 int mode
= irda_config
->mode
;
173 if ((err
= read_gpio_expa(&expa
, 0x20)) != 0) {
174 printk(KERN_ERR
"Error reading from I/O expander\n");
179 if (!(mode
& IR_SIRMODE
)) { /* MIR/FIR */
183 if ((err
= write_gpio_expa(expa
, 0x20)) != 0) {
184 printk(KERN_ERR
"Error writing to I/O expander\n");
188 static int h4_transceiver_mode(struct device
*dev
, int mode
)
190 struct omap_irda_config
*irda_config
= dev
->platform_data
;
192 irda_config
->mode
= mode
;
193 cancel_delayed_work(&irda_config
->gpio_expa
);
194 PREPARE_DELAYED_WORK(&irda_config
->gpio_expa
, set_trans_mode
);
195 schedule_delayed_work(&irda_config
->gpio_expa
, 0);
200 static struct omap_irda_config h4_irda_data
= {
201 .transceiver_cap
= IR_SIRMODE
| IR_MIRMODE
| IR_FIRMODE
,
202 .transceiver_mode
= h4_transceiver_mode
,
203 .select_irda
= h4_select_irda
,
204 .rx_channel
= OMAP24XX_DMA_UART3_RX
,
205 .tx_channel
= OMAP24XX_DMA_UART3_TX
,
206 .dest_start
= OMAP_UART3_BASE
,
207 .src_start
= OMAP_UART3_BASE
,
208 .tx_trigger
= OMAP24XX_DMA_UART3_TX
,
209 .rx_trigger
= OMAP24XX_DMA_UART3_RX
,
212 static struct resource h4_irda_resources
[] = {
214 .start
= INT_24XX_UART3_IRQ
,
215 .end
= INT_24XX_UART3_IRQ
,
216 .flags
= IORESOURCE_IRQ
,
220 static struct platform_device h4_irda_device
= {
224 .platform_data
= &h4_irda_data
,
227 .resource
= h4_irda_resources
,
230 static struct omap_kp_platform_data h4_kp_data
= {
234 .keymapsize
= ARRAY_SIZE(h4_keymap
),
236 .row_gpios
= row_gpios
,
237 .col_gpios
= col_gpios
,
240 static struct platform_device h4_kp_device
= {
241 .name
= "omap-keypad",
244 .platform_data
= &h4_kp_data
,
248 static struct platform_device h4_lcd_device
= {
253 static struct platform_device
*h4_devices
[] __initdata
= {
260 /* 2420 Sysboot setup (2430 is different) */
261 static u32
get_sysboot_value(void)
263 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS
) &
264 (OMAP2_SYSBOOT_5_MASK
| OMAP2_SYSBOOT_4_MASK
|
265 OMAP2_SYSBOOT_3_MASK
| OMAP2_SYSBOOT_2_MASK
|
266 OMAP2_SYSBOOT_1_MASK
| OMAP2_SYSBOOT_0_MASK
));
269 /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
271 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
272 * correctly. The macro needs to look at production_id not just hawkeye.
274 static u32
is_gpmc_muxed(void)
277 mux
= get_sysboot_value();
278 if ((mux
& 0xF) == 0xd)
279 return 1; /* NAND config (could be either) */
280 if (mux
& 0x2) /* if mux'ed */
286 static inline void __init
h4_init_debug(void)
289 unsigned long cs_mem_base
;
290 unsigned int muxed
, rate
;
291 struct clk
*gpmc_fck
;
293 eth_cs
= H4_SMC91X_CS
;
295 gpmc_fck
= clk_get(NULL
, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
296 if (IS_ERR(gpmc_fck
)) {
301 clk_enable(gpmc_fck
);
302 rate
= clk_get_rate(gpmc_fck
);
303 clk_disable(gpmc_fck
);
311 /* Make sure CS1 timings are correct */
312 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG1
,
315 if (rate
>= 160000000) {
316 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG2
, 0x001f1f01);
317 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG3
, 0x00080803);
318 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG4
, 0x1c0b1c0a);
319 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG5
, 0x041f1F1F);
320 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG6
, 0x000004C4);
321 } else if (rate
>= 130000000) {
322 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG2
, 0x001f1f00);
323 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG3
, 0x00080802);
324 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG4
, 0x1C091C09);
325 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG5
, 0x041f1F1F);
326 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG6
, 0x000004C4);
327 } else {/* rate = 100000000 */
328 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG2
, 0x001f1f00);
329 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG3
, 0x00080802);
330 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG4
, 0x1C091C09);
331 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG5
, 0x031A1F1F);
332 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG6
, 0x000003C2);
335 if (gpmc_cs_request(eth_cs
, SZ_16M
, &cs_mem_base
) < 0) {
336 printk(KERN_ERR
"Failed to request GPMC mem for smc91x\n");
342 omap_cfg_reg(M15_24XX_GPIO92
);
343 if (debug_card_init(cs_mem_base
, OMAP24XX_ETHR_GPIO_IRQ
) < 0)
344 gpmc_cs_free(eth_cs
);
347 clk_disable(gpmc_fck
);
351 static void __init
h4_init_flash(void)
355 if (gpmc_cs_request(H4_FLASH_CS
, SZ_64M
, &base
) < 0) {
356 printk("Can't request GPMC CS for flash\n");
359 h4_flash_resource
.start
= base
;
360 h4_flash_resource
.end
= base
+ SZ_64M
- 1;
363 static void __init
omap_h4_init_irq(void)
365 omap2_init_common_hw();
371 static struct omap_uart_config h4_uart_config __initdata
= {
372 .enabled_uarts
= ((1 << 0) | (1 << 1) | (1 << 2)),
375 static struct omap_mmc_config h4_mmc_config __initdata
= {
385 static struct omap_lcd_config h4_lcd_config __initdata
= {
386 .ctrl_name
= "internal",
389 static struct omap_board_config_kernel h4_config
[] = {
390 { OMAP_TAG_UART
, &h4_uart_config
},
391 { OMAP_TAG_MMC
, &h4_mmc_config
},
392 { OMAP_TAG_LCD
, &h4_lcd_config
},
395 static void __init
omap_h4_init(void)
398 * Make sure the serial ports are muxed on at this point.
399 * You have to mux them off in device drivers later on
402 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
403 omap_cfg_reg(K15_24XX_UART3_TX
);
404 omap_cfg_reg(K14_24XX_UART3_RX
);
407 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
408 if (omap_has_menelaus()) {
415 platform_add_devices(h4_devices
, ARRAY_SIZE(h4_devices
));
416 omap_board_config
= h4_config
;
417 omap_board_config_size
= ARRAY_SIZE(h4_config
);
421 static void __init
omap_h4_map_io(void)
423 omap2_set_globals_242x();
424 omap2_map_common_io();
427 MACHINE_START(OMAP_H4
, "OMAP2420 H4 board")
428 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
429 .phys_io
= 0x48000000,
430 .io_pg_offst
= ((0xd8000000) >> 18) & 0xfffc,
431 .boot_params
= 0x80000100,
432 .map_io
= omap_h4_map_io
,
433 .init_irq
= omap_h4_init_irq
,
434 .init_machine
= omap_h4_init
,
435 .timer
= &omap_timer
,