blob: 58cacafcf6628758a27623abb8f8be1b1b240317 [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>
Linus Walleijb9576622012-01-11 09:46:59 +010030#include <asm/mach/time.h>
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010031
Linus Walleij0f332862011-08-22 08:33:30 +010032#include <plat/gpio-nomadik.h>
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010033#include <plat/mtu.h>
34
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
Linus Walleij61b38752011-11-28 12:20:53 +010038#include "cpu-8815.h"
39
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +010040/* Initial value for SRC control register: all timers use MXTAL/8 source */
41#define SRC_CR_INIT_MASK 0x00007fff
42#define SRC_CR_INIT_VAL 0x2aaa8000
43
Daniel Mack3ad2f3f2010-02-03 08:01:28 +080044/* These addresses span 16MB, so use three individual pages */
Alessandro Rubini63234712009-07-29 18:51:56 +020045static struct resource nhk8815_nand_resources[] = {
46 {
47 .name = "nand_addr",
48 .start = NAND_IO_ADDR,
49 .end = NAND_IO_ADDR + 0xfff,
50 .flags = IORESOURCE_MEM,
51 }, {
52 .name = "nand_cmd",
53 .start = NAND_IO_CMD,
54 .end = NAND_IO_CMD + 0xfff,
55 .flags = IORESOURCE_MEM,
56 }, {
57 .name = "nand_data",
58 .start = NAND_IO_DATA,
59 .end = NAND_IO_DATA + 0xfff,
60 .flags = IORESOURCE_MEM,
61 }
62};
63
64static int nhk8815_nand_init(void)
65{
66 /* FSMC setup for nand chip select (8-bit nand in 8815NHK) */
67 writel(0x0000000E, FSMC_PCR(0));
68 writel(0x000D0A00, FSMC_PMEM(0));
69 writel(0x00100A00, FSMC_PATT(0));
70
71 /* enable access to the chip select area */
72 writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
73
74 return 0;
75}
76
77/*
78 * These partitions are the same as those used in the 2.6.20 release
79 * shipped by the vendor; the first two partitions are mandated
80 * by the boot ROM, and the bootloader area is somehow oversized...
81 */
82static struct mtd_partition nhk8815_partitions[] = {
83 {
84 .name = "X-Loader(NAND)",
85 .offset = 0,
86 .size = SZ_256K,
87 }, {
88 .name = "MemInit(NAND)",
89 .offset = MTDPART_OFS_APPEND,
90 .size = SZ_256K,
91 }, {
92 .name = "BootLoader(NAND)",
93 .offset = MTDPART_OFS_APPEND,
94 .size = SZ_2M,
95 }, {
96 .name = "Kernel zImage(NAND)",
97 .offset = MTDPART_OFS_APPEND,
98 .size = 3 * SZ_1M,
99 }, {
100 .name = "Root Filesystem(NAND)",
101 .offset = MTDPART_OFS_APPEND,
102 .size = 22 * SZ_1M,
103 }, {
104 .name = "User Filesystem(NAND)",
105 .offset = MTDPART_OFS_APPEND,
106 .size = MTDPART_SIZ_FULL,
107 }
108};
109
110static struct nomadik_nand_platform_data nhk8815_nand_data = {
111 .parts = nhk8815_partitions,
112 .nparts = ARRAY_SIZE(nhk8815_partitions),
113 .options = NAND_COPYBACK | NAND_CACHEPRG | NAND_NO_PADDING \
114 | NAND_NO_READRDY | NAND_NO_AUTOINCR,
115 .init = nhk8815_nand_init,
116};
117
118static struct platform_device nhk8815_nand_device = {
119 .name = "nomadik_nand",
120 .dev = {
121 .platform_data = &nhk8815_nand_data,
122 },
123 .resource = nhk8815_nand_resources,
124 .num_resources = ARRAY_SIZE(nhk8815_nand_resources),
125};
126
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200127/* These are the partitions for the OneNand device, different from above */
128static struct mtd_partition nhk8815_onenand_partitions[] = {
129 {
130 .name = "X-Loader(OneNAND)",
131 .offset = 0,
132 .size = SZ_256K,
133 }, {
134 .name = "MemInit(OneNAND)",
135 .offset = MTDPART_OFS_APPEND,
136 .size = SZ_256K,
137 }, {
138 .name = "BootLoader(OneNAND)",
139 .offset = MTDPART_OFS_APPEND,
140 .size = SZ_2M-SZ_256K,
141 }, {
142 .name = "SysImage(OneNAND)",
143 .offset = MTDPART_OFS_APPEND,
144 .size = 4 * SZ_1M,
145 }, {
146 .name = "Root Filesystem(OneNAND)",
147 .offset = MTDPART_OFS_APPEND,
148 .size = 22 * SZ_1M,
149 }, {
150 .name = "User Filesystem(OneNAND)",
151 .offset = MTDPART_OFS_APPEND,
152 .size = MTDPART_SIZ_FULL,
153 }
154};
155
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200156static struct onenand_platform_data nhk8815_onenand_data = {
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200157 .parts = nhk8815_onenand_partitions,
158 .nr_parts = ARRAY_SIZE(nhk8815_onenand_partitions),
159};
160
161static struct resource nhk8815_onenand_resource[] = {
162 {
163 .start = 0x30000000,
164 .end = 0x30000000 + SZ_128K - 1,
165 .flags = IORESOURCE_MEM,
166 },
167};
168
169static struct platform_device nhk8815_onenand_device = {
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200170 .name = "onenand-flash",
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200171 .id = -1,
172 .dev = {
173 .platform_data = &nhk8815_onenand_data,
174 },
175 .resource = nhk8815_onenand_resource,
176 .num_resources = ARRAY_SIZE(nhk8815_onenand_resource),
177};
178
179static void __init nhk8815_onenand_init(void)
180{
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200181#ifdef CONFIG_MTD_ONENAND
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200182 /* Set up SMCS0 for OneNand */
Alessandro Rubinic1558b52009-09-20 23:28:24 +0200183 writel(0x000030db, FSMC_BCR(0));
184 writel(0x02100551, FSMC_BTR(0));
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200185#endif
186}
Alessandro Rubini63234712009-07-29 18:51:56 +0200187
Russell King53d68af2011-12-18 15:28:51 +0000188static AMBA_APB_DEVICE(uart0, "uart0", 0, NOMADIK_UART0_BASE,
189 { IRQ_UART0 }, NULL);
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100190
Russell King53d68af2011-12-18 15:28:51 +0000191static AMBA_APB_DEVICE(uart1, "uart1", 0, NOMADIK_UART1_BASE,
192 { IRQ_UART1 }, NULL);
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100193
194static struct amba_device *amba_devs[] __initdata = {
195 &uart0_device,
196 &uart1_device,
197};
198
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100199static struct resource nhk8815_eth_resources[] = {
200 {
201 .name = "smc91x-regs",
202 .start = 0x34000000 + 0x300,
203 .end = 0x34000000 + SZ_64K - 1,
204 .flags = IORESOURCE_MEM,
205 }, {
206 .start = NOMADIK_GPIO_TO_IRQ(115),
207 .end = NOMADIK_GPIO_TO_IRQ(115),
208 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
209 }
210};
211
212static struct platform_device nhk8815_eth_device = {
213 .name = "smc91x",
214 .resource = nhk8815_eth_resources,
215 .num_resources = ARRAY_SIZE(nhk8815_eth_resources),
216};
217
218static int __init nhk8815_eth_init(void)
219{
220 int gpio_nr = 115; /* hardwired in the board */
221 int err;
222
223 err = gpio_request(gpio_nr, "eth_irq");
224 if (!err) err = nmk_gpio_set_mode(gpio_nr, NMK_GPIO_ALT_GPIO);
225 if (!err) err = gpio_direction_input(gpio_nr);
226 if (err)
227 pr_err("Error %i in %s\n", err, __func__);
228 return err;
229}
230device_initcall(nhk8815_eth_init);
231
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100232static struct platform_device *nhk8815_platform_devices[] __initdata = {
Alessandro Rubini63234712009-07-29 18:51:56 +0200233 &nhk8815_nand_device,
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200234 &nhk8815_onenand_device,
Alessandro Rubini725b1f92009-07-02 15:29:32 +0100235 &nhk8815_eth_device,
236 /* will add more devices */
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100237};
238
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +0100239static void __init nomadik_timer_init(void)
240{
241 u32 src_cr;
242
243 /* Configure timer sources in "system reset controller" ctrl reg */
244 src_cr = readl(io_p2v(NOMADIK_SRC_BASE));
245 src_cr &= SRC_CR_INIT_MASK;
246 src_cr |= SRC_CR_INIT_VAL;
247 writel(src_cr, io_p2v(NOMADIK_SRC_BASE));
248
Linus Walleijb9576622012-01-11 09:46:59 +0100249 nmdk_timer_init(io_p2v(NOMADIK_MTU0_BASE));
Srinidhi Kasagar59b559d2009-11-12 06:20:54 +0100250}
251
252static struct sys_timer nomadik_timer = {
253 .init = nomadik_timer_init,
254};
255
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100256static void __init nhk8815_platform_init(void)
257{
258 int i;
259
260 cpu8815_platform_init();
Alessandro Rubini8b85e7c2009-07-24 13:30:04 +0200261 nhk8815_onenand_init();
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100262 platform_add_devices(nhk8815_platform_devices,
263 ARRAY_SIZE(nhk8815_platform_devices));
264
Rabin Vincentdc6048c2010-05-06 10:47:25 +0100265 for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100266 amba_device_register(amba_devs[i], &iomem_resource);
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100267}
268
269MACHINE_START(NOMADIK, "NHK8815")
270 /* Maintainer: ST MicroElectronics */
Nicolas Pitre013b5fb2011-07-05 22:38:14 -0400271 .atag_offset = 0x100,
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100272 .map_io = cpu8815_map_io,
273 .init_irq = cpu8815_init_irq,
Jamie Iles42ab5302011-09-27 20:25:51 +0100274 .handle_irq = vic_handle_irq,
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100275 .timer = &nomadik_timer,
276 .init_machine = nhk8815_platform_init,
Russell King35b47a4052011-11-28 10:48:02 +0000277 .restart = cpu8815_restart,
Alessandro Rubini28ad94e2009-07-02 19:06:47 +0100278MACHINE_END