2 * linux/arch/arm/mach-omap2/board-2430sdp-flash.c
4 * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #include <linux/kernel.h>
13 #include <linux/platform_device.h>
14 #include <asm/mach/flash.h>
15 #include <linux/mtd/mtd.h>
16 #include <linux/mtd/partitions.h>
17 #include <linux/mtd/onenand_regs.h>
20 #include <asm/arch/onenand.h>
21 #include <asm/arch/board.h>
22 #include <asm/arch/gpmc.h>
24 #define ONENAND_MAP 0x20000000
25 #define GPMC_OFF_CONFIG1_0 0x60
27 static struct mtd_partition onenand_partitions[] = {
29 .name = "(OneNAND)X-Loader",
31 .size = 4*(64*2048), /* 0-3 blks reserved.
32 Mandated by ROM code */
33 .mask_flags = MTD_WRITEABLE /* force read-only */
36 .name = "(OneNAND)U-Boot",
37 .offset = MTDPART_OFS_APPEND,
39 .mask_flags = MTD_WRITEABLE /* force read-only */
42 .name = "(OneNAND)U-Boot Environment",
43 .offset = MTDPART_OFS_APPEND,
47 .name = "(OneNAND)Kernel",
48 .offset = MTDPART_OFS_APPEND,
52 .name = "(OneNAND)File System",
53 .offset = MTDPART_OFS_APPEND,
54 .size = MTDPART_SIZ_FULL,
58 static struct omap_onenand_platform_data sdp_onenand_data = {
59 .parts = onenand_partitions,
60 .nr_parts = ARRAY_SIZE(onenand_partitions),
61 .dma_channel = -1, /* disable DMA in OMAP OneNAND driver */
64 static struct platform_device sdp_onenand_device = {
65 .name = "omap2-onenand",
68 .platform_data = &sdp_onenand_data,
72 void __init sdp2430_flash_init(void)
74 unsigned long gpmc_base_add, gpmc_cs_base_add;
77 gpmc_base_add = OMAP243X_GPMC_VIRT;
78 while (cs < GPMC_CS_NUM) {
81 /* Each GPMC set for a single CS is at offset 0x30 */
83 (gpmc_base_add + GPMC_OFF_CONFIG1_0 + (cs*0x30));
85 /* xloader/Uboot would have programmed the oneNAND
86 * base address for us This is a ugly hack. The proper
87 * way of doing this is to pass the setup of u-boot up
88 * to kernel using kernel params - something on the
89 * lines of machineID. Check if oneNAND is
91 ret = __raw_readl(gpmc_cs_base_add + GPMC_CS_CONFIG7);
92 if ((ret & 0x3F) == (ONENAND_MAP >> 24)) {
98 if (cs >= GPMC_CS_NUM) {
99 printk("OneNAND: Unable to find oneNAND configuration in GPMC "
100 " - not registering.\n");
104 sdp_onenand_data.cs = cs;
106 if (platform_device_register(&sdp_onenand_device) < 0) {
107 printk(KERN_ERR "Unable to register OneNAND device\n");