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