blob: ab3712c86d2b1f583144c14a8588719de71dda2b [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
30#include <plat/mtu.h>
31
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010032#include <mach/setup.h>
Alessandro Rubini63234712009-07-29 18:51:56 +020033#include <mach/nand.h>
34#include <mach/fsmc.h>
Alessandro Rubini28ad94e2009-07-02 19:06:47 +010035#include "clock.h"
36
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010037/* Initial value for SRC control register: all timers use MXTAL/8 source */
38#define SRC_CR_INIT_MASK 0x00007fff
39#define SRC_CR_INIT_VAL 0x2aaa8000
40
Daniel Mack3ad2f3f2010-02-03 08:01:28 +080041/* These addresses span 16MB, so use three individual pages */
Alessandro Rubini63234712009-07-29 18:51:56 +020042static struct resource nhk8815_nand_resources[] = {
43 {
44 .name = "nand_addr",
45 .start = NAND_IO_ADDR,
46 .end = NAND_IO_ADDR + 0xfff,
47 .flags = IORESOURCE_MEM,
48 }, {
49 .name = "nand_cmd",
50 .start = NAND_IO_CMD,
51 .end = NAND_IO_CMD + 0xfff,
52 .flags = IORESOURCE_MEM,
53 }, {
54 .name = "nand_data",
55 .start = NAND_IO_DATA,
56 .end = NAND_IO_DATA + 0xfff,
57 .flags = IORESOURCE_MEM,
58 }
59};
60
61static int nhk8815_nand_init(void)
62{
63 /* FSMC setup for nand chip select (8-bit nand in 8815NHK) */
64 writel(0x0000000E, FSMC_PCR(0));
65 writel(0x000D0A00, FSMC_PMEM(0));
66 writel(0x00100A00, FSMC_PATT(0));
67
68 /* enable access to the chip select area */
69 writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
70
71 return 0;
72}
73
74/*
75 * These partitions are the same as those used in the 2.6.20 release
76 * shipped by the vendor; the first two partitions are mandated
77 * by the boot ROM, and the bootloader area is somehow oversized...
78 */
79static struct mtd_partition nhk8815_partitions[] = {
80 {
81 .name = "X-Loader(NAND)",
82 .offset = 0,
83 .size = SZ_256K,
84 }, {
85 .name = "MemInit(NAND)",
86 .offset = MTDPART_OFS_APPEND,
87 .size = SZ_256K,
88 }, {
89 .name = "BootLoader(NAND)",
90 .offset = MTDPART_OFS_APPEND,
91 .size = SZ_2M,
92 }, {
93 .name = "Kernel zImage(NAND)",
94 .offset = MTDPART_OFS_APPEND,
95 .size = 3 * SZ_1M,
96 }, {
97 .name = "Root Filesystem(NAND)",
98 .offset = MTDPART_OFS_APPEND,
99 .size = 22 * SZ_1M,
100 }, {
101 .name = "User Filesystem(NAND)",
102 .offset = MTDPART_OFS_APPEND,
103 .size = MTDPART_SIZ_FULL,
104 }
105};
106
107static struct nomadik_nand_platform_data nhk8815_nand_data = {
108 .parts = nhk8815_partitions,
109 .nparts = ARRAY_SIZE(nhk8815_partitions),
110 .options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \
111 | NAND_NO_READRDY | NAND_NO_AUTOINCR,
112 .init = nhk8815_nand_init,
113};
114
115static struct platform_device nhk8815_nand_device = {
116 .name = "nomadik_nand",
117 .dev = {
118 .platform_data = &nhk8815_nand_data,
119 },
120 .resource = nhk8815_nand_resources,
121 .num_resources = ARRAY_SIZE(nhk8815_nand_resources),
122};
123
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200124/* These are the partitions for the OneNand device, different from above */
125static struct mtd_partition nhk8815_onenand_partitions[] = {
126 {
127 .name = "X-Loader(OneNAND)",
128 .offset = 0,
129 .size = SZ_256K,
130 }, {
131 .name = "MemInit(OneNAND)",
132 .offset = MTDPART_OFS_APPEND,
133 .size = SZ_256K,
134 }, {
135 .name = "BootLoader(OneNAND)",
136 .offset = MTDPART_OFS_APPEND,
137 .size = SZ_2M-SZ_256K,
138 }, {
139 .name = "SysImage(OneNAND)",
140 .offset = MTDPART_OFS_APPEND,
141 .size = 4 * SZ_1M,
142 }, {
143 .name = "Root Filesystem(OneNAND)",
144 .offset = MTDPART_OFS_APPEND,
145 .size = 22 * SZ_1M,
146 }, {
147 .name = "User Filesystem(OneNAND)",
148 .offset = MTDPART_OFS_APPEND,
149 .size = MTDPART_SIZ_FULL,
150 }
151};
152
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200153static struct onenand_platform_data nhk8815_onenand_data = {
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200154 .parts = nhk8815_onenand_partitions,
155 .nr_parts = ARRAY_SIZE(nhk8815_onenand_partitions),
156};
157
158static struct resource nhk8815_onenand_resource[] = {
159 {
160 .start = 0x30000000,
161 .end = 0x30000000 + SZ_128K - 1,
162 .flags = IORESOURCE_MEM,
163 },
164};
165
166static struct platform_device nhk8815_onenand_device = {
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200167 .name = "onenand-flash",
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200168 .id = -1,
169 .dev = {
170 .platform_data = &nhk8815_onenand_data,
171 },
172 .resource = nhk8815_onenand_resource,
173 .num_resources = ARRAY_SIZE(nhk8815_onenand_resource),
174};
175
176static void __init nhk8815_onenand_init(void)
177{
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200178#ifdef CONFIG_MTD_ONENAND
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200179 /* Set up SMCS0 for OneNand */
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200180 writel(0x000030db, FSMC_BCR(0));
181 writel(0x02100551, FSMC_BTR(0));
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200182#endif
183}
Alessandro Rubini63234712009-07-29 18:51:56 +0200184
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100185#define __MEM_4K_RESOURCE(x) \
186 .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
187
188static struct amba_device uart0_device = {
189 .dev = { .init_name = "uart0" },
190 __MEM_4K_RESOURCE(NOMADIK_UART0_BASE),
191 .irq = {IRQ_UART0, NO_IRQ},
192};
193
194static struct amba_device uart1_device = {
195 .dev = { .init_name = "uart1" },
196 __MEM_4K_RESOURCE(NOMADIK_UART1_BASE),
197 .irq = {IRQ_UART1, NO_IRQ},
198};
199
200static struct amba_device *amba_devs[] __initdata = {
201 &uart0_device,
202 &uart1_device,
203};
204
205/* We have a fixed clock alone, by now */
206static struct clk nhk8815_clk_48 = {
207 .rate = 48*1000*1000,
208};
209
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100210static struct resource nhk8815_eth_resources[] = {
211 {
212 .name = "smc91x-regs",
213 .start = 0x34000000 + 0x300,
214 .end = 0x34000000 + SZ_64K - 1,
215 .flags = IORESOURCE_MEM,
216 }, {
217 .start = NOMADIK_GPIO_TO_IRQ(115),
218 .end = NOMADIK_GPIO_TO_IRQ(115),
219 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
220 }
221};
222
223static struct platform_device nhk8815_eth_device = {
224 .name = "smc91x",
225 .resource = nhk8815_eth_resources,
226 .num_resources = ARRAY_SIZE(nhk8815_eth_resources),
227};
228
229static int __init nhk8815_eth_init(void)
230{
231 int gpio_nr = 115; /* hardwired in the board */
232 int err;
233
234 err = gpio_request(gpio_nr, "eth_irq");
235 if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO);
236 if (!err) err = gpio_direction_input(gpio_nr);
237 if (err)
238 pr_err("Error %i in %s\n", err, __func__);
239 return err;
240}
241device_initcall(nhk8815_eth_init);
242
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100243static struct platform_device *nhk8815_platform_devices[] __initdata = {
Alessandro Rubini63234712009-07-29 18:51:56 +0200244 &nhk8815_nand_device,
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200245 &nhk8815_onenand_device,
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100246 &nhk8815_eth_device,
247 /* will add more devices */
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100248};
249
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +0100250static void __init nomadik_timer_init(void)
251{
252 u32 src_cr;
253
254 /* Configure timer sources in "system reset controller" ctrl reg */
255 src_cr = readl(io_p2v(NOMADIK_SRC_BASE));
256 src_cr &= SRC_CR_INIT_MASK;
257 src_cr |= SRC_CR_INIT_VAL;
258 writel(src_cr, io_p2v(NOMADIK_SRC_BASE));
259
260 /* Save global pointer to mtu, used by platform timer code */
261 mtu_base = io_p2v(NOMADIK_MTU0_BASE);
262
263 nmdk_timer_init();
264}
265
266static struct sys_timer nomadik_timer = {
267 .init = nomadik_timer_init,
268};
269
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100270static void __init nhk8815_platform_init(void)
271{
272 int i;
273
274 cpu8815_platform_init();
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200275 nhk8815_onenand_init();
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100276 platform_add_devices(nhk8815_platform_devices,
277 ARRAY_SIZE(nhk8815_platform_devices));
278
279 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
280 nmdk_clk_create(&nhk8815_clk_48, amba_devs[i]->dev.init_name);
281 amba_device_register(amba_devs[i], &iomem_resource);
282 }
283}
284
285MACHINE_START(NOMADIK, "NHK8815")
286 /* Maintainer: ST MicroElectronics */
287 .phys_io = NOMADIK_UART0_BASE,
288 .io_pg_offst = (IO_ADDRESS(NOMADIK_UART0_BASE) >> 18) & 0xfffc,
289 .boot_params = 0x100,
290 .map_io = cpu8815_map_io,
291 .init_irq = cpu8815_init_irq,
292 .timer = &nomadik_timer,
293 .init_machine = nhk8815_platform_init,
294MACHINE_END