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 <asm/arch/onenand.h>
25 #include <asm/arch/board.h>
26 #include <asm/arch/gpmc.h>
28 static struct mtd_partition sdp_nor_partitions
[] = {
29 /* bootloader (U-Boot, etc) in first sector */
31 .name
= "Bootloader-NOR",
34 .mask_flags
= MTD_WRITEABLE
, /* force read-only */
36 /* bootloader params in the next sector */
39 .offset
= MTDPART_OFS_APPEND
,
46 .offset
= MTDPART_OFS_APPEND
,
52 .name
= "Filesystem-NOR",
53 .offset
= MTDPART_OFS_APPEND
,
54 .size
= MTDPART_SIZ_FULL
,
59 static struct flash_platform_data sdp_nor_data
= {
60 .map_name
= "cfi_probe",
62 .parts
= sdp_nor_partitions
,
63 .nr_parts
= ARRAY_SIZE(sdp_nor_partitions
),
66 static struct resource sdp_nor_resource
= {
69 .flags
= IORESOURCE_MEM
,
72 static struct platform_device sdp_nor_device
= {
76 .platform_data
= &sdp_nor_data
,
79 .resource
= &sdp_nor_resource
,
82 static int sdp_onenand_setup(void __iomem
*, int freq
);
84 static struct mtd_partition sdp_onenand_partitions
[] = {
86 .name
= "X-Loader-OneNAND",
88 .size
= 4 * (64 * 2048),
89 .mask_flags
= MTD_WRITEABLE
/* force read-only */
92 .name
= "U-Boot-OneNAND",
93 .offset
= MTDPART_OFS_APPEND
,
94 .size
= 2 * (64 * 2048),
95 .mask_flags
= MTD_WRITEABLE
/* force read-only */
98 .name
= "U-Boot Environment-OneNAND",
99 .offset
= MTDPART_OFS_APPEND
,
100 .size
= 1 * (64 * 2048),
103 .name
= "Kernel-OneNAND",
104 .offset
= MTDPART_OFS_APPEND
,
105 .size
= 16 * (64 * 2048),
108 .name
= "File System-OneNAND",
109 .offset
= MTDPART_OFS_APPEND
,
110 .size
= MTDPART_SIZ_FULL
,
114 static struct omap_onenand_platform_data sdp_onenand_data
= {
115 .parts
= sdp_onenand_partitions
,
116 .nr_parts
= ARRAY_SIZE(sdp_onenand_partitions
),
117 .onenand_setup
= sdp_onenand_setup
,
118 .dma_channel
= -1, /* disable DMA in OMAP OneNAND driver */
121 static struct platform_device sdp_onenand_device
= {
122 .name
= "omap2-onenand",
125 .platform_data
= &sdp_onenand_data
,
130 * sdp_onenand_setup - The function configures the onenand flash.
131 * @onenand_base: Onenand base address
133 * @return int: Currently always returning zero.
135 static int sdp_onenand_setup(void __iomem
*onenand_base
, int freq
)
137 /* Onenand setup does nothing at present */
141 * sdp3430_flash_init - Identify devices connected to GPMC and register.
145 void __init
sdp3430_flash_init(void)
148 u8 onenandcs
= GPMC_CS_NUM
+ 1;
150 /* Configure start address and size of NOR device */
151 if (is_sil_rev_greater_than(OMAP3430_REV_ES1_0
)) {
152 sdp_nor_resource
.start
= FLASH_BASE_SDPV2
;
153 sdp_nor_resource
.end
= FLASH_BASE_SDPV2
154 + FLASH_SIZE_SDPV2
- 1;
156 sdp_nor_resource
.start
= FLASH_BASE_SDPV1
;
157 sdp_nor_resource
.end
= FLASH_BASE_SDPV1
158 + FLASH_SIZE_SDPV1
- 1;
161 if (platform_device_register(&sdp_nor_device
) < 0)
162 printk(KERN_ERR
"Unable to register NOR device\n");
164 while (cs
< GPMC_CS_NUM
) {
166 ret
= gpmc_cs_read_reg(cs
, GPMC_CS_CONFIG7
);
169 * xloader/Uboot would have programmed the oneNAND
170 * base address for us This is a ugly hack. The proper
171 * way of doing this is to pass the setup of u-boot up
172 * to kernel using kernel params - something on the
173 * lines of machineID. Check if oneNAND is configured
175 if ((ret
& 0x3F) == (ONENAND_MAP
>> 24))
179 if (onenandcs
> GPMC_CS_NUM
) {
180 printk(KERN_INFO
"OneNAND: Unable to find configuration "
185 if (onenandcs
< GPMC_CS_NUM
) {
186 sdp_onenand_data
.cs
= onenandcs
;
187 if (platform_device_register(&sdp_onenand_device
) < 0)
188 printk(KERN_ERR
"Unable to register OneNAND device\n");