board-omap2evm.c 7.2 KB
Newer Older
1
/*
2
 * linux/arch/arm/mach-omap2/board-omap2evm.c
3
 *
4
 * Copyright (C) 2008 Mistral Solutions Pvt Ltd
5 6 7 8 9 10 11 12 13 14 15 16 17 18
 *
 * Modified from mach-omap2/board-generic.c
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/clk.h>
19
#include <linux/io.h>
arun c's avatar
arun c committed
20
#include <linux/input.h>
Arun KS's avatar
Arun KS committed
21
#include <linux/i2c/twl4030.h>
Arun KS's avatar
Arun KS committed
22 23 24
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/nand.h>
25

26
#include <mach/hardware.h>
27 28 29
#include <asm/mach-types.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
Arun KS's avatar
Arun KS committed
30
#include <asm/mach/flash.h>
31

32 33 34 35 36
#include <mach/gpio.h>
#include <mach/board.h>
#include <mach/common.h>
#include <mach/hsmmc.h>
#include <mach/keypad.h>
Arun KS's avatar
Arun KS committed
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
#include <mach/gpmc.h>
#include <mach/nand.h>

#define GPMC_OFF_CONFIG1_0 0x60

static struct mtd_partition omap2evm_nand_partitions[] = {
	{
		.name		= "X-Loader",
		.offset		= 0,
		.size		= 1 * (64 * 2048),
		.mask_flags	= MTD_WRITEABLE,	/* force read-only */
	},
	{
		.name		= "U-Boot",
		.offset		= MTDPART_OFS_APPEND,
		.size		= 3 * (64 * 2048),
		.mask_flags	= MTD_WRITEABLE,	/* force read-only */
	},
	{
		.name		= "U-Boot Environment",
		.offset		= MTDPART_OFS_APPEND,
		.size		= 1 * (64 * 2048),
	 },
	{
		.name		= "Kernel",
		.offset		= MTDPART_OFS_APPEND,
		.size		= 16 * (64 * 2048),	/* 2MB */
	},
	{
		.name		= "Ramdisk",
		.offset		= MTDPART_OFS_APPEND,
		.size		= 32 * (64 * 2048),	/* 4MB */
	},
	{
		.name		= "Filesystem",
		.offset		= MTDPART_OFS_APPEND,
		.size		= MTDPART_SIZ_FULL,
	}
};

static struct omap_nand_platform_data omap2evm_nand_data = {
	.parts		= omap2evm_nand_partitions,
	.nr_parts	= ARRAY_SIZE(omap2evm_nand_partitions),
	.dma_channel	= -1,	/* disable DMA in OMAP NAND driver */
};

static struct resource omap2evm_nand_resource = {
	.flags		= IORESOURCE_MEM,
};

static struct platform_device omap2evm_nand_device = {
	.name		= "omap2-nand",
	.id		= -1,
	.dev		= {
		.platform_data	= &omap2evm_nand_data,
	},
	.num_resources	= 1,
	.resource	= &omap2evm_nand_resource,
};

void __init omap2evm_flash_init(void)
{
	void __iomem *gpmc_base_add, *gpmc_cs_base_add;
	unsigned char cs = 0;

	gpmc_base_add = (__force void __iomem *)OMAP243X_GPMC_VIRT;
	while (cs < GPMC_CS_NUM) {
		int ret = 0;

		/* Each GPMC set for a single CS is at offset 0x30 */
		gpmc_cs_base_add = (gpmc_base_add + GPMC_OFF_CONFIG1_0 +
				    (cs * 0x30));

		/* xloader/Uboot would have programmed the NAND
		 * base address for us This is a ugly hack. The proper
		 * way of doing this is to pass the setup of u-boot up
		 * to kernel using kernel params - something on the
		 * lines of machineID. Check if Nand is
		 * configured */
		ret = __raw_readl(gpmc_cs_base_add + GPMC_CS_CONFIG1);
		if ((ret & 0xC00) == (0x800)) {
			/* Found it!! */
			printk(KERN_INFO "NAND: Found NAND on CS %d \n", cs);
			break;
		}
		cs++;
	}
	if (cs >= GPMC_CS_NUM) {
		printk(KERN_INFO "MTD: Unable to find MTD configuration in "
				 "GPMC   - not registering.\n");
		return;
	}

	omap2evm_nand_data.cs			= cs;
	omap2evm_nand_data.gpmc_cs_baseaddr	= gpmc_cs_base_add;
	omap2evm_nand_data.gpmc_baseaddr	= gpmc_base_add;

	if (platform_device_register(&omap2evm_nand_device) < 0) {
		printk(KERN_ERR "Unable to register NAND device\n");
		return;
	}
}
139

