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 static struct mtd_partition sdp_nor_partitions[] = {
30 /* bootloader (U-Boot, etc) in first sector */
32 .name = "Bootloader-NOR",
35 .mask_flags = MTD_WRITEABLE, /* force read-only */
37 /* bootloader params in the next sector */
40 .offset = MTDPART_OFS_APPEND,
47 .offset = MTDPART_OFS_APPEND,
53 .name = "Filesystem-NOR",
54 .offset = MTDPART_OFS_APPEND,
55 .size = MTDPART_SIZ_FULL,
60 static struct flash_platform_data sdp_nor_data = {
61 .map_name = "cfi_probe",
63 .parts = sdp_nor_partitions,
64 .nr_parts = ARRAY_SIZE(sdp_nor_partitions),
67 static struct resource sdp_nor_resource = {
70 .flags = IORESOURCE_MEM,
73 static struct platform_device sdp_nor_device = {
77 .platform_data = &sdp_nor_data,
80 .resource = &sdp_nor_resource,
83 static int sdp_onenand_setup(void __iomem *, int freq);
85 static struct mtd_partition sdp_onenand_partitions[] = {
87 .name = "X-Loader-OneNAND",
89 .size = 4 * (64 * 2048),
90 .mask_flags = MTD_WRITEABLE /* force read-only */
93 .name = "U-Boot-OneNAND",
94 .offset = MTDPART_OFS_APPEND,
95 .size = 2 * (64 * 2048),
96 .mask_flags = MTD_WRITEABLE /* force read-only */
99 .name = "U-Boot Environment-OneNAND",
100 .offset = MTDPART_OFS_APPEND,
101 .size = 1 * (64 * 2048),
104 .name = "Kernel-OneNAND",
105 .offset = MTDPART_OFS_APPEND,
106 .size = 16 * (64 * 2048),
109 .name = "File System-OneNAND",
110 .offset = MTDPART_OFS_APPEND,
111 .size = MTDPART_SIZ_FULL,
115 static struct omap_onenand_platform_data sdp_onenand_data = {
116 .parts = sdp_onenand_partitions,
117 .nr_parts = ARRAY_SIZE(sdp_onenand_partitions),
118 .onenand_setup = sdp_onenand_setup,
119 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
122 static struct platform_device sdp_onenand_device = {
123 .name = "omap2-onenand",
126 .platform_data = &sdp_onenand_data,
131 * sdp_onenand_setup - The function configures the onenand flash.
132 * @onenand_base: Onenand base address
134 * @return int: Currently always returning zero.
136 static int sdp_onenand_setup(void __iomem *onenand_base, int freq)
138 /* Onenand setup does nothing at present */
142 static struct mtd_partition sdp_nand_partitions[] = {
143 /* All the partition sizes are listed in terms of NAND block size */
145 .name = "X-Loader-NAND",
147 .size = 4 * NAND_BLOCK_SIZE,
148 .mask_flags = MTD_WRITEABLE, /* force read-only */
151 .name = "U-Boot-NAND",
152 .offset = MTDPART_OFS_APPEND, /* Offset = 0x80000 */
153 .size = 4 * NAND_BLOCK_SIZE,
154 .mask_flags = MTD_WRITEABLE, /* force read-only */
157 .name = "Boot Env-NAND",
158 .offset = MTDPART_OFS_APPEND, /* Offset = 0x100000 */
159 .size = 2 * NAND_BLOCK_SIZE,
162 .name = "Kernel-NAND",
163 .offset = MTDPART_OFS_APPEND, /* Offset = 0x140000 */
164 .size = 32 * NAND_BLOCK_SIZE,
167 .name = "File System - NAND",
168 .size = MTDPART_SIZ_FULL,
169 .offset = MTDPART_OFS_APPEND, /* Offset = 0x540000 */
173 static struct omap_nand_platform_data sdp_nand_data = {
174 .parts = sdp_nand_partitions,
175 .nr_parts = ARRAY_SIZE(sdp_nand_partitions),
177 .dma_channel = -1, /* disable DMA in OMAP NAND driver */
181 static struct resource sdp_nand_resource = {
182 .flags = IORESOURCE_MEM,
185 static struct platform_device sdp_nand_device = {
186 .name = "omap2-nand",
189 .platform_data = &sdp_nand_data,
192 .resource = &sdp_nand_resource,
197 * sdp3430_flash_init - Identify devices connected to GPMC and register.
201 void __init sdp3430_flash_init(void)
204 u8 nandcs = GPMC_CS_NUM + 1;
205 u8 onenandcs = GPMC_CS_NUM + 1;
206 unsigned long gpmc_base_add;
208 gpmc_base_add = OMAP34XX_GPMC_VIRT;
210 /* Configure start address and size of NOR device */
211 if (system_rev > OMAP3430_REV_ES1_0) {
212 sdp_nor_resource.start = FLASH_BASE_SDPV2;
213 sdp_nor_resource.end = FLASH_BASE_SDPV2
214 + FLASH_SIZE_SDPV2 - 1;
216 sdp_nor_resource.start = FLASH_BASE_SDPV1;
217 sdp_nor_resource.end = FLASH_BASE_SDPV1
218 + FLASH_SIZE_SDPV1 - 1;
221 if (platform_device_register(&sdp_nor_device) < 0)
222 printk(KERN_ERR "Unable to register NOR device\n");
224 while (cs < GPMC_CS_NUM) {
226 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
229 * xloader/Uboot would have programmed the NAND/oneNAND
230 * base address for us This is a ugly hack. The proper
231 * way of doing this is to pass the setup of u-boot up
232 * to kernel using kernel params - something on the
233 * lines of machineID. Check if oneNAND is configured
235 if ((ret & 0xC00) == 0x800) {
237 if (nandcs > GPMC_CS_NUM)
240 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
241 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
246 if ((nandcs > GPMC_CS_NUM) && (onenandcs > GPMC_CS_NUM)) {
247 printk(KERN_INFO "NAND/OneNAND: Unable to find configuration "
252 if (nandcs < GPMC_CS_NUM) {
253 sdp_nand_data.cs = nandcs;
254 sdp_nand_data.gpmc_cs_baseaddr = (void *)(gpmc_base_add +
255 GPMC_CS0_BASE + nandcs*GPMC_CS_SIZE);
256 sdp_nand_data.gpmc_baseaddr = (void *) (gpmc_base_add);
258 if (platform_device_register(&sdp_nand_device) < 0)
259 printk(KERN_ERR "Unable to register NAND device\n");
262 if (onenandcs < GPMC_CS_NUM) {
263 sdp_onenand_data.cs = onenandcs;
264 if (platform_device_register(&sdp_onenand_device) < 0)
265 printk(KERN_ERR "Unable to register OneNAND device\n");