]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap2/board-omap3evm-flash.c
5f3663daf4f83d3f95c3d7ebab1359a4a49bfa96
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-omap3evm-flash.c
1 /*
2  * board-omap3evm-flash.c
3  *
4  * Copyright (c) 2008 Texas Instruments,
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #include <linux/kernel.h>
12 #include <linux/platform_device.h>
13 #include <linux/mtd/mtd.h>
14 #include <linux/mtd/partitions.h>
15 #include <linux/mtd/nand.h>
16 #include <linux/mtd/onenand_regs.h>
17 #include <linux/types.h>
18 #include <linux/io.h>
19
20 #include <asm/mach/flash.h>
21 #include <mach/onenand.h>
22 #include <mach/board.h>
23 #include <mach/gpmc.h>
24 #include <mach/nand.h>
25
26 static int omap3evm_onenand_setup(void __iomem *, int freq);
27
28 static struct mtd_partition omap3evm_onenand_partitions[] = {
29         {
30                 .name           = "xloader",
31                 .offset         = 0,
32                 .size           = 4*(64*2048),
33                 .mask_flags     = MTD_WRITEABLE
34         },
35         {
36                 .name           = "uboot",
37                 .offset         = MTDPART_OFS_APPEND,
38                 .size           =  15*(64*2048),
39                 .mask_flags     = MTD_WRITEABLE
40         },
41         {
42                 .name           = "params",
43                 .offset         = MTDPART_OFS_APPEND,
44                 .size           = 1*(64*2048),
45         },
46         {
47                 .name           = "linux",
48                 .offset         = MTDPART_OFS_APPEND,
49                 .size           = 40*(64*2048),
50         },
51         {
52                 .name           = "jffs2",
53                 .offset         = MTDPART_OFS_APPEND,
54                 .size           = MTDPART_SIZ_FULL,
55         },
56 };
57
58 static struct omap_onenand_platform_data omap3evm_onenand_data = {
59         .parts = omap3evm_onenand_partitions,
60         .nr_parts = ARRAY_SIZE(omap3evm_onenand_partitions),
61         .onenand_setup = omap3evm_onenand_setup,
62         .dma_channel    = -1,   /* disable DMA in OMAP OneNAND driver */
63 };
64
65 static struct platform_device omap3evm_onenand_device = {
66         .name           = "omap2-onenand",
67         .id             = -1,
68         .dev = {
69                 .platform_data = &omap3evm_onenand_data,
70         },
71 };
72
73 /*
74  *      omap3evm_onenand_setup - Set the onenand sync mode
75  *      @onenand_base:  The onenand base address in GPMC memory map
76  *
77  */
78
79 static int omap3evm_onenand_setup(void __iomem *onenand_base, int freq)
80 {
81         /* nothing is required to be setup for onenand as of now */
82         return 0;
83 }
84
85 void __init omap3evm_flash_init(void)
86 {
87         u8              cs = 0;
88         u8              onenandcs = GPMC_CS_NUM + 1;
89
90         while (cs < GPMC_CS_NUM) {
91                 u32 ret = 0;
92                 ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG7);
93
94                 /*
95                 * xloader/Uboot would have programmed the oneNAND
96                 * base address for us This is a ugly hack. The proper
97                 * way of doing this is to pass the setup of u-boot up
98                 * to kernel using kernel params - something on the
99                 * lines of machineID. Check if oneNAND is configured
100                 */
101                 if ((ret & 0x3F) == (ONENAND_MAP >> 24))
102                         onenandcs = cs;
103                 cs++;
104         }
105         if (onenandcs > GPMC_CS_NUM) {
106                 printk(KERN_INFO "OneNAND: Unable to find configuration "
107                                 " in GPMC\n ");
108                 return;
109         }
110
111         if (onenandcs < GPMC_CS_NUM) {
112                 omap3evm_onenand_data.cs = onenandcs;
113                 if (platform_device_register(&omap3evm_onenand_device) < 0)
114                         printk(KERN_ERR "Unable to register OneNAND device\n");
115         }
116 }
117