Arun KS's avatar
Arun KS committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
static struct resource omap2evm_smc911x_resources[] = {
	[0] =   {
		.start  = OMAP2EVM_ETHR_START,
		.end    = (OMAP2EVM_ETHR_START + OMAP2EVM_ETHR_SIZE - 1),
		.flags  = IORESOURCE_MEM,
	},
	[1] =   {
		.start  = OMAP_GPIO_IRQ(OMAP2EVM_ETHR_GPIO_IRQ),
		.end    = OMAP_GPIO_IRQ(OMAP2EVM_ETHR_GPIO_IRQ),
		.flags  = IORESOURCE_IRQ,
	},
};

static struct platform_device omap2evm_smc911x_device = {
	.name       = "smc911x",
	.id     = -1,
	.num_resources  = ARRAY_SIZE(omap2evm_smc911x_resources),
	.resource   = &omap2evm_smc911x_resources [0],
};

static inline void __init omap2evm_init_smc911x(void)
{
	int gpio = OMAP2EVM_ETHR_GPIO_IRQ;
	int ret;

	ret = gpio_request(gpio, "smc911x IRQ");
	if (ret < 0) {
		printk(KERN_ERR "Failed to request GPIO %d for smc911x IRQ\n",
				gpio);
		return;
	}
	gpio_direction_input(gpio);

}

arun c's avatar
arun c committed
175 176 177 178 179 180 181 182 183
static struct platform_device omap2_evm_lcd_device = {
	.name		= "omap2evm_lcd",
	.id		= -1,
};

static struct omap_lcd_config omap2_evm_lcd_config __initdata = {
	.ctrl_name	= "internal",
};

arun c's avatar
arun c committed
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
static int omap2evm_keymap[] = {
	KEY(0, 0, KEY_LEFT),
	KEY(0, 1, KEY_RIGHT),
	KEY(0, 2, KEY_A),
	KEY(0, 3, KEY_B),
	KEY(1, 0, KEY_DOWN),
	KEY(1, 1, KEY_UP),
	KEY(1, 2, KEY_E),
	KEY(1, 3, KEY_F),
	KEY(2, 0, KEY_ENTER),
	KEY(2, 1, KEY_I),
	KEY(2, 2, KEY_J),
	KEY(2, 3, KEY_K),
	KEY(3, 0, KEY_M),
	KEY(3, 1, KEY_N),
	KEY(3, 2, KEY_O),
	KEY(3, 3, KEY_P)
};

203
static struct twl4030_keypad_data omap2evm_kp_data = {
arun c's avatar
arun c committed
204 205
	.rows		= 4,
	.cols		= 4,
206
	.keymap		= omap2evm_keymap,
arun c's avatar
arun c committed
207 208
	.keymapsize	= ARRAY_SIZE(omap2evm_keymap),
	.rep		= 1,
Arun KS's avatar
Arun KS committed
209
	.irq		= TWL4030_MODIRQ_KEYPAD,
arun c's avatar
arun c committed
210 211
};

212
static void __init omap2_evm_init_irq(void)
213
{
214
	omap2_init_common_hw(NULL);
215 216
	omap_init_irq();
	omap_gpio_init();
Arun KS's avatar
Arun KS committed
217
	omap2evm_init_smc911x();
218 219
}

220
static struct omap_uart_config omap2_evm_uart_config __initdata = {
221 222 223
	.enabled_uarts	= ((1 << 0) | (1 << 1) | (1 << 2)),
};

224
static struct omap_board_config_kernel omap2_evm_config[] __initdata = {
arun c's avatar
arun c committed
225 226
	{ OMAP_TAG_UART,	&omap2_evm_uart_config },
	{ OMAP_TAG_LCD,		&omap2_evm_lcd_config },
227 228
};

David Brownell's avatar
David Brownell committed
229 230 231 232 233 234
static struct twl4030_gpio_platform_data omap2evm_gpio_data = {
	.gpio_base	= OMAP_MAX_GPIO_LINES,
	.irq_base	= TWL4030_GPIO_IRQ_BASE,
	.irq_end	= TWL4030_GPIO_IRQ_END,
};

235 236 237 238
static struct twl4030_usb_data omap2evm_usb_data = {
	.usb_mode	= T2_USB_MODE_ULPI,
};

239 240 241 242
static struct twl4030_madc_platform_data omap2evm_madc_data = {
	.irq_line	= 1,
};

David Brownell's avatar
David Brownell committed
243 244 245
static struct twl4030_platform_data omap2evm_twldata = {
	.irq_base	= TWL4030_IRQ_BASE,
	.irq_end	= TWL4030_IRQ_END,
246 247 248

	/* platform_data for children goes here */
	.keypad		= &omap2evm_kp_data,
249
	.madc		= &omap2evm_madc_data,
250
	.usb		= &omap2evm_usb_data,
David Brownell's avatar
David Brownell committed
251
	.gpio		= &omap2evm_gpio_data,
David Brownell's avatar
David Brownell committed
252 253 254 255 256 257 258 259 260 261 262
};

static struct i2c_board_info __initdata omap2evm_i2c_boardinfo[] = {
	{
		I2C_BOARD_INFO("twl4030", 0x48),
		.flags = I2C_CLIENT_WAKE,
		.irq = INT_24XX_SYS_NIRQ,
		.platform_data = &omap2evm_twldata,
	},
};

263
static int __init omap2_evm_i2c_init(void)
264
{
265
	omap_register_i2c_bus(1, 400, NULL, 0);
David Brownell's avatar
David Brownell committed
266 267
	omap_register_i2c_bus(2, 2600, omap2evm_i2c_boardinfo,
			ARRAY_SIZE(omap2evm_i2c_boardinfo));
268 269 270
	return 0;
}

Arun KS's avatar
Arun KS committed
271
static struct platform_device *omap2_evm_devices[] __initdata = {
arun c's avatar
arun c committed
272 273
	&omap2_evm_lcd_device,
	&omap2evm_smc911x_device,
Arun KS's avatar
Arun KS committed
274 275
};

276
static void __init omap2_evm_init(void)
277
{
278 279
	omap2_evm_i2c_init();

Arun KS's avatar
Arun KS committed
280
	platform_add_devices(omap2_evm_devices, ARRAY_SIZE(omap2_evm_devices));
281 282
	omap_board_config = omap2_evm_config;
	omap_board_config_size = ARRAY_SIZE(omap2_evm_config);
283
	omap_serial_init();
Arun KS's avatar
Arun KS committed
284
	hsmmc_init();
Arun KS's avatar
Arun KS committed
285
	omap2evm_flash_init();
286 287
}

288
static void __init omap2_evm_map_io(void)
289
{
290
	omap2_set_globals_243x();
291 292 293
	omap2_map_common_io();
}

294 295
MACHINE_START(OMAP2EVM, "OMAP2EVM Board")
	/* Maintainer:  Arun KS <arunks@mistralsolutions.com> */
296 297 298
	.phys_io	= 0x48000000,
	.io_pg_offst	= ((0xd8000000) >> 18) & 0xfffc,
	.boot_params	= 0x80000100,
299 300 301
	.map_io		= omap2_evm_map_io,
	.init_irq	= omap2_evm_init_irq,
	.init_machine	= omap2_evm_init,
302 303
	.timer		= &omap_timer,
MACHINE_END