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 <plat/control.h>
35 #include <mach/gpio.h>
38 #include <plat/board.h>
39 #include <plat/common.h>
40 #include <plat/keypad.h>
41 #include <plat/menelaus.h>
43 #include <plat/gpmc.h>
46 #define H4_SMC91X_CS 1
48 #define H4_ETHR_GPIO_IRQ 92
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 static struct omap_kp_platform_data h4_kp_data
= {
143 .keymapsize
= ARRAY_SIZE(h4_keymap
),
145 .row_gpios
= row_gpios
,
146 .col_gpios
= col_gpios
,
149 static struct platform_device h4_kp_device
= {
150 .name
= "omap-keypad",
153 .platform_data
= &h4_kp_data
,
157 static struct platform_device h4_lcd_device
= {
162 static struct platform_device
*h4_devices
[] __initdata
= {
168 /* 2420 Sysboot setup (2430 is different) */
169 static u32
get_sysboot_value(void)
171 return (omap_ctrl_readl(OMAP24XX_CONTROL_STATUS
) &
172 (OMAP2_SYSBOOT_5_MASK
| OMAP2_SYSBOOT_4_MASK
|
173 OMAP2_SYSBOOT_3_MASK
| OMAP2_SYSBOOT_2_MASK
|
174 OMAP2_SYSBOOT_1_MASK
| OMAP2_SYSBOOT_0_MASK
));
177 /* H4-2420's always used muxed mode, H4-2422's always use non-muxed
179 * Note: OMAP-GIT doesn't correctly do is_cpu_omap2422 and is_cpu_omap2423
180 * correctly. The macro needs to look at production_id not just hawkeye.
182 static u32
is_gpmc_muxed(void)
185 mux
= get_sysboot_value();
186 if ((mux
& 0xF) == 0xd)
187 return 1; /* NAND config (could be either) */
188 if (mux
& 0x2) /* if mux'ed */
194 static inline void __init
h4_init_debug(void)
197 unsigned long cs_mem_base
;
198 unsigned int muxed
, rate
;
199 struct clk
*gpmc_fck
;
201 eth_cs
= H4_SMC91X_CS
;
203 gpmc_fck
= clk_get(NULL
, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
204 if (IS_ERR(gpmc_fck
)) {
209 clk_enable(gpmc_fck
);
210 rate
= clk_get_rate(gpmc_fck
);
211 clk_disable(gpmc_fck
);
219 /* Make sure CS1 timings are correct */
220 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG1
,
223 if (rate
>= 160000000) {
224 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG2
, 0x001f1f01);
225 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG3
, 0x00080803);
226 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG4
, 0x1c0b1c0a);
227 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG5
, 0x041f1F1F);
228 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG6
, 0x000004C4);
229 } else if (rate
>= 130000000) {
230 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG2
, 0x001f1f00);
231 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG3
, 0x00080802);
232 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG4
, 0x1C091C09);
233 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG5
, 0x041f1F1F);
234 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG6
, 0x000004C4);
235 } else {/* rate = 100000000 */
236 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG2
, 0x001f1f00);
237 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG3
, 0x00080802);
238 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG4
, 0x1C091C09);
239 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG5
, 0x031A1F1F);
240 gpmc_cs_write_reg(eth_cs
, GPMC_CS_CONFIG6
, 0x000003C2);
243 if (gpmc_cs_request(eth_cs
, SZ_16M
, &cs_mem_base
) < 0) {
244 printk(KERN_ERR
"Failed to request GPMC mem for smc91x\n");
250 omap_cfg_reg(M15_24XX_GPIO92
);
251 if (debug_card_init(cs_mem_base
, H4_ETHR_GPIO_IRQ
) < 0)
252 gpmc_cs_free(eth_cs
);
255 clk_disable(gpmc_fck
);
259 static void __init
h4_init_flash(void)
263 if (gpmc_cs_request(H4_FLASH_CS
, SZ_64M
, &base
) < 0) {
264 printk("Can't request GPMC CS for flash\n");
267 h4_flash_resource
.start
= base
;
268 h4_flash_resource
.end
= base
+ SZ_64M
- 1;
271 static struct omap_lcd_config h4_lcd_config __initdata
= {
272 .ctrl_name
= "internal",
275 static struct omap_usb_config h4_usb_config __initdata
= {
276 #ifdef CONFIG_MACH_OMAP2_H4_USB1
277 /* NOTE: usb1 could also be used with 3 wire signaling */
281 #ifdef CONFIG_MACH_OMAP_H4_OTG
282 /* S1.10 ON -- USB OTG port
283 * usb0 switched to Mini-AB port and isp1301 transceiver;
284 * S2.POS3 = OFF, S2.POS4 = ON ... to allow battery charging
288 #ifdef CONFIG_USB_GADGET_OMAP
289 /* use OTG cable, or standard A-to-MiniB */
290 .hmc_mode
= 0x14, /* 0:dev/otg 1:host 2:disable */
291 #elif defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
292 /* use OTG cable, or NONSTANDARD (B-to-MiniB) */
293 .hmc_mode
= 0x11, /* 0:host 1:host 2:disable */
297 /* S1.10 OFF -- usb "download port"
298 * usb0 switched to Mini-B port and isp1105 transceiver;
299 * S2.POS3 = ON, S2.POS4 = OFF ... to enable battery charging
303 /* .hmc_mode = 0x14,*/ /* 0:dev 1:host 2:disable */
304 .hmc_mode
= 0x00, /* 0:dev|otg 1:disable 2:disable */
308 static struct omap_board_config_kernel h4_config
[] = {
309 { OMAP_TAG_LCD
, &h4_lcd_config
},
312 static void __init
omap_h4_init_irq(void)
314 omap_board_config
= h4_config
;
315 omap_board_config_size
= ARRAY_SIZE(h4_config
);
316 omap2_init_common_hw(NULL
, NULL
);
322 static struct at24_platform_data m24c01
= {
323 .byte_len
= SZ_1K
/ 8,
327 static struct i2c_board_info __initdata h4_i2c_board_info
[] = {
329 I2C_BOARD_INFO("isp1301_omap", 0x2d),
330 .irq
= OMAP_GPIO_IRQ(125),
332 { /* EEPROM on mainboard */
333 I2C_BOARD_INFO("24c01", 0x52),
334 .platform_data
= &m24c01
,
336 { /* EEPROM on cpu card */
337 I2C_BOARD_INFO("24c01", 0x57),
338 .platform_data
= &m24c01
,
342 static void __init
omap_h4_init(void)
345 * Make sure the serial ports are muxed on at this point.
346 * You have to mux them off in device drivers later on
349 #if defined(CONFIG_OMAP_IR) || defined(CONFIG_OMAP_IR_MODULE)
350 omap_cfg_reg(K15_24XX_UART3_TX
);
351 omap_cfg_reg(K14_24XX_UART3_RX
);
354 #if defined(CONFIG_KEYBOARD_OMAP) || defined(CONFIG_KEYBOARD_OMAP_MODULE)
355 if (omap_has_menelaus()) {
362 i2c_register_board_info(1, h4_i2c_board_info
,
363 ARRAY_SIZE(h4_i2c_board_info
));
365 platform_add_devices(h4_devices
, ARRAY_SIZE(h4_devices
));
366 omap_usb_init(&h4_usb_config
);
370 static void __init
omap_h4_map_io(void)
372 omap2_set_globals_242x();
373 omap2_map_common_io();
376 MACHINE_START(OMAP_H4
, "OMAP2420 H4 board")
377 /* Maintainer: Paul Mundt <paul.mundt@nokia.com> */
378 .phys_io
= 0x48000000,
379 .io_pg_offst
= ((0xfa000000) >> 18) & 0xfffc,
380 .boot_params
= 0x80000100,
381 .map_io
= omap_h4_map_io
,
382 .init_irq
= omap_h4_init_irq
,
383 .init_machine
= omap_h4_init
,
384 .timer
= &omap_timer
,