ARM Nomadik: use new OneNand name and pdata
[safe/jmp/linux-2.6] / arch / arm / mach-nomadik / board-nhk8815.c
1 /*
2  *  linux/arch/arm/mach-nomadik/board-8815nhk.c
3  *
4  *  Copyright (C) STMicroelectronics
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  *  NHK15 board specifc driver definition
11  */
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/amba/bus.h>
17 #include <linux/interrupt.h>
18 #include <linux/gpio.h>
19 #include <linux/mtd/mtd.h>
20 #include <linux/mtd/nand.h>
21 #include <linux/mtd/onenand.h>
22 #include <linux/mtd/partitions.h>
23 #include <linux/io.h>
24 #include <asm/sizes.h>
25 #include <asm/mach-types.h>
26 #include <asm/mach/arch.h>
27 #include <asm/mach/irq.h>
28 #include <asm/mach/flash.h>
29 #include <mach/setup.h>
30 #include <mach/nand.h>
31 #include <mach/fsmc.h>
32 #include "clock.h"
33
34 /* These adresses span 16MB, so use three individual pages */
35 static struct resource nhk8815_nand_resources[] = {
36         {
37                 .name = "nand_addr",
38                 .start = NAND_IO_ADDR,
39                 .end = NAND_IO_ADDR + 0xfff,
40                 .flags = IORESOURCE_MEM,
41         }, {
42                 .name = "nand_cmd",
43                 .start = NAND_IO_CMD,
44                 .end = NAND_IO_CMD + 0xfff,
45                 .flags = IORESOURCE_MEM,
46         }, {
47                 .name = "nand_data",
48                 .start = NAND_IO_DATA,
49                 .end = NAND_IO_DATA + 0xfff,
50                 .flags = IORESOURCE_MEM,
51         }
52 };
53
54 static int nhk8815_nand_init(void)
55 {
56         /* FSMC setup for nand chip select (8-bit nand in 8815NHK) */
57         writel(0x0000000E, FSMC_PCR(0));
58         writel(0x000D0A00, FSMC_PMEM(0));
59         writel(0x00100A00, FSMC_PATT(0));
60
61         /* enable access to the chip select area */
62         writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
63
64         return 0;
65 }
66
67 /*
68  * These partitions are the same as those used in the 2.6.20 release
69  * shipped by the vendor; the first two partitions are mandated
70  * by the boot ROM, and the bootloader area is somehow oversized...
71  */
72 static struct mtd_partition nhk8815_partitions[] = {
73         {
74                 .name   = "X-Loader(NAND)",
75                 .offset = 0,
76                 .size   = SZ_256K,
77         }, {
78                 .name   = "MemInit(NAND)",
79                 .offset = MTDPART_OFS_APPEND,
80                 .size   = SZ_256K,
81         }, {
82                 .name   = "BootLoader(NAND)",
83                 .offset = MTDPART_OFS_APPEND,
84                 .size   = SZ_2M,
85         }, {
86                 .name   = "Kernel zImage(NAND)",
87                 .offset = MTDPART_OFS_APPEND,
88                 .size   = 3 * SZ_1M,
89         }, {
90                 .name   = "Root Filesystem(NAND)",
91                 .offset = MTDPART_OFS_APPEND,
92                 .size   = 22 * SZ_1M,
93         }, {
94                 .name   = "User Filesystem(NAND)",
95                 .offset = MTDPART_OFS_APPEND,
96                 .size   = MTDPART_SIZ_FULL,
97         }
98 };
99
100 static struct nomadik_nand_platform_data nhk8815_nand_data = {
101         .parts          = nhk8815_partitions,
102         .nparts         = ARRAY_SIZE(nhk8815_partitions),
103         .options        = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \
104                         | NAND_NO_READRDY | NAND_NO_AUTOINCR,
105         .init           = nhk8815_nand_init,
106 };
107
108 static struct platform_device nhk8815_nand_device = {
109         .name           = "nomadik_nand",
110         .dev            = {
111                 .platform_data = &nhk8815_nand_data,
112         },
113         .resource       = nhk8815_nand_resources,
114         .num_resources  = ARRAY_SIZE(nhk8815_nand_resources),
115 };
116
117 /* These are the partitions for the OneNand device, different from above */
118 static struct mtd_partition nhk8815_onenand_partitions[] = {
119         {
120                 .name   = "X-Loader(OneNAND)",
121                 .offset = 0,
122                 .size   = SZ_256K,
123         }, {
124                 .name   = "MemInit(OneNAND)",
125                 .offset = MTDPART_OFS_APPEND,
126                 .size   = SZ_256K,
127         }, {
128                 .name   = "BootLoader(OneNAND)",
129                 .offset = MTDPART_OFS_APPEND,
130                 .size   = SZ_2M-SZ_256K,
131         }, {
132                 .name   = "SysImage(OneNAND)",
133                 .offset = MTDPART_OFS_APPEND,
134                 .size   = 4 * SZ_1M,
135         }, {
136                 .name   = "Root Filesystem(OneNAND)",
137                 .offset = MTDPART_OFS_APPEND,
138                 .size   = 22 * SZ_1M,
139         }, {
140                 .name   = "User Filesystem(OneNAND)",
141                 .offset = MTDPART_OFS_APPEND,
142                 .size   = MTDPART_SIZ_FULL,
143         }
144 };
145
146 static struct onenand_platform_data nhk8815_onenand_data = {
147         .parts          = nhk8815_onenand_partitions,
148         .nr_parts       = ARRAY_SIZE(nhk8815_onenand_partitions),
149 };
150
151 static struct resource nhk8815_onenand_resource[] = {
152         {
153                 .start          = 0x30000000,
154                 .end            = 0x30000000 + SZ_128K - 1,
155                 .flags          = IORESOURCE_MEM,
156         },
157 };
158
159 static struct platform_device nhk8815_onenand_device = {
160         .name           = "onenand-flash",
161         .id             = -1,
162         .dev            = {
163                 .platform_data  = &nhk8815_onenand_data,
164         },
165         .resource       = nhk8815_onenand_resource,
166         .num_resources  = ARRAY_SIZE(nhk8815_onenand_resource),
167 };
168
169 static void __init nhk8815_onenand_init(void)
170 {
171 #ifdef CONFIG_MTD_ONENAND
172        /* Set up SMCS0 for OneNand */
173         writel(0x000030db, FSMC_BCR(0));
174         writel(0x02100551, FSMC_BTR(0));
175 #endif
176 }
177
178 #define __MEM_4K_RESOURCE(x) \
179         .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
180
181 static struct amba_device uart0_device = {
182         .dev = { .init_name = "uart0" },
183         __MEM_4K_RESOURCE(NOMADIK_UART0_BASE),
184         .irq = {IRQ_UART0, NO_IRQ},
185 };
186
187 static struct amba_device uart1_device = {
188         .dev = { .init_name = "uart1" },
189         __MEM_4K_RESOURCE(NOMADIK_UART1_BASE),
190         .irq = {IRQ_UART1, NO_IRQ},
191 };
192
193 static struct amba_device *amba_devs[] __initdata = {
194         &uart0_device,
195         &uart1_device,
196 };
197
198 /* We have a fixed clock alone, by now */
199 static struct clk nhk8815_clk_48 = {
200         .rate = 48*1000*1000,
201 };
202
203 static struct resource nhk8815_eth_resources[] = {
204         {
205                 .name = "smc91x-regs",
206                 .start = 0x34000000 + 0x300,
207                 .end = 0x34000000 + SZ_64K - 1,
208                 .flags = IORESOURCE_MEM,
209         }, {
210                 .start = NOMADIK_GPIO_TO_IRQ(115),
211                 .end = NOMADIK_GPIO_TO_IRQ(115),
212                 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
213         }
214 };
215
216 static struct platform_device nhk8815_eth_device = {
217         .name = "smc91x",
218         .resource = nhk8815_eth_resources,
219         .num_resources = ARRAY_SIZE(nhk8815_eth_resources),
220 };
221
222 static int __init nhk8815_eth_init(void)
223 {
224         int gpio_nr = 115; /* hardwired in the board */
225         int err;
226
227         err = gpio_request(gpio_nr, "eth_irq");
228         if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO);
229         if (!err) err = gpio_direction_input(gpio_nr);
230         if (err)
231                 pr_err("Error %i in %s\n", err, __func__);
232         return err;
233 }
234 device_initcall(nhk8815_eth_init);
235
236 static struct platform_device *nhk8815_platform_devices[] __initdata = {
237         &nhk8815_nand_device,
238         &nhk8815_onenand_device,
239         &nhk8815_eth_device,
240         /* will add more devices */
241 };
242
243 static void __init nhk8815_platform_init(void)
244 {
245         int i;
246
247         cpu8815_platform_init();
248         nhk8815_onenand_init();
249         platform_add_devices(nhk8815_platform_devices,
250                              ARRAY_SIZE(nhk8815_platform_devices));
251
252         for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
253                 nmdk_clk_create(&nhk8815_clk_48, amba_devs[i]->dev.init_name);
254                 amba_device_register(amba_devs[i], &iomem_resource);
255         }
256 }
257
258 MACHINE_START(NOMADIK, "NHK8815")
259         /* Maintainer: ST MicroElectronics */
260         .phys_io        = NOMADIK_UART0_BASE,
261         .io_pg_offst    = (IO_ADDRESS(NOMADIK_UART0_BASE) >> 18) & 0xfffc,
262         .boot_params    = 0x100,
263         .map_io         = cpu8815_map_io,
264         .init_irq       = cpu8815_init_irq,
265         .timer          = &nomadik_timer,
266         .init_machine   = nhk8815_platform_init,
267 MACHINE_END