2 * board-omap3evm-flash.c
4 * Copyright (c) 2008 Texas Instruments,
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
11 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/nand.h>
16 #include <linux/mtd/onenand_regs.h>
17 #include <linux/types.h>
20 #include <asm/mach/flash.h>
21 #include <asm/arch/onenand.h>
22 #include <asm/arch/board.h>
23 #include <asm/arch/gpmc.h>
24 #include <asm/arch/nand.h>
26 static int omap3evm_onenand_setup(void __iomem
*);
28 static struct mtd_partition omap3evm_onenand_partitions
[] = {
33 .mask_flags
= MTD_WRITEABLE
37 .offset
= MTDPART_OFS_APPEND
,
39 .mask_flags
= MTD_WRITEABLE
43 .offset
= MTDPART_OFS_APPEND
,
48 .offset
= MTDPART_OFS_APPEND
,
53 .offset
= MTDPART_OFS_APPEND
,
54 .size
= MTDPART_SIZ_FULL
,
58 static struct omap_onenand_platform_data omap3evm_onenand_data
= {
59 .parts
= omap3evm_onenand_partitions
,
60 .nr_parts
= ARRAY_SIZE(omap3evm_onenand_partitions
),
61 .onenand_setup
= omap3evm_onenand_setup
,
62 .dma_channel
= -1, /* disable DMA in OMAP OneNAND driver */
65 static struct platform_device omap3evm_onenand_device
= {
66 .name
= "omap2-onenand",
69 .platform_data
= &omap3evm_onenand_data
,
74 * omap3evm_onenand_setup - Set the onenand sync mode
75 * @onenand_base: The onenand base address in GPMC memory map
79 static int omap3evm_onenand_setup(void __iomem
*onenand_base
)
81 /* nothing is required to be setup for onenand as of now */
85 void __init
omap3evm_flash_init(void)
88 u8 onenandcs
= GPMC_CS_NUM
+ 1;
90 while (cs
< GPMC_CS_NUM
) {
92 ret
= gpmc_cs_read_reg(cs
, GPMC_CS_CONFIG7
);
95 * xloader/Uboot would have programmed the oneNAND
96 * base address for us This is a ugly hack. The proper
97 * way of doing this is to pass the setup of u-boot up
98 * to kernel using kernel params - something on the
99 * lines of machineID. Check if oneNAND is configured
101 if ((ret
& 0x3F) == (ONENAND_MAP
>> 24))
105 if (onenandcs
> GPMC_CS_NUM
) {
106 printk(KERN_INFO
"OneNAND: Unable to find configuration "
111 if (onenandcs
< GPMC_CS_NUM
) {
112 omap3evm_onenand_data
.cs
= onenandcs
;
113 if (platform_device_register(&omap3evm_onenand_device
) < 0)
114 printk(KERN_ERR
"Unable to register OneNAND device\n");