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 <mach/onenand.h>
22 #include <mach/board.h>
23 #include <mach/gpmc.h>
24 #include <mach/nand.h>
26 static int omap3evm_onenand_setup(void __iomem *, int freq);
28 static struct mtd_partition omap3evm_onenand_partitions[] = {
30 .name = "xloader-onenand",
33 .mask_flags = MTD_WRITEABLE
36 .name = "uboot-onenand",
37 .offset = MTDPART_OFS_APPEND,
39 .mask_flags = MTD_WRITEABLE
42 .name = "params-onenand",
43 .offset = MTDPART_OFS_APPEND,
47 .name = "linux-onenand",
48 .offset = MTDPART_OFS_APPEND,
52 .name = "jffs2-onenand",
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,
73 static struct mtd_partition omap3evm_nand_partitions[] = {
74 /* All the partition sizes are listed in terms of NAND block size */
76 .name = "xloader-nand",
78 .size = 4*(128 * 1024),
79 .mask_flags = MTD_WRITEABLE
83 .offset = MTDPART_OFS_APPEND,
84 .size = 14*(128 * 1024),
85 .mask_flags = MTD_WRITEABLE
88 .name = "params-nand",
90 .offset = MTDPART_OFS_APPEND,
91 .size = 2*(128 * 1024)
95 .offset = MTDPART_OFS_APPEND,
96 .size = 40*(128 * 1024)
100 .size = MTDPART_SIZ_FULL,
101 .offset = MTDPART_OFS_APPEND,
105 static struct omap_nand_platform_data omap3evm_nand_data = {
106 .parts = omap3evm_nand_partitions,
107 .nr_parts = ARRAY_SIZE(omap3evm_nand_partitions),
109 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
113 static struct resource omap3evm_nand_resource = {
114 .flags = IORESOURCE_MEM,
117 static struct platform_device omap3evm_nand_device = {
118 .name = "omap2-nand",
121 .platform_data = &omap3evm_nand_data,
124 .resource = &omap3evm_nand_resource,
128 * omap3evm_onenand_setup - Set the onenand sync mode
129 * @onenand_base: The onenand base address in GPMC memory map
133 static int omap3evm_onenand_setup(void __iomem *onenand_base, int freq)
135 /* nothing is required to be setup for onenand as of now */
139 void __init omap3evm_flash_init(void)
142 u8 onenandcs = GPMC_CS_NUM + 1, nandcs = GPMC_CS_NUM + 1;
143 u32 gpmc_base_add = OMAP34XX_GPMC_VIRT;
145 while (cs < GPMC_CS_NUM) {
147 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
150 * xloader/Uboot would have programmed the NAND/oneNAND
151 * base address for us This is a ugly hack. The proper
152 * way of doing this is to pass the setup of u-boot up
153 * to kernel using kernel params - something on the
154 * lines of machineID. Check if NAND/oneNAND is configured
156 if ((ret & 0xC00) == 0x800) {
158 if (nandcs > GPMC_CS_NUM)
161 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
162 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
167 if ((nandcs > GPMC_CS_NUM) && (onenandcs > GPMC_CS_NUM)) {
168 printk(KERN_INFO "NAND/OneNAND: Unable to find configuration "
173 if (nandcs < GPMC_CS_NUM) {
174 omap3evm_nand_data.cs = nandcs;
175 omap3evm_nand_data.gpmc_cs_baseaddr = (void *)(gpmc_base_add +
176 GPMC_CS0_BASE + nandcs*GPMC_CS_SIZE);
177 omap3evm_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
179 if (platform_device_register(&omap3evm_nand_device) < 0) {
180 printk(KERN_ERR "Unable to register NAND device\n");
184 if (onenandcs < GPMC_CS_NUM) {
185 omap3evm_onenand_data.cs = onenandcs;
186 if (platform_device_register(&omap3evm_onenand_device) < 0)
187 printk(KERN_ERR "Unable to register OneNAND device\n");