PRCM: OMAP3: Fix to wrongly modified omap2_clk_wait_ready
[linux-ginger.git] / arch / arm / mach-omap2 / board-3430sdp-flash.c
blob1fddcd67b57750feab6e889efb93c811a2e59cc4
1 /*
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>
21 #include <linux/io.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",
32 .offset = 0,
33 .size = SZ_256K,
34 .mask_flags = MTD_WRITEABLE, /* force read-only */
36 /* bootloader params in the next sector */
38 .name = "Params-NOR",
39 .offset = MTDPART_OFS_APPEND,
40 .size = SZ_256K,
41 .mask_flags = 0,
43 /* kernel */
45 .name = "Kernel-NOR",
46 .offset = MTDPART_OFS_APPEND,
47 .size = SZ_2M,
48 .mask_flags = 0
50 /* file system */
52 .name = "Filesystem-NOR",
53 .offset = MTDPART_OFS_APPEND,
54 .size = MTDPART_SIZ_FULL,
55 .mask_flags = 0
59 static struct flash_platform_data sdp_nor_data = {
60 .map_name = "cfi_probe",
61 .width = 2,
62 .parts = sdp_nor_partitions,
63 .nr_parts = ARRAY_SIZE(sdp_nor_partitions),
66 static struct resource sdp_nor_resource = {
67 .start = 0,
68 .end = 0,
69 .flags = IORESOURCE_MEM,
72 static struct platform_device sdp_nor_device = {
73 .name = "omapflash",
74 .id = 0,
75 .dev = {
76 .platform_data = &sdp_nor_data,
78 .num_resources = 1,
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",
87 .offset = 0,
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",
123 .id = -1,
124 .dev = {
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 */
138 return 0;
141 * sdp3430_flash_init - Identify devices connected to GPMC and register.
143 * @return - void.
145 void __init sdp3430_flash_init(void)
147 u8 cs = 0;
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;
155 } else {
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) {
165 u32 ret = 0;
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))
176 onenandcs = cs;
177 cs++;
179 if (onenandcs > GPMC_CS_NUM) {
180 printk(KERN_INFO "OneNAND: Unable to find configuration "
181 " in GPMC\n ");
182 return;
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");