2 * linux/arch/arm/mach-omap2/board-3430sdp-flash.c
4 * Copyright (c) 2007 Texas Instruments
6 * Modified from mach-omap2/board-2430sdp-flash.c
7 * Author: Rohit Choraria <rohitkc@ti.com>
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/platform_device.h>
16 #include <linux/mtd/mtd.h>
17 #include <linux/mtd/partitions.h>
18 #include <linux/mtd/nand.h>
19 #include <linux/mtd/onenand_regs.h>
20 #include <linux/types.h>
23 #include <asm/mach/flash.h>
24 #include <mach/onenand.h>
25 #include <mach/board.h>
26 #include <mach/gpmc.h>
27 #include <mach/nand.h>
29 #define NAND_BLOCK_SIZE SZ_128K
31 static struct mtd_partition sdp_nor_partitions[] = {
32 /* bootloader (U-Boot, etc) in first sector */
34 .name = "Bootloader-NOR",
37 .mask_flags = MTD_WRITEABLE, /* force read-only */
39 /* bootloader params in the next sector */
42 .offset = MTDPART_OFS_APPEND,
49 .offset = MTDPART_OFS_APPEND,
55 .name = "Filesystem-NOR",
56 .offset = MTDPART_OFS_APPEND,
57 .size = MTDPART_SIZ_FULL,
62 static struct flash_platform_data sdp_nor_data = {
63 .map_name = "cfi_probe",
65 .parts = sdp_nor_partitions,
66 .nr_parts = ARRAY_SIZE(sdp_nor_partitions),
69 static struct resource sdp_nor_resource = {
72 .flags = IORESOURCE_MEM,
75 static struct platform_device sdp_nor_device = {
79 .platform_data = &sdp_nor_data,
82 .resource = &sdp_nor_resource,
85 static int sdp_onenand_setup(void __iomem *, int freq);
87 static struct mtd_partition sdp_onenand_partitions[] = {
89 .name = "X-Loader-OneNAND",
91 .size = 4 * (64 * 2048),
92 .mask_flags = MTD_WRITEABLE /* force read-only */
95 .name = "U-Boot-OneNAND",
96 .offset = MTDPART_OFS_APPEND,
97 .size = 2 * (64 * 2048),
98 .mask_flags = MTD_WRITEABLE /* force read-only */
101 .name = "U-Boot Environment-OneNAND",
102 .offset = MTDPART_OFS_APPEND,
103 .size = 1 * (64 * 2048),
106 .name = "Kernel-OneNAND",
107 .offset = MTDPART_OFS_APPEND,
108 .size = 16 * (64 * 2048),
111 .name = "File System-OneNAND",
112 .offset = MTDPART_OFS_APPEND,
113 .size = MTDPART_SIZ_FULL,
117 static struct omap_onenand_platform_data sdp_onenand_data = {
118 .parts = sdp_onenand_partitions,
119 .nr_parts = ARRAY_SIZE(sdp_onenand_partitions),
120 .onenand_setup = sdp_onenand_setup,
121 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
124 static struct platform_device sdp_onenand_device = {
125 .name = "omap2-onenand",
128 .platform_data = &sdp_onenand_data,
133 * sdp_onenand_setup - The function configures the onenand flash.
134 * @onenand_base: Onenand base address
136 * @return int: Currently always returning zero.
138 static int sdp_onenand_setup(void __iomem *onenand_base, int freq)
140 /* Onenand setup does nothing at present */
144 static struct mtd_partition sdp_nand_partitions[] = {
145 /* All the partition sizes are listed in terms of NAND block size */
147 .name = "X-Loader-NAND",
149 .size = 4 * NAND_BLOCK_SIZE,
150 .mask_flags = MTD_WRITEABLE, /* force read-only */
153 .name = "U-Boot-NAND",
154 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
155 .size = 4 * NAND_BLOCK_SIZE,
156 .mask_flags = MTD_WRITEABLE, /* force read-only */
159 .name = "Boot Env-NAND",
160 .offset = MTDPART_OFS_APPEND, /* Offset = 0x100000 */
161 .size = 2 * NAND_BLOCK_SIZE,
164 .name = "Kernel-NAND",
165 .offset = MTDPART_OFS_APPEND, /* Offset = 0x140000 */
166 .size = 32 * NAND_BLOCK_SIZE,
169 .name = "File System - NAND",
170 .size = MTDPART_SIZ_FULL,
171 .offset = MTDPART_OFS_APPEND, /* Offset = 0x540000 */
175 static struct omap_nand_platform_data sdp_nand_data = {
176 .parts = sdp_nand_partitions,
177 .nr_parts = ARRAY_SIZE(sdp_nand_partitions),
179 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
183 static struct resource sdp_nand_resource = {
184 .flags = IORESOURCE_MEM,
187 static struct platform_device sdp_nand_device = {
188 .name = "omap2-nand",
191 .platform_data = &sdp_nand_data,
194 .resource = &sdp_nand_resource,
199 * sdp3430_flash_init - Identify devices connected to GPMC and register.
203 void __init sdp3430_flash_init(void)
206 u8 nandcs = GPMC_CS_NUM + 1;
207 u8 onenandcs = GPMC_CS_NUM + 1;
208 unsigned long gpmc_base_add;
210 gpmc_base_add = OMAP34XX_GPMC_VIRT;
212 /* Configure start address and size of NOR device */
213 if (omap_rev() > OMAP3430_REV_ES1_0) {
214 sdp_nor_resource.start = FLASH_BASE_SDPV2;
215 sdp_nor_resource.end = FLASH_BASE_SDPV2
216 + FLASH_SIZE_SDPV2 - 1;
218 sdp_nor_resource.start = FLASH_BASE_SDPV1;
219 sdp_nor_resource.end = FLASH_BASE_SDPV1
220 + FLASH_SIZE_SDPV1 - 1;
223 if (platform_device_register(&sdp_nor_device) < 0)
224 printk(KERN_ERR "Unable to register NOR device\n");
226 while (cs < GPMC_CS_NUM) {
228 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
231 * xloader/Uboot would have programmed the NAND/oneNAND
232 * base address for us This is a ugly hack. The proper
233 * way of doing this is to pass the setup of u-boot up
234 * to kernel using kernel params - something on the
235 * lines of machineID. Check if oneNAND is configured
237 if ((ret & 0xC00) == 0x800) {
239 if (nandcs > GPMC_CS_NUM)
242 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
243 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
248 if ((nandcs > GPMC_CS_NUM) && (onenandcs > GPMC_CS_NUM)) {
249 printk(KERN_INFO "NAND/OneNAND: Unable to find configuration "
254 if (nandcs < GPMC_CS_NUM) {
255 sdp_nand_data.cs = nandcs;
256 sdp_nand_data.gpmc_cs_baseaddr = (void *)(gpmc_base_add +
257 GPMC_CS0_BASE + nandcs*GPMC_CS_SIZE);
258 sdp_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
260 if (platform_device_register(&sdp_nand_device) < 0)
261 printk(KERN_ERR "Unable to register NAND device\n");
264 if (onenandcs < GPMC_CS_NUM) {
265 sdp_onenand_data.cs = onenandcs;
266 if (platform_device_register(&sdp_onenand_device) < 0)
267 printk(KERN_ERR "Unable to register OneNAND device\n");