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
32 /* IMPORTANT NOTE ON MAPPING
35 * NOR always on 0x04000000 for SDPV1
36 * NOR always on 0x10000000 for SDPV2
37 * MPDB always on 0x08000000
38 * NAND always on 0x0C000000
39 * OneNand Mapped to 0x20000000
40 * Boot Mode(NAND/NOR). The other on CS1
42 #define FLASH_BASE_SDPV1 0x04000000 /* NOR flash (64 Meg aligned) */
43 #define FLASH_BASE_SDPV2 0x10000000 /* NOR flash (256 Meg aligned) */
44 #define DEBUG_BASE 0x08000000 /* debug board */
45 #define NAND_BASE 0x0C000000 /* NAND flash */
46 #define ONENAND_MAP 0x20000000 /* OneNand flash */
48 /* various memory sizes */
49 #define FLASH_SIZE_SDPV1 SZ_64M
50 #define FLASH_SIZE_SDPV2 SZ_128M
52 static struct mtd_partition sdp_nor_partitions[] = {
53 /* bootloader (U-Boot, etc) in first sector */
55 .name = "Bootloader-NOR",
58 .mask_flags = MTD_WRITEABLE, /* force read-only */
60 /* bootloader params in the next sector */
63 .offset = MTDPART_OFS_APPEND,
70 .offset = MTDPART_OFS_APPEND,
76 .name = "Filesystem-NOR",
77 .offset = MTDPART_OFS_APPEND,
78 .size = MTDPART_SIZ_FULL,
83 static struct flash_platform_data sdp_nor_data = {
84 .map_name = "cfi_probe",
86 .parts = sdp_nor_partitions,
87 .nr_parts = ARRAY_SIZE(sdp_nor_partitions),
90 static struct resource sdp_nor_resource = {
93 .flags = IORESOURCE_MEM,
96 static struct platform_device sdp_nor_device = {
100 .platform_data = &sdp_nor_data,
103 .resource = &sdp_nor_resource,
106 static int sdp_onenand_setup(void __iomem *, int freq);
108 static struct mtd_partition sdp_onenand_partitions[] = {
110 .name = "X-Loader-OneNAND",
112 .size = 4 * (64 * 2048),
113 .mask_flags = MTD_WRITEABLE /* force read-only */
116 .name = "U-Boot-OneNAND",
117 .offset = MTDPART_OFS_APPEND,
118 .size = 2 * (64 * 2048),
119 .mask_flags = MTD_WRITEABLE /* force read-only */
122 .name = "U-Boot Environment-OneNAND",
123 .offset = MTDPART_OFS_APPEND,
124 .size = 1 * (64 * 2048),
127 .name = "Kernel-OneNAND",
128 .offset = MTDPART_OFS_APPEND,
129 .size = 16 * (64 * 2048),
132 .name = "File System-OneNAND",
133 .offset = MTDPART_OFS_APPEND,
134 .size = MTDPART_SIZ_FULL,
138 static struct omap_onenand_platform_data sdp_onenand_data = {
139 .parts = sdp_onenand_partitions,
140 .nr_parts = ARRAY_SIZE(sdp_onenand_partitions),
141 .onenand_setup = sdp_onenand_setup,
142 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
145 static struct platform_device sdp_onenand_device = {
146 .name = "omap2-onenand",
149 .platform_data = &sdp_onenand_data,
154 * sdp_onenand_setup - The function configures the onenand flash.
155 * @onenand_base: Onenand base address
157 * @return int: Currently always returning zero.
159 static int sdp_onenand_setup(void __iomem *onenand_base, int freq)
161 /* Onenand setup does nothing at present */
165 static struct mtd_partition sdp_nand_partitions[] = {
166 /* All the partition sizes are listed in terms of NAND block size */
168 .name = "X-Loader-NAND",
170 .size = 4 * NAND_BLOCK_SIZE,
171 .mask_flags = MTD_WRITEABLE, /* force read-only */
174 .name = "U-Boot-NAND",
175 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
176 .size = 4 * NAND_BLOCK_SIZE,
177 .mask_flags = MTD_WRITEABLE, /* force read-only */
180 .name = "Boot Env-NAND",
181 .offset = MTDPART_OFS_APPEND, /* Offset = 0x100000 */
182 .size = 2 * NAND_BLOCK_SIZE,
185 .name = "Kernel-NAND",
186 .offset = MTDPART_OFS_APPEND, /* Offset = 0x140000 */
187 .size = 32 * NAND_BLOCK_SIZE,
190 .name = "File System - NAND",
191 .size = MTDPART_SIZ_FULL,
192 .offset = MTDPART_OFS_APPEND, /* Offset = 0x540000 */
196 static struct omap_nand_platform_data sdp_nand_data = {
197 .parts = sdp_nand_partitions,
198 .nr_parts = ARRAY_SIZE(sdp_nand_partitions),
200 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
204 static struct resource sdp_nand_resource = {
205 .flags = IORESOURCE_MEM,
208 static struct platform_device sdp_nand_device = {
209 .name = "omap2-nand",
212 .platform_data = &sdp_nand_data,
215 .resource = &sdp_nand_resource,
220 * sdp3430_flash_init - Identify devices connected to GPMC and register.
224 void __init sdp3430_flash_init(void)
227 u8 nandcs = GPMC_CS_NUM + 1;
228 u8 onenandcs = GPMC_CS_NUM + 1;
229 unsigned long gpmc_base_add;
231 gpmc_base_add = OMAP34XX_GPMC_VIRT;
233 /* Configure start address and size of NOR device */
234 if (omap_rev() > OMAP3430_REV_ES1_0) {
235 sdp_nor_resource.start = FLASH_BASE_SDPV2;
236 sdp_nor_resource.end = FLASH_BASE_SDPV2
237 + FLASH_SIZE_SDPV2 - 1;
239 sdp_nor_resource.start = FLASH_BASE_SDPV1;
240 sdp_nor_resource.end = FLASH_BASE_SDPV1
241 + FLASH_SIZE_SDPV1 - 1;
244 if (platform_device_register(&sdp_nor_device) < 0)
245 printk(KERN_ERR "Unable to register NOR device\n");
247 while (cs < GPMC_CS_NUM) {
249 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
252 * xloader/Uboot would have programmed the NAND/oneNAND
253 * base address for us This is a ugly hack. The proper
254 * way of doing this is to pass the setup of u-boot up
255 * to kernel using kernel params - something on the
256 * lines of machineID. Check if oneNAND is configured
258 if ((ret & 0xC00) == 0x800) {
260 if (nandcs > GPMC_CS_NUM)
263 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
264 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
269 if ((nandcs > GPMC_CS_NUM) && (onenandcs > GPMC_CS_NUM)) {
270 printk(KERN_INFO "NAND/OneNAND: Unable to find configuration "
275 if (nandcs < GPMC_CS_NUM) {
276 sdp_nand_data.cs = nandcs;
277 sdp_nand_data.gpmc_cs_baseaddr = (void *)(gpmc_base_add +
278 GPMC_CS0_BASE + nandcs*GPMC_CS_SIZE);
279 sdp_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
281 if (platform_device_register(&sdp_nand_device) < 0)
282 printk(KERN_ERR "Unable to register NAND device\n");
285 if (onenandcs < GPMC_CS_NUM) {
286 sdp_onenand_data.cs = onenandcs;
287 if (platform_device_register(&sdp_onenand_device) < 0)
288 printk(KERN_ERR "Unable to register OneNAND device\n");