]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-2430sdp-flash.c
Revert "OMAP: Adding Support for 2K nand page support for omap2430"
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-2430sdp-flash.c
1 /*
2  * linux/arch/arm/mach-omap2/board-2430sdp-flash.c
3  *
4  * Copyright (C) 2007 MontaVista Software, Inc. <source@mvista.com>
5  * Author: Kevin Hilman
6  *
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.
10  */
11
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>
18
19 #include <asm/io.h>
20 #include <asm/arch/onenand.h>
21 #include <asm/arch/board.h>
22 #include <asm/arch/gpmc.h>
23
24 #define ONENAND_MAP 0x20000000
25 #define GPMC_OFF_CONFIG1_0 0x60
26
27 static struct mtd_partition onenand_partitions[] = {
28         {
29                 .name           = "(OneNAND)X-Loader",
30                 .offset         = 0,
31                 .size           = 4*(64*2048),  /* 0-3 blks reserved.
32                                                    Mandated by ROM code */
33                 .mask_flags     = MTD_WRITEABLE /* force read-only */
34         },
35         {
36                 .name           = "(OneNAND)U-Boot",
37                 .offset         = MTDPART_OFS_APPEND,
38                 .size           =  2*(64*2048),
39                 .mask_flags     = MTD_WRITEABLE /* force read-only */
40         },
41         {
42                 .name           = "(OneNAND)U-Boot Environment",
43                 .offset         = MTDPART_OFS_APPEND,
44                 .size           = 1*(64*2048),
45         },
46         {
47                 .name           = "(OneNAND)Kernel",
48                 .offset         = MTDPART_OFS_APPEND,
49                 .size           = 4*(64*2048),
50         },
51         {
52                 .name           = "(OneNAND)File System",
53                 .offset         = MTDPART_OFS_APPEND,
54                 .size           = MTDPART_SIZ_FULL,
55         },
56 };
57
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 */
62 };
63
64 static struct platform_device sdp_onenand_device = {
65         .name           = "omap2-onenand",
66         .id             = -1,
67         .dev = {
68                 .platform_data = &sdp_onenand_data,
69         },
70 };
71
72 void __init sdp2430_flash_init(void)
73 {
74         unsigned long gpmc_base_add, gpmc_cs_base_add;
75         unsigned char cs=0;
76
77         gpmc_base_add = OMAP243X_GPMC_VIRT;
78         while (cs < GPMC_CS_NUM) {
79                 int ret = 0;
80
81                 /* Each GPMC set for a single CS is at offset 0x30 */
82                 gpmc_cs_base_add =
83                         (gpmc_base_add + GPMC_OFF_CONFIG1_0 + (cs*0x30));
84
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
90                  * configured */
91                 ret = __raw_readl(gpmc_cs_base_add + GPMC_CS_CONFIG7);
92                 if ((ret & 0x3F) == (ONENAND_MAP >> 24)) {
93                         /* Found it!! */
94                         break;
95                 }
96                 cs++;
97         }
98         if (cs >= GPMC_CS_NUM) {
99                 printk("OneNAND: Unable to find oneNAND configuration in GPMC "
100                        " - not registering.\n");
101                 return;
102         }
103
104         sdp_onenand_data.cs = cs;
105
106         if (platform_device_register(&sdp_onenand_device) < 0) {
107                 printk(KERN_ERR "Unable to register OneNAND device\n");
108                 return;
109         }
110 }