blob: 68c7b79bad790f2f5a134c1a958255cb3baf5a00 [file] [log] [blame]
Alessandro Rubini28ad94e2009-07-02 19:06:47 +01001/*
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>
Alessandro Rubini725b1f92009-07-02 15:29:32 +010017#include <linux/interrupt.h>
18#include <linux/gpio.h>
Alessandro Rubini63234712009-07-29 18:51:56 +020019#include <linux/mtd/mtd.h>
20#include <linux/mtd/nand.h>
Alessandro Rubinic1558b52009-09-20 23:28:24 +020021#include <linux/mtd/onenand.h>
Alessandro Rubini63234712009-07-29 18:51:56 +020022#include <linux/mtd/partitions.h>
23#include <linux/io.h>
24#include <asm/sizes.h>
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010025#include <asm/mach-types.h>
26#include <asm/mach/arch.h>
27#include <asm/mach/irq.h>
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +020028#include <asm/mach/flash.h>
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010029
Linus Walleij0f332862011-08-22 08:33:30 +010030#include <plat/gpio-nomadik.h>
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010031#include <plat/mtu.h>
32
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010033#include <mach/setup.h>
Alessandro Rubini63234712009-07-29 18:51:56 +020034#include <mach/nand.h>
35#include <mach/fsmc.h>
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010036
Linus Walleij61b38752011-11-28 12:20:53 +010037#include "cpu-8815.h"
38
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010039/* Initial value for SRC control register: all timers use MXTAL/8 source */
40#define SRC_CR_INIT_MASK 0x00007fff
41#define SRC_CR_INIT_VAL 0x2aaa8000
42
Daniel Mack3ad2f3f2010-02-03 08:01:28 +080043/* These addresses span 16MB, so use three individual pages */
Alessandro Rubini63234712009-07-29 18:51:56 +020044static struct resource nhk8815_nand_resources[] = {
45 {
46 .name = "nand_addr",
47 .start = NAND_IO_ADDR,
48 .end = NAND_IO_ADDR + 0xfff,
49 .flags = IORESOURCE_MEM,
50 }, {
51 .name = "nand_cmd",
52 .start = NAND_IO_CMD,
53 .end = NAND_IO_CMD + 0xfff,
54 .flags = IORESOURCE_MEM,
55 }, {
56 .name = "nand_data",
57 .start = NAND_IO_DATA,
58 .end = NAND_IO_DATA + 0xfff,
59 .flags = IORESOURCE_MEM,
60 }
61};
62
63static int nhk8815_nand_init(void)
64{
65 /* FSMC setup for nand chip select (8-bit nand in 8815NHK) */
66 writel(0x0000000E, FSMC_PCR(0));
67 writel(0x000D0A00, FSMC_PMEM(0));
68 writel(0x00100A00, FSMC_PATT(0));
69
70 /* enable access to the chip select area */
71 writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
72
73 return 0;
74}
75
76/*
77 * These partitions are the same as those used in the 2.6.20 release
78 * shipped by the vendor; the first two partitions are mandated
79 * by the boot ROM, and the bootloader area is somehow oversized...
80 */
81static struct mtd_partition nhk8815_partitions[] = {
82 {
83 .name = "X-Loader(NAND)",
84 .offset = 0,
85 .size = SZ_256K,
86 }, {
87 .name = "MemInit(NAND)",
88 .offset = MTDPART_OFS_APPEND,
89 .size = SZ_256K,
90 }, {
91 .name = "BootLoader(NAND)",
92 .offset = MTDPART_OFS_APPEND,
93 .size = SZ_2M,
94 }, {
95 .name = "Kernel zImage(NAND)",
96 .offset = MTDPART_OFS_APPEND,
97 .size = 3 * SZ_1M,
98 }, {
99 .name = "Root Filesystem(NAND)",
100 .offset = MTDPART_OFS_APPEND,
101 .size = 22 * SZ_1M,
102 }, {
103 .name = "User Filesystem(NAND)",
104 .offset = MTDPART_OFS_APPEND,
105 .size = MTDPART_SIZ_FULL,
106 }
107};
108
109static struct nomadik_nand_platform_data nhk8815_nand_data = {
110 .parts = nhk8815_partitions,
111 .nparts = ARRAY_SIZE(nhk8815_partitions),
112 .options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \
113 | NAND_NO_READRDY | NAND_NO_AUTOINCR,
114 .init = nhk8815_nand_init,
115};
116
117static struct platform_device nhk8815_nand_device = {
118 .name = "nomadik_nand",
119 .dev = {
120 .platform_data = &nhk8815_nand_data,
121 },
122 .resource = nhk8815_nand_resources,
123 .num_resources = ARRAY_SIZE(nhk8815_nand_resources),
124};
125
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200126/* These are the partitions for the OneNand device, different from above */
127static struct mtd_partition nhk8815_onenand_partitions[] = {
128 {
129 .name = "X-Loader(OneNAND)",
130 .offset = 0,
131 .size = SZ_256K,
132 }, {
133 .name = "MemInit(OneNAND)",
134 .offset = MTDPART_OFS_APPEND,
135 .size = SZ_256K,
136 }, {
137 .name = "BootLoader(OneNAND)",
138 .offset = MTDPART_OFS_APPEND,
139 .size = SZ_2M-SZ_256K,
140 }, {
141 .name = "SysImage(OneNAND)",
142 .offset = MTDPART_OFS_APPEND,
143 .size = 4 * SZ_1M,
144 }, {
145 .name = "Root Filesystem(OneNAND)",
146 .offset = MTDPART_OFS_APPEND,
147 .size = 22 * SZ_1M,
148 }, {
149 .name = "User Filesystem(OneNAND)",
150 .offset = MTDPART_OFS_APPEND,
151 .size = MTDPART_SIZ_FULL,
152 }
153};
154
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200155static struct onenand_platform_data nhk8815_onenand_data = {
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200156 .parts = nhk8815_onenand_partitions,
157 .nr_parts = ARRAY_SIZE(nhk8815_onenand_partitions),
158};
159
160static struct resource nhk8815_onenand_resource[] = {
161 {
162 .start = 0x30000000,
163 .end = 0x30000000 + SZ_128K - 1,
164 .flags = IORESOURCE_MEM,
165 },
166};
167
168static struct platform_device nhk8815_onenand_device = {
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200169 .name = "onenand-flash",
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200170 .id = -1,
171 .dev = {
172 .platform_data = &nhk8815_onenand_data,
173 },
174 .resource = nhk8815_onenand_resource,
175 .num_resources = ARRAY_SIZE(nhk8815_onenand_resource),
176};
177
178static void __init nhk8815_onenand_init(void)
179{
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200180#ifdef CONFIG_MTD_ONENAND
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200181 /* Set up SMCS0 for OneNand */
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200182 writel(0x000030db, FSMC_BCR(0));
183 writel(0x02100551, FSMC_BTR(0));
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200184#endif
185}
Alessandro Rubini63234712009-07-29 18:51:56 +0200186
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100187#define __MEM_4K_RESOURCE(x) \
188 .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
189
190static struct amba_device uart0_device = {
191 .dev = { .init_name = "uart0" },
192 __MEM_4K_RESOURCE(NOMADIK_UART0_BASE),
193 .irq = {IRQ_UART0, NO_IRQ},
194};
195
196static struct amba_device uart1_device = {
197 .dev = { .init_name = "uart1" },
198 __MEM_4K_RESOURCE(NOMADIK_UART1_BASE),
199 .irq = {IRQ_UART1, NO_IRQ},
200};
201
202static struct amba_device *amba_devs[] __initdata = {
203 &uart0_device,
204 &uart1_device,
205};
206
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100207static struct resource nhk8815_eth_resources[] = {
208 {
209 .name = "smc91x-regs",
210 .start = 0x34000000 + 0x300,
211 .end = 0x34000000 + SZ_64K - 1,
212 .flags = IORESOURCE_MEM,
213 }, {
214 .start = NOMADIK_GPIO_TO_IRQ(115),
215 .end = NOMADIK_GPIO_TO_IRQ(115),
216 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
217 }
218};
219
220static struct platform_device nhk8815_eth_device = {
221 .name = "smc91x",
222 .resource = nhk8815_eth_resources,
223 .num_resources = ARRAY_SIZE(nhk8815_eth_resources),
224};
225
226static int __init nhk8815_eth_init(void)
227{
228 int gpio_nr = 115; /* hardwired in the board */
229 int err;
230
231 err = gpio_request(gpio_nr, "eth_irq");
232 if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO);
233 if (!err) err = gpio_direction_input(gpio_nr);
234 if (err)
235 pr_err("Error %i in %s\n", err, __func__);
236 return err;
237}
238device_initcall(nhk8815_eth_init);
239
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100240static struct platform_device *nhk8815_platform_devices[] __initdata = {
Alessandro Rubini63234712009-07-29 18:51:56 +0200241 &nhk8815_nand_device,
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200242 &nhk8815_onenand_device,
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100243 &nhk8815_eth_device,
244 /* will add more devices */
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100245};
246
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +0100247static void __init nomadik_timer_init(void)
248{
249 u32 src_cr;
250
251 /* Configure timer sources in "system reset controller" ctrl reg */
252 src_cr = readl(io_p2v(NOMADIK_SRC_BASE));
253 src_cr &= SRC_CR_INIT_MASK;
254 src_cr |= SRC_CR_INIT_VAL;
255 writel(src_cr, io_p2v(NOMADIK_SRC_BASE));
256
257 /* Save global pointer to mtu, used by platform timer code */
258 mtu_base = io_p2v(NOMADIK_MTU0_BASE);
259
260 nmdk_timer_init();
261}
262
263static struct sys_timer nomadik_timer = {
264 .init = nomadik_timer_init,
265};
266
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100267static void __init nhk8815_platform_init(void)
268{
269 int i;
270
271 cpu8815_platform_init();
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200272 nhk8815_onenand_init();
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100273 platform_add_devices(nhk8815_platform_devices,
274 ARRAY_SIZE(nhk8815_platform_devices));
275
Rabin Vincentdc6048c2010-05-06 10:47:25 +0100276 for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100277 amba_device_register(amba_devs[i], &iomem_resource);
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100278}
279
280MACHINE_START(NOMADIK, "NHK8815")
281 /* Maintainer: ST MicroElectronics */
Nicolas Pitre013b5fb2011-07-05 22:38:14 -0400282 .atag_offset = 0x100,
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100283 .map_io = cpu8815_map_io,
284 .init_irq = cpu8815_init_irq,
285 .timer = &nomadik_timer,
286 .init_machine = nhk8815_platform_init,
Russell King35b47a4052011-11-28 10:48:02 +0000287 .restart = cpu8815_restart,
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100288MACHINE_END