2 * linux/arch/arm/mach-nomadik/board-8815nhk.c
4 * Copyright (C) STMicroelectronics
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.
10 * NHK15 board specifc driver definition
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>
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>
34 /* These adresses span 16MB, so use three individual pages */
35 static struct resource nhk8815_nand_resources[] = {
38 .start = NAND_IO_ADDR,
39 .end = NAND_IO_ADDR + 0xfff,
40 .flags = IORESOURCE_MEM,
44 .end = NAND_IO_CMD + 0xfff,
45 .flags = IORESOURCE_MEM,
48 .start = NAND_IO_DATA,
49 .end = NAND_IO_DATA + 0xfff,
50 .flags = IORESOURCE_MEM,
54 static int nhk8815_nand_init(void)
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));
61 /* enable access to the chip select area */
62 writel(readl(FSMC_PCR(0)) | 0x04, FSMC_PCR(0));
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...
72 static struct mtd_partition nhk8815_partitions[] = {
74 .name = "X-Loader(NAND)",
78 .name = "MemInit(NAND)",
79 .offset = MTDPART_OFS_APPEND,
82 .name = "BootLoader(NAND)",
83 .offset = MTDPART_OFS_APPEND,
86 .name = "Kernel zImage(NAND)",
87 .offset = MTDPART_OFS_APPEND,
90 .name = "Root Filesystem(NAND)",
91 .offset = MTDPART_OFS_APPEND,
94 .name = "User Filesystem(NAND)",
95 .offset = MTDPART_OFS_APPEND,
96 .size = MTDPART_SIZ_FULL,
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,
108 static struct platform_device nhk8815_nand_device = {
109 .name = "nomadik_nand",
111 .platform_data = &nhk8815_nand_data,
113 .resource = nhk8815_nand_resources,
114 .num_resources = ARRAY_SIZE(nhk8815_nand_resources),
117 /* These are the partitions for the OneNand device, different from above */
118 static struct mtd_partition nhk8815_onenand_partitions[] = {
120 .name = "X-Loader(OneNAND)",
124 .name = "MemInit(OneNAND)",
125 .offset = MTDPART_OFS_APPEND,
128 .name = "BootLoader(OneNAND)",
129 .offset = MTDPART_OFS_APPEND,
130 .size = SZ_2M-SZ_256K,
132 .name = "SysImage(OneNAND)",
133 .offset = MTDPART_OFS_APPEND,
136 .name = "Root Filesystem(OneNAND)",
137 .offset = MTDPART_OFS_APPEND,
140 .name = "User Filesystem(OneNAND)",
141 .offset = MTDPART_OFS_APPEND,
142 .size = MTDPART_SIZ_FULL,
146 static struct onenand_platform_data nhk8815_onenand_data = {
147 .parts = nhk8815_onenand_partitions,
148 .nr_parts = ARRAY_SIZE(nhk8815_onenand_partitions),
151 static struct resource nhk8815_onenand_resource[] = {
154 .end = 0x30000000 + SZ_128K - 1,
155 .flags = IORESOURCE_MEM,
159 static struct platform_device nhk8815_onenand_device = {
160 .name = "onenand-flash",
163 .platform_data = &nhk8815_onenand_data,
165 .resource = nhk8815_onenand_resource,
166 .num_resources = ARRAY_SIZE(nhk8815_onenand_resource),
169 static void __init nhk8815_onenand_init(void)
171 #ifdef CONFIG_MTD_ONENAND
172 /* Set up SMCS0 for OneNand */
173 writel(0x000030db, FSMC_BCR(0));
174 writel(0x02100551, FSMC_BTR(0));
178 #define __MEM_4K_RESOURCE(x) \
179 .res = {.start = (x), .end = (x) + SZ_4K - 1, .flags = IORESOURCE_MEM}
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},
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},
193 static struct amba_device *amba_devs[] __initdata = {
198 /* We have a fixed clock alone, by now */
199 static struct clk nhk8815_clk_48 = {
200 .rate = 48*1000*1000,
203 static struct resource nhk8815_eth_resources[] = {
205 .name = "smc91x-regs",
206 .start = 0x34000000 + 0x300,
207 .end = 0x34000000 + SZ_64K - 1,
208 .flags = IORESOURCE_MEM,
210 .start = NOMADIK_GPIO_TO_IRQ(115),
211 .end = NOMADIK_GPIO_TO_IRQ(115),
212 .flags = IORESOURCE_IRQ | IRQF_TRIGGER_RISING,
216 static struct platform_device nhk8815_eth_device = {
218 .resource = nhk8815_eth_resources,
219 .num_resources = ARRAY_SIZE(nhk8815_eth_resources),
222 static int __init nhk8815_eth_init(void)
224 int gpio_nr = 115; /* hardwired in the board */
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);
231 pr_err("Error %i in %s\n", err, __func__);
234 device_initcall(nhk8815_eth_init);
236 static struct platform_device *nhk8815_platform_devices[] __initdata = {
237 &nhk8815_nand_device,
238 &nhk8815_onenand_device,
240 /* will add more devices */
243 static void __init nhk8815_platform_init(void)
247 cpu8815_platform_init();
248 nhk8815_onenand_init();
249 platform_add_devices(nhk8815_platform_devices,
250 ARRAY_SIZE(nhk8815_platform_devices));
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);
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,