2 * linux/arch/arm/mach-omap2/board-omap2evm.c
4 * Copyright (C) 2008 Mistral Solutions Pvt Ltd
6 * Modified from mach-omap2/board-generic.c
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/delay.h>
17 #include <linux/err.h>
18 #include <linux/clk.h>
20 #include <linux/input.h>
21 #include <linux/i2c/twl4030.h>
22 #include <linux/mtd/mtd.h>
23 #include <linux/mtd/partitions.h>
24 #include <linux/mtd/nand.h>
26 #include <mach/hardware.h>
27 #include <asm/mach-types.h>
28 #include <asm/mach/arch.h>
29 #include <asm/mach/map.h>
30 #include <asm/mach/flash.h>
32 #include <mach/gpio.h>
33 #include <mach/board.h>
34 #include <mach/common.h>
35 #include <mach/hsmmc.h>
36 #include <mach/keypad.h>
37 #include <mach/gpmc.h>
38 #include <mach/nand.h>
40 #define GPMC_OFF_CONFIG1_0 0x60
42 static struct mtd_partition omap2evm_nand_partitions[] = {
46 .size = 1 * (64 * 2048),
47 .mask_flags = MTD_WRITEABLE, /* force read-only */
51 .offset = MTDPART_OFS_APPEND,
52 .size = 3 * (64 * 2048),
53 .mask_flags = MTD_WRITEABLE, /* force read-only */
56 .name = "U-Boot Environment",
57 .offset = MTDPART_OFS_APPEND,
58 .size = 1 * (64 * 2048),
62 .offset = MTDPART_OFS_APPEND,
63 .size = 16 * (64 * 2048), /* 2MB */
67 .offset = MTDPART_OFS_APPEND,
68 .size = 32 * (64 * 2048), /* 4MB */
72 .offset = MTDPART_OFS_APPEND,
73 .size = MTDPART_SIZ_FULL,
77 static struct omap_nand_platform_data omap2evm_nand_data = {
78 .parts = omap2evm_nand_partitions,
79 .nr_parts = ARRAY_SIZE(omap2evm_nand_partitions),
80 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
83 static struct resource omap2evm_nand_resource = {
84 .flags = IORESOURCE_MEM,
87 static struct platform_device omap2evm_nand_device = {
91 .platform_data = &omap2evm_nand_data,
94 .resource = &omap2evm_nand_resource,
97 void __init omap2evm_flash_init(void)
99 void __iomem *gpmc_base_add, *gpmc_cs_base_add;
100 unsigned char cs = 0;
102 gpmc_base_add = (__force void __iomem *)OMAP243X_GPMC_VIRT;
103 while (cs < GPMC_CS_NUM) {
106 /* Each GPMC set for a single CS is at offset 0x30 */
107 gpmc_cs_base_add = (gpmc_base_add + GPMC_OFF_CONFIG1_0 +
110 /* xloader/Uboot would have programmed the NAND
111 * base address for us This is a ugly hack. The proper
112 * way of doing this is to pass the setup of u-boot up
113 * to kernel using kernel params - something on the
114 * lines of machineID. Check if Nand is
116 ret = __raw_readl(gpmc_cs_base_add + GPMC_CS_CONFIG1);
117 if ((ret & 0xC00) == (0x800)) {
119 printk(KERN_INFO "NAND: Found NAND on CS %d \n", cs);
124 if (cs >= GPMC_CS_NUM) {
125 printk(KERN_INFO "MTD: Unable to find MTD configuration in "
126 "GPMC - not registering.\n");
130 omap2evm_nand_data.cs = cs;
131 omap2evm_nand_data.gpmc_cs_baseaddr = gpmc_cs_base_add;
132 omap2evm_nand_data.gpmc_baseaddr = gpmc_base_add;
134 if (platform_device_register(&omap2evm_nand_device) < 0) {
135 printk(KERN_ERR "Unable to register NAND device\n");
140 static struct resource omap2evm_smc911x_resources[] = {
142 .start = OMAP2EVM_ETHR_START,
143 .end = (OMAP2EVM_ETHR_START + OMAP2EVM_ETHR_SIZE - 1),
144 .flags = IORESOURCE_MEM,
147 .start = OMAP_GPIO_IRQ(OMAP2EVM_ETHR_GPIO_IRQ),
148 .end = OMAP_GPIO_IRQ(OMAP2EVM_ETHR_GPIO_IRQ),
149 .flags = IORESOURCE_IRQ,
153 static struct platform_device omap2evm_smc911x_device = {
156 .num_resources = ARRAY_SIZE(omap2evm_smc911x_resources),
157 .resource = &omap2evm_smc911x_resources [0],
160 static inline void __init omap2evm_init_smc911x(void)
162 int gpio = OMAP2EVM_ETHR_GPIO_IRQ;
165 ret = gpio_request(gpio, "smc911x IRQ");
167 printk(KERN_ERR "Failed to request GPIO %d for smc911x IRQ\n",
171 gpio_direction_input(gpio);
175 static struct platform_device omap2_evm_lcd_device = {
176 .name = "omap2evm_lcd",
180 static struct omap_lcd_config omap2_evm_lcd_config __initdata = {
181 .ctrl_name = "internal",
184 static int omap2evm_keymap[] = {
186 KEY(0, 1, KEY_RIGHT),
193 KEY(2, 0, KEY_ENTER),
203 static struct omap_kp_platform_data omap2evm_kp_data = {
206 .keymap = omap2evm_keymap,
207 .keymapsize = ARRAY_SIZE(omap2evm_keymap),
209 .irq = TWL4030_MODIRQ_KEYPAD,
212 static struct platform_device omap2evm_kp_device = {
213 .name = "omap_twl4030keypad",
216 .platform_data = &omap2evm_kp_data,
220 static void __init omap2_evm_init_irq(void)
222 omap2_init_common_hw(NULL);
225 omap2evm_init_smc911x();
228 static struct omap_uart_config omap2_evm_uart_config __initdata = {
229 .enabled_uarts = ((1 << 0) | (1 << 1) | (1 << 2)),
232 static struct omap_board_config_kernel omap2_evm_config[] __initdata = {
233 { OMAP_TAG_UART, &omap2_evm_uart_config },
234 { OMAP_TAG_LCD, &omap2_evm_lcd_config },
237 static int __init omap2_evm_i2c_init(void)
240 * Registering bus 2 first to avoid twl4030 misbehaving as OMAP2EVM
241 * has twl4030 on bus 2
243 omap_register_i2c_bus(2, 2600, NULL, 0);
244 omap_register_i2c_bus(1, 400, NULL, 0);
248 static struct platform_device *omap2_evm_devices[] __initdata = {
249 &omap2_evm_lcd_device,
250 &omap2evm_smc911x_device,
254 static void __init omap2_evm_init(void)
256 omap2_evm_i2c_init();
258 platform_add_devices(omap2_evm_devices, ARRAY_SIZE(omap2_evm_devices));
259 omap_board_config = omap2_evm_config;
260 omap_board_config_size = ARRAY_SIZE(omap2_evm_config);
263 omap2evm_flash_init();
266 static void __init omap2_evm_map_io(void)
268 omap2_set_globals_243x();
269 omap2_map_common_io();
272 MACHINE_START(OMAP2EVM, "OMAP2EVM Board")
273 /* Maintainer: Arun KS <arunks@mistralsolutions.com> */
274 .phys_io = 0x48000000,
275 .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
276 .boot_params = 0x80000100,
277 .map_io = omap2_evm_map_io,
278 .init_irq = omap2_evm_init_irq,
279 .init_machine = omap2_evm_init,
280 .timer = &omap_timer